Skip to content

Commit 0cc5820

Browse files
committed
WIP: Support MUI X date pickers v8 for react material renderers
- Update dev and peer dependency of `@mui/x-date-pickers` from v7 to v8. - Adapt input variant handling for picker text fields - Adapt picker variant handling - Adapt textfield input property handling WIP/IN PROGRESS: - time and datetime pickers no longer autoclose after selecting the smallest unit - time and datetime picker require handling onChange in addition to onAccept. Otherwise, the value in the open picker is not updated. This was added here but triggers more data updates than before.
1 parent c610c85 commit 0cc5820

5 files changed

Lines changed: 58 additions & 29 deletions

File tree

packages/material-renderers/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"@jsonforms/react": "3.7.0-alpha.0",
9191
"@mui/icons-material": "^7.0.0",
9292
"@mui/material": "^7.0.0",
93-
"@mui/x-date-pickers": "^7.28.0",
93+
"@mui/x-date-pickers": "^8.0.0",
9494
"react": "^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
9595
},
9696
"devDependencies": {
@@ -100,7 +100,7 @@
100100
"@jsonforms/react": "workspace:*",
101101
"@mui/icons-material": "^7.3.0",
102102
"@mui/material": "^7.3.0",
103-
"@mui/x-date-pickers": "^7.29.4",
103+
"@mui/x-date-pickers": "^8.9.2",
104104
"@rollup/plugin-commonjs": "^23.0.3",
105105
"@rollup/plugin-json": "^5.0.2",
106106
"@rollup/plugin-node-resolve": "^15.0.1",

packages/material-renderers/src/controls/MaterialDateControl.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ import {
4141
createOnChangeHandler,
4242
getData,
4343
useFocus,
44+
useInputVariant,
4445
} from '../util';
4546

4647
export const MaterialDateControl = (props: ControlProps) => {
4748
const [focused, onFocus, onBlur] = useFocus();
49+
const inputVariant = useInputVariant();
4850
const {
4951
description,
5052
id,
@@ -100,7 +102,7 @@ export const MaterialDateControl = (props: ControlProps) => {
100102
updateChild,
101103
onBlur
102104
),
103-
[path, handleChange, format, saveFormat, updateChild]
105+
[path, handleChange, format, saveFormat, updateChild, onBlur]
104106
);
105107
const value = getData(data, saveFormat);
106108

@@ -122,22 +124,23 @@ export const MaterialDateControl = (props: ControlProps) => {
122124
views={views}
123125
disabled={!enabled}
124126
slotProps={{
125-
actionBar: ({ wrapperVariant }) => ({
127+
actionBar: ({ pickerVariant }) => ({
126128
actions:
127-
wrapperVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
129+
pickerVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
128130
}),
129131
textField: {
130132
id: id + '-input',
131133
required: required && !appliedUiSchemaOptions.hideRequiredAsterisk,
132-
autoFocus: appliedUiSchemaOptions.focus,
133134
error: !isValid,
134135
fullWidth: !appliedUiSchemaOptions.trim,
136+
variant: inputVariant,
135137
inputProps: {
138+
autoFocus: appliedUiSchemaOptions.focus,
136139
type: 'text',
140+
onFocus: onFocus,
141+
onBlur: onBlurHandler,
137142
},
138143
InputLabelProps: data ? { shrink: true } : undefined,
139-
onFocus: onFocus,
140-
onBlur: onBlurHandler,
141144
},
142145
}}
143146
/>

packages/material-renderers/src/controls/MaterialDateTimeControl.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ import {
4141
createOnChangeHandler,
4242
getData,
4343
useFocus,
44+
useInputVariant,
4445
} from '../util';
4546

4647
export const MaterialDateTimeControl = (props: ControlProps) => {
4748
const [focused, onFocus, onBlur] = useFocus();
49+
const inputVariant = useInputVariant();
4850
const {
4951
id,
5052
description,
@@ -124,27 +126,29 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
124126
label={label}
125127
value={value}
126128
onAccept={onChange}
129+
onChange={onChange}
127130
format={format}
128131
ampm={!!appliedUiSchemaOptions.ampm}
129132
views={views}
130133
disabled={!enabled}
131134
slotProps={{
132-
actionBar: ({ wrapperVariant }) => ({
135+
actionBar: ({ pickerVariant }) => ({
133136
actions:
134-
wrapperVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
137+
pickerVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
135138
}),
136139
textField: {
137140
id: id + '-input',
138141
required: required && !appliedUiSchemaOptions.hideRequiredAsterisk,
139-
autoFocus: appliedUiSchemaOptions.focus,
140142
error: !isValid,
141143
fullWidth: !appliedUiSchemaOptions.trim,
144+
variant: inputVariant,
142145
inputProps: {
146+
autoFocus: appliedUiSchemaOptions.focus,
143147
type: 'text',
148+
onFocus: onFocus,
149+
onBlur: onBlurHandler,
144150
},
145151
InputLabelProps: data ? { shrink: true } : undefined,
146-
onFocus: onFocus,
147-
onBlur: onBlurHandler,
148152
},
149153
}}
150154
/>

packages/material-renderers/src/controls/MaterialTimeControl.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ import {
4141
createOnChangeHandler,
4242
getData,
4343
useFocus,
44+
useInputVariant,
4445
} from '../util';
4546

4647
export const MaterialTimeControl = (props: ControlProps) => {
4748
const [focused, onFocus, onBlur] = useFocus();
49+
const inputVariant = useInputVariant();
4850
const {
4951
id,
5052
description,
@@ -118,27 +120,29 @@ export const MaterialTimeControl = (props: ControlProps) => {
118120
label={label}
119121
value={value}
120122
onAccept={onChange}
123+
onChange={onChange}
121124
format={format}
122125
ampm={!!appliedUiSchemaOptions.ampm}
123126
views={views}
124127
disabled={!enabled}
125128
slotProps={{
126-
actionBar: ({ wrapperVariant }) => ({
129+
actionBar: ({ pickerVariant }) => ({
127130
actions:
128-
wrapperVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
131+
pickerVariant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
129132
}),
130133
textField: {
131134
id: id + '-input',
132135
required: required && !appliedUiSchemaOptions.hideRequiredAsterisk,
133-
autoFocus: appliedUiSchemaOptions.focus,
134136
error: !isValid,
135137
fullWidth: !appliedUiSchemaOptions.trim,
138+
variant: inputVariant,
136139
inputProps: {
140+
autoFocus: appliedUiSchemaOptions.focus,
137141
type: 'text',
142+
onBlur: onBlurHandler,
143+
onFocus: onFocus,
138144
},
139145
InputLabelProps: data ? { shrink: true } : undefined,
140-
onFocus: onFocus,
141-
onBlur: onBlurHandler,
142146
},
143147
}}
144148
/>

pnpm-lock.yaml

Lines changed: 29 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)