@mui/x-date-pickers 5.0.2 → 6.0.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/CHANGELOG.md +212 -3
- package/CalendarPicker/CalendarPicker.d.ts +8 -2
- package/CalendarPicker/CalendarPicker.js +54 -71
- package/CalendarPicker/DayPicker.d.ts +2 -2
- package/CalendarPicker/DayPicker.js +6 -2
- package/CalendarPicker/PickersCalendarHeader.d.ts +3 -10
- package/CalendarPicker/PickersCalendarHeader.js +7 -20
- package/CalendarPicker/useCalendarState.d.ts +2 -2
- package/CalendarPicker/useCalendarState.js +7 -7
- package/ClockPicker/Clock.d.ts +9 -4
- package/ClockPicker/Clock.js +13 -13
- package/ClockPicker/ClockNumbers.d.ts +3 -3
- package/ClockPicker/ClockNumbers.js +2 -2
- package/ClockPicker/ClockPicker.d.ts +8 -58
- package/ClockPicker/ClockPicker.js +52 -128
- package/ClockPicker/ClockPointer.d.ts +1 -1
- package/ClockPicker/ClockPointer.js +4 -4
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +5 -1
- package/DatePicker/DatePicker.js +10 -20
- package/DateTimePicker/DateTimePicker.js +10 -39
- package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +14 -22
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.js +9 -21
- package/LocalizationProvider/LocalizationProvider.d.ts +10 -11
- package/LocalizationProvider/LocalizationProvider.js +31 -24
- package/MobileDatePicker/MobileDatePicker.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.js +14 -22
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/MobileTimePicker/MobileTimePicker.d.ts +1 -1
- package/MobileTimePicker/MobileTimePicker.js +9 -21
- package/MonthPicker/MonthPicker.d.ts +12 -9
- package/MonthPicker/MonthPicker.js +60 -57
- package/MonthPicker/PickersMonth.d.ts +10 -7
- package/MonthPicker/PickersMonth.js +76 -44
- package/MonthPicker/pickersMonthClasses.d.ts +9 -1
- package/MonthPicker/pickersMonthClasses.js +1 -1
- package/PickersDay/PickersDay.d.ts +0 -6
- package/PickersDay/PickersDay.js +0 -5
- package/StaticDatePicker/StaticDatePicker.d.ts +1 -1
- package/StaticDatePicker/StaticDatePicker.js +17 -23
- package/StaticDateTimePicker/StaticDateTimePicker.d.ts +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +17 -42
- package/StaticTimePicker/StaticTimePicker.d.ts +1 -1
- package/StaticTimePicker/StaticTimePicker.js +17 -22
- package/TimePicker/TimePicker.js +5 -19
- package/YearPicker/PickersYear.d.ts +7 -6
- package/YearPicker/PickersYear.js +34 -23
- package/YearPicker/YearPicker.d.ts +21 -4
- package/YearPicker/YearPicker.js +109 -49
- package/YearPicker/pickersYearClasses.d.ts +1 -1
- package/index.js +1 -1
- package/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/internals/components/PickerStaticWrapper/PickerStaticWrapper.d.ts +20 -6
- package/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +38 -22
- package/internals/components/PickerStaticWrapper/index.d.ts +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.d.ts +3 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +166 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +63 -0
- package/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/internals/components/PickersArrowSwitcher/index.d.ts +2 -0
- package/internals/components/PickersArrowSwitcher/index.js +1 -0
- package/internals/components/{pickersArrowSwitcherClasses.d.ts → PickersArrowSwitcher/pickersArrowSwitcherClasses.d.ts} +0 -0
- package/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/internals/components/PickersPopper.d.ts +2 -6
- package/internals/components/PickersPopper.js +5 -5
- package/internals/components/PickersToolbar.d.ts +1 -1
- package/internals/components/PickersToolbar.js +1 -2
- package/internals/components/PickersToolbarText.d.ts +1 -1
- package/internals/components/wrappers/DesktopTooltipWrapper.d.ts +1 -1
- package/internals/components/wrappers/DesktopTooltipWrapper.js +29 -24
- package/internals/components/wrappers/DesktopWrapper.d.ts +8 -3
- package/internals/components/wrappers/DesktopWrapper.js +26 -21
- package/internals/components/wrappers/MobileWrapper.d.ts +8 -3
- package/internals/components/wrappers/MobileWrapper.js +23 -18
- package/internals/hooks/useField/useField.interfaces.d.ts +0 -1
- package/internals/hooks/useField/useField.js +19 -23
- package/internals/hooks/useField/useField.utils.js +10 -2
- package/internals/hooks/useUtils.d.ts +5 -2
- package/internals/hooks/useUtils.js +11 -2
- package/internals/hooks/validation/useDateValidation.d.ts +4 -4
- package/internals/hooks/validation/useDateValidation.js +12 -2
- package/internals/index.d.ts +5 -5
- package/internals/index.js +3 -3
- package/internals/models/muiPickersAdapter.d.ts +12 -7
- package/internals/models/props/baseToolbarProps.d.ts +0 -8
- package/internals/models/props/staticPickerProps.d.ts +2 -8
- package/legacy/CalendarPicker/CalendarPicker.js +52 -69
- package/legacy/CalendarPicker/DayPicker.js +6 -2
- package/legacy/CalendarPicker/PickersCalendarHeader.js +7 -20
- package/legacy/CalendarPicker/useCalendarState.js +7 -7
- package/legacy/ClockPicker/Clock.js +13 -13
- package/legacy/ClockPicker/ClockNumbers.js +2 -2
- package/legacy/ClockPicker/ClockPicker.js +57 -133
- package/legacy/ClockPicker/ClockPointer.js +4 -4
- package/legacy/DateField/useDateField.js +5 -1
- package/legacy/DatePicker/DatePicker.js +10 -20
- package/legacy/DateTimePicker/DateTimePicker.js +10 -39
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +13 -21
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +8 -20
- package/legacy/LocalizationProvider/LocalizationProvider.js +28 -23
- package/legacy/MobileDatePicker/MobileDatePicker.js +13 -21
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/legacy/MobileTimePicker/MobileTimePicker.js +8 -20
- package/legacy/MonthPicker/MonthPicker.js +67 -62
- package/legacy/MonthPicker/PickersMonth.js +89 -57
- package/legacy/MonthPicker/pickersMonthClasses.js +1 -1
- package/legacy/PickersDay/PickersDay.js +0 -5
- package/legacy/StaticDatePicker/StaticDatePicker.js +17 -24
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +17 -43
- package/legacy/StaticTimePicker/StaticTimePicker.js +17 -23
- package/legacy/TimePicker/TimePicker.js +5 -19
- package/legacy/YearPicker/PickersYear.js +35 -25
- package/legacy/YearPicker/YearPicker.js +111 -51
- package/legacy/index.js +1 -1
- package/legacy/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/legacy/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +41 -24
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +180 -0
- package/legacy/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/legacy/internals/components/PickersArrowSwitcher/index.js +1 -0
- package/legacy/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/legacy/internals/components/PickersPopper.js +5 -5
- package/legacy/internals/components/PickersToolbar.js +1 -2
- package/legacy/internals/components/wrappers/DesktopTooltipWrapper.js +29 -24
- package/legacy/internals/components/wrappers/DesktopWrapper.js +26 -21
- package/legacy/internals/components/wrappers/MobileWrapper.js +22 -17
- package/legacy/internals/hooks/useField/useField.js +21 -23
- package/legacy/internals/hooks/useField/useField.utils.js +10 -2
- package/legacy/internals/hooks/useUtils.js +13 -2
- package/legacy/internals/hooks/validation/useDateValidation.js +12 -2
- package/legacy/internals/index.js +3 -3
- package/legacy/locales/faIR.js +52 -0
- package/legacy/locales/fiFI.js +61 -0
- package/legacy/locales/index.js +2 -0
- package/legacy/locales/isIS.js +0 -1
- package/locales/faIR.d.ts +35 -0
- package/locales/faIR.js +36 -0
- package/locales/fiFI.d.ts +35 -0
- package/locales/fiFI.js +45 -0
- package/locales/index.d.ts +2 -0
- package/locales/index.js +2 -0
- package/locales/isIS.js +0 -1
- package/locales/utils/pickersLocaleTextApi.d.ts +1 -0
- package/modern/CalendarPicker/CalendarPicker.js +54 -71
- package/modern/CalendarPicker/DayPicker.js +6 -2
- package/modern/CalendarPicker/PickersCalendarHeader.js +7 -20
- package/modern/CalendarPicker/useCalendarState.js +7 -7
- package/modern/ClockPicker/Clock.js +13 -13
- package/modern/ClockPicker/ClockNumbers.js +2 -2
- package/modern/ClockPicker/ClockPicker.js +52 -128
- package/modern/ClockPicker/ClockPointer.js +4 -4
- package/modern/DateField/useDateField.js +5 -1
- package/modern/DatePicker/DatePicker.js +10 -20
- package/modern/DateTimePicker/DateTimePicker.js +10 -39
- package/modern/DesktopDatePicker/DesktopDatePicker.js +14 -22
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/modern/DesktopTimePicker/DesktopTimePicker.js +9 -21
- package/modern/LocalizationProvider/LocalizationProvider.js +29 -24
- package/modern/MobileDatePicker/MobileDatePicker.js +14 -22
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/modern/MobileTimePicker/MobileTimePicker.js +9 -21
- package/modern/MonthPicker/MonthPicker.js +60 -57
- package/modern/MonthPicker/PickersMonth.js +76 -44
- package/modern/MonthPicker/pickersMonthClasses.js +1 -1
- package/modern/PickersDay/PickersDay.js +0 -5
- package/modern/StaticDatePicker/StaticDatePicker.js +17 -23
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +17 -42
- package/modern/StaticTimePicker/StaticTimePicker.js +17 -22
- package/modern/TimePicker/TimePicker.js +5 -19
- package/modern/YearPicker/PickersYear.js +34 -23
- package/modern/YearPicker/YearPicker.js +109 -49
- package/modern/index.js +1 -1
- package/modern/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/modern/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +38 -22
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +164 -0
- package/modern/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/modern/internals/components/PickersArrowSwitcher/index.js +1 -0
- package/modern/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/modern/internals/components/PickersPopper.js +5 -5
- package/modern/internals/components/PickersToolbar.js +1 -2
- package/modern/internals/components/wrappers/DesktopTooltipWrapper.js +29 -24
- package/modern/internals/components/wrappers/DesktopWrapper.js +26 -21
- package/modern/internals/components/wrappers/MobileWrapper.js +23 -18
- package/modern/internals/hooks/useField/useField.js +19 -21
- package/modern/internals/hooks/useField/useField.utils.js +10 -2
- package/modern/internals/hooks/useUtils.js +11 -2
- package/modern/internals/hooks/validation/useDateValidation.js +12 -2
- package/modern/internals/index.js +3 -3
- package/modern/locales/faIR.js +36 -0
- package/modern/locales/fiFI.js +45 -0
- package/modern/locales/index.js +2 -0
- package/modern/locales/isIS.js +0 -1
- package/node/CalendarPicker/CalendarPicker.js +54 -71
- package/node/CalendarPicker/DayPicker.js +5 -1
- package/node/CalendarPicker/PickersCalendarHeader.js +7 -21
- package/node/CalendarPicker/useCalendarState.js +6 -6
- package/node/ClockPicker/Clock.js +12 -12
- package/node/ClockPicker/ClockNumbers.js +2 -2
- package/node/ClockPicker/ClockPicker.js +52 -129
- package/node/ClockPicker/ClockPointer.js +4 -4
- package/node/DateField/useDateField.js +5 -1
- package/node/DatePicker/DatePicker.js +10 -20
- package/node/DateTimePicker/DateTimePicker.js +10 -39
- package/node/DesktopDatePicker/DesktopDatePicker.js +14 -22
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/node/DesktopTimePicker/DesktopTimePicker.js +9 -21
- package/node/LocalizationProvider/LocalizationProvider.js +31 -25
- package/node/MobileDatePicker/MobileDatePicker.js +14 -22
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/node/MobileTimePicker/MobileTimePicker.js +9 -21
- package/node/MonthPicker/MonthPicker.js +61 -58
- package/node/MonthPicker/PickersMonth.js +71 -43
- package/node/MonthPicker/pickersMonthClasses.js +1 -1
- package/node/PickersDay/PickersDay.js +0 -5
- package/node/StaticDatePicker/StaticDatePicker.js +17 -23
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +17 -42
- package/node/StaticTimePicker/StaticTimePicker.js +17 -22
- package/node/TimePicker/TimePicker.js +5 -19
- package/node/YearPicker/PickersYear.js +33 -22
- package/node/YearPicker/YearPicker.js +111 -49
- package/node/index.js +1 -1
- package/node/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/node/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +39 -22
- package/node/internals/components/{PickersArrowSwitcher.js → PickersArrowSwitcher/PickersArrowSwitcher.js} +102 -58
- package/node/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/node/internals/components/PickersArrowSwitcher/index.js +13 -0
- package/node/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/node/internals/components/PickersPopper.js +5 -5
- package/node/internals/components/PickersToolbar.js +1 -2
- package/node/internals/components/wrappers/DesktopTooltipWrapper.js +30 -24
- package/node/internals/components/wrappers/DesktopWrapper.js +27 -21
- package/node/internals/components/wrappers/MobileWrapper.js +24 -18
- package/node/internals/hooks/useField/useField.js +19 -23
- package/node/internals/hooks/useField/useField.utils.js +10 -2
- package/node/internals/hooks/useUtils.js +15 -2
- package/node/internals/hooks/validation/useDateValidation.js +14 -4
- package/node/internals/index.js +8 -2
- package/node/locales/faIR.js +45 -0
- package/node/locales/fiFI.js +54 -0
- package/node/locales/index.js +26 -0
- package/node/locales/isIS.js +0 -1
- package/package.json +4 -4
- package/themeAugmentation/props.d.ts +3 -3
- package/internals/components/PickersArrowSwitcher.d.ts +0 -62
- package/internals/components/PickersArrowSwitcher.js +0 -124
- package/legacy/internals/components/PickersArrowSwitcher.js +0 -128
- package/modern/internals/components/PickersArrowSwitcher.js +0 -124
|
@@ -156,12 +156,20 @@ export const adjustInvalidDateSectionValue = (utils, section, keyCode) => {
|
|
|
156
156
|
|
|
157
157
|
if (shouldSetAbsolute) {
|
|
158
158
|
if (delta > 0 || isEnd) {
|
|
159
|
-
newDate = utils.endOfMonth(today);
|
|
160
|
-
} else {
|
|
161
159
|
newDate = utils.startOfMonth(today);
|
|
160
|
+
} else {
|
|
161
|
+
newDate = utils.endOfMonth(today);
|
|
162
162
|
}
|
|
163
163
|
} else {
|
|
164
164
|
newDate = utils.addDays(utils.parse(section.value, section.formatValue), delta);
|
|
165
|
+
|
|
166
|
+
if (!utils.isSameMonth(newDate, today)) {
|
|
167
|
+
if (delta > 0) {
|
|
168
|
+
newDate = utils.startOfMonth(today);
|
|
169
|
+
} else {
|
|
170
|
+
newDate = utils.endOfMonth(today);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
return utils.formatByString(newDate, section.formatValue);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { MuiPickersAdapterContextValue } from '../../LocalizationProvider/LocalizationProvider';
|
|
2
|
-
|
|
2
|
+
import { PickersLocaleText } from '../../locales/utils/pickersLocaleTextApi';
|
|
3
|
+
export declare const useLocalizationContext: <TDate>() => Omit<MuiPickersAdapterContextValue<TDate>, "localeText"> & {
|
|
4
|
+
localeText: PickersLocaleText<TDate>;
|
|
5
|
+
};
|
|
3
6
|
export declare const useUtils: <T>() => import("..").MuiPickersAdapter<T>;
|
|
4
7
|
export declare const useDefaultDates: <T>() => {
|
|
5
8
|
minDate: T;
|
|
6
9
|
maxDate: T;
|
|
7
10
|
};
|
|
8
|
-
export declare const useLocaleText: <T>() =>
|
|
11
|
+
export declare const useLocaleText: <T>() => PickersLocaleText<T>;
|
|
9
12
|
export declare const useNow: <TDate>() => TDate;
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { MuiPickersAdapterContext } from '../../LocalizationProvider/LocalizationProvider';
|
|
4
|
+
import { DEFAULT_LOCALE } from '../../locales/enUS';
|
|
3
5
|
export const useLocalizationContext = () => {
|
|
4
6
|
const localization = React.useContext(MuiPickersAdapterContext);
|
|
5
7
|
|
|
6
8
|
if (localization === null) {
|
|
7
|
-
throw new Error('MUI: Can not find
|
|
9
|
+
throw new Error(['MUI: Can not find the date and time pickers localization context.', 'It looks like you forgot to wrap your component in LocalizationProvider.', 'This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package'].join('\n'));
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
if (localization.utils === null) {
|
|
13
|
+
throw new Error(['MUI: Can not find the date and time pickers adapter from its localization context.', 'It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider.'].join('\n'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const localeText = React.useMemo(() => _extends({}, DEFAULT_LOCALE, localization.localeText), [localization.localeText]);
|
|
17
|
+
return _extends({}, localization, {
|
|
18
|
+
localeText
|
|
19
|
+
});
|
|
11
20
|
};
|
|
12
21
|
export const useUtils = () => useLocalizationContext().utils;
|
|
13
22
|
export const useDefaultDates = () => useLocalizationContext().defaultDates;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ValidationProps, Validator } from './useValidation';
|
|
2
|
-
import { BaseDateValidationProps, DayValidationProps } from './models';
|
|
2
|
+
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from './models';
|
|
3
3
|
export interface ExportedDateValidationProps<TDate> extends DayValidationProps<TDate>, BaseDateValidationProps<TDate> {
|
|
4
4
|
}
|
|
5
|
-
export interface DateValidationProps<TInputDate, TDate> extends ValidationProps<DateValidationError, TInputDate | null>, DayValidationProps<TDate>, Required<BaseDateValidationProps<TDate>> {
|
|
5
|
+
export interface DateValidationProps<TInputDate, TDate> extends ValidationProps<DateValidationError, TInputDate | null>, DayValidationProps<TDate>, MonthValidationProps<TDate>, YearValidationProps<TDate>, Required<BaseDateValidationProps<TDate>> {
|
|
6
6
|
}
|
|
7
|
-
export declare type DateValidationError = 'invalidDate' | 'shouldDisableDate' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | null;
|
|
7
|
+
export declare type DateValidationError = 'invalidDate' | 'shouldDisableDate' | 'shouldDisableMonth' | 'shouldDisableYear' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | null;
|
|
8
8
|
export declare const validateDate: Validator<any, DateValidationProps<any, any>>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const useIsDateDisabled: <TDate>({ shouldDisableDate, shouldDisableMonth, shouldDisableYear, minDate, maxDate, disableFuture, disablePast, }: Omit<DateValidationProps<any, TDate>, keyof ValidationProps<any, any>>) => (day: TDate | null) => boolean;
|
|
10
10
|
export declare const isSameDateError: (a: DateValidationError, b: DateValidationError) => boolean;
|
|
11
11
|
export declare const useDateValidation: <TInputDate, TDate>(props: DateValidationProps<TInputDate, TDate>) => DateValidationError;
|
|
@@ -23,6 +23,12 @@ export const validateDate = ({
|
|
|
23
23
|
case Boolean(props.shouldDisableDate && props.shouldDisableDate(date)):
|
|
24
24
|
return 'shouldDisableDate';
|
|
25
25
|
|
|
26
|
+
case Boolean(props.shouldDisableMonth && props.shouldDisableMonth(date)):
|
|
27
|
+
return 'shouldDisableMonth';
|
|
28
|
+
|
|
29
|
+
case Boolean(props.shouldDisableYear && props.shouldDisableYear(date)):
|
|
30
|
+
return 'shouldDisableYear';
|
|
31
|
+
|
|
26
32
|
case Boolean(props.disableFuture && adapter.utils.isAfterDay(date, now)):
|
|
27
33
|
return 'disableFuture';
|
|
28
34
|
|
|
@@ -39,8 +45,10 @@ export const validateDate = ({
|
|
|
39
45
|
return null;
|
|
40
46
|
}
|
|
41
47
|
};
|
|
42
|
-
export const
|
|
48
|
+
export const useIsDateDisabled = ({
|
|
43
49
|
shouldDisableDate,
|
|
50
|
+
shouldDisableMonth,
|
|
51
|
+
shouldDisableYear,
|
|
44
52
|
minDate,
|
|
45
53
|
maxDate,
|
|
46
54
|
disableFuture,
|
|
@@ -52,12 +60,14 @@ export const useIsDayDisabled = ({
|
|
|
52
60
|
value: day,
|
|
53
61
|
props: {
|
|
54
62
|
shouldDisableDate,
|
|
63
|
+
shouldDisableMonth,
|
|
64
|
+
shouldDisableYear,
|
|
55
65
|
minDate,
|
|
56
66
|
maxDate,
|
|
57
67
|
disableFuture,
|
|
58
68
|
disablePast
|
|
59
69
|
}
|
|
60
|
-
}) !== null, [adapter, shouldDisableDate, minDate, maxDate, disableFuture, disablePast]);
|
|
70
|
+
}) !== null, [adapter, shouldDisableDate, shouldDisableMonth, shouldDisableYear, minDate, maxDate, disableFuture, disablePast]);
|
|
61
71
|
};
|
|
62
72
|
export const isSameDateError = (a, b) => a === b;
|
|
63
73
|
export const useDateValidation = props => useValidation(props, validateDate, isSameDateError);
|
package/internals/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export { MobileKeyboardInputView } from './components/CalendarOrClockPicker/Cale
|
|
|
6
6
|
export type { CalendarOrClockPickerProps } from './components/CalendarOrClockPicker/CalendarOrClockPicker';
|
|
7
7
|
export { calendarOrClockPickerClasses } from './components/CalendarOrClockPicker/calendarOrClockPickerClasses';
|
|
8
8
|
export type { CalendarOrClockPickerClassKey, CalendarOrClockPickerClasses, } from './components/CalendarOrClockPicker/calendarOrClockPickerClasses';
|
|
9
|
-
export { PickersArrowSwitcher } from './components/PickersArrowSwitcher';
|
|
10
|
-
export type {
|
|
9
|
+
export { PickersArrowSwitcher } from './components/PickersArrowSwitcher/PickersArrowSwitcher';
|
|
10
|
+
export type { ExportedPickersArrowSwitcherProps, PickersArrowSwitcherSlotsComponent, PickersArrowSwitcherSlotsComponentsProps, } from './components/PickersArrowSwitcher';
|
|
11
11
|
export { PickerStaticWrapper } from './components/PickerStaticWrapper/PickerStaticWrapper';
|
|
12
12
|
export type { PickerStaticWrapperProps } from './components/PickerStaticWrapper/PickerStaticWrapper';
|
|
13
13
|
export type { PickersStaticWrapperSlotsComponent, PickersStaticWrapperSlotsComponentsProps, } from './components/PickerStaticWrapper/PickerStaticWrapper';
|
|
@@ -21,8 +21,8 @@ export type { PickersToolbarButtonClassKey, PickersToolbarButtonClasses, } from
|
|
|
21
21
|
export type { PickersToolbarTextProps } from './components/PickersToolbarText';
|
|
22
22
|
export { pickersToolbarTextClasses } from './components/pickersToolbarTextClasses';
|
|
23
23
|
export type { PickersToolbarTextClassKey, PickersToolbarTextClasses, } from './components/pickersToolbarTextClasses';
|
|
24
|
-
export { pickersArrowSwitcherClasses } from './components/pickersArrowSwitcherClasses';
|
|
25
|
-
export type { PickersArrowSwitcherClassKey, PickersArrowSwitcherClasses, } from './components/pickersArrowSwitcherClasses';
|
|
24
|
+
export { pickersArrowSwitcherClasses } from './components/PickersArrowSwitcher/pickersArrowSwitcherClasses';
|
|
25
|
+
export type { PickersArrowSwitcherClassKey, PickersArrowSwitcherClasses, } from './components/PickersArrowSwitcher/pickersArrowSwitcherClasses';
|
|
26
26
|
export type { PickerPopperProps } from './components/PickersPopper';
|
|
27
27
|
export { pickersPopperClasses } from './components/pickersPopperClasses';
|
|
28
28
|
export type { PickersPopperClassKey, PickersPopperClasses, } from './components/pickersPopperClasses';
|
|
@@ -38,7 +38,7 @@ export { useMaskedInput } from './hooks/useMaskedInput';
|
|
|
38
38
|
export { usePickerState } from './hooks/usePickerState';
|
|
39
39
|
export type { PickerStateProps, PickerStatePickerProps } from './hooks/usePickerState';
|
|
40
40
|
export type { PickerStateValueManager, PickerSelectionState } from './hooks/usePickerState';
|
|
41
|
-
export { useDefaultDates, useUtils, useLocaleText } from './hooks/useUtils';
|
|
41
|
+
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText } from './hooks/useUtils';
|
|
42
42
|
export type { BaseDateValidationProps, DayValidationProps } from './hooks/validation/models';
|
|
43
43
|
export { useValidation } from './hooks/validation/useValidation';
|
|
44
44
|
export type { ValidationProps, Validator } from './hooks/validation/useValidation';
|
package/internals/index.js
CHANGED
|
@@ -2,13 +2,13 @@ export { DesktopTooltipWrapper } from './components/wrappers/DesktopTooltipWrapp
|
|
|
2
2
|
export { MobileWrapper } from './components/wrappers/MobileWrapper';
|
|
3
3
|
export { MobileKeyboardInputView } from './components/CalendarOrClockPicker/CalendarOrClockPicker';
|
|
4
4
|
export { calendarOrClockPickerClasses } from './components/CalendarOrClockPicker/calendarOrClockPickerClasses';
|
|
5
|
-
export { PickersArrowSwitcher } from './components/PickersArrowSwitcher';
|
|
5
|
+
export { PickersArrowSwitcher } from './components/PickersArrowSwitcher/PickersArrowSwitcher';
|
|
6
6
|
export { PickerStaticWrapper } from './components/PickerStaticWrapper/PickerStaticWrapper';
|
|
7
7
|
export { PickersToolbar } from './components/PickersToolbar';
|
|
8
8
|
export { pickersToolbarClasses } from './components/pickersToolbarClasses';
|
|
9
9
|
export { pickersToolbarButtonClasses } from './components/pickersToolbarButtonClasses';
|
|
10
10
|
export { pickersToolbarTextClasses } from './components/pickersToolbarTextClasses';
|
|
11
|
-
export { pickersArrowSwitcherClasses } from './components/pickersArrowSwitcherClasses';
|
|
11
|
+
export { pickersArrowSwitcherClasses } from './components/PickersArrowSwitcher/pickersArrowSwitcherClasses';
|
|
12
12
|
export { pickersPopperClasses } from './components/pickersPopperClasses';
|
|
13
13
|
export { PickersToolbarButton } from './components/PickersToolbarButton';
|
|
14
14
|
export { pickerStaticWrapperClasses } from './components/PickerStaticWrapper/pickerStaticWrapperClasses';
|
|
@@ -16,7 +16,7 @@ export { WrapperVariantContext } from './components/wrappers/WrapperVariantConte
|
|
|
16
16
|
export { DAY_MARGIN } from './constants/dimensions';
|
|
17
17
|
export { useMaskedInput } from './hooks/useMaskedInput';
|
|
18
18
|
export { usePickerState } from './hooks/usePickerState';
|
|
19
|
-
export { useDefaultDates, useUtils, useLocaleText } from './hooks/useUtils';
|
|
19
|
+
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText } from './hooks/useUtils';
|
|
20
20
|
export { useValidation } from './hooks/validation/useValidation';
|
|
21
21
|
export { validateDate } from './hooks/validation/useDateValidation';
|
|
22
22
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { IUtils } from '@date-io/core/IUtils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
|
|
3
|
+
// TODO: Maybe we should add the same constraint.
|
|
4
|
+
// @ts-expect-error TDate in our codebase does not have the `ExtendableDateType` constraint.
|
|
5
|
+
export type MuiPickersAdapter<TDate> = IUtils<TDate>;
|
|
6
|
+
|
|
7
|
+
export type MuiDateSectionName = 'day' | 'month' | 'year' | 'hour' | 'minute' | 'second' | 'am-pm';
|
|
8
|
+
|
|
9
|
+
export type MuiFormatTokenMap = { [formatToken: string]: MuiDateSectionName };
|
|
10
|
+
|
|
7
11
|
export interface MuiPickerFieldAdapter<TDate> extends MuiPickersAdapter<TDate> {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
formatTokenMap: MuiFormatTokenMap;
|
|
13
|
+
|
|
14
|
+
expandFormat: (format: string) => string;
|
|
10
15
|
}
|
|
@@ -7,14 +7,6 @@ import { PickerStatePickerProps } from '../../hooks/usePickerState';
|
|
|
7
7
|
export interface BaseToolbarProps<TDate, TValue> extends ExportedCalendarPickerProps<TDate>, ExportedClockPickerProps<TDate>, Omit<PickerStatePickerProps<TValue>, 'onDateChange'> {
|
|
8
8
|
ampmInClock?: boolean;
|
|
9
9
|
dateRangeIcon?: React.ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Text for aria label of the button switching between input and interactive view.
|
|
12
|
-
* @deprecated Use the translation key `inputModeToggleButtonAriaLabel` instead, see https://mui.com/x/react-date-pickers/localization
|
|
13
|
-
* @param {boolean} isKeyboardInputOpen Indicates if the interface is the keyboard input.
|
|
14
|
-
* @param {'calendar' | 'clock' } viewType Indicates if the interface is about a date or a time.
|
|
15
|
-
* @returns {string} The arial label
|
|
16
|
-
*/
|
|
17
|
-
getMobileKeyboardInputViewButtonText?: (isKeyboardInputOpen: boolean, viewType: 'calendar' | 'clock') => string;
|
|
18
10
|
isLandscape: boolean;
|
|
19
11
|
onChange: PickerOnChangeFn<TDate>;
|
|
20
12
|
openView: CalendarOrClockPickerView;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { BasePickerProps } from './basePickerProps';
|
|
2
|
-
import {
|
|
3
|
-
export declare type StaticPickerProps<BaseProps extends BasePickerProps<any, any>> = Omit<BaseProps, 'open' | 'onOpen' | 'onClose'> &
|
|
4
|
-
/**
|
|
5
|
-
* Force static wrapper inner components to be rendered in mobile or desktop mode.
|
|
6
|
-
* @default 'mobile'
|
|
7
|
-
*/
|
|
8
|
-
displayStaticWrapperAs?: PickerStaticWrapperProps['displayStaticWrapperAs'];
|
|
9
|
-
};
|
|
2
|
+
import { ExportedPickerStaticWrapperProps } from '../../components/PickerStaticWrapper';
|
|
3
|
+
export declare type StaticPickerProps<TDate, BaseProps extends BasePickerProps<any, any>> = Omit<BaseProps, 'open' | 'onOpen' | 'onClose'> & ExportedPickerStaticWrapperProps<TDate>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
var _excluded = ["autoFocus", "onViewChange", "date", "disableFuture", "disablePast", "defaultCalendarMonth", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "classes"];
|
|
5
3
|
import * as React from 'react';
|
|
6
4
|
import PropTypes from 'prop-types';
|
|
7
5
|
import clsx from 'clsx';
|
|
@@ -73,9 +71,7 @@ var CalendarPickerViewTransitionContainer = styled(PickersFadeTransitionGroup, {
|
|
|
73
71
|
overridesResolver: function overridesResolver(props, styles) {
|
|
74
72
|
return styles.viewTransitionContainer;
|
|
75
73
|
}
|
|
76
|
-
})({
|
|
77
|
-
overflowY: 'auto'
|
|
78
|
-
});
|
|
74
|
+
})({});
|
|
79
75
|
|
|
80
76
|
/**
|
|
81
77
|
*
|
|
@@ -91,10 +87,9 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
91
87
|
var utils = useUtils();
|
|
92
88
|
var id = useId();
|
|
93
89
|
var props = useCalendarPickerDefaultizedProps(inProps, 'MuiCalendarPicker');
|
|
94
|
-
|
|
95
90
|
var autoFocus = props.autoFocus,
|
|
96
91
|
onViewChange = props.onViewChange,
|
|
97
|
-
|
|
92
|
+
value = props.value,
|
|
98
93
|
disableFuture = props.disableFuture,
|
|
99
94
|
disablePast = props.disablePast,
|
|
100
95
|
defaultCalendarMonth = props.defaultCalendarMonth,
|
|
@@ -116,8 +111,14 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
116
111
|
disableHighlightToday = props.disableHighlightToday,
|
|
117
112
|
focusedView = props.focusedView,
|
|
118
113
|
onFocusedViewChange = props.onFocusedViewChange,
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
showDaysOutsideCurrentMonth = props.showDaysOutsideCurrentMonth,
|
|
115
|
+
dayOfWeekFormatter = props.dayOfWeekFormatter,
|
|
116
|
+
renderDay = props.renderDay,
|
|
117
|
+
components = props.components,
|
|
118
|
+
componentsProps = props.componentsProps,
|
|
119
|
+
loading = props.loading,
|
|
120
|
+
renderLoading = props.renderLoading,
|
|
121
|
+
sx = props.sx;
|
|
121
122
|
|
|
122
123
|
var _useViews = useViews({
|
|
123
124
|
view: view,
|
|
@@ -131,7 +132,7 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
131
132
|
openNext = _useViews.openNext;
|
|
132
133
|
|
|
133
134
|
var _useCalendarState = useCalendarState({
|
|
134
|
-
|
|
135
|
+
value: value,
|
|
135
136
|
defaultCalendarMonth: defaultCalendarMonth,
|
|
136
137
|
reduceAnimations: reduceAnimations,
|
|
137
138
|
onMonthChange: onMonthChange,
|
|
@@ -148,7 +149,7 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
148
149
|
isDateDisabled = _useCalendarState.isDateDisabled,
|
|
149
150
|
onMonthSwitchingAnimationEnd = _useCalendarState.onMonthSwitchingAnimationEnd;
|
|
150
151
|
|
|
151
|
-
var handleDateMonthChange = React.useCallback(function (newDate
|
|
152
|
+
var handleDateMonthChange = React.useCallback(function (newDate) {
|
|
152
153
|
var startOfMonth = utils.startOfMonth(newDate);
|
|
153
154
|
var endOfMonth = utils.endOfMonth(newDate);
|
|
154
155
|
var closestEnabledDate = isDateDisabled(newDate) ? findClosestEnabledDate({
|
|
@@ -162,7 +163,7 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
162
163
|
}) : newDate;
|
|
163
164
|
|
|
164
165
|
if (closestEnabledDate) {
|
|
165
|
-
onChange(closestEnabledDate,
|
|
166
|
+
onChange(closestEnabledDate, 'finish');
|
|
166
167
|
onMonthChange == null ? void 0 : onMonthChange(startOfMonth);
|
|
167
168
|
} else {
|
|
168
169
|
openNext();
|
|
@@ -171,7 +172,7 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
171
172
|
|
|
172
173
|
changeFocusedDay(closestEnabledDate, true);
|
|
173
174
|
}, [changeFocusedDay, disableFuture, disablePast, isDateDisabled, maxDate, minDate, onChange, onMonthChange, changeMonth, openNext, utils]);
|
|
174
|
-
var handleDateYearChange = React.useCallback(function (newDate
|
|
175
|
+
var handleDateYearChange = React.useCallback(function (newDate) {
|
|
175
176
|
var startOfYear = utils.startOfYear(newDate);
|
|
176
177
|
var endOfYear = utils.endOfYear(newDate);
|
|
177
178
|
var closestEnabledDate = isDateDisabled(newDate) ? findClosestEnabledDate({
|
|
@@ -185,7 +186,7 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
185
186
|
}) : newDate;
|
|
186
187
|
|
|
187
188
|
if (closestEnabledDate) {
|
|
188
|
-
onChange(closestEnabledDate,
|
|
189
|
+
onChange(closestEnabledDate, 'finish');
|
|
189
190
|
onYearChange == null ? void 0 : onYearChange(closestEnabledDate);
|
|
190
191
|
} else {
|
|
191
192
|
openNext();
|
|
@@ -195,35 +196,18 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
195
196
|
changeFocusedDay(closestEnabledDate, true);
|
|
196
197
|
}, [changeFocusedDay, disableFuture, disablePast, isDateDisabled, maxDate, minDate, onChange, onYearChange, openNext, utils, changeMonth]);
|
|
197
198
|
var onSelectedDayChange = React.useCallback(function (day, isFinish) {
|
|
198
|
-
if (
|
|
199
|
+
if (value && day) {
|
|
199
200
|
// If there is a date already selected, then we want to keep its time
|
|
200
|
-
return onChange(utils.mergeDateAndTime(day,
|
|
201
|
+
return onChange(utils.mergeDateAndTime(day, value), isFinish);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
return onChange(day, isFinish);
|
|
204
|
-
}, [utils,
|
|
205
|
+
}, [utils, value, onChange]);
|
|
205
206
|
React.useEffect(function () {
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
utils: utils,
|
|
209
|
-
date: date,
|
|
210
|
-
minDate: minDate,
|
|
211
|
-
maxDate: maxDate,
|
|
212
|
-
disablePast: disablePast,
|
|
213
|
-
disableFuture: disableFuture,
|
|
214
|
-
isDateDisabled: isDateDisabled
|
|
215
|
-
});
|
|
216
|
-
onChange(closestEnabledDate, 'partial');
|
|
217
|
-
} // This call is too expensive to run it on each prop change.
|
|
218
|
-
// So just ensure that we are not rendering disabled as selected on mount.
|
|
219
|
-
|
|
220
|
-
}, []); // eslint-disable-line
|
|
221
|
-
|
|
222
|
-
React.useEffect(function () {
|
|
223
|
-
if (date) {
|
|
224
|
-
changeMonth(date);
|
|
207
|
+
if (value != null && utils.isValid(value)) {
|
|
208
|
+
changeMonth(value);
|
|
225
209
|
}
|
|
226
|
-
}, [
|
|
210
|
+
}, [value]); // eslint-disable-line
|
|
227
211
|
|
|
228
212
|
var ownerState = props;
|
|
229
213
|
var classes = useUtilityClasses(ownerState);
|
|
@@ -234,8 +218,8 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
234
218
|
minDate: minDate
|
|
235
219
|
}; // When disabled, limit the view to the selected date
|
|
236
220
|
|
|
237
|
-
var minDateWithDisabled = disabled &&
|
|
238
|
-
var maxDateWithDisabled = disabled &&
|
|
221
|
+
var minDateWithDisabled = disabled && value || minDate;
|
|
222
|
+
var maxDateWithDisabled = disabled && value || maxDate;
|
|
239
223
|
var commonViewProps = {
|
|
240
224
|
disableHighlightToday: disableHighlightToday,
|
|
241
225
|
readOnly: readOnly,
|
|
@@ -272,11 +256,16 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
272
256
|
}
|
|
273
257
|
};
|
|
274
258
|
});
|
|
259
|
+
React.useEffect(function () {
|
|
260
|
+
// Set focus to the button when switching from a view to another
|
|
261
|
+
handleFocusedViewChange(openView)(true);
|
|
262
|
+
}, [openView, handleFocusedViewChange]);
|
|
275
263
|
return /*#__PURE__*/_jsxs(CalendarPickerRoot, {
|
|
276
264
|
ref: ref,
|
|
277
265
|
className: clsx(classes.root, className),
|
|
278
266
|
ownerState: ownerState,
|
|
279
|
-
|
|
267
|
+
sx: sx,
|
|
268
|
+
children: [/*#__PURE__*/_jsx(PickersCalendarHeader, {
|
|
280
269
|
views: views,
|
|
281
270
|
openView: openView,
|
|
282
271
|
currentMonth: calendarState.currentMonth,
|
|
@@ -293,16 +282,18 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
293
282
|
disablePast: disablePast,
|
|
294
283
|
disableFuture: disableFuture,
|
|
295
284
|
reduceAnimations: reduceAnimations,
|
|
296
|
-
labelId: gridLabelId
|
|
297
|
-
|
|
285
|
+
labelId: gridLabelId,
|
|
286
|
+
components: components,
|
|
287
|
+
componentsProps: componentsProps
|
|
288
|
+
}), /*#__PURE__*/_jsx(CalendarPickerViewTransitionContainer, {
|
|
298
289
|
reduceAnimations: reduceAnimations,
|
|
299
290
|
className: classes.viewTransitionContainer,
|
|
300
291
|
transKey: openView,
|
|
301
292
|
ownerState: ownerState,
|
|
302
293
|
children: /*#__PURE__*/_jsxs("div", {
|
|
303
|
-
children: [openView === 'year' && /*#__PURE__*/_jsx(YearPicker, _extends({},
|
|
294
|
+
children: [openView === 'year' && /*#__PURE__*/_jsx(YearPicker, _extends({}, baseDateValidationProps, commonViewProps, {
|
|
304
295
|
autoFocus: autoFocus,
|
|
305
|
-
|
|
296
|
+
value: value,
|
|
306
297
|
onChange: handleDateYearChange,
|
|
307
298
|
shouldDisableYear: shouldDisableYear,
|
|
308
299
|
hasFocus: hasFocus,
|
|
@@ -311,21 +302,28 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
|
|
|
311
302
|
autoFocus: autoFocus,
|
|
312
303
|
hasFocus: hasFocus,
|
|
313
304
|
className: className,
|
|
314
|
-
|
|
305
|
+
value: value,
|
|
315
306
|
onChange: handleDateMonthChange,
|
|
316
307
|
shouldDisableMonth: shouldDisableMonth,
|
|
317
308
|
onFocusedViewChange: handleFocusedViewChange('month')
|
|
318
|
-
})), openView === 'day' && /*#__PURE__*/_jsx(DayPicker, _extends({},
|
|
309
|
+
})), openView === 'day' && /*#__PURE__*/_jsx(DayPicker, _extends({}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
319
310
|
autoFocus: autoFocus,
|
|
320
311
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
321
312
|
onFocusedDayChange: changeFocusedDay,
|
|
322
313
|
reduceAnimations: reduceAnimations,
|
|
323
|
-
selectedDays: [
|
|
314
|
+
selectedDays: [value],
|
|
324
315
|
onSelectedDaysChange: onSelectedDayChange,
|
|
325
316
|
shouldDisableDate: shouldDisableDate,
|
|
317
|
+
shouldDisableMonth: shouldDisableMonth,
|
|
318
|
+
shouldDisableYear: shouldDisableYear,
|
|
326
319
|
hasFocus: hasFocus,
|
|
327
320
|
onFocusedViewChange: handleFocusedViewChange('day'),
|
|
328
|
-
gridLabelId: gridLabelId
|
|
321
|
+
gridLabelId: gridLabelId,
|
|
322
|
+
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
323
|
+
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
324
|
+
renderDay: renderDay,
|
|
325
|
+
loading: loading,
|
|
326
|
+
renderLoading: renderLoading
|
|
329
327
|
}))]
|
|
330
328
|
})
|
|
331
329
|
})]
|
|
@@ -351,7 +349,6 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
|
|
|
351
349
|
* @default {}
|
|
352
350
|
*/
|
|
353
351
|
componentsProps: PropTypes.object,
|
|
354
|
-
date: PropTypes.any,
|
|
355
352
|
|
|
356
353
|
/**
|
|
357
354
|
* Formats the day of week displayed in the calendar header.
|
|
@@ -391,20 +388,6 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
|
|
|
391
388
|
disablePast: PropTypes.bool,
|
|
392
389
|
focusedView: PropTypes.oneOf(['day', 'month', 'year']),
|
|
393
390
|
|
|
394
|
-
/**
|
|
395
|
-
* Get aria-label text for switching between views button.
|
|
396
|
-
* @param {CalendarPickerView} currentView The view from which we want to get the button text.
|
|
397
|
-
* @returns {string} The label of the view.
|
|
398
|
-
* @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
|
|
399
|
-
*/
|
|
400
|
-
getViewSwitchingButtonText: PropTypes.func,
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Left arrow icon aria-label text.
|
|
404
|
-
* @deprecated
|
|
405
|
-
*/
|
|
406
|
-
leftArrowButtonText: PropTypes.string,
|
|
407
|
-
|
|
408
391
|
/**
|
|
409
392
|
* If `true` renders `LoadingComponent` in calendar instead of calendar view.
|
|
410
393
|
* Can be used to preload information and show it in calendar.
|
|
@@ -484,12 +467,6 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
|
|
|
484
467
|
*/
|
|
485
468
|
renderLoading: PropTypes.func,
|
|
486
469
|
|
|
487
|
-
/**
|
|
488
|
-
* Right arrow icon aria-label text.
|
|
489
|
-
* @deprecated
|
|
490
|
-
*/
|
|
491
|
-
rightArrowButtonText: PropTypes.string,
|
|
492
|
-
|
|
493
470
|
/**
|
|
494
471
|
* Disable specific date. @DateIOType
|
|
495
472
|
* @template TDate
|
|
@@ -522,6 +499,12 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
|
|
|
522
499
|
*/
|
|
523
500
|
showDaysOutsideCurrentMonth: PropTypes.bool,
|
|
524
501
|
|
|
502
|
+
/**
|
|
503
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
504
|
+
*/
|
|
505
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
506
|
+
value: PropTypes.any,
|
|
507
|
+
|
|
525
508
|
/**
|
|
526
509
|
* Controlled open view.
|
|
527
510
|
*/
|
|
@@ -9,7 +9,7 @@ import { PickersDay } from '../PickersDay/PickersDay';
|
|
|
9
9
|
import { useUtils, useNow } from '../internals/hooks/useUtils';
|
|
10
10
|
import { DAY_SIZE, DAY_MARGIN } from '../internals/constants/dimensions';
|
|
11
11
|
import { PickersSlideTransition } from './PickersSlideTransition';
|
|
12
|
-
import {
|
|
12
|
+
import { useIsDateDisabled } from '../internals/hooks/validation/useDateValidation';
|
|
13
13
|
import { findClosestEnabledDate } from '../internals/utils/date-utils';
|
|
14
14
|
import { getDayPickerUtilityClass } from './dayPickerClasses';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -144,13 +144,17 @@ export function DayPicker(inProps) {
|
|
|
144
144
|
minDate = props.minDate,
|
|
145
145
|
maxDate = props.maxDate,
|
|
146
146
|
shouldDisableDate = props.shouldDisableDate,
|
|
147
|
+
shouldDisableMonth = props.shouldDisableMonth,
|
|
148
|
+
shouldDisableYear = props.shouldDisableYear,
|
|
147
149
|
_props$dayOfWeekForma = props.dayOfWeekFormatter,
|
|
148
150
|
dayOfWeekFormatter = _props$dayOfWeekForma === void 0 ? defaultDayOfWeekFormatter : _props$dayOfWeekForma,
|
|
149
151
|
hasFocus = props.hasFocus,
|
|
150
152
|
onFocusedViewChange = props.onFocusedViewChange,
|
|
151
153
|
gridLabelId = props.gridLabelId;
|
|
152
|
-
var isDateDisabled =
|
|
154
|
+
var isDateDisabled = useIsDateDisabled({
|
|
153
155
|
shouldDisableDate: shouldDisableDate,
|
|
156
|
+
shouldDisableMonth: shouldDisableMonth,
|
|
157
|
+
shouldDisableYear: shouldDisableYear,
|
|
154
158
|
minDate: minDate,
|
|
155
159
|
maxDate: maxDate,
|
|
156
160
|
disablePast: disablePast,
|
|
@@ -9,7 +9,6 @@ import { PickersFadeTransitionGroup } from './PickersFadeTransitionGroup';
|
|
|
9
9
|
import { ArrowDropDown } from '../internals/components/icons';
|
|
10
10
|
import { PickersArrowSwitcher } from '../internals/components/PickersArrowSwitcher';
|
|
11
11
|
import { usePreviousMonthDisabled, useNextMonthDisabled } from '../internals/hooks/date-helpers-hooks';
|
|
12
|
-
import { buildDeprecatedPropsWarning } from '../internals/utils/warning';
|
|
13
12
|
import { getPickersCalendarHeaderUtilityClass } from './pickersCalendarHeaderClasses';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -97,7 +96,6 @@ var PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDown, {
|
|
|
97
96
|
transform: 'rotate(180deg)'
|
|
98
97
|
});
|
|
99
98
|
});
|
|
100
|
-
var deprecatedPropsWarning = buildDeprecatedPropsWarning('Props for translation are deprecated. See https://mui.com/x/react-date-pickers/localization for more information.');
|
|
101
99
|
/**
|
|
102
100
|
* @ignore - do not document.
|
|
103
101
|
*/
|
|
@@ -115,26 +113,15 @@ export function PickersCalendarHeader(inProps) {
|
|
|
115
113
|
disabled = props.disabled,
|
|
116
114
|
disableFuture = props.disableFuture,
|
|
117
115
|
disablePast = props.disablePast,
|
|
118
|
-
getViewSwitchingButtonTextProp = props.getViewSwitchingButtonText,
|
|
119
|
-
leftArrowButtonTextProp = props.leftArrowButtonText,
|
|
120
116
|
maxDate = props.maxDate,
|
|
121
117
|
minDate = props.minDate,
|
|
122
118
|
onMonthChange = props.onMonthChange,
|
|
123
119
|
onViewChange = props.onViewChange,
|
|
124
120
|
currentView = props.openView,
|
|
125
121
|
reduceAnimations = props.reduceAnimations,
|
|
126
|
-
rightArrowButtonTextProp = props.rightArrowButtonText,
|
|
127
122
|
views = props.views,
|
|
128
123
|
labelId = props.labelId;
|
|
129
|
-
deprecatedPropsWarning({
|
|
130
|
-
leftArrowButtonText: leftArrowButtonTextProp,
|
|
131
|
-
rightArrowButtonText: rightArrowButtonTextProp,
|
|
132
|
-
getViewSwitchingButtonText: getViewSwitchingButtonTextProp
|
|
133
|
-
});
|
|
134
124
|
var localeText = useLocaleText();
|
|
135
|
-
var leftArrowButtonText = leftArrowButtonTextProp != null ? leftArrowButtonTextProp : localeText.previousMonth;
|
|
136
|
-
var rightArrowButtonText = rightArrowButtonTextProp != null ? rightArrowButtonTextProp : localeText.nextMonth;
|
|
137
|
-
var getViewSwitchingButtonText = getViewSwitchingButtonTextProp != null ? getViewSwitchingButtonTextProp : localeText.calendarViewSwitchingButtonAriaLabel;
|
|
138
125
|
var utils = useUtils();
|
|
139
126
|
var classes = useUtilityClasses(props);
|
|
140
127
|
var switchViewButtonProps = componentsProps.switchViewButton || {};
|
|
@@ -200,7 +187,7 @@ export function PickersCalendarHeader(inProps) {
|
|
|
200
187
|
}), views.length > 1 && !disabled && /*#__PURE__*/_jsx(PickersCalendarHeaderSwitchViewButton, _extends({
|
|
201
188
|
size: "small",
|
|
202
189
|
as: components.SwitchViewButton,
|
|
203
|
-
"aria-label":
|
|
190
|
+
"aria-label": localeText.calendarViewSwitchingButtonAriaLabel(currentView),
|
|
204
191
|
className: classes.switchViewButton
|
|
205
192
|
}, switchViewButtonProps, {
|
|
206
193
|
children: /*#__PURE__*/_jsx(PickersCalendarHeaderSwitchViewIcon, {
|
|
@@ -212,14 +199,14 @@ export function PickersCalendarHeader(inProps) {
|
|
|
212
199
|
}), /*#__PURE__*/_jsx(Fade, {
|
|
213
200
|
in: currentView === 'day',
|
|
214
201
|
children: /*#__PURE__*/_jsx(PickersArrowSwitcher, {
|
|
215
|
-
leftArrowButtonText: leftArrowButtonText,
|
|
216
|
-
rightArrowButtonText: rightArrowButtonText,
|
|
217
202
|
components: components,
|
|
218
203
|
componentsProps: componentsProps,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
204
|
+
onGoToPrevious: selectPreviousMonth,
|
|
205
|
+
isPreviousDisabled: isPreviousMonthDisabled,
|
|
206
|
+
previousLabel: localeText.previousMonth,
|
|
207
|
+
onGoToNext: selectNextMonth,
|
|
208
|
+
isNextDisabled: isNextMonthDisabled,
|
|
209
|
+
nextLabel: localeText.nextMonth
|
|
223
210
|
})
|
|
224
211
|
})]
|
|
225
212
|
});
|