@mui/x-date-pickers 5.0.0-beta.6 → 5.0.0-beta.7
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 +56 -0
- package/CalendarPicker/CalendarPicker.d.ts +6 -4
- package/CalendarPicker/CalendarPicker.js +41 -24
- package/CalendarPicker/DayPicker.d.ts +4 -3
- package/CalendarPicker/DayPicker.js +23 -11
- package/CalendarPicker/PickersCalendarHeader.d.ts +1 -0
- package/CalendarPicker/PickersCalendarHeader.js +6 -3
- package/CalendarPicker/PickersSlideTransition.js +1 -0
- package/CalendarPicker/useCalendarState.d.ts +2 -2
- package/ClockPicker/ClockPicker.js +1 -1
- package/DateField/DateField.d.ts +7 -0
- package/DateField/DateField.interfaces.d.ts +9 -0
- package/DateField/DateField.interfaces.js +1 -0
- package/DateField/DateField.js +15 -0
- package/DateField/index.d.ts +3 -0
- package/DateField/index.js +2 -0
- package/DateField/package.json +6 -0
- package/DateField/useDateField.d.ts +2 -0
- package/DateField/useDateField.js +46 -0
- package/DatePicker/DatePickerToolbar.js +4 -2
- package/DatePicker/shared.d.ts +4 -3
- package/DatePicker/shared.js +6 -4
- package/DateTimePicker/DateTimePickerToolbar.js +4 -2
- package/DateTimePicker/shared.d.ts +4 -4
- package/DateTimePicker/shared.js +7 -5
- package/MonthPicker/MonthPicker.d.ts +4 -2
- package/MonthPicker/MonthPicker.js +22 -8
- package/PickersDay/PickersDay.js +4 -3
- package/StaticDatePicker/StaticDatePicker.d.ts +2 -2
- package/StaticDateTimePicker/StaticDateTimePicker.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.js +2 -1
- package/TimePicker/TimePickerToolbar.js +4 -2
- package/TimePicker/shared.d.ts +3 -4
- package/YearPicker/PickersYear.js +9 -4
- package/YearPicker/YearPicker.d.ts +2 -2
- package/YearPicker/YearPicker.js +24 -8
- package/index.js +1 -1
- package/internals/components/KeyboardDateInput.js +4 -2
- package/internals/components/PickerStaticWrapper/PickerStaticWrapper.d.ts +3 -2
- package/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +4 -1
- package/internals/components/PickersPopper.d.ts +3 -2
- package/internals/components/PickersPopper.js +23 -10
- package/internals/components/PickersToolbar.js +4 -6
- package/internals/components/PureDateInput.d.ts +1 -0
- package/internals/components/PureDateInput.js +3 -1
- package/internals/components/wrappers/DesktopTooltipWrapper.js +2 -0
- package/internals/components/wrappers/WrapperProps.d.ts +7 -0
- package/internals/hooks/useField/index.d.ts +3 -0
- package/internals/hooks/useField/index.js +2 -0
- package/internals/hooks/useField/useField.d.ts +2 -0
- package/internals/hooks/useField/useField.interfaces.d.ts +74 -0
- package/internals/hooks/useField/useField.interfaces.js +1 -0
- package/internals/hooks/useField/useField.js +286 -0
- package/internals/hooks/useField/useField.utils.d.ts +16 -0
- package/internals/hooks/useField/useField.utils.js +460 -0
- package/internals/hooks/validation/models.d.ts +3 -3
- package/internals/hooks/validation/useDateTimeValidation.d.ts +4 -2
- package/internals/hooks/validation/useDateValidation.d.ts +4 -4
- package/internals/hooks/validation/useDateValidation.js +6 -10
- package/internals/hooks/validation/useValidation.d.ts +5 -3
- package/internals/index.d.ts +5 -0
- package/internals/index.js +2 -0
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/props/baseToolbarProps.d.ts +8 -1
- package/internals/utils/date-utils.d.ts +1 -0
- package/internals/utils/date-utils.js +14 -0
- package/legacy/CalendarPicker/CalendarPicker.js +43 -33
- package/legacy/CalendarPicker/DayPicker.js +25 -13
- package/legacy/CalendarPicker/PickersCalendarHeader.js +6 -3
- package/legacy/CalendarPicker/PickersSlideTransition.js +1 -0
- package/legacy/ClockPicker/ClockPicker.js +1 -1
- package/legacy/DateField/DateField.interfaces.js +1 -0
- package/legacy/DateField/DateField.js +15 -0
- package/legacy/DateField/index.js +2 -0
- package/legacy/DateField/useDateField.js +56 -0
- package/legacy/DatePicker/DatePickerToolbar.js +4 -3
- package/legacy/DatePicker/shared.js +6 -4
- package/legacy/DateTimePicker/DateTimePickerToolbar.js +4 -3
- package/legacy/DateTimePicker/shared.js +7 -5
- package/legacy/MonthPicker/MonthPicker.js +22 -10
- package/legacy/PickersDay/PickersDay.js +4 -3
- package/legacy/StaticTimePicker/StaticTimePicker.js +2 -1
- package/legacy/TimePicker/TimePickerToolbar.js +4 -3
- package/legacy/YearPicker/PickersYear.js +9 -4
- package/legacy/YearPicker/YearPicker.js +24 -10
- package/legacy/index.js +1 -1
- package/legacy/internals/components/KeyboardDateInput.js +5 -3
- package/legacy/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +4 -1
- package/legacy/internals/components/PickersPopper.js +23 -10
- package/legacy/internals/components/PickersToolbar.js +4 -7
- package/legacy/internals/components/PureDateInput.js +3 -1
- package/legacy/internals/components/wrappers/DesktopTooltipWrapper.js +2 -0
- package/legacy/internals/hooks/useField/index.js +2 -0
- package/legacy/internals/hooks/useField/useField.interfaces.js +1 -0
- package/legacy/internals/hooks/useField/useField.js +307 -0
- package/legacy/internals/hooks/useField/useField.utils.js +471 -0
- package/legacy/internals/hooks/validation/useDateValidation.js +6 -10
- package/legacy/internals/index.js +2 -0
- package/legacy/internals/utils/date-utils.js +14 -0
- package/legacy/locales/deDE.js +6 -0
- package/legacy/locales/enUS.js +8 -0
- package/legacy/locales/esES.js +7 -2
- package/legacy/locales/frFR.js +12 -0
- package/legacy/locales/index.js +2 -0
- package/legacy/locales/itIT.js +7 -2
- package/legacy/locales/koKR.js +55 -0
- package/legacy/locales/nbNO.js +6 -0
- package/legacy/locales/nlNL.js +6 -0
- package/legacy/locales/plPL.js +50 -0
- package/legacy/locales/ptBR.js +6 -0
- package/legacy/locales/svSE.js +6 -0
- package/legacy/locales/trTR.js +7 -2
- package/legacy/locales/zhCN.js +7 -2
- package/locales/deDE.d.ts +5 -0
- package/locales/deDE.js +6 -0
- package/locales/enUS.d.ts +5 -0
- package/locales/enUS.js +6 -0
- package/locales/esES.d.ts +5 -0
- package/locales/esES.js +7 -2
- package/locales/frFR.d.ts +5 -0
- package/locales/frFR.js +10 -0
- package/locales/index.d.ts +2 -0
- package/locales/index.js +2 -0
- package/locales/itIT.d.ts +5 -0
- package/locales/itIT.js +7 -2
- package/locales/koKR.d.ts +35 -0
- package/locales/koKR.js +41 -0
- package/locales/nbNO.d.ts +5 -0
- package/locales/nbNO.js +6 -0
- package/locales/nlNL.d.ts +5 -0
- package/locales/nlNL.js +6 -0
- package/locales/plPL.d.ts +35 -0
- package/locales/plPL.js +36 -0
- package/locales/ptBR.d.ts +5 -0
- package/locales/ptBR.js +6 -0
- package/locales/svSE.d.ts +5 -0
- package/locales/svSE.js +6 -0
- package/locales/trTR.d.ts +5 -0
- package/locales/trTR.js +7 -2
- package/locales/utils/getPickersLocalization.d.ts +5 -0
- package/locales/utils/pickersLocaleTextApi.d.ts +5 -0
- package/locales/zhCN.d.ts +5 -0
- package/locales/zhCN.js +7 -2
- package/modern/CalendarPicker/CalendarPicker.js +41 -24
- package/modern/CalendarPicker/DayPicker.js +23 -11
- package/modern/CalendarPicker/PickersCalendarHeader.js +6 -3
- package/modern/CalendarPicker/PickersSlideTransition.js +1 -0
- package/modern/ClockPicker/ClockPicker.js +1 -1
- package/modern/DateField/DateField.interfaces.js +1 -0
- package/modern/DateField/DateField.js +15 -0
- package/modern/DateField/index.js +2 -0
- package/modern/DateField/useDateField.js +46 -0
- package/modern/DatePicker/DatePickerToolbar.js +4 -2
- package/modern/DatePicker/shared.js +6 -4
- package/modern/DateTimePicker/DateTimePickerToolbar.js +4 -2
- package/modern/DateTimePicker/shared.js +6 -4
- package/modern/MonthPicker/MonthPicker.js +22 -8
- package/modern/PickersDay/PickersDay.js +4 -3
- package/modern/StaticTimePicker/StaticTimePicker.js +2 -1
- package/modern/TimePicker/TimePickerToolbar.js +4 -2
- package/modern/YearPicker/PickersYear.js +9 -4
- package/modern/YearPicker/YearPicker.js +24 -8
- package/modern/index.js +1 -1
- package/modern/internals/components/KeyboardDateInput.js +4 -2
- package/modern/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +4 -1
- package/modern/internals/components/PickersPopper.js +23 -10
- package/modern/internals/components/PickersToolbar.js +4 -6
- package/modern/internals/components/PureDateInput.js +3 -1
- package/modern/internals/components/wrappers/DesktopTooltipWrapper.js +2 -0
- package/modern/internals/hooks/useField/index.js +2 -0
- package/modern/internals/hooks/useField/useField.interfaces.js +1 -0
- package/modern/internals/hooks/useField/useField.js +276 -0
- package/modern/internals/hooks/useField/useField.utils.js +458 -0
- package/modern/internals/hooks/validation/useDateValidation.js +6 -10
- package/modern/internals/index.js +2 -0
- package/modern/internals/utils/date-utils.js +14 -0
- package/modern/locales/deDE.js +6 -0
- package/modern/locales/enUS.js +6 -0
- package/modern/locales/esES.js +7 -2
- package/modern/locales/frFR.js +10 -0
- package/modern/locales/index.js +2 -0
- package/modern/locales/itIT.js +7 -2
- package/modern/locales/koKR.js +41 -0
- package/modern/locales/nbNO.js +6 -0
- package/modern/locales/nlNL.js +6 -0
- package/modern/locales/plPL.js +36 -0
- package/modern/locales/ptBR.js +6 -0
- package/modern/locales/svSE.js +6 -0
- package/modern/locales/trTR.js +7 -2
- package/modern/locales/zhCN.js +7 -2
- package/node/CalendarPicker/CalendarPicker.js +40 -21
- package/node/CalendarPicker/DayPicker.js +23 -11
- package/node/CalendarPicker/PickersCalendarHeader.js +6 -3
- package/node/CalendarPicker/PickersSlideTransition.js +1 -0
- package/node/ClockPicker/ClockPicker.js +1 -1
- package/node/DateField/DateField.interfaces.js +5 -0
- package/node/DateField/DateField.js +34 -0
- package/node/DateField/index.js +21 -0
- package/node/DateField/useDateField.js +63 -0
- package/node/DatePicker/DatePickerToolbar.js +3 -1
- package/node/DatePicker/shared.js +5 -3
- package/node/DateTimePicker/DateTimePickerToolbar.js +3 -1
- package/node/DateTimePicker/shared.js +6 -4
- package/node/MonthPicker/MonthPicker.js +26 -9
- package/node/PickersDay/PickersDay.js +4 -3
- package/node/StaticTimePicker/StaticTimePicker.js +2 -1
- package/node/TimePicker/TimePickerToolbar.js +3 -1
- package/node/YearPicker/PickersYear.js +10 -4
- package/node/YearPicker/YearPicker.js +25 -7
- package/node/index.js +1 -1
- package/node/internals/components/KeyboardDateInput.js +4 -2
- package/node/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +4 -1
- package/node/internals/components/PickersPopper.js +23 -10
- package/node/internals/components/PickersToolbar.js +5 -6
- package/node/internals/components/PureDateInput.js +3 -1
- package/node/internals/components/wrappers/DesktopTooltipWrapper.js +2 -0
- package/node/internals/hooks/useField/index.js +33 -0
- package/node/internals/hooks/useField/useField.interfaces.js +5 -0
- package/node/internals/hooks/useField/useField.js +308 -0
- package/node/internals/hooks/useField/useField.utils.js +501 -0
- package/node/internals/hooks/validation/useDateValidation.js +7 -10
- package/node/internals/index.js +34 -0
- package/node/internals/utils/date-utils.js +19 -2
- package/node/locales/deDE.js +6 -0
- package/node/locales/enUS.js +6 -0
- package/node/locales/esES.js +7 -2
- package/node/locales/frFR.js +10 -0
- package/node/locales/index.js +26 -0
- package/node/locales/itIT.js +7 -2
- package/node/locales/koKR.js +50 -0
- package/node/locales/nbNO.js +6 -0
- package/node/locales/nlNL.js +6 -0
- package/node/locales/plPL.js +45 -0
- package/node/locales/ptBR.js +6 -0
- package/node/locales/svSE.js +6 -0
- package/node/locales/trTR.js +7 -2
- package/node/locales/zhCN.js +7 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,62 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.16.0
|
|
7
|
+
|
|
8
|
+
_Aug 25, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎁 Introduce column grouping for data grid (#5133) @alexfauquette
|
|
13
|
+
|
|
14
|
+
You can now group columns using the `columnGroupingModel` prop. This lets you to display more structured data.
|
|
15
|
+
|
|
16
|
+
<img src="https://user-images.githubusercontent.com/45398769/186178366-4fba66b2-bf90-4c7a-9d83-940a7fc78704.png" width="800" />
|
|
17
|
+
|
|
18
|
+
To enable this feature, add `experimentalFeatures={{ columnGrouping: true }}`.
|
|
19
|
+
The grouping header can be fully customized.
|
|
20
|
+
See the [documentation](https://mui.com/x/react-data-grid/column-groups/) to explore everything it has to offer.
|
|
21
|
+
|
|
22
|
+
- 🐞 Bugfixes
|
|
23
|
+
- 🌏 New locales for pickers thanks to @tesseractjh and @drastus
|
|
24
|
+
|
|
25
|
+
### `@mui/x-data-grid@v5.16.0` / `@mui/x-data-grid-pro@v5.16.0` / `@mui/x-data-grid-premium@v5.16.0`
|
|
26
|
+
|
|
27
|
+
#### Changes
|
|
28
|
+
|
|
29
|
+
- [DataGrid] Implement column grouping (#5133) @alexfauquette
|
|
30
|
+
- [DataGrid] Handle `disableVirtualization` prop change (#5889) @cherniavskii
|
|
31
|
+
- [DataGrid] Improve `GridRowModel` typing (#5734) @cherniavskii
|
|
32
|
+
- [DataGrid] Update deprecation note for `GridColDef` `hide` property (#5886) @cherniavskii
|
|
33
|
+
|
|
34
|
+
### `@mui/x-date-pickers@v5.0.0-beta.7` / `@mui/x-date-pickers-pro@v5.0.0-beta.7`
|
|
35
|
+
|
|
36
|
+
#### Changes
|
|
37
|
+
|
|
38
|
+
- [DatePicker] Fix to pass down `className` prop provided on DatePicker to `renderInput` (#5471) @CruseCtrl
|
|
39
|
+
- [DatePicker] Improve `a11y` support (#5809) @LukasTy
|
|
40
|
+
- [pickers] Add `PaperContent` component slot (#5801) @LukasTy
|
|
41
|
+
- [pickers] Add a breaking change section in the migration guide (#5805) @alexfauquette
|
|
42
|
+
- [pickers] Add new translations to `localeText` (#5143) @alexfauquette
|
|
43
|
+
- [pickers] Document components slots (#4657) @flaviendelangle
|
|
44
|
+
- [pickers] Add new unstable field components (#5504) @flaviendelangle
|
|
45
|
+
- [pickers] Fallback to default `minDate` / `maxDate` when `null` value is passed (#5397) @flaviendelangle
|
|
46
|
+
- [l10n] Add Korean (ko-KR) locale (#5854) @tesseractjh
|
|
47
|
+
- [l10n] Add Polish (pl-PL) locale (#5833) @drastus
|
|
48
|
+
|
|
49
|
+
### Docs
|
|
50
|
+
|
|
51
|
+
- [docs] Fix typo in `migration from lab` (#5277) @chuckwired
|
|
52
|
+
- [docs] Use `dayjs` instead of `date-fns` in doc examples (#5481) @flaviendelangle
|
|
53
|
+
|
|
54
|
+
### Core
|
|
55
|
+
|
|
56
|
+
- [core] Clarify the scope of the license key used for tests and documentation (#5824) @oliviertassinari
|
|
57
|
+
- [core] Fix Typescript error on field hooks (#5892) @flaviendelangle
|
|
58
|
+
- [core] Memoize `columns` in `useDemoData` hook (#5848) @cherniavskii
|
|
59
|
+
- [core] Remove Firefox from the BrowserStack list (#5874) @DanailH
|
|
60
|
+
- [core] Small changes to the release script (#5840) @m4theushw
|
|
61
|
+
|
|
6
62
|
## 5.15.3
|
|
7
63
|
|
|
8
64
|
_Aug 18, 2022_
|
|
@@ -4,12 +4,13 @@ import { PickerOnChangeFn } from '../internals/hooks/useViews';
|
|
|
4
4
|
import { ExportedCalendarHeaderProps, PickersCalendarHeaderSlotsComponent, PickersCalendarHeaderSlotsComponentsProps } from './PickersCalendarHeader';
|
|
5
5
|
import { CalendarPickerView } from '../internals/models';
|
|
6
6
|
import { CalendarPickerClasses } from './calendarPickerClasses';
|
|
7
|
-
import { MonthValidationProps, YearValidationProps } from '../internals/hooks/validation/models';
|
|
7
|
+
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../internals/hooks/validation/models';
|
|
8
|
+
import { DefaultizedProps } from '../internals/models/helpers';
|
|
8
9
|
export interface CalendarPickerSlotsComponent extends PickersCalendarHeaderSlotsComponent {
|
|
9
10
|
}
|
|
10
11
|
export interface CalendarPickerSlotsComponentsProps extends PickersCalendarHeaderSlotsComponentsProps {
|
|
11
12
|
}
|
|
12
|
-
export interface CalendarPickerProps<TDate> extends ExportedDayPickerProps<TDate>, YearValidationProps<TDate>, MonthValidationProps<TDate>, ExportedCalendarHeaderProps<TDate> {
|
|
13
|
+
export interface CalendarPickerProps<TDate> extends ExportedDayPickerProps<TDate>, BaseDateValidationProps<TDate>, DayValidationProps<TDate>, YearValidationProps<TDate>, MonthValidationProps<TDate>, ExportedCalendarHeaderProps<TDate> {
|
|
13
14
|
className?: string;
|
|
14
15
|
classes?: Partial<CalendarPickerClasses>;
|
|
15
16
|
/**
|
|
@@ -86,6 +87,7 @@ export interface CalendarPickerProps<TDate> extends ExportedDayPickerProps<TDate
|
|
|
86
87
|
onMonthChange?: (month: TDate) => void | Promise<void>;
|
|
87
88
|
}
|
|
88
89
|
export declare type ExportedCalendarPickerProps<TDate> = Omit<CalendarPickerProps<TDate>, 'date' | 'view' | 'views' | 'openTo' | 'onChange' | 'changeView' | 'slideDirection' | 'currentMonth' | 'className' | 'classes' | 'components' | 'componentsProps'>;
|
|
90
|
+
export declare type CalendarPickerDefaultizedProps<TDate> = DefaultizedProps<CalendarPickerProps<TDate>, 'views' | 'openTo' | 'loading' | 'reduceAnimations' | 'renderLoading' | keyof BaseDateValidationProps<TDate>>;
|
|
89
91
|
declare type CalendarPickerComponent = (<TDate>(props: CalendarPickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => JSX.Element) & {
|
|
90
92
|
propTypes?: any;
|
|
91
93
|
};
|
|
@@ -99,5 +101,5 @@ declare type CalendarPickerComponent = (<TDate>(props: CalendarPickerProps<TDate
|
|
|
99
101
|
*
|
|
100
102
|
* - [CalendarPicker API](https://mui.com/x/api/date-pickers/calendar-picker/)
|
|
101
103
|
*/
|
|
102
|
-
declare const CalendarPicker: CalendarPickerComponent;
|
|
103
|
-
export {
|
|
104
|
+
export declare const CalendarPicker: CalendarPickerComponent;
|
|
105
|
+
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["autoFocus", "onViewChange", "date", "disableFuture", "disablePast", "defaultCalendarMonth", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
8
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
9
|
+
import { unstable_useId as useId } from '@mui/material/utils';
|
|
9
10
|
import { MonthPicker } from '../MonthPicker/MonthPicker';
|
|
10
11
|
import { useCalendarState } from './useCalendarState';
|
|
11
12
|
import { useDefaultDates, useUtils } from '../internals/hooks/useUtils';
|
|
@@ -14,7 +15,7 @@ import { DayPicker } from './DayPicker';
|
|
|
14
15
|
import { useViews } from '../internals/hooks/useViews';
|
|
15
16
|
import { PickersCalendarHeader } from './PickersCalendarHeader';
|
|
16
17
|
import { YearPicker } from '../YearPicker/YearPicker';
|
|
17
|
-
import { findClosestEnabledDate } from '../internals/utils/date-utils';
|
|
18
|
+
import { findClosestEnabledDate, parseNonNullablePickerDate } from '../internals/utils/date-utils';
|
|
18
19
|
import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
19
20
|
import { defaultReduceAnimations } from '../internals/utils/defaultReduceAnimations';
|
|
20
21
|
import { getCalendarPickerUtilityClass } from './calendarPickerClasses';
|
|
@@ -32,6 +33,29 @@ const useUtilityClasses = ownerState => {
|
|
|
32
33
|
return composeClasses(slots, getCalendarPickerUtilityClass, classes);
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
function useCalendarPickerDefaultizedProps(props, name) {
|
|
37
|
+
const utils = useUtils();
|
|
38
|
+
const defaultDates = useDefaultDates();
|
|
39
|
+
const themeProps = useThemeProps({
|
|
40
|
+
props,
|
|
41
|
+
name
|
|
42
|
+
});
|
|
43
|
+
return _extends({
|
|
44
|
+
loading: false,
|
|
45
|
+
disablePast: false,
|
|
46
|
+
disableFuture: false,
|
|
47
|
+
openTo: 'day',
|
|
48
|
+
views: ['year', 'day'],
|
|
49
|
+
reduceAnimations: defaultReduceAnimations,
|
|
50
|
+
renderLoading: () => /*#__PURE__*/_jsx("span", {
|
|
51
|
+
children: "..."
|
|
52
|
+
})
|
|
53
|
+
}, themeProps, {
|
|
54
|
+
minDate: parseNonNullablePickerDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
55
|
+
maxDate: parseNonNullablePickerDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
35
59
|
const CalendarPickerRoot = styled(PickerViewRoot, {
|
|
36
60
|
name: 'MuiCalendarPicker',
|
|
37
61
|
slot: 'Root',
|
|
@@ -58,13 +82,10 @@ const CalendarPickerViewTransitionContainer = styled(PickersFadeTransitionGroup,
|
|
|
58
82
|
*
|
|
59
83
|
* - [CalendarPicker API](https://mui.com/x/api/date-pickers/calendar-picker/)
|
|
60
84
|
*/
|
|
61
|
-
const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inProps, ref) {
|
|
85
|
+
export const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inProps, ref) {
|
|
62
86
|
const utils = useUtils();
|
|
63
|
-
const
|
|
64
|
-
const props =
|
|
65
|
-
props: inProps,
|
|
66
|
-
name: 'MuiCalendarPicker'
|
|
67
|
-
});
|
|
87
|
+
const id = useId();
|
|
88
|
+
const props = useCalendarPickerDefaultizedProps(inProps, 'MuiCalendarPicker');
|
|
68
89
|
|
|
69
90
|
const {
|
|
70
91
|
autoFocus,
|
|
@@ -73,25 +94,21 @@ const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inP
|
|
|
73
94
|
disableFuture,
|
|
74
95
|
disablePast,
|
|
75
96
|
defaultCalendarMonth,
|
|
76
|
-
loading = false,
|
|
77
97
|
onChange,
|
|
78
98
|
onYearChange,
|
|
79
99
|
onMonthChange,
|
|
80
|
-
reduceAnimations
|
|
81
|
-
renderLoading = () => /*#__PURE__*/_jsx("span", {
|
|
82
|
-
children: "..."
|
|
83
|
-
}),
|
|
100
|
+
reduceAnimations,
|
|
84
101
|
shouldDisableDate,
|
|
85
102
|
shouldDisableMonth,
|
|
86
103
|
shouldDisableYear,
|
|
87
104
|
view,
|
|
88
|
-
views
|
|
89
|
-
openTo
|
|
105
|
+
views,
|
|
106
|
+
openTo,
|
|
90
107
|
className,
|
|
91
108
|
disabled,
|
|
92
109
|
readOnly,
|
|
93
|
-
minDate
|
|
94
|
-
maxDate
|
|
110
|
+
minDate,
|
|
111
|
+
maxDate,
|
|
95
112
|
disableHighlightToday
|
|
96
113
|
} = props,
|
|
97
114
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
@@ -220,6 +237,7 @@ const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inP
|
|
|
220
237
|
readOnly,
|
|
221
238
|
disabled
|
|
222
239
|
};
|
|
240
|
+
const gridLabelId = `${id}-grid-label`;
|
|
223
241
|
return /*#__PURE__*/_jsxs(CalendarPickerRoot, {
|
|
224
242
|
ref: ref,
|
|
225
243
|
className: clsx(classes.root, className),
|
|
@@ -238,7 +256,8 @@ const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inP
|
|
|
238
256
|
disabled: disabled,
|
|
239
257
|
disablePast: disablePast,
|
|
240
258
|
disableFuture: disableFuture,
|
|
241
|
-
reduceAnimations: reduceAnimations
|
|
259
|
+
reduceAnimations: reduceAnimations,
|
|
260
|
+
labelId: gridLabelId
|
|
242
261
|
})), /*#__PURE__*/_jsx(CalendarPickerViewTransitionContainer, {
|
|
243
262
|
reduceAnimations: reduceAnimations,
|
|
244
263
|
className: classes.viewTransitionContainer,
|
|
@@ -262,9 +281,8 @@ const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inP
|
|
|
262
281
|
reduceAnimations: reduceAnimations,
|
|
263
282
|
selectedDays: [date],
|
|
264
283
|
onSelectedDaysChange: onSelectedDayChange,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
shouldDisableDate: shouldDisableDate
|
|
284
|
+
shouldDisableDate: shouldDisableDate,
|
|
285
|
+
gridLabelId: gridLabelId
|
|
268
286
|
}))]
|
|
269
287
|
})
|
|
270
288
|
})]
|
|
@@ -469,5 +487,4 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
|
|
|
469
487
|
* @default ['year', 'day']
|
|
470
488
|
*/
|
|
471
489
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired)
|
|
472
|
-
} : void 0;
|
|
473
|
-
export { CalendarPicker };
|
|
490
|
+
} : void 0;
|
|
@@ -2,8 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import { PickersDayProps } from '../PickersDay/PickersDay';
|
|
3
3
|
import { PickerOnChangeFn } from '../internals/hooks/useViews';
|
|
4
4
|
import { SlideDirection, SlideTransitionProps } from './PickersSlideTransition';
|
|
5
|
-
import { DayValidationProps } from '../internals/hooks/validation/models';
|
|
6
|
-
export interface ExportedDayPickerProps<TDate> extends
|
|
5
|
+
import { BaseDateValidationProps, DayValidationProps } from '../internals/hooks/validation/models';
|
|
6
|
+
export interface ExportedDayPickerProps<TDate> extends Pick<PickersDayProps<TDate>, 'disableHighlightToday' | 'showDaysOutsideCurrentMonth'> {
|
|
7
7
|
autoFocus?: boolean;
|
|
8
8
|
/**
|
|
9
9
|
* If `true` renders `LoadingComponent` in calendar instead of calendar view.
|
|
@@ -34,7 +34,7 @@ export interface ExportedDayPickerProps<TDate> extends DayValidationProps<TDate>
|
|
|
34
34
|
*/
|
|
35
35
|
dayOfWeekFormatter?: (day: string) => string;
|
|
36
36
|
}
|
|
37
|
-
export interface DayPickerProps<TDate> extends ExportedDayPickerProps<TDate
|
|
37
|
+
export interface DayPickerProps<TDate> extends ExportedDayPickerProps<TDate>, DayValidationProps<TDate>, Required<BaseDateValidationProps<TDate>> {
|
|
38
38
|
autoFocus?: boolean;
|
|
39
39
|
className?: string;
|
|
40
40
|
currentMonth: TDate;
|
|
@@ -49,6 +49,7 @@ export interface DayPickerProps<TDate> extends ExportedDayPickerProps<TDate> {
|
|
|
49
49
|
reduceAnimations: boolean;
|
|
50
50
|
slideDirection: SlideDirection;
|
|
51
51
|
TransitionProps?: Partial<SlideTransitionProps>;
|
|
52
|
+
gridLabelId?: string;
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* @ignore - do not document.
|
|
@@ -81,7 +81,8 @@ export function DayPicker(props) {
|
|
|
81
81
|
minDate,
|
|
82
82
|
maxDate,
|
|
83
83
|
shouldDisableDate,
|
|
84
|
-
dayOfWeekFormatter = defaultDayOfWeekFormatter
|
|
84
|
+
dayOfWeekFormatter = defaultDayOfWeekFormatter,
|
|
85
|
+
gridLabelId
|
|
85
86
|
} = props;
|
|
86
87
|
const isDateDisabled = useIsDayDisabled({
|
|
87
88
|
shouldDisableDate,
|
|
@@ -103,14 +104,19 @@ export function DayPicker(props) {
|
|
|
103
104
|
const transitionKey = currentMonthNumber; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
105
|
|
|
105
106
|
const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
|
|
106
|
-
|
|
107
|
+
const startOfCurrentWeek = utils.startOfWeek(now);
|
|
108
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
109
|
+
role: "grid",
|
|
110
|
+
"aria-labelledby": gridLabelId,
|
|
107
111
|
children: [/*#__PURE__*/_jsx(PickersCalendarDayHeader, {
|
|
112
|
+
role: "row",
|
|
108
113
|
children: utils.getWeekdays().map((day, i) => {
|
|
109
114
|
var _dayOfWeekFormatter;
|
|
110
115
|
|
|
111
116
|
return /*#__PURE__*/_jsx(PickersCalendarWeekDayLabel, {
|
|
112
|
-
"aria-hidden": true,
|
|
113
117
|
variant: "caption",
|
|
118
|
+
role: "columnheader",
|
|
119
|
+
"aria-label": utils.format(utils.addDays(startOfCurrentWeek, i), 'weekday'),
|
|
114
120
|
children: (_dayOfWeekFormatter = dayOfWeekFormatter == null ? void 0 : dayOfWeekFormatter(day)) != null ? _dayOfWeekFormatter : day
|
|
115
121
|
}, day + i.toString());
|
|
116
122
|
})
|
|
@@ -126,28 +132,34 @@ export function DayPicker(props) {
|
|
|
126
132
|
nodeRef: slideNodeRef,
|
|
127
133
|
children: /*#__PURE__*/_jsx(PickersCalendarWeekContainer, {
|
|
128
134
|
ref: slideNodeRef,
|
|
129
|
-
role: "
|
|
135
|
+
role: "rowgroup",
|
|
130
136
|
children: utils.getWeekArray(currentMonth).map(week => /*#__PURE__*/_jsx(PickersCalendarWeek, {
|
|
131
137
|
role: "row",
|
|
132
138
|
children: week.map(day => {
|
|
139
|
+
const isSelected = validSelectedDays.some(selectedDay => utils.isSameDay(selectedDay, day));
|
|
140
|
+
const isToday = utils.isSameDay(day, now);
|
|
133
141
|
const pickersDayProps = {
|
|
134
142
|
key: day == null ? void 0 : day.toString(),
|
|
135
143
|
day,
|
|
136
144
|
isAnimating: isMonthSwitchingAnimating,
|
|
137
145
|
disabled: disabled || isDateDisabled(day),
|
|
138
146
|
autoFocus: autoFocus && focusedDay !== null && utils.isSameDay(day, focusedDay),
|
|
139
|
-
today:
|
|
147
|
+
today: isToday,
|
|
140
148
|
outsideCurrentMonth: utils.getMonth(day) !== currentMonthNumber,
|
|
141
|
-
selected:
|
|
149
|
+
selected: isSelected,
|
|
142
150
|
disableHighlightToday,
|
|
143
151
|
showDaysOutsideCurrentMonth,
|
|
144
152
|
onDayFocus: onFocusedDayChange,
|
|
145
|
-
onDaySelect: handleDaySelect
|
|
153
|
+
onDaySelect: handleDaySelect,
|
|
154
|
+
role: 'gridcell',
|
|
155
|
+
'aria-selected': isSelected
|
|
146
156
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
157
|
+
|
|
158
|
+
if (isToday) {
|
|
159
|
+
pickersDayProps['aria-current'] = 'date';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return renderDay ? renderDay(day, validSelectedDays, pickersDayProps) : /*#__PURE__*/_jsx(PickersDay, _extends({}, pickersDayProps), pickersDayProps.key);
|
|
151
163
|
})
|
|
152
164
|
}, `week-${week[0]}`))
|
|
153
165
|
})
|
|
@@ -39,6 +39,7 @@ export interface PickersCalendarHeaderProps<TDate> extends ExportedArrowSwitcher
|
|
|
39
39
|
openView: CalendarPickerView;
|
|
40
40
|
reduceAnimations: boolean;
|
|
41
41
|
onViewChange?: (view: CalendarPickerView) => void;
|
|
42
|
+
labelId?: string;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* @ignore - do not document.
|
|
@@ -72,7 +72,8 @@ export function PickersCalendarHeader(props) {
|
|
|
72
72
|
openView: currentView,
|
|
73
73
|
reduceAnimations,
|
|
74
74
|
rightArrowButtonText: rightArrowButtonTextProp,
|
|
75
|
-
views
|
|
75
|
+
views,
|
|
76
|
+
labelId
|
|
76
77
|
} = props;
|
|
77
78
|
deprecatedPropsWarning({
|
|
78
79
|
leftArrowButtonText: leftArrowButtonTextProp,
|
|
@@ -124,12 +125,14 @@ export function PickersCalendarHeader(props) {
|
|
|
124
125
|
children: [/*#__PURE__*/_jsxs(PickersCalendarHeaderLabel, {
|
|
125
126
|
role: "presentation",
|
|
126
127
|
onClick: handleToggleView,
|
|
127
|
-
ownerState: ownerState
|
|
128
|
+
ownerState: ownerState // putting this on the label item element below breaks when using transition
|
|
129
|
+
,
|
|
130
|
+
"aria-live": "polite",
|
|
128
131
|
children: [/*#__PURE__*/_jsx(PickersFadeTransitionGroup, {
|
|
129
132
|
reduceAnimations: reduceAnimations,
|
|
130
133
|
transKey: utils.format(month, 'monthAndYear'),
|
|
131
134
|
children: /*#__PURE__*/_jsx(PickersCalendarHeaderLabelItem, {
|
|
132
|
-
|
|
135
|
+
id: labelId,
|
|
133
136
|
ownerState: ownerState,
|
|
134
137
|
children: utils.format(month, 'monthAndYear')
|
|
135
138
|
})
|
|
@@ -89,6 +89,7 @@ export const PickersSlideTransition = _ref => {
|
|
|
89
89
|
childFactory: element => /*#__PURE__*/React.cloneElement(element, {
|
|
90
90
|
classNames: transitionClasses
|
|
91
91
|
}),
|
|
92
|
+
role: "presentation",
|
|
92
93
|
children: /*#__PURE__*/_jsx(CSSTransition, _extends({
|
|
93
94
|
mountOnEnter: true,
|
|
94
95
|
unmountOnExit: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SlideDirection } from './PickersSlideTransition';
|
|
2
2
|
import { MuiPickersAdapter } from '../internals/models';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CalendarPickerDefaultizedProps } from './CalendarPicker';
|
|
4
4
|
interface CalendarState<TDate> {
|
|
5
5
|
currentMonth: TDate;
|
|
6
6
|
focusedDay: TDate | null;
|
|
@@ -19,7 +19,7 @@ export declare const createCalendarStateReducer: <TDate extends unknown>(reduceA
|
|
|
19
19
|
} | ReducerAction<"changeMonth", ChangeMonthPayload<TDate>> | ReducerAction<"changeFocusedDay", {
|
|
20
20
|
focusedDay: TDate | null;
|
|
21
21
|
}>) => CalendarState<TDate>;
|
|
22
|
-
interface CalendarStateInput<TDate> extends Pick<
|
|
22
|
+
interface CalendarStateInput<TDate> extends Pick<CalendarPickerDefaultizedProps<TDate>, 'date' | 'defaultCalendarMonth' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | 'onMonthChange' | 'reduceAnimations' | 'shouldDisableDate'> {
|
|
23
23
|
disableSwitchToMonthOnDayFocus?: boolean;
|
|
24
24
|
}
|
|
25
25
|
export declare const useCalendarState: <TDate extends unknown>({ date, defaultCalendarMonth, disableFuture, disablePast, disableSwitchToMonthOnDayFocus, maxDate, minDate, onMonthChange, reduceAnimations, shouldDisableDate, }: CalendarStateInput<TDate>) => {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { unstable_useId as useId } from '@mui/utils';
|
|
5
|
+
import { unstable_useId as useId } from '@mui/material/utils';
|
|
6
6
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
8
8
|
import { Clock } from './Clock';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DateFieldProps } from './DateField.interfaces';
|
|
3
|
+
declare type DateFieldComponent = (<TInputDate, TDate = TInputDate>(props: DateFieldProps<TInputDate, TDate> & React.RefAttributes<HTMLInputElement>) => JSX.Element) & {
|
|
4
|
+
propTypes?: any;
|
|
5
|
+
};
|
|
6
|
+
export declare const DateField: DateFieldComponent;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
import { UseFieldProps } from '../internals/hooks/useField';
|
|
3
|
+
import { DateValidationError, DateValidationProps } from '../internals/hooks/validation/useDateValidation';
|
|
4
|
+
import { DefaultizedProps } from '../internals/models/helpers';
|
|
5
|
+
export interface UseDateFieldProps<TInputDate, TDate> extends UseFieldProps<TInputDate | null, TDate | null, DateValidationError>, Partial<Omit<DateValidationProps<TInputDate, TDate>, 'value'>> {
|
|
6
|
+
}
|
|
7
|
+
export declare type UseDateFieldDefaultizedProps<TInputDate, TDate> = DefaultizedProps<UseDateFieldProps<TInputDate, TDate>, 'minDate' | 'maxDate' | 'disableFuture' | 'disablePast'>;
|
|
8
|
+
export interface DateFieldProps<TInputDate, TDate> extends Omit<TextFieldProps, 'value' | 'defaultValue' | 'onChange' | 'onError'>, UseDateFieldProps<TInputDate, TDate> {
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import TextField from '@mui/material/TextField';
|
|
4
|
+
import { useDateField } from './useDateField';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref) {
|
|
7
|
+
const {
|
|
8
|
+
inputRef,
|
|
9
|
+
inputProps
|
|
10
|
+
} = useDateField(inProps);
|
|
11
|
+
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
12
|
+
ref: ref,
|
|
13
|
+
inputRef: inputRef
|
|
14
|
+
}, inputProps));
|
|
15
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { UseDateFieldProps } from './DateField.interfaces';
|
|
2
|
+
export declare const useDateField: <TInputDate, TDate, TProps extends UseDateFieldProps<TInputDate, TDate>>(inProps: TProps) => import("../internals/hooks/useField").UseFieldResponse<TProps & Omit<UseDateFieldProps<TInputDate, TDate>, "minDate" | "maxDate" | "disableFuture" | "disablePast"> & Required<Pick<UseDateFieldProps<TInputDate, TDate>, "minDate" | "maxDate" | "disableFuture" | "disablePast">>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { datePickerValueManager } from '../DatePicker/shared';
|
|
3
|
+
import { useField, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections } from '../internals/hooks/useField';
|
|
4
|
+
import { validateDate } from '../internals/hooks/validation/useDateValidation';
|
|
5
|
+
import { parseNonNullablePickerDate } from '../internals/utils/date-utils';
|
|
6
|
+
import { useUtils, useDefaultDates } from '../internals/hooks/useUtils';
|
|
7
|
+
const dateRangeFieldValueManager = {
|
|
8
|
+
getSectionsFromValue: (utils, prevSections, date, format) => addPositionPropertiesToSections(splitFormatIntoSections(utils, format, date)),
|
|
9
|
+
getValueStrFromSections: sections => createDateStrFromSections(sections),
|
|
10
|
+
getValueFromSections: (utils, prevSections, sections, format) => {
|
|
11
|
+
const dateStr = createDateStrFromSections(sections);
|
|
12
|
+
const value = utils.parse(dateStr, format);
|
|
13
|
+
return {
|
|
14
|
+
value,
|
|
15
|
+
shouldPublish: utils.isValid(value)
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
getActiveDateFromActiveSection: value => ({
|
|
19
|
+
value,
|
|
20
|
+
update: newActiveDate => newActiveDate
|
|
21
|
+
}),
|
|
22
|
+
hasError: error => error != null
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const useDefaultizedDateField = props => {
|
|
26
|
+
const utils = useUtils();
|
|
27
|
+
const defaultDates = useDefaultDates();
|
|
28
|
+
return _extends({
|
|
29
|
+
disablePast: false,
|
|
30
|
+
disableFuture: false
|
|
31
|
+
}, props, {
|
|
32
|
+
minDate: parseNonNullablePickerDate(utils, props.minDate, defaultDates.minDate),
|
|
33
|
+
maxDate: parseNonNullablePickerDate(utils, props.maxDate, defaultDates.maxDate)
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const useDateField = inProps => {
|
|
38
|
+
const props = useDefaultizedDateField(inProps);
|
|
39
|
+
return useField({
|
|
40
|
+
props,
|
|
41
|
+
valueManager: datePickerValueManager,
|
|
42
|
+
fieldValueManager: dateRangeFieldValueManager,
|
|
43
|
+
// TODO: Support time validation.
|
|
44
|
+
validator: validateDate
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -6,7 +6,7 @@ import Typography from '@mui/material/Typography';
|
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
7
|
import { generateUtilityClasses } from '@mui/material';
|
|
8
8
|
import { PickersToolbar, pickersToolbarClasses } from '../internals/components/PickersToolbar';
|
|
9
|
-
import { useUtils } from '../internals/hooks/useUtils';
|
|
9
|
+
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
|
|
10
10
|
import { isYearAndMonthViews, isYearOnlyView } from './shared';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
export const datePickerToolbarClasses = generateUtilityClasses('MuiDatePickerToolbar', ['root', 'title']);
|
|
@@ -41,12 +41,14 @@ export const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePick
|
|
|
41
41
|
toggleMobileKeyboardView,
|
|
42
42
|
toolbarFormat,
|
|
43
43
|
toolbarPlaceholder = '––',
|
|
44
|
-
toolbarTitle
|
|
44
|
+
toolbarTitle: toolbarTitleProp,
|
|
45
45
|
views
|
|
46
46
|
} = props,
|
|
47
47
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
48
48
|
|
|
49
49
|
const utils = useUtils();
|
|
50
|
+
const localeText = useLocaleText();
|
|
51
|
+
const toolbarTitle = toolbarTitleProp != null ? toolbarTitleProp : localeText.datePickerDefaultToolbarTitle;
|
|
50
52
|
const dateText = React.useMemo(() => {
|
|
51
53
|
if (!parsedValue) {
|
|
52
54
|
return toolbarPlaceholder;
|
package/DatePicker/shared.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { ExportedDateInputProps } from '../internals/components/PureDateInput';
|
|
|
7
7
|
import { BasePickerProps } from '../internals/models/props/basePickerProps';
|
|
8
8
|
import { PickerStateValueManager } from '../internals/hooks/usePickerState';
|
|
9
9
|
import { BaseToolbarProps } from '../internals/models/props/baseToolbarProps';
|
|
10
|
+
import { DefaultizedProps } from '../internals/models/helpers';
|
|
11
|
+
import { BaseDateValidationProps } from '../internals/hooks/validation/models';
|
|
10
12
|
export interface BaseDatePickerProps<TInputDate, TDate> extends ExportedCalendarPickerProps<TDate>, BasePickerProps<TInputDate | null, TDate | null>, ValidationProps<DateValidationError, TInputDate | null>, ExportedDateInputProps<TInputDate, TDate> {
|
|
11
13
|
/**
|
|
12
14
|
* Callback fired on view change.
|
|
@@ -43,8 +45,7 @@ export interface BaseDatePickerProps<TInputDate, TDate> extends ExportedCalendar
|
|
|
43
45
|
}
|
|
44
46
|
export declare const isYearOnlyView: (views: readonly CalendarPickerView[]) => views is readonly "year"[];
|
|
45
47
|
export declare const isYearAndMonthViews: (views: readonly CalendarPickerView[]) => views is readonly ("month" | "year")[];
|
|
46
|
-
export declare
|
|
48
|
+
export declare function useDatePickerDefaultizedProps<TInputDate, TDate, Props extends BaseDatePickerProps<TInputDate, TDate>>(props: Props, name: string): DefaultizedProps<Props, 'openTo' | 'views' | keyof BaseDateValidationProps<TDate>, {
|
|
47
49
|
inputFormat: string;
|
|
48
|
-
}
|
|
49
|
-
export declare function useDatePickerDefaultizedProps<TInputDate, TDate, Props extends BaseDatePickerProps<TInputDate, TDate>>(props: Props, name: string): DefaultizedProps<Props> & Required<Pick<BaseDatePickerProps<TInputDate, TDate>, 'openTo' | 'views'>>;
|
|
50
|
+
}>;
|
|
50
51
|
export declare const datePickerValueManager: PickerStateValueManager<any, any, any>;
|
package/DatePicker/shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { useThemeProps } from '@mui/material/styles';
|
|
3
3
|
import { useDefaultDates, useUtils } from '../internals/hooks/useUtils';
|
|
4
|
-
import { parsePickerInputValue } from '../internals/utils/date-utils';
|
|
4
|
+
import { parsePickerInputValue, parseNonNullablePickerDate } from '../internals/utils/date-utils';
|
|
5
5
|
export const isYearOnlyView = views => views.length === 1 && views[0] === 'year';
|
|
6
6
|
export const isYearAndMonthViews = views => views.length === 2 && views.indexOf('month') !== -1 && views.indexOf('year') !== -1;
|
|
7
7
|
|
|
@@ -38,10 +38,12 @@ export function useDatePickerDefaultizedProps(props, name) {
|
|
|
38
38
|
const views = (_themeProps$views = themeProps.views) != null ? _themeProps$views : ['year', 'day'];
|
|
39
39
|
return _extends({
|
|
40
40
|
openTo: 'day',
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
disableFuture: false,
|
|
42
|
+
disablePast: false
|
|
43
43
|
}, getFormatAndMaskByViews(views, utils), themeProps, {
|
|
44
|
-
views
|
|
44
|
+
views,
|
|
45
|
+
minDate: parseNonNullablePickerDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
46
|
+
maxDate: parseNonNullablePickerDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
export const datePickerValueManager = {
|
|
@@ -8,7 +8,7 @@ import { PickersToolbarText } from '../internals/components/PickersToolbarText';
|
|
|
8
8
|
import { PickersToolbar, pickersToolbarClasses } from '../internals/components/PickersToolbar';
|
|
9
9
|
import { PickersToolbarButton } from '../internals/components/PickersToolbarButton';
|
|
10
10
|
import { DateTimePickerTabs } from './DateTimePickerTabs';
|
|
11
|
-
import { useUtils } from '../internals/hooks/useUtils';
|
|
11
|
+
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
|
|
12
12
|
import { WrapperVariantContext } from '../internals/components/wrappers/WrapperVariantContext';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -68,12 +68,14 @@ export const DateTimePickerToolbar = props => {
|
|
|
68
68
|
toggleMobileKeyboardView,
|
|
69
69
|
toolbarFormat,
|
|
70
70
|
toolbarPlaceholder = '––',
|
|
71
|
-
toolbarTitle
|
|
71
|
+
toolbarTitle: toolbarTitleProp,
|
|
72
72
|
views
|
|
73
73
|
} = props,
|
|
74
74
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
75
75
|
|
|
76
76
|
const utils = useUtils();
|
|
77
|
+
const localeText = useLocaleText();
|
|
78
|
+
const toolbarTitle = toolbarTitleProp != null ? toolbarTitleProp : localeText.dateTimePickerDefaultToolbarTitle;
|
|
77
79
|
const wrapperVariant = React.useContext(WrapperVariantContext);
|
|
78
80
|
const showTabs = wrapperVariant === 'desktop' ? true : !hideTabs && typeof window !== 'undefined' && window.innerHeight > 667;
|
|
79
81
|
|
|
@@ -8,6 +8,8 @@ import { ExportedDateInputProps } from '../internals/components/PureDateInput';
|
|
|
8
8
|
import { CalendarOrClockPickerView } from '../internals/models';
|
|
9
9
|
import { PickerStateValueManager } from '../internals/hooks/usePickerState';
|
|
10
10
|
import { BaseToolbarProps } from '../internals/models/props/baseToolbarProps';
|
|
11
|
+
import { DefaultizedProps } from '../internals/models/helpers';
|
|
12
|
+
import { BaseDateValidationProps } from '../internals/hooks/validation/models';
|
|
11
13
|
export interface BaseDateTimePickerProps<TInputDate, TDate> extends ExportedClockPickerProps<TDate>, ExportedCalendarPickerProps<TDate>, BasePickerProps<TInputDate | null, TDate | null>, ValidationProps<DateTimeValidationError, TInputDate | null>, ExportedDateInputProps<TInputDate, TDate> {
|
|
12
14
|
/**
|
|
13
15
|
* 12h/24h view for hour selection clock.
|
|
@@ -67,9 +69,7 @@ export interface BaseDateTimePickerProps<TInputDate, TDate> extends ExportedCloc
|
|
|
67
69
|
*/
|
|
68
70
|
views?: readonly CalendarOrClockPickerView[];
|
|
69
71
|
}
|
|
70
|
-
declare
|
|
72
|
+
export declare function useDateTimePickerDefaultizedProps<TInputDate, TDate, Props extends BaseDateTimePickerProps<TInputDate, TDate>>(props: Props, name: string): DefaultizedProps<Props, 'openTo' | 'views' | keyof BaseDateValidationProps<TDate>, {
|
|
71
73
|
inputFormat: string;
|
|
72
|
-
}
|
|
73
|
-
export declare function useDateTimePickerDefaultizedProps<TInputDate, TDate, Props extends BaseDateTimePickerProps<TInputDate, TDate>>(props: Props, name: string): DefaultizedProps<Props> & Required<Pick<BaseDateTimePickerProps<TInputDate, TDate>, 'openTo' | 'views'>>;
|
|
74
|
+
}>;
|
|
74
75
|
export declare const dateTimePickerValueManager: PickerStateValueManager<any, any, any>;
|
|
75
|
-
export {};
|