@jsonforms/material-renderers 3.0.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.
Files changed (102) hide show
  1. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  2. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  3. package/lib/controls/index.d.ts +2 -2
  4. package/lib/jsonforms-react-material.cjs.js +84 -17
  5. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  6. package/lib/jsonforms-react-material.esm.js +85 -18
  7. package/lib/jsonforms-react-material.esm.js.map +1 -1
  8. package/lib/mui-controls/MuiCheckbox.d.ts +6 -1
  9. package/lib/mui-controls/MuiToggle.d.ts +6 -1
  10. package/package.json +23 -12
  11. package/src/additional/ListWithDetailMasterItem.tsx +1 -1
  12. package/src/complex/TableToolbar.tsx +3 -3
  13. package/src/controls/MaterialBooleanControl.tsx +84 -23
  14. package/src/controls/MaterialBooleanToggleControl.tsx +84 -23
  15. package/src/layouts/ArrayToolbar.tsx +2 -3
  16. package/src/mui-controls/MuiCheckbox.tsx +12 -5
  17. package/src/mui-controls/MuiToggle.tsx +12 -5
  18. package/docs/assets/css/main.css +0 -1
  19. package/docs/assets/images/icons.png +0 -0
  20. package/docs/assets/images/icons@2x.png +0 -0
  21. package/docs/assets/images/widgets.png +0 -0
  22. package/docs/assets/images/widgets@2x.png +0 -0
  23. package/docs/assets/js/main.js +0 -51
  24. package/docs/assets/js/search.json +0 -1
  25. package/docs/classes/combinatorproperties.html +0 -957
  26. package/docs/classes/materialanyofstringorenumcontrol.html +0 -822
  27. package/docs/classes/materialtablecontrol.html +0 -999
  28. package/docs/globals.html +0 -4492
  29. package/docs/index.html +0 -753
  30. package/docs/interfaces/ajvprops.html +0 -162
  31. package/docs/interfaces/arraylayouttoolbarprops.html +0 -253
  32. package/docs/interfaces/categorizationstate.html +0 -154
  33. package/docs/interfaces/categorizationstepperstate.html +0 -154
  34. package/docs/interfaces/combinatorpropertiesprops.html +0 -182
  35. package/docs/interfaces/deletedialogprops.html +0 -225
  36. package/docs/interfaces/dispatchpropsofexpandpanel.html +0 -296
  37. package/docs/interfaces/emptytableprops.html +0 -154
  38. package/docs/interfaces/expandpanelprops.html +0 -594
  39. package/docs/interfaces/inputref.html +0 -168
  40. package/docs/interfaces/jsonformstheme.html +0 -352
  41. package/docs/interfaces/materialcategorizationlayoutrendererprops.html +0 -460
  42. package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +0 -394
  43. package/docs/interfaces/materiallabelablelayoutrendererprops.html +0 -328
  44. package/docs/interfaces/materiallayoutrendererprops.html +0 -317
  45. package/docs/interfaces/materialtabletoolbarprops.html +0 -302
  46. package/docs/interfaces/muitextinputprops.html +0 -168
  47. package/docs/interfaces/nonemptycellcomponentprops.html +0 -266
  48. package/docs/interfaces/nonemptycellprops.html +0 -277
  49. package/docs/interfaces/nonemptyrowprops.html +0 -366
  50. package/docs/interfaces/ownoneofprops.html +0 -308
  51. package/docs/interfaces/ownpropsofexpandpanel.html +0 -397
  52. package/docs/interfaces/ownpropsofnonemptycell.html +0 -229
  53. package/docs/interfaces/statepropsofexpandpanel.html +0 -445
  54. package/docs/interfaces/tableheadercellprops.html +0 -154
  55. package/docs/interfaces/tablerowsprop.html +0 -330
  56. package/docs/interfaces/validationprops.html +0 -168
  57. package/docs/interfaces/withdeletedialogsupport.html +0 -170
  58. package/docs/interfaces/withinput.html +0 -154
  59. package/docs/interfaces/withoptionlabel.html +0 -230
  60. package/example/index.html +0 -16
  61. package/example/index.ts +0 -31
  62. package/rollup.config.js +0 -51
  63. package/stats.html +0 -3279
  64. package/test/renderers/MatchMediaMock.ts +0 -36
  65. package/test/renderers/MaterialAllOfRenderer.test.tsx +0 -114
  66. package/test/renderers/MaterialAnyOfRenderer.test.tsx +0 -310
  67. package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +0 -126
  68. package/test/renderers/MaterialArrayControl.test.tsx +0 -633
  69. package/test/renderers/MaterialArrayLayout.test.tsx +0 -528
  70. package/test/renderers/MaterialBooleanCell.test.tsx +0 -374
  71. package/test/renderers/MaterialBooleanToggleCell.test.tsx +0 -466
  72. package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -469
  73. package/test/renderers/MaterialCategorizationLayout.test.tsx +0 -458
  74. package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +0 -647
  75. package/test/renderers/MaterialDateCell.test.tsx +0 -303
  76. package/test/renderers/MaterialDateControl.test.tsx +0 -411
  77. package/test/renderers/MaterialDateTimeControl.test.tsx +0 -417
  78. package/test/renderers/MaterialEnumArrayRenderer.test.tsx +0 -207
  79. package/test/renderers/MaterialEnumCell.test.tsx +0 -88
  80. package/test/renderers/MaterialEnumControl.test.tsx +0 -75
  81. package/test/renderers/MaterialGroupLayout.test.tsx +0 -90
  82. package/test/renderers/MaterialInputControl.test.tsx +0 -370
  83. package/test/renderers/MaterialIntegerCell.test.tsx +0 -333
  84. package/test/renderers/MaterialLabelRenderer.test.tsx +0 -114
  85. package/test/renderers/MaterialLayouts.test.tsx +0 -542
  86. package/test/renderers/MaterialListWithDetailRenderer.test.tsx +0 -279
  87. package/test/renderers/MaterialNativeControl.test.tsx +0 -81
  88. package/test/renderers/MaterialNumberCell.test.tsx +0 -382
  89. package/test/renderers/MaterialObjectControl.test.tsx +0 -186
  90. package/test/renderers/MaterialOneOfEnumCell.test.tsx +0 -94
  91. package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +0 -108
  92. package/test/renderers/MaterialOneOfRenderer.test.tsx +0 -603
  93. package/test/renderers/MaterialRadioGroupControl.test.tsx +0 -125
  94. package/test/renderers/MaterialSliderControl.test.tsx +0 -438
  95. package/test/renderers/MaterialTextCell.test.tsx +0 -541
  96. package/test/renderers/MaterialTextControl.test.tsx +0 -115
  97. package/test/renderers/MaterialTimeCell.test.tsx +0 -331
  98. package/test/renderers/MaterialTimeControl.test.tsx +0 -411
  99. package/test/renderers/util.ts +0 -50
  100. package/tsconfig.json +0 -13
  101. package/tsconfig.test.json +0 -7
  102. package/webpack/webpack.dev.js +0 -11
@@ -1,647 +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 MaterialCategorizationStepperLayoutRenderer, {
41
- materialCategorizationStepperTester
42
- } from '../../src/layouts/MaterialCategorizationStepperLayout';
43
- import { MaterialLayoutRenderer, materialRenderers } from '../../src';
44
- import { Button, Step, Stepper } 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 stepper layout tester', () => {
80
- it('should not fail when given undefined data', () => {
81
- expect(materialCategorizationStepperTester(undefined, undefined, undefined)).toBe(-1);
82
- expect(materialCategorizationStepperTester(null, undefined, undefined)).toBe(-1);
83
- expect(
84
- materialCategorizationStepperTester({ type: 'Foo' }, undefined, undefined)
85
- ).toBe(-1);
86
- expect(
87
- materialCategorizationStepperTester({ type: 'Categorization' }, undefined, undefined)
88
- ).toBe(-1);
89
- });
90
-
91
- it('should not fail with null elements and no schema', () => {
92
- const uischema: Layout = {
93
- type: 'Categorization',
94
- elements: null
95
- };
96
- expect(materialCategorizationStepperTester(uischema, undefined, undefined)).toBe(-1);
97
- });
98
-
99
- it('should not fail with empty elements and no schema', () => {
100
- const uischema: Layout = {
101
- type: 'Categorization',
102
- elements: []
103
- };
104
- expect(materialCategorizationStepperTester(uischema, undefined, undefined)).toBe(-1);
105
- });
106
-
107
- it('should not fail tester with single unknown element and no schema', () => {
108
- const uischema: Layout = {
109
- type: 'Categorization',
110
- elements: [
111
- {
112
- type: 'Foo'
113
- }
114
- ]
115
- };
116
- expect(materialCategorizationStepperTester(uischema, undefined, undefined)).toBe(-1);
117
- });
118
-
119
- it('should not apply to a single category and no schema', () => {
120
- const categorization = {
121
- type: 'Categorization',
122
- elements: [
123
- {
124
- type: 'Category'
125
- }
126
- ]
127
- };
128
- expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
129
- -1
130
- );
131
- });
132
-
133
- it('should not apply to a nested categorization with single category and no schema', () => {
134
- const nestedCategorization: Layout = {
135
- type: 'Categorization',
136
- elements: [
137
- {
138
- type: 'Category'
139
- }
140
- ]
141
- };
142
- const categorization: Layout = {
143
- type: 'Categorization',
144
- elements: [nestedCategorization]
145
- };
146
- expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
147
- -1
148
- );
149
- });
150
-
151
- it('should not apply to nested categorizations without categories and no schema', () => {
152
- const categorization: any = {
153
- type: 'Categorization',
154
- elements: [
155
- {
156
- type: 'Categorization'
157
- }
158
- ]
159
- };
160
- expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
161
- -1
162
- );
163
- });
164
-
165
- it('should not apply to a nested categorization with null elements and no schema', () => {
166
- const categorization: any = {
167
- type: 'Categorization',
168
- elements: [
169
- {
170
- type: 'Categorization',
171
- label: 'Test',
172
- elements: null
173
- }
174
- ]
175
- };
176
-
177
- expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
178
- -1
179
- );
180
- });
181
-
182
- it('should not apply to a nested categorizations with empty elements and no schema', () => {
183
- const categorization: any = {
184
- type: 'Categorization',
185
- elements: [
186
- {
187
- type: 'Categorization',
188
- elements: []
189
- }
190
- ]
191
- };
192
- expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
193
- -1
194
- );
195
- });
196
- });
197
-
198
- describe('Material categorization stepper layout', () => {
199
- it('should render', () => {
200
- const nameControl = {
201
- type: 'Control',
202
- scope: '#/properties/name'
203
- };
204
- const uischema: Categorization = {
205
- type: 'Categorization',
206
- label: 'Root',
207
- elements: [
208
- {
209
- type: 'Categorization',
210
- label: 'Bar',
211
- elements: [
212
- {
213
- type: 'Category',
214
- label: 'A',
215
- elements: [nameControl]
216
- }
217
- ]
218
- },
219
- {
220
- type: 'Category',
221
- label: 'B',
222
- elements: [nameControl]
223
- }
224
- ]
225
- };
226
-
227
- const core = initCore(fixture.schema, fixture.uischema, fixture.data);
228
- const wrapper = mount(
229
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
230
- <MaterialCategorizationStepperLayoutRenderer
231
- {...testDefaultProps}
232
- schema={fixture.schema}
233
- uischema={uischema}
234
- />
235
- </JsonFormsStateProvider>
236
- );
237
- const steps = wrapper.find(Step);
238
- expect(steps.length).toBe(2);
239
- wrapper.unmount();
240
- });
241
-
242
- it('should render on click', () => {
243
- const data = { name: 'Foo' };
244
- const nameControl: ControlElement = {
245
- type: 'Control',
246
- scope: '#/properties/name'
247
- };
248
- const innerCategorization: Categorization = {
249
- type: 'Categorization',
250
- label: 'Bar',
251
- elements: [
252
- {
253
- type: 'Category',
254
- label: 'A',
255
- elements: [nameControl]
256
- }
257
- ]
258
- };
259
- const uischema: Categorization = {
260
- type: 'Categorization',
261
- label: 'Root',
262
- elements: [
263
- innerCategorization,
264
- {
265
- type: 'Category',
266
- label: 'B',
267
- elements: [nameControl, nameControl]
268
- },
269
- {
270
- type: 'Category',
271
- label: 'C',
272
- elements: undefined
273
- },
274
- {
275
- type: 'Category',
276
- label: 'D',
277
- elements: null
278
- }
279
- ]
280
- };
281
- const core = initCore(fixture.schema, fixture.uischema, data);
282
-
283
- const wrapper = mount(
284
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
285
- <MaterialCategorizationStepperLayoutRenderer
286
- {...testDefaultProps}
287
- schema={fixture.schema}
288
- uischema={uischema}
289
- />
290
- </JsonFormsStateProvider>
291
- );
292
- const beforeClick = wrapper.find(Stepper).props().activeStep;
293
- wrapper
294
- .find('button')
295
- .at(1)
296
- .simulate('click');
297
- const afterClick = wrapper.find(Stepper).props().activeStep;
298
-
299
- expect(beforeClick).toBe(0);
300
- expect(afterClick).toBe(1);
301
- wrapper.unmount();
302
- });
303
-
304
- it('can be hidden via ownProp', () => {
305
- const core = initCore(fixture.schema, fixture.uischema, fixture.data);
306
-
307
- const wrapper = mount(
308
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
309
- <MaterialCategorizationStepperLayoutRenderer
310
- {...testDefaultProps}
311
- schema={fixture.schema}
312
- uischema={fixture.uischema}
313
- visible={false}
314
- />
315
- </JsonFormsStateProvider>
316
- );
317
-
318
- expect(wrapper.find(Stepper).exists()).toBeFalsy();
319
- wrapper.unmount();
320
- });
321
-
322
- it('is shown by default', () => {
323
- const core = initCore(fixture.schema, fixture.uischema, fixture.data);
324
- const wrapper = mount(
325
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
326
- <MaterialCategorizationStepperLayoutRenderer
327
- {...testDefaultProps}
328
- schema={fixture.schema}
329
- uischema={fixture.uischema}
330
- />
331
- </JsonFormsStateProvider>
332
- );
333
-
334
- expect(wrapper.find(Stepper).exists()).toBeTruthy();
335
- wrapper.unmount();
336
- });
337
-
338
- it('allows categories to be hidden', () => {
339
- const condition: SchemaBasedCondition = {
340
- scope: '#/properties/name',
341
- schema: { minLength: 3 }
342
- };
343
-
344
- const uischema: Categorization = {
345
- type: 'Categorization',
346
- label: '',
347
- elements: [
348
- {
349
- type: 'Category',
350
- label: 'A',
351
- elements: []
352
- },
353
- {
354
- type: 'Category',
355
- label: 'B',
356
- elements: [],
357
- rule: {
358
- effect: RuleEffect.HIDE,
359
- condition
360
- }
361
- }
362
- ]
363
- };
364
- const core = initCore(fixture.schema, fixture.uischema, fixture.data);
365
- const wrapper = mount(
366
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
367
- <MaterialCategorizationStepperLayoutRenderer
368
- {...testDefaultProps}
369
- schema={fixture.schema}
370
- uischema={uischema}
371
- />
372
- </JsonFormsStateProvider>
373
- );
374
-
375
- expect(wrapper.find(Step).length).toBe(1);
376
- wrapper.unmount();
377
- });
378
-
379
- it('should have renderers prop via ownProps', () => {
380
- const core = initCore(fixture.schema, fixture.uischema, fixture.data);
381
- const renderers: any[] = [];
382
- const wrapper = mount(
383
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
384
- <MaterialCategorizationStepperLayoutRenderer
385
- {...testDefaultProps}
386
- schema={fixture.schema}
387
- uischema={fixture.uischema}
388
- renderers={renderers}
389
- />
390
- </JsonFormsStateProvider>
391
- );
392
-
393
- const materialArrayLayout = wrapper.find(MaterialLayoutRenderer);
394
- expect(materialArrayLayout.props().renderers).toHaveLength(0);
395
- });
396
-
397
- it('should render nav buttons if showNavButtons is set', () => {
398
- const nameControl: ControlElement = {
399
- type: 'Control',
400
- scope: '#/properties/name'
401
- };
402
- const uischema: Categorization = {
403
- type: 'Categorization',
404
- label: 'Root',
405
- options: {
406
- showNavButtons: true
407
- },
408
- elements: [
409
- {
410
- type: 'Category',
411
- label: 'B',
412
- elements: [nameControl, nameControl]
413
- },
414
- {
415
- type: 'Category',
416
- label: 'C',
417
- elements: undefined
418
- }
419
- ]
420
- };
421
- const core = initCore(fixture.schema, uischema, fixture.data);
422
-
423
- const wrapper = mount(
424
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
425
- <MaterialCategorizationStepperLayoutRenderer
426
- {...testDefaultProps}
427
- schema={fixture.schema}
428
- uischema={uischema}
429
- />
430
- </JsonFormsStateProvider>
431
- );
432
- const isPrevButtonEnabledBeforeClick = !wrapper.find(Button).at(1).props().disabled;
433
- const isNextButtonEnabledBeforeClick = !wrapper.find(Button).at(0).props().disabled;
434
- wrapper
435
- .find('button')
436
- .at(1)
437
- .simulate('click');
438
- const isPrevButtonEnabledAfterClick = !wrapper.find(Button).at(1).props().disabled;
439
- const isNextButtonEnabledAfterClick = !wrapper.find(Button).at(0).props().disabled;
440
-
441
- expect(isPrevButtonEnabledBeforeClick).toBeFalsy();
442
- expect(isNextButtonEnabledBeforeClick).toBeTruthy();
443
- expect(isPrevButtonEnabledAfterClick).toBeTruthy();
444
- expect(isNextButtonEnabledAfterClick).toBeFalsy();
445
- wrapper.unmount();
446
- });
447
-
448
- it('should render new category on button click', () => {
449
- const nameControl: ControlElement = {
450
- type: 'Control',
451
- scope: '#/properties/name'
452
- };
453
- const innerCategorization: Categorization = {
454
- type: 'Categorization',
455
- label: 'Bar',
456
- elements: [
457
- {
458
- type: 'Category',
459
- label: 'A',
460
- elements: [nameControl]
461
- }
462
- ]
463
- };
464
- const uischema: Categorization = {
465
- type: 'Categorization',
466
- label: 'Root',
467
- options: {
468
- showNavButtons: true
469
- },
470
- elements: [
471
- innerCategorization,
472
- {
473
- type: 'Category',
474
- label: 'B',
475
- elements: [nameControl, nameControl]
476
- },
477
- {
478
- type: 'Category',
479
- label: 'C',
480
- elements: undefined
481
- },
482
- {
483
- type: 'Category',
484
- label: 'D',
485
- elements: null
486
- }
487
- ]
488
- };
489
- const core = initCore(fixture.schema, uischema, fixture.data);
490
-
491
- const wrapper = mount(
492
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
493
- <MaterialCategorizationStepperLayoutRenderer
494
- {...testDefaultProps}
495
- schema={fixture.schema}
496
- uischema={uischema}
497
- />
498
- </JsonFormsStateProvider>
499
- );
500
- const activeStepBeforeClick = wrapper.find(Stepper).props().activeStep;
501
- wrapper
502
- .find('button')
503
- .at(4)
504
- .simulate('click');
505
- const activeStepAfterClick = wrapper.find(Stepper).props().activeStep;
506
-
507
- expect(activeStepBeforeClick).toBe(0);
508
- expect(activeStepAfterClick).toBe(1);
509
- wrapper.unmount();
510
- });
511
-
512
- it('nav button behavior after hiding a step', () => {
513
- const data = { name : 'fo' };
514
- const condition: SchemaBasedCondition = {
515
- scope: '#/properties/name',
516
- schema: { maxLength: 3 }
517
- };
518
-
519
- const nameControl: ControlElement = {
520
- type: 'Control',
521
- scope: '#/properties/name'
522
- };
523
-
524
- const uischema: Categorization = {
525
- type: 'Categorization',
526
- label: 'Root',
527
- options: {
528
- showNavButtons: true
529
- },
530
- elements: [
531
- {
532
- type: 'Category',
533
- label: 'B',
534
- elements: [nameControl]
535
- },
536
- {
537
- type: 'Category',
538
- label: 'C',
539
- elements: undefined,
540
- rule: {
541
- effect: RuleEffect.SHOW,
542
- condition
543
- }
544
- }
545
- ]
546
- };
547
-
548
- const core = initCore(fixture.schema, uischema, data);
549
-
550
- const wrapper = mount(
551
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
552
- <MaterialCategorizationStepperLayoutRenderer
553
- {...testDefaultProps}
554
- schema={fixture.schema}
555
- uischema={uischema}
556
- />
557
- </JsonFormsStateProvider>
558
- );
559
-
560
- const isNextButtonDisabledBeforeTextInput = wrapper.find(Button).at(0).props().disabled;
561
-
562
- expect(isNextButtonDisabledBeforeTextInput).toBe(false);
563
-
564
- core.data = { ...core.data, name: 'Barr' };
565
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
566
- wrapper.update();
567
-
568
- const isNextButtonDisabledAfterTextInput = wrapper.find(Button).at(0).props().disabled;
569
-
570
- expect(isNextButtonDisabledAfterTextInput).toBe(true);
571
-
572
- wrapper.unmount();
573
- });
574
-
575
- it('display correct content when hiding a step', () => {
576
- const data = { name : 'fo' };
577
- const condition: SchemaBasedCondition = {
578
- scope: '#/properties/name',
579
- schema: { maxLength: 3 }
580
- };
581
- const nameControl: ControlElement = {
582
- type: 'Control',
583
- scope: '#/properties/name'
584
- };
585
- const uischema: Categorization = {
586
- type: 'Categorization',
587
- label: '',
588
- options: {
589
- showNavButtons: true
590
- },
591
- elements: [
592
- {
593
- type: 'Category',
594
- label: 'A',
595
- elements: undefined
596
- },
597
- {
598
- type: 'Category',
599
- label: 'B',
600
- elements: undefined,
601
- rule: {
602
- effect: RuleEffect.SHOW,
603
- condition: condition
604
- }
605
- },
606
- {
607
- type: 'Category',
608
- label: 'C',
609
- elements: [nameControl],
610
- rule: {
611
- effect: RuleEffect.HIDE,
612
- condition: condition
613
- }
614
- }
615
- ]
616
- };
617
-
618
- const core = initCore(fixture.schema, uischema, data);
619
-
620
- const wrapper = mount(
621
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
622
- <MaterialCategorizationStepperLayoutRenderer
623
- {...testDefaultProps}
624
- schema={fixture.schema}
625
- uischema={uischema}
626
- />
627
- </JsonFormsStateProvider>
628
- );
629
-
630
- wrapper
631
- .find('button')
632
- .at(1)
633
- .simulate('click');
634
-
635
- let isCategoryCshown = wrapper.find('input[type="text"]').length > 0;
636
- expect(isCategoryCshown).toBe(false);
637
-
638
- core.data = { ...core.data, name: 'Barr' };
639
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
640
- wrapper.update();
641
-
642
- isCategoryCshown = wrapper.find('input[type="text"]').length > 0;
643
- expect(isCategoryCshown).toBe(true);
644
-
645
- wrapper.unmount();
646
- });
647
- });