@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
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/*
|
|
2
2
|
The MIT License
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
5
|
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
8
|
of this software and associated documentation files (the "Software"), to deal
|
|
9
9
|
in the Software without restriction, including without limitation the rights
|
|
10
10
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
11
|
copies of the Software, and to permit persons to whom the Software is
|
|
12
12
|
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
The above copyright notice and this permission notice shall be included in
|
|
15
15
|
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
18
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
19
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
@@ -22,15 +22,18 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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(
|
|
@@ -23,15 +23,22 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import isEmpty from 'lodash/isEmpty';
|
|
26
|
+
import merge from 'lodash/merge';
|
|
26
27
|
import React from 'react';
|
|
27
28
|
import {
|
|
28
29
|
isBooleanControl,
|
|
29
30
|
RankedTester,
|
|
30
31
|
rankWith,
|
|
31
|
-
ControlProps
|
|
32
|
+
ControlProps,
|
|
33
|
+
isDescriptionHidden,
|
|
32
34
|
} from '@jsonforms/core';
|
|
33
35
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
34
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
FormControlLabel,
|
|
38
|
+
FormHelperText,
|
|
39
|
+
Tooltip,
|
|
40
|
+
Hidden,
|
|
41
|
+
} from '@mui/material';
|
|
35
42
|
import { MuiCheckbox } from '../mui-controls/MuiCheckbox';
|
|
36
43
|
|
|
37
44
|
export const MaterialBooleanControl = ({
|
|
@@ -46,30 +53,90 @@ export const MaterialBooleanControl = ({
|
|
|
46
53
|
handleChange,
|
|
47
54
|
errors,
|
|
48
55
|
path,
|
|
49
|
-
config
|
|
56
|
+
config,
|
|
57
|
+
description,
|
|
50
58
|
}: ControlProps) => {
|
|
59
|
+
const isValid = errors.length === 0;
|
|
60
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
61
|
+
|
|
62
|
+
const showDescription = !isDescriptionHidden(
|
|
63
|
+
visible,
|
|
64
|
+
description,
|
|
65
|
+
// Checkboxes do not receive focus until they are used, so
|
|
66
|
+
// we cannot rely on focus as criteria for showing descriptions.
|
|
67
|
+
// So we pass "false" to treat it as unfocused.
|
|
68
|
+
false,
|
|
69
|
+
appliedUiSchemaOptions.showUnfocusedDescription
|
|
70
|
+
);
|
|
71
|
+
|
|
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
|
+
);
|
|
84
|
+
|
|
85
|
+
const firstFormHelperText = showDescription
|
|
86
|
+
? description
|
|
87
|
+
: !isValid
|
|
88
|
+
? errors
|
|
89
|
+
: null;
|
|
90
|
+
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
91
|
+
|
|
92
|
+
const descriptionIds = [];
|
|
93
|
+
const tooltipId = `${id}-tip`;
|
|
94
|
+
const helpId1 = `${id}-help1`;
|
|
95
|
+
const helpId2 = `${id}-help2`;
|
|
96
|
+
if (showTooltip) {
|
|
97
|
+
descriptionIds.push(tooltipId);
|
|
98
|
+
}
|
|
99
|
+
if (firstFormHelperText) {
|
|
100
|
+
descriptionIds.push(helpId1);
|
|
101
|
+
}
|
|
102
|
+
if (secondFormHelperText) {
|
|
103
|
+
descriptionIds.push(helpId2);
|
|
104
|
+
}
|
|
105
|
+
const ariaDescribedBy = descriptionIds.join(' ');
|
|
106
|
+
|
|
51
107
|
return (
|
|
52
108
|
<Hidden xsUp={!visible}>
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
109
|
+
<Tooltip id={tooltipId} title={showTooltip ? description : ''}>
|
|
110
|
+
<FormControlLabel
|
|
111
|
+
label={label}
|
|
112
|
+
id={id}
|
|
113
|
+
control={
|
|
114
|
+
<MuiCheckbox
|
|
115
|
+
id={`${id}-input`}
|
|
116
|
+
isValid={isEmpty(errors)}
|
|
117
|
+
data={data}
|
|
118
|
+
enabled={enabled}
|
|
119
|
+
visible={visible}
|
|
120
|
+
path={path}
|
|
121
|
+
uischema={uischema}
|
|
122
|
+
schema={schema}
|
|
123
|
+
rootSchema={rootSchema}
|
|
124
|
+
handleChange={handleChange}
|
|
125
|
+
errors={errors}
|
|
126
|
+
config={config}
|
|
127
|
+
inputProps={{
|
|
128
|
+
'aria-describedby': ariaDescribedBy,
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
}
|
|
132
|
+
/>
|
|
133
|
+
</Tooltip>
|
|
134
|
+
<FormHelperText id={helpId1} error={!isValid && !showDescription}>
|
|
135
|
+
{firstFormHelperText}
|
|
136
|
+
</FormHelperText>
|
|
137
|
+
<FormHelperText id={helpId2} error={!isValid}>
|
|
138
|
+
{secondFormHelperText}
|
|
139
|
+
</FormHelperText>
|
|
73
140
|
</Hidden>
|
|
74
141
|
);
|
|
75
142
|
};
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import isEmpty from 'lodash/isEmpty';
|
|
26
|
+
import merge from 'lodash/merge';
|
|
26
27
|
import React from 'react';
|
|
27
28
|
import {
|
|
28
29
|
isBooleanControl,
|
|
@@ -30,10 +31,16 @@ import {
|
|
|
30
31
|
rankWith,
|
|
31
32
|
ControlProps,
|
|
32
33
|
optionIs,
|
|
33
|
-
and
|
|
34
|
+
and,
|
|
35
|
+
isDescriptionHidden,
|
|
34
36
|
} from '@jsonforms/core';
|
|
35
37
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
36
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
FormControlLabel,
|
|
40
|
+
FormHelperText,
|
|
41
|
+
Tooltip,
|
|
42
|
+
Hidden,
|
|
43
|
+
} from '@mui/material';
|
|
37
44
|
import { MuiToggle } from '../mui-controls/MuiToggle';
|
|
38
45
|
|
|
39
46
|
export const MaterialBooleanToggleControl = ({
|
|
@@ -48,30 +55,90 @@ export const MaterialBooleanToggleControl = ({
|
|
|
48
55
|
handleChange,
|
|
49
56
|
errors,
|
|
50
57
|
path,
|
|
51
|
-
config
|
|
58
|
+
config,
|
|
59
|
+
description,
|
|
52
60
|
}: ControlProps) => {
|
|
61
|
+
const isValid = errors.length === 0;
|
|
62
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
63
|
+
|
|
64
|
+
const showDescription = !isDescriptionHidden(
|
|
65
|
+
visible,
|
|
66
|
+
description,
|
|
67
|
+
// Checkboxes do not receive focus until they are used, so
|
|
68
|
+
// we cannot rely on focus as criteria for showing descriptions.
|
|
69
|
+
// So we pass "false" to treat it as unfocused.
|
|
70
|
+
false,
|
|
71
|
+
appliedUiSchemaOptions.showUnfocusedDescription
|
|
72
|
+
);
|
|
73
|
+
|
|
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
|
+
);
|
|
86
|
+
|
|
87
|
+
const firstFormHelperText = showDescription
|
|
88
|
+
? description
|
|
89
|
+
: !isValid
|
|
90
|
+
? errors
|
|
91
|
+
: null;
|
|
92
|
+
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
93
|
+
|
|
94
|
+
const descriptionIds = [];
|
|
95
|
+
const tooltipId = `${id}-tip`;
|
|
96
|
+
const helpId1 = `${id}-help1`;
|
|
97
|
+
const helpId2 = `${id}-help2`;
|
|
98
|
+
if (showTooltip) {
|
|
99
|
+
descriptionIds.push(tooltipId);
|
|
100
|
+
}
|
|
101
|
+
if (firstFormHelperText) {
|
|
102
|
+
descriptionIds.push(helpId1);
|
|
103
|
+
}
|
|
104
|
+
if (secondFormHelperText) {
|
|
105
|
+
descriptionIds.push(helpId2);
|
|
106
|
+
}
|
|
107
|
+
const ariaDescribedBy = descriptionIds.join(' ');
|
|
108
|
+
|
|
53
109
|
return (
|
|
54
110
|
<Hidden xsUp={!visible}>
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
111
|
+
<Tooltip id={tooltipId} title={showTooltip ? description : ''}>
|
|
112
|
+
<FormControlLabel
|
|
113
|
+
label={label}
|
|
114
|
+
id={id}
|
|
115
|
+
control={
|
|
116
|
+
<MuiToggle
|
|
117
|
+
id={`${id}-input`}
|
|
118
|
+
isValid={isEmpty(errors)}
|
|
119
|
+
data={data}
|
|
120
|
+
enabled={enabled}
|
|
121
|
+
visible={visible}
|
|
122
|
+
path={path}
|
|
123
|
+
uischema={uischema}
|
|
124
|
+
schema={schema}
|
|
125
|
+
rootSchema={rootSchema}
|
|
126
|
+
handleChange={handleChange}
|
|
127
|
+
errors={errors}
|
|
128
|
+
config={config}
|
|
129
|
+
inputProps={{
|
|
130
|
+
'aria-describedby': ariaDescribedBy,
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
</Tooltip>
|
|
136
|
+
<FormHelperText id={helpId1} error={!isValid && !showDescription}>
|
|
137
|
+
{firstFormHelperText}
|
|
138
|
+
</FormHelperText>
|
|
139
|
+
<FormHelperText id={helpId2} error={!isValid}>
|
|
140
|
+
{secondFormHelperText}
|
|
141
|
+
</FormHelperText>
|
|
75
142
|
</Hidden>
|
|
76
143
|
);
|
|
77
144
|
};
|
|
@@ -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
|
+
);
|