@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.
Files changed (100) 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 +79 -11
  5. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  6. package/lib/jsonforms-react-material.esm.js +79 -11
  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/controls/MaterialBooleanControl.tsx +84 -23
  13. package/src/controls/MaterialBooleanToggleControl.tsx +84 -23
  14. package/src/mui-controls/MuiCheckbox.tsx +12 -5
  15. package/src/mui-controls/MuiToggle.tsx +12 -5
  16. package/docs/assets/css/main.css +0 -1
  17. package/docs/assets/images/icons.png +0 -0
  18. package/docs/assets/images/icons@2x.png +0 -0
  19. package/docs/assets/images/widgets.png +0 -0
  20. package/docs/assets/images/widgets@2x.png +0 -0
  21. package/docs/assets/js/main.js +0 -51
  22. package/docs/assets/js/search.json +0 -1
  23. package/docs/classes/combinatorproperties.html +0 -957
  24. package/docs/classes/materialanyofstringorenumcontrol.html +0 -822
  25. package/docs/classes/materialtablecontrol.html +0 -999
  26. package/docs/globals.html +0 -4492
  27. package/docs/index.html +0 -753
  28. package/docs/interfaces/ajvprops.html +0 -162
  29. package/docs/interfaces/arraylayouttoolbarprops.html +0 -253
  30. package/docs/interfaces/categorizationstate.html +0 -154
  31. package/docs/interfaces/categorizationstepperstate.html +0 -154
  32. package/docs/interfaces/combinatorpropertiesprops.html +0 -182
  33. package/docs/interfaces/deletedialogprops.html +0 -225
  34. package/docs/interfaces/dispatchpropsofexpandpanel.html +0 -296
  35. package/docs/interfaces/emptytableprops.html +0 -154
  36. package/docs/interfaces/expandpanelprops.html +0 -594
  37. package/docs/interfaces/inputref.html +0 -168
  38. package/docs/interfaces/jsonformstheme.html +0 -352
  39. package/docs/interfaces/materialcategorizationlayoutrendererprops.html +0 -460
  40. package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +0 -394
  41. package/docs/interfaces/materiallabelablelayoutrendererprops.html +0 -328
  42. package/docs/interfaces/materiallayoutrendererprops.html +0 -317
  43. package/docs/interfaces/materialtabletoolbarprops.html +0 -302
  44. package/docs/interfaces/muitextinputprops.html +0 -168
  45. package/docs/interfaces/nonemptycellcomponentprops.html +0 -266
  46. package/docs/interfaces/nonemptycellprops.html +0 -277
  47. package/docs/interfaces/nonemptyrowprops.html +0 -366
  48. package/docs/interfaces/ownoneofprops.html +0 -308
  49. package/docs/interfaces/ownpropsofexpandpanel.html +0 -397
  50. package/docs/interfaces/ownpropsofnonemptycell.html +0 -229
  51. package/docs/interfaces/statepropsofexpandpanel.html +0 -445
  52. package/docs/interfaces/tableheadercellprops.html +0 -154
  53. package/docs/interfaces/tablerowsprop.html +0 -330
  54. package/docs/interfaces/validationprops.html +0 -168
  55. package/docs/interfaces/withdeletedialogsupport.html +0 -170
  56. package/docs/interfaces/withinput.html +0 -154
  57. package/docs/interfaces/withoptionlabel.html +0 -230
  58. package/example/index.html +0 -16
  59. package/example/index.ts +0 -31
  60. package/rollup.config.js +0 -51
  61. package/stats.html +0 -3279
  62. package/test/renderers/MatchMediaMock.ts +0 -36
  63. package/test/renderers/MaterialAllOfRenderer.test.tsx +0 -114
  64. package/test/renderers/MaterialAnyOfRenderer.test.tsx +0 -310
  65. package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +0 -126
  66. package/test/renderers/MaterialArrayControl.test.tsx +0 -633
  67. package/test/renderers/MaterialArrayLayout.test.tsx +0 -528
  68. package/test/renderers/MaterialBooleanCell.test.tsx +0 -374
  69. package/test/renderers/MaterialBooleanToggleCell.test.tsx +0 -466
  70. package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -469
  71. package/test/renderers/MaterialCategorizationLayout.test.tsx +0 -458
  72. package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +0 -647
  73. package/test/renderers/MaterialDateCell.test.tsx +0 -303
  74. package/test/renderers/MaterialDateControl.test.tsx +0 -411
  75. package/test/renderers/MaterialDateTimeControl.test.tsx +0 -417
  76. package/test/renderers/MaterialEnumArrayRenderer.test.tsx +0 -207
  77. package/test/renderers/MaterialEnumCell.test.tsx +0 -88
  78. package/test/renderers/MaterialEnumControl.test.tsx +0 -75
  79. package/test/renderers/MaterialGroupLayout.test.tsx +0 -90
  80. package/test/renderers/MaterialInputControl.test.tsx +0 -370
  81. package/test/renderers/MaterialIntegerCell.test.tsx +0 -333
  82. package/test/renderers/MaterialLabelRenderer.test.tsx +0 -114
  83. package/test/renderers/MaterialLayouts.test.tsx +0 -542
  84. package/test/renderers/MaterialListWithDetailRenderer.test.tsx +0 -279
  85. package/test/renderers/MaterialNativeControl.test.tsx +0 -81
  86. package/test/renderers/MaterialNumberCell.test.tsx +0 -382
  87. package/test/renderers/MaterialObjectControl.test.tsx +0 -186
  88. package/test/renderers/MaterialOneOfEnumCell.test.tsx +0 -94
  89. package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +0 -108
  90. package/test/renderers/MaterialOneOfRenderer.test.tsx +0 -603
  91. package/test/renderers/MaterialRadioGroupControl.test.tsx +0 -125
  92. package/test/renderers/MaterialSliderControl.test.tsx +0 -438
  93. package/test/renderers/MaterialTextCell.test.tsx +0 -541
  94. package/test/renderers/MaterialTextControl.test.tsx +0 -115
  95. package/test/renderers/MaterialTimeCell.test.tsx +0 -331
  96. package/test/renderers/MaterialTimeControl.test.tsx +0 -411
  97. package/test/renderers/util.ts +0 -50
  98. package/tsconfig.json +0 -13
  99. package/tsconfig.test.json +0 -7
  100. package/webpack/webpack.dev.js +0 -11
@@ -1,542 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2018-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 Enzyme, { mount } from 'enzyme';
28
- import { materialRenderers } from '../../src';
29
- import {
30
- ControlElement,
31
- Layout,
32
- RuleEffect,
33
- UISchemaElement
34
- } from '@jsonforms/core';
35
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
36
- import { JsonForms } from '@jsonforms/react';
37
-
38
- Enzyme.configure({ adapter: new Adapter() });
39
-
40
- const schema = {
41
- type: 'object',
42
- properties: {
43
- toggleTopLayout: {
44
- type: 'boolean'
45
- },
46
- topString: {
47
- type: 'string'
48
- },
49
- toggleMiddleLayout: {
50
- type: 'boolean'
51
- },
52
- middleNumber: {
53
- type: 'number'
54
- },
55
- toggleBottomLayout: {
56
- type: 'boolean'
57
- },
58
- bottomBoolean: {
59
- type: 'boolean'
60
- }
61
- }
62
- };
63
- const baseUischema = () => ({
64
- type: 'VerticalLayout',
65
- elements: [
66
- {
67
- type: 'Control',
68
- scope: '#/properties/topString'
69
- },
70
- {
71
- type: 'HorizontalLayout',
72
- elements: [
73
- {
74
- type: 'Control',
75
- scope: '#/properties/middleNumber'
76
- },
77
- {
78
- type: 'Group',
79
- label: 'group',
80
- elements: [
81
- {
82
- type: 'Control',
83
- scope: '#/properties/bottomBoolean'
84
- }
85
- ]
86
- }
87
- ]
88
- }
89
- ]
90
- });
91
-
92
- const rule = (effect: RuleEffect, propertyName: string) => ({
93
- effect: effect,
94
- condition: {
95
- scope: '#/properties/' + propertyName,
96
- schema: { const: true }
97
- }
98
- });
99
-
100
- const topRule = (rule: any, uischema: UISchemaElement) => {
101
- uischema.rule = rule;
102
- return uischema;
103
- };
104
- const topShowRule = (uischema: Layout) =>
105
- topRule(rule(RuleEffect.SHOW, 'toggleTopLayout'), uischema);
106
- const topEnableRule = (uischema: Layout) =>
107
- topRule(rule(RuleEffect.ENABLE, 'toggleTopLayout'), uischema);
108
-
109
- const middleRule = (rule: any, uischema: Layout) => {
110
- uischema.elements[1].rule = rule;
111
- return uischema;
112
- };
113
- const middleShowRule = (uischema: Layout) =>
114
- middleRule(rule(RuleEffect.SHOW, 'toggleMiddleLayout'), uischema);
115
- const middleEnableRule = (uischema: Layout) =>
116
- middleRule(rule(RuleEffect.ENABLE, 'toggleMiddleLayout'), uischema);
117
-
118
- const bottomRule = (rule: any, uischema: Layout) => {
119
- (uischema.elements[1] as Layout).elements[1].rule = rule;
120
- return uischema;
121
- };
122
- const bottomShowRule = (uischema: Layout) =>
123
- bottomRule(rule(RuleEffect.SHOW, 'toggleBottomLayout'), uischema);
124
- const bottomEnableRule = (uischema: Layout) =>
125
- bottomRule(rule(RuleEffect.ENABLE, 'toggleBottomLayout'), uischema);
126
-
127
- const controlRule = (rule: any, uischema: Layout) => {
128
- const group = (uischema.elements[1] as Layout).elements[1];
129
- (group as Layout).elements[0].rule = rule;
130
- return uischema;
131
- };
132
- const controlEnableRule = (uischema: Layout) =>
133
- controlRule(rule(RuleEffect.ENABLE, 'toggleControl'), uischema);
134
-
135
- describe('Layout Tests', () => {
136
- let wrapper: Enzyme.ReactWrapper;
137
-
138
- const createWrapper = (data: any, uischema: UISchemaElement) => {
139
- wrapper = mount(
140
- <JsonForms
141
- data={data}
142
- schema={schema}
143
- uischema={uischema}
144
- renderers={materialRenderers}
145
- />
146
- );
147
- };
148
-
149
- afterEach(() => {
150
- wrapper.unmount();
151
- });
152
-
153
- const controlIsShown = (control: string) => {
154
- switch (control) {
155
- case 'top':
156
- return wrapper.find('input[type="text"]').length > 0;
157
- case 'middle':
158
- return wrapper.find('input[type="number"]').length > 0;
159
- case 'bottom':
160
- return wrapper.find('input[type="checkbox"]').length > 0;
161
- default:
162
- fail('Should not happen, something is massively broken');
163
- }
164
- };
165
-
166
- const controlIsEnabled = (control: string) => {
167
- let foundControl;
168
- switch (control) {
169
- case 'top':
170
- foundControl = wrapper.find('input[type="text"]');
171
- break;
172
- case 'middle':
173
- foundControl = wrapper.find('input[type="number"]');
174
- break;
175
- case 'bottom':
176
- foundControl = wrapper.find('input[type="checkbox"]');
177
- break;
178
- default:
179
- fail('Should not happen, something is massively broken');
180
- }
181
- if (foundControl.length === 0) {
182
- fail('Control was expected to be rendered but could not be found');
183
- }
184
- return (
185
- foundControl.first().props().disabled === undefined ||
186
- !foundControl.first().props().disabled
187
- );
188
- };
189
-
190
- describe('Sanity Checks', () => {
191
- it('should render all inputs without rules', () => {
192
- // data doesn't matter
193
- const data = {
194
- toggleTopLayout: true,
195
- toggleMiddleLayout: true,
196
- toggleBottomLayout: true
197
- };
198
- createWrapper(data, baseUischema());
199
- expect(controlIsShown('top')).toBe(true);
200
- expect(controlIsShown('middle')).toBe(true);
201
- expect(controlIsShown('bottom')).toBe(true);
202
- });
203
-
204
- it('should render all inputs with all rules set to show', () => {
205
- const data = {
206
- toggleTopLayout: true,
207
- toggleMiddleLayout: true,
208
- toggleBottomLayout: true
209
- };
210
- const uischema = topShowRule(
211
- middleShowRule(bottomShowRule(baseUischema()))
212
- );
213
- createWrapper(data, uischema);
214
- expect(controlIsShown('top')).toBe(true);
215
- expect(controlIsShown('middle')).toBe(true);
216
- expect(controlIsShown('bottom')).toBe(true);
217
- });
218
-
219
- it('should enable all inputs with all rules set to enabled', () => {
220
- const data = {
221
- toggleTopLayout: true,
222
- toggleMiddleLayout: true,
223
- toggleBottomLayout: true
224
- };
225
- const uischema = topEnableRule(
226
- middleEnableRule(bottomEnableRule(baseUischema()))
227
- );
228
- createWrapper(data, uischema);
229
- expect(controlIsEnabled('top')).toBe(true);
230
- expect(controlIsEnabled('middle')).toBe(true);
231
- expect(controlIsEnabled('bottom')).toBe(true);
232
- });
233
- });
234
-
235
- describe('Single Rule', () => {
236
- it('hiding top should hide everything', () => {
237
- const data = {
238
- toggleTopLayout: false,
239
- toggleMiddleLayout: true,
240
- toggleBottomLayout: true
241
- };
242
- const uischema = topShowRule(baseUischema());
243
- createWrapper(data, uischema);
244
- expect(controlIsShown('top')).toBe(false);
245
- expect(controlIsShown('middle')).toBe(false);
246
- expect(controlIsShown('bottom')).toBe(false);
247
- });
248
-
249
- it('hiding middle should leave top', () => {
250
- const data = {
251
- toggleTopLayout: true,
252
- toggleMiddleLayout: false,
253
- toggleBottomLayout: true
254
- };
255
- const uischema = middleShowRule(baseUischema());
256
- createWrapper(data, uischema);
257
- expect(controlIsShown('top')).toBe(true);
258
- expect(controlIsShown('middle')).toBe(false);
259
- expect(controlIsShown('bottom')).toBe(false);
260
- });
261
-
262
- it('hiding bottom should leave top and middle', () => {
263
- const data = {
264
- toggleTopLayout: true,
265
- toggleMiddleLayout: true,
266
- toggleBottomLayout: false
267
- };
268
- const uischema = bottomShowRule(baseUischema());
269
- createWrapper(data, uischema);
270
- expect(controlIsShown('top')).toBe(true);
271
- expect(controlIsShown('middle')).toBe(true);
272
- expect(controlIsShown('bottom')).toBe(false);
273
- });
274
-
275
- it('disabling top should disable everything', () => {
276
- const data = {
277
- toggleTopLayout: false,
278
- toggleMiddleLayout: true,
279
- toggleBottomLayout: true
280
- };
281
- const uischema = topEnableRule(baseUischema());
282
- createWrapper(data, uischema);
283
- expect(controlIsEnabled('top')).toBe(false);
284
- expect(controlIsEnabled('middle')).toBe(false);
285
- expect(controlIsEnabled('bottom')).toBe(false);
286
- });
287
-
288
- it('disabling middle should leave top', () => {
289
- const data = {
290
- toggleTopLayout: true,
291
- toggleMiddleLayout: false,
292
- toggleBottomLayout: true
293
- };
294
- const uischema = middleEnableRule(baseUischema());
295
- createWrapper(data, uischema);
296
- expect(controlIsEnabled('top')).toBe(true);
297
- expect(controlIsEnabled('middle')).toBe(false);
298
- expect(controlIsEnabled('bottom')).toBe(false);
299
- });
300
-
301
- it('disabling bottom should leave top and middle', () => {
302
- const data = {
303
- toggleTopLayout: true,
304
- toggleMiddleLayout: true,
305
- toggleBottomLayout: false
306
- };
307
- const uischema = bottomEnableRule(baseUischema());
308
- createWrapper(data, uischema);
309
- expect(controlIsEnabled('top')).toBe(true);
310
- expect(controlIsEnabled('middle')).toBe(true);
311
- expect(controlIsEnabled('bottom')).toBe(false);
312
- });
313
-
314
- it('disabling control should disable control', () => {
315
- const data = {
316
- toggleTopLayout: true,
317
- toggleMiddleLayout: true,
318
- toggleBottomLayout: true,
319
- toggleControl: false
320
- };
321
- const uischema = controlEnableRule(baseUischema());
322
- createWrapper(data, uischema);
323
- expect(controlIsEnabled('top')).toBe(true);
324
- expect(controlIsEnabled('middle')).toBe(true);
325
- expect(controlIsEnabled('bottom')).toBe(false);
326
- });
327
- });
328
-
329
- describe('Rule Combinations', () => {
330
- it('disabling middle should disable bottom, even if it has a show rule', () => {
331
- const data = {
332
- toggleTopLayout: true,
333
- toggleMiddleLayout: false,
334
- toggleBottomLayout: true
335
- };
336
- const uischema = middleEnableRule(bottomShowRule(baseUischema()));
337
- createWrapper(data, uischema);
338
- expect(controlIsEnabled('top')).toBe(true);
339
- expect(controlIsEnabled('middle')).toBe(false);
340
- expect(controlIsEnabled('bottom')).toBe(false);
341
- });
342
-
343
- it('disabling layout and enabling control should enable control', () => {
344
- const data = {
345
- toggleTopLayout: true,
346
- toggleMiddleLayout: true,
347
- toggleBottomLayout: false,
348
- toggleControl: true
349
- };
350
- const uischema = bottomEnableRule(controlEnableRule(baseUischema()));
351
- createWrapper(data, uischema);
352
- expect(controlIsEnabled('top')).toBe(true);
353
- expect(controlIsEnabled('middle')).toBe(true);
354
- expect(controlIsEnabled('bottom')).toBe(true);
355
- });
356
- });
357
- });
358
-
359
- describe('Special Layout Tests', () => {
360
- describe('Categorization Tests', () => {
361
- const schema = {
362
- type: 'object',
363
- properties: {
364
- name: {
365
- type: 'string'
366
- },
367
- age: {
368
- type: 'integer'
369
- },
370
- topCheck: {
371
- type: 'boolean'
372
- },
373
- bottomCheck: {
374
- type: 'boolean'
375
- }
376
- }
377
- };
378
-
379
- const uischema = {
380
- type: 'Categorization',
381
- elements: [
382
- {
383
- type: 'Category',
384
- label: 'Private',
385
- elements: [
386
- {
387
- type: 'Control',
388
- scope: '#/properties/name',
389
- rule: {
390
- effect: RuleEffect.ENABLE,
391
- condition: {
392
- scope: '#/properties/bottomCheck',
393
- schema: {
394
- const: true
395
- }
396
- }
397
- }
398
- },
399
- {
400
- type: 'Control',
401
- scope: '#/properties/age'
402
- }
403
- ],
404
- rule: {
405
- effect: RuleEffect.ENABLE,
406
- condition: {
407
- scope: '#/properties/topCheck',
408
- schema: {
409
- const: true
410
- }
411
- }
412
- }
413
- }
414
- ]
415
- };
416
-
417
- it('enabling top rule and disabling bottom rule should disable control', () => {
418
- const data = {
419
- topCheck: true,
420
- bottomCheck: false
421
- };
422
- const wrapper = mount(
423
- <JsonForms
424
- data={data}
425
- schema={schema}
426
- uischema={uischema}
427
- renderers={materialRenderers}
428
- />
429
- );
430
- expect(
431
- wrapper
432
- .find('input[type="text"]')
433
- .first()
434
- .props().disabled
435
- ).toBe(true);
436
- });
437
-
438
- it('disabling top rule and enabling bottom rule should enable control', () => {
439
- const data = {
440
- topCheck: false,
441
- bottomCheck: true
442
- };
443
- const wrapper = mount(
444
- <JsonForms
445
- data={data}
446
- schema={schema}
447
- uischema={uischema}
448
- renderers={materialRenderers}
449
- />
450
- );
451
- expect(
452
- wrapper
453
- .find('input[type="text"]')
454
- .first()
455
- .props().disabled
456
- ).toBe(false);
457
- });
458
- });
459
-
460
- describe('Object Renderer Tests', () => {
461
- const schema = {
462
- type: 'object',
463
- properties: {
464
- name: {
465
- type: 'string'
466
- },
467
- age: {
468
- type: 'integer'
469
- },
470
- check: {
471
- type: 'boolean'
472
- }
473
- }
474
- };
475
-
476
- const uischema: ControlElement = {
477
- type: 'Control',
478
- scope: '#',
479
- rule: {
480
- effect: RuleEffect.ENABLE,
481
- condition: {
482
- scope: '#/properties/check',
483
- schema: {
484
- const: true
485
- }
486
- } as any
487
- }
488
- };
489
-
490
- it('enabling object control should enable child controls', () => {
491
- const data = {
492
- check: true
493
- };
494
- const wrapper = mount(
495
- <JsonForms
496
- data={data}
497
- schema={schema}
498
- uischema={uischema}
499
- renderers={materialRenderers}
500
- />
501
- );
502
- expect(
503
- wrapper
504
- .find('input[type="text"]')
505
- .first()
506
- .props().disabled
507
- ).toBe(false);
508
- expect(
509
- wrapper
510
- .find('input[type="number"]')
511
- .first()
512
- .props().disabled
513
- ).toBe(false);
514
- });
515
-
516
- it('disabling object control should disable child controls', () => {
517
- const data = {
518
- check: false
519
- };
520
- const wrapper = mount(
521
- <JsonForms
522
- data={data}
523
- schema={schema}
524
- uischema={uischema}
525
- renderers={materialRenderers}
526
- />
527
- );
528
- expect(
529
- wrapper
530
- .find('input[type="text"]')
531
- .first()
532
- .props().disabled
533
- ).toBe(true);
534
- expect(
535
- wrapper
536
- .find('input[type="number"]')
537
- .first()
538
- .props().disabled
539
- ).toBe(true);
540
- });
541
- });
542
- });