@jsonforms/material-renderers 3.1.0-alpha.0 → 3.1.0-alpha.2
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/README.md +16 -17
- package/lib/additional/ListWithDetailMasterItem.d.ts +2 -0
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/additional/index.d.ts +2 -2
- package/lib/additional/unwrapped.d.ts +5 -0
- package/lib/cells/index.d.ts +1 -1
- package/lib/complex/CombinatorProperties.d.ts +1 -2
- package/lib/complex/DeleteDialog.d.ts +5 -1
- package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialArrayControlRenderer.d.ts +2 -1
- package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
- package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
- package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialTableControl.d.ts +4 -2
- package/lib/complex/NoBorderTableCell.d.ts +2 -2
- package/lib/complex/TableToolbar.d.ts +3 -2
- package/lib/complex/index.d.ts +11 -16
- package/lib/complex/unwrapped.d.ts +9 -0
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/index.d.ts +8 -26
- package/lib/controls/unwrapped.d.ts +19 -0
- package/lib/index.d.ts +34 -1
- package/lib/jsonforms-react-material.cjs.js +731 -572
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +648 -517
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/ArrayToolbar.d.ts +3 -1
- package/lib/layouts/ExpandPanelRenderer.d.ts +3 -1
- package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
- package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
- package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
- package/lib/layouts/index.d.ts +3 -1
- package/lib/layouts/unwrapped.d.ts +10 -0
- package/lib/mui-controls/MuiCheckbox.d.ts +6 -1
- package/lib/mui-controls/MuiInputInteger.d.ts +1 -1
- package/lib/mui-controls/MuiInputNumber.d.ts +1 -1
- package/lib/mui-controls/MuiInputNumberFormat.d.ts +1 -1
- package/lib/mui-controls/MuiInputText.d.ts +1 -1
- package/lib/mui-controls/MuiInputTime.d.ts +1 -1
- package/lib/mui-controls/MuiSelect.d.ts +1 -1
- package/lib/mui-controls/MuiToggle.d.ts +6 -1
- package/lib/mui-controls/index.d.ts +3 -1
- package/lib/util/layout.d.ts +2 -3
- package/package.json +33 -15
- package/src/additional/ListWithDetailMasterItem.tsx +32 -24
- package/src/additional/MaterialLabelRenderer.tsx +8 -15
- package/src/additional/MaterialListWithDetailRenderer.tsx +8 -5
- package/src/additional/index.ts +12 -4
- package/{example/index.ts → src/additional/unwrapped.ts} +7 -6
- package/src/cells/MaterialBooleanCell.tsx +1 -1
- package/src/cells/MaterialBooleanToggleCell.tsx +2 -2
- package/src/cells/MaterialDateCell.tsx +4 -12
- package/src/cells/MaterialEnumCell.tsx +13 -6
- package/src/cells/MaterialIntegerCell.tsx +1 -1
- package/src/cells/MaterialNumberCell.tsx +1 -1
- package/src/cells/MaterialNumberFormatCell.tsx +1 -1
- package/src/cells/MaterialOneOfEnumCell.tsx +17 -7
- package/src/cells/MaterialTextCell.tsx +1 -1
- package/src/cells/MaterialTimeCell.tsx +1 -1
- package/src/cells/index.ts +7 -7
- package/src/complex/CombinatorProperties.tsx +20 -9
- package/src/complex/DeleteDialog.tsx +48 -37
- package/src/complex/MaterialAllOfRenderer.tsx +2 -2
- package/src/complex/MaterialAnyOfRenderer.tsx +3 -3
- package/src/complex/MaterialArrayControlRenderer.tsx +27 -11
- package/src/complex/MaterialEnumArrayRenderer.tsx +6 -8
- package/src/complex/MaterialObjectRenderer.tsx +6 -3
- package/src/complex/MaterialOneOfRenderer.tsx +105 -88
- package/src/complex/MaterialTableControl.tsx +145 -97
- package/src/complex/NoBorderTableCell.tsx +3 -5
- package/src/complex/TableToolbar.tsx +24 -25
- package/src/complex/ValidationIcon.tsx +10 -18
- package/src/complex/index.ts +35 -32
- package/{test/renderers/MatchMediaMock.ts → src/complex/unwrapped.ts} +19 -16
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +19 -11
- package/src/controls/MaterialBooleanControl.tsx +90 -23
- package/src/controls/MaterialBooleanToggleControl.tsx +90 -23
- package/src/controls/MaterialDateControl.tsx +16 -19
- package/src/controls/MaterialDateTimeControl.tsx +24 -23
- package/src/controls/MaterialEnumControl.tsx +21 -15
- package/src/controls/MaterialInputControl.tsx +7 -8
- package/src/controls/MaterialIntegerControl.tsx +1 -1
- package/src/controls/MaterialNativeControl.tsx +12 -9
- package/src/controls/MaterialNumberControl.tsx +1 -1
- package/src/controls/MaterialOneOfEnumControl.tsx +21 -15
- package/src/controls/MaterialOneOfRadioGroupControl.tsx +5 -3
- package/src/controls/MaterialRadioGroup.tsx +11 -17
- package/src/controls/MaterialRadioGroupControl.tsx +8 -3
- package/src/controls/MaterialSliderControl.tsx +17 -16
- package/src/controls/MaterialTextControl.tsx +1 -1
- package/src/controls/MaterialTimeControl.tsx +19 -22
- package/src/controls/index.ts +36 -72
- package/src/controls/unwrapped.ts +57 -0
- package/src/index.ts +41 -22
- package/src/layouts/ArrayToolbar.tsx +38 -42
- package/src/layouts/ExpandPanelRenderer.tsx +96 -67
- package/src/layouts/MaterialArrayLayout.tsx +21 -16
- package/src/layouts/MaterialArrayLayoutRenderer.tsx +6 -9
- package/src/layouts/MaterialCategorizationLayout.tsx +52 -21
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +60 -44
- package/src/layouts/MaterialGroupLayout.tsx +25 -6
- package/src/layouts/MaterialHorizontalLayout.tsx +18 -4
- package/src/layouts/MaterialVerticalLayout.tsx +18 -4
- package/src/layouts/index.ts +18 -7
- package/{test/renderers/util.ts → src/layouts/unwrapped.ts} +19 -28
- package/src/mui-controls/MuiAutocomplete.tsx +51 -35
- package/src/mui-controls/MuiCheckbox.tsx +14 -5
- package/src/mui-controls/MuiInputInteger.tsx +31 -32
- package/src/mui-controls/MuiInputNumber.tsx +16 -16
- package/src/mui-controls/MuiInputNumberFormat.tsx +51 -42
- package/src/mui-controls/MuiInputText.tsx +30 -19
- package/src/mui-controls/MuiInputTime.tsx +11 -12
- package/src/mui-controls/MuiSelect.tsx +15 -6
- package/src/mui-controls/MuiToggle.tsx +14 -5
- package/src/mui-controls/index.ts +3 -1
- package/src/util/datejs.tsx +41 -20
- package/src/util/debounce.ts +26 -11
- package/src/util/focus.ts +7 -7
- package/src/util/i18nDefaults.ts +2 -2
- package/src/util/layout.tsx +47 -42
- package/src/util/theme.ts +2 -2
- 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/rollup.config.js +0 -51
- package/stats.html +0 -3279
- 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/tsconfig.json +0 -13
- package/tsconfig.test.json +0 -7
- package/webpack/webpack.dev.js +0 -11
|
@@ -29,8 +29,7 @@ import {
|
|
|
29
29
|
isDescriptionHidden,
|
|
30
30
|
} from '@jsonforms/core';
|
|
31
31
|
|
|
32
|
-
import { Hidden, InputLabel } from '@mui/material';
|
|
33
|
-
import { FormControl, FormHelperText } from '@mui/material';
|
|
32
|
+
import { Hidden, InputLabel, FormControl, FormHelperText } from '@mui/material';
|
|
34
33
|
import merge from 'lodash/merge';
|
|
35
34
|
import { useFocus } from '../util';
|
|
36
35
|
|
|
@@ -49,7 +48,7 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
|
|
|
49
48
|
visible,
|
|
50
49
|
required,
|
|
51
50
|
config,
|
|
52
|
-
input
|
|
51
|
+
input,
|
|
53
52
|
} = props;
|
|
54
53
|
const isValid = errors.length === 0;
|
|
55
54
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
@@ -81,8 +80,10 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
|
|
|
81
80
|
<InputLabel
|
|
82
81
|
htmlFor={id + '-input'}
|
|
83
82
|
error={!isValid}
|
|
84
|
-
required={showAsRequired(
|
|
85
|
-
|
|
83
|
+
required={showAsRequired(
|
|
84
|
+
required,
|
|
85
|
+
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
86
|
+
)}
|
|
86
87
|
>
|
|
87
88
|
{label}
|
|
88
89
|
</InputLabel>
|
|
@@ -95,9 +96,7 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
|
|
|
95
96
|
<FormHelperText error={!isValid && !showDescription}>
|
|
96
97
|
{firstFormHelperText}
|
|
97
98
|
</FormHelperText>
|
|
98
|
-
<FormHelperText error={!isValid}>
|
|
99
|
-
{secondFormHelperText}
|
|
100
|
-
</FormHelperText>
|
|
99
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
101
100
|
</FormControl>
|
|
102
101
|
</Hidden>
|
|
103
102
|
);
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
isTimeControl,
|
|
32
32
|
or,
|
|
33
33
|
RankedTester,
|
|
34
|
-
rankWith
|
|
34
|
+
rankWith,
|
|
35
35
|
} from '@jsonforms/core';
|
|
36
36
|
import { Hidden, TextField } from '@mui/material';
|
|
37
37
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
@@ -52,15 +52,16 @@ export const MaterialNativeControl = (props: ControlProps) => {
|
|
|
52
52
|
path,
|
|
53
53
|
handleChange,
|
|
54
54
|
data,
|
|
55
|
-
config
|
|
55
|
+
config,
|
|
56
56
|
} = props;
|
|
57
57
|
const isValid = errors.length === 0;
|
|
58
|
-
const appliedUiSchemaOptions = merge(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
|
|
59
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
60
|
+
handleChange,
|
|
61
|
+
'',
|
|
62
|
+
data,
|
|
63
|
+
path
|
|
62
64
|
);
|
|
63
|
-
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
|
|
64
65
|
const fieldType = appliedUiSchemaOptions.format ?? schema.format;
|
|
65
66
|
const showDescription = !isDescriptionHidden(
|
|
66
67
|
visible,
|
|
@@ -72,8 +73,10 @@ export const MaterialNativeControl = (props: ControlProps) => {
|
|
|
72
73
|
return (
|
|
73
74
|
<Hidden xsUp={!visible}>
|
|
74
75
|
<TextField
|
|
75
|
-
required={showAsRequired(
|
|
76
|
-
|
|
76
|
+
required={showAsRequired(
|
|
77
|
+
required,
|
|
78
|
+
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
79
|
+
)}
|
|
77
80
|
id={id + '-input'}
|
|
78
81
|
label={label}
|
|
79
82
|
type={fieldType}
|
|
@@ -30,27 +30,30 @@ import {
|
|
|
30
30
|
RankedTester,
|
|
31
31
|
rankWith,
|
|
32
32
|
} from '@jsonforms/core';
|
|
33
|
-
import {
|
|
34
|
-
|
|
33
|
+
import {
|
|
34
|
+
TranslateProps,
|
|
35
|
+
withJsonFormsOneOfEnumProps,
|
|
36
|
+
withTranslateProps,
|
|
37
|
+
} from '@jsonforms/react';
|
|
38
|
+
import {
|
|
39
|
+
MuiAutocomplete,
|
|
40
|
+
WithOptionLabel,
|
|
41
|
+
} from '../mui-controls/MuiAutocomplete';
|
|
35
42
|
import { MuiSelect } from '../mui-controls/MuiSelect';
|
|
36
43
|
import { MaterialInputControl } from '../controls/MaterialInputControl';
|
|
37
44
|
import merge from 'lodash/merge';
|
|
38
45
|
|
|
39
|
-
export const MaterialOneOfEnumControl = (
|
|
40
|
-
|
|
46
|
+
export const MaterialOneOfEnumControl = (
|
|
47
|
+
props: ControlProps & OwnPropsOfEnum & WithOptionLabel & TranslateProps
|
|
48
|
+
) => {
|
|
49
|
+
const { config, uischema, errors } = props;
|
|
41
50
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
42
51
|
const isValid = errors.length === 0;
|
|
43
52
|
|
|
44
|
-
return (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
input={MuiSelect}
|
|
49
|
-
/>:
|
|
50
|
-
<MuiAutocomplete
|
|
51
|
-
{...props}
|
|
52
|
-
isValid={isValid}
|
|
53
|
-
/>
|
|
53
|
+
return appliedUiSchemaOptions.autocomplete === false ? (
|
|
54
|
+
<MaterialInputControl {...props} input={MuiSelect} />
|
|
55
|
+
) : (
|
|
56
|
+
<MuiAutocomplete {...props} isValid={isValid} />
|
|
54
57
|
);
|
|
55
58
|
};
|
|
56
59
|
|
|
@@ -60,4 +63,7 @@ export const materialOneOfEnumControlTester: RankedTester = rankWith(
|
|
|
60
63
|
);
|
|
61
64
|
|
|
62
65
|
// HOC order can be reversed with https://github.com/eclipsesource/jsonforms/issues/1987
|
|
63
|
-
export default withJsonFormsOneOfEnumProps(
|
|
66
|
+
export default withJsonFormsOneOfEnumProps(
|
|
67
|
+
withTranslateProps(React.memo(MaterialOneOfEnumControl)),
|
|
68
|
+
false
|
|
69
|
+
);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import {
|
|
27
|
-
|
|
27
|
+
and,
|
|
28
28
|
ControlProps,
|
|
29
29
|
isOneOfEnumControl,
|
|
30
30
|
optionIs,
|
|
@@ -35,8 +35,10 @@ import {
|
|
|
35
35
|
import { withJsonFormsOneOfEnumProps } from '@jsonforms/react';
|
|
36
36
|
import { MaterialRadioGroup } from './MaterialRadioGroup';
|
|
37
37
|
|
|
38
|
-
export const MaterialOneOfRadioGroupControl = (
|
|
39
|
-
|
|
38
|
+
export const MaterialOneOfRadioGroupControl = (
|
|
39
|
+
props: ControlProps & OwnPropsOfEnum
|
|
40
|
+
) => {
|
|
41
|
+
return <MaterialRadioGroup {...props} />;
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
export const materialOneOfRadioGroupControlTester: RankedTester = rankWith(
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
ControlProps,
|
|
29
29
|
showAsRequired,
|
|
30
30
|
isDescriptionHidden,
|
|
31
|
-
OwnPropsOfEnum
|
|
31
|
+
OwnPropsOfEnum,
|
|
32
32
|
} from '@jsonforms/core';
|
|
33
33
|
import {
|
|
34
34
|
FormControl,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
FormLabel,
|
|
38
38
|
Hidden,
|
|
39
39
|
Radio,
|
|
40
|
-
RadioGroup
|
|
40
|
+
RadioGroup,
|
|
41
41
|
} from '@mui/material';
|
|
42
42
|
import { useFocus } from '../util';
|
|
43
43
|
|
|
@@ -55,21 +55,17 @@ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
|
|
|
55
55
|
options,
|
|
56
56
|
handleChange,
|
|
57
57
|
path,
|
|
58
|
-
enabled
|
|
58
|
+
enabled,
|
|
59
59
|
} = props;
|
|
60
60
|
const isValid = errors.length === 0;
|
|
61
|
-
const appliedUiSchemaOptions = merge(
|
|
62
|
-
{},
|
|
63
|
-
config,
|
|
64
|
-
props.uischema.options
|
|
65
|
-
);
|
|
61
|
+
const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
|
|
66
62
|
const showDescription = !isDescriptionHidden(
|
|
67
63
|
visible,
|
|
68
64
|
description,
|
|
69
65
|
focused,
|
|
70
66
|
appliedUiSchemaOptions.showUnfocusedDescription
|
|
71
67
|
);
|
|
72
|
-
const onChange = (_ev:any, value:any) => handleChange(path, value);
|
|
68
|
+
const onChange = (_ev: any, value: any) => handleChange(path, value);
|
|
73
69
|
|
|
74
70
|
return (
|
|
75
71
|
<Hidden xsUp={!visible}>
|
|
@@ -83,18 +79,16 @@ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
|
|
|
83
79
|
htmlFor={id}
|
|
84
80
|
error={!isValid}
|
|
85
81
|
component={'legend' as 'label'}
|
|
86
|
-
required={showAsRequired(
|
|
87
|
-
|
|
82
|
+
required={showAsRequired(
|
|
83
|
+
required,
|
|
84
|
+
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
85
|
+
)}
|
|
88
86
|
>
|
|
89
87
|
{label}
|
|
90
88
|
</FormLabel>
|
|
91
89
|
|
|
92
|
-
<RadioGroup
|
|
93
|
-
|
|
94
|
-
onChange={onChange}
|
|
95
|
-
row={true}
|
|
96
|
-
>
|
|
97
|
-
{options.map(option => (
|
|
90
|
+
<RadioGroup value={props.data ?? ''} onChange={onChange} row={true}>
|
|
91
|
+
{options.map((option) => (
|
|
98
92
|
<FormControlLabel
|
|
99
93
|
value={option.value}
|
|
100
94
|
key={option.label}
|
|
@@ -27,11 +27,16 @@ import {
|
|
|
27
27
|
and,
|
|
28
28
|
ControlProps,
|
|
29
29
|
isEnumControl,
|
|
30
|
-
optionIs,
|
|
30
|
+
optionIs,
|
|
31
|
+
OwnPropsOfEnum,
|
|
32
|
+
RankedTester,
|
|
33
|
+
rankWith,
|
|
31
34
|
} from '@jsonforms/core';
|
|
32
|
-
import {
|
|
35
|
+
import { withJsonFormsEnumProps } from '@jsonforms/react';
|
|
33
36
|
import { MaterialRadioGroup } from './MaterialRadioGroup';
|
|
34
|
-
export const MaterialRadioGroupControl = (
|
|
37
|
+
export const MaterialRadioGroupControl = (
|
|
38
|
+
props: ControlProps & OwnPropsOfEnum
|
|
39
|
+
) => {
|
|
35
40
|
return <MaterialRadioGroup {...props} />;
|
|
36
41
|
};
|
|
37
42
|
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
import React, {useCallback} from 'react';
|
|
25
|
+
import React, { useCallback } from 'react';
|
|
26
26
|
import {
|
|
27
27
|
ControlProps,
|
|
28
28
|
showAsRequired,
|
|
29
29
|
isDescriptionHidden,
|
|
30
30
|
isRangeControl,
|
|
31
31
|
RankedTester,
|
|
32
|
-
rankWith
|
|
32
|
+
rankWith,
|
|
33
33
|
} from '@jsonforms/core';
|
|
34
34
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
35
35
|
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
FormLabel,
|
|
40
40
|
Hidden,
|
|
41
41
|
Slider,
|
|
42
|
-
Typography
|
|
42
|
+
Typography,
|
|
43
43
|
} from '@mui/material';
|
|
44
44
|
import merge from 'lodash/merge';
|
|
45
45
|
import { useFocus } from '../util';
|
|
@@ -58,28 +58,24 @@ export const MaterialSliderControl = (props: ControlProps) => {
|
|
|
58
58
|
visible,
|
|
59
59
|
path,
|
|
60
60
|
required,
|
|
61
|
-
config
|
|
61
|
+
config,
|
|
62
62
|
} = props;
|
|
63
63
|
const isValid = errors.length === 0;
|
|
64
|
-
const appliedUiSchemaOptions = merge(
|
|
65
|
-
{},
|
|
66
|
-
config,
|
|
67
|
-
props.uischema.options
|
|
68
|
-
);
|
|
64
|
+
const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
|
|
69
65
|
const labelStyle: { [x: string]: any } = {
|
|
70
66
|
whiteSpace: 'nowrap',
|
|
71
67
|
overflow: 'hidden',
|
|
72
68
|
textOverflow: 'ellipsis',
|
|
73
|
-
width: '100%'
|
|
69
|
+
width: '100%',
|
|
74
70
|
};
|
|
75
71
|
const rangeContainerStyle: { [x: string]: any } = {
|
|
76
|
-
display: 'flex'
|
|
72
|
+
display: 'flex',
|
|
77
73
|
};
|
|
78
74
|
const rangeItemStyle: { [x: string]: any } = {
|
|
79
|
-
flexGrow: '1'
|
|
75
|
+
flexGrow: '1',
|
|
80
76
|
};
|
|
81
77
|
const sliderStyle: { [x: string]: any } = {
|
|
82
|
-
marginTop: '7px'
|
|
78
|
+
marginTop: '7px',
|
|
83
79
|
};
|
|
84
80
|
|
|
85
81
|
const showDescription = !isDescriptionHidden(
|
|
@@ -89,7 +85,10 @@ export const MaterialSliderControl = (props: ControlProps) => {
|
|
|
89
85
|
appliedUiSchemaOptions.showUnfocusedDescription
|
|
90
86
|
);
|
|
91
87
|
|
|
92
|
-
const onChange = useCallback(
|
|
88
|
+
const onChange = useCallback(
|
|
89
|
+
(_ev: any, value: any) => handleChange(path, Number(value)),
|
|
90
|
+
[path, handleChange]
|
|
91
|
+
);
|
|
93
92
|
|
|
94
93
|
return (
|
|
95
94
|
<Hidden xsUp={!visible}>
|
|
@@ -103,8 +102,10 @@ export const MaterialSliderControl = (props: ControlProps) => {
|
|
|
103
102
|
htmlFor={id}
|
|
104
103
|
error={!isValid}
|
|
105
104
|
component={'legend' as 'label'}
|
|
106
|
-
required={showAsRequired(
|
|
107
|
-
|
|
105
|
+
required={showAsRequired(
|
|
106
|
+
required,
|
|
107
|
+
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
108
|
+
)}
|
|
108
109
|
>
|
|
109
110
|
<Typography id={id + '-typo'} style={labelStyle} variant='caption'>
|
|
110
111
|
{label}
|
|
@@ -29,25 +29,22 @@ import {
|
|
|
29
29
|
isTimeControl,
|
|
30
30
|
isDescriptionHidden,
|
|
31
31
|
RankedTester,
|
|
32
|
-
rankWith
|
|
32
|
+
rankWith,
|
|
33
33
|
} from '@jsonforms/core';
|
|
34
34
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
35
35
|
import { FormHelperText, Hidden } from '@mui/material';
|
|
36
|
-
import {
|
|
37
|
-
TimePicker,
|
|
38
|
-
LocalizationProvider
|
|
39
|
-
} from '@mui/x-date-pickers';
|
|
36
|
+
import { TimePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
40
37
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
41
38
|
import {
|
|
42
39
|
createOnChangeHandler,
|
|
43
40
|
getData,
|
|
44
41
|
ResettableTextField,
|
|
45
|
-
useFocus
|
|
42
|
+
useFocus,
|
|
46
43
|
} from '../util';
|
|
47
44
|
|
|
48
45
|
export const MaterialTimeControl = (props: ControlProps) => {
|
|
49
46
|
const [focused, onFocus, onBlur] = useFocus();
|
|
50
|
-
|
|
47
|
+
const {
|
|
51
48
|
id,
|
|
52
49
|
description,
|
|
53
50
|
errors,
|
|
@@ -59,7 +56,7 @@ export const MaterialTimeControl = (props: ControlProps) => {
|
|
|
59
56
|
path,
|
|
60
57
|
handleChange,
|
|
61
58
|
data,
|
|
62
|
-
config
|
|
59
|
+
config,
|
|
63
60
|
} = props;
|
|
64
61
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
65
62
|
const isValid = errors.length === 0;
|
|
@@ -83,11 +80,10 @@ export const MaterialTimeControl = (props: ControlProps) => {
|
|
|
83
80
|
: null;
|
|
84
81
|
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
85
82
|
|
|
86
|
-
const onChange = useMemo(
|
|
87
|
-
path,
|
|
88
|
-
handleChange,
|
|
89
|
-
|
|
90
|
-
),[path, handleChange, saveFormat]);
|
|
83
|
+
const onChange = useMemo(
|
|
84
|
+
() => createOnChangeHandler(path, handleChange, saveFormat),
|
|
85
|
+
[path, handleChange, saveFormat]
|
|
86
|
+
);
|
|
91
87
|
|
|
92
88
|
const value = getData(data, saveFormat);
|
|
93
89
|
const valueInInputFormat = value ? value.format(format) : '';
|
|
@@ -106,24 +102,27 @@ export const MaterialTimeControl = (props: ControlProps) => {
|
|
|
106
102
|
disabled={!enabled}
|
|
107
103
|
componentsProps={{
|
|
108
104
|
actionBar: {
|
|
109
|
-
actions: (variant) =>
|
|
110
|
-
|
|
105
|
+
actions: (variant) =>
|
|
106
|
+
variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
|
|
107
|
+
},
|
|
111
108
|
}}
|
|
112
|
-
renderInput={params => (
|
|
113
|
-
<ResettableTextField
|
|
109
|
+
renderInput={(params) => (
|
|
110
|
+
<ResettableTextField
|
|
114
111
|
{...params}
|
|
115
112
|
rawValue={data}
|
|
116
113
|
dayjsValueIsValid={value !== null}
|
|
117
114
|
valueInInputFormat={valueInInputFormat}
|
|
118
115
|
focused={focused}
|
|
119
116
|
id={id + '-input'}
|
|
120
|
-
required={
|
|
117
|
+
required={
|
|
118
|
+
required && !appliedUiSchemaOptions.hideRequiredAsterisk
|
|
119
|
+
}
|
|
121
120
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
122
121
|
error={!isValid}
|
|
123
122
|
fullWidth={!appliedUiSchemaOptions.trim}
|
|
124
123
|
inputProps={{
|
|
125
124
|
...params.inputProps,
|
|
126
|
-
type: 'text'
|
|
125
|
+
type: 'text',
|
|
127
126
|
}}
|
|
128
127
|
InputLabelProps={data ? { shrink: true } : undefined}
|
|
129
128
|
onFocus={onFocus}
|
|
@@ -135,9 +134,7 @@ export const MaterialTimeControl = (props: ControlProps) => {
|
|
|
135
134
|
<FormHelperText error={!isValid && !showDescription}>
|
|
136
135
|
{firstFormHelperText}
|
|
137
136
|
</FormHelperText>
|
|
138
|
-
<FormHelperText error={!isValid}>
|
|
139
|
-
{secondFormHelperText}
|
|
140
|
-
</FormHelperText>
|
|
137
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
141
138
|
</LocalizationProvider>
|
|
142
139
|
</Hidden>
|
|
143
140
|
);
|
package/src/controls/index.ts
CHANGED
|
@@ -22,119 +22,83 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
+
import MaterialAnyOfStringOrEnumControl, {
|
|
26
|
+
materialAnyOfStringOrEnumControlTester,
|
|
27
|
+
} from './MaterialAnyOfStringOrEnumControl';
|
|
25
28
|
import MaterialBooleanControl, {
|
|
26
29
|
materialBooleanControlTester,
|
|
27
|
-
MaterialBooleanControl as MaterialBooleanControlUnwrapped
|
|
28
30
|
} from './MaterialBooleanControl';
|
|
29
31
|
import MaterialBooleanToggleControl, {
|
|
30
32
|
materialBooleanToggleControlTester,
|
|
31
|
-
MaterialBooleanToggleControl as MaterialBooleanToggleControlUnwrapped
|
|
32
33
|
} from './MaterialBooleanToggleControl';
|
|
33
|
-
import MaterialEnumControl, {
|
|
34
|
-
materialEnumControlTester,
|
|
35
|
-
MaterialEnumControl as MaterialEnumControlUnwrapped
|
|
36
|
-
} from './MaterialEnumControl';
|
|
37
|
-
import MaterialNativeControl, {
|
|
38
|
-
materialNativeControlTester,
|
|
39
|
-
MaterialNativeControl as MaterialNativeControlUnwrapped
|
|
40
|
-
} from './MaterialNativeControl';
|
|
41
34
|
import MaterialDateControl, {
|
|
42
35
|
materialDateControlTester,
|
|
43
|
-
MaterialDateControl as MaterialDateControlUnwrapped
|
|
44
36
|
} from './MaterialDateControl';
|
|
45
37
|
import MaterialDateTimeControl, {
|
|
46
38
|
materialDateTimeControlTester,
|
|
47
|
-
MaterialDateTimeControl as MaterialDateTimeControlUnwrapped
|
|
48
39
|
} from './MaterialDateTimeControl';
|
|
49
|
-
import
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} from './MaterialTimeControl';
|
|
53
|
-
import MaterialSliderControl, {
|
|
54
|
-
materialSliderControlTester,
|
|
55
|
-
MaterialSliderControl as MaterialSliderControlUnwrapped
|
|
56
|
-
} from './MaterialSliderControl';
|
|
57
|
-
import MaterialRadioGroupControl, {
|
|
58
|
-
materialRadioGroupControlTester,
|
|
59
|
-
MaterialRadioGroupControl as MaterialRadioGroupControlUnwrapped
|
|
60
|
-
} from './MaterialRadioGroupControl';
|
|
40
|
+
import MaterialEnumControl, {
|
|
41
|
+
materialEnumControlTester,
|
|
42
|
+
} from './MaterialEnumControl';
|
|
61
43
|
import MaterialIntegerControl, {
|
|
62
44
|
materialIntegerControlTester,
|
|
63
|
-
MaterialIntegerControl as MaterialIntegerControlUnwrapped
|
|
64
45
|
} from './MaterialIntegerControl';
|
|
46
|
+
import MaterialNativeControl, {
|
|
47
|
+
materialNativeControlTester,
|
|
48
|
+
} from './MaterialNativeControl';
|
|
65
49
|
import MaterialNumberControl, {
|
|
66
50
|
materialNumberControlTester,
|
|
67
|
-
MaterialNumberControl as MaterialNumberControlUnwrapped
|
|
68
51
|
} from './MaterialNumberControl';
|
|
69
|
-
import MaterialTextControl, {
|
|
70
|
-
materialTextControlTester,
|
|
71
|
-
MaterialTextControl as MaterialTextControlUnwrapped
|
|
72
|
-
} from './MaterialTextControl';
|
|
73
|
-
|
|
74
|
-
import MaterialAnyOfStringOrEnumControl, {
|
|
75
|
-
materialAnyOfStringOrEnumControlTester,
|
|
76
|
-
MaterialAnyOfStringOrEnumControl as MaterialAnyOfStringOrEnumControlUnwrapped
|
|
77
|
-
} from './MaterialAnyOfStringOrEnumControl';
|
|
78
|
-
|
|
79
52
|
import MaterialOneOfEnumControl, {
|
|
80
53
|
materialOneOfEnumControlTester,
|
|
81
|
-
MaterialOneOfEnumControl as MaterialOneOfEnumControlUnwrapped
|
|
82
54
|
} from './MaterialOneOfEnumControl';
|
|
83
|
-
|
|
84
55
|
import MaterialOneOfRadioGroupControl, {
|
|
85
56
|
materialOneOfRadioGroupControlTester,
|
|
86
|
-
MaterialOneOfRadioGroupControl as MaterialOneOfRadioGroupControlUnwrapped
|
|
87
57
|
} from './MaterialOneOfRadioGroupControl';
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
MaterialNumberControl: MaterialNumberControlUnwrapped,
|
|
101
|
-
MaterialTextControl: MaterialTextControlUnwrapped,
|
|
102
|
-
MaterialAnyOfStringOrEnumControl: MaterialAnyOfStringOrEnumControlUnwrapped,
|
|
103
|
-
MaterialOneOfEnumControl: MaterialOneOfEnumControlUnwrapped,
|
|
104
|
-
MaterialOneOfRadioGroupControl: MaterialOneOfRadioGroupControlUnwrapped
|
|
105
|
-
};
|
|
58
|
+
import MaterialRadioGroupControl, {
|
|
59
|
+
materialRadioGroupControlTester,
|
|
60
|
+
} from './MaterialRadioGroupControl';
|
|
61
|
+
import MaterialSliderControl, {
|
|
62
|
+
materialSliderControlTester,
|
|
63
|
+
} from './MaterialSliderControl';
|
|
64
|
+
import MaterialTextControl, {
|
|
65
|
+
materialTextControlTester,
|
|
66
|
+
} from './MaterialTextControl';
|
|
67
|
+
import MaterialTimeControl, {
|
|
68
|
+
materialTimeControlTester,
|
|
69
|
+
} from './MaterialTimeControl';
|
|
106
70
|
|
|
107
71
|
export {
|
|
72
|
+
MaterialAnyOfStringOrEnumControl,
|
|
73
|
+
materialAnyOfStringOrEnumControlTester,
|
|
108
74
|
MaterialBooleanControl,
|
|
109
75
|
materialBooleanControlTester,
|
|
110
76
|
MaterialBooleanToggleControl,
|
|
111
77
|
materialBooleanToggleControlTester,
|
|
112
|
-
MaterialEnumControl,
|
|
113
|
-
materialEnumControlTester,
|
|
114
|
-
MaterialNativeControl,
|
|
115
|
-
materialNativeControlTester,
|
|
116
78
|
MaterialDateControl,
|
|
117
79
|
materialDateControlTester,
|
|
118
80
|
MaterialDateTimeControl,
|
|
119
81
|
materialDateTimeControlTester,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
MaterialSliderControl,
|
|
123
|
-
materialSliderControlTester,
|
|
124
|
-
MaterialRadioGroupControl,
|
|
125
|
-
materialRadioGroupControlTester,
|
|
82
|
+
MaterialEnumControl,
|
|
83
|
+
materialEnumControlTester,
|
|
126
84
|
MaterialIntegerControl,
|
|
127
85
|
materialIntegerControlTester,
|
|
86
|
+
MaterialNativeControl,
|
|
87
|
+
materialNativeControlTester,
|
|
128
88
|
MaterialNumberControl,
|
|
129
89
|
materialNumberControlTester,
|
|
130
|
-
MaterialTextControl,
|
|
131
|
-
materialTextControlTester,
|
|
132
|
-
MaterialAnyOfStringOrEnumControl,
|
|
133
|
-
materialAnyOfStringOrEnumControlTester,
|
|
134
90
|
MaterialOneOfEnumControl,
|
|
135
91
|
materialOneOfEnumControlTester,
|
|
136
92
|
MaterialOneOfRadioGroupControl,
|
|
137
|
-
materialOneOfRadioGroupControlTester
|
|
93
|
+
materialOneOfRadioGroupControlTester,
|
|
94
|
+
MaterialRadioGroupControl,
|
|
95
|
+
materialRadioGroupControlTester,
|
|
96
|
+
MaterialSliderControl,
|
|
97
|
+
materialSliderControlTester,
|
|
98
|
+
MaterialTextControl,
|
|
99
|
+
materialTextControlTester,
|
|
100
|
+
MaterialTimeControl,
|
|
101
|
+
materialTimeControlTester,
|
|
138
102
|
};
|
|
139
103
|
|
|
140
104
|
export * from './MaterialInputControl';
|