@jsonforms/material-renderers 3.1.0-alpha.0 → 3.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/index.d.ts +2 -2
- package/lib/jsonforms-react-material.cjs.js +79 -11
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +79 -11
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/mui-controls/MuiCheckbox.d.ts +6 -1
- package/lib/mui-controls/MuiToggle.d.ts +6 -1
- package/package.json +23 -12
- package/src/additional/ListWithDetailMasterItem.tsx +1 -1
- package/src/controls/MaterialBooleanControl.tsx +84 -23
- package/src/controls/MaterialBooleanToggleControl.tsx +84 -23
- package/src/mui-controls/MuiCheckbox.tsx +12 -5
- package/src/mui-controls/MuiToggle.tsx +12 -5
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/combinatorproperties.html +0 -957
- package/docs/classes/materialanyofstringorenumcontrol.html +0 -822
- package/docs/classes/materialtablecontrol.html +0 -999
- package/docs/globals.html +0 -4492
- package/docs/index.html +0 -753
- package/docs/interfaces/ajvprops.html +0 -162
- package/docs/interfaces/arraylayouttoolbarprops.html +0 -253
- package/docs/interfaces/categorizationstate.html +0 -154
- package/docs/interfaces/categorizationstepperstate.html +0 -154
- package/docs/interfaces/combinatorpropertiesprops.html +0 -182
- package/docs/interfaces/deletedialogprops.html +0 -225
- package/docs/interfaces/dispatchpropsofexpandpanel.html +0 -296
- package/docs/interfaces/emptytableprops.html +0 -154
- package/docs/interfaces/expandpanelprops.html +0 -594
- package/docs/interfaces/inputref.html +0 -168
- package/docs/interfaces/jsonformstheme.html +0 -352
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +0 -460
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +0 -394
- package/docs/interfaces/materiallabelablelayoutrendererprops.html +0 -328
- package/docs/interfaces/materiallayoutrendererprops.html +0 -317
- package/docs/interfaces/materialtabletoolbarprops.html +0 -302
- package/docs/interfaces/muitextinputprops.html +0 -168
- package/docs/interfaces/nonemptycellcomponentprops.html +0 -266
- package/docs/interfaces/nonemptycellprops.html +0 -277
- package/docs/interfaces/nonemptyrowprops.html +0 -366
- package/docs/interfaces/ownoneofprops.html +0 -308
- package/docs/interfaces/ownpropsofexpandpanel.html +0 -397
- package/docs/interfaces/ownpropsofnonemptycell.html +0 -229
- package/docs/interfaces/statepropsofexpandpanel.html +0 -445
- package/docs/interfaces/tableheadercellprops.html +0 -154
- package/docs/interfaces/tablerowsprop.html +0 -330
- package/docs/interfaces/validationprops.html +0 -168
- package/docs/interfaces/withdeletedialogsupport.html +0 -170
- package/docs/interfaces/withinput.html +0 -154
- package/docs/interfaces/withoptionlabel.html +0 -230
- package/example/index.html +0 -16
- package/example/index.ts +0 -31
- package/rollup.config.js +0 -51
- package/stats.html +0 -3279
- package/test/renderers/MatchMediaMock.ts +0 -36
- package/test/renderers/MaterialAllOfRenderer.test.tsx +0 -114
- package/test/renderers/MaterialAnyOfRenderer.test.tsx +0 -310
- package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +0 -126
- package/test/renderers/MaterialArrayControl.test.tsx +0 -633
- package/test/renderers/MaterialArrayLayout.test.tsx +0 -528
- package/test/renderers/MaterialBooleanCell.test.tsx +0 -374
- package/test/renderers/MaterialBooleanToggleCell.test.tsx +0 -466
- package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -469
- package/test/renderers/MaterialCategorizationLayout.test.tsx +0 -458
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +0 -647
- package/test/renderers/MaterialDateCell.test.tsx +0 -303
- package/test/renderers/MaterialDateControl.test.tsx +0 -411
- package/test/renderers/MaterialDateTimeControl.test.tsx +0 -417
- package/test/renderers/MaterialEnumArrayRenderer.test.tsx +0 -207
- package/test/renderers/MaterialEnumCell.test.tsx +0 -88
- package/test/renderers/MaterialEnumControl.test.tsx +0 -75
- package/test/renderers/MaterialGroupLayout.test.tsx +0 -90
- package/test/renderers/MaterialInputControl.test.tsx +0 -370
- package/test/renderers/MaterialIntegerCell.test.tsx +0 -333
- package/test/renderers/MaterialLabelRenderer.test.tsx +0 -114
- package/test/renderers/MaterialLayouts.test.tsx +0 -542
- package/test/renderers/MaterialListWithDetailRenderer.test.tsx +0 -279
- package/test/renderers/MaterialNativeControl.test.tsx +0 -81
- package/test/renderers/MaterialNumberCell.test.tsx +0 -382
- package/test/renderers/MaterialObjectControl.test.tsx +0 -186
- package/test/renderers/MaterialOneOfEnumCell.test.tsx +0 -94
- package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +0 -108
- package/test/renderers/MaterialOneOfRenderer.test.tsx +0 -603
- package/test/renderers/MaterialRadioGroupControl.test.tsx +0 -125
- package/test/renderers/MaterialSliderControl.test.tsx +0 -438
- package/test/renderers/MaterialTextCell.test.tsx +0 -541
- package/test/renderers/MaterialTextControl.test.tsx +0 -115
- package/test/renderers/MaterialTimeCell.test.tsx +0 -331
- package/test/renderers/MaterialTimeControl.test.tsx +0 -411
- package/test/renderers/util.ts +0 -50
- package/tsconfig.json +0 -13
- package/tsconfig.test.json +0 -7
- package/webpack/webpack.dev.js +0 -11
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import './MatchMediaMock';
|
|
26
|
-
import React from 'react';
|
|
27
|
-
import {
|
|
28
|
-
Categorization,
|
|
29
|
-
ControlElement,
|
|
30
|
-
createAjv,
|
|
31
|
-
defaultJsonFormsI18nState,
|
|
32
|
-
Layout,
|
|
33
|
-
layoutDefaultProps,
|
|
34
|
-
RuleEffect,
|
|
35
|
-
SchemaBasedCondition
|
|
36
|
-
} from '@jsonforms/core';
|
|
37
|
-
import { JsonFormsStateProvider } from '@jsonforms/react';
|
|
38
|
-
import Enzyme, { mount } from 'enzyme';
|
|
39
|
-
|
|
40
|
-
import MaterialCategorizationLayoutRenderer, {
|
|
41
|
-
materialCategorizationTester
|
|
42
|
-
} from '../../src/layouts/MaterialCategorizationLayout';
|
|
43
|
-
import { MaterialLayoutRenderer, materialRenderers } from '../../src';
|
|
44
|
-
import { Tab, Tabs } from '@mui/material';
|
|
45
|
-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
46
|
-
import { initCore } from './util';
|
|
47
|
-
|
|
48
|
-
Enzyme.configure({ adapter: new Adapter() });
|
|
49
|
-
|
|
50
|
-
const fixture = {
|
|
51
|
-
data: {},
|
|
52
|
-
schema: {
|
|
53
|
-
type: 'object',
|
|
54
|
-
properties: {
|
|
55
|
-
name: {
|
|
56
|
-
type: 'string'
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
uischema: {
|
|
61
|
-
type: 'Categorization',
|
|
62
|
-
elements: [
|
|
63
|
-
{
|
|
64
|
-
type: 'Category',
|
|
65
|
-
label: 'B'
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const testDefaultProps = {
|
|
72
|
-
...layoutDefaultProps,
|
|
73
|
-
data: fixture.data,
|
|
74
|
-
ajv: createAjv(),
|
|
75
|
-
t: defaultJsonFormsI18nState.translate,
|
|
76
|
-
locale: defaultJsonFormsI18nState.locale
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
describe('Material categorization layout tester', () => {
|
|
80
|
-
it('should not fail when given undefined data', () => {
|
|
81
|
-
expect(materialCategorizationTester(undefined, undefined, undefined)).toBe(-1);
|
|
82
|
-
expect(materialCategorizationTester(null, undefined, undefined)).toBe(-1);
|
|
83
|
-
expect(materialCategorizationTester({ type: 'Foo' }, undefined, undefined)).toBe(-1);
|
|
84
|
-
expect(
|
|
85
|
-
materialCategorizationTester({ type: 'Categorization' }, undefined, undefined)
|
|
86
|
-
).toBe(-1);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should not fail with null elements and no schema', () => {
|
|
90
|
-
const uischema: Layout = {
|
|
91
|
-
type: 'Categorization',
|
|
92
|
-
elements: null
|
|
93
|
-
};
|
|
94
|
-
expect(materialCategorizationTester(uischema, undefined, undefined)).toBe(-1);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should succeed with empty elements and no schema', () => {
|
|
98
|
-
const uischema: Layout = {
|
|
99
|
-
type: 'Categorization',
|
|
100
|
-
elements: []
|
|
101
|
-
};
|
|
102
|
-
expect(materialCategorizationTester(uischema, undefined, undefined)).toBe(1);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should not fail tester with single unknown element and no schema', () => {
|
|
106
|
-
const uischema: Layout = {
|
|
107
|
-
type: 'Categorization',
|
|
108
|
-
elements: [
|
|
109
|
-
{
|
|
110
|
-
type: 'Foo'
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
};
|
|
114
|
-
expect(materialCategorizationTester(uischema, undefined, undefined)).toBe(-1);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should succeed with a single category and no schema', () => {
|
|
118
|
-
const categorization = {
|
|
119
|
-
type: 'Categorization',
|
|
120
|
-
elements: [
|
|
121
|
-
{
|
|
122
|
-
type: 'Category'
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
};
|
|
126
|
-
expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(1);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should not apply to a nested categorization with single category and no schema', () => {
|
|
130
|
-
const nestedCategorization: Layout = {
|
|
131
|
-
type: 'Categorization',
|
|
132
|
-
elements: [
|
|
133
|
-
{
|
|
134
|
-
type: 'Category'
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
};
|
|
138
|
-
const categorization: Layout = {
|
|
139
|
-
type: 'Categorization',
|
|
140
|
-
elements: [nestedCategorization]
|
|
141
|
-
};
|
|
142
|
-
expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('should not apply to nested categorizations without categories and no schema', () => {
|
|
146
|
-
const categorization: any = {
|
|
147
|
-
type: 'Categorization',
|
|
148
|
-
elements: [
|
|
149
|
-
{
|
|
150
|
-
type: 'Categorization'
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('should not apply to a nested categorization with null elements and no schema', () => {
|
|
158
|
-
const categorization: any = {
|
|
159
|
-
type: 'Categorization',
|
|
160
|
-
elements: [
|
|
161
|
-
{
|
|
162
|
-
type: 'Categorization',
|
|
163
|
-
label: 'Test',
|
|
164
|
-
elements: null
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('should not apply to a nested categorizations with empty elements and no schema', () => {
|
|
173
|
-
const categorization: any = {
|
|
174
|
-
type: 'Categorization',
|
|
175
|
-
elements: [
|
|
176
|
-
{
|
|
177
|
-
type: 'Categorization',
|
|
178
|
-
elements: []
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
};
|
|
182
|
-
expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe('Material categorization layout', () => {
|
|
187
|
-
it('should render', () => {
|
|
188
|
-
const nameControl = {
|
|
189
|
-
type: 'Control',
|
|
190
|
-
scope: '#/properties/name'
|
|
191
|
-
};
|
|
192
|
-
const uischema: Categorization = {
|
|
193
|
-
type: 'Categorization',
|
|
194
|
-
label: 'Root',
|
|
195
|
-
elements: [
|
|
196
|
-
{
|
|
197
|
-
type: 'Categorization',
|
|
198
|
-
label: 'Bar',
|
|
199
|
-
elements: [
|
|
200
|
-
{
|
|
201
|
-
type: 'Category',
|
|
202
|
-
label: 'A',
|
|
203
|
-
elements: [nameControl]
|
|
204
|
-
}
|
|
205
|
-
]
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
type: 'Category',
|
|
209
|
-
label: 'B',
|
|
210
|
-
elements: [nameControl]
|
|
211
|
-
}
|
|
212
|
-
]
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
|
|
216
|
-
const wrapper = mount(
|
|
217
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
218
|
-
<MaterialCategorizationLayoutRenderer
|
|
219
|
-
{...testDefaultProps}
|
|
220
|
-
schema={fixture.schema}
|
|
221
|
-
uischema={uischema}
|
|
222
|
-
/>
|
|
223
|
-
</JsonFormsStateProvider>
|
|
224
|
-
);
|
|
225
|
-
const steps = wrapper.find(Tab);
|
|
226
|
-
expect(steps.length).toBe(2);
|
|
227
|
-
wrapper.unmount();
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('should render on click', () => {
|
|
231
|
-
const data = { name: 'Foo' };
|
|
232
|
-
const nameControl: ControlElement = {
|
|
233
|
-
type: 'Control',
|
|
234
|
-
scope: '#/properties/name'
|
|
235
|
-
};
|
|
236
|
-
const innerCategorization: Categorization = {
|
|
237
|
-
type: 'Categorization',
|
|
238
|
-
label: 'Bar',
|
|
239
|
-
elements: [
|
|
240
|
-
{
|
|
241
|
-
type: 'Category',
|
|
242
|
-
label: 'A',
|
|
243
|
-
elements: [nameControl]
|
|
244
|
-
}
|
|
245
|
-
]
|
|
246
|
-
};
|
|
247
|
-
const uischema: Categorization = {
|
|
248
|
-
type: 'Categorization',
|
|
249
|
-
label: 'Root',
|
|
250
|
-
elements: [
|
|
251
|
-
innerCategorization,
|
|
252
|
-
{
|
|
253
|
-
type: 'Category',
|
|
254
|
-
label: 'B',
|
|
255
|
-
elements: [nameControl, nameControl]
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
type: 'Category',
|
|
259
|
-
label: 'C',
|
|
260
|
-
elements: undefined
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
type: 'Category',
|
|
264
|
-
label: 'D',
|
|
265
|
-
elements: null
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
};
|
|
269
|
-
const core = initCore(fixture.schema, fixture.uischema, data);
|
|
270
|
-
|
|
271
|
-
const wrapper = mount(
|
|
272
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
273
|
-
<MaterialCategorizationLayoutRenderer
|
|
274
|
-
{...testDefaultProps}
|
|
275
|
-
schema={fixture.schema}
|
|
276
|
-
uischema={uischema}
|
|
277
|
-
/>
|
|
278
|
-
</JsonFormsStateProvider>
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
const beforeClick = wrapper.find(Tabs).props().value;
|
|
282
|
-
wrapper
|
|
283
|
-
.find('button[role="tab"]')
|
|
284
|
-
.at(1)
|
|
285
|
-
.simulate('click');
|
|
286
|
-
const afterClick = wrapper.find(Tabs).props().value;
|
|
287
|
-
|
|
288
|
-
expect(beforeClick).toBe(0);
|
|
289
|
-
expect(afterClick).toBe(1);
|
|
290
|
-
wrapper.unmount();
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('can be hidden via ownProp', () => {
|
|
294
|
-
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
|
|
295
|
-
|
|
296
|
-
const wrapper = mount(
|
|
297
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
298
|
-
<MaterialCategorizationLayoutRenderer
|
|
299
|
-
{...testDefaultProps}
|
|
300
|
-
schema={fixture.schema}
|
|
301
|
-
uischema={fixture.uischema}
|
|
302
|
-
visible={false}
|
|
303
|
-
/>
|
|
304
|
-
</JsonFormsStateProvider>
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
expect(wrapper.find(Tab).exists()).toBeFalsy();
|
|
308
|
-
wrapper.unmount();
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('is shown by default', () => {
|
|
312
|
-
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
|
|
313
|
-
const wrapper = mount(
|
|
314
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
315
|
-
<MaterialCategorizationLayoutRenderer
|
|
316
|
-
{...testDefaultProps}
|
|
317
|
-
schema={fixture.schema}
|
|
318
|
-
uischema={fixture.uischema}
|
|
319
|
-
/>
|
|
320
|
-
</JsonFormsStateProvider>
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
expect(wrapper.find(Tab).exists()).toBeTruthy();
|
|
324
|
-
wrapper.unmount();
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
it('allows categories to be hidden', () => {
|
|
328
|
-
const condition: SchemaBasedCondition = {
|
|
329
|
-
scope: '#/properties/name',
|
|
330
|
-
schema: { minLength: 3 }
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
const uischema: Categorization = {
|
|
334
|
-
type: 'Categorization',
|
|
335
|
-
label: '',
|
|
336
|
-
elements: [
|
|
337
|
-
{
|
|
338
|
-
type: 'Category',
|
|
339
|
-
label: 'A',
|
|
340
|
-
elements: []
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
type: 'Category',
|
|
344
|
-
label: 'B',
|
|
345
|
-
elements: [],
|
|
346
|
-
rule: {
|
|
347
|
-
effect: RuleEffect.HIDE,
|
|
348
|
-
condition
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
]
|
|
352
|
-
};
|
|
353
|
-
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
|
|
354
|
-
const wrapper = mount(
|
|
355
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
356
|
-
<MaterialCategorizationLayoutRenderer
|
|
357
|
-
{...testDefaultProps}
|
|
358
|
-
schema={fixture.schema}
|
|
359
|
-
uischema={uischema}
|
|
360
|
-
/>
|
|
361
|
-
</JsonFormsStateProvider>
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
expect(wrapper.find(Tab).length).toBe(1);
|
|
365
|
-
wrapper.unmount();
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it('should have renderers prop via ownProps', () => {
|
|
369
|
-
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
|
|
370
|
-
const renderers: any[] = [];
|
|
371
|
-
const wrapper = mount(
|
|
372
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
373
|
-
<MaterialCategorizationLayoutRenderer
|
|
374
|
-
{...testDefaultProps}
|
|
375
|
-
schema={fixture.schema}
|
|
376
|
-
uischema={fixture.uischema}
|
|
377
|
-
renderers={renderers}
|
|
378
|
-
/>
|
|
379
|
-
</JsonFormsStateProvider>
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
const materialArrayLayout = wrapper.find(MaterialLayoutRenderer);
|
|
383
|
-
expect(materialArrayLayout.props().renderers).toHaveLength(0);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it('display correct content when hiding a tab', () => {
|
|
387
|
-
const data = { name : 'fo' };
|
|
388
|
-
const condition: SchemaBasedCondition = {
|
|
389
|
-
scope: '#/properties/name',
|
|
390
|
-
schema: { maxLength: 3 }
|
|
391
|
-
};
|
|
392
|
-
const nameControl: ControlElement = {
|
|
393
|
-
type: 'Control',
|
|
394
|
-
scope: '#/properties/name'
|
|
395
|
-
};
|
|
396
|
-
const uischema: Categorization = {
|
|
397
|
-
type: 'Categorization',
|
|
398
|
-
label: '',
|
|
399
|
-
options: {
|
|
400
|
-
showNavButtons: true
|
|
401
|
-
},
|
|
402
|
-
elements: [
|
|
403
|
-
{
|
|
404
|
-
type: 'Category',
|
|
405
|
-
label: 'A',
|
|
406
|
-
elements: undefined
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
type: 'Category',
|
|
410
|
-
label: 'B',
|
|
411
|
-
elements: undefined,
|
|
412
|
-
rule: {
|
|
413
|
-
effect: RuleEffect.SHOW,
|
|
414
|
-
condition: condition
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
type: 'Category',
|
|
419
|
-
label: 'C',
|
|
420
|
-
elements: [nameControl],
|
|
421
|
-
rule: {
|
|
422
|
-
effect: RuleEffect.HIDE,
|
|
423
|
-
condition: condition
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
]
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
const core = initCore(fixture.schema, uischema, data);
|
|
430
|
-
|
|
431
|
-
const wrapper = mount(
|
|
432
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
433
|
-
<MaterialCategorizationLayoutRenderer
|
|
434
|
-
{...testDefaultProps}
|
|
435
|
-
schema={fixture.schema}
|
|
436
|
-
uischema={uischema}
|
|
437
|
-
/>
|
|
438
|
-
</JsonFormsStateProvider>
|
|
439
|
-
);
|
|
440
|
-
|
|
441
|
-
wrapper
|
|
442
|
-
.find('button[role="tab"]')
|
|
443
|
-
.at(1)
|
|
444
|
-
.simulate('click');
|
|
445
|
-
|
|
446
|
-
let isCategoryCshown = wrapper.find('input[type="text"]').length > 0;
|
|
447
|
-
expect(isCategoryCshown).toBe(false);
|
|
448
|
-
|
|
449
|
-
core.data = { ...core.data, name: 'Barr' };
|
|
450
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
451
|
-
wrapper.update();
|
|
452
|
-
|
|
453
|
-
isCategoryCshown = wrapper.find('input[type="text"]').length > 0;
|
|
454
|
-
expect(isCategoryCshown).toBe(true);
|
|
455
|
-
|
|
456
|
-
wrapper.unmount();
|
|
457
|
-
});
|
|
458
|
-
});
|