@mui/x-date-pickers 6.18.5 → 6.18.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/AdapterLuxon/AdapterLuxon.d.ts +32 -32
- package/CHANGELOG.md +91 -0
- package/DateCalendar/DateCalendar.js +6 -4
- package/DateCalendar/DateCalendar.types.d.ts +0 -8
- package/DigitalClock/DigitalClock.js +3 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/TimeClock/TimeClock.js +3 -2
- package/index.js +1 -1
- package/internals/hooks/useField/useField.js +8 -1
- package/internals/hooks/useViews.d.ts +4 -4
- package/internals/hooks/useViews.js +13 -13
- package/internals/models/props/clock.d.ts +0 -9
- package/legacy/DateCalendar/DateCalendar.js +6 -4
- package/legacy/DigitalClock/DigitalClock.js +3 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/legacy/TimeClock/TimeClock.js +3 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useField/useField.js +8 -1
- package/legacy/internals/hooks/useViews.js +13 -13
- package/legacy/locales/ruRU.js +1 -2
- package/locales/ruRU.js +1 -2
- package/modern/DateCalendar/DateCalendar.js +6 -4
- package/modern/DigitalClock/DigitalClock.js +3 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/modern/TimeClock/TimeClock.js +3 -2
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +8 -1
- package/modern/internals/hooks/useViews.js +13 -13
- package/modern/locales/ruRU.js +1 -2
- package/node/DateCalendar/DateCalendar.js +6 -4
- package/node/DigitalClock/DigitalClock.js +3 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
- package/node/TimeClock/TimeClock.js +3 -2
- package/node/index.js +1 -1
- package/node/internals/hooks/useField/useField.js +8 -1
- package/node/internals/hooks/useViews.js +13 -13
- package/node/locales/ruRU.js +1 -2
- package/package.json +1 -1
|
@@ -38,14 +38,14 @@ export declare class AdapterLuxon implements MuiPickersAdapter<DateTime, string>
|
|
|
38
38
|
formatTokenMap: FieldFormatTokenMap;
|
|
39
39
|
constructor({ locale, formats }?: AdapterOptions<string, never>);
|
|
40
40
|
private setLocaleToValue;
|
|
41
|
-
date: (value?: any) => DateTime | null;
|
|
42
|
-
dateWithTimezone: <T extends string | null | undefined>(value: T, timezone: PickersTimezone) => DateBuilderReturnType<T, DateTime
|
|
41
|
+
date: (value?: any) => DateTime<true> | DateTime<false> | null;
|
|
42
|
+
dateWithTimezone: <T extends string | null | undefined>(value: T, timezone: PickersTimezone) => DateBuilderReturnType<T, DateTime<boolean>>;
|
|
43
43
|
getTimezone: (value: DateTime) => string;
|
|
44
44
|
setTimezone: (value: DateTime, timezone: PickersTimezone) => DateTime;
|
|
45
45
|
toJsDate: (value: DateTime) => Date;
|
|
46
|
-
parseISO: (isoString: string) => DateTime
|
|
46
|
+
parseISO: (isoString: string) => DateTime<true> | DateTime<false>;
|
|
47
47
|
toISO: (value: DateTime) => string;
|
|
48
|
-
parse: (value: string, formatString: string) => DateTime | null;
|
|
48
|
+
parse: (value: string, formatString: string) => DateTime<true> | DateTime<false> | null;
|
|
49
49
|
getCurrentLocaleCode: () => string;
|
|
50
50
|
is12HourCycleInCurrentLocale: () => boolean;
|
|
51
51
|
expandFormat: (format: string) => string;
|
|
@@ -68,21 +68,21 @@ export declare class AdapterLuxon implements MuiPickersAdapter<DateTime, string>
|
|
|
68
68
|
isBeforeYear: (value: DateTime, comparing: DateTime) => boolean;
|
|
69
69
|
isBeforeDay: (value: DateTime, comparing: DateTime) => boolean;
|
|
70
70
|
isWithinRange: (value: DateTime, [start, end]: [DateTime, DateTime]) => boolean;
|
|
71
|
-
startOfYear: (value: DateTime) => DateTime
|
|
72
|
-
startOfMonth: (value: DateTime) => DateTime
|
|
73
|
-
startOfWeek: (value: DateTime) => DateTime
|
|
74
|
-
startOfDay: (value: DateTime) => DateTime
|
|
75
|
-
endOfYear: (value: DateTime) => DateTime
|
|
76
|
-
endOfMonth: (value: DateTime) => DateTime
|
|
77
|
-
endOfWeek: (value: DateTime) => DateTime
|
|
78
|
-
endOfDay: (value: DateTime) => DateTime
|
|
79
|
-
addYears: (value: DateTime, amount: number) => DateTime
|
|
80
|
-
addMonths: (value: DateTime, amount: number) => DateTime
|
|
81
|
-
addWeeks: (value: DateTime, amount: number) => DateTime
|
|
82
|
-
addDays: (value: DateTime, amount: number) => DateTime
|
|
83
|
-
addHours: (value: DateTime, amount: number) => DateTime
|
|
84
|
-
addMinutes: (value: DateTime, amount: number) => DateTime
|
|
85
|
-
addSeconds: (value: DateTime, amount: number) => DateTime
|
|
71
|
+
startOfYear: (value: DateTime) => DateTime<boolean>;
|
|
72
|
+
startOfMonth: (value: DateTime) => DateTime<boolean>;
|
|
73
|
+
startOfWeek: (value: DateTime) => DateTime<boolean>;
|
|
74
|
+
startOfDay: (value: DateTime) => DateTime<boolean>;
|
|
75
|
+
endOfYear: (value: DateTime) => DateTime<boolean>;
|
|
76
|
+
endOfMonth: (value: DateTime) => DateTime<boolean>;
|
|
77
|
+
endOfWeek: (value: DateTime) => DateTime<boolean>;
|
|
78
|
+
endOfDay: (value: DateTime) => DateTime<boolean>;
|
|
79
|
+
addYears: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
80
|
+
addMonths: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
81
|
+
addWeeks: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
82
|
+
addDays: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
83
|
+
addHours: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
84
|
+
addMinutes: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
85
|
+
addSeconds: (value: DateTime, amount: number) => DateTime<boolean>;
|
|
86
86
|
getYear: (value: DateTime) => number;
|
|
87
87
|
getMonth: (value: DateTime) => number;
|
|
88
88
|
getDate: (value: DateTime) => number;
|
|
@@ -90,21 +90,21 @@ export declare class AdapterLuxon implements MuiPickersAdapter<DateTime, string>
|
|
|
90
90
|
getMinutes: (value: DateTime) => number;
|
|
91
91
|
getSeconds: (value: DateTime) => number;
|
|
92
92
|
getMilliseconds: (value: DateTime) => number;
|
|
93
|
-
setYear: (value: DateTime, year: number) => DateTime
|
|
94
|
-
setMonth: (value: DateTime, month: number) => DateTime
|
|
95
|
-
setDate: (value: DateTime, date: number) => DateTime
|
|
96
|
-
setHours: (value: DateTime, hours: number) => DateTime
|
|
97
|
-
setMinutes: (value: DateTime, minutes: number) => DateTime
|
|
98
|
-
setSeconds: (value: DateTime, seconds: number) => DateTime
|
|
99
|
-
setMilliseconds: (value: DateTime, milliseconds: number) => DateTime
|
|
93
|
+
setYear: (value: DateTime, year: number) => DateTime<boolean>;
|
|
94
|
+
setMonth: (value: DateTime, month: number) => DateTime<boolean>;
|
|
95
|
+
setDate: (value: DateTime, date: number) => DateTime<boolean>;
|
|
96
|
+
setHours: (value: DateTime, hours: number) => DateTime<boolean>;
|
|
97
|
+
setMinutes: (value: DateTime, minutes: number) => DateTime<boolean>;
|
|
98
|
+
setSeconds: (value: DateTime, seconds: number) => DateTime<boolean>;
|
|
99
|
+
setMilliseconds: (value: DateTime, milliseconds: number) => DateTime<boolean>;
|
|
100
100
|
getDaysInMonth: (value: DateTime) => import("luxon").PossibleDaysInMonth;
|
|
101
|
-
getNextMonth: (value: DateTime) => DateTime
|
|
102
|
-
getPreviousMonth: (value: DateTime) => DateTime
|
|
103
|
-
getMonthArray: (value: DateTime) => DateTime[];
|
|
104
|
-
mergeDateAndTime: (dateParam: DateTime, timeParam: DateTime) => DateTime
|
|
101
|
+
getNextMonth: (value: DateTime) => DateTime<boolean>;
|
|
102
|
+
getPreviousMonth: (value: DateTime) => DateTime<boolean>;
|
|
103
|
+
getMonthArray: (value: DateTime) => DateTime<boolean>[];
|
|
104
|
+
mergeDateAndTime: (dateParam: DateTime, timeParam: DateTime) => DateTime<boolean>;
|
|
105
105
|
getWeekdays: () => string[];
|
|
106
|
-
getWeekArray: (value: DateTime) => DateTime[][];
|
|
106
|
+
getWeekArray: (value: DateTime) => DateTime<boolean>[][];
|
|
107
107
|
getWeekNumber: (value: DateTime) => number;
|
|
108
|
-
getYearRange: (start: DateTime, end: DateTime) => DateTime[];
|
|
108
|
+
getYearRange: (start: DateTime, end: DateTime) => DateTime<boolean>[];
|
|
109
109
|
getMeridiemText: (ampm: 'am' | 'pm') => string;
|
|
110
110
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,97 @@
|
|
|
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
|
+
## 6.18.7
|
|
7
|
+
|
|
8
|
+
_Jan 5, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🌍 Improve Czech (cs-CZ) locale on Data Grid (#11429) @wensiet
|
|
13
|
+
- 🐞 Bugfixes
|
|
14
|
+
|
|
15
|
+
### Data Grid
|
|
16
|
+
|
|
17
|
+
#### `@mui/x-data-grid@6.18.7`
|
|
18
|
+
|
|
19
|
+
- [DataGrid] Don't evaluate `hasEval` when `disableEval` is set (#11553) @reihwald
|
|
20
|
+
- [l10n] Update Czech (cs-CZ) locale (#11498) @fdebef
|
|
21
|
+
|
|
22
|
+
#### `@mui/x-data-grid-pro@6.18.7` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
23
|
+
|
|
24
|
+
Same changes as in `@mui/x-data-grid@6.18.7`.
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid-premium@6.18.7` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
27
|
+
|
|
28
|
+
Same changes as in `@mui/x-data-grid-pro@6.18.7`.
|
|
29
|
+
|
|
30
|
+
### Date Pickers
|
|
31
|
+
|
|
32
|
+
#### `@mui/x-date-pickers@6.18.7`
|
|
33
|
+
|
|
34
|
+
- [pickers] Fix views management (@LukasTy) (#11572)
|
|
35
|
+
|
|
36
|
+
#### `@mui/x-date-pickers-pro@6.18.7` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
37
|
+
|
|
38
|
+
Same changes as in `@mui/x-date-pickers@6.18.7`.
|
|
39
|
+
|
|
40
|
+
### Charts / `@mui/x-charts@6.18.7`
|
|
41
|
+
|
|
42
|
+
- [charts] Fix `null` in line chart using dataset (@alexfauquette) (#11561)
|
|
43
|
+
|
|
44
|
+
### Docs
|
|
45
|
+
|
|
46
|
+
- [docs] Clarify Pickers usage with Luxon (#11566) @LukasTy
|
|
47
|
+
|
|
48
|
+
## 6.18.6
|
|
49
|
+
|
|
50
|
+
_Dec 22, 2023_
|
|
51
|
+
|
|
52
|
+
We'd like to offer a big thanks to the 5 contributors who made this release possible. Here are some highlights ✨:
|
|
53
|
+
|
|
54
|
+
- 🌍 Improve Russian (ru-RU) locale (#11429) @wensiet
|
|
55
|
+
- 🐞 Bugfixes
|
|
56
|
+
|
|
57
|
+
### Data Grid
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-data-grid@6.18.6`
|
|
60
|
+
|
|
61
|
+
- [DataGrid] Fix typos in the JSDoc (#11475) @flaviendelangle
|
|
62
|
+
- [l10n] Improve Russian (ru-RU) locale (#11429) @wensiet
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-data-grid-pro@6.18.6` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
65
|
+
|
|
66
|
+
Same changes as in `@mui/x-data-grid@6.18.6`.
|
|
67
|
+
|
|
68
|
+
#### `@mui/x-data-grid-premium@6.18.6` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
69
|
+
|
|
70
|
+
Same changes as in `@mui/x-data-grid-pro@6.18.6`.
|
|
71
|
+
|
|
72
|
+
### Date Pickers
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-date-pickers@6.18.6`
|
|
75
|
+
|
|
76
|
+
- [fields] Fix section pasting (#11467) @LukasTy
|
|
77
|
+
|
|
78
|
+
#### `@mui/x-date-pickers-pro@6.18.6` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
79
|
+
|
|
80
|
+
Same changes as in `@mui/x-date-pickers@6.18.6`.
|
|
81
|
+
|
|
82
|
+
### Charts / `@mui/x-charts@6.18.4`
|
|
83
|
+
|
|
84
|
+
- [charts] Allow percentage values for pie chart center and radius (#11464) @alexfauquette
|
|
85
|
+
- [charts] Make error message more explicit (#11457) @alexfauquette
|
|
86
|
+
- [charts] Make the helper `ChartsText` component public (#11370) @alexfauquette
|
|
87
|
+
- [charts] Improve dataset typing (#11372) @alexfauquette
|
|
88
|
+
- [charts] Fix size overflow (#11385) @alexfauquette
|
|
89
|
+
|
|
90
|
+
### Docs
|
|
91
|
+
|
|
92
|
+
- [docs] Document false default values for boolean props (#11489) @cherniavskii
|
|
93
|
+
- [docs] Improve Pickers `name` prop examples (#11442) @LukasTy
|
|
94
|
+
- [docs] Limit `date-fns` package to v2 in codesandbox (#11478) @LukasTy
|
|
95
|
+
- [test] Reload the page if its blank and there are no links to the remaining tests (#11471) @cherniavskii
|
|
96
|
+
|
|
6
97
|
## 6.18.5
|
|
7
98
|
|
|
8
99
|
_Dec 14, 2023_
|
|
@@ -258,9 +258,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
258
258
|
const handleSelectedDayChange = useEventCallback(day => {
|
|
259
259
|
if (day) {
|
|
260
260
|
// If there is a date already selected, then we want to keep its time
|
|
261
|
-
return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish');
|
|
261
|
+
return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish', view);
|
|
262
262
|
}
|
|
263
|
-
return handleValueChange(day, 'finish');
|
|
263
|
+
return handleValueChange(day, 'finish', view);
|
|
264
264
|
});
|
|
265
265
|
React.useEffect(() => {
|
|
266
266
|
if (value != null && utils.isValid(value)) {
|
|
@@ -449,9 +449,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
449
449
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
450
450
|
/**
|
|
451
451
|
* Callback fired when the value changes.
|
|
452
|
-
* @template
|
|
453
|
-
* @
|
|
452
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
453
|
+
* @template TView The view type. Will be one of date or time views.
|
|
454
|
+
* @param {TValue} value The new value.
|
|
454
455
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
456
|
+
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
455
457
|
*/
|
|
456
458
|
onChange: PropTypes.func,
|
|
457
459
|
/**
|
|
@@ -6,7 +6,6 @@ import { PickersCalendarHeader, PickersCalendarHeaderProps, PickersCalendarHeade
|
|
|
6
6
|
import { DayCalendarSlotsComponent, DayCalendarSlotsComponentsProps, ExportedDayCalendarProps } from './DayCalendar';
|
|
7
7
|
import { DateCalendarClasses } from './dateCalendarClasses';
|
|
8
8
|
import { BaseDateValidationProps, YearValidationProps, MonthValidationProps, DayValidationProps } from '../internals/models/validation';
|
|
9
|
-
import { PickerSelectionState } from '../internals/hooks/usePicker/usePickerValue.types';
|
|
10
9
|
import { ExportedUseViewsOptions } from '../internals/hooks/useViews';
|
|
11
10
|
import { DateView, TimezoneProps } from '../models';
|
|
12
11
|
import { DefaultizedProps } from '../internals/models/helpers';
|
|
@@ -80,13 +79,6 @@ export interface DateCalendarProps<TDate> extends ExportedDateCalendarProps<TDat
|
|
|
80
79
|
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`.
|
|
81
80
|
*/
|
|
82
81
|
referenceDate?: TDate;
|
|
83
|
-
/**
|
|
84
|
-
* Callback fired when the value changes.
|
|
85
|
-
* @template TDate
|
|
86
|
-
* @param {TDate | null} value The new value.
|
|
87
|
-
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
88
|
-
*/
|
|
89
|
-
onChange?: (value: TDate | null, selectionState?: PickerSelectionState) => void;
|
|
90
82
|
className?: string;
|
|
91
83
|
classes?: Partial<DateCalendarClasses>;
|
|
92
84
|
/**
|
|
@@ -340,8 +340,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
340
340
|
minutesStep: PropTypes.number,
|
|
341
341
|
/**
|
|
342
342
|
* Callback fired when the value changes.
|
|
343
|
-
* @template
|
|
344
|
-
* @
|
|
343
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
344
|
+
* @template TView The view type. Will be one of date or time views.
|
|
345
|
+
* @param {TValue} value The new value.
|
|
345
346
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
346
347
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
347
348
|
*/
|
|
@@ -125,7 +125,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
125
125
|
}, [ampm, inViews]);
|
|
126
126
|
const {
|
|
127
127
|
view,
|
|
128
|
-
|
|
128
|
+
setValueAndGoToNextView,
|
|
129
129
|
focusedView
|
|
130
130
|
} = useViews({
|
|
131
131
|
view: inView,
|
|
@@ -137,7 +137,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
137
137
|
onFocusedViewChange
|
|
138
138
|
});
|
|
139
139
|
const handleMeridiemValueChange = useEventCallback(newValue => {
|
|
140
|
-
|
|
140
|
+
setValueAndGoToNextView(newValue, 'finish', 'meridiem');
|
|
141
141
|
});
|
|
142
142
|
const {
|
|
143
143
|
meridiemMode,
|
|
@@ -221,11 +221,6 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
221
221
|
throw new Error('not supported');
|
|
222
222
|
}
|
|
223
223
|
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableClock, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
|
|
224
|
-
const handleSectionChange = useEventCallback((sectionView, newValue) => {
|
|
225
|
-
const viewIndex = views.indexOf(sectionView);
|
|
226
|
-
const nextView = views[viewIndex + 1];
|
|
227
|
-
setValueAndGoToView(newValue, nextView, sectionView);
|
|
228
|
-
});
|
|
229
224
|
const buildViewProps = React.useCallback(viewToBuild => {
|
|
230
225
|
switch (viewToBuild) {
|
|
231
226
|
case 'hours':
|
|
@@ -233,7 +228,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
233
228
|
return {
|
|
234
229
|
onChange: hours => {
|
|
235
230
|
const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
|
|
236
|
-
|
|
231
|
+
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
|
|
237
232
|
},
|
|
238
233
|
items: getHourSectionOptions({
|
|
239
234
|
now,
|
|
@@ -250,7 +245,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
250
245
|
{
|
|
251
246
|
return {
|
|
252
247
|
onChange: minutes => {
|
|
253
|
-
|
|
248
|
+
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
|
|
254
249
|
},
|
|
255
250
|
items: getTimeSectionOptions({
|
|
256
251
|
value: utils.getMinutes(valueOrReferenceDate),
|
|
@@ -267,7 +262,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
267
262
|
{
|
|
268
263
|
return {
|
|
269
264
|
onChange: seconds => {
|
|
270
|
-
|
|
265
|
+
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
|
|
271
266
|
},
|
|
272
267
|
items: getTimeSectionOptions({
|
|
273
268
|
value: utils.getSeconds(valueOrReferenceDate),
|
|
@@ -302,7 +297,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
302
297
|
default:
|
|
303
298
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
304
299
|
}
|
|
305
|
-
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode,
|
|
300
|
+
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
|
|
306
301
|
const viewTimeOptions = React.useMemo(() => {
|
|
307
302
|
return views.reduce((result, currentView) => {
|
|
308
303
|
return _extends({}, result, {
|
|
@@ -412,8 +407,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
412
407
|
minutesStep: PropTypes.number,
|
|
413
408
|
/**
|
|
414
409
|
* Callback fired when the value changes.
|
|
415
|
-
* @template
|
|
416
|
-
* @
|
|
410
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
411
|
+
* @template TView The view type. Will be one of date or time views.
|
|
412
|
+
* @param {TValue} value The new value.
|
|
417
413
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
418
414
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
419
415
|
*/
|
|
@@ -89,7 +89,7 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
89
89
|
var _slots$digitalClockSe;
|
|
90
90
|
const containerRef = React.useRef(null);
|
|
91
91
|
const handleRef = useForkRef(ref, containerRef);
|
|
92
|
-
const
|
|
92
|
+
const previousActive = React.useRef(null);
|
|
93
93
|
const props = useThemeProps({
|
|
94
94
|
props: inProps,
|
|
95
95
|
name: 'MuiMultiSectionDigitalClockSection'
|
|
@@ -116,19 +116,15 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
116
116
|
if (containerRef.current === null) {
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
if (previousSelected.current !== selectedItem) {
|
|
123
|
-
previousSelected.current = selectedItem;
|
|
124
|
-
}
|
|
125
|
-
return;
|
|
119
|
+
const activeItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
|
|
120
|
+
if (active && autoFocus && activeItem) {
|
|
121
|
+
activeItem.focus();
|
|
126
122
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
selectedItem.focus();
|
|
123
|
+
if (!activeItem || previousActive.current === activeItem) {
|
|
124
|
+
return;
|
|
130
125
|
}
|
|
131
|
-
|
|
126
|
+
previousActive.current = activeItem;
|
|
127
|
+
const offsetTop = activeItem.offsetTop;
|
|
132
128
|
|
|
133
129
|
// Subtracting the 4px of extra margin intended for the first visible section item
|
|
134
130
|
containerRef.current.scrollTop = offsetTop - 4;
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -404,8 +404,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
404
404
|
minutesStep: PropTypes.number,
|
|
405
405
|
/**
|
|
406
406
|
* Callback fired when the value changes.
|
|
407
|
-
* @template
|
|
408
|
-
* @
|
|
407
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
408
|
+
* @template TView The view type. Will be one of date or time views.
|
|
409
|
+
* @param {TValue} value The new value.
|
|
409
410
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
410
411
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
411
412
|
*/
|
package/index.js
CHANGED
|
@@ -143,7 +143,14 @@ export const useField = params => {
|
|
|
143
143
|
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
144
144
|
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
145
145
|
if (isValidPastedValue) {
|
|
146
|
-
|
|
146
|
+
resetCharacterQuery();
|
|
147
|
+
updateSectionValue({
|
|
148
|
+
activeSection,
|
|
149
|
+
newSectionValue: pastedValue,
|
|
150
|
+
shouldGoToNextSection: true
|
|
151
|
+
});
|
|
152
|
+
// prevent default to avoid the input change handler being called
|
|
153
|
+
event.preventDefault();
|
|
147
154
|
return;
|
|
148
155
|
}
|
|
149
156
|
if (lettersOnly || digitsOnly) {
|
|
@@ -5,7 +5,8 @@ export type PickerOnChangeFn<TDate> = (date: TDate | null, selectionState?: Pick
|
|
|
5
5
|
export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
6
6
|
/**
|
|
7
7
|
* Callback fired when the value changes.
|
|
8
|
-
* @template TValue
|
|
8
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
9
|
+
* @template TView The view type. Will be one of date or time views.
|
|
9
10
|
* @param {TValue} value The new value.
|
|
10
11
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
11
12
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
@@ -52,7 +53,7 @@ export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridie
|
|
|
52
53
|
*/
|
|
53
54
|
onFocusedViewChange?: (view: TView, hasFocus: boolean) => void;
|
|
54
55
|
}
|
|
55
|
-
export interface ExportedUseViewsOptions<TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<
|
|
56
|
+
export interface ExportedUseViewsOptions<TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<UseViewsOptions<any, TView>, 'onChange' | 'openTo' | 'views'> {
|
|
56
57
|
}
|
|
57
58
|
interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
58
59
|
view: TView;
|
|
@@ -63,8 +64,7 @@ interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
|
63
64
|
previousView: TView | null;
|
|
64
65
|
defaultView: TView;
|
|
65
66
|
goToNextView: () => void;
|
|
66
|
-
setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState) => void;
|
|
67
|
-
setValueAndGoToView: (value: TValue, newView: TView | null, selectedView: TView) => void;
|
|
67
|
+
setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState, selectedView?: TView) => void;
|
|
68
68
|
}
|
|
69
69
|
export declare function useViews<TValue, TView extends DateOrTimeViewWithMeridiem>({ onChange, onViewChange, openTo, view: inView, views, autoFocus, focusedView: inFocusedView, onFocusedViewChange, }: UseViewsOptions<TValue, TView>): UseViewsResponse<TValue, TView>;
|
|
70
70
|
export {};
|
|
@@ -65,11 +65,12 @@ export function useViews({
|
|
|
65
65
|
onFocusedViewChange == null || onFocusedViewChange(viewToFocus, hasFocus);
|
|
66
66
|
});
|
|
67
67
|
const handleChangeView = useEventCallback(newView => {
|
|
68
|
+
// always keep the focused view in sync
|
|
69
|
+
handleFocusedViewChange(newView, true);
|
|
68
70
|
if (newView === view) {
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
73
|
setView(newView);
|
|
72
|
-
handleFocusedViewChange(newView, true);
|
|
73
74
|
if (onViewChange) {
|
|
74
75
|
onViewChange(newView);
|
|
75
76
|
}
|
|
@@ -78,7 +79,6 @@ export function useViews({
|
|
|
78
79
|
if (nextView) {
|
|
79
80
|
handleChangeView(nextView);
|
|
80
81
|
}
|
|
81
|
-
handleFocusedViewChange(nextView, true);
|
|
82
82
|
});
|
|
83
83
|
const setValueAndGoToNextView = useEventCallback((value, currentViewSelectionState, selectedView) => {
|
|
84
84
|
const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
|
|
@@ -87,18 +87,19 @@ export function useViews({
|
|
|
87
87
|
// but we it's not the final view given all `views` -> overall selection state should be `partial`.
|
|
88
88
|
views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
|
|
89
89
|
const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
|
|
90
|
-
onChange(value, globalSelectionState);
|
|
91
|
-
if
|
|
90
|
+
onChange(value, globalSelectionState, selectedView);
|
|
91
|
+
// Detects if the selected view is not the active one.
|
|
92
|
+
// Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
|
|
93
|
+
if (selectedView && selectedView !== view) {
|
|
94
|
+
const nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
|
|
95
|
+
if (nextViewAfterSelected) {
|
|
96
|
+
// move to next view after the selected one
|
|
97
|
+
handleChangeView(nextViewAfterSelected);
|
|
98
|
+
}
|
|
99
|
+
} else if (isSelectionFinishedOnCurrentView) {
|
|
92
100
|
goToNextView();
|
|
93
101
|
}
|
|
94
102
|
});
|
|
95
|
-
const setValueAndGoToView = useEventCallback((value, newView, selectedView) => {
|
|
96
|
-
onChange(value, newView ? 'partial' : 'finish', selectedView);
|
|
97
|
-
if (newView) {
|
|
98
|
-
handleChangeView(newView);
|
|
99
|
-
handleFocusedViewChange(newView, true);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
103
|
return {
|
|
103
104
|
view,
|
|
104
105
|
setView: handleChangeView,
|
|
@@ -109,7 +110,6 @@ export function useViews({
|
|
|
109
110
|
// Always return up to date default view instead of the initial one (i.e. defaultView.current)
|
|
110
111
|
defaultView: views.includes(openTo) ? openTo : views[0],
|
|
111
112
|
goToNextView,
|
|
112
|
-
setValueAndGoToNextView
|
|
113
|
-
setValueAndGoToView
|
|
113
|
+
setValueAndGoToNextView
|
|
114
114
|
};
|
|
115
115
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
2
|
import { BaseTimeValidationProps, TimeValidationProps } from '../validation';
|
|
3
|
-
import { PickerSelectionState } from '../../hooks/usePicker/usePickerValue.types';
|
|
4
3
|
import { TimeStepOptions, TimezoneProps } from '../../../models';
|
|
5
4
|
import type { ExportedDigitalClockProps } from '../../../DigitalClock/DigitalClock.types';
|
|
6
5
|
import type { ExportedMultiSectionDigitalClockProps } from '../../../MultiSectionDigitalClock/MultiSectionDigitalClock.types';
|
|
@@ -29,14 +28,6 @@ export interface BaseClockProps<TDate, TView extends TimeViewWithMeridiem> exten
|
|
|
29
28
|
* Used when the component is not controlled.
|
|
30
29
|
*/
|
|
31
30
|
defaultValue?: TDate | null;
|
|
32
|
-
/**
|
|
33
|
-
* Callback fired when the value changes.
|
|
34
|
-
* @template TDate, TView
|
|
35
|
-
* @param {TDate | null} value The new value.
|
|
36
|
-
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
37
|
-
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
38
|
-
*/
|
|
39
|
-
onChange?: (value: TDate | null, selectionState?: PickerSelectionState, selectedView?: TView) => void;
|
|
40
31
|
/**
|
|
41
32
|
* If `true`, the picker views and text field are disabled.
|
|
42
33
|
* @default false
|
|
@@ -259,9 +259,9 @@ export var DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(in
|
|
|
259
259
|
var handleSelectedDayChange = useEventCallback(function (day) {
|
|
260
260
|
if (day) {
|
|
261
261
|
// If there is a date already selected, then we want to keep its time
|
|
262
|
-
return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish');
|
|
262
|
+
return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish', view);
|
|
263
263
|
}
|
|
264
|
-
return handleValueChange(day, 'finish');
|
|
264
|
+
return handleValueChange(day, 'finish', view);
|
|
265
265
|
});
|
|
266
266
|
React.useEffect(function () {
|
|
267
267
|
if (value != null && utils.isValid(value)) {
|
|
@@ -458,9 +458,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
458
458
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
459
459
|
/**
|
|
460
460
|
* Callback fired when the value changes.
|
|
461
|
-
* @template
|
|
462
|
-
* @
|
|
461
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
462
|
+
* @template TView The view type. Will be one of date or time views.
|
|
463
|
+
* @param {TValue} value The new value.
|
|
463
464
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
465
|
+
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
464
466
|
*/
|
|
465
467
|
onChange: PropTypes.func,
|
|
466
468
|
/**
|
|
@@ -357,8 +357,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
357
357
|
minutesStep: PropTypes.number,
|
|
358
358
|
/**
|
|
359
359
|
* Callback fired when the value changes.
|
|
360
|
-
* @template
|
|
361
|
-
* @
|
|
360
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
361
|
+
* @template TView The view type. Will be one of date or time views.
|
|
362
|
+
* @param {TValue} value The new value.
|
|
362
363
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
363
364
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
364
365
|
*/
|
|
@@ -143,10 +143,10 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
|
|
|
143
143
|
onFocusedViewChange: onFocusedViewChange
|
|
144
144
|
}),
|
|
145
145
|
view = _useViews.view,
|
|
146
|
-
|
|
146
|
+
setValueAndGoToNextView = _useViews.setValueAndGoToNextView,
|
|
147
147
|
focusedView = _useViews.focusedView;
|
|
148
148
|
var handleMeridiemValueChange = useEventCallback(function (newValue) {
|
|
149
|
-
|
|
149
|
+
setValueAndGoToNextView(newValue, 'finish', 'meridiem');
|
|
150
150
|
});
|
|
151
151
|
var _useMeridiemMode = useMeridiemMode(valueOrReferenceDate, ampm, handleMeridiemValueChange, 'finish'),
|
|
152
152
|
meridiemMode = _useMeridiemMode.meridiemMode,
|
|
@@ -229,11 +229,6 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
|
|
|
229
229
|
throw new Error('not supported');
|
|
230
230
|
}
|
|
231
231
|
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableClock, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
|
|
232
|
-
var handleSectionChange = useEventCallback(function (sectionView, newValue) {
|
|
233
|
-
var viewIndex = views.indexOf(sectionView);
|
|
234
|
-
var nextView = views[viewIndex + 1];
|
|
235
|
-
setValueAndGoToView(newValue, nextView, sectionView);
|
|
236
|
-
});
|
|
237
232
|
var buildViewProps = React.useCallback(function (viewToBuild) {
|
|
238
233
|
switch (viewToBuild) {
|
|
239
234
|
case 'hours':
|
|
@@ -241,7 +236,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
|
|
|
241
236
|
return {
|
|
242
237
|
onChange: function onChange(hours) {
|
|
243
238
|
var valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
|
|
244
|
-
|
|
239
|
+
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
|
|
245
240
|
},
|
|
246
241
|
items: getHourSectionOptions({
|
|
247
242
|
now: now,
|
|
@@ -260,7 +255,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
|
|
|
260
255
|
{
|
|
261
256
|
return {
|
|
262
257
|
onChange: function onChange(minutes) {
|
|
263
|
-
|
|
258
|
+
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
|
|
264
259
|
},
|
|
265
260
|
items: getTimeSectionOptions({
|
|
266
261
|
value: utils.getMinutes(valueOrReferenceDate),
|
|
@@ -281,7 +276,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
|
|
|
281
276
|
{
|
|
282
277
|
return {
|
|
283
278
|
onChange: function onChange(seconds) {
|
|
284
|
-
|
|
279
|
+
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
|
|
285
280
|
},
|
|
286
281
|
items: getTimeSectionOptions({
|
|
287
282
|
value: utils.getSeconds(valueOrReferenceDate),
|
|
@@ -324,7 +319,7 @@ export var MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function Mul
|
|
|
324
319
|
default:
|
|
325
320
|
throw new Error("Unknown view: ".concat(viewToBuild, " found."));
|
|
326
321
|
}
|
|
327
|
-
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode,
|
|
322
|
+
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
|
|
328
323
|
var viewTimeOptions = React.useMemo(function () {
|
|
329
324
|
return views.reduce(function (result, currentView) {
|
|
330
325
|
return _extends({}, result, _defineProperty({}, currentView, buildViewProps(currentView)));
|
|
@@ -437,8 +432,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
437
432
|
minutesStep: PropTypes.number,
|
|
438
433
|
/**
|
|
439
434
|
* Callback fired when the value changes.
|
|
440
|
-
* @template
|
|
441
|
-
* @
|
|
435
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
436
|
+
* @template TView The view type. Will be one of date or time views.
|
|
437
|
+
* @param {TValue} value The new value.
|
|
442
438
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
443
439
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
444
440
|
*/
|