@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,75 +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
- } from '@jsonforms/core';
30
- import { materialRenderers, MuiSelect } from '../../src';
31
-
32
- import Enzyme, { mount } from 'enzyme';
33
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
34
- import { JsonFormsStateProvider } from '@jsonforms/react';
35
- import { initCore } from './util';
36
- import { MaterialEnumControl } from '../../src';
37
-
38
- Enzyme.configure({ adapter: new Adapter() });
39
-
40
- const data = { nationality: 'JP' };
41
- const schema = {
42
- type: 'string',
43
- enum: ['DE', 'IT', 'JP', 'US', 'RU', 'Other']
44
- };
45
- const uischema: ControlElement = {
46
- type: 'Control',
47
- scope: '#/properties/nationality',
48
- options: {
49
- autocomplete: false
50
- }
51
- };
52
-
53
- describe('Material enum control', () => {
54
- it('enum options should change when translation changes', () => {
55
- const core = initCore(schema, uischema, data);
56
- const translate = () => 'Translated';
57
- const changedTranslate = () => 'OtherTranslation';
58
- const wrapper = mount(
59
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core, i18n: {translate} }}>
60
- <MaterialEnumControl
61
- schema={schema}
62
- uischema={uischema}
63
- path='nationality'
64
- />
65
- </JsonFormsStateProvider>
66
- );
67
-
68
- expect(wrapper.find(MuiSelect).props().options[0].label).toBe('Translated');
69
-
70
- wrapper.setProps({ initState: { renderers: materialRenderers, core, i18n: {translate: changedTranslate} }} );
71
- wrapper.update();
72
-
73
- expect(wrapper.find(MuiSelect).props().options[0].label).toBe('OtherTranslation');
74
- });
75
- });
@@ -1,90 +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 Enzyme, { mount } from 'enzyme';
28
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
29
- import MaterialGroupLayout from '../../src/layouts/MaterialGroupLayout';
30
- import { MaterialLayoutRenderer } from '../../src/util/layout';
31
-
32
- Enzyme.configure({ adapter: new Adapter() });
33
-
34
- const schema = {
35
- type: 'object',
36
- properties: {
37
- name: {
38
- type: 'string',
39
- minLength: 3,
40
- description: 'Please enter your name'
41
- },
42
- birthDate: {
43
- type: 'string',
44
- format: 'date',
45
- description: 'Please enter your birth date.'
46
- }
47
- }
48
- };
49
-
50
- const uischema = {
51
- type: 'Group',
52
- label: 'My Group',
53
- elements: [
54
- {
55
- type: 'Control',
56
- label: 'Name',
57
- scope: '#/properties/name'
58
- },
59
- {
60
- type: 'Control',
61
- label: 'Birth Date',
62
- scope: '#/properties/birthDate'
63
- }
64
- ]
65
- };
66
-
67
- describe('Material group layout', () => {
68
- it('should render a GroupComponent with direction column when given no direction LayoutProp', () => {
69
- const wrapper = mount(
70
- <MaterialGroupLayout schema={schema} uischema={uischema} direction="column" enabled visible path=""/>
71
- );
72
- expect(wrapper.find(MaterialLayoutRenderer).props().direction).toBe(
73
- 'column'
74
- );
75
- });
76
-
77
- it('should render a GroupComponent with direction row when this is provided as a direction prop', () => {
78
- const wrapper = mount(
79
- <MaterialGroupLayout
80
- schema={schema}
81
- uischema={uischema}
82
- direction={'row'}
83
- enabled
84
- visible
85
- path=""
86
- />
87
- );
88
- expect(wrapper.find(MaterialLayoutRenderer).props().direction).toBe('row');
89
- });
90
- });
@@ -1,370 +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 Enzyme, { mount, ReactWrapper } from 'enzyme';
27
- import { materialRenderers } from '../../src';
28
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
29
- import * as React from 'react';
30
- import {
31
- ControlElement,
32
- ControlProps,
33
- ControlState,
34
- HorizontalLayout,
35
- isControl,
36
- JsonSchema,
37
- RankedTester,
38
- rankWith,
39
- } from '@jsonforms/core';
40
- import { Control, JsonFormsStateProvider, withJsonFormsControlProps } from '@jsonforms/react';
41
- import { MaterialInputControl } from '../../src/controls/MaterialInputControl';
42
- import MaterialHorizontalLayoutRenderer from '../../src/layouts/MaterialHorizontalLayout';
43
- import { MuiInputText } from '../../src/mui-controls';
44
- import { initCore } from './util';
45
-
46
- Enzyme.configure({ adapter: new Adapter() });
47
-
48
- const data = { foo: 'bar' };
49
- const schema = {
50
- type: 'object',
51
- properties: {
52
- foo: {
53
- type: 'string'
54
- }
55
- }
56
- };
57
- const uischema: ControlElement = {
58
- type: 'Control',
59
- scope: '#/properties/foo'
60
- };
61
- class TestControlInner extends Control<ControlProps, ControlState> {
62
- render() {
63
- return <MaterialInputControl {...this.props} input={MuiInputText} />;
64
- }
65
- }
66
- export const testControlTester: RankedTester = rankWith(1, isControl);
67
- const TestControl = withJsonFormsControlProps(TestControlInner);
68
-
69
- describe('Material input control', () => {
70
- let wrapper: ReactWrapper;
71
-
72
- afterEach(() => {
73
- wrapper.unmount();
74
- });
75
-
76
- it('render', () => {
77
- const core = initCore(schema, uischema, data);
78
- wrapper = mount(
79
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
80
- <TestControl
81
- schema={schema}
82
- uischema={uischema}
83
- />
84
- </JsonFormsStateProvider>
85
- );
86
-
87
- const control = wrapper.find('div').first();
88
- expect(control.children()).toHaveLength(4);
89
-
90
- const label = wrapper.find('label');
91
- expect(label.text()).toBe('Foo');
92
-
93
- const inputs = wrapper.find('input');
94
- expect(inputs).toHaveLength(1);
95
-
96
- const validation = wrapper.find('p').first();
97
- expect(validation.props().className).toContain('MuiFormHelperText-root');
98
- expect(validation.children()).toHaveLength(0);
99
- });
100
-
101
- it('should render without label', () => {
102
- const control: ControlElement = {
103
- type: 'Control',
104
- scope: '#/properties/foo',
105
- label: false
106
- };
107
- const core = initCore(schema, uischema);
108
- wrapper = mount(
109
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
110
- <TestControl schema={schema} uischema={control} />
111
- </JsonFormsStateProvider>
112
- );
113
-
114
- const div = wrapper.find('div').first();
115
- expect(div.children()).toHaveLength(4);
116
-
117
- const label = wrapper.find('label');
118
- expect(label.text()).toBe('');
119
-
120
- const inputs = wrapper.find('input');
121
- expect(inputs).toHaveLength(1);
122
-
123
- const validation = wrapper.find('p').first();
124
- expect(validation.props().className).toContain('MuiFormHelperText-root');
125
- expect(validation.children()).toHaveLength(0);
126
- });
127
-
128
- it('can be hidden', () => {
129
- const core = initCore(schema, uischema, data);
130
- wrapper = mount(
131
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
132
- <TestControl schema={schema} uischema={uischema} visible={false} />
133
- </JsonFormsStateProvider>
134
- );
135
- const inputs = wrapper.find('input');
136
- expect(inputs.length).toBe(0);
137
- });
138
-
139
- it('should be shown by default', () => {
140
- const core = initCore(schema, uischema, data);
141
- wrapper = mount(
142
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
143
- <TestControl schema={schema} uischema={uischema} />
144
- </JsonFormsStateProvider>
145
- );
146
- const control = wrapper.find('div').first();
147
- expect(control.props().hidden).toBeFalsy();
148
- });
149
-
150
- it('should display a single error', () => {
151
- const core = initCore(schema, uischema, data );
152
- wrapper = mount(
153
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
154
- <TestControl schema={schema} uischema={uischema} />
155
- </JsonFormsStateProvider>
156
- );
157
-
158
- core.data = { ...core.data, foo: 2 };
159
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
160
- wrapper.update();
161
- const validation = wrapper.find('p').first();
162
- expect(validation.text()).toBe('must be string');
163
- });
164
-
165
- it('should display multiple errors', () => {
166
- const core = initCore(schema, uischema, data);
167
- wrapper = mount(
168
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
169
- <TestControl schema={schema} uischema={uischema} />
170
- </JsonFormsStateProvider>
171
- );
172
- core.data = { ...core.data, foo: 3 };
173
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
174
- wrapper.update();
175
- const validation = wrapper.find('p').first();
176
- expect(validation.text()).toBe('must be string');
177
- });
178
-
179
- it('should not show any errors', () => {
180
- const core = initCore(schema, uischema, data);
181
- wrapper = mount(
182
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
183
- <TestControl schema={schema} uischema={uischema} />
184
- </JsonFormsStateProvider>
185
- );
186
- const validation = wrapper.find('p').first();
187
- expect(validation.text()).toBe('');
188
- });
189
-
190
- it('should handle validation updates', () => {
191
- const core = initCore(schema, uischema, data);
192
- wrapper = mount(
193
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
194
- <TestControl schema={schema} uischema={uischema} />
195
- </JsonFormsStateProvider>
196
- );
197
- core.data = { ...core.data, foo: 3 };
198
- core.data = { ...core.data, foo: 'bar' };
199
- wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
200
- wrapper.update();
201
- const validation = wrapper.find('p').first();
202
- expect(validation.text()).toBe('');
203
- });
204
-
205
- it('should handle validation with nested schemas', () => {
206
- const jsonSchema = {
207
- type: 'object',
208
- properties: {
209
- name: {
210
- type: 'string'
211
- },
212
- personalData: {
213
- type: 'object',
214
- properties: {
215
- middleName: {
216
- type: 'string'
217
- },
218
- lastName: {
219
- type: 'string'
220
- }
221
- },
222
- required: ['middleName', 'lastName']
223
- }
224
- },
225
- required: ['name']
226
- };
227
- const firstControlElement: ControlElement = {
228
- type: 'Control',
229
- scope: '#/properties/name'
230
- };
231
- const secondControlElement: ControlElement = {
232
- type: 'Control',
233
- scope: '#/properties/personalData/properties/middleName'
234
- };
235
- const thirdControlElement: ControlElement = {
236
- type: 'Control',
237
- scope: '#/properties/personalData/properties/lastName'
238
- };
239
- const layout: HorizontalLayout = {
240
- type: 'HorizontalLayout',
241
- elements: [firstControlElement, secondControlElement, thirdControlElement]
242
- };
243
- const newData = {
244
- name: 'John Doe',
245
- personalData: {}
246
- };
247
- const core = initCore(jsonSchema, layout, newData);
248
- wrapper = mount(
249
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }} >
250
- <MaterialHorizontalLayoutRenderer
251
- schema={jsonSchema}
252
- uischema={layout}
253
- direction="row"
254
- enabled
255
- visible
256
- path=""
257
- />
258
- </ JsonFormsStateProvider>
259
- );
260
- const validation = wrapper.find('p');
261
- expect(validation).toHaveLength(6);
262
- expect(validation.at(0).text()).toBe('');
263
- expect(validation.at(2).text()).toBe('is a required property');
264
- expect(validation.at(4).text()).toBe('is a required property');
265
- });
266
-
267
- it('should display a marker for a required prop', () => {
268
- const jsonSchema: JsonSchema = {
269
- type: 'object',
270
- properties: {
271
- dateCell: {
272
- type: 'string',
273
- format: 'date'
274
- }
275
- },
276
- required: ['dateCell']
277
- };
278
- const control: ControlElement = {
279
- type: 'Control',
280
- scope: '#/properties/dateCell'
281
- };
282
-
283
- const core = initCore(jsonSchema, control, {});
284
- wrapper = mount(
285
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
286
- <TestControl schema={jsonSchema} uischema={control} />
287
- </JsonFormsStateProvider>
288
- );
289
- const label = wrapper.find('label').first();
290
- expect(label.text()).toBe('Date Cell *');
291
- });
292
-
293
- it('should not display a marker for a non-required prop', () => {
294
- const jsonSchema: JsonSchema = {
295
- type: 'object',
296
- properties: {
297
- dateCell: {
298
- type: 'string',
299
- format: 'date'
300
- }
301
- }
302
- };
303
- const control: ControlElement = {
304
- type: 'Control',
305
- scope: '#/properties/dateCell'
306
- };
307
-
308
- const core = initCore(jsonSchema, control, {});
309
- wrapper = mount(
310
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
311
- <TestControl schema={jsonSchema} uischema={control} />
312
- </JsonFormsStateProvider>
313
- );
314
- const label = wrapper.find('label').first();
315
- expect(label.text()).toBe('Date Cell');
316
- });
317
-
318
- it('should display a password cell if the password option is set', () => {
319
- const jsonSchema = {
320
- type: 'object',
321
- properties: {
322
- password: { type: 'string' }
323
- }
324
- };
325
- const control: ControlElement = {
326
- type: 'Control',
327
- scope: '#/properties/password',
328
- options: { format: 'password' }
329
- };
330
- const core = initCore(jsonSchema, control, {});
331
- wrapper = mount(
332
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
333
- <TestControl schema={jsonSchema} uischema={control} />
334
- </JsonFormsStateProvider>
335
- );
336
- const input = wrapper.find('input');
337
- expect(input.props().type).toBe('password');
338
- });
339
-
340
- it('should render own id and create/use input id', () => {
341
- const jsonSchema = {
342
- type: 'object',
343
- properties: {
344
- name: { type: 'string' }
345
- }
346
- };
347
- const control: ControlElement = {
348
- type: 'Control',
349
- scope: '#/properties/name'
350
- };
351
- const core = initCore(jsonSchema, control, {});
352
- wrapper = mount(
353
- <JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
354
- <TestControl
355
- schema={jsonSchema}
356
- uischema={control}
357
- id={control.scope}
358
- />
359
- </JsonFormsStateProvider>
360
- );
361
- const input = wrapper.find('input').first();
362
- expect(input.props().id).toBe('#/properties/name-input');
363
-
364
- const label = wrapper.find('label').first();
365
- expect(label.props().htmlFor).toBe('#/properties/name-input');
366
-
367
- const rootDiv = wrapper.find('div').first();
368
- expect(rootDiv.props().id).toBe('#/properties/name');
369
- });
370
- });