Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate material date- and time pickers from mui/lab to mui/x-date-pickers #2002

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 120 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@
"@jsonforms/core": "3.0.0-rc.0",
"@jsonforms/react": "3.0.0-rc.0",
"@mui/icons-material": "^5.0.0",
"@mui/lab": "^5.0.0-alpha.54",
"@mui/material": "^5.0.0"
"@mui/material": "^5.0.0",
"@mui/x-date-pickers": "^5.0.0-beta.5"
},
"devDependencies": {
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@jsonforms/core": "^3.0.0-rc.0",
"@jsonforms/react": "^3.0.0-rc.0",
"@mui/icons-material": "^5.2.0",
"@mui/lab": "^5.0.0-alpha.58",
"@mui/material": "^5.2.2",
"@mui/x-date-pickers": "^5.0.0-beta.5",
"@types/enzyme": "^3.10.3",
"@types/react-dom": "^17.0.9",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
Expand Down
13 changes: 7 additions & 6 deletions packages/material/src/controls/MaterialDateControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { FormHelperText, Hidden } from '@mui/material';
import {
DatePicker,
LocalizationProvider
} from '@mui/lab';
import AdapterDayjs from '@mui/lab/AdapterDayjs';
} from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import {
createOnChangeHandler,
getData,
Expand Down Expand Up @@ -96,15 +96,16 @@ export const MaterialDateControl = (props: ControlProps)=> {
<DatePicker
label={label}
value={value}
clearable
onChange={onChange}
inputFormat={format}
disableMaskedInput
views={views}
disabled={!enabled}
cancelText={appliedUiSchemaOptions.cancelLabel}
clearText={appliedUiSchemaOptions.clearLabel}
okText={appliedUiSchemaOptions.okLabel}
componentsProps={{
actionBar: {
actions: (variant) => (variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'])
}
}}
renderInput={params => (
<ResettableTextField
{...params}
Expand Down
16 changes: 9 additions & 7 deletions packages/material/src/controls/MaterialDateTimeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { FormHelperText, Hidden } from '@mui/material';
import {
DateTimePicker,
LocalizationProvider
} from '@mui/lab';
import AdapterDayjs from '@mui/lab/AdapterDayjs';
} from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import {
createOnChangeHandler,
getData,
Expand Down Expand Up @@ -98,16 +98,17 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
<DateTimePicker
label={label}
value={value}
clearable
onChange={onChange}
inputFormat={format}
disableMaskedInput
ampm={!!appliedUiSchemaOptions.ampm}
views={views}
disabled={!enabled}
cancelText={appliedUiSchemaOptions.cancelLabel}
clearText={appliedUiSchemaOptions.clearLabel}
okText={appliedUiSchemaOptions.okLabel}
componentsProps={{
actionBar: {
actions: (variant) => (variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'])
}
}}
renderInput={params => (
<ResettableTextField
{...params}
Expand All @@ -129,7 +130,8 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
onBlur={onBlur}
variant={'standard'}
/>
)}
)
}
/>
<FormHelperText error={!isValid && !showDescription}>
{firstFormHelperText}
Expand Down
13 changes: 7 additions & 6 deletions packages/material/src/controls/MaterialTimeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { FormHelperText, Hidden } from '@mui/material';
import {
TimePicker,
LocalizationProvider
} from '@mui/lab';
import AdapterDayjs from '@mui/lab/AdapterDayjs';
} from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import {
createOnChangeHandler,
getData,
Expand Down Expand Up @@ -98,16 +98,17 @@ export const MaterialTimeControl = (props: ControlProps) => {
<TimePicker
label={label}
value={value}
clearable
onChange={onChange}
inputFormat={format}
disableMaskedInput
ampm={!!appliedUiSchemaOptions.ampm}
views={views}
disabled={!enabled}
cancelText={appliedUiSchemaOptions.cancelLabel}
clearText={appliedUiSchemaOptions.clearLabel}
okText={appliedUiSchemaOptions.okLabel}
componentsProps={{
actionBar: {
actions: (variant) => (variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'])
}
}}
sdirix marked this conversation as resolved.
Show resolved Hide resolved
renderInput={params => (
<ResettableTextField
{...params}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ describe('Material date time control', () => {
</JsonFormsStateProvider>
);
const input = wrapper.find('input').first();
(input.getDOMNode() as HTMLInputElement).value ='1961-12-94 20:15';
(input.getDOMNode() as HTMLInputElement).value ='1961-12-12 20:15';
input.simulate('change', input);
expect(onChangeData.data.foo).toBe(
dayjs('1961-12-94 20:15').format()
dayjs('1961-12-12 20:15').format()
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ describe('Material time control', () => {
const input = wrapper.find('input').first();
expect(input.props().value).toBe('02-13');

(input.getDOMNode() as HTMLInputElement).value = '12:01';
(input.getDOMNode() as HTMLInputElement).value = '12-01';
input.simulate('change', input);
expect(onChangeData.data.foo).toBe('1//12 am');
});
Expand Down