@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
|
@@ -23,7 +23,13 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import React, { ReactNode } from 'react';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
ControlProps,
|
|
28
|
+
EnumCellProps,
|
|
29
|
+
EnumOption,
|
|
30
|
+
isDescriptionHidden,
|
|
31
|
+
WithClassname,
|
|
32
|
+
} from '@jsonforms/core';
|
|
27
33
|
|
|
28
34
|
import {
|
|
29
35
|
Autocomplete,
|
|
@@ -31,18 +37,27 @@ import {
|
|
|
31
37
|
FilterOptionsState,
|
|
32
38
|
FormHelperText,
|
|
33
39
|
Hidden,
|
|
34
|
-
TextField
|
|
40
|
+
TextField,
|
|
35
41
|
} from '@mui/material';
|
|
36
42
|
import merge from 'lodash/merge';
|
|
37
43
|
import { useFocus } from '../util/focus';
|
|
38
44
|
|
|
39
45
|
export interface WithOptionLabel {
|
|
40
|
-
getOptionLabel?(option: EnumOption)
|
|
41
|
-
renderOption?(
|
|
42
|
-
|
|
46
|
+
getOptionLabel?(option: EnumOption): string;
|
|
47
|
+
renderOption?(
|
|
48
|
+
props: React.HTMLAttributes<HTMLLIElement>,
|
|
49
|
+
option: EnumOption,
|
|
50
|
+
state: AutocompleteRenderOptionState
|
|
51
|
+
): ReactNode;
|
|
52
|
+
filterOptions?(
|
|
53
|
+
options: EnumOption[],
|
|
54
|
+
state: FilterOptionsState<EnumOption>
|
|
55
|
+
): EnumOption[];
|
|
43
56
|
}
|
|
44
57
|
|
|
45
|
-
export const MuiAutocomplete = (
|
|
58
|
+
export const MuiAutocomplete = (
|
|
59
|
+
props: ControlProps & EnumCellProps & WithClassname & WithOptionLabel
|
|
60
|
+
) => {
|
|
46
61
|
const {
|
|
47
62
|
description,
|
|
48
63
|
errors,
|
|
@@ -61,21 +76,21 @@ export const MuiAutocomplete = (props: ControlProps & EnumCellProps & WithClassn
|
|
|
61
76
|
getOptionLabel,
|
|
62
77
|
renderOption,
|
|
63
78
|
filterOptions,
|
|
64
|
-
isValid
|
|
79
|
+
isValid,
|
|
65
80
|
} = props;
|
|
66
81
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
67
82
|
const [inputValue, setInputValue] = React.useState(data ?? '');
|
|
68
83
|
const [focused, onFocus, onBlur] = useFocus();
|
|
69
84
|
|
|
70
|
-
const findOption = options.find(o => o.value === data) ?? null;
|
|
71
|
-
|
|
85
|
+
const findOption = options.find((o) => o.value === data) ?? null;
|
|
86
|
+
|
|
72
87
|
const showDescription = !isDescriptionHidden(
|
|
73
88
|
visible,
|
|
74
89
|
description,
|
|
75
90
|
focused,
|
|
76
91
|
appliedUiSchemaOptions.showUnfocusedDescription
|
|
77
92
|
);
|
|
78
|
-
|
|
93
|
+
|
|
79
94
|
const firstFormHelperText = showDescription
|
|
80
95
|
? description
|
|
81
96
|
: !isValid
|
|
@@ -102,38 +117,39 @@ export const MuiAutocomplete = (props: ControlProps & EnumCellProps & WithClassn
|
|
|
102
117
|
autoComplete
|
|
103
118
|
fullWidth
|
|
104
119
|
options={options}
|
|
105
|
-
getOptionLabel={getOptionLabel || (option => option?.label)}
|
|
120
|
+
getOptionLabel={getOptionLabel || ((option) => option?.label)}
|
|
106
121
|
freeSolo={false}
|
|
107
|
-
renderInput={params => {
|
|
108
|
-
return(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
renderInput={(params) => {
|
|
123
|
+
return (
|
|
124
|
+
<TextField
|
|
125
|
+
label={label}
|
|
126
|
+
variant={'standard'}
|
|
127
|
+
type='text'
|
|
128
|
+
inputProps={params.inputProps}
|
|
129
|
+
inputRef={params.InputProps.ref}
|
|
130
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
131
|
+
disabled={!enabled}
|
|
132
|
+
{...params}
|
|
133
|
+
id={id + '-input'}
|
|
134
|
+
required={
|
|
135
|
+
required && !appliedUiSchemaOptions.hideRequiredAsterisk
|
|
136
|
+
}
|
|
137
|
+
error={!isValid}
|
|
138
|
+
fullWidth={!appliedUiSchemaOptions.trim}
|
|
139
|
+
InputLabelProps={data ? { shrink: true } : undefined}
|
|
140
|
+
onFocus={onFocus}
|
|
141
|
+
onBlur={onBlur}
|
|
142
|
+
focused={focused}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}}
|
|
128
146
|
renderOption={renderOption}
|
|
129
147
|
filterOptions={filterOptions}
|
|
130
148
|
/>
|
|
131
149
|
<FormHelperText error={!isValid && !showDescription}>
|
|
132
150
|
{firstFormHelperText}
|
|
133
151
|
</FormHelperText>
|
|
134
|
-
<FormHelperText error={!isValid}>
|
|
135
|
-
{secondFormHelperText}
|
|
136
|
-
</FormHelperText>
|
|
152
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
137
153
|
</Hidden>
|
|
138
154
|
);
|
|
139
155
|
};
|
|
@@ -24,10 +24,16 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import { Checkbox } from '@mui/material';
|
|
27
|
+
import { Checkbox, InputProps } from '@mui/material';
|
|
28
28
|
import merge from 'lodash/merge';
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
interface MuiCheckboxInputProps {
|
|
31
|
+
inputProps?: InputProps['inputProps'];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MuiCheckbox = React.memo(function MuiCheckbox(
|
|
35
|
+
props: CellProps & WithClassname & MuiCheckboxInputProps
|
|
36
|
+
) {
|
|
31
37
|
const {
|
|
32
38
|
data,
|
|
33
39
|
className,
|
|
@@ -36,10 +42,13 @@ export const MuiCheckbox = React.memo((props: CellProps & WithClassname) => {
|
|
|
36
42
|
uischema,
|
|
37
43
|
path,
|
|
38
44
|
handleChange,
|
|
39
|
-
config
|
|
45
|
+
config,
|
|
46
|
+
inputProps,
|
|
40
47
|
} = props;
|
|
41
48
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
42
|
-
const
|
|
49
|
+
const inputPropsMerged = merge({}, inputProps, {
|
|
50
|
+
autoFocus: !!appliedUiSchemaOptions.focus,
|
|
51
|
+
});
|
|
43
52
|
// !! causes undefined value to be converted to false, otherwise has no effect
|
|
44
53
|
const checked = !!data;
|
|
45
54
|
|
|
@@ -50,7 +59,7 @@ export const MuiCheckbox = React.memo((props: CellProps & WithClassname) => {
|
|
|
50
59
|
className={className}
|
|
51
60
|
id={id}
|
|
52
61
|
disabled={!enabled}
|
|
53
|
-
inputProps={
|
|
62
|
+
inputProps={inputPropsMerged}
|
|
54
63
|
/>
|
|
55
64
|
);
|
|
56
65
|
});
|
|
@@ -29,38 +29,37 @@ import merge from 'lodash/merge';
|
|
|
29
29
|
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
31
|
const toNumber = (value: string) =>
|
|
32
|
-
|
|
33
|
-
const eventToValue = (ev:any) => toNumber(ev.target.value);
|
|
32
|
+
value === '' ? undefined : parseInt(value, 10);
|
|
33
|
+
const eventToValue = (ev: any) => toNumber(ev.target.value);
|
|
34
34
|
|
|
35
|
-
export const MuiInputInteger = React.memo(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
enabled,
|
|
42
|
-
uischema,
|
|
43
|
-
path,
|
|
44
|
-
handleChange,
|
|
45
|
-
config
|
|
46
|
-
} = props;
|
|
47
|
-
const inputProps = { step: '1' };
|
|
48
|
-
|
|
49
|
-
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
35
|
+
export const MuiInputInteger = React.memo(function MuiInputInteger(
|
|
36
|
+
props: CellProps & WithClassname
|
|
37
|
+
) {
|
|
38
|
+
const { data, className, id, enabled, uischema, path, handleChange, config } =
|
|
39
|
+
props;
|
|
40
|
+
const inputProps = { step: '1' };
|
|
50
41
|
|
|
51
|
-
|
|
42
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
52
43
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
45
|
+
handleChange,
|
|
46
|
+
'',
|
|
47
|
+
data,
|
|
48
|
+
path,
|
|
49
|
+
eventToValue
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Input
|
|
54
|
+
type='number'
|
|
55
|
+
value={inputValue}
|
|
56
|
+
onChange={onChange}
|
|
57
|
+
className={className}
|
|
58
|
+
id={id}
|
|
59
|
+
disabled={!enabled}
|
|
60
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
61
|
+
inputProps={inputProps}
|
|
62
|
+
fullWidth={true}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
@@ -26,26 +26,26 @@ import React from 'react';
|
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
27
|
import { Input } from '@mui/material';
|
|
28
28
|
import merge from 'lodash/merge';
|
|
29
|
-
import {useDebouncedChange} from '../util';
|
|
29
|
+
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
31
|
const toNumber = (value: string) =>
|
|
32
|
-
|
|
33
|
-
const eventToValue = (ev:any) => toNumber(ev.target.value);
|
|
34
|
-
export const MuiInputNumber = React.memo((
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
enabled,
|
|
40
|
-
uischema,
|
|
41
|
-
path,
|
|
42
|
-
handleChange,
|
|
43
|
-
config
|
|
44
|
-
} = props;
|
|
32
|
+
value === '' ? undefined : parseFloat(value);
|
|
33
|
+
const eventToValue = (ev: any) => toNumber(ev.target.value);
|
|
34
|
+
export const MuiInputNumber = React.memo(function MuiInputNumber(
|
|
35
|
+
props: CellProps & WithClassname
|
|
36
|
+
) {
|
|
37
|
+
const { data, className, id, enabled, uischema, path, handleChange, config } =
|
|
38
|
+
props;
|
|
45
39
|
const inputProps = { step: '0.1' };
|
|
46
|
-
|
|
40
|
+
|
|
47
41
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
48
|
-
const [inputValue, onChange] = useDebouncedChange(
|
|
42
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
43
|
+
handleChange,
|
|
44
|
+
'',
|
|
45
|
+
data,
|
|
46
|
+
path,
|
|
47
|
+
eventToValue
|
|
48
|
+
);
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<Input
|
|
@@ -22,52 +22,61 @@
|
|
|
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 { CellProps, Formatted, WithClassname } from '@jsonforms/core';
|
|
27
27
|
import { Input } from '@mui/material';
|
|
28
28
|
import merge from 'lodash/merge';
|
|
29
29
|
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
|
-
export const MuiInputNumberFormat = React.memo(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
31
|
+
export const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(
|
|
32
|
+
props: CellProps & WithClassname & Formatted<number>
|
|
33
|
+
) {
|
|
34
|
+
const {
|
|
35
|
+
className,
|
|
36
|
+
id,
|
|
37
|
+
enabled,
|
|
38
|
+
uischema,
|
|
39
|
+
isValid,
|
|
40
|
+
path,
|
|
41
|
+
handleChange,
|
|
42
|
+
schema,
|
|
43
|
+
config,
|
|
44
|
+
} = props;
|
|
45
|
+
const maxLength = schema.maxLength;
|
|
46
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
47
|
+
let inputProps;
|
|
48
|
+
if (appliedUiSchemaOptions.restrict) {
|
|
49
|
+
inputProps = { maxLength: maxLength };
|
|
50
|
+
} else {
|
|
51
|
+
inputProps = {};
|
|
52
|
+
}
|
|
53
|
+
const formattedNumber = props.toFormatted(props.data);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const validStringNumber = useCallback(
|
|
56
|
+
(ev: any) => props.fromFormatted(ev.currentTarget.value),
|
|
57
|
+
[props.fromFormatted]
|
|
58
|
+
);
|
|
59
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
60
|
+
handleChange,
|
|
61
|
+
'',
|
|
62
|
+
formattedNumber,
|
|
63
|
+
path,
|
|
64
|
+
validStringNumber
|
|
65
|
+
);
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
67
|
+
return (
|
|
68
|
+
<Input
|
|
69
|
+
type='text'
|
|
70
|
+
value={inputValue}
|
|
71
|
+
onChange={onChange}
|
|
72
|
+
className={className}
|
|
73
|
+
id={id}
|
|
74
|
+
disabled={!enabled}
|
|
75
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
76
|
+
multiline={appliedUiSchemaOptions.multi}
|
|
77
|
+
fullWidth={!appliedUiSchemaOptions.trim || maxLength === undefined}
|
|
78
|
+
inputProps={inputProps}
|
|
79
|
+
error={!isValid}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
InputAdornment,
|
|
31
31
|
InputBaseComponentProps,
|
|
32
32
|
InputProps,
|
|
33
|
-
useTheme
|
|
33
|
+
useTheme,
|
|
34
34
|
} from '@mui/material';
|
|
35
35
|
import merge from 'lodash/merge';
|
|
36
36
|
import Close from '@mui/icons-material/Close';
|
|
@@ -41,9 +41,12 @@ interface MuiTextInputProps {
|
|
|
41
41
|
inputComponent?: InputProps['inputComponent'];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const eventToValue = (ev:any) =>
|
|
44
|
+
const eventToValue = (ev: any) =>
|
|
45
|
+
ev.target.value === '' ? undefined : ev.target.value;
|
|
45
46
|
|
|
46
|
-
export const MuiInputText = React.memo((
|
|
47
|
+
export const MuiInputText = React.memo(function MuiInputText(
|
|
48
|
+
props: CellProps & WithClassname & MuiTextInputProps
|
|
49
|
+
) {
|
|
47
50
|
const [showAdornment, setShowAdornment] = useState(false);
|
|
48
51
|
const {
|
|
49
52
|
data,
|
|
@@ -57,7 +60,7 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
|
|
|
57
60
|
handleChange,
|
|
58
61
|
schema,
|
|
59
62
|
muiInputProps,
|
|
60
|
-
inputComponent
|
|
63
|
+
inputComponent,
|
|
61
64
|
} = props;
|
|
62
65
|
const maxLength = schema.maxLength;
|
|
63
66
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
@@ -67,29 +70,35 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
|
|
|
67
70
|
} else {
|
|
68
71
|
inputProps = {};
|
|
69
72
|
}
|
|
70
|
-
|
|
73
|
+
|
|
71
74
|
inputProps = merge(inputProps, muiInputProps);
|
|
72
|
-
|
|
75
|
+
|
|
73
76
|
if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
|
|
74
77
|
inputProps.size = maxLength;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const [inputText, onChange, onClear] = useDebouncedChange(
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const [inputText, onChange, onClear] = useDebouncedChange(
|
|
81
|
+
handleChange,
|
|
82
|
+
'',
|
|
83
|
+
data,
|
|
84
|
+
path,
|
|
85
|
+
eventToValue
|
|
86
|
+
);
|
|
78
87
|
const onPointerEnter = () => setShowAdornment(true);
|
|
79
88
|
const onPointerLeave = () => setShowAdornment(false);
|
|
80
89
|
|
|
81
90
|
const theme: JsonFormsTheme = useTheme();
|
|
82
|
-
|
|
91
|
+
|
|
83
92
|
const closeStyle = {
|
|
84
|
-
background:
|
|
85
|
-
|
|
93
|
+
background:
|
|
94
|
+
theme.jsonforms?.input?.delete?.background ||
|
|
95
|
+
theme.palette.background.default,
|
|
96
|
+
borderRadius: '50%',
|
|
86
97
|
};
|
|
87
98
|
|
|
88
99
|
return (
|
|
89
100
|
<Input
|
|
90
|
-
type={
|
|
91
|
-
appliedUiSchemaOptions.format === 'password' ? 'password' : 'text'
|
|
92
|
-
}
|
|
101
|
+
type={appliedUiSchemaOptions.format === 'password' ? 'password' : 'text'}
|
|
93
102
|
value={inputText}
|
|
94
103
|
onChange={onChange}
|
|
95
104
|
className={className}
|
|
@@ -107,17 +116,19 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
|
|
|
107
116
|
position='end'
|
|
108
117
|
style={{
|
|
109
118
|
display:
|
|
110
|
-
!showAdornment || !enabled || data === undefined
|
|
119
|
+
!showAdornment || !enabled || data === undefined
|
|
120
|
+
? 'none'
|
|
121
|
+
: 'flex',
|
|
111
122
|
position: 'absolute',
|
|
112
|
-
right: 0
|
|
123
|
+
right: 0,
|
|
113
124
|
}}
|
|
114
125
|
>
|
|
115
126
|
<IconButton
|
|
116
127
|
aria-label='Clear input field'
|
|
117
|
-
onClick={onClear}
|
|
128
|
+
onClick={onClear}
|
|
118
129
|
size='large'
|
|
119
130
|
>
|
|
120
|
-
<Close style={closeStyle}/>
|
|
131
|
+
<Close style={closeStyle} />
|
|
121
132
|
</IconButton>
|
|
122
133
|
</InputAdornment>
|
|
123
134
|
}
|
|
@@ -28,19 +28,18 @@ import { Input } from '@mui/material';
|
|
|
28
28
|
import merge from 'lodash/merge';
|
|
29
29
|
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
|
-
export const MuiInputTime = React.memo((
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
enabled,
|
|
37
|
-
uischema,
|
|
38
|
-
path,
|
|
39
|
-
handleChange,
|
|
40
|
-
config
|
|
41
|
-
} = props;
|
|
31
|
+
export const MuiInputTime = React.memo(function MuiInputTime(
|
|
32
|
+
props: CellProps & WithClassname
|
|
33
|
+
) {
|
|
34
|
+
const { data, className, id, enabled, uischema, path, handleChange, config } =
|
|
35
|
+
props;
|
|
42
36
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
43
|
-
const [inputValue, onChange] = useDebouncedChange(
|
|
37
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
38
|
+
handleChange,
|
|
39
|
+
'',
|
|
40
|
+
data,
|
|
41
|
+
path
|
|
42
|
+
);
|
|
44
43
|
|
|
45
44
|
return (
|
|
46
45
|
<Input
|
|
@@ -30,7 +30,9 @@ import merge from 'lodash/merge';
|
|
|
30
30
|
import { TranslateProps } from '@jsonforms/react';
|
|
31
31
|
import { i18nDefaults } from '../util';
|
|
32
32
|
|
|
33
|
-
export const MuiSelect = React.memo((
|
|
33
|
+
export const MuiSelect = React.memo(function MuiSelect(
|
|
34
|
+
props: EnumCellProps & WithClassname & TranslateProps
|
|
35
|
+
) {
|
|
34
36
|
const {
|
|
35
37
|
data,
|
|
36
38
|
className,
|
|
@@ -42,10 +44,13 @@ export const MuiSelect = React.memo((props: EnumCellProps & WithClassname & Tran
|
|
|
42
44
|
handleChange,
|
|
43
45
|
options,
|
|
44
46
|
config,
|
|
45
|
-
t
|
|
47
|
+
t,
|
|
46
48
|
} = props;
|
|
47
49
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
48
|
-
const noneOptionLabel = useMemo(
|
|
50
|
+
const noneOptionLabel = useMemo(
|
|
51
|
+
() => t('enum.none', i18nDefaults['enum.none'], { schema, uischema, path }),
|
|
52
|
+
[t, schema, uischema, path]
|
|
53
|
+
);
|
|
49
54
|
|
|
50
55
|
return (
|
|
51
56
|
<Select
|
|
@@ -54,12 +59,16 @@ export const MuiSelect = React.memo((props: EnumCellProps & WithClassname & Tran
|
|
|
54
59
|
disabled={!enabled}
|
|
55
60
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
56
61
|
value={data !== undefined ? data : ''}
|
|
57
|
-
onChange={ev =>handleChange(path, ev.target.value || undefined)}
|
|
62
|
+
onChange={(ev) => handleChange(path, ev.target.value || undefined)}
|
|
58
63
|
fullWidth={true}
|
|
59
64
|
variant={'standard'}
|
|
60
65
|
>
|
|
61
|
-
{[
|
|
62
|
-
|
|
66
|
+
{[
|
|
67
|
+
<MenuItem value={''} key='jsonforms.enum.none'>
|
|
68
|
+
<em>{noneOptionLabel}</em>
|
|
69
|
+
</MenuItem>,
|
|
70
|
+
].concat(
|
|
71
|
+
options.map((optionValue) => (
|
|
63
72
|
<MenuItem value={optionValue.value} key={optionValue.value}>
|
|
64
73
|
{optionValue.label}
|
|
65
74
|
</MenuItem>
|
|
@@ -24,10 +24,16 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import { Switch } from '@mui/material';
|
|
27
|
+
import { Switch, InputProps } from '@mui/material';
|
|
28
28
|
import merge from 'lodash/merge';
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
interface MuiToggleInputProps {
|
|
31
|
+
inputProps?: InputProps['inputProps'];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MuiToggle = React.memo(function MuiToggle(
|
|
35
|
+
props: CellProps & WithClassname & MuiToggleInputProps
|
|
36
|
+
) {
|
|
31
37
|
const {
|
|
32
38
|
data,
|
|
33
39
|
className,
|
|
@@ -36,10 +42,13 @@ export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
|
|
|
36
42
|
uischema,
|
|
37
43
|
path,
|
|
38
44
|
handleChange,
|
|
39
|
-
config
|
|
45
|
+
config,
|
|
46
|
+
inputProps,
|
|
40
47
|
} = props;
|
|
41
48
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
42
|
-
const
|
|
49
|
+
const inputPropsMerged = merge({}, inputProps, {
|
|
50
|
+
autoFocus: !!appliedUiSchemaOptions.focus,
|
|
51
|
+
});
|
|
43
52
|
const checked = !!data;
|
|
44
53
|
|
|
45
54
|
return (
|
|
@@ -49,7 +58,7 @@ export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
|
|
|
49
58
|
className={className}
|
|
50
59
|
id={id}
|
|
51
60
|
disabled={!enabled}
|
|
52
|
-
inputProps={
|
|
61
|
+
inputProps={inputPropsMerged}
|
|
53
62
|
/>
|
|
54
63
|
);
|
|
55
64
|
});
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
+
export * from './MuiAutocomplete';
|
|
25
26
|
export * from './MuiCheckbox';
|
|
26
|
-
export * from './MuiSelect';
|
|
27
27
|
export * from './MuiInputInteger';
|
|
28
28
|
export * from './MuiInputNumber';
|
|
29
29
|
export * from './MuiInputNumberFormat';
|
|
30
30
|
export * from './MuiInputText';
|
|
31
31
|
export * from './MuiInputTime';
|
|
32
|
+
export * from './MuiSelect';
|
|
33
|
+
export * from './MuiToggle';
|