@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.
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/index.d.ts +2 -2
- package/lib/jsonforms-react-material.cjs.js +84 -17
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +85 -18
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/mui-controls/MuiCheckbox.d.ts +6 -1
- package/lib/mui-controls/MuiToggle.d.ts +6 -1
- package/package.json +23 -12
- package/src/additional/ListWithDetailMasterItem.tsx +1 -1
- package/src/complex/TableToolbar.tsx +3 -3
- package/src/controls/MaterialBooleanControl.tsx +84 -23
- package/src/controls/MaterialBooleanToggleControl.tsx +84 -23
- package/src/layouts/ArrayToolbar.tsx +2 -3
- package/src/mui-controls/MuiCheckbox.tsx +12 -5
- package/src/mui-controls/MuiToggle.tsx +12 -5
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/combinatorproperties.html +0 -957
- package/docs/classes/materialanyofstringorenumcontrol.html +0 -822
- package/docs/classes/materialtablecontrol.html +0 -999
- package/docs/globals.html +0 -4492
- package/docs/index.html +0 -753
- package/docs/interfaces/ajvprops.html +0 -162
- package/docs/interfaces/arraylayouttoolbarprops.html +0 -253
- package/docs/interfaces/categorizationstate.html +0 -154
- package/docs/interfaces/categorizationstepperstate.html +0 -154
- package/docs/interfaces/combinatorpropertiesprops.html +0 -182
- package/docs/interfaces/deletedialogprops.html +0 -225
- package/docs/interfaces/dispatchpropsofexpandpanel.html +0 -296
- package/docs/interfaces/emptytableprops.html +0 -154
- package/docs/interfaces/expandpanelprops.html +0 -594
- package/docs/interfaces/inputref.html +0 -168
- package/docs/interfaces/jsonformstheme.html +0 -352
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +0 -460
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +0 -394
- package/docs/interfaces/materiallabelablelayoutrendererprops.html +0 -328
- package/docs/interfaces/materiallayoutrendererprops.html +0 -317
- package/docs/interfaces/materialtabletoolbarprops.html +0 -302
- package/docs/interfaces/muitextinputprops.html +0 -168
- package/docs/interfaces/nonemptycellcomponentprops.html +0 -266
- package/docs/interfaces/nonemptycellprops.html +0 -277
- package/docs/interfaces/nonemptyrowprops.html +0 -366
- package/docs/interfaces/ownoneofprops.html +0 -308
- package/docs/interfaces/ownpropsofexpandpanel.html +0 -397
- package/docs/interfaces/ownpropsofnonemptycell.html +0 -229
- package/docs/interfaces/statepropsofexpandpanel.html +0 -445
- package/docs/interfaces/tableheadercellprops.html +0 -154
- package/docs/interfaces/tablerowsprop.html +0 -330
- package/docs/interfaces/validationprops.html +0 -168
- package/docs/interfaces/withdeletedialogsupport.html +0 -170
- package/docs/interfaces/withinput.html +0 -154
- package/docs/interfaces/withoptionlabel.html +0 -230
- package/example/index.html +0 -16
- package/example/index.ts +0 -31
- package/rollup.config.js +0 -51
- package/stats.html +0 -3279
- package/test/renderers/MatchMediaMock.ts +0 -36
- package/test/renderers/MaterialAllOfRenderer.test.tsx +0 -114
- package/test/renderers/MaterialAnyOfRenderer.test.tsx +0 -310
- package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +0 -126
- package/test/renderers/MaterialArrayControl.test.tsx +0 -633
- package/test/renderers/MaterialArrayLayout.test.tsx +0 -528
- package/test/renderers/MaterialBooleanCell.test.tsx +0 -374
- package/test/renderers/MaterialBooleanToggleCell.test.tsx +0 -466
- package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -469
- package/test/renderers/MaterialCategorizationLayout.test.tsx +0 -458
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +0 -647
- package/test/renderers/MaterialDateCell.test.tsx +0 -303
- package/test/renderers/MaterialDateControl.test.tsx +0 -411
- package/test/renderers/MaterialDateTimeControl.test.tsx +0 -417
- package/test/renderers/MaterialEnumArrayRenderer.test.tsx +0 -207
- package/test/renderers/MaterialEnumCell.test.tsx +0 -88
- package/test/renderers/MaterialEnumControl.test.tsx +0 -75
- package/test/renderers/MaterialGroupLayout.test.tsx +0 -90
- package/test/renderers/MaterialInputControl.test.tsx +0 -370
- package/test/renderers/MaterialIntegerCell.test.tsx +0 -333
- package/test/renderers/MaterialLabelRenderer.test.tsx +0 -114
- package/test/renderers/MaterialLayouts.test.tsx +0 -542
- package/test/renderers/MaterialListWithDetailRenderer.test.tsx +0 -279
- package/test/renderers/MaterialNativeControl.test.tsx +0 -81
- package/test/renderers/MaterialNumberCell.test.tsx +0 -382
- package/test/renderers/MaterialObjectControl.test.tsx +0 -186
- package/test/renderers/MaterialOneOfEnumCell.test.tsx +0 -94
- package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +0 -108
- package/test/renderers/MaterialOneOfRenderer.test.tsx +0 -603
- package/test/renderers/MaterialRadioGroupControl.test.tsx +0 -125
- package/test/renderers/MaterialSliderControl.test.tsx +0 -438
- package/test/renderers/MaterialTextCell.test.tsx +0 -541
- package/test/renderers/MaterialTextControl.test.tsx +0 -115
- package/test/renderers/MaterialTimeCell.test.tsx +0 -331
- package/test/renderers/MaterialTimeControl.test.tsx +0 -411
- package/test/renderers/util.ts +0 -50
- package/tsconfig.json +0 -13
- package/tsconfig.test.json +0 -7
- package/webpack/webpack.dev.js +0 -11
|
@@ -1,382 +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 NumberCell, {
|
|
33
|
-
materialNumberCellTester
|
|
34
|
-
} from '../../src/cells/MaterialNumberCell';
|
|
35
|
-
import { materialRenderers } from '../../src';
|
|
36
|
-
import Enzyme, { mount, ReactWrapper } from 'enzyme';
|
|
37
|
-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
38
|
-
import { JsonFormsStateProvider } from '@jsonforms/react';
|
|
39
|
-
import { initCore, TestEmitter } from './util';
|
|
40
|
-
|
|
41
|
-
Enzyme.configure({ adapter: new Adapter() });
|
|
42
|
-
|
|
43
|
-
const data = { foo: 3.14 };
|
|
44
|
-
const schema = {
|
|
45
|
-
type: 'number',
|
|
46
|
-
minimum: 5
|
|
47
|
-
};
|
|
48
|
-
const uischema: ControlElement = {
|
|
49
|
-
type: 'Control',
|
|
50
|
-
scope: '#/properties/foo'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
describe('Material number cells tester', () => {
|
|
54
|
-
it('should fail', () => {
|
|
55
|
-
expect(materialNumberCellTester(undefined, undefined, undefined)).toBe(NOT_APPLICABLE);
|
|
56
|
-
expect(materialNumberCellTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
|
|
57
|
-
expect(materialNumberCellTester({ type: 'Foo' }, undefined, undefined)).toBe(
|
|
58
|
-
NOT_APPLICABLE
|
|
59
|
-
);
|
|
60
|
-
expect(materialNumberCellTester({ type: 'Control' }, undefined, undefined)).toBe(
|
|
61
|
-
NOT_APPLICABLE
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should succeed with wrong schema type', () => {
|
|
66
|
-
const control: ControlElement = {
|
|
67
|
-
type: 'Control',
|
|
68
|
-
scope: '#/properties/foo'
|
|
69
|
-
};
|
|
70
|
-
expect(
|
|
71
|
-
materialNumberCellTester(control, {
|
|
72
|
-
type: 'object',
|
|
73
|
-
properties: {
|
|
74
|
-
foo: {
|
|
75
|
-
type: 'string'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
undefined)
|
|
80
|
-
).toBe(NOT_APPLICABLE);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should fail if only sibling has correct type', () => {
|
|
84
|
-
const control: ControlElement = {
|
|
85
|
-
type: 'Control',
|
|
86
|
-
scope: '#/properties/foo'
|
|
87
|
-
};
|
|
88
|
-
expect(
|
|
89
|
-
materialNumberCellTester(control, {
|
|
90
|
-
type: 'object',
|
|
91
|
-
properties: {
|
|
92
|
-
foo: {
|
|
93
|
-
type: 'string'
|
|
94
|
-
},
|
|
95
|
-
bar: {
|
|
96
|
-
type: 'number'
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
undefined)
|
|
101
|
-
).toBe(NOT_APPLICABLE);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should succeed with matching prop type', () => {
|
|
105
|
-
const control: ControlElement = {
|
|
106
|
-
type: 'Control',
|
|
107
|
-
scope: '#/properties/foo'
|
|
108
|
-
};
|
|
109
|
-
expect(
|
|
110
|
-
materialNumberCellTester(control, {
|
|
111
|
-
type: 'object',
|
|
112
|
-
properties: {
|
|
113
|
-
foo: {
|
|
114
|
-
type: 'number'
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
undefined)
|
|
119
|
-
).toBe(2);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('Material number cells', () => {
|
|
124
|
-
let wrapper: ReactWrapper;
|
|
125
|
-
|
|
126
|
-
afterEach(() => wrapper.unmount());
|
|
127
|
-
|
|
128
|
-
it('should autofocus via option', () => {
|
|
129
|
-
const control: ControlElement = {
|
|
130
|
-
type: 'Control',
|
|
131
|
-
scope: '#/properties/foo',
|
|
132
|
-
options: {
|
|
133
|
-
focus: true
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const core = initCore(schema, control, data);
|
|
137
|
-
wrapper = mount(
|
|
138
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
139
|
-
<NumberCell schema={schema} uischema={control} path='foo' />
|
|
140
|
-
</JsonFormsStateProvider>
|
|
141
|
-
);
|
|
142
|
-
const inputs = wrapper.find('input');
|
|
143
|
-
expect(inputs.first().props().autoFocus).toBeTruthy();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should not autofocus via option', () => {
|
|
147
|
-
const control: ControlElement = {
|
|
148
|
-
type: 'Control',
|
|
149
|
-
scope: '#/properties/foo',
|
|
150
|
-
options: {
|
|
151
|
-
focus: false
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const core = initCore(schema, control, data);
|
|
155
|
-
wrapper = mount(
|
|
156
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
157
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
158
|
-
</JsonFormsStateProvider>
|
|
159
|
-
);
|
|
160
|
-
const inputs = wrapper.find('input');
|
|
161
|
-
expect(inputs.first().props().autoFocus).toBeFalsy();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('should not autofocus by default', () => {
|
|
165
|
-
const control: ControlElement = {
|
|
166
|
-
type: 'Control',
|
|
167
|
-
scope: '#/properties/foo'
|
|
168
|
-
};
|
|
169
|
-
const core = initCore(schema, uischema, data);
|
|
170
|
-
wrapper = mount(
|
|
171
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
172
|
-
<NumberCell schema={schema} uischema={control} path='foo' />
|
|
173
|
-
</JsonFormsStateProvider>
|
|
174
|
-
);
|
|
175
|
-
const inputs = wrapper.find('input');
|
|
176
|
-
expect(inputs.first().props().autoFocus).toBeFalsy();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should render', () => {
|
|
180
|
-
const jsonSchema: JsonSchema = {
|
|
181
|
-
type: 'object',
|
|
182
|
-
properties: {
|
|
183
|
-
foo: {
|
|
184
|
-
type: 'number'
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
const core = initCore(schema, uischema, { foo: 3.14 });
|
|
189
|
-
wrapper = mount(
|
|
190
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
191
|
-
<NumberCell schema={jsonSchema} uischema={uischema} path='foo' />
|
|
192
|
-
</JsonFormsStateProvider>
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
const input = wrapper.find('input').first();
|
|
196
|
-
expect(input.props().type).toBe('number');
|
|
197
|
-
expect(input.props().step).toBe('0.1');
|
|
198
|
-
expect(input.props().value).toBe(3.14);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('should render 0', () => {
|
|
202
|
-
const jsonSchema: JsonSchema = {
|
|
203
|
-
type: 'object',
|
|
204
|
-
properties: {
|
|
205
|
-
foo: {
|
|
206
|
-
type: 'number'
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
const core = initCore(schema, uischema, { foo: 0 });
|
|
211
|
-
wrapper = mount(
|
|
212
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
213
|
-
<NumberCell schema={jsonSchema} uischema={uischema} path='foo' />
|
|
214
|
-
</JsonFormsStateProvider>
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
const input = wrapper.find('input').first();
|
|
218
|
-
expect(input.props().type).toBe('number');
|
|
219
|
-
expect(input.props().step).toBe('0.1');
|
|
220
|
-
expect(input.props().value).toBe(0);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('should update via input event', (done) => {
|
|
224
|
-
const core = initCore(schema, uischema, data);
|
|
225
|
-
const onChangeData: any = {
|
|
226
|
-
data: undefined
|
|
227
|
-
};
|
|
228
|
-
wrapper = mount(
|
|
229
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
230
|
-
<TestEmitter
|
|
231
|
-
onChange={({ data }) => {
|
|
232
|
-
onChangeData.data = data;
|
|
233
|
-
}}
|
|
234
|
-
/>
|
|
235
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
236
|
-
</JsonFormsStateProvider>
|
|
237
|
-
);
|
|
238
|
-
const input = wrapper.find('input');
|
|
239
|
-
input.simulate('change', { target: { value: 2.72 } });
|
|
240
|
-
setTimeout(() => {
|
|
241
|
-
expect(onChangeData.data.foo).toBe(2.72);
|
|
242
|
-
done();
|
|
243
|
-
}, 1000);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('should update via action', (done) => {
|
|
247
|
-
const core = initCore(schema, uischema, { foo: 2.72 });
|
|
248
|
-
wrapper = mount(
|
|
249
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
250
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
251
|
-
</JsonFormsStateProvider>
|
|
252
|
-
);
|
|
253
|
-
const input = wrapper.find('input').first();
|
|
254
|
-
expect(input.props().value).toBe(2.72);
|
|
255
|
-
|
|
256
|
-
core.data = { ...core.data, foo: 3.14 };
|
|
257
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
258
|
-
wrapper.update();
|
|
259
|
-
|
|
260
|
-
setTimeout(() => {
|
|
261
|
-
expect(
|
|
262
|
-
wrapper
|
|
263
|
-
.find('input')
|
|
264
|
-
.first()
|
|
265
|
-
.props().value
|
|
266
|
-
).toBe(3.14);
|
|
267
|
-
done();
|
|
268
|
-
}, 1000);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it('should update with undefined value', (done) => {
|
|
272
|
-
const core = initCore(schema, uischema, data);
|
|
273
|
-
wrapper = mount(
|
|
274
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
275
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
276
|
-
</JsonFormsStateProvider>
|
|
277
|
-
);
|
|
278
|
-
core.data = { ...core.data, foo: undefined };
|
|
279
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
280
|
-
wrapper.update();
|
|
281
|
-
setTimeout(() => {
|
|
282
|
-
const input = wrapper.find('input').first();
|
|
283
|
-
expect(input.props().value).toBe('');
|
|
284
|
-
done();
|
|
285
|
-
}, 1000);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('should not update with null value', (done) => {
|
|
289
|
-
const core = initCore(schema, uischema, data);
|
|
290
|
-
wrapper = mount(
|
|
291
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
292
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
293
|
-
</JsonFormsStateProvider>
|
|
294
|
-
);
|
|
295
|
-
core.data = { ...core.data, foo: null };
|
|
296
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
297
|
-
wrapper.update();
|
|
298
|
-
setTimeout(() => {
|
|
299
|
-
const input = wrapper.find('input').first();
|
|
300
|
-
expect(input.props().value).toBe('');
|
|
301
|
-
done();
|
|
302
|
-
}, 1000);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it('should not update with wrong ref', (done) => {
|
|
306
|
-
const core = initCore(schema, uischema, data);
|
|
307
|
-
wrapper = mount(
|
|
308
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
309
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
310
|
-
</JsonFormsStateProvider>
|
|
311
|
-
);
|
|
312
|
-
core.data = { ...core.data, bar: 11 };
|
|
313
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
314
|
-
wrapper.update();
|
|
315
|
-
setTimeout(() => {
|
|
316
|
-
const input = wrapper.find('input').first();
|
|
317
|
-
expect(input.props().value).toBe(3.14);
|
|
318
|
-
done();
|
|
319
|
-
}, 1000);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('should not update with null ref', (done) => {
|
|
323
|
-
const core = initCore(schema, uischema, data);
|
|
324
|
-
wrapper = mount(
|
|
325
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
326
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
327
|
-
</JsonFormsStateProvider>
|
|
328
|
-
);
|
|
329
|
-
core.data = { ...core.data, null: 2.72 };
|
|
330
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
331
|
-
wrapper.update();
|
|
332
|
-
setTimeout(() => {
|
|
333
|
-
const input = wrapper.find('input').first();
|
|
334
|
-
expect(input.props().value).toBe(3.14);
|
|
335
|
-
done();
|
|
336
|
-
}, 1000);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('should not update with undefined ref', (done) => {
|
|
340
|
-
const core = initCore(schema, uischema, data);
|
|
341
|
-
wrapper = mount(
|
|
342
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
343
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
344
|
-
</JsonFormsStateProvider>
|
|
345
|
-
);
|
|
346
|
-
core.data = { ...core.data, undefined: 13 };
|
|
347
|
-
wrapper.setProps({ initState: { renderers: materialRenderers, core }} );
|
|
348
|
-
wrapper.update();
|
|
349
|
-
setTimeout(() => {
|
|
350
|
-
const input = wrapper.find('input').first();
|
|
351
|
-
expect(input.props().value).toBe(3.14);
|
|
352
|
-
done();
|
|
353
|
-
}, 1000);
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it('can be disabled', () => {
|
|
357
|
-
const core = initCore(schema, uischema, data);
|
|
358
|
-
wrapper = mount(
|
|
359
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
360
|
-
<NumberCell
|
|
361
|
-
schema={schema}
|
|
362
|
-
uischema={uischema}
|
|
363
|
-
path='foo'
|
|
364
|
-
enabled={false}
|
|
365
|
-
/>
|
|
366
|
-
</JsonFormsStateProvider>
|
|
367
|
-
);
|
|
368
|
-
const input = wrapper.find('input').first();
|
|
369
|
-
expect(input.props().disabled).toBeTruthy();
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it('should be enabled by default', () => {
|
|
373
|
-
const core = initCore(schema, uischema, data);
|
|
374
|
-
wrapper = mount(
|
|
375
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
376
|
-
<NumberCell schema={schema} uischema={uischema} path='foo' />
|
|
377
|
-
</JsonFormsStateProvider>
|
|
378
|
-
);
|
|
379
|
-
const input = wrapper.find('input').first();
|
|
380
|
-
expect(input.props().disabled).toBeFalsy();
|
|
381
|
-
});
|
|
382
|
-
});
|
|
@@ -1,186 +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 {
|
|
27
|
-
ControlElement,
|
|
28
|
-
NOT_APPLICABLE
|
|
29
|
-
} from '@jsonforms/core';
|
|
30
|
-
import * as React from 'react';
|
|
31
|
-
import { materialRenderers } from '../../src';
|
|
32
|
-
import MaterialObjectRenderer, {
|
|
33
|
-
materialObjectControlTester
|
|
34
|
-
} from '../../src/complex/MaterialObjectRenderer';
|
|
35
|
-
import Enzyme, { mount, ReactWrapper } from 'enzyme';
|
|
36
|
-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
37
|
-
import { JsonFormsStateProvider } from '@jsonforms/react';
|
|
38
|
-
import { initCore } from './util';
|
|
39
|
-
|
|
40
|
-
Enzyme.configure({ adapter: new Adapter() });
|
|
41
|
-
|
|
42
|
-
const data = { foo: { foo_1: 'foo' }, bar: { bar_1: 'bar' } };
|
|
43
|
-
const schema = {
|
|
44
|
-
type: 'object',
|
|
45
|
-
properties: {
|
|
46
|
-
foo: {
|
|
47
|
-
type: 'object',
|
|
48
|
-
properties: {
|
|
49
|
-
foo_1: { type: 'string' }
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
bar: {
|
|
53
|
-
type: 'object',
|
|
54
|
-
properties: {
|
|
55
|
-
bar_1: { type: 'string' }
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const uischema1: ControlElement = {
|
|
61
|
-
type: 'Control',
|
|
62
|
-
scope: '#'
|
|
63
|
-
};
|
|
64
|
-
const uischema2: ControlElement = {
|
|
65
|
-
type: 'Control',
|
|
66
|
-
scope: '#/properties/foo'
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
describe('Material object renderer tester', () => {
|
|
70
|
-
test('should fail', () => {
|
|
71
|
-
expect(materialObjectControlTester(undefined, undefined, undefined)).toBe(
|
|
72
|
-
NOT_APPLICABLE
|
|
73
|
-
);
|
|
74
|
-
expect(materialObjectControlTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
|
|
75
|
-
expect(materialObjectControlTester({ type: 'Foo' }, undefined, undefined)).toBe(
|
|
76
|
-
NOT_APPLICABLE
|
|
77
|
-
);
|
|
78
|
-
expect(materialObjectControlTester({ type: 'Control' }, undefined, undefined)).toBe(
|
|
79
|
-
NOT_APPLICABLE
|
|
80
|
-
);
|
|
81
|
-
expect(
|
|
82
|
-
materialObjectControlTester(uischema2, {
|
|
83
|
-
type: 'object',
|
|
84
|
-
properties: {
|
|
85
|
-
foo: { type: 'string' }
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
undefined)
|
|
89
|
-
).toBe(NOT_APPLICABLE);
|
|
90
|
-
expect(
|
|
91
|
-
materialObjectControlTester(uischema2, {
|
|
92
|
-
type: 'object',
|
|
93
|
-
properties: {
|
|
94
|
-
foo: { type: 'string' },
|
|
95
|
-
bar: schema.properties.bar
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
undefined)
|
|
99
|
-
).toBe(NOT_APPLICABLE);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should succeed', () => {
|
|
103
|
-
expect(
|
|
104
|
-
materialObjectControlTester(uischema2, {
|
|
105
|
-
type: 'object',
|
|
106
|
-
properties: {
|
|
107
|
-
foo: schema.properties.foo
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
undefined)
|
|
111
|
-
).toBe(2);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('Material object control', () => {
|
|
116
|
-
let wrapper: ReactWrapper;
|
|
117
|
-
|
|
118
|
-
afterEach(() => wrapper.unmount());
|
|
119
|
-
|
|
120
|
-
it('should render all children', () => {
|
|
121
|
-
const core = initCore(schema, uischema1, data);
|
|
122
|
-
wrapper = mount(
|
|
123
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
124
|
-
<MaterialObjectRenderer schema={schema} uischema={uischema1} />
|
|
125
|
-
</JsonFormsStateProvider>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const inputs = wrapper.find('input');
|
|
129
|
-
expect(inputs.length).toBe(2);
|
|
130
|
-
expect(inputs.at(0).props().type).toBe('text');
|
|
131
|
-
expect(inputs.at(0).props().value).toBe('foo');
|
|
132
|
-
expect(inputs.at(1).props().type).toBe('text');
|
|
133
|
-
expect(inputs.at(1).props().value).toBe('bar');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('should render only itself', () => {
|
|
137
|
-
const core = initCore(schema, uischema1, data);
|
|
138
|
-
wrapper = mount(
|
|
139
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
140
|
-
<MaterialObjectRenderer schema={schema} uischema={uischema2} />
|
|
141
|
-
</JsonFormsStateProvider>
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const inputs = wrapper.find('input');
|
|
145
|
-
expect(inputs.length).toBe(1);
|
|
146
|
-
expect(inputs.at(0).props().type).toBe('text');
|
|
147
|
-
expect(inputs.at(0).props().value).toBe('foo');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('should be enabled by default', () => {
|
|
151
|
-
const core = initCore(schema, uischema2, data);
|
|
152
|
-
wrapper = mount(
|
|
153
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
154
|
-
<MaterialObjectRenderer schema={schema} uischema={uischema2} />
|
|
155
|
-
</JsonFormsStateProvider>
|
|
156
|
-
);
|
|
157
|
-
const inputs = wrapper.find('input');
|
|
158
|
-
expect(inputs.first().props().disabled).toBeFalsy();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('can be invisible', () => {
|
|
162
|
-
const core = initCore(schema, uischema2, data);
|
|
163
|
-
wrapper = mount(
|
|
164
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
165
|
-
<MaterialObjectRenderer
|
|
166
|
-
schema={schema}
|
|
167
|
-
uischema={uischema2}
|
|
168
|
-
visible={false}
|
|
169
|
-
/>
|
|
170
|
-
</JsonFormsStateProvider>
|
|
171
|
-
);
|
|
172
|
-
const inputs = wrapper.find('input');
|
|
173
|
-
expect(inputs.length).toBe(0);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should be visible by default', () => {
|
|
177
|
-
const core = initCore(schema, uischema2, data);
|
|
178
|
-
wrapper = mount(
|
|
179
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
180
|
-
<MaterialObjectRenderer schema={schema} uischema={uischema2} />
|
|
181
|
-
</JsonFormsStateProvider>
|
|
182
|
-
);
|
|
183
|
-
const inputs = wrapper.find('input');
|
|
184
|
-
expect(inputs.first().props().hidden).toBeFalsy();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,94 +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 MaterialOneOfEnumCell, {
|
|
31
|
-
materialOneOfEnumCellTester
|
|
32
|
-
} from '../../src/cells/MaterialOneOfEnumCell';
|
|
33
|
-
import { materialRenderers } from '../../src';
|
|
34
|
-
|
|
35
|
-
import Enzyme, { mount } from 'enzyme';
|
|
36
|
-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
37
|
-
import { JsonFormsStateProvider } from '@jsonforms/react';
|
|
38
|
-
import { initCore } from './util';
|
|
39
|
-
|
|
40
|
-
Enzyme.configure({ adapter: new Adapter() });
|
|
41
|
-
|
|
42
|
-
const data = { country: 'AU' };
|
|
43
|
-
const schema = {
|
|
44
|
-
type: 'string',
|
|
45
|
-
oneOf: [
|
|
46
|
-
{
|
|
47
|
-
const: 'AU',
|
|
48
|
-
title: 'Australia'
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
const: 'NZ',
|
|
52
|
-
title: 'New Zealand'
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
};
|
|
56
|
-
const uischema: ControlElement = {
|
|
57
|
-
type: 'Control',
|
|
58
|
-
scope: '#/properties/country'
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
describe('Material one of enum cell tester', () => {
|
|
62
|
-
it('should succeed with matching prop type', () => {
|
|
63
|
-
const control: ControlElement = {
|
|
64
|
-
type: 'Control',
|
|
65
|
-
scope: '#/properties/country'
|
|
66
|
-
};
|
|
67
|
-
expect(
|
|
68
|
-
materialOneOfEnumCellTester(control, {
|
|
69
|
-
type: 'object',
|
|
70
|
-
properties: {
|
|
71
|
-
country: schema
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
undefined)
|
|
75
|
-
).toBe(2);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('Material enum cell', () => {
|
|
80
|
-
it('should select an item from dropdown list', () => {
|
|
81
|
-
const core = initCore(schema, uischema, data);
|
|
82
|
-
const wrapper = mount(
|
|
83
|
-
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
84
|
-
<MaterialOneOfEnumCell
|
|
85
|
-
schema={schema}
|
|
86
|
-
uischema={uischema}
|
|
87
|
-
path='country'
|
|
88
|
-
/>
|
|
89
|
-
</JsonFormsStateProvider>
|
|
90
|
-
);
|
|
91
|
-
const input = wrapper.find('input');
|
|
92
|
-
expect(input.props().value).toBe('AU');
|
|
93
|
-
});
|
|
94
|
-
});
|