Skip to content

Commit 859cc3d

Browse files
committed
Fix uischemas change depencency
1 parent c75b163 commit 859cc3d

File tree

5 files changed

+61
-57
lines changed

5 files changed

+61
-57
lines changed

packages/example/src/enhancements.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,14 @@ export const enhancements = () => {
5757
'apply': (props: JsonFormsInitStateProps) => {
5858
return {
5959
...props,
60-
uischemas: [
61-
{ tester: nestedArray.nestedArrayTester, uischema: nestedArray.nestedArrayLayout }
62-
]
60+
uischemas: nestedArray.uischemas
6361
}
6462
}
6563
},
6664
{
6765
'label': 'Unregister NestedArray UISchema',
6866
'apply': (props: JsonFormsInitStateProps) => {
69-
const uischemas: JsonFormsUISchemaRegistryEntry[] = [];
67+
const uischemas: JsonFormsUISchemaRegistryEntry[] = undefined;
7068
return {
7169
...props,
7270
uischemas: uischemas
@@ -80,16 +78,14 @@ export const enhancements = () => {
8078
'apply': (props: JsonFormsInitStateProps) => {
8179
return {
8280
...props,
83-
uischemas: [
84-
{ tester: issue_1220.nestedArrayTester, schema: issue_1220.detail_uischema }
85-
]
81+
uischemas: issue_1220.uischemas
8682
}
8783
}
8884
},
8985
{
9086
'label': 'Unregister Issue 1220 UISchema',
9187
'apply': (props: JsonFormsInitStateProps) => {
92-
const uischemas: JsonFormsUISchemaRegistryEntry[] = [];
88+
const uischemas: JsonFormsUISchemaRegistryEntry[] = undefined;
9389
return {
9490
...props,
9591
uischemas: uischemas

packages/examples/src/example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
THE SOFTWARE.
2424
*/
25-
import { JsonSchema, UISchemaElement } from '@jsonforms/core';
25+
import { JsonFormsUISchemaRegistryEntry, JsonSchema, UISchemaElement } from '@jsonforms/core';
2626

2727
export interface ExampleDescription {
2828
name: string;
2929
label: string;
3030
data: any;
3131
schema: JsonSchema;
3232
uischema: UISchemaElement;
33-
uischemas?: any;
33+
uischemas?: JsonFormsUISchemaRegistryEntry[];
3434
config?: any;
3535
}

packages/examples/src/examples/1220.ts

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,44 @@ export const uischema = {
7272
type: 'Control',
7373
scope: '#/properties/orders'
7474
};
75-
export const detail_uischema = {
76-
type: 'VerticalLayout',
77-
elements: [
78-
{
79-
type: 'Control',
80-
scope: '#/properties/title'
81-
},
82-
{
83-
type: 'Control',
84-
scope: '#/properties/ordered'
75+
76+
export const uischemas = [
77+
{
78+
tester: (_jsonSchema: JsonSchema, schemaPath: string) => {
79+
return schemaPath === '#/properties/orders' ? 2 : NOT_APPLICABLE;
8580
},
86-
{
81+
uischema: {
8782
type: 'VerticalLayout',
8883
elements: [
8984
{
9085
type: 'Control',
91-
scope: '#/properties/assignee'
92-
}
93-
],
94-
rule: {
95-
effect: 'SHOW',
96-
condition: {
97-
type: 'LEAF',
98-
scope: '#/properties/ordered',
99-
expectedValue: true
86+
scope: '#/properties/title'
87+
},
88+
{
89+
type: 'Control',
90+
scope: '#/properties/ordered'
91+
},
92+
{
93+
type: 'VerticalLayout',
94+
elements: [
95+
{
96+
type: 'Control',
97+
scope: '#/properties/assignee'
98+
}
99+
],
100+
rule: {
101+
effect: 'SHOW',
102+
condition: {
103+
type: 'LEAF',
104+
scope: '#/properties/ordered',
105+
expectedValue: true
106+
}
107+
}
100108
}
101-
}
102-
}
103-
]
104-
};
109+
]
110+
},
111+
},
112+
];
105113

106114
registerExamples([
107115
{
@@ -112,7 +120,3 @@ registerExamples([
112120
uischema
113121
}
114122
]);
115-
116-
export const nestedArrayTester = (_jsonSchema: JsonSchema, schemaPath: string) => {
117-
return schemaPath === '#/properties/orders' ? 2 : NOT_APPLICABLE;
118-
};

packages/examples/src/examples/nestedArrays.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
THE SOFTWARE.
2424
*/
2525
import { registerExamples } from '../register';
26-
import { ControlElement, JsonSchema, NOT_APPLICABLE, VerticalLayout } from '@jsonforms/core';
26+
import { ControlElement, JsonSchema, NOT_APPLICABLE } from '@jsonforms/core';
2727

2828
const schema = {
2929
type: 'object',
@@ -69,16 +69,6 @@ const data = {
6969
]
7070
};
7171

72-
registerExamples([
73-
{
74-
name: 'nestedArray',
75-
label: 'Nested Array',
76-
data,
77-
schema,
78-
uischema
79-
}
80-
]);
81-
8272
const control1: ControlElement = {
8373
type: 'Control',
8474
scope: '#/properties/name'
@@ -88,11 +78,25 @@ const control2: ControlElement = {
8878
type: 'Control',
8979
scope: '#/properties/choices'
9080
};
91-
export const nestedArrayLayout: VerticalLayout = {
92-
type: 'VerticalLayout',
93-
elements: [control1, control2]
94-
};
9581

96-
export const nestedArrayTester = (_jsonSchema: JsonSchema, schemaPath: string) => {
97-
return schemaPath === '#/properties/exampleArray' ? 2 : NOT_APPLICABLE;
98-
};
82+
export const uischemas = [
83+
{
84+
tester: (_jsonSchema: JsonSchema, schemaPath: string) => {
85+
return schemaPath === '#/properties/exampleArray' ? 2 : NOT_APPLICABLE;
86+
},
87+
uischema: {
88+
type: 'VerticalLayout',
89+
elements: [control1, control2]
90+
}
91+
}
92+
]
93+
94+
registerExamples([
95+
{
96+
name: 'nestedArray',
97+
label: 'Nested Array',
98+
data,
99+
schema,
100+
uischema
101+
}
102+
]);

packages/react/src/JsonFormsContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const JsonFormsStateProvider = ({ children, initState, onChange }: any) =
158158
i18n: i18n,
159159
// only core dispatch available
160160
dispatch: coreDispatch,
161-
}), [core, initState.renderers, initState.cells, config, initState.readonly, i18n]);
161+
}), [core, initState.renderers, initState.cells, config, initState.uischemas, initState.readonly, i18n]);
162162

163163
const onChangeRef = useRef(onChange);
164164
useEffect(() => {

0 commit comments

Comments
 (0)