@mui/x-date-pickers 6.18.7 → 6.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterDateFns/AdapterDateFns.d.ts +4 -24
- package/AdapterDateFns/AdapterDateFns.js +11 -272
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +358 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/AdapterLuxon/AdapterLuxon.js +0 -1
- package/CHANGELOG.md +106 -0
- package/DateCalendar/useCalendarState.js +0 -1
- package/DatePicker/DatePickerToolbar.d.ts +2 -2
- package/DatePicker/DatePickerToolbar.js +2 -7
- package/DateTimePicker/DateTimePickerTabs.js +6 -3
- package/DigitalClock/DigitalClock.js +1 -0
- package/DigitalClock/DigitalClock.types.d.ts +5 -0
- package/MonthCalendar/MonthCalendar.js +0 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
- package/PickersLayout/pickersLayoutClasses.js +3 -2
- package/PickersLayout/usePickerLayout.js +2 -1
- package/TimeClock/Clock.js +0 -1
- package/TimeClock/ClockPointer.js +0 -1
- package/TimeClock/TimeClock.js +1 -0
- package/TimeClock/TimeClock.types.d.ts +5 -0
- package/YearCalendar/YearCalendar.js +0 -1
- package/hooks/useClearableField.d.ts +1 -1
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/hooks/useClockReferenceDate.js +0 -1
- package/internals/hooks/useField/useField.utils.js +0 -2
- package/internals/hooks/useViews.js +0 -1
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/props/tabs.d.ts +1 -0
- package/legacy/AdapterDateFns/AdapterDateFns.js +278 -529
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/AdapterLuxon/AdapterLuxon.js +0 -1
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
- package/legacy/DateCalendar/PickersSlideTransition.js +8 -9
- package/legacy/DateCalendar/useCalendarState.js +0 -1
- package/legacy/DatePicker/DatePickerToolbar.js +2 -7
- package/legacy/DateTimePicker/DateTimePickerTabs.js +6 -3
- package/legacy/DigitalClock/DigitalClock.js +1 -0
- package/legacy/MonthCalendar/MonthCalendar.js +0 -1
- package/legacy/MonthCalendar/PickersMonth.js +4 -5
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/legacy/PickersDay/PickersDay.js +5 -6
- package/legacy/PickersLayout/PickersLayout.js +5 -6
- package/legacy/PickersLayout/pickersLayoutClasses.js +3 -2
- package/legacy/PickersLayout/usePickerLayout.js +2 -1
- package/legacy/TimeClock/Clock.js +0 -1
- package/legacy/TimeClock/ClockNumber.js +4 -5
- package/legacy/TimeClock/ClockPointer.js +0 -1
- package/legacy/TimeClock/TimeClock.js +1 -0
- package/legacy/TimePicker/TimePickerToolbar.js +1 -2
- package/legacy/YearCalendar/PickersYear.js +4 -5
- package/legacy/YearCalendar/YearCalendar.js +0 -1
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersModalDialog.js +3 -4
- package/legacy/internals/hooks/useClockReferenceDate.js +0 -1
- package/legacy/internals/hooks/useField/useField.utils.js +0 -2
- package/legacy/internals/hooks/useViews.js +0 -1
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/plPL.js +0 -1
- package/legacy/locales/svSE.js +0 -1
- package/legacy/locales/urPK.js +0 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/plPL.js +0 -1
- package/locales/svSE.js +0 -1
- package/locales/urPK.js +0 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +358 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/AdapterLuxon/AdapterLuxon.js +0 -1
- package/modern/DateCalendar/useCalendarState.js +0 -1
- package/modern/DatePicker/DatePickerToolbar.js +2 -7
- package/modern/DateTimePicker/DateTimePickerTabs.js +6 -3
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +0 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersLayout/pickersLayoutClasses.js +3 -2
- package/modern/PickersLayout/usePickerLayout.js +2 -1
- package/modern/TimeClock/Clock.js +0 -1
- package/modern/TimeClock/ClockPointer.js +0 -1
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/YearCalendar/YearCalendar.js +0 -1
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useClockReferenceDate.js +0 -1
- package/modern/internals/hooks/useField/useField.utils.js +0 -2
- package/modern/internals/hooks/useViews.js +0 -1
- package/modern/locales/index.js +1 -0
- package/modern/locales/plPL.js +0 -1
- package/modern/locales/svSE.js +0 -1
- package/modern/locales/urPK.js +0 -1
- package/node/AdapterDateFns/AdapterDateFns.js +11 -271
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/AdapterLuxon/AdapterLuxon.js +0 -1
- package/node/DateCalendar/useCalendarState.js +0 -1
- package/node/DatePicker/DatePickerToolbar.js +0 -4
- package/node/DateTimePicker/DateTimePickerTabs.js +7 -4
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/MonthCalendar/MonthCalendar.js +0 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersLayout/pickersLayoutClasses.js +5 -3
- package/node/PickersLayout/usePickerLayout.js +2 -1
- package/node/TimeClock/Clock.js +0 -1
- package/node/TimeClock/ClockPointer.js +0 -1
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/YearCalendar/YearCalendar.js +0 -1
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/hooks/useClockReferenceDate.js +0 -1
- package/node/internals/hooks/useField/useField.utils.js +0 -2
- package/node/internals/hooks/useViews.js +0 -1
- package/node/locales/index.js +11 -0
- package/node/locales/plPL.js +0 -1
- package/node/locales/svSE.js +0 -1
- package/node/locales/urPK.js +0 -1
- package/package.json +2 -2
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
// TODO remove when date-fns-v3 is the default
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
import { addDays } from 'date-fns/addDays';
|
|
5
|
+
import { addSeconds } from 'date-fns/addSeconds';
|
|
6
|
+
import { addMinutes } from 'date-fns/addMinutes';
|
|
7
|
+
import { addHours } from 'date-fns/addHours';
|
|
8
|
+
import { addWeeks } from 'date-fns/addWeeks';
|
|
9
|
+
import { addMonths } from 'date-fns/addMonths';
|
|
10
|
+
import { addYears } from 'date-fns/addYears';
|
|
11
|
+
import { differenceInYears } from 'date-fns/differenceInYears';
|
|
12
|
+
import { differenceInQuarters } from 'date-fns/differenceInQuarters';
|
|
13
|
+
import { differenceInMonths } from 'date-fns/differenceInMonths';
|
|
14
|
+
import { differenceInWeeks } from 'date-fns/differenceInWeeks';
|
|
15
|
+
import { differenceInDays } from 'date-fns/differenceInDays';
|
|
16
|
+
import { differenceInHours } from 'date-fns/differenceInHours';
|
|
17
|
+
import { differenceInMinutes } from 'date-fns/differenceInMinutes';
|
|
18
|
+
import { differenceInSeconds } from 'date-fns/differenceInSeconds';
|
|
19
|
+
import { differenceInMilliseconds } from 'date-fns/differenceInMilliseconds';
|
|
20
|
+
import { eachDayOfInterval } from 'date-fns/eachDayOfInterval';
|
|
21
|
+
import { endOfDay } from 'date-fns/endOfDay';
|
|
22
|
+
import { endOfWeek } from 'date-fns/endOfWeek';
|
|
23
|
+
import { endOfYear } from 'date-fns/endOfYear';
|
|
24
|
+
// @ts-ignore TODO remove when date-fns-v3 is the default
|
|
25
|
+
import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
|
|
26
|
+
import { getDate } from 'date-fns/getDate';
|
|
27
|
+
import { getDaysInMonth } from 'date-fns/getDaysInMonth';
|
|
28
|
+
import { getHours } from 'date-fns/getHours';
|
|
29
|
+
import { getMinutes } from 'date-fns/getMinutes';
|
|
30
|
+
import { getMonth } from 'date-fns/getMonth';
|
|
31
|
+
import { getSeconds } from 'date-fns/getSeconds';
|
|
32
|
+
import { getMilliseconds } from 'date-fns/getMilliseconds';
|
|
33
|
+
import { getWeek } from 'date-fns/getWeek';
|
|
34
|
+
import { getYear } from 'date-fns/getYear';
|
|
35
|
+
import { isAfter } from 'date-fns/isAfter';
|
|
36
|
+
import { isBefore } from 'date-fns/isBefore';
|
|
37
|
+
import { isEqual } from 'date-fns/isEqual';
|
|
38
|
+
import { isSameDay } from 'date-fns/isSameDay';
|
|
39
|
+
import { isSameYear } from 'date-fns/isSameYear';
|
|
40
|
+
import { isSameMonth } from 'date-fns/isSameMonth';
|
|
41
|
+
import { isSameHour } from 'date-fns/isSameHour';
|
|
42
|
+
import { isValid } from 'date-fns/isValid';
|
|
43
|
+
import { parse as dateFnsParse } from 'date-fns/parse';
|
|
44
|
+
import { setDate } from 'date-fns/setDate';
|
|
45
|
+
import { setHours } from 'date-fns/setHours';
|
|
46
|
+
import { setMinutes } from 'date-fns/setMinutes';
|
|
47
|
+
import { setMonth } from 'date-fns/setMonth';
|
|
48
|
+
import { setSeconds } from 'date-fns/setSeconds';
|
|
49
|
+
import { setMilliseconds } from 'date-fns/setMilliseconds';
|
|
50
|
+
import { setYear } from 'date-fns/setYear';
|
|
51
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
52
|
+
import { startOfMonth } from 'date-fns/startOfMonth';
|
|
53
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
54
|
+
import { startOfWeek } from 'date-fns/startOfWeek';
|
|
55
|
+
import { startOfYear } from 'date-fns/startOfYear';
|
|
56
|
+
import { formatISO } from 'date-fns/formatISO';
|
|
57
|
+
import { parseISO } from 'date-fns/parseISO';
|
|
58
|
+
import { isWithinInterval } from 'date-fns/isWithinInterval';
|
|
59
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
60
|
+
// date-fns v2 does not export types
|
|
61
|
+
// @ts-ignore TODO remove when date-fns-v3 is the default
|
|
62
|
+
|
|
63
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Based on `@date-io/date-fns`
|
|
67
|
+
*
|
|
68
|
+
* MIT License
|
|
69
|
+
*
|
|
70
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
71
|
+
*
|
|
72
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
73
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
74
|
+
* in the Software without restriction, including without limitation the rights
|
|
75
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
77
|
+
* furnished to do so, subject to the following conditions:
|
|
78
|
+
*
|
|
79
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
80
|
+
* copies or substantial portions of the Software.
|
|
81
|
+
*
|
|
82
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
83
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
84
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
85
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
86
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
87
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
88
|
+
* SOFTWARE.
|
|
89
|
+
*/
|
|
90
|
+
export class AdapterDateFns extends AdapterDateFnsBase {
|
|
91
|
+
constructor({
|
|
92
|
+
locale,
|
|
93
|
+
formats
|
|
94
|
+
} = {}) {
|
|
95
|
+
if (typeof addDays !== 'function') {
|
|
96
|
+
throw new Error([`MUI: The \`date-fns\` package v2.x is not compatible with this adapter.`, 'Please, install v3.x of the package or use the `AdapterDateFns` instead.'].join('\n'));
|
|
97
|
+
}
|
|
98
|
+
if (!longFormatters) {
|
|
99
|
+
throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
|
|
100
|
+
}
|
|
101
|
+
super({
|
|
102
|
+
locale: locale ?? enUS,
|
|
103
|
+
formats,
|
|
104
|
+
longFormatters
|
|
105
|
+
});
|
|
106
|
+
this.parseISO = isoString => {
|
|
107
|
+
return parseISO(isoString);
|
|
108
|
+
};
|
|
109
|
+
this.toISO = value => {
|
|
110
|
+
return formatISO(value, {
|
|
111
|
+
format: 'extended'
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
this.parse = (value, format) => {
|
|
115
|
+
if (value === '') {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return dateFnsParse(value, format, new Date(), {
|
|
119
|
+
locale: this.locale
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
this.isValid = value => {
|
|
123
|
+
return isValid(this.date(value));
|
|
124
|
+
};
|
|
125
|
+
this.format = (value, formatKey) => {
|
|
126
|
+
return this.formatByString(value, this.formats[formatKey]);
|
|
127
|
+
};
|
|
128
|
+
this.formatByString = (value, formatString) => {
|
|
129
|
+
return dateFnsFormat(value, formatString, {
|
|
130
|
+
locale: this.locale
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
this.getDiff = (value, comparing, unit) => {
|
|
134
|
+
switch (unit) {
|
|
135
|
+
case 'years':
|
|
136
|
+
return differenceInYears(value, this.date(comparing));
|
|
137
|
+
case 'quarters':
|
|
138
|
+
return differenceInQuarters(value, this.date(comparing));
|
|
139
|
+
case 'months':
|
|
140
|
+
return differenceInMonths(value, this.date(comparing));
|
|
141
|
+
case 'weeks':
|
|
142
|
+
return differenceInWeeks(value, this.date(comparing));
|
|
143
|
+
case 'days':
|
|
144
|
+
return differenceInDays(value, this.date(comparing));
|
|
145
|
+
case 'hours':
|
|
146
|
+
return differenceInHours(value, this.date(comparing));
|
|
147
|
+
case 'minutes':
|
|
148
|
+
return differenceInMinutes(value, this.date(comparing));
|
|
149
|
+
case 'seconds':
|
|
150
|
+
return differenceInSeconds(value, this.date(comparing));
|
|
151
|
+
default:
|
|
152
|
+
{
|
|
153
|
+
return differenceInMilliseconds(value, this.date(comparing));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
this.isEqual = (value, comparing) => {
|
|
158
|
+
if (value === null && comparing === null) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return isEqual(value, comparing);
|
|
162
|
+
};
|
|
163
|
+
this.isSameYear = (value, comparing) => {
|
|
164
|
+
return isSameYear(value, comparing);
|
|
165
|
+
};
|
|
166
|
+
this.isSameMonth = (value, comparing) => {
|
|
167
|
+
return isSameMonth(value, comparing);
|
|
168
|
+
};
|
|
169
|
+
this.isSameDay = (value, comparing) => {
|
|
170
|
+
return isSameDay(value, comparing);
|
|
171
|
+
};
|
|
172
|
+
this.isSameHour = (value, comparing) => {
|
|
173
|
+
return isSameHour(value, comparing);
|
|
174
|
+
};
|
|
175
|
+
this.isAfter = (value, comparing) => {
|
|
176
|
+
return isAfter(value, comparing);
|
|
177
|
+
};
|
|
178
|
+
this.isAfterYear = (value, comparing) => {
|
|
179
|
+
return isAfter(value, endOfYear(comparing));
|
|
180
|
+
};
|
|
181
|
+
this.isAfterDay = (value, comparing) => {
|
|
182
|
+
return isAfter(value, endOfDay(comparing));
|
|
183
|
+
};
|
|
184
|
+
this.isBefore = (value, comparing) => {
|
|
185
|
+
return isBefore(value, comparing);
|
|
186
|
+
};
|
|
187
|
+
this.isBeforeYear = (value, comparing) => {
|
|
188
|
+
return isBefore(value, this.startOfYear(comparing));
|
|
189
|
+
};
|
|
190
|
+
this.isBeforeDay = (value, comparing) => {
|
|
191
|
+
return isBefore(value, this.startOfDay(comparing));
|
|
192
|
+
};
|
|
193
|
+
this.isWithinRange = (value, [start, end]) => {
|
|
194
|
+
return isWithinInterval(value, {
|
|
195
|
+
start,
|
|
196
|
+
end
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
this.startOfYear = value => {
|
|
200
|
+
return startOfYear(value);
|
|
201
|
+
};
|
|
202
|
+
this.startOfMonth = value => {
|
|
203
|
+
return startOfMonth(value);
|
|
204
|
+
};
|
|
205
|
+
this.startOfWeek = value => {
|
|
206
|
+
return startOfWeek(value, {
|
|
207
|
+
locale: this.locale
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
this.startOfDay = value => {
|
|
211
|
+
return startOfDay(value);
|
|
212
|
+
};
|
|
213
|
+
this.endOfYear = value => {
|
|
214
|
+
return endOfYear(value);
|
|
215
|
+
};
|
|
216
|
+
this.endOfMonth = value => {
|
|
217
|
+
return endOfMonth(value);
|
|
218
|
+
};
|
|
219
|
+
this.endOfWeek = value => {
|
|
220
|
+
return endOfWeek(value, {
|
|
221
|
+
locale: this.locale
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
this.endOfDay = value => {
|
|
225
|
+
return endOfDay(value);
|
|
226
|
+
};
|
|
227
|
+
this.addYears = (value, amount) => {
|
|
228
|
+
return addYears(value, amount);
|
|
229
|
+
};
|
|
230
|
+
this.addMonths = (value, amount) => {
|
|
231
|
+
return addMonths(value, amount);
|
|
232
|
+
};
|
|
233
|
+
this.addWeeks = (value, amount) => {
|
|
234
|
+
return addWeeks(value, amount);
|
|
235
|
+
};
|
|
236
|
+
this.addDays = (value, amount) => {
|
|
237
|
+
return addDays(value, amount);
|
|
238
|
+
};
|
|
239
|
+
this.addHours = (value, amount) => {
|
|
240
|
+
return addHours(value, amount);
|
|
241
|
+
};
|
|
242
|
+
this.addMinutes = (value, amount) => {
|
|
243
|
+
return addMinutes(value, amount);
|
|
244
|
+
};
|
|
245
|
+
this.addSeconds = (value, amount) => {
|
|
246
|
+
return addSeconds(value, amount);
|
|
247
|
+
};
|
|
248
|
+
this.getYear = value => {
|
|
249
|
+
return getYear(value);
|
|
250
|
+
};
|
|
251
|
+
this.getMonth = value => {
|
|
252
|
+
return getMonth(value);
|
|
253
|
+
};
|
|
254
|
+
this.getDate = value => {
|
|
255
|
+
return getDate(value);
|
|
256
|
+
};
|
|
257
|
+
this.getHours = value => {
|
|
258
|
+
return getHours(value);
|
|
259
|
+
};
|
|
260
|
+
this.getMinutes = value => {
|
|
261
|
+
return getMinutes(value);
|
|
262
|
+
};
|
|
263
|
+
this.getSeconds = value => {
|
|
264
|
+
return getSeconds(value);
|
|
265
|
+
};
|
|
266
|
+
this.getMilliseconds = value => {
|
|
267
|
+
return getMilliseconds(value);
|
|
268
|
+
};
|
|
269
|
+
this.setYear = (value, year) => {
|
|
270
|
+
return setYear(value, year);
|
|
271
|
+
};
|
|
272
|
+
this.setMonth = (value, month) => {
|
|
273
|
+
return setMonth(value, month);
|
|
274
|
+
};
|
|
275
|
+
this.setDate = (value, date) => {
|
|
276
|
+
return setDate(value, date);
|
|
277
|
+
};
|
|
278
|
+
this.setHours = (value, hours) => {
|
|
279
|
+
return setHours(value, hours);
|
|
280
|
+
};
|
|
281
|
+
this.setMinutes = (value, minutes) => {
|
|
282
|
+
return setMinutes(value, minutes);
|
|
283
|
+
};
|
|
284
|
+
this.setSeconds = (value, seconds) => {
|
|
285
|
+
return setSeconds(value, seconds);
|
|
286
|
+
};
|
|
287
|
+
this.setMilliseconds = (value, milliseconds) => {
|
|
288
|
+
return setMilliseconds(value, milliseconds);
|
|
289
|
+
};
|
|
290
|
+
this.getDaysInMonth = value => {
|
|
291
|
+
return getDaysInMonth(value);
|
|
292
|
+
};
|
|
293
|
+
this.getNextMonth = value => {
|
|
294
|
+
return addMonths(value, 1);
|
|
295
|
+
};
|
|
296
|
+
this.getPreviousMonth = value => {
|
|
297
|
+
return addMonths(value, -1);
|
|
298
|
+
};
|
|
299
|
+
this.getMonthArray = value => {
|
|
300
|
+
const firstMonth = startOfYear(value);
|
|
301
|
+
const monthArray = [firstMonth];
|
|
302
|
+
while (monthArray.length < 12) {
|
|
303
|
+
const prevMonth = monthArray[monthArray.length - 1];
|
|
304
|
+
monthArray.push(this.getNextMonth(prevMonth));
|
|
305
|
+
}
|
|
306
|
+
return monthArray;
|
|
307
|
+
};
|
|
308
|
+
this.mergeDateAndTime = (dateParam, timeParam) => {
|
|
309
|
+
return this.setSeconds(this.setMinutes(this.setHours(dateParam, this.getHours(timeParam)), this.getMinutes(timeParam)), this.getSeconds(timeParam));
|
|
310
|
+
};
|
|
311
|
+
this.getWeekdays = () => {
|
|
312
|
+
const now = new Date();
|
|
313
|
+
return eachDayOfInterval({
|
|
314
|
+
start: startOfWeek(now, {
|
|
315
|
+
locale: this.locale
|
|
316
|
+
}),
|
|
317
|
+
end: endOfWeek(now, {
|
|
318
|
+
locale: this.locale
|
|
319
|
+
})
|
|
320
|
+
}).map(day => this.formatByString(day, 'EEEEEE'));
|
|
321
|
+
};
|
|
322
|
+
this.getWeekArray = value => {
|
|
323
|
+
const start = startOfWeek(startOfMonth(value), {
|
|
324
|
+
locale: this.locale
|
|
325
|
+
});
|
|
326
|
+
const end = endOfWeek(endOfMonth(value), {
|
|
327
|
+
locale: this.locale
|
|
328
|
+
});
|
|
329
|
+
let count = 0;
|
|
330
|
+
let current = start;
|
|
331
|
+
const nestedWeeks = [];
|
|
332
|
+
while (isBefore(current, end)) {
|
|
333
|
+
const weekNumber = Math.floor(count / 7);
|
|
334
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
335
|
+
nestedWeeks[weekNumber].push(current);
|
|
336
|
+
current = addDays(current, 1);
|
|
337
|
+
count += 1;
|
|
338
|
+
}
|
|
339
|
+
return nestedWeeks;
|
|
340
|
+
};
|
|
341
|
+
this.getWeekNumber = value => {
|
|
342
|
+
return getWeek(value, {
|
|
343
|
+
locale: this.locale
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
this.getYearRange = (start, end) => {
|
|
347
|
+
const startDate = startOfYear(start);
|
|
348
|
+
const endDate = endOfYear(end);
|
|
349
|
+
const years = [];
|
|
350
|
+
let current = startDate;
|
|
351
|
+
while (isBefore(current, endDate)) {
|
|
352
|
+
years.push(current);
|
|
353
|
+
current = addYears(current, 1);
|
|
354
|
+
}
|
|
355
|
+
return years;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFns } from './AdapterDateFnsV3';
|
|
@@ -265,7 +265,6 @@ export class AdapterLuxon {
|
|
|
265
265
|
if (typeof Intl === 'undefined' || typeof Intl.DateTimeFormat === 'undefined') {
|
|
266
266
|
return true; // Luxon defaults to en-US if Intl not found
|
|
267
267
|
}
|
|
268
|
-
|
|
269
268
|
return Boolean(new Intl.DateTimeFormat(this.locale, {
|
|
270
269
|
hour: 'numeric'
|
|
271
270
|
})?.resolvedOptions()?.hour12);
|
|
@@ -70,7 +70,6 @@ export const useCalendarState = params => {
|
|
|
70
70
|
});
|
|
71
71
|
}, [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
72
72
|
);
|
|
73
|
-
|
|
74
73
|
const [calendarState, dispatch] = React.useReducer(reducerFn, {
|
|
75
74
|
isMonthSwitchingAnimating: false,
|
|
76
75
|
focusedDay: utils.isValid(value) ? value : now,
|
|
@@ -26,10 +26,6 @@ const DatePickerToolbarRoot = styled(PickersToolbar, {
|
|
|
26
26
|
slot: 'Root',
|
|
27
27
|
overridesResolver: (_, styles) => styles.root
|
|
28
28
|
})({});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @ignore - do not document.
|
|
32
|
-
*/
|
|
33
29
|
const DatePickerToolbarTitle = styled(Typography, {
|
|
34
30
|
name: 'MuiDatePickerToolbar',
|
|
35
31
|
slot: 'Title',
|
|
@@ -49,7 +45,7 @@ const DatePickerToolbarTitle = styled(Typography, {
|
|
|
49
45
|
*
|
|
50
46
|
* - [DatePickerToolbar API](https://mui.com/x/api/date-pickers/date-picker-toolbar/)
|
|
51
47
|
*/
|
|
52
|
-
const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
|
|
48
|
+
export const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar(inProps, ref) {
|
|
53
49
|
const props = useThemeProps({
|
|
54
50
|
props: inProps,
|
|
55
51
|
name: 'MuiDatePickerToolbar'
|
|
@@ -133,5 +129,4 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
|
|
|
133
129
|
*/
|
|
134
130
|
view: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
|
|
135
131
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'month', 'year']).isRequired).isRequired
|
|
136
|
-
} : void 0;
|
|
137
|
-
export { DatePickerToolbar };
|
|
132
|
+
} : void 0;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import Tab from '@mui/material/Tab';
|
|
4
5
|
import Tabs, { tabsClasses } from '@mui/material/Tabs';
|
|
5
6
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
6
|
-
import
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
8
|
import { TimeIcon, DateRangeIcon } from '../icons';
|
|
8
9
|
import { useLocaleText } from '../internals/hooks/useUtils';
|
|
9
10
|
import { getDateTimePickerTabsUtilityClass } from './dateTimePickerTabsClasses';
|
|
@@ -68,7 +69,8 @@ const DateTimePickerTabs = function DateTimePickerTabs(inProps) {
|
|
|
68
69
|
onViewChange,
|
|
69
70
|
timeIcon = /*#__PURE__*/_jsx(TimeIcon, {}),
|
|
70
71
|
view,
|
|
71
|
-
hidden = typeof window === 'undefined' || window.innerHeight < 667
|
|
72
|
+
hidden = typeof window === 'undefined' || window.innerHeight < 667,
|
|
73
|
+
className
|
|
72
74
|
} = props;
|
|
73
75
|
const localeText = useLocaleText();
|
|
74
76
|
const classes = useUtilityClasses(props);
|
|
@@ -83,7 +85,7 @@ const DateTimePickerTabs = function DateTimePickerTabs(inProps) {
|
|
|
83
85
|
variant: "fullWidth",
|
|
84
86
|
value: viewToTab(view),
|
|
85
87
|
onChange: handleChange,
|
|
86
|
-
className: classes.root,
|
|
88
|
+
className: clsx(className, classes.root),
|
|
87
89
|
children: [/*#__PURE__*/_jsx(Tab, {
|
|
88
90
|
value: "date",
|
|
89
91
|
"aria-label": localeText.dateTableLabel,
|
|
@@ -108,6 +110,7 @@ process.env.NODE_ENV !== "production" ? DateTimePickerTabs.propTypes = {
|
|
|
108
110
|
* Override or extend the styles applied to the component.
|
|
109
111
|
*/
|
|
110
112
|
classes: PropTypes.object,
|
|
113
|
+
className: PropTypes.string,
|
|
111
114
|
/**
|
|
112
115
|
* Date tab icon.
|
|
113
116
|
* @default DateRange
|
|
@@ -111,7 +111,6 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
111
111
|
granularity: SECTION_TYPE_GRANULARITY.month
|
|
112
112
|
}), [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
113
113
|
);
|
|
114
|
-
|
|
115
114
|
const ownerState = props;
|
|
116
115
|
const classes = useUtilityClasses(ownerState);
|
|
117
116
|
const todayMonth = React.useMemo(() => utils.getMonth(now), [utils, now]);
|
|
@@ -509,6 +509,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
509
509
|
view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
|
|
510
510
|
/**
|
|
511
511
|
* Available views.
|
|
512
|
+
* @default ['hours', 'minutes']
|
|
512
513
|
*/
|
|
513
514
|
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired)
|
|
514
515
|
} : void 0;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersLayoutUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersLayout', slot);
|
|
4
5
|
}
|
|
5
|
-
export const pickersLayoutClasses = generateUtilityClasses('MuiPickersLayout', ['root', 'landscape', 'contentWrapper', 'toolbar', 'actionBar', 'shortcuts']);
|
|
6
|
+
export const pickersLayoutClasses = generateUtilityClasses('MuiPickersLayout', ['root', 'landscape', 'contentWrapper', 'toolbar', 'actionBar', 'tabs', 'shortcuts']);
|
|
@@ -109,7 +109,8 @@ const usePickerLayout = props => {
|
|
|
109
109
|
const Tabs = slots?.tabs;
|
|
110
110
|
const tabs = view && Tabs ? /*#__PURE__*/_jsx(Tabs, _extends({
|
|
111
111
|
view: view,
|
|
112
|
-
onViewChange: onViewChange
|
|
112
|
+
onViewChange: onViewChange,
|
|
113
|
+
className: classes.tabs
|
|
113
114
|
}, slotProps?.tabs)) : null;
|
|
114
115
|
|
|
115
116
|
// Shortcuts
|
|
@@ -492,6 +492,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
492
492
|
view: PropTypes.oneOf(['hours', 'minutes', 'seconds']),
|
|
493
493
|
/**
|
|
494
494
|
* Available views.
|
|
495
|
+
* @default ['hours', 'minutes']
|
|
495
496
|
*/
|
|
496
497
|
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
|
|
497
498
|
} : void 0;
|
|
@@ -116,7 +116,6 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
116
116
|
granularity: SECTION_TYPE_GRANULARITY.year
|
|
117
117
|
}), [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
118
118
|
);
|
|
119
|
-
|
|
120
119
|
const ownerState = props;
|
|
121
120
|
const classes = useUtilityClasses(ownerState);
|
|
122
121
|
const todayYear = React.useMemo(() => utils.getYear(now), [utils, now]);
|
|
@@ -39,8 +39,8 @@ export const useClearableField = ({
|
|
|
39
39
|
ownerState: {}
|
|
40
40
|
});
|
|
41
41
|
const InputProps = _extends({}, ForwardedInputProps, {
|
|
42
|
-
endAdornment:
|
|
43
|
-
children: [/*#__PURE__*/_jsx(InputAdornment, {
|
|
42
|
+
endAdornment: /*#__PURE__*/_jsxs(React.Fragment, {
|
|
43
|
+
children: [clearable && /*#__PURE__*/_jsx(InputAdornment, {
|
|
44
44
|
position: "end",
|
|
45
45
|
sx: {
|
|
46
46
|
marginRight: ForwardedInputProps?.endAdornment ? -1 : -1.5
|
|
@@ -52,7 +52,7 @@ export const useClearableField = ({
|
|
|
52
52
|
}, endClearIconProps))
|
|
53
53
|
}))
|
|
54
54
|
}), ForwardedInputProps?.endAdornment]
|
|
55
|
-
})
|
|
55
|
+
})
|
|
56
56
|
});
|
|
57
57
|
const fieldProps = _extends({}, forwardedFieldProps, {
|
|
58
58
|
sx: [{
|
package/modern/index.js
CHANGED
|
@@ -125,7 +125,6 @@ export const adjustSectionValue = (utils, timezone, section, keyCode, sectionsVa
|
|
|
125
125
|
if (delta < 0 || isStart) {
|
|
126
126
|
newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)
|
|
127
127
|
}
|
|
128
|
-
|
|
129
128
|
if (delta > 0 || isEnd) {
|
|
130
129
|
newSectionValueNumber -= newSectionValueNumber % step;
|
|
131
130
|
}
|
|
@@ -401,7 +400,6 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
|
|
|
401
400
|
const isTokenStartRegExp = new RegExp(`^(${Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length) // Sort to put longest word first
|
|
402
401
|
.join('|')})`, 'g') // used to get access to lastIndex state
|
|
403
402
|
;
|
|
404
|
-
|
|
405
403
|
let currentTokenValue = '';
|
|
406
404
|
for (let i = 0; i < expandedFormat.length; i += 1) {
|
|
407
405
|
const escapedPartOfCurrentChar = escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
|
|
@@ -60,7 +60,6 @@ export function useViews({
|
|
|
60
60
|
setFocusedView(prevFocusedView => viewToFocus === prevFocusedView ? null : prevFocusedView // If false the blur is due to view switching
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
63
|
onFocusedViewChange?.(viewToFocus, hasFocus);
|
|
65
64
|
});
|
|
66
65
|
const handleChangeView = useEventCallback(newView => {
|
package/modern/locales/index.js
CHANGED
package/modern/locales/plPL.js
CHANGED
package/modern/locales/svSE.js
CHANGED