@mui/x-date-pickers 6.11.1 → 6.12.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/AdapterDateFns/AdapterDateFns.d.ts +2 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -2
- package/AdapterDayjs/AdapterDayjs.d.ts +2 -2
- package/AdapterLuxon/AdapterLuxon.d.ts +2 -2
- package/AdapterMoment/AdapterMoment.d.ts +2 -2
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +2 -2
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +2 -2
- package/CHANGELOG.md +154 -31
- package/DateCalendar/DateCalendar.js +4 -4
- package/DateCalendar/DateCalendar.types.d.ts +2 -2
- package/DateCalendar/DayCalendar.js +2 -2
- package/DatePicker/DatePicker.js +2 -2
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/DesktopTimePicker/DesktopTimePicker.js +5 -0
- package/DigitalClock/DigitalClock.js +3 -1
- package/MobileDatePicker/MobileDatePicker.js +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/MobileTimePicker/MobileTimePicker.js +5 -0
- package/MonthCalendar/PickersMonth.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
- package/PickersShortcuts/PickersShortcuts.d.ts +2 -1
- package/PickersShortcuts/PickersShortcuts.js +9 -4
- package/PickersShortcuts/index.d.ts +1 -1
- package/StaticDatePicker/StaticDatePicker.js +2 -2
- package/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/StaticTimePicker/StaticTimePicker.js +5 -0
- package/TimePicker/TimePicker.js +5 -0
- package/YearCalendar/YearCalendar.js +5 -2
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -11
- package/internals/components/PickersPopper.d.ts +7 -4
- package/internals/components/PickersPopper.js +65 -32
- package/internals/components/PickersToolbar.js +13 -13
- package/internals/hooks/useDefaultReduceAnimations.d.ts +1 -1
- package/internals/hooks/useDefaultReduceAnimations.js +7 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
- package/internals/hooks/useField/useField.js +6 -6
- package/internals/hooks/useField/useField.utils.d.ts +0 -1
- package/internals/hooks/useField/useField.utils.js +0 -48
- package/internals/hooks/useField/useFieldState.js +5 -25
- package/internals/hooks/usePicker/usePickerValue.js +11 -3
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +3 -5
- package/internals/hooks/usePicker/usePickerViews.d.ts +5 -0
- package/internals/hooks/usePicker/usePickerViews.js +1 -1
- package/internals/hooks/useValidation.d.ts +2 -4
- package/internals/hooks/useValueWithTimezone.js +2 -2
- package/internals/hooks/useViews.js +1 -1
- package/legacy/DateCalendar/DateCalendar.js +4 -4
- package/legacy/DateCalendar/DayCalendar.js +2 -2
- package/legacy/DatePicker/DatePicker.js +2 -2
- package/legacy/DateTimePicker/DateTimePicker.js +2 -2
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +5 -0
- package/legacy/DigitalClock/DigitalClock.js +3 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +2 -2
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/legacy/MobileTimePicker/MobileTimePicker.js +5 -0
- package/legacy/MonthCalendar/PickersMonth.js +1 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
- package/legacy/PickersShortcuts/PickersShortcuts.js +7 -4
- package/legacy/StaticDatePicker/StaticDatePicker.js +2 -2
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/legacy/StaticTimePicker/StaticTimePicker.js +5 -0
- package/legacy/TimePicker/TimePicker.js +5 -0
- package/legacy/YearCalendar/YearCalendar.js +5 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -15
- package/legacy/internals/components/PickersPopper.js +61 -32
- package/legacy/internals/components/PickersToolbar.js +11 -14
- package/legacy/internals/hooks/useDefaultReduceAnimations.js +7 -2
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
- package/legacy/internals/hooks/useField/useField.js +6 -6
- package/legacy/internals/hooks/useField/useField.utils.js +0 -52
- package/legacy/internals/hooks/useField/useFieldState.js +4 -24
- package/legacy/internals/hooks/usePicker/usePickerValue.js +11 -3
- package/legacy/internals/hooks/usePicker/usePickerViews.js +1 -1
- package/legacy/internals/hooks/useValueWithTimezone.js +2 -2
- package/legacy/internals/hooks/useViews.js +1 -1
- package/legacy/models/index.js +2 -1
- package/legacy/models/pickers.js +1 -0
- package/legacy/tests/describeAdapters/describeAdapters.js +1 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +1 -1
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +1 -1
- package/legacy/tests/describeValidation/testDayViewValidation.js +1 -1
- package/legacy/tests/describeValidation/testMinutesViewValidation.js +2 -2
- package/legacy/tests/describeValidation/testMonthViewValidation.js +1 -1
- package/legacy/tests/describeValidation/testTextFieldValidation.js +1 -1
- package/legacy/tests/describeValidation/testYearViewValidation.js +1 -1
- package/legacy/tests/describeValue/describeValue.js +1 -1
- package/legacy/tests/describeValue/testControlledUnControlled.js +2 -2
- package/legacy/tests/describeValue/testPickerActionBar.js +1 -2
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +1 -1
- package/legacy/tests/describeValue/testShortcuts.js +1 -1
- package/models/adapters.d.ts +2 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/models/pickers.d.ts +9 -0
- package/models/pickers.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +2 -2
- package/modern/DatePicker/DatePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/modern/DesktopTimePicker/DesktopTimePicker.js +5 -0
- package/modern/DigitalClock/DigitalClock.js +3 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/modern/MobileTimePicker/MobileTimePicker.js +5 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
- package/modern/PickersShortcuts/PickersShortcuts.js +9 -4
- package/modern/StaticDatePicker/StaticDatePicker.js +2 -2
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/modern/StaticTimePicker/StaticTimePicker.js +5 -0
- package/modern/TimePicker/TimePicker.js +5 -0
- package/modern/YearCalendar/YearCalendar.js +4 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -11
- package/modern/internals/components/PickersPopper.js +63 -30
- package/modern/internals/components/PickersToolbar.js +9 -12
- package/modern/internals/hooks/useDefaultReduceAnimations.js +7 -2
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
- package/modern/internals/hooks/useField/useField.utils.js +0 -48
- package/modern/internals/hooks/useField/useFieldState.js +4 -24
- package/modern/internals/hooks/usePicker/usePickerValue.js +10 -2
- package/modern/models/index.js +2 -1
- package/modern/models/pickers.js +1 -0
- package/modern/tests/describeAdapters/describeAdapters.js +1 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +1 -1
- package/modern/tests/describeGregorianAdapter/testLocalization.js +1 -1
- package/modern/tests/describeValidation/testDayViewValidation.js +1 -1
- package/modern/tests/describeValidation/testMinutesViewValidation.js +2 -2
- package/modern/tests/describeValidation/testMonthViewValidation.js +1 -1
- package/modern/tests/describeValidation/testTextFieldValidation.js +1 -1
- package/modern/tests/describeValidation/testYearViewValidation.js +1 -1
- package/modern/tests/describeValue/describeValue.js +1 -1
- package/modern/tests/describeValue/testControlledUnControlled.js +1 -1
- package/modern/tests/describeValue/testPickerActionBar.js +1 -2
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +1 -1
- package/modern/tests/describeValue/testShortcuts.js +1 -1
- package/node/DateCalendar/DateCalendar.js +2 -2
- package/node/DatePicker/DatePicker.js +2 -2
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/node/DesktopTimePicker/DesktopTimePicker.js +5 -0
- package/node/DigitalClock/DigitalClock.js +3 -1
- package/node/MobileDatePicker/MobileDatePicker.js +2 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/node/MobileTimePicker/MobileTimePicker.js +5 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -1
- package/node/PickersShortcuts/PickersShortcuts.js +9 -4
- package/node/StaticDatePicker/StaticDatePicker.js +2 -2
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/node/StaticTimePicker/StaticTimePicker.js +5 -0
- package/node/TimePicker/TimePicker.js +5 -0
- package/node/YearCalendar/YearCalendar.js +4 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -11
- package/node/internals/components/PickersPopper.js +63 -30
- package/node/internals/components/PickersToolbar.js +9 -12
- package/node/internals/hooks/useDefaultReduceAnimations.js +9 -4
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +4 -2
- package/node/internals/hooks/useField/useField.utils.js +1 -50
- package/node/internals/hooks/useField/useFieldState.js +3 -23
- package/node/internals/hooks/usePicker/usePickerValue.js +10 -2
- package/node/models/index.js +11 -0
- package/node/models/pickers.js +5 -0
- package/node/tests/describeAdapters/describeAdapters.js +3 -3
- package/node/tests/describeGregorianAdapter/testCalculations.js +2 -2
- package/node/tests/describeGregorianAdapter/testLocalization.js +4 -4
- package/node/tests/describeValidation/testDayViewValidation.js +33 -33
- package/node/tests/describeValidation/testMinutesViewValidation.js +14 -14
- package/node/tests/describeValidation/testMonthViewValidation.js +22 -22
- package/node/tests/describeValidation/testTextFieldValidation.js +54 -54
- package/node/tests/describeValidation/testYearViewValidation.js +18 -18
- package/node/tests/describeValue/describeValue.js +2 -2
- package/node/tests/describeValue/testControlledUnControlled.js +3 -3
- package/node/tests/describeValue/testPickerActionBar.js +10 -11
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -10
- package/node/tests/describeValue/testShortcuts.js +6 -6
- package/package.json +3 -3
- package/tests/describeAdapters/describeAdapters.js +1 -1
- package/tests/describeGregorianAdapter/testCalculations.js +1 -1
- package/tests/describeGregorianAdapter/testLocalization.js +1 -1
- package/tests/describeValidation/testDayViewValidation.js +1 -1
- package/tests/describeValidation/testMinutesViewValidation.js +2 -2
- package/tests/describeValidation/testMonthViewValidation.js +1 -1
- package/tests/describeValidation/testTextFieldValidation.js +1 -1
- package/tests/describeValidation/testYearViewValidation.js +1 -1
- package/tests/describeValue/describeValue.js +1 -1
- package/tests/describeValue/testControlledUnControlled.js +2 -2
- package/tests/describeValue/testPickerActionBar.js +1 -2
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +1 -1
- package/tests/describeValue/testShortcuts.js +1 -1
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import useControlled from '@mui/utils/useControlled';
|
|
4
4
|
import { useTheme } from '@mui/material/styles';
|
|
5
5
|
import { useUtils, useLocaleText, useLocalizationContext } from '../useUtils';
|
|
6
|
-
import { addPositionPropertiesToSections, splitFormatIntoSections,
|
|
6
|
+
import { addPositionPropertiesToSections, splitFormatIntoSections, mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections } from './useField.utils';
|
|
7
7
|
import { useValueWithTimezone } from '../useValueWithTimezone';
|
|
8
8
|
import { getSectionTypeGranularity } from '../../utils/getDefaultReferenceDate';
|
|
9
9
|
export const useFieldState = params => {
|
|
@@ -209,21 +209,7 @@ export const useFieldState = params => {
|
|
|
209
209
|
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
210
210
|
const newSections = setSectionValue(selectedSectionIndexes.startIndex, newSectionValue);
|
|
211
211
|
const newActiveDateSections = activeDateManager.getSections(newSections);
|
|
212
|
-
|
|
213
|
-
let shouldRegenSections = false;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* If the date is invalid,
|
|
217
|
-
* Then we can try to clamp the day section to see if that produces a valid date.
|
|
218
|
-
* This can be useful if the month has fewer days than the day value currently provided.
|
|
219
|
-
*/
|
|
220
|
-
if (!utils.isValid(newActiveDate)) {
|
|
221
|
-
const clampedSections = clampDaySectionIfPossible(utils, timezone, newActiveDateSections, sectionsValueBoundaries);
|
|
222
|
-
if (clampedSections != null) {
|
|
223
|
-
shouldRegenSections = true;
|
|
224
|
-
newActiveDate = getDateFromDateSections(utils, clampedSections);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
212
|
+
const newActiveDate = getDateFromDateSections(utils, newActiveDateSections);
|
|
227
213
|
let values;
|
|
228
214
|
let shouldPublish;
|
|
229
215
|
|
|
@@ -241,22 +227,16 @@ export const useFieldState = params => {
|
|
|
241
227
|
shouldPublish = (newActiveDate != null && !utils.isValid(newActiveDate)) !== (activeDateManager.date != null && !utils.isValid(activeDateManager.date));
|
|
242
228
|
}
|
|
243
229
|
|
|
244
|
-
/**
|
|
245
|
-
* If the value has been modified (to clamp the day).
|
|
246
|
-
* Then we need to re-generate the sections to make sure they also have this change.
|
|
247
|
-
*/
|
|
248
|
-
const sections = shouldRegenSections ? getSectionsFromValue(values.value, state.sections) : newSections;
|
|
249
|
-
|
|
250
230
|
/**
|
|
251
231
|
* Publish or update the internal state with the new value and sections.
|
|
252
232
|
*/
|
|
253
233
|
if (shouldPublish) {
|
|
254
234
|
return publishValue(_extends({}, values, {
|
|
255
|
-
sections
|
|
235
|
+
sections: newSections
|
|
256
236
|
}));
|
|
257
237
|
}
|
|
258
238
|
return setState(prevState => _extends({}, prevState, values, {
|
|
259
|
-
sections,
|
|
239
|
+
sections: newSections,
|
|
260
240
|
tempValueStrAndroid: null
|
|
261
241
|
}));
|
|
262
242
|
};
|
|
@@ -221,6 +221,11 @@ export const usePickerValue = ({
|
|
|
221
221
|
const context = {
|
|
222
222
|
validationError
|
|
223
223
|
};
|
|
224
|
+
|
|
225
|
+
// TODO v7: Remove 2nd condition
|
|
226
|
+
if (action.name === 'setValueFromShortcut' && action.shortcut != null) {
|
|
227
|
+
context.shortcut = action.shortcut;
|
|
228
|
+
}
|
|
224
229
|
handleValueChange(action.value, context);
|
|
225
230
|
}
|
|
226
231
|
if (shouldCommit && onAccept) {
|
|
@@ -283,10 +288,13 @@ export const usePickerValue = ({
|
|
|
283
288
|
value: newValue,
|
|
284
289
|
selectionState
|
|
285
290
|
}));
|
|
286
|
-
|
|
291
|
+
|
|
292
|
+
// TODO v7: Make changeImportance and label mandatory.
|
|
293
|
+
const handleSelectShortcut = useEventCallback((newValue, changeImportance, shortcut) => updateDate({
|
|
287
294
|
name: 'setValueFromShortcut',
|
|
288
295
|
value: newValue,
|
|
289
|
-
changeImportance: changeImportance ?? 'accept'
|
|
296
|
+
changeImportance: changeImportance ?? 'accept',
|
|
297
|
+
shortcut
|
|
290
298
|
}));
|
|
291
299
|
const handleChangeFromField = useEventCallback((newValue, context) => updateDate({
|
|
292
300
|
name: 'setValueFromField',
|
package/modern/models/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import momentTZ from 'moment-timezone';
|
|
4
4
|
import createDescribe from '@mui/monorepo/test/utils/createDescribe';
|
|
5
|
-
import { buildFieldInteractions, createPickerRenderer } from 'test/utils/pickers
|
|
5
|
+
import { buildFieldInteractions, createPickerRenderer } from 'test/utils/pickers';
|
|
6
6
|
const ADAPTERS = ['dayjs', 'date-fns', 'luxon', 'moment'];
|
|
7
7
|
function innerDescribeAdapters(title, FieldComponent, testRunner) {
|
|
8
8
|
ADAPTERS.forEach(adapterName => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import { stub } from 'sinon';
|
|
3
|
-
import { cleanText } from 'test/utils/pickers
|
|
3
|
+
import { cleanText } from 'test/utils/pickers';
|
|
4
4
|
import { TEST_DATE_ISO_STRING } from './describeGregorianAdapter.utils';
|
|
5
5
|
export const testLocalization = ({
|
|
6
6
|
adapter
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { screen } from '@mui/monorepo/test/utils';
|
|
5
|
-
import { adapterToUse } from 'test/utils/pickers
|
|
5
|
+
import { adapterToUse } from 'test/utils/pickers';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const testDayViewValidation = (ElementToTest, getOptions) => {
|
|
8
8
|
const {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { expect } from 'chai';
|
|
3
2
|
import * as React from 'react';
|
|
3
|
+
import { expect } from 'chai';
|
|
4
4
|
import { screen } from '@mui/monorepo/test/utils';
|
|
5
|
-
import { adapterToUse } from 'test/utils/pickers
|
|
5
|
+
import { adapterToUse } from 'test/utils/pickers';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
const toMinutesLabel = minutes => `${Number(minutes) < 10 ? `0${minutes}` : minutes} minutes`;
|
|
8
8
|
export const testMinutesViewValidation = (ElementToTest, getOption) => {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { screen } from '@mui/monorepo/test/utils';
|
|
5
|
-
import { adapterToUse } from 'test/utils/pickers
|
|
5
|
+
import { adapterToUse } from 'test/utils/pickers';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const testMonthViewValidation = (ElementToTest, getOptions) => {
|
|
8
8
|
const {
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { expect } from 'chai';
|
|
4
4
|
import { spy } from 'sinon';
|
|
5
5
|
import { screen } from '@mui/monorepo/test/utils';
|
|
6
|
-
import { adapterToUse } from 'test/utils/pickers
|
|
6
|
+
import { adapterToUse } from 'test/utils/pickers';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
export const testTextFieldValidation = (ElementToTest, getOptions) => {
|
|
9
9
|
const {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { expect } from 'chai';
|
|
4
4
|
import { screen } from '@mui/monorepo/test/utils';
|
|
5
|
-
import { adapterToUse } from 'test/utils/pickers
|
|
5
|
+
import { adapterToUse } from 'test/utils/pickers';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const testYearViewValidation = (ElementToTest, getOptions) => {
|
|
8
8
|
const {
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["hook"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import createDescribe from '@mui/monorepo/test/utils/createDescribe';
|
|
6
|
-
import { buildFieldInteractions } from 'test/utils/pickers
|
|
6
|
+
import { buildFieldInteractions } from 'test/utils/pickers';
|
|
7
7
|
import { testControlledUnControlled } from './testControlledUnControlled';
|
|
8
8
|
import { testPickerOpenCloseLifeCycle } from './testPickerOpenCloseLifeCycle';
|
|
9
9
|
import { testPickerActionBar } from './testPickerActionBar';
|
|
@@ -6,7 +6,7 @@ import { expect } from 'chai';
|
|
|
6
6
|
import { spy } from 'sinon';
|
|
7
7
|
import { screen, act, userEvent } from '@mui/monorepo/test/utils';
|
|
8
8
|
import { inputBaseClasses } from '@mui/material/InputBase';
|
|
9
|
-
import { getExpectedOnChangeCount } from 'test/utils/pickers
|
|
9
|
+
import { getExpectedOnChangeCount } from 'test/utils/pickers';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
export const testControlledUnControlled = (ElementToTest, options) => {
|
|
@@ -4,8 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { expect } from 'chai';
|
|
5
5
|
import { spy } from 'sinon';
|
|
6
6
|
import { screen, userEvent } from '@mui/monorepo/test/utils';
|
|
7
|
-
import { adapterToUse, getExpectedOnChangeCount } from 'test/utils/pickers
|
|
8
|
-
import { expectPickerChangeHandlerValue } from 'test/utils/pickers/assertions';
|
|
7
|
+
import { adapterToUse, getExpectedOnChangeCount, expectPickerChangeHandlerValue } from 'test/utils/pickers';
|
|
9
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
9
|
export const testPickerActionBar = (ElementToTest, options) => {
|
|
11
10
|
const {
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { expect } from 'chai';
|
|
5
5
|
import { spy } from 'sinon';
|
|
6
6
|
import { screen, userEvent } from '@mui/monorepo/test/utils';
|
|
7
|
-
import { getExpectedOnChangeCount, getTextbox, openPicker } from 'test/utils/pickers
|
|
7
|
+
import { getExpectedOnChangeCount, getTextbox, openPicker } from 'test/utils/pickers';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export const testPickerOpenCloseLifeCycle = (ElementToTest, options) => {
|
|
10
10
|
const {
|
|
@@ -3,7 +3,7 @@ const _excluded = ["componentFamily", "render", "renderWithProps", "values", "em
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { expect } from 'chai';
|
|
5
5
|
import { spy } from 'sinon';
|
|
6
|
-
import { expectPickerChangeHandlerValue } from 'test/utils/pickers
|
|
6
|
+
import { expectPickerChangeHandlerValue } from 'test/utils/pickers';
|
|
7
7
|
import { userEvent, screen } from '@mui/monorepo/test/utils';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export const testShortcuts = (ElementToTest, options) => {
|
|
@@ -493,8 +493,8 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
493
493
|
*/
|
|
494
494
|
readOnly: _propTypes.default.bool,
|
|
495
495
|
/**
|
|
496
|
-
*
|
|
497
|
-
* @default
|
|
496
|
+
* If `true`, disable heavy animations.
|
|
497
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
498
498
|
*/
|
|
499
499
|
reduceAnimations: _propTypes.default.bool,
|
|
500
500
|
/**
|
|
@@ -251,8 +251,8 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
251
251
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
252
252
|
readOnly: _propTypes.default.bool,
|
|
253
253
|
/**
|
|
254
|
-
*
|
|
255
|
-
* @default
|
|
254
|
+
* If `true`, disable heavy animations.
|
|
255
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
256
256
|
*/
|
|
257
257
|
reduceAnimations: _propTypes.default.bool,
|
|
258
258
|
/**
|
|
@@ -289,8 +289,8 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
289
289
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
290
290
|
readOnly: _propTypes.default.bool,
|
|
291
291
|
/**
|
|
292
|
-
*
|
|
293
|
-
* @default
|
|
292
|
+
* If `true`, disable heavy animations.
|
|
293
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
294
294
|
*/
|
|
295
295
|
reduceAnimations: _propTypes.default.bool,
|
|
296
296
|
/**
|
|
@@ -265,8 +265,8 @@ DesktopDatePicker.propTypes = {
|
|
|
265
265
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
266
266
|
readOnly: _propTypes.default.bool,
|
|
267
267
|
/**
|
|
268
|
-
*
|
|
269
|
-
* @default
|
|
268
|
+
* If `true`, disable heavy animations.
|
|
269
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
270
270
|
*/
|
|
271
271
|
reduceAnimations: _propTypes.default.bool,
|
|
272
272
|
/**
|
|
@@ -339,8 +339,8 @@ DesktopDateTimePicker.propTypes = {
|
|
|
339
339
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
340
340
|
readOnly: _propTypes.default.bool,
|
|
341
341
|
/**
|
|
342
|
-
*
|
|
343
|
-
* @default
|
|
342
|
+
* If `true`, disable heavy animations.
|
|
343
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
344
344
|
*/
|
|
345
345
|
reduceAnimations: _propTypes.default.bool,
|
|
346
346
|
/**
|
|
@@ -260,6 +260,11 @@ DesktopTimePicker.propTypes = {
|
|
|
260
260
|
*/
|
|
261
261
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
262
262
|
readOnly: _propTypes.default.bool,
|
|
263
|
+
/**
|
|
264
|
+
* If `true`, disable heavy animations.
|
|
265
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
266
|
+
*/
|
|
267
|
+
reduceAnimations: _propTypes.default.bool,
|
|
263
268
|
/**
|
|
264
269
|
* The currently selected sections.
|
|
265
270
|
* This prop accept four formats:
|
|
@@ -50,7 +50,9 @@ const DigitalClockRoot = (0, _styles.styled)(_PickerViewRoot.PickerViewRoot, {
|
|
|
50
50
|
}) => ({
|
|
51
51
|
overflowY: 'auto',
|
|
52
52
|
width: '100%',
|
|
53
|
-
|
|
53
|
+
'@media (prefers-reduced-motion: no-preference)': {
|
|
54
|
+
scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
|
|
55
|
+
},
|
|
54
56
|
maxHeight: _dimensions.DIGITAL_CLOCK_VIEW_HEIGHT
|
|
55
57
|
}));
|
|
56
58
|
const DigitalClockList = (0, _styles.styled)(_MenuList.default, {
|
|
@@ -262,8 +262,8 @@ MobileDatePicker.propTypes = {
|
|
|
262
262
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
263
263
|
readOnly: _propTypes.default.bool,
|
|
264
264
|
/**
|
|
265
|
-
*
|
|
266
|
-
* @default
|
|
265
|
+
* If `true`, disable heavy animations.
|
|
266
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
267
267
|
*/
|
|
268
268
|
reduceAnimations: _propTypes.default.bool,
|
|
269
269
|
/**
|
|
@@ -311,8 +311,8 @@ MobileDateTimePicker.propTypes = {
|
|
|
311
311
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
312
312
|
readOnly: _propTypes.default.bool,
|
|
313
313
|
/**
|
|
314
|
-
*
|
|
315
|
-
* @default
|
|
314
|
+
* If `true`, disable heavy animations.
|
|
315
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
316
316
|
*/
|
|
317
317
|
reduceAnimations: _propTypes.default.bool,
|
|
318
318
|
/**
|
|
@@ -238,6 +238,11 @@ MobileTimePicker.propTypes = {
|
|
|
238
238
|
*/
|
|
239
239
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
240
240
|
readOnly: _propTypes.default.bool,
|
|
241
|
+
/**
|
|
242
|
+
* If `true`, disable heavy animations.
|
|
243
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
244
|
+
*/
|
|
245
|
+
reduceAnimations: _propTypes.default.bool,
|
|
241
246
|
/**
|
|
242
247
|
* The currently selected sections.
|
|
243
248
|
* This prop accept four formats:
|
|
@@ -42,7 +42,9 @@ const MultiSectionDigitalClockSectionRoot = (0, _styles.styled)(_MenuList.defaul
|
|
|
42
42
|
width: 56,
|
|
43
43
|
padding: 0,
|
|
44
44
|
overflow: 'hidden',
|
|
45
|
-
|
|
45
|
+
'@media (prefers-reduced-motion: no-preference)': {
|
|
46
|
+
scrollBehavior: ownerState.alreadyRendered ? 'smooth' : 'auto'
|
|
47
|
+
},
|
|
46
48
|
'&:hover': {
|
|
47
49
|
overflowY: 'auto'
|
|
48
50
|
},
|
|
@@ -14,7 +14,8 @@ var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
|
|
|
14
14
|
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
15
15
|
var _dimensions = require("../internals/constants/dimensions");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"]
|
|
17
|
+
const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"],
|
|
18
|
+
_excluded2 = ["getValue"];
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
21
|
function PickersShortcuts(props) {
|
|
@@ -28,14 +29,18 @@ function PickersShortcuts(props) {
|
|
|
28
29
|
if (items == null || items.length === 0) {
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
|
-
const resolvedItems = items.map(
|
|
32
|
-
|
|
32
|
+
const resolvedItems = items.map(_ref => {
|
|
33
|
+
let {
|
|
34
|
+
getValue
|
|
35
|
+
} = _ref,
|
|
36
|
+
item = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
|
|
37
|
+
const newValue = getValue({
|
|
33
38
|
isValid
|
|
34
39
|
});
|
|
35
40
|
return {
|
|
36
41
|
label: item.label,
|
|
37
42
|
onClick: () => {
|
|
38
|
-
onChange(newValue, changeImportance);
|
|
43
|
+
onChange(newValue, changeImportance, item);
|
|
39
44
|
},
|
|
40
45
|
disabled: !isValid(newValue)
|
|
41
46
|
};
|
|
@@ -210,8 +210,8 @@ StaticDatePicker.propTypes = {
|
|
|
210
210
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
211
211
|
readOnly: _propTypes.default.bool,
|
|
212
212
|
/**
|
|
213
|
-
*
|
|
214
|
-
* @default
|
|
213
|
+
* If `true`, disable heavy animations.
|
|
214
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
215
215
|
*/
|
|
216
216
|
reduceAnimations: _propTypes.default.bool,
|
|
217
217
|
/**
|
|
@@ -258,8 +258,8 @@ StaticDateTimePicker.propTypes = {
|
|
|
258
258
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
259
259
|
readOnly: _propTypes.default.bool,
|
|
260
260
|
/**
|
|
261
|
-
*
|
|
262
|
-
* @default
|
|
261
|
+
* If `true`, disable heavy animations.
|
|
262
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
263
263
|
*/
|
|
264
264
|
reduceAnimations: _propTypes.default.bool,
|
|
265
265
|
/**
|
|
@@ -184,6 +184,11 @@ StaticTimePicker.propTypes = {
|
|
|
184
184
|
*/
|
|
185
185
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
186
186
|
readOnly: _propTypes.default.bool,
|
|
187
|
+
/**
|
|
188
|
+
* If `true`, disable heavy animations.
|
|
189
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
190
|
+
*/
|
|
191
|
+
reduceAnimations: _propTypes.default.bool,
|
|
187
192
|
/**
|
|
188
193
|
* Disable specific clock time.
|
|
189
194
|
* @param {number} clockValue The value to check.
|
|
@@ -223,6 +223,11 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
223
223
|
*/
|
|
224
224
|
orientation: _propTypes.default.oneOf(['landscape', 'portrait']),
|
|
225
225
|
readOnly: _propTypes.default.bool,
|
|
226
|
+
/**
|
|
227
|
+
* If `true`, disable heavy animations.
|
|
228
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
229
|
+
*/
|
|
230
|
+
reduceAnimations: _propTypes.default.bool,
|
|
226
231
|
/**
|
|
227
232
|
* The currently selected sections.
|
|
228
233
|
* This prop accept four formats:
|
|
@@ -60,7 +60,10 @@ const YearCalendarRoot = (0, _styles.styled)('div', {
|
|
|
60
60
|
height: '100%',
|
|
61
61
|
padding: '0 4px',
|
|
62
62
|
width: 320,
|
|
63
|
-
maxHeight: 304
|
|
63
|
+
maxHeight: 304,
|
|
64
|
+
// avoid padding increasing width over defined
|
|
65
|
+
boxSizing: 'border-box',
|
|
66
|
+
position: 'relative'
|
|
64
67
|
});
|
|
65
68
|
const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(inProps, ref) {
|
|
66
69
|
const props = useYearCalendarDefaultizedProps(inProps, 'MuiYearCalendar');
|
package/node/index.js
CHANGED
|
@@ -94,21 +94,20 @@ const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrow
|
|
|
94
94
|
goTo: onGoToPrevious,
|
|
95
95
|
label: previousLabel
|
|
96
96
|
};
|
|
97
|
-
const [leftProps, rightProps] = isRTL ? [nextProps, previousProps] : [previousProps, nextProps];
|
|
98
97
|
const PreviousIconButton = slots?.previousIconButton ?? PickersArrowSwitcherButton;
|
|
99
98
|
const previousIconButtonProps = (0, _utils2.useSlotProps)({
|
|
100
99
|
elementType: PreviousIconButton,
|
|
101
100
|
externalSlotProps: slotProps?.previousIconButton,
|
|
102
101
|
additionalProps: {
|
|
103
102
|
size: 'medium',
|
|
104
|
-
title:
|
|
105
|
-
'aria-label':
|
|
106
|
-
disabled:
|
|
103
|
+
title: previousProps.label,
|
|
104
|
+
'aria-label': previousProps.label,
|
|
105
|
+
disabled: previousProps.isDisabled,
|
|
107
106
|
edge: 'end',
|
|
108
|
-
onClick:
|
|
107
|
+
onClick: previousProps.goTo
|
|
109
108
|
},
|
|
110
109
|
ownerState: (0, _extends2.default)({}, ownerState, {
|
|
111
|
-
hidden:
|
|
110
|
+
hidden: previousProps.isHidden
|
|
112
111
|
}),
|
|
113
112
|
className: classes.button
|
|
114
113
|
});
|
|
@@ -118,14 +117,14 @@ const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrow
|
|
|
118
117
|
externalSlotProps: slotProps?.nextIconButton,
|
|
119
118
|
additionalProps: {
|
|
120
119
|
size: 'medium',
|
|
121
|
-
title:
|
|
122
|
-
'aria-label':
|
|
123
|
-
disabled:
|
|
120
|
+
title: nextProps.label,
|
|
121
|
+
'aria-label': nextProps.label,
|
|
122
|
+
disabled: nextProps.isDisabled,
|
|
124
123
|
edge: 'start',
|
|
125
|
-
onClick:
|
|
124
|
+
onClick: nextProps.goTo
|
|
126
125
|
},
|
|
127
126
|
ownerState: (0, _extends2.default)({}, ownerState, {
|
|
128
|
-
hidden:
|
|
127
|
+
hidden: nextProps.isHidden
|
|
129
128
|
}),
|
|
130
129
|
className: classes.button
|
|
131
130
|
});
|