@mui/x-date-pickers 8.8.0 → 8.9.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/AdapterDayjs/AdapterDayjs.d.ts +28 -31
- package/AdapterDayjs/AdapterDayjs.js +25 -31
- package/CHANGELOG.md +101 -24
- package/DateCalendar/DateCalendar.js +2 -2
- package/DatePicker/DatePicker.js +1 -1
- package/DateTimePicker/DateTimePicker.js +3 -3
- package/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -3
- package/DesktopTimePicker/DesktopTimePicker.js +3 -3
- package/DigitalClock/DigitalClock.js +2 -2
- package/MobileDatePicker/MobileDatePicker.js +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +3 -3
- package/MobileTimePicker/MobileTimePicker.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -3
- package/PickersLayout/PickersLayout.js +1 -1
- package/StaticDatePicker/StaticDatePicker.js +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +3 -3
- package/StaticTimePicker/StaticTimePicker.js +1 -1
- package/TimeClock/TimeClock.js +2 -2
- package/TimePicker/TimePicker.js +3 -3
- package/esm/AdapterDayjs/AdapterDayjs.d.ts +28 -31
- package/esm/AdapterDayjs/AdapterDayjs.js +37 -43
- package/esm/DateCalendar/DateCalendar.js +2 -2
- package/esm/DatePicker/DatePicker.js +1 -1
- package/esm/DateTimePicker/DateTimePicker.js +3 -3
- package/esm/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -3
- package/esm/DesktopTimePicker/DesktopTimePicker.js +3 -3
- package/esm/DigitalClock/DigitalClock.js +2 -2
- package/esm/MobileDatePicker/MobileDatePicker.js +1 -1
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +3 -3
- package/esm/MobileTimePicker/MobileTimePicker.js +1 -1
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -3
- package/esm/PickersLayout/PickersLayout.js +1 -1
- package/esm/StaticDatePicker/StaticDatePicker.js +1 -1
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +3 -3
- package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
- package/esm/TimeClock/TimeClock.js +2 -2
- package/esm/TimePicker/TimePicker.js +3 -3
- package/esm/index.js +1 -1
- package/esm/internals/hooks/useViews.d.ts +2 -2
- package/esm/internals/models/props/time.d.ts +3 -3
- package/index.js +1 -1
- package/internals/hooks/useViews.d.ts +2 -2
- package/internals/models/props/time.d.ts +3 -3
- package/package.json +1 -1
|
@@ -400,14 +400,14 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
400
400
|
onChange: _propTypes.default.func,
|
|
401
401
|
/**
|
|
402
402
|
* Callback fired on focused view change.
|
|
403
|
-
* @template TView
|
|
403
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
404
404
|
* @param {TView} view The new view to focus or not.
|
|
405
405
|
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
406
406
|
*/
|
|
407
407
|
onFocusedViewChange: _propTypes.default.func,
|
|
408
408
|
/**
|
|
409
409
|
* Callback fired on view change.
|
|
410
|
-
* @template TView
|
|
410
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
411
411
|
* @param {TView} view The new view.
|
|
412
412
|
*/
|
|
413
413
|
onViewChange: _propTypes.default.func,
|
|
@@ -235,7 +235,7 @@ MobileDatePicker.propTypes = {
|
|
|
235
235
|
onSelectedSectionsChange: _propTypes.default.func,
|
|
236
236
|
/**
|
|
237
237
|
* Callback fired on view change.
|
|
238
|
-
* @template TView
|
|
238
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
239
239
|
* @param {TView} view The new view.
|
|
240
240
|
*/
|
|
241
241
|
onViewChange: _propTypes.default.func,
|
|
@@ -323,7 +323,7 @@ MobileDateTimePicker.propTypes = {
|
|
|
323
323
|
onSelectedSectionsChange: _propTypes.default.func,
|
|
324
324
|
/**
|
|
325
325
|
* Callback fired on view change.
|
|
326
|
-
* @template TView
|
|
326
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
327
327
|
* @param {TView} view The new view.
|
|
328
328
|
*/
|
|
329
329
|
onViewChange: _propTypes.default.func,
|
|
@@ -444,8 +444,8 @@ MobileDateTimePicker.propTypes = {
|
|
|
444
444
|
thresholdToRenderTimeInASingleColumn: _propTypes.default.number,
|
|
445
445
|
/**
|
|
446
446
|
* The time steps between two time unit options.
|
|
447
|
-
* For example, if `
|
|
448
|
-
* When single column time renderer is used, only `
|
|
447
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
448
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
449
449
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
450
450
|
*/
|
|
451
451
|
timeSteps: _propTypes.default.shape({
|
|
@@ -221,7 +221,7 @@ MobileTimePicker.propTypes = {
|
|
|
221
221
|
onSelectedSectionsChange: _propTypes.default.func,
|
|
222
222
|
/**
|
|
223
223
|
* Callback fired on view change.
|
|
224
|
-
* @template TView
|
|
224
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
225
225
|
* @param {TView} view The new view.
|
|
226
226
|
*/
|
|
227
227
|
onViewChange: _propTypes.default.func,
|
|
@@ -429,14 +429,14 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
429
429
|
onChange: _propTypes.default.func,
|
|
430
430
|
/**
|
|
431
431
|
* Callback fired on focused view change.
|
|
432
|
-
* @template TView
|
|
432
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
433
433
|
* @param {TView} view The new view to focus or not.
|
|
434
434
|
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
435
435
|
*/
|
|
436
436
|
onFocusedViewChange: _propTypes.default.func,
|
|
437
437
|
/**
|
|
438
438
|
* Callback fired on view change.
|
|
439
|
-
* @template TView
|
|
439
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
440
440
|
* @param {TView} view The new view.
|
|
441
441
|
*/
|
|
442
442
|
onViewChange: _propTypes.default.func,
|
|
@@ -485,7 +485,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
485
485
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
486
486
|
/**
|
|
487
487
|
* The time steps between two time unit options.
|
|
488
|
-
* For example, if `
|
|
488
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
489
489
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
490
490
|
*/
|
|
491
491
|
timeSteps: _propTypes.default.shape({
|
|
@@ -183,7 +183,7 @@ StaticDatePicker.propTypes = {
|
|
|
183
183
|
onMonthChange: _propTypes.default.func,
|
|
184
184
|
/**
|
|
185
185
|
* Callback fired on view change.
|
|
186
|
-
* @template TView
|
|
186
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
187
187
|
* @param {TView} view The new view.
|
|
188
188
|
*/
|
|
189
189
|
onViewChange: _propTypes.default.func,
|
|
@@ -270,7 +270,7 @@ StaticDateTimePicker.propTypes = {
|
|
|
270
270
|
onMonthChange: _propTypes.default.func,
|
|
271
271
|
/**
|
|
272
272
|
* Callback fired on view change.
|
|
273
|
-
* @template TView
|
|
273
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
274
274
|
* @param {TView} view The new view.
|
|
275
275
|
*/
|
|
276
276
|
onViewChange: _propTypes.default.func,
|
|
@@ -376,8 +376,8 @@ StaticDateTimePicker.propTypes = {
|
|
|
376
376
|
thresholdToRenderTimeInASingleColumn: _propTypes.default.number,
|
|
377
377
|
/**
|
|
378
378
|
* The time steps between two time unit options.
|
|
379
|
-
* For example, if `
|
|
380
|
-
* When single column time renderer is used, only `
|
|
379
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
380
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
381
381
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
382
382
|
*/
|
|
383
383
|
timeSteps: _propTypes.default.shape({
|
|
@@ -168,7 +168,7 @@ StaticTimePicker.propTypes = {
|
|
|
168
168
|
onError: _propTypes.default.func,
|
|
169
169
|
/**
|
|
170
170
|
* Callback fired on view change.
|
|
171
|
-
* @template TView
|
|
171
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
172
172
|
* @param {TView} view The new view.
|
|
173
173
|
*/
|
|
174
174
|
onViewChange: _propTypes.default.func,
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -421,14 +421,14 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
421
421
|
onChange: _propTypes.default.func,
|
|
422
422
|
/**
|
|
423
423
|
* Callback fired on focused view change.
|
|
424
|
-
* @template TView
|
|
424
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
425
425
|
* @param {TView} view The new view to focus or not.
|
|
426
426
|
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
427
427
|
*/
|
|
428
428
|
onFocusedViewChange: _propTypes.default.func,
|
|
429
429
|
/**
|
|
430
430
|
* Callback fired on view change.
|
|
431
|
-
* @template TView
|
|
431
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
432
432
|
* @param {TView} view The new view.
|
|
433
433
|
*/
|
|
434
434
|
onViewChange: _propTypes.default.func,
|
package/TimePicker/TimePicker.js
CHANGED
|
@@ -209,7 +209,7 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
209
209
|
onSelectedSectionsChange: _propTypes.default.func,
|
|
210
210
|
/**
|
|
211
211
|
* Callback fired on view change.
|
|
212
|
-
* @template TView
|
|
212
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
213
213
|
* @param {TView} view The new view.
|
|
214
214
|
*/
|
|
215
215
|
onViewChange: _propTypes.default.func,
|
|
@@ -287,8 +287,8 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
287
287
|
thresholdToRenderTimeInASingleColumn: _propTypes.default.number,
|
|
288
288
|
/**
|
|
289
289
|
* The time steps between two time unit options.
|
|
290
|
-
* For example, if `
|
|
291
|
-
* When single column time renderer is used, only `
|
|
290
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
291
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
292
292
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
293
293
|
*/
|
|
294
294
|
timeSteps: _propTypes.default.shape({
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
2
2
|
import { FieldFormatTokenMap, MuiPickersAdapter, AdapterFormats, AdapterOptions, PickersTimezone, DateBuilderReturnType } from "../models/index.js";
|
|
3
|
-
type Constructor = (...args: Parameters<typeof defaultDayjs>) => Dayjs;
|
|
4
3
|
declare module '@mui/x-date-pickers/models' {
|
|
5
4
|
interface PickerValidDateLookup {
|
|
6
5
|
dayjs: Dayjs;
|
|
@@ -35,7 +34,6 @@ export declare class AdapterDayjs implements MuiPickersAdapter<string> {
|
|
|
35
34
|
isMUIAdapter: boolean;
|
|
36
35
|
isTimezoneCompatible: boolean;
|
|
37
36
|
lib: string;
|
|
38
|
-
dayjs: Constructor;
|
|
39
37
|
locale?: string;
|
|
40
38
|
formats: AdapterFormats;
|
|
41
39
|
escapedCharacters: {
|
|
@@ -67,11 +65,11 @@ export declare class AdapterDayjs implements MuiPickersAdapter<string> {
|
|
|
67
65
|
*/
|
|
68
66
|
private adjustOffset;
|
|
69
67
|
date: <T extends string | null | undefined>(value?: T, timezone?: PickersTimezone) => DateBuilderReturnType<T>;
|
|
70
|
-
getInvalidDate: () =>
|
|
68
|
+
getInvalidDate: () => dayjs.Dayjs;
|
|
71
69
|
getTimezone: (value: Dayjs) => string;
|
|
72
70
|
setTimezone: (value: Dayjs, timezone: PickersTimezone) => Dayjs;
|
|
73
71
|
toJsDate: (value: Dayjs) => Date;
|
|
74
|
-
parse: (value: string, format: string) =>
|
|
72
|
+
parse: (value: string, format: string) => dayjs.Dayjs | null;
|
|
75
73
|
getCurrentLocaleCode: () => string;
|
|
76
74
|
is12HourCycleInCurrentLocale: () => boolean;
|
|
77
75
|
expandFormat: (format: string) => string;
|
|
@@ -91,21 +89,21 @@ export declare class AdapterDayjs implements MuiPickersAdapter<string> {
|
|
|
91
89
|
isBeforeYear: (value: Dayjs, comparing: Dayjs) => boolean;
|
|
92
90
|
isBeforeDay: (value: Dayjs, comparing: Dayjs) => boolean;
|
|
93
91
|
isWithinRange: (value: Dayjs, [start, end]: [Dayjs, Dayjs]) => boolean;
|
|
94
|
-
startOfYear: (value: Dayjs) =>
|
|
95
|
-
startOfMonth: (value: Dayjs) =>
|
|
96
|
-
startOfWeek: (value: Dayjs) =>
|
|
97
|
-
startOfDay: (value: Dayjs) =>
|
|
98
|
-
endOfYear: (value: Dayjs) =>
|
|
99
|
-
endOfMonth: (value: Dayjs) =>
|
|
100
|
-
endOfWeek: (value: Dayjs) =>
|
|
101
|
-
endOfDay: (value: Dayjs) =>
|
|
102
|
-
addYears: (value: Dayjs, amount: number) =>
|
|
103
|
-
addMonths: (value: Dayjs, amount: number) =>
|
|
104
|
-
addWeeks: (value: Dayjs, amount: number) =>
|
|
105
|
-
addDays: (value: Dayjs, amount: number) =>
|
|
106
|
-
addHours: (value: Dayjs, amount: number) =>
|
|
107
|
-
addMinutes: (value: Dayjs, amount: number) =>
|
|
108
|
-
addSeconds: (value: Dayjs, amount: number) =>
|
|
92
|
+
startOfYear: (value: Dayjs) => dayjs.Dayjs;
|
|
93
|
+
startOfMonth: (value: Dayjs) => dayjs.Dayjs;
|
|
94
|
+
startOfWeek: (value: Dayjs) => dayjs.Dayjs;
|
|
95
|
+
startOfDay: (value: Dayjs) => dayjs.Dayjs;
|
|
96
|
+
endOfYear: (value: Dayjs) => dayjs.Dayjs;
|
|
97
|
+
endOfMonth: (value: Dayjs) => dayjs.Dayjs;
|
|
98
|
+
endOfWeek: (value: Dayjs) => dayjs.Dayjs;
|
|
99
|
+
endOfDay: (value: Dayjs) => dayjs.Dayjs;
|
|
100
|
+
addYears: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
101
|
+
addMonths: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
102
|
+
addWeeks: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
103
|
+
addDays: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
104
|
+
addHours: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
105
|
+
addMinutes: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
106
|
+
addSeconds: (value: Dayjs, amount: number) => dayjs.Dayjs;
|
|
109
107
|
getYear: (value: Dayjs) => number;
|
|
110
108
|
getMonth: (value: Dayjs) => number;
|
|
111
109
|
getDate: (value: Dayjs) => number;
|
|
@@ -113,17 +111,16 @@ export declare class AdapterDayjs implements MuiPickersAdapter<string> {
|
|
|
113
111
|
getMinutes: (value: Dayjs) => number;
|
|
114
112
|
getSeconds: (value: Dayjs) => number;
|
|
115
113
|
getMilliseconds: (value: Dayjs) => number;
|
|
116
|
-
setYear: (value: Dayjs, year: number) =>
|
|
117
|
-
setMonth: (value: Dayjs, month: number) =>
|
|
118
|
-
setDate: (value: Dayjs, date: number) =>
|
|
119
|
-
setHours: (value: Dayjs, hours: number) =>
|
|
120
|
-
setMinutes: (value: Dayjs, minutes: number) =>
|
|
121
|
-
setSeconds: (value: Dayjs, seconds: number) =>
|
|
122
|
-
setMilliseconds: (value: Dayjs, milliseconds: number) =>
|
|
114
|
+
setYear: (value: Dayjs, year: number) => dayjs.Dayjs;
|
|
115
|
+
setMonth: (value: Dayjs, month: number) => dayjs.Dayjs;
|
|
116
|
+
setDate: (value: Dayjs, date: number) => dayjs.Dayjs;
|
|
117
|
+
setHours: (value: Dayjs, hours: number) => dayjs.Dayjs;
|
|
118
|
+
setMinutes: (value: Dayjs, minutes: number) => dayjs.Dayjs;
|
|
119
|
+
setSeconds: (value: Dayjs, seconds: number) => dayjs.Dayjs;
|
|
120
|
+
setMilliseconds: (value: Dayjs, milliseconds: number) => dayjs.Dayjs;
|
|
123
121
|
getDaysInMonth: (value: Dayjs) => number;
|
|
124
|
-
getWeekArray: (value: Dayjs) =>
|
|
122
|
+
getWeekArray: (value: Dayjs) => dayjs.Dayjs[][];
|
|
125
123
|
getWeekNumber: (value: Dayjs) => number;
|
|
126
124
|
getDayOfWeek(value: Dayjs): number;
|
|
127
|
-
getYearRange: ([start, end]: [Dayjs, Dayjs]) =>
|
|
128
|
-
}
|
|
129
|
-
export {};
|
|
125
|
+
getYearRange: ([start, end]: [Dayjs, Dayjs]) => dayjs.Dayjs[];
|
|
126
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
/* eslint-disable class-methods-use-this */
|
|
3
3
|
/* v8 ignore start */
|
|
4
|
-
import
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
5
|
// dayjs has no exports field defined
|
|
6
6
|
// See https://github.com/iamkun/dayjs/issues/2562
|
|
7
7
|
/* eslint-disable import/extensions */
|
|
@@ -13,10 +13,10 @@ import advancedFormatPlugin from 'dayjs/plugin/advancedFormat.js';
|
|
|
13
13
|
/* v8 ignore stop */
|
|
14
14
|
/* eslint-enable import/extensions */
|
|
15
15
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
dayjs.extend(localizedFormatPlugin);
|
|
17
|
+
dayjs.extend(weekOfYearPlugin);
|
|
18
|
+
dayjs.extend(isBetweenPlugin);
|
|
19
|
+
dayjs.extend(advancedFormatPlugin);
|
|
20
20
|
const formatTokenMap = {
|
|
21
21
|
// Year
|
|
22
22
|
YY: 'year',
|
|
@@ -125,7 +125,6 @@ const defaultFormats = {
|
|
|
125
125
|
};
|
|
126
126
|
const MISSING_UTC_PLUGIN = ['Missing UTC plugin', 'To be able to use UTC or timezones, you have to enable the `utc` plugin', 'Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc'].join('\n');
|
|
127
127
|
const MISSING_TIMEZONE_PLUGIN = ['Missing timezone plugin', 'To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin', 'Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone'].join('\n');
|
|
128
|
-
const withLocale = (dayjs, locale) => !locale ? dayjs : (...args) => dayjs(...args).locale(locale);
|
|
129
128
|
/**
|
|
130
129
|
* Based on `@date-io/dayjs`
|
|
131
130
|
*
|
|
@@ -159,7 +158,6 @@ export class AdapterDayjs {
|
|
|
159
158
|
this.isMUIAdapter = true;
|
|
160
159
|
this.isTimezoneCompatible = true;
|
|
161
160
|
this.lib = 'dayjs';
|
|
162
|
-
this.dayjs = void 0;
|
|
163
161
|
this.locale = void 0;
|
|
164
162
|
this.formats = void 0;
|
|
165
163
|
this.escapedCharacters = {
|
|
@@ -174,8 +172,8 @@ export class AdapterDayjs {
|
|
|
174
172
|
}
|
|
175
173
|
return value.locale(expectedLocale);
|
|
176
174
|
};
|
|
177
|
-
this.hasUTCPlugin = () => typeof
|
|
178
|
-
this.hasTimezonePlugin = () => typeof
|
|
175
|
+
this.hasUTCPlugin = () => typeof dayjs.utc !== 'undefined';
|
|
176
|
+
this.hasTimezonePlugin = () => typeof dayjs.tz !== 'undefined';
|
|
179
177
|
this.isSame = (value, comparing, comparisonTemplate) => {
|
|
180
178
|
const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
|
|
181
179
|
return value.format(comparisonTemplate) === comparingInValueTimezone.format(comparisonTemplate);
|
|
@@ -191,7 +189,7 @@ export class AdapterDayjs {
|
|
|
191
189
|
}
|
|
192
190
|
case 'system':
|
|
193
191
|
{
|
|
194
|
-
return
|
|
192
|
+
return dayjs.tz.guess();
|
|
195
193
|
}
|
|
196
194
|
default:
|
|
197
195
|
{
|
|
@@ -200,24 +198,26 @@ export class AdapterDayjs {
|
|
|
200
198
|
}
|
|
201
199
|
};
|
|
202
200
|
this.createSystemDate = value => {
|
|
201
|
+
let date;
|
|
203
202
|
if (this.hasUTCPlugin() && this.hasTimezonePlugin()) {
|
|
204
|
-
const timezone =
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
/* v8 ignore next 3 */
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
const timezone = dayjs.tz.guess();
|
|
204
|
+
if (timezone === 'UTC') {
|
|
205
|
+
date = dayjs(value);
|
|
206
|
+
} /* v8 ignore next 3 */else {
|
|
207
|
+
// We can't change the system timezone in the tests
|
|
208
|
+
date = dayjs.tz(value, timezone);
|
|
210
209
|
}
|
|
211
|
-
|
|
210
|
+
} else {
|
|
211
|
+
date = dayjs(value);
|
|
212
212
|
}
|
|
213
|
-
return
|
|
213
|
+
return this.setLocaleToValue(date);
|
|
214
214
|
};
|
|
215
215
|
this.createUTCDate = value => {
|
|
216
216
|
/* v8 ignore next 3 */
|
|
217
217
|
if (!this.hasUTCPlugin()) {
|
|
218
218
|
throw new Error(MISSING_UTC_PLUGIN);
|
|
219
219
|
}
|
|
220
|
-
return
|
|
220
|
+
return this.setLocaleToValue(dayjs.utc(value));
|
|
221
221
|
};
|
|
222
222
|
this.createTZDate = (value, timezone) => {
|
|
223
223
|
/* v8 ignore next 3 */
|
|
@@ -230,10 +230,10 @@ export class AdapterDayjs {
|
|
|
230
230
|
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
231
231
|
}
|
|
232
232
|
const keepLocalTime = value !== undefined && !value.endsWith('Z');
|
|
233
|
-
return
|
|
233
|
+
return this.setLocaleToValue(dayjs(value).tz(this.cleanTimezone(timezone), keepLocalTime));
|
|
234
234
|
};
|
|
235
235
|
this.getLocaleFormats = () => {
|
|
236
|
-
const locales =
|
|
236
|
+
const locales = dayjs.Ls;
|
|
237
237
|
const locale = this.locale || 'en';
|
|
238
238
|
let localeObject = locales[locale];
|
|
239
239
|
if (localeObject === undefined) {
|
|
@@ -277,20 +277,15 @@ export class AdapterDayjs {
|
|
|
277
277
|
if (value === null) {
|
|
278
278
|
return null;
|
|
279
279
|
}
|
|
280
|
-
let parsedValue;
|
|
281
280
|
if (timezone === 'UTC') {
|
|
282
|
-
|
|
283
|
-
} else if (timezone === 'system' || timezone === 'default' && !this.hasTimezonePlugin()) {
|
|
284
|
-
parsedValue = this.createSystemDate(value);
|
|
285
|
-
} else {
|
|
286
|
-
parsedValue = this.createTZDate(value, timezone);
|
|
281
|
+
return this.createUTCDate(value);
|
|
287
282
|
}
|
|
288
|
-
if (
|
|
289
|
-
return
|
|
283
|
+
if (timezone === 'system' || timezone === 'default' && !this.hasTimezonePlugin()) {
|
|
284
|
+
return this.createSystemDate(value);
|
|
290
285
|
}
|
|
291
|
-
return
|
|
286
|
+
return this.createTZDate(value, timezone);
|
|
292
287
|
};
|
|
293
|
-
this.getInvalidDate = () =>
|
|
288
|
+
this.getInvalidDate = () => dayjs(new Date('Invalid date'));
|
|
294
289
|
this.getTimezone = value => {
|
|
295
290
|
if (this.hasTimezonePlugin()) {
|
|
296
291
|
// @ts-ignore
|
|
@@ -330,7 +325,7 @@ export class AdapterDayjs {
|
|
|
330
325
|
/* v8 ignore next */
|
|
331
326
|
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
332
327
|
}
|
|
333
|
-
return
|
|
328
|
+
return this.setLocaleToValue(dayjs.tz(value, this.cleanTimezone(timezone)));
|
|
334
329
|
};
|
|
335
330
|
this.toJsDate = value => {
|
|
336
331
|
return value.toDate();
|
|
@@ -339,7 +334,7 @@ export class AdapterDayjs {
|
|
|
339
334
|
if (value === '') {
|
|
340
335
|
return null;
|
|
341
336
|
}
|
|
342
|
-
return
|
|
337
|
+
return dayjs(value, format, this.locale, true);
|
|
343
338
|
};
|
|
344
339
|
this.getCurrentLocaleCode = () => {
|
|
345
340
|
return this.locale || 'en';
|
|
@@ -368,7 +363,7 @@ export class AdapterDayjs {
|
|
|
368
363
|
return this.formatByString(value, this.formats[formatKey]);
|
|
369
364
|
};
|
|
370
365
|
this.formatByString = (value, formatString) => {
|
|
371
|
-
return this.
|
|
366
|
+
return this.setLocaleToValue(value).format(formatString);
|
|
372
367
|
};
|
|
373
368
|
this.formatNumber = numberToFormat => {
|
|
374
369
|
return numberToFormat;
|
|
@@ -452,25 +447,25 @@ export class AdapterDayjs {
|
|
|
452
447
|
return this.adjustOffset(value.endOf('day'));
|
|
453
448
|
};
|
|
454
449
|
this.addYears = (value, amount) => {
|
|
455
|
-
return this.adjustOffset(
|
|
450
|
+
return this.adjustOffset(value.add(amount, 'year'));
|
|
456
451
|
};
|
|
457
452
|
this.addMonths = (value, amount) => {
|
|
458
|
-
return this.adjustOffset(
|
|
453
|
+
return this.adjustOffset(value.add(amount, 'month'));
|
|
459
454
|
};
|
|
460
455
|
this.addWeeks = (value, amount) => {
|
|
461
|
-
return this.adjustOffset(
|
|
456
|
+
return this.adjustOffset(value.add(amount, 'week'));
|
|
462
457
|
};
|
|
463
458
|
this.addDays = (value, amount) => {
|
|
464
|
-
return this.adjustOffset(
|
|
459
|
+
return this.adjustOffset(value.add(amount, 'day'));
|
|
465
460
|
};
|
|
466
461
|
this.addHours = (value, amount) => {
|
|
467
|
-
return this.adjustOffset(
|
|
462
|
+
return this.adjustOffset(value.add(amount, 'hour'));
|
|
468
463
|
};
|
|
469
464
|
this.addMinutes = (value, amount) => {
|
|
470
|
-
return this.adjustOffset(
|
|
465
|
+
return this.adjustOffset(value.add(amount, 'minute'));
|
|
471
466
|
};
|
|
472
467
|
this.addSeconds = (value, amount) => {
|
|
473
|
-
return this.adjustOffset(
|
|
468
|
+
return this.adjustOffset(value.add(amount, 'second'));
|
|
474
469
|
};
|
|
475
470
|
this.getYear = value => {
|
|
476
471
|
return value.year();
|
|
@@ -546,13 +541,12 @@ export class AdapterDayjs {
|
|
|
546
541
|
}
|
|
547
542
|
return years;
|
|
548
543
|
};
|
|
549
|
-
this.dayjs = withLocale(defaultDayjs, _locale);
|
|
550
544
|
this.locale = _locale;
|
|
551
545
|
this.formats = _extends({}, defaultFormats, formats);
|
|
552
546
|
|
|
553
547
|
// Moved plugins to the constructor to allow for users to use options on the library
|
|
554
548
|
// for reference: https://github.com/mui/mui-x/pull/11151
|
|
555
|
-
|
|
549
|
+
dayjs.extend(customParseFormatPlugin);
|
|
556
550
|
}
|
|
557
551
|
getDayOfWeek(value) {
|
|
558
552
|
return value.day() + 1;
|
|
@@ -459,7 +459,7 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
459
459
|
onChange: PropTypes.func,
|
|
460
460
|
/**
|
|
461
461
|
* Callback fired on focused view change.
|
|
462
|
-
* @template TView
|
|
462
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
463
463
|
* @param {TView} view The new view to focus or not.
|
|
464
464
|
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
465
465
|
*/
|
|
@@ -471,7 +471,7 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
471
471
|
onMonthChange: PropTypes.func,
|
|
472
472
|
/**
|
|
473
473
|
* Callback fired on view change.
|
|
474
|
-
* @template TView
|
|
474
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
475
475
|
* @param {TView} view The new view.
|
|
476
476
|
*/
|
|
477
477
|
onViewChange: PropTypes.func,
|
|
@@ -219,7 +219,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
219
219
|
onSelectedSectionsChange: PropTypes.func,
|
|
220
220
|
/**
|
|
221
221
|
* Callback fired on view change.
|
|
222
|
-
* @template TView
|
|
222
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
223
223
|
* @param {TView} view The new view.
|
|
224
224
|
*/
|
|
225
225
|
onViewChange: PropTypes.func,
|
|
@@ -257,7 +257,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
257
257
|
onSelectedSectionsChange: PropTypes.func,
|
|
258
258
|
/**
|
|
259
259
|
* Callback fired on view change.
|
|
260
|
-
* @template TView
|
|
260
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
261
261
|
* @param {TView} view The new view.
|
|
262
262
|
*/
|
|
263
263
|
onViewChange: PropTypes.func,
|
|
@@ -378,8 +378,8 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
378
378
|
thresholdToRenderTimeInASingleColumn: PropTypes.number,
|
|
379
379
|
/**
|
|
380
380
|
* The time steps between two time unit options.
|
|
381
|
-
* For example, if `
|
|
382
|
-
* When single column time renderer is used, only `
|
|
381
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
382
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
383
383
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
384
384
|
*/
|
|
385
385
|
timeSteps: PropTypes.shape({
|
|
@@ -230,7 +230,7 @@ DesktopDatePicker.propTypes = {
|
|
|
230
230
|
onSelectedSectionsChange: PropTypes.func,
|
|
231
231
|
/**
|
|
232
232
|
* Callback fired on view change.
|
|
233
|
-
* @template TView
|
|
233
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
234
234
|
* @param {TView} view The new view.
|
|
235
235
|
*/
|
|
236
236
|
onViewChange: PropTypes.func,
|
|
@@ -350,7 +350,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
350
350
|
onSelectedSectionsChange: PropTypes.func,
|
|
351
351
|
/**
|
|
352
352
|
* Callback fired on view change.
|
|
353
|
-
* @template TView
|
|
353
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
354
354
|
* @param {TView} view The new view.
|
|
355
355
|
*/
|
|
356
356
|
onViewChange: PropTypes.func,
|
|
@@ -471,8 +471,8 @@ DesktopDateTimePicker.propTypes = {
|
|
|
471
471
|
thresholdToRenderTimeInASingleColumn: PropTypes.number,
|
|
472
472
|
/**
|
|
473
473
|
* The time steps between two time unit options.
|
|
474
|
-
* For example, if `
|
|
475
|
-
* When single column time renderer is used, only `
|
|
474
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
475
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
476
476
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
477
477
|
*/
|
|
478
478
|
timeSteps: PropTypes.shape({
|
|
@@ -229,7 +229,7 @@ DesktopTimePicker.propTypes = {
|
|
|
229
229
|
onSelectedSectionsChange: PropTypes.func,
|
|
230
230
|
/**
|
|
231
231
|
* Callback fired on view change.
|
|
232
|
-
* @template TView
|
|
232
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
233
233
|
* @param {TView} view The new view.
|
|
234
234
|
*/
|
|
235
235
|
onViewChange: PropTypes.func,
|
|
@@ -307,8 +307,8 @@ DesktopTimePicker.propTypes = {
|
|
|
307
307
|
thresholdToRenderTimeInASingleColumn: PropTypes.number,
|
|
308
308
|
/**
|
|
309
309
|
* The time steps between two time unit options.
|
|
310
|
-
* For example, if `
|
|
311
|
-
* When single column time renderer is used, only `
|
|
310
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
311
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
312
312
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
313
313
|
*/
|
|
314
314
|
timeSteps: PropTypes.shape({
|
|
@@ -393,14 +393,14 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
393
393
|
onChange: PropTypes.func,
|
|
394
394
|
/**
|
|
395
395
|
* Callback fired on focused view change.
|
|
396
|
-
* @template TView
|
|
396
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
397
397
|
* @param {TView} view The new view to focus or not.
|
|
398
398
|
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
399
399
|
*/
|
|
400
400
|
onFocusedViewChange: PropTypes.func,
|
|
401
401
|
/**
|
|
402
402
|
* Callback fired on view change.
|
|
403
|
-
* @template TView
|
|
403
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
404
404
|
* @param {TView} view The new view.
|
|
405
405
|
*/
|
|
406
406
|
onViewChange: PropTypes.func,
|
|
@@ -228,7 +228,7 @@ MobileDatePicker.propTypes = {
|
|
|
228
228
|
onSelectedSectionsChange: PropTypes.func,
|
|
229
229
|
/**
|
|
230
230
|
* Callback fired on view change.
|
|
231
|
-
* @template TView
|
|
231
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
232
232
|
* @param {TView} view The new view.
|
|
233
233
|
*/
|
|
234
234
|
onViewChange: PropTypes.func,
|
|
@@ -316,7 +316,7 @@ MobileDateTimePicker.propTypes = {
|
|
|
316
316
|
onSelectedSectionsChange: PropTypes.func,
|
|
317
317
|
/**
|
|
318
318
|
* Callback fired on view change.
|
|
319
|
-
* @template TView
|
|
319
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
320
320
|
* @param {TView} view The new view.
|
|
321
321
|
*/
|
|
322
322
|
onViewChange: PropTypes.func,
|
|
@@ -437,8 +437,8 @@ MobileDateTimePicker.propTypes = {
|
|
|
437
437
|
thresholdToRenderTimeInASingleColumn: PropTypes.number,
|
|
438
438
|
/**
|
|
439
439
|
* The time steps between two time unit options.
|
|
440
|
-
* For example, if `
|
|
441
|
-
* When single column time renderer is used, only `
|
|
440
|
+
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
441
|
+
* When single column time renderer is used, only `timeSteps.minutes` will be used.
|
|
442
442
|
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
443
443
|
*/
|
|
444
444
|
timeSteps: PropTypes.shape({
|
|
@@ -214,7 +214,7 @@ MobileTimePicker.propTypes = {
|
|
|
214
214
|
onSelectedSectionsChange: PropTypes.func,
|
|
215
215
|
/**
|
|
216
216
|
* Callback fired on view change.
|
|
217
|
-
* @template TView
|
|
217
|
+
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
|
|
218
218
|
* @param {TView} view The new view.
|
|
219
219
|
*/
|
|
220
220
|
onViewChange: PropTypes.func,
|