@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,374 +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 BooleanCell, {
32
- materialBooleanCellTester
33
- } from '../../src/cells/MaterialBooleanCell';
34
- import * as ReactDOM from 'react-dom';
35
- import { materialRenderers } from '../../src';
36
-
37
- import Enzyme, { mount, ReactWrapper } from 'enzyme';
38
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
39
- import { JsonFormsStateProvider } from '@jsonforms/react';
40
- import { initCore, TestEmitter } from './util';
41
-
42
- Enzyme.configure({ adapter: new Adapter() });
43
-
44
- const data = { foo: true };
45
- const schema = {
46
- type: 'boolean'
47
- };
48
- const uischema: ControlElement = {
49
- type: 'Control',
50
- scope: '#/properties/foo'
51
- };
52
-
53
- describe('Material boolean cell tester', () => {
54
- const control: ControlElement = {
55
- type: 'Control',
56
- scope: '#/properties/foo'
57
- };
58
-
59
- it('should fail', () => {
60
- expect(materialBooleanCellTester(undefined, undefined, undefined)).toBe(
61
- NOT_APPLICABLE
62
- );
63
- expect(materialBooleanCellTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
64
- expect(materialBooleanCellTester({ type: 'Foo' }, undefined, undefined)).toBe(
65
- NOT_APPLICABLE
66
- );
67
- expect(materialBooleanCellTester({ type: 'Control' }, undefined, undefined)).toBe(
68
- NOT_APPLICABLE
69
- );
70
- expect(
71
- materialBooleanCellTester(control, {
72
- type: 'object',
73
- properties: { foo: { type: 'string' } }
74
- },
75
- undefined)
76
- ).toBe(NOT_APPLICABLE);
77
- expect(
78
- materialBooleanCellTester(control, {
79
- type: 'object',
80
- properties: {
81
- foo: {
82
- type: 'string'
83
- },
84
- bar: {
85
- type: 'boolean'
86
- }
87
- }
88
- },
89
- undefined)
90
- ).toBe(NOT_APPLICABLE);
91
- });
92
-
93
- it('should succeed', () => {
94
- expect(
95
- materialBooleanCellTester(control, {
96
- type: 'object',
97
- properties: {
98
- foo: {
99
- type: 'boolean'
100
- }
101
- }
102
- },
103
- undefined)
104
- ).toBe(2);
105
- });
106
- });
107
-
108
- describe('Material boolean cell', () => {
109
- let wrapper: ReactWrapper;
110
-
111
- afterEach(() => wrapper.unmount());
112
-
113
- /** Use this container to render components */
114
- const container = document.createElement('div');
115
-
116
- afterEach(() => {
117
- ReactDOM.unmountComponentAtNode(container);
118
- });
119
-
120
- // seems to be broken in material-ui
121
- it('should autofocus via option', () => {
122
- const control: ControlElement = {
123
- type: 'Control',
124
- scope: '#/properties/foo',
125
- options: {
126
- focus: true
127
- }
128
- };
129
- const core = initCore(schema, uischema, data);
130
- wrapper = mount(
131
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
132
- <BooleanCell schema={schema} uischema={control} path='foo' />
133
- </JsonFormsStateProvider>
134
- );
135
- const input = wrapper.find('input').first();
136
- expect(input.props().autoFocus).toBeTruthy();
137
- });
138
-
139
- it('should not autofocus via option', () => {
140
- const control: ControlElement = {
141
- type: 'Control',
142
- scope: '#/properties/foo',
143
- options: {
144
- focus: false
145
- }
146
- };
147
- const core = initCore(schema, uischema, data);
148
- wrapper = mount(
149
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
150
- <BooleanCell schema={schema} uischema={control} path='foo' />
151
- </JsonFormsStateProvider>
152
- );
153
- const input = wrapper.find('input').first();
154
- expect(input.props().autoFocus).toBe(false);
155
- });
156
-
157
- it('should not autofocus by default', () => {
158
- const control: ControlElement = {
159
- type: 'Control',
160
- scope: '#/properties/foo'
161
- };
162
- const core = initCore(schema, uischema, data);
163
- wrapper = mount(
164
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
165
- <BooleanCell schema={schema} uischema={control} path='foo' />
166
- </JsonFormsStateProvider>
167
- );
168
- const input = wrapper.find('input').first();
169
- expect(input.props().autoFocus).toBeFalsy();
170
- });
171
-
172
- it('should render', () => {
173
- const core = initCore(schema, uischema, data);
174
- wrapper = mount(
175
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
176
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
177
- </JsonFormsStateProvider>
178
- );
179
-
180
- const input = wrapper.find('input').first();
181
- expect(input.props().type).toBe('checkbox');
182
- expect(input.props().checked).toBeTruthy();
183
- });
184
-
185
- it('should update via input event', () => {
186
- const core = initCore(schema, uischema, data);
187
- const onChangeData: any = {
188
- data: undefined
189
- };
190
- wrapper = mount(
191
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
192
- <TestEmitter
193
- onChange={({ data }) => {
194
- onChangeData.data = data;
195
- }}
196
- />
197
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
198
- </JsonFormsStateProvider>
199
- );
200
-
201
- const input = wrapper.find('input');
202
- input.simulate('change', { target: { value: false } });
203
- expect(onChangeData.data.foo).toBeFalsy();
204
- });
205
-
206
- it('should update via action', () => {
207
- const core = initCore(schema, uischema, data);
208
- const onChangeData: any = {
209
- data: undefined
210
- };
211
- wrapper = mount(
212
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
213
- <TestEmitter
214
- onChange={({ data }) => {
215
- onChangeData.data = data;
216
- }}
217
- />
218
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
219
- </JsonFormsStateProvider>
220
- );
221
- core.data = { ...core.data, foo: false };
222
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
223
- wrapper.update();
224
- const input = wrapper.find('input').first();
225
- expect(input.props().checked).toBeFalsy();
226
- expect(onChangeData.data.foo).toBeFalsy();
227
- });
228
-
229
- it('should update with undefined value', () => {
230
- const core = initCore(schema, uischema, data);
231
- const onChangeData: any = {
232
- data: undefined
233
- };
234
- wrapper = mount(
235
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
236
- <TestEmitter
237
- onChange={({ data }) => {
238
- onChangeData.data = data;
239
- }}
240
- />
241
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
242
- </JsonFormsStateProvider>
243
- );
244
- core.data = { ...core.data, foo: undefined };
245
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
246
- wrapper.update();
247
- const input = wrapper.find('input').first();
248
- expect(input.props().checked).toBeFalsy();
249
- });
250
-
251
- it('should update with null value', () => {
252
- const core = initCore(schema, uischema, data);
253
- const onChangeData: any = {
254
- data: undefined
255
- };
256
- wrapper = mount(
257
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
258
- <TestEmitter
259
- onChange={({ data }) => {
260
- onChangeData.data = data;
261
- }}
262
- />
263
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
264
- </JsonFormsStateProvider>
265
- );
266
- core.data = { ...core.data, foo: null };
267
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
268
- wrapper.update();
269
- const input = wrapper.find('input').first();
270
- expect(input.props().checked).toBeFalsy();
271
- });
272
-
273
- it('should not update with wrong ref', () => {
274
- const core = initCore(schema, uischema, data);
275
- const onChangeData: any = {
276
- data: undefined
277
- };
278
- wrapper = mount(
279
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
280
- <TestEmitter
281
- onChange={({ data }) => {
282
- onChangeData.data = data;
283
- }}
284
- />
285
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
286
- </JsonFormsStateProvider>
287
- );
288
- core.data = { ...core.data, bar: 11 };
289
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
290
- const input = wrapper.find('input').first();
291
- expect(input.props().checked).toBeTruthy();
292
- });
293
-
294
- it('should not update with null ref', () => {
295
- const core = initCore(schema, uischema, data);
296
- const onChangeData: any = {
297
- data: undefined
298
- };
299
- wrapper = mount(
300
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
301
- <TestEmitter
302
- onChange={({ data }) => {
303
- onChangeData.data = data;
304
- }}
305
- />
306
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
307
- </JsonFormsStateProvider>
308
- );
309
- core.data = { ...core.data, null: false };
310
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
311
- const input = wrapper.find('input').first();
312
- expect(input.props().checked).toBeTruthy();
313
- });
314
-
315
- it('should not update with an undefined ref', () => {
316
- const core = initCore(schema, uischema, data);
317
- const onChangeData: any = {
318
- data: undefined
319
- };
320
- wrapper = mount(
321
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
322
- <TestEmitter
323
- onChange={({ data }) => {
324
- onChangeData.data = data;
325
- }}
326
- />
327
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
328
- </JsonFormsStateProvider>
329
- );
330
- core.data = { ...core.data, undefined: false};
331
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
332
- wrapper.update();
333
- const input = wrapper.find('input').first();
334
- expect(input.props().checked).toBeTruthy();
335
- });
336
-
337
- it('can be disabled', () => {
338
- const core = initCore(schema, uischema, data);
339
- wrapper = mount(
340
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
341
- <BooleanCell
342
- schema={schema}
343
- uischema={uischema}
344
- enabled={false}
345
- path='foo'
346
- />
347
- </JsonFormsStateProvider>
348
- );
349
- const input = wrapper.find('input').first();
350
- expect(input.props().disabled).toBeTruthy();
351
- });
352
-
353
- it('should be enabled by default', () => {
354
- const core = initCore(schema, uischema, data);
355
- wrapper = mount(
356
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
357
- <BooleanCell schema={schema} uischema={uischema} path='foo' />
358
- </JsonFormsStateProvider>
359
- );
360
- const input = wrapper.find('input').first();
361
- expect(input.props().disabled).toBeFalsy();
362
- });
363
-
364
- it('id should be present in output', () => {
365
- const core = initCore(schema, uischema, data);
366
- wrapper = mount(
367
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
368
- <BooleanCell schema={schema} uischema={uischema} path='foo' id='myid' />
369
- </JsonFormsStateProvider>
370
- );
371
- const input = wrapper.find('input');
372
- expect(input.props().id).toBe('myid');
373
- });
374
- });