@jsonforms/material-renderers 3.0.0-beta.4 → 3.0.0-rc.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/docs/assets/js/search.json +1 -1
- package/docs/globals.html +167 -40
- package/docs/index.html +15 -0
- package/docs/interfaces/categorizationstate.html +1 -1
- package/docs/interfaces/categorizationstepperstate.html +1 -1
- package/docs/interfaces/inputref.html +168 -0
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +49 -4
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +46 -1
- package/docs/interfaces/materiallabelablelayoutrendererprops.html +328 -0
- package/docs/interfaces/materiallayoutrendererprops.html +5 -0
- package/docs/interfaces/withoptionlabel.html +3 -3
- package/lib/additional/MaterialLabelRenderer.d.ts +3 -3
- package/lib/cells/MaterialEnumCell.d.ts +2 -1
- package/lib/cells/MaterialOneOfEnumCell.d.ts +2 -1
- package/lib/controls/MaterialEnumControl.d.ts +2 -1
- package/lib/controls/MaterialOneOfEnumControl.d.ts +2 -1
- package/lib/controls/index.d.ts +2 -2
- package/lib/jsonforms-react-material.cjs.js +143 -65
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +137 -57
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/MaterialCategorizationLayout.d.ts +4 -3
- package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +4 -3
- package/lib/layouts/MaterialGroupLayout.d.ts +2 -2
- package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
- package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
- package/lib/mui-controls/MuiAutocomplete.d.ts +2 -2
- package/lib/mui-controls/MuiSelect.d.ts +2 -1
- package/lib/util/datejs.d.ts +17 -1
- package/lib/util/i18nDefaults.d.ts +3 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/layout.d.ts +3 -0
- package/package.json +9 -9
- package/src/additional/MaterialLabelRenderer.tsx +5 -7
- package/src/additional/MaterialListWithDetailRenderer.tsx +4 -0
- package/src/cells/MaterialEnumCell.tsx +4 -3
- package/src/cells/MaterialOneOfEnumCell.tsx +3 -3
- package/src/controls/MaterialDateControl.tsx +30 -12
- package/src/controls/MaterialDateTimeControl.tsx +32 -13
- package/src/controls/MaterialEnumControl.tsx +12 -5
- package/src/controls/MaterialOneOfEnumControl.tsx +13 -5
- package/src/controls/MaterialRadioGroup.tsx +1 -1
- package/src/controls/MaterialTimeControl.tsx +31 -13
- package/src/layouts/MaterialCategorizationLayout.tsx +18 -9
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +19 -12
- package/src/layouts/MaterialGroupLayout.tsx +6 -5
- package/src/mui-controls/MuiAutocomplete.tsx +81 -37
- package/src/mui-controls/MuiInputText.tsx +4 -1
- package/src/mui-controls/MuiSelect.tsx +10 -5
- package/src/util/datejs.tsx +73 -0
- package/src/util/i18nDefaults.ts +3 -0
- package/src/util/index.ts +1 -0
- package/src/util/layout.tsx +4 -0
- package/stats.html +1 -1
- package/test/renderers/MaterialArrayLayout.test.tsx +4 -4
- package/test/renderers/MaterialCategorizationLayout.test.tsx +17 -7
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +21 -11
- package/test/renderers/MaterialDateControl.test.tsx +27 -0
- package/test/renderers/MaterialDateTimeControl.test.tsx +29 -2
- package/test/renderers/MaterialGroupLayout.test.tsx +4 -1
- package/test/renderers/MaterialInputControl.test.tsx +4 -0
- package/test/renderers/MaterialLabelRenderer.test.tsx +2 -1
- package/test/renderers/MaterialTimeControl.test.tsx +28 -1
- package/test/renderers/util.ts +5 -0
- package/src/util/datejs.ts +0 -32
|
@@ -67,7 +67,7 @@ const uischema = {
|
|
|
67
67
|
describe('Material group layout', () => {
|
|
68
68
|
it('should render a GroupComponent with direction column when given no direction LayoutProp', () => {
|
|
69
69
|
const wrapper = mount(
|
|
70
|
-
<MaterialGroupLayout schema={schema} uischema={uischema} />
|
|
70
|
+
<MaterialGroupLayout schema={schema} uischema={uischema} direction="column" enabled visible path=""/>
|
|
71
71
|
);
|
|
72
72
|
expect(wrapper.find(MaterialLayoutRenderer).props().direction).toBe(
|
|
73
73
|
'column'
|
|
@@ -80,6 +80,9 @@ describe('Material group layout', () => {
|
|
|
80
80
|
schema={schema}
|
|
81
81
|
uischema={uischema}
|
|
82
82
|
direction={'row'}
|
|
83
|
+
enabled
|
|
84
|
+
visible
|
|
85
|
+
path=""
|
|
83
86
|
/>
|
|
84
87
|
);
|
|
85
88
|
expect(wrapper.find(MaterialLayoutRenderer).props().direction).toBe('row');
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import './MatchMediaMock';
|
|
26
26
|
import * as React from 'react';
|
|
27
27
|
import {
|
|
28
|
+
LabelElement,
|
|
28
29
|
NOT_APPLICABLE
|
|
29
30
|
} from '@jsonforms/core';
|
|
30
31
|
import '../../src/cells';
|
|
@@ -44,7 +45,7 @@ const schema = {
|
|
|
44
45
|
type: 'object',
|
|
45
46
|
properties: {}
|
|
46
47
|
};
|
|
47
|
-
const uischema = {
|
|
48
|
+
const uischema: LabelElement = {
|
|
48
49
|
type: 'Label',
|
|
49
50
|
text: 'Foo'
|
|
50
51
|
};
|
|
@@ -377,8 +377,35 @@ describe('Material time control', () => {
|
|
|
377
377
|
const input = wrapper.find('input').first();
|
|
378
378
|
expect(input.props().value).toBe('02-13');
|
|
379
379
|
|
|
380
|
-
(input.getDOMNode() as HTMLInputElement).value = '12
|
|
380
|
+
(input.getDOMNode() as HTMLInputElement).value = '12-01';
|
|
381
381
|
input.simulate('change', input);
|
|
382
382
|
expect(onChangeData.data.foo).toBe('1//12 am');
|
|
383
383
|
});
|
|
384
|
+
|
|
385
|
+
it('should call onChange with original input value for invalid date strings', () => {
|
|
386
|
+
const core = initCore(schema, uischema);
|
|
387
|
+
const onChangeData: any = {
|
|
388
|
+
data: undefined
|
|
389
|
+
};
|
|
390
|
+
wrapper = mount(
|
|
391
|
+
<JsonFormsStateProvider initState={{ renderers: materialRenderers, core }}>
|
|
392
|
+
<TestEmitter
|
|
393
|
+
onChange={({ data }) => {
|
|
394
|
+
onChangeData.data = data;
|
|
395
|
+
}}
|
|
396
|
+
/>
|
|
397
|
+
<MaterialTimeControl
|
|
398
|
+
schema={schema}
|
|
399
|
+
uischema={{...uischema}}
|
|
400
|
+
/>
|
|
401
|
+
</JsonFormsStateProvider>
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
const input = wrapper.find('input').first();
|
|
405
|
+
expect(input.props().value).toBe('');
|
|
406
|
+
|
|
407
|
+
(input.getDOMNode() as HTMLInputElement).value = 'invalid date string';
|
|
408
|
+
input.simulate('change', input);
|
|
409
|
+
expect(onChangeData.data.foo).toBe('invalid date string');
|
|
410
|
+
});
|
|
384
411
|
});
|
package/test/renderers/util.ts
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import {
|
|
27
27
|
createAjv,
|
|
28
28
|
JsonSchema,
|
|
29
|
+
TesterContext,
|
|
29
30
|
UISchemaElement
|
|
30
31
|
} from '@jsonforms/core';
|
|
31
32
|
import { JsonFormsReactProps, useJsonForms } from '@jsonforms/react';
|
|
@@ -43,3 +44,7 @@ export const TestEmitter : React.FC<JsonFormsReactProps> = ({onChange}) => {
|
|
|
43
44
|
}, [data, errors]);
|
|
44
45
|
return null;
|
|
45
46
|
};
|
|
47
|
+
|
|
48
|
+
export const createTesterContext = (rootSchema: JsonSchema, config?: any): TesterContext => {
|
|
49
|
+
return { rootSchema, config };
|
|
50
|
+
};
|
package/src/util/datejs.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import customParsing from 'dayjs/plugin/customParseFormat';
|
|
3
|
-
|
|
4
|
-
// required for the custom save formats in the date, time and date-time pickers
|
|
5
|
-
dayjs.extend(customParsing);
|
|
6
|
-
|
|
7
|
-
export const createOnChangeHandler = (
|
|
8
|
-
path: string,
|
|
9
|
-
handleChange: (path: string, value: any) => void,
|
|
10
|
-
saveFormat: string | undefined
|
|
11
|
-
) => (time: dayjs.Dayjs) => {
|
|
12
|
-
if (!time) {
|
|
13
|
-
handleChange(path, undefined);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const result = dayjs(time).format(saveFormat);
|
|
17
|
-
handleChange(path, result === 'Invalid Date' ? undefined : result);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const getData = (
|
|
21
|
-
data: any,
|
|
22
|
-
saveFormat: string | undefined
|
|
23
|
-
): dayjs.Dayjs | null => {
|
|
24
|
-
if (!data) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const dayjsData = dayjs(data, saveFormat);
|
|
28
|
-
if (dayjsData.toString() === 'Invalid Date') {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return dayjsData;
|
|
32
|
-
};
|