@jsonforms/material-renderers 3.1.0-alpha.1 → 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 +690 -599
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +620 -557
- 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 +1 -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 +1 -1
- package/lib/mui-controls/index.d.ts +3 -1
- package/lib/util/layout.d.ts +2 -3
- package/package.json +16 -9
- package/src/additional/ListWithDetailMasterItem.tsx +31 -23
- package/src/additional/MaterialLabelRenderer.tsx +8 -15
- package/src/additional/MaterialListWithDetailRenderer.tsx +8 -5
- package/src/additional/index.ts +12 -4
- package/src/additional/unwrapped.ts +32 -0
- 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/src/complex/unwrapped.ts +39 -0
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +19 -11
- package/src/controls/MaterialBooleanControl.tsx +22 -16
- package/src/controls/MaterialBooleanToggleControl.tsx +22 -16
- 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/src/layouts/unwrapped.ts +41 -0
- package/src/mui-controls/MuiAutocomplete.tsx +51 -35
- package/src/mui-controls/MuiCheckbox.tsx +5 -3
- 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 +5 -3
- 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
|
@@ -0,0 +1,39 @@
|
|
|
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 { MaterialAllOfRenderer } from './MaterialAllOfRenderer';
|
|
26
|
+
import { MaterialAnyOfRenderer } from './MaterialAnyOfRenderer';
|
|
27
|
+
import { MaterialArrayControlRenderer } from './MaterialArrayControlRenderer';
|
|
28
|
+
import { MaterialEnumArrayRenderer } from './MaterialEnumArrayRenderer';
|
|
29
|
+
import { MaterialObjectRenderer } from './MaterialObjectRenderer';
|
|
30
|
+
import { MaterialOneOfRenderer } from './MaterialOneOfRenderer';
|
|
31
|
+
|
|
32
|
+
export const UnwrappedComplex = {
|
|
33
|
+
MaterialAllOfRenderer,
|
|
34
|
+
MaterialAnyOfRenderer,
|
|
35
|
+
MaterialArrayControlRenderer,
|
|
36
|
+
MaterialEnumArrayRenderer,
|
|
37
|
+
MaterialObjectRenderer,
|
|
38
|
+
MaterialOneOfRenderer,
|
|
39
|
+
};
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
rankWith,
|
|
33
33
|
schemaMatches,
|
|
34
34
|
uiTypeIs,
|
|
35
|
-
WithClassname
|
|
35
|
+
WithClassname,
|
|
36
36
|
} from '@jsonforms/core';
|
|
37
37
|
import { Control, withJsonFormsControlProps } from '@jsonforms/react';
|
|
38
38
|
import { Input, InputBaseComponentProps } from '@mui/material';
|
|
@@ -43,10 +43,10 @@ import { MaterialInputControl } from './MaterialInputControl';
|
|
|
43
43
|
|
|
44
44
|
const findEnumSchema = (schemas: JsonSchema[]) =>
|
|
45
45
|
schemas.find(
|
|
46
|
-
s => s.enum !== undefined && (s.type === 'string' || s.type === undefined)
|
|
46
|
+
(s) => s.enum !== undefined && (s.type === 'string' || s.type === undefined)
|
|
47
47
|
);
|
|
48
48
|
const findTextSchema = (schemas: JsonSchema[]) =>
|
|
49
|
-
schemas.find(s => s.type === 'string' && s.enum === undefined);
|
|
49
|
+
schemas.find((s) => s.type === 'string' && s.enum === undefined);
|
|
50
50
|
|
|
51
51
|
const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
52
52
|
const {
|
|
@@ -59,12 +59,15 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
|
59
59
|
isValid,
|
|
60
60
|
path,
|
|
61
61
|
handleChange,
|
|
62
|
-
schema
|
|
62
|
+
schema,
|
|
63
63
|
} = props;
|
|
64
64
|
const enumSchema = findEnumSchema(schema.anyOf);
|
|
65
65
|
const stringSchema = findTextSchema(schema.anyOf);
|
|
66
66
|
const maxLength = stringSchema.maxLength;
|
|
67
|
-
const appliedUiSchemaOptions = useMemo(
|
|
67
|
+
const appliedUiSchemaOptions = useMemo(
|
|
68
|
+
() => merge({}, config, uischema.options),
|
|
69
|
+
[config, uischema.options]
|
|
70
|
+
);
|
|
68
71
|
const inputProps: InputBaseComponentProps = useMemo(() => {
|
|
69
72
|
let propMemo: InputBaseComponentProps = {};
|
|
70
73
|
if (appliedUiSchemaOptions.restrict) {
|
|
@@ -75,12 +78,17 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
|
75
78
|
}
|
|
76
79
|
propMemo.list = props.id + 'datalist';
|
|
77
80
|
return propMemo;
|
|
78
|
-
},[appliedUiSchemaOptions,props.id]);
|
|
79
|
-
const [inputText, onChange] = useDebouncedChange(
|
|
81
|
+
}, [appliedUiSchemaOptions, props.id]);
|
|
82
|
+
const [inputText, onChange] = useDebouncedChange(
|
|
83
|
+
handleChange,
|
|
84
|
+
'',
|
|
85
|
+
data,
|
|
86
|
+
path
|
|
87
|
+
);
|
|
80
88
|
|
|
81
89
|
const dataList = (
|
|
82
90
|
<datalist id={props.id + 'datalist'}>
|
|
83
|
-
{enumSchema.enum.map(optionValue => (
|
|
91
|
+
{enumSchema.enum.map((optionValue) => (
|
|
84
92
|
<option value={optionValue} key={optionValue} />
|
|
85
93
|
))}
|
|
86
94
|
</datalist>
|
|
@@ -117,15 +125,15 @@ const hasEnumAndText = (schemas: JsonSchema[]) => {
|
|
|
117
125
|
const enumSchema = findEnumSchema(schemas);
|
|
118
126
|
const stringSchema = findTextSchema(schemas);
|
|
119
127
|
const remainingSchemas = schemas.filter(
|
|
120
|
-
s => s !== enumSchema || s !== stringSchema
|
|
128
|
+
(s) => s !== enumSchema || s !== stringSchema
|
|
121
129
|
);
|
|
122
|
-
const wrongType = remainingSchemas.find(s => s.type && s.type !== 'string');
|
|
130
|
+
const wrongType = remainingSchemas.find((s) => s.type && s.type !== 'string');
|
|
123
131
|
return enumSchema && stringSchema && !wrongType;
|
|
124
132
|
};
|
|
125
133
|
const simpleAnyOf = and(
|
|
126
134
|
uiTypeIs('Control'),
|
|
127
135
|
schemaMatches(
|
|
128
|
-
schema => schema.hasOwnProperty('anyOf') && hasEnumAndText(schema.anyOf)
|
|
136
|
+
(schema) => schema.hasOwnProperty('anyOf') && hasEnumAndText(schema.anyOf)
|
|
129
137
|
)
|
|
130
138
|
);
|
|
131
139
|
export const materialAnyOfStringOrEnumControlTester: RankedTester = rankWith(
|
|
@@ -30,10 +30,15 @@ import {
|
|
|
30
30
|
RankedTester,
|
|
31
31
|
rankWith,
|
|
32
32
|
ControlProps,
|
|
33
|
-
isDescriptionHidden
|
|
33
|
+
isDescriptionHidden,
|
|
34
34
|
} from '@jsonforms/core';
|
|
35
35
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
FormControlLabel,
|
|
38
|
+
FormHelperText,
|
|
39
|
+
Tooltip,
|
|
40
|
+
Hidden,
|
|
41
|
+
} from '@mui/material';
|
|
37
42
|
import { MuiCheckbox } from '../mui-controls/MuiCheckbox';
|
|
38
43
|
|
|
39
44
|
export const MaterialBooleanControl = ({
|
|
@@ -49,9 +54,8 @@ export const MaterialBooleanControl = ({
|
|
|
49
54
|
errors,
|
|
50
55
|
path,
|
|
51
56
|
config,
|
|
52
|
-
description
|
|
57
|
+
description,
|
|
53
58
|
}: ControlProps) => {
|
|
54
|
-
|
|
55
59
|
const isValid = errors.length === 0;
|
|
56
60
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
57
61
|
|
|
@@ -65,16 +69,18 @@ export const MaterialBooleanControl = ({
|
|
|
65
69
|
appliedUiSchemaOptions.showUnfocusedDescription
|
|
66
70
|
);
|
|
67
71
|
|
|
68
|
-
const showTooltip =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
const showTooltip =
|
|
73
|
+
!showDescription &&
|
|
74
|
+
!isDescriptionHidden(
|
|
75
|
+
visible,
|
|
76
|
+
description,
|
|
77
|
+
// Tooltips have their own focus handlers, so we do not need to rely
|
|
78
|
+
// on focus state here. So we pass 'true' to treat it as focused.
|
|
79
|
+
true,
|
|
80
|
+
// We also pass true here for showUnfocusedDescription since it should
|
|
81
|
+
// render regardless of that setting.
|
|
82
|
+
true
|
|
83
|
+
);
|
|
78
84
|
|
|
79
85
|
const firstFormHelperText = showDescription
|
|
80
86
|
? description
|
|
@@ -100,7 +106,7 @@ export const MaterialBooleanControl = ({
|
|
|
100
106
|
|
|
101
107
|
return (
|
|
102
108
|
<Hidden xsUp={!visible}>
|
|
103
|
-
<Tooltip id={tooltipId} title={
|
|
109
|
+
<Tooltip id={tooltipId} title={showTooltip ? description : ''}>
|
|
104
110
|
<FormControlLabel
|
|
105
111
|
label={label}
|
|
106
112
|
id={id}
|
|
@@ -119,7 +125,7 @@ export const MaterialBooleanControl = ({
|
|
|
119
125
|
errors={errors}
|
|
120
126
|
config={config}
|
|
121
127
|
inputProps={{
|
|
122
|
-
'aria-describedby': ariaDescribedBy
|
|
128
|
+
'aria-describedby': ariaDescribedBy,
|
|
123
129
|
}}
|
|
124
130
|
/>
|
|
125
131
|
}
|
|
@@ -32,10 +32,15 @@ import {
|
|
|
32
32
|
ControlProps,
|
|
33
33
|
optionIs,
|
|
34
34
|
and,
|
|
35
|
-
isDescriptionHidden
|
|
35
|
+
isDescriptionHidden,
|
|
36
36
|
} from '@jsonforms/core';
|
|
37
37
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
FormControlLabel,
|
|
40
|
+
FormHelperText,
|
|
41
|
+
Tooltip,
|
|
42
|
+
Hidden,
|
|
43
|
+
} from '@mui/material';
|
|
39
44
|
import { MuiToggle } from '../mui-controls/MuiToggle';
|
|
40
45
|
|
|
41
46
|
export const MaterialBooleanToggleControl = ({
|
|
@@ -51,9 +56,8 @@ export const MaterialBooleanToggleControl = ({
|
|
|
51
56
|
errors,
|
|
52
57
|
path,
|
|
53
58
|
config,
|
|
54
|
-
description
|
|
59
|
+
description,
|
|
55
60
|
}: ControlProps) => {
|
|
56
|
-
|
|
57
61
|
const isValid = errors.length === 0;
|
|
58
62
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
59
63
|
|
|
@@ -67,16 +71,18 @@ export const MaterialBooleanToggleControl = ({
|
|
|
67
71
|
appliedUiSchemaOptions.showUnfocusedDescription
|
|
68
72
|
);
|
|
69
73
|
|
|
70
|
-
const showTooltip =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
const showTooltip =
|
|
75
|
+
!showDescription &&
|
|
76
|
+
!isDescriptionHidden(
|
|
77
|
+
visible,
|
|
78
|
+
description,
|
|
79
|
+
// Tooltips have their own focus handlers, so we do not need to rely
|
|
80
|
+
// on focus state here. So we pass 'true' to treat it as focused.
|
|
81
|
+
true,
|
|
82
|
+
// We also pass true here for showUnfocusedDescription since it should
|
|
83
|
+
// render regardless of that setting.
|
|
84
|
+
true
|
|
85
|
+
);
|
|
80
86
|
|
|
81
87
|
const firstFormHelperText = showDescription
|
|
82
88
|
? description
|
|
@@ -102,7 +108,7 @@ export const MaterialBooleanToggleControl = ({
|
|
|
102
108
|
|
|
103
109
|
return (
|
|
104
110
|
<Hidden xsUp={!visible}>
|
|
105
|
-
<Tooltip id={tooltipId} title={
|
|
111
|
+
<Tooltip id={tooltipId} title={showTooltip ? description : ''}>
|
|
106
112
|
<FormControlLabel
|
|
107
113
|
label={label}
|
|
108
114
|
id={id}
|
|
@@ -121,7 +127,7 @@ export const MaterialBooleanToggleControl = ({
|
|
|
121
127
|
errors={errors}
|
|
122
128
|
config={config}
|
|
123
129
|
inputProps={{
|
|
124
|
-
'aria-describedby': ariaDescribedBy
|
|
130
|
+
'aria-describedby': ariaDescribedBy,
|
|
125
131
|
}}
|
|
126
132
|
/>
|
|
127
133
|
}
|
|
@@ -33,10 +33,7 @@ import {
|
|
|
33
33
|
} from '@jsonforms/core';
|
|
34
34
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
35
35
|
import { FormHelperText, Hidden } from '@mui/material';
|
|
36
|
-
import {
|
|
37
|
-
DatePicker,
|
|
38
|
-
LocalizationProvider
|
|
39
|
-
} from '@mui/x-date-pickers';
|
|
36
|
+
import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
40
37
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
41
38
|
import {
|
|
42
39
|
createOnChangeHandler,
|
|
@@ -45,7 +42,7 @@ import {
|
|
|
45
42
|
useFocus,
|
|
46
43
|
} from '../util';
|
|
47
44
|
|
|
48
|
-
export const MaterialDateControl = (props: ControlProps)=> {
|
|
45
|
+
export const MaterialDateControl = (props: ControlProps) => {
|
|
49
46
|
const [focused, onFocus, onBlur] = useFocus();
|
|
50
47
|
const {
|
|
51
48
|
description,
|
|
@@ -59,7 +56,7 @@ export const MaterialDateControl = (props: ControlProps)=> {
|
|
|
59
56
|
path,
|
|
60
57
|
handleChange,
|
|
61
58
|
data,
|
|
62
|
-
config
|
|
59
|
+
config,
|
|
63
60
|
} = props;
|
|
64
61
|
const isValid = errors.length === 0;
|
|
65
62
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
@@ -81,11 +78,10 @@ export const MaterialDateControl = (props: ControlProps)=> {
|
|
|
81
78
|
? errors
|
|
82
79
|
: null;
|
|
83
80
|
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
84
|
-
const onChange = useMemo(
|
|
85
|
-
path,
|
|
86
|
-
handleChange,
|
|
87
|
-
|
|
88
|
-
),[path, handleChange, saveFormat]);
|
|
81
|
+
const onChange = useMemo(
|
|
82
|
+
() => createOnChangeHandler(path, handleChange, saveFormat),
|
|
83
|
+
[path, handleChange, saveFormat]
|
|
84
|
+
);
|
|
89
85
|
|
|
90
86
|
const value = getData(data, saveFormat);
|
|
91
87
|
const valueInInputFormat = value ? value.format(format) : '';
|
|
@@ -103,18 +99,21 @@ export const MaterialDateControl = (props: ControlProps)=> {
|
|
|
103
99
|
disabled={!enabled}
|
|
104
100
|
componentsProps={{
|
|
105
101
|
actionBar: {
|
|
106
|
-
actions: (variant) =>
|
|
107
|
-
|
|
102
|
+
actions: (variant) =>
|
|
103
|
+
variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
|
|
104
|
+
},
|
|
108
105
|
}}
|
|
109
|
-
renderInput={params => (
|
|
110
|
-
<ResettableTextField
|
|
106
|
+
renderInput={(params) => (
|
|
107
|
+
<ResettableTextField
|
|
111
108
|
{...params}
|
|
112
109
|
rawValue={data}
|
|
113
110
|
dayjsValueIsValid={value !== null}
|
|
114
111
|
valueInInputFormat={valueInInputFormat}
|
|
115
112
|
focused={focused}
|
|
116
113
|
id={id + '-input'}
|
|
117
|
-
required={
|
|
114
|
+
required={
|
|
115
|
+
required && !appliedUiSchemaOptions.hideRequiredAsterisk
|
|
116
|
+
}
|
|
118
117
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
119
118
|
error={!isValid}
|
|
120
119
|
fullWidth={!appliedUiSchemaOptions.trim}
|
|
@@ -132,9 +131,7 @@ export const MaterialDateControl = (props: ControlProps)=> {
|
|
|
132
131
|
<FormHelperText error={!isValid && !showDescription}>
|
|
133
132
|
{firstFormHelperText}
|
|
134
133
|
</FormHelperText>
|
|
135
|
-
<FormHelperText error={!isValid}>
|
|
136
|
-
{secondFormHelperText}
|
|
137
|
-
</FormHelperText>
|
|
134
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
138
135
|
</LocalizationProvider>
|
|
139
136
|
</Hidden>
|
|
140
137
|
);
|
|
@@ -29,20 +29,17 @@ import {
|
|
|
29
29
|
isDateTimeControl,
|
|
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
|
-
DateTimePicker,
|
|
38
|
-
LocalizationProvider
|
|
39
|
-
} from '@mui/x-date-pickers';
|
|
36
|
+
import { DateTimePicker, 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 MaterialDateTimeControl = (props: ControlProps) => {
|
|
@@ -59,7 +56,7 @@ export const MaterialDateTimeControl = (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;
|
|
@@ -74,7 +71,12 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
|
|
|
74
71
|
const format = appliedUiSchemaOptions.dateTimeFormat ?? 'YYYY-MM-DD HH:mm';
|
|
75
72
|
const saveFormat = appliedUiSchemaOptions.dateTimeSaveFormat ?? undefined;
|
|
76
73
|
|
|
77
|
-
const views = appliedUiSchemaOptions.views ?? [
|
|
74
|
+
const views = appliedUiSchemaOptions.views ?? [
|
|
75
|
+
'year',
|
|
76
|
+
'day',
|
|
77
|
+
'hours',
|
|
78
|
+
'minutes',
|
|
79
|
+
];
|
|
78
80
|
|
|
79
81
|
const firstFormHelperText = showDescription
|
|
80
82
|
? description
|
|
@@ -83,11 +85,10 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
|
|
|
83
85
|
: null;
|
|
84
86
|
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
85
87
|
|
|
86
|
-
const onChange = useMemo(
|
|
87
|
-
path,
|
|
88
|
-
handleChange,
|
|
89
|
-
|
|
90
|
-
),[path, handleChange, saveFormat]);
|
|
88
|
+
const onChange = useMemo(
|
|
89
|
+
() => createOnChangeHandler(path, handleChange, saveFormat),
|
|
90
|
+
[path, handleChange, saveFormat]
|
|
91
|
+
);
|
|
91
92
|
|
|
92
93
|
const value = getData(data, saveFormat);
|
|
93
94
|
const valueInInputFormat = value ? value.format(format) : '';
|
|
@@ -106,18 +107,21 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
|
|
|
106
107
|
disabled={!enabled}
|
|
107
108
|
componentsProps={{
|
|
108
109
|
actionBar: {
|
|
109
|
-
actions: (variant) =>
|
|
110
|
-
|
|
110
|
+
actions: (variant) =>
|
|
111
|
+
variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
|
|
112
|
+
},
|
|
111
113
|
}}
|
|
112
|
-
renderInput={params => (
|
|
113
|
-
<ResettableTextField
|
|
114
|
+
renderInput={(params) => (
|
|
115
|
+
<ResettableTextField
|
|
114
116
|
{...params}
|
|
115
117
|
rawValue={data}
|
|
116
118
|
dayjsValueIsValid={value !== null}
|
|
117
119
|
valueInInputFormat={valueInInputFormat}
|
|
118
120
|
focused={focused}
|
|
119
121
|
id={id + '-input'}
|
|
120
|
-
required={
|
|
122
|
+
required={
|
|
123
|
+
required && !appliedUiSchemaOptions.hideRequiredAsterisk
|
|
124
|
+
}
|
|
121
125
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
122
126
|
error={!isValid}
|
|
123
127
|
fullWidth={!appliedUiSchemaOptions.trim}
|
|
@@ -130,15 +134,12 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
|
|
|
130
134
|
onBlur={onBlur}
|
|
131
135
|
variant={'standard'}
|
|
132
136
|
/>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
137
|
+
)}
|
|
135
138
|
/>
|
|
136
139
|
<FormHelperText error={!isValid && !showDescription}>
|
|
137
140
|
{firstFormHelperText}
|
|
138
141
|
</FormHelperText>
|
|
139
|
-
<FormHelperText error={!isValid}>
|
|
140
|
-
{secondFormHelperText}
|
|
141
|
-
</FormHelperText>
|
|
142
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
142
143
|
</LocalizationProvider>
|
|
143
144
|
</Hidden>
|
|
144
145
|
);
|
|
@@ -30,26 +30,29 @@ import {
|
|
|
30
30
|
RankedTester,
|
|
31
31
|
rankWith,
|
|
32
32
|
} from '@jsonforms/core';
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
TranslateProps,
|
|
35
|
+
withJsonFormsEnumProps,
|
|
36
|
+
withTranslateProps,
|
|
37
|
+
} from '@jsonforms/react';
|
|
34
38
|
import { MuiSelect } from '../mui-controls/MuiSelect';
|
|
35
39
|
import merge from 'lodash/merge';
|
|
36
40
|
import { MaterialInputControl } from './MaterialInputControl';
|
|
37
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
MuiAutocomplete,
|
|
43
|
+
WithOptionLabel,
|
|
44
|
+
} from '../mui-controls/MuiAutocomplete';
|
|
38
45
|
|
|
39
|
-
export const MaterialEnumControl = (
|
|
40
|
-
|
|
46
|
+
export const MaterialEnumControl = (
|
|
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
|
-
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
input={MuiSelect}
|
|
48
|
-
/>:
|
|
49
|
-
<MuiAutocomplete
|
|
50
|
-
{...props}
|
|
51
|
-
isValid={isValid}
|
|
52
|
-
/>
|
|
52
|
+
return appliedUiSchemaOptions.autocomplete === false ? (
|
|
53
|
+
<MaterialInputControl {...props} input={MuiSelect} />
|
|
54
|
+
) : (
|
|
55
|
+
<MuiAutocomplete {...props} isValid={isValid} />
|
|
53
56
|
);
|
|
54
57
|
};
|
|
55
58
|
|
|
@@ -59,4 +62,7 @@ export const materialEnumControlTester: RankedTester = rankWith(
|
|
|
59
62
|
);
|
|
60
63
|
|
|
61
64
|
// HOC order can be reversed with https://github.com/eclipsesource/jsonforms/issues/1987
|
|
62
|
-
export default withJsonFormsEnumProps(
|
|
65
|
+
export default withJsonFormsEnumProps(
|
|
66
|
+
withTranslateProps(React.memo(MaterialEnumControl)),
|
|
67
|
+
false
|
|
68
|
+
);
|
|
@@ -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
|
+
);
|