@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,125 +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 * as React from 'react';
27
- import {
28
- ControlElement,
29
- NOT_APPLICABLE
30
- } from '@jsonforms/core';
31
- import MaterialRadioGroupControl, { materialRadioGroupControlTester } from '../../src/controls/MaterialRadioGroupControl';
32
- import { materialRenderers } from '../../src';
33
- import Enzyme, { mount, ReactWrapper } from 'enzyme';
34
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
35
- import { JsonFormsStateProvider } from '@jsonforms/react';
36
- import { initCore } from './util';
37
- Enzyme.configure({ adapter: new Adapter() });
38
-
39
- const data = { foo: 'D' };
40
- const schema = {
41
- type: 'object',
42
- properties: {
43
- foo: {
44
- type: 'string',
45
- enum: ['A', 'B', 'C', 'D']
46
- }
47
- }
48
- };
49
- const uischema: ControlElement = {
50
- type: 'Control',
51
- scope: '#/properties/foo',
52
- options: {
53
- format: 'radio'
54
- }
55
- };
56
-
57
- describe('Material radio group tester', () => {
58
- it('should return valid rank for enums with radio format', () => {
59
- const rank = materialRadioGroupControlTester(uischema, schema, undefined);
60
- expect(rank).not.toBe(NOT_APPLICABLE);
61
- });
62
-
63
- it('should return NOT_APPLICABLE for enums without radio format', () => {
64
- const uiSchemaNoRadio = {
65
- type: 'Control',
66
- scope: '#/properties/foo'
67
- };
68
- const rank = materialRadioGroupControlTester(uiSchemaNoRadio, schema, undefined);
69
- expect(rank).toBe(NOT_APPLICABLE);
70
- });
71
- });
72
-
73
- describe('Material radio group control', () => {
74
- let wrapper: ReactWrapper;
75
-
76
- afterEach(() => wrapper.unmount());
77
-
78
- it('should have option selected', () => {
79
- const core = initCore(schema, uischema, data);
80
- wrapper = mount(
81
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
82
- <MaterialRadioGroupControl schema={schema} uischema={uischema} />
83
- </JsonFormsStateProvider>
84
- );
85
-
86
- const radioButtons = wrapper.find('input[type="radio"]');
87
- const currentlyChecked = wrapper.find('input[type="radio"][checked=true]');
88
- expect(radioButtons.length).toBe(4);
89
- expect(currentlyChecked.first().props().value).toBe('D');
90
- });
91
-
92
- it('should have only update selected option ', () => {
93
- const core = initCore(schema, uischema, data);
94
-
95
- core.data = { ...core.data, foo: 'A' };
96
- core.data = { ...core.data, foo: 'B' };
97
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
98
- wrapper.update();
99
-
100
- wrapper = mount(
101
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
102
- <MaterialRadioGroupControl schema={schema} uischema={uischema} />
103
- </JsonFormsStateProvider>
104
- );
105
- const currentlyChecked = wrapper.find('input[type="radio"][checked=true]');
106
- expect(currentlyChecked.length).toBe(1);
107
- expect(currentlyChecked.first().props().value).toBe('B');
108
- });
109
-
110
- it('should be hideable ', () => {
111
- const core = initCore(schema, uischema, data);
112
- wrapper = mount(
113
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
114
- <MaterialRadioGroupControl
115
- schema={schema}
116
- uischema={uischema}
117
- visible={false}
118
- />
119
- </JsonFormsStateProvider>
120
- );
121
-
122
- const radioButtons = wrapper.find('input[type="radio"]');
123
- expect(radioButtons.length).toBe(0);
124
- });
125
- });
@@ -1,438 +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 * as React from 'react';
27
- import {
28
- ControlElement,
29
- JsonSchema,
30
- NOT_APPLICABLE
31
- } from '@jsonforms/core';
32
- import SliderControl, {
33
- materialSliderControlTester
34
- } from '../../src/controls/MaterialSliderControl';
35
- import { materialRenderers } from '../../src';
36
- import { Slider } from '@mui/material';
37
-
38
- import Enzyme, { mount, ReactWrapper } from 'enzyme';
39
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
40
- import { JsonForms, JsonFormsStateProvider } from '@jsonforms/react';
41
- import { initCore } from './util';
42
-
43
- Enzyme.configure({ adapter: new Adapter() });
44
-
45
- const data: any = { foo: 5 };
46
- const schema = {
47
- type: 'object',
48
- properties: {
49
- foo: {
50
- type: 'number',
51
- maximum: 10,
52
- minimum: 2,
53
- default: 6
54
- }
55
- }
56
- };
57
- const uischema: ControlElement = {
58
- type: 'Control',
59
- scope: '#/properties/foo',
60
- options: {
61
- slider: true
62
- }
63
- };
64
-
65
- describe('Material slider tester', () => {
66
- it('should fail', () => {
67
- expect(materialSliderControlTester(undefined, undefined, undefined)).toBe(
68
- NOT_APPLICABLE
69
- );
70
- expect(materialSliderControlTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
71
- expect(materialSliderControlTester({ type: 'Foo' }, undefined, undefined)).toBe(
72
- NOT_APPLICABLE
73
- );
74
- expect(materialSliderControlTester({ type: 'Control' }, undefined, undefined)).toBe(
75
- NOT_APPLICABLE
76
- );
77
- });
78
-
79
- it('should fail with wrong schema type', () => {
80
- expect(
81
- materialSliderControlTester(uischema, {
82
- type: 'object',
83
- properties: {
84
- foo: { type: 'string' }
85
- }
86
- },
87
- undefined)
88
- ).toBe(NOT_APPLICABLE);
89
- });
90
-
91
- it('should fail if only sibling has correct prop type', () => {
92
- expect(
93
- materialSliderControlTester(uischema, {
94
- type: 'object',
95
- properties: {
96
- foo: { type: 'string' },
97
- bar: { type: 'number' }
98
- }
99
- },
100
- undefined)
101
- ).toBe(NOT_APPLICABLE);
102
- });
103
-
104
- it('should fail if maximum and minimum are missing', () => {
105
- expect(
106
- materialSliderControlTester(uischema, {
107
- type: 'object',
108
- properties: {
109
- foo: { type: 'number' }
110
- }
111
- },
112
- undefined)
113
- ).toBe(NOT_APPLICABLE);
114
- });
115
-
116
- it('should fail if maximum is missing', () => {
117
- expect(
118
- materialSliderControlTester(uischema, {
119
- type: 'object',
120
- properties: {
121
- foo: {
122
- type: 'number',
123
- minimum: 2
124
- }
125
- }
126
- },
127
- undefined)
128
- ).toBe(NOT_APPLICABLE);
129
- });
130
-
131
- it('should fail if minimum is missing', () => {
132
- expect(
133
- materialSliderControlTester(uischema, {
134
- type: 'object',
135
- properties: {
136
- foo: {
137
- type: 'number',
138
- maximum: 10
139
- }
140
- }
141
- },
142
- undefined)
143
- ).toBe(NOT_APPLICABLE);
144
- });
145
-
146
- it('should fail is default is missing', () => {
147
- expect(
148
- materialSliderControlTester(uischema, {
149
- type: 'object',
150
- properties: {
151
- foo: {
152
- type: 'number',
153
- maximum: 10,
154
- minimum: 2
155
- }
156
- }
157
- },
158
- undefined)
159
- ).toBe(NOT_APPLICABLE);
160
- });
161
-
162
- it('should succeed with number type', () => {
163
- expect(
164
- materialSliderControlTester(uischema, {
165
- type: 'object',
166
- properties: {
167
- foo: {
168
- type: 'number',
169
- maximum: 10,
170
- minimum: 2,
171
- default: 6
172
- }
173
- }
174
- },
175
- undefined)
176
- ).toBe(4);
177
- });
178
-
179
- it('should succeed with integer type', () => {
180
- expect(
181
- materialSliderControlTester(uischema, {
182
- type: 'object',
183
- properties: {
184
- foo: {
185
- type: 'integer',
186
- maximum: 10,
187
- minimum: 2,
188
- default: 6
189
- }
190
- }
191
- },
192
- undefined)
193
- ).toBe(4);
194
- });
195
- });
196
-
197
- describe('Material slider control', () => {
198
- let wrapper: ReactWrapper;
199
-
200
- afterEach(() => wrapper.unmount());
201
-
202
- it('should render', () => {
203
- const jsonSchema: JsonSchema = {
204
- type: 'object',
205
- properties: {
206
- foo: {
207
- type: 'number',
208
- maximum: 10,
209
- minimum: 2,
210
- default: 6
211
- }
212
- }
213
- };
214
- const core = initCore(jsonSchema, uischema, data);
215
- wrapper = mount(
216
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
217
- <SliderControl
218
- schema={jsonSchema}
219
- uischema={uischema}
220
- />
221
- </JsonFormsStateProvider>
222
- );
223
- const input = wrapper.find(Slider).first();
224
- expect(input.props().value).toBe(5);
225
- });
226
-
227
- it('should update via action', () => {
228
- let data = {
229
- foo: 3
230
- };
231
- wrapper = mount(
232
- <JsonForms
233
- data={data}
234
- schema={schema}
235
- uischema={uischema}
236
- renderers={materialRenderers}
237
- />
238
- );
239
- expect(wrapper.find(SliderControl).length).toBeTruthy();
240
- let slider = wrapper.find(Slider).first();
241
- expect(slider.props().value).toBe(3);
242
- data = { ...data, foo: 4 };
243
- wrapper.setProps({ data: data });
244
- wrapper.update();
245
- slider = wrapper.find(Slider).first();
246
- expect(slider.props().value).toBe(4);
247
- });
248
-
249
- it('should honor multipleOf', () => {
250
- const schemaWithMultipleOf = {
251
- type: 'object',
252
- properties: {
253
- foo: {
254
- type: 'number',
255
- maximum: 10,
256
- minimum: 2,
257
- default: 6,
258
- multipleOf: 2
259
- }
260
- }
261
- };
262
- const data = {
263
- foo: 6
264
- };
265
- wrapper = mount(
266
- <JsonForms
267
- data={data}
268
- schema={schemaWithMultipleOf}
269
- uischema={uischema}
270
- renderers={materialRenderers}
271
- />
272
- );
273
- expect(wrapper.find(SliderControl).length).toBeTruthy();
274
- const input = wrapper.find(Slider).first();
275
- expect(input.props().step).toBe(2);
276
- });
277
-
278
- it('should not update with undefined value', () => {
279
- wrapper = mount(
280
- <JsonForms
281
- data={data}
282
- schema={schema}
283
- uischema={uischema}
284
- renderers={materialRenderers}
285
- />
286
- );
287
- expect(wrapper.find(SliderControl).length).toBeTruthy();
288
- const newData = { ...data, foo: undefined };
289
- wrapper.setProps({ data: newData });
290
- wrapper.update();
291
- const input = wrapper.find(Slider);
292
- expect(input.props().value).toBe(schema.properties.foo.default);
293
- });
294
-
295
- it('should not update with null value', () => {
296
- wrapper = mount(
297
- <JsonForms
298
- data={data}
299
- schema={schema}
300
- uischema={uischema}
301
- renderers={materialRenderers}
302
- />
303
- );
304
- expect(wrapper.find(SliderControl).length).toBeTruthy();
305
- const newData = { ...data, foo: null };
306
- wrapper.setProps({ data: newData });
307
- wrapper.update();
308
- const slider = wrapper.find(Slider).first();
309
- expect(slider.props().value).toBe(schema.properties.foo.default);
310
- });
311
-
312
- it('should not update with wrong ref', () => {
313
- wrapper = mount(
314
- <JsonForms
315
- data={data}
316
- schema={schema}
317
- uischema={uischema}
318
- renderers={materialRenderers}
319
- />
320
- );
321
- expect(wrapper.find(SliderControl).length).toBeTruthy();
322
- const newData = { ...data, bar: 11 };
323
- wrapper.setProps({ data: newData });
324
- wrapper.update();
325
- const input = wrapper.find(Slider).first();
326
- expect(input.props().value).toBe(5);
327
- });
328
-
329
- it('should not update with null ref', () => {
330
- wrapper = mount(
331
- <JsonForms
332
- data={data}
333
- schema={schema}
334
- uischema={uischema}
335
- renderers={materialRenderers}
336
- />
337
- );
338
- expect(wrapper.find(SliderControl).length).toBeTruthy();
339
- const newData = { ...data, null: 3 };
340
- wrapper.setProps({ data: newData });
341
- wrapper.update();
342
- const input = wrapper.find(Slider).first();
343
- expect(input.props().value).toBe(5);
344
- });
345
-
346
- it('should not update with undefined ref', () => {
347
- wrapper = mount(
348
- <JsonForms
349
- data={data}
350
- schema={schema}
351
- uischema={uischema}
352
- renderers={materialRenderers}
353
- />
354
- );
355
- expect(wrapper.find(SliderControl).length).toBeTruthy();
356
- const newData = { ...data, undefined: 13 };
357
- wrapper.setProps({ data: newData });
358
- wrapper.update();
359
- const input = wrapper.find(Slider).first();
360
- expect(input.props().value).toBe(5);
361
- });
362
-
363
- it('can be disabled', () => {
364
- const core = initCore(schema, uischema, data);
365
- wrapper = mount(
366
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
367
- <SliderControl
368
- schema={schema}
369
- uischema={uischema}
370
- enabled={false}
371
- />
372
- </JsonFormsStateProvider>
373
- );
374
- const input = wrapper.find(Slider).first();
375
- expect(input.props().disabled).toBeTruthy();
376
- });
377
-
378
- it('should be enabled by default', () => {
379
- wrapper = mount(
380
- <JsonForms
381
- data={data}
382
- schema={schema}
383
- uischema={uischema}
384
- renderers={materialRenderers}
385
- />
386
- );
387
- expect(wrapper.find(SliderControl).length).toBeTruthy();
388
- const input = wrapper.find(Slider).first();
389
- expect(input.props().disabled).toBeFalsy();
390
- });
391
-
392
- it('should render id and input id', () => {
393
- const core = initCore(schema, uischema, data);
394
- wrapper = mount(
395
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
396
- <SliderControl
397
- schema={schema}
398
- uischema={uischema}
399
- id='#/properties/foo'
400
- />
401
- </JsonFormsStateProvider>
402
- );
403
- const divs = wrapper.find('div');
404
- // id
405
- expect(divs.find((d: any) => d.id === '#/properties/foo')).toBeDefined();
406
- // input id
407
- expect(
408
- divs.find((d: any) => d.id === '#/properties/foo-input')
409
- ).toBeDefined();
410
- });
411
-
412
- it('should be hideable', () => {
413
- const jsonSchema: JsonSchema = {
414
- type: 'object',
415
- properties: {
416
- foo: {
417
- type: 'number',
418
- maximum: 10,
419
- minimum: 2,
420
- default: 6
421
- }
422
- }
423
- };
424
- const core = initCore(schema, uischema, { foo: 5 });
425
- wrapper = mount(
426
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
427
- <SliderControl
428
- schema={jsonSchema}
429
- uischema={uischema}
430
- visible={false}
431
- />
432
- </JsonFormsStateProvider>
433
- );
434
-
435
- const inputs = wrapper.find(Slider);
436
- expect(inputs.length).toBe(0);
437
- });
438
- });