@jsonforms/material-renderers 3.2.0 → 3.3.0-alpha.0
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/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
- package/lib/complex/unwrapped.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/jsonforms-react-material.cjs.js +113 -99
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +106 -92
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/package.json +11 -11
- package/src/complex/MaterialEnumArrayRenderer.tsx +41 -3
- package/src/complex/MaterialTableControl.tsx +41 -20
- package/src/controls/MaterialDateControl.tsx +42 -39
- package/src/controls/MaterialDateTimeControl.tsx +42 -40
- package/src/controls/MaterialRadioGroup.tsx +2 -4
- package/src/controls/MaterialSliderControl.tsx +1 -1
- package/src/controls/MaterialTimeControl.tsx +42 -40
- package/src/layouts/ExpandPanelRenderer.tsx +44 -23
- package/src/layouts/MaterialArrayLayout.tsx +1 -1
- package/src/mui-controls/MuiAutocomplete.tsx +0 -1
- package/src/util/theme.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonforms/material-renderers",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0-alpha.0",
|
|
4
4
|
"description": "Material Renderer Set for JSON Forms",
|
|
5
5
|
"repository": "https://github.com/eclipsesource/jsonforms",
|
|
6
6
|
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@emotion/react": "^11.4.1",
|
|
75
75
|
"@emotion/styled": "^11.3.0",
|
|
76
|
-
"@jsonforms/core": "3.
|
|
77
|
-
"@jsonforms/react": "3.
|
|
76
|
+
"@jsonforms/core": "3.3.0-alpha.0",
|
|
77
|
+
"@jsonforms/react": "3.3.0-alpha.0",
|
|
78
78
|
"@mui/icons-material": "^5.11.16",
|
|
79
79
|
"@mui/material": "^5.13.0",
|
|
80
80
|
"@mui/x-date-pickers": "^6.0.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
|
|
99
99
|
"copy-webpack-plugin": "^5.0.5",
|
|
100
100
|
"enzyme": "^3.11.0",
|
|
101
|
-
"eslint": "^
|
|
101
|
+
"eslint": "^8.56.0",
|
|
102
102
|
"eslint-config-prettier": "^8.7.0",
|
|
103
103
|
"eslint-plugin-import": "^2.27.5",
|
|
104
104
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -119,20 +119,20 @@
|
|
|
119
119
|
"rollup-plugin-visualizer": "^5.4.1",
|
|
120
120
|
"source-map-loader": "^0.2.4",
|
|
121
121
|
"ts-jest": "^27.1.4",
|
|
122
|
-
"ts-loader": "^
|
|
122
|
+
"ts-loader": "^9.5.1",
|
|
123
123
|
"tslib": "^2.5.0",
|
|
124
124
|
"typedoc": "~0.25.3",
|
|
125
125
|
"typescript": "~4.9.5",
|
|
126
|
-
"webpack": "^
|
|
127
|
-
"webpack-cli": "^
|
|
128
|
-
"webpack-dev-server": "^
|
|
129
|
-
"@jsonforms/
|
|
130
|
-
"@jsonforms/
|
|
126
|
+
"webpack": "^5.78.0",
|
|
127
|
+
"webpack-cli": "^5.1.4",
|
|
128
|
+
"webpack-dev-server": "^4.15.1",
|
|
129
|
+
"@jsonforms/core": "3.3.0-alpha.0",
|
|
130
|
+
"@jsonforms/react": "3.3.0-alpha.0"
|
|
131
131
|
},
|
|
132
132
|
"scripts": {
|
|
133
133
|
"build": "rollup -c rollup.config.js",
|
|
134
134
|
"build:examples-app": "rollup -c rollup.example.config.js",
|
|
135
|
-
"dev": "webpack
|
|
135
|
+
"dev": "webpack-dev-server --config webpack/webpack.dev.js --env=dev",
|
|
136
136
|
"clean": "rimraf lib coverage dist .nyc_output example/dist 2> /dev/null",
|
|
137
137
|
"lint": "eslint .",
|
|
138
138
|
"lint:fix": "eslint --fix .",
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ControlProps,
|
|
4
4
|
DispatchPropsOfMultiEnumControl,
|
|
5
5
|
hasType,
|
|
6
|
+
isDescriptionHidden,
|
|
6
7
|
JsonSchema,
|
|
7
8
|
OwnPropsOfEnum,
|
|
8
9
|
Paths,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
resolveSchema,
|
|
12
13
|
schemaMatches,
|
|
13
14
|
schemaSubPathMatches,
|
|
15
|
+
showAsRequired,
|
|
14
16
|
uiTypeIs,
|
|
15
17
|
} from '@jsonforms/core';
|
|
16
18
|
|
|
@@ -21,15 +23,23 @@ import {
|
|
|
21
23
|
FormControlLabel,
|
|
22
24
|
FormGroup,
|
|
23
25
|
FormHelperText,
|
|
26
|
+
FormLabel,
|
|
24
27
|
Hidden,
|
|
25
28
|
} from '@mui/material';
|
|
26
29
|
import isEmpty from 'lodash/isEmpty';
|
|
27
30
|
import React from 'react';
|
|
31
|
+
import merge from 'lodash/merge';
|
|
32
|
+
import { useFocus } from '../util';
|
|
28
33
|
|
|
29
34
|
export const MaterialEnumArrayRenderer = ({
|
|
35
|
+
config,
|
|
36
|
+
id,
|
|
30
37
|
schema,
|
|
31
38
|
visible,
|
|
32
39
|
errors,
|
|
40
|
+
description,
|
|
41
|
+
label,
|
|
42
|
+
required,
|
|
33
43
|
path,
|
|
34
44
|
options,
|
|
35
45
|
data,
|
|
@@ -38,9 +48,34 @@ export const MaterialEnumArrayRenderer = ({
|
|
|
38
48
|
handleChange: _handleChange,
|
|
39
49
|
...otherProps
|
|
40
50
|
}: ControlProps & OwnPropsOfEnum & DispatchPropsOfMultiEnumControl) => {
|
|
51
|
+
const [focused, onFocus, onBlur] = useFocus();
|
|
52
|
+
const isValid = errors.length === 0;
|
|
53
|
+
const appliedUiSchemaOptions = merge({}, config, otherProps.uischema.options);
|
|
54
|
+
const showDescription = !isDescriptionHidden(
|
|
55
|
+
visible,
|
|
56
|
+
description,
|
|
57
|
+
focused,
|
|
58
|
+
appliedUiSchemaOptions.showUnfocusedDescription
|
|
59
|
+
);
|
|
60
|
+
|
|
41
61
|
return (
|
|
42
62
|
<Hidden xsUp={!visible}>
|
|
43
|
-
<FormControl
|
|
63
|
+
<FormControl
|
|
64
|
+
component='fieldset'
|
|
65
|
+
fullWidth={!appliedUiSchemaOptions.trim}
|
|
66
|
+
onFocus={onFocus}
|
|
67
|
+
onBlur={onBlur}
|
|
68
|
+
>
|
|
69
|
+
<FormLabel
|
|
70
|
+
error={!isValid}
|
|
71
|
+
component='legend'
|
|
72
|
+
required={showAsRequired(
|
|
73
|
+
required,
|
|
74
|
+
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
75
|
+
)}
|
|
76
|
+
>
|
|
77
|
+
{label}
|
|
78
|
+
</FormLabel>
|
|
44
79
|
<FormGroup row>
|
|
45
80
|
{options.map((option: any, index: number) => {
|
|
46
81
|
const optionPath = Paths.compose(path, `${index}`);
|
|
@@ -49,10 +84,11 @@ export const MaterialEnumArrayRenderer = ({
|
|
|
49
84
|
: undefined;
|
|
50
85
|
return (
|
|
51
86
|
<FormControlLabel
|
|
52
|
-
id={option.value}
|
|
87
|
+
id={id + '-label-' + option.value}
|
|
53
88
|
key={option.value}
|
|
54
89
|
control={
|
|
55
90
|
<MuiCheckbox
|
|
91
|
+
id={id + '-' + option.value}
|
|
56
92
|
key={'checkbox-' + option.value}
|
|
57
93
|
isValid={isEmpty(errors)}
|
|
58
94
|
path={optionPath}
|
|
@@ -73,7 +109,9 @@ export const MaterialEnumArrayRenderer = ({
|
|
|
73
109
|
);
|
|
74
110
|
})}
|
|
75
111
|
</FormGroup>
|
|
76
|
-
<FormHelperText error
|
|
112
|
+
<FormHelperText error={!isValid}>
|
|
113
|
+
{!isValid ? errors : showDescription ? description : null}
|
|
114
|
+
</FormHelperText>
|
|
77
115
|
</FormControl>
|
|
78
116
|
</Hidden>
|
|
79
117
|
);
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
TableCell,
|
|
43
43
|
TableHead,
|
|
44
44
|
TableRow,
|
|
45
|
+
Tooltip,
|
|
45
46
|
Typography,
|
|
46
47
|
} from '@mui/material';
|
|
47
48
|
import {
|
|
@@ -319,35 +320,55 @@ const NonEmptyRowComponent = ({
|
|
|
319
320
|
{showSortButtons ? (
|
|
320
321
|
<Fragment>
|
|
321
322
|
<Grid item>
|
|
322
|
-
<
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
<Tooltip
|
|
324
|
+
id='tooltip-up'
|
|
325
|
+
title={translations.up}
|
|
326
|
+
placement='bottom'
|
|
327
|
+
open={enableUp ? undefined : false}
|
|
327
328
|
>
|
|
328
|
-
<
|
|
329
|
-
|
|
329
|
+
<IconButton
|
|
330
|
+
aria-label={translations.upAriaLabel}
|
|
331
|
+
onClick={moveUp}
|
|
332
|
+
disabled={!enableUp}
|
|
333
|
+
size='large'
|
|
334
|
+
>
|
|
335
|
+
<ArrowUpward />
|
|
336
|
+
</IconButton>
|
|
337
|
+
</Tooltip>
|
|
330
338
|
</Grid>
|
|
331
339
|
<Grid item>
|
|
332
|
-
<
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
340
|
+
<Tooltip
|
|
341
|
+
id='tooltip-down'
|
|
342
|
+
title={translations.down}
|
|
343
|
+
placement='bottom'
|
|
344
|
+
open={enableDown ? undefined : false}
|
|
337
345
|
>
|
|
338
|
-
<
|
|
339
|
-
|
|
346
|
+
<IconButton
|
|
347
|
+
aria-label={translations.downAriaLabel}
|
|
348
|
+
onClick={moveDown}
|
|
349
|
+
disabled={!enableDown}
|
|
350
|
+
size='large'
|
|
351
|
+
>
|
|
352
|
+
<ArrowDownward />
|
|
353
|
+
</IconButton>
|
|
354
|
+
</Tooltip>
|
|
340
355
|
</Grid>
|
|
341
356
|
</Fragment>
|
|
342
357
|
) : null}
|
|
343
358
|
<Grid item>
|
|
344
|
-
<
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
<Tooltip
|
|
360
|
+
id='tooltip-remove'
|
|
361
|
+
title={translations.removeTooltip}
|
|
362
|
+
placement='bottom'
|
|
348
363
|
>
|
|
349
|
-
<
|
|
350
|
-
|
|
364
|
+
<IconButton
|
|
365
|
+
aria-label={translations.removeAriaLabel}
|
|
366
|
+
onClick={() => openDeleteDialog(childPath, rowIndex)}
|
|
367
|
+
size='large'
|
|
368
|
+
>
|
|
369
|
+
<DeleteIcon />
|
|
370
|
+
</IconButton>
|
|
371
|
+
</Tooltip>
|
|
351
372
|
</Grid>
|
|
352
373
|
</Grid>
|
|
353
374
|
</NoBorderTableCell>
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
rankWith,
|
|
34
34
|
} from '@jsonforms/core';
|
|
35
35
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
36
|
-
import { FormHelperText
|
|
36
|
+
import { FormHelperText } from '@mui/material';
|
|
37
37
|
import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
38
38
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
39
39
|
import {
|
|
@@ -69,6 +69,7 @@ export const MaterialDateControl = (props: ControlProps) => {
|
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
const [key, setKey] = useState<number>(0);
|
|
72
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
72
73
|
|
|
73
74
|
const format = appliedUiSchemaOptions.dateFormat ?? 'YYYY-MM-DD';
|
|
74
75
|
const saveFormat = appliedUiSchemaOptions.dateSaveFormat ?? defaultDateFormat;
|
|
@@ -103,46 +104,48 @@ export const MaterialDateControl = (props: ControlProps) => {
|
|
|
103
104
|
);
|
|
104
105
|
const value = getData(data, saveFormat);
|
|
105
106
|
|
|
107
|
+
if (!visible) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
106
111
|
return (
|
|
107
|
-
<
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
type: 'text',
|
|
133
|
-
},
|
|
134
|
-
InputLabelProps: data ? { shrink: true } : undefined,
|
|
135
|
-
onFocus: onFocus,
|
|
136
|
-
onBlur: onBlurHandler,
|
|
112
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
113
|
+
<DatePicker
|
|
114
|
+
open={open}
|
|
115
|
+
onOpen={() => setOpen(true)}
|
|
116
|
+
onClose={() => setOpen(false)}
|
|
117
|
+
key={key}
|
|
118
|
+
label={label}
|
|
119
|
+
value={value}
|
|
120
|
+
onAccept={onChange}
|
|
121
|
+
format={format}
|
|
122
|
+
views={views}
|
|
123
|
+
disabled={!enabled}
|
|
124
|
+
slotProps={{
|
|
125
|
+
actionBar: ({ wrapperVariant }) => ({
|
|
126
|
+
actions:
|
|
127
|
+
wrapperVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
|
|
128
|
+
}),
|
|
129
|
+
textField: {
|
|
130
|
+
id: id + '-input',
|
|
131
|
+
required: required && !appliedUiSchemaOptions.hideRequiredAsterisk,
|
|
132
|
+
autoFocus: appliedUiSchemaOptions.focus,
|
|
133
|
+
error: !isValid,
|
|
134
|
+
fullWidth: !appliedUiSchemaOptions.trim,
|
|
135
|
+
inputProps: {
|
|
136
|
+
type: 'text',
|
|
137
137
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
InputLabelProps: data ? { shrink: true } : undefined,
|
|
139
|
+
onFocus: onFocus,
|
|
140
|
+
onBlur: onBlurHandler,
|
|
141
|
+
},
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
<FormHelperText error={!isValid && !showDescription}>
|
|
145
|
+
{firstFormHelperText}
|
|
146
|
+
</FormHelperText>
|
|
147
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
148
|
+
</LocalizationProvider>
|
|
146
149
|
);
|
|
147
150
|
};
|
|
148
151
|
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
rankWith,
|
|
34
34
|
} from '@jsonforms/core';
|
|
35
35
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
36
|
-
import { FormHelperText
|
|
36
|
+
import { FormHelperText } from '@mui/material';
|
|
37
37
|
import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
38
38
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
39
39
|
import {
|
|
@@ -74,6 +74,7 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
|
|
|
74
74
|
appliedUiSchemaOptions.dateTimeSaveFormat ?? defaultDateTimeFormat;
|
|
75
75
|
|
|
76
76
|
const [key, setKey] = useState<number>(0);
|
|
77
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
77
78
|
|
|
78
79
|
const views = appliedUiSchemaOptions.views ?? [
|
|
79
80
|
'year',
|
|
@@ -110,47 +111,48 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
|
|
|
110
111
|
);
|
|
111
112
|
const value = getData(data, saveFormat);
|
|
112
113
|
|
|
114
|
+
if (!visible) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
113
117
|
return (
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
type: 'text',
|
|
141
|
-
},
|
|
142
|
-
InputLabelProps: data ? { shrink: true } : undefined,
|
|
143
|
-
onFocus: onFocus,
|
|
144
|
-
onBlur: onBlurHandler,
|
|
118
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
119
|
+
<DateTimePicker
|
|
120
|
+
open={open}
|
|
121
|
+
onOpen={() => setOpen(true)}
|
|
122
|
+
onClose={() => setOpen(false)}
|
|
123
|
+
key={key}
|
|
124
|
+
label={label}
|
|
125
|
+
value={value}
|
|
126
|
+
onAccept={onChange}
|
|
127
|
+
format={format}
|
|
128
|
+
ampm={!!appliedUiSchemaOptions.ampm}
|
|
129
|
+
views={views}
|
|
130
|
+
disabled={!enabled}
|
|
131
|
+
slotProps={{
|
|
132
|
+
actionBar: ({ wrapperVariant }) => ({
|
|
133
|
+
actions:
|
|
134
|
+
wrapperVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
|
|
135
|
+
}),
|
|
136
|
+
textField: {
|
|
137
|
+
id: id + '-input',
|
|
138
|
+
required: required && !appliedUiSchemaOptions.hideRequiredAsterisk,
|
|
139
|
+
autoFocus: appliedUiSchemaOptions.focus,
|
|
140
|
+
error: !isValid,
|
|
141
|
+
fullWidth: !appliedUiSchemaOptions.trim,
|
|
142
|
+
inputProps: {
|
|
143
|
+
type: 'text',
|
|
145
144
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
InputLabelProps: data ? { shrink: true } : undefined,
|
|
146
|
+
onFocus: onFocus,
|
|
147
|
+
onBlur: onBlurHandler,
|
|
148
|
+
},
|
|
149
|
+
}}
|
|
150
|
+
/>
|
|
151
|
+
<FormHelperText error={!isValid && !showDescription}>
|
|
152
|
+
{firstFormHelperText}
|
|
153
|
+
</FormHelperText>
|
|
154
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
155
|
+
</LocalizationProvider>
|
|
154
156
|
);
|
|
155
157
|
};
|
|
156
158
|
|
|
@@ -45,7 +45,6 @@ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
|
|
|
45
45
|
const [focused, onFocus, onBlur] = useFocus();
|
|
46
46
|
const {
|
|
47
47
|
config,
|
|
48
|
-
id,
|
|
49
48
|
label,
|
|
50
49
|
required,
|
|
51
50
|
description,
|
|
@@ -69,15 +68,14 @@ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
|
|
|
69
68
|
return (
|
|
70
69
|
<Hidden xsUp={!visible}>
|
|
71
70
|
<FormControl
|
|
72
|
-
component=
|
|
71
|
+
component='fieldset'
|
|
73
72
|
fullWidth={!appliedUiSchemaOptions.trim}
|
|
74
73
|
onFocus={onFocus}
|
|
75
74
|
onBlur={onBlur}
|
|
76
75
|
>
|
|
77
76
|
<FormLabel
|
|
78
|
-
htmlFor={id}
|
|
79
77
|
error={!isValid}
|
|
80
|
-
component=
|
|
78
|
+
component='legend'
|
|
81
79
|
required={showAsRequired(
|
|
82
80
|
required,
|
|
83
81
|
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
@@ -101,7 +101,7 @@ export const MaterialSliderControl = (props: ControlProps) => {
|
|
|
101
101
|
<FormLabel
|
|
102
102
|
htmlFor={id}
|
|
103
103
|
error={!isValid}
|
|
104
|
-
component=
|
|
104
|
+
component='legend'
|
|
105
105
|
required={showAsRequired(
|
|
106
106
|
required,
|
|
107
107
|
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
defaultTimeFormat,
|
|
34
34
|
} from '@jsonforms/core';
|
|
35
35
|
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
36
|
-
import { FormHelperText
|
|
36
|
+
import { FormHelperText } from '@mui/material';
|
|
37
37
|
import { TimePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
|
38
38
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
39
39
|
import {
|
|
@@ -63,6 +63,7 @@ export const MaterialTimeControl = (props: ControlProps) => {
|
|
|
63
63
|
const isValid = errors.length === 0;
|
|
64
64
|
|
|
65
65
|
const [key, setKey] = useState<number>(0);
|
|
66
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
66
67
|
|
|
67
68
|
const showDescription = !isDescriptionHidden(
|
|
68
69
|
visible,
|
|
@@ -104,47 +105,48 @@ export const MaterialTimeControl = (props: ControlProps) => {
|
|
|
104
105
|
);
|
|
105
106
|
const value = getData(data, saveFormat);
|
|
106
107
|
|
|
108
|
+
if (!visible) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
107
111
|
return (
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
type: 'text',
|
|
135
|
-
},
|
|
136
|
-
InputLabelProps: data ? { shrink: true } : undefined,
|
|
137
|
-
onFocus: onFocus,
|
|
138
|
-
onBlur: onBlurHandler,
|
|
112
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
113
|
+
<TimePicker
|
|
114
|
+
open={open}
|
|
115
|
+
onOpen={() => setOpen(true)}
|
|
116
|
+
onClose={() => setOpen(false)}
|
|
117
|
+
key={key}
|
|
118
|
+
label={label}
|
|
119
|
+
value={value}
|
|
120
|
+
onAccept={onChange}
|
|
121
|
+
format={format}
|
|
122
|
+
ampm={!!appliedUiSchemaOptions.ampm}
|
|
123
|
+
views={views}
|
|
124
|
+
disabled={!enabled}
|
|
125
|
+
slotProps={{
|
|
126
|
+
actionBar: ({ wrapperVariant }) => ({
|
|
127
|
+
actions:
|
|
128
|
+
wrapperVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
|
|
129
|
+
}),
|
|
130
|
+
textField: {
|
|
131
|
+
id: id + '-input',
|
|
132
|
+
required: required && !appliedUiSchemaOptions.hideRequiredAsterisk,
|
|
133
|
+
autoFocus: appliedUiSchemaOptions.focus,
|
|
134
|
+
error: !isValid,
|
|
135
|
+
fullWidth: !appliedUiSchemaOptions.trim,
|
|
136
|
+
inputProps: {
|
|
137
|
+
type: 'text',
|
|
139
138
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
InputLabelProps: data ? { shrink: true } : undefined,
|
|
140
|
+
onFocus: onFocus,
|
|
141
|
+
onBlur: onBlurHandler,
|
|
142
|
+
},
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
<FormHelperText error={!isValid && !showDescription}>
|
|
146
|
+
{firstFormHelperText}
|
|
147
|
+
</FormHelperText>
|
|
148
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
149
|
+
</LocalizationProvider>
|
|
148
150
|
);
|
|
149
151
|
};
|
|
150
152
|
|