@mui/x-date-pickers 6.18.7 → 6.19.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.
Files changed (44) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +3 -24
  2. package/AdapterDateFns/AdapterDateFns.js +11 -272
  3. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
  4. package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  5. package/AdapterDateFnsBase/index.d.ts +1 -0
  6. package/AdapterDateFnsBase/index.js +1 -0
  7. package/AdapterDateFnsBase/package.json +6 -0
  8. package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
  9. package/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  10. package/AdapterDateFnsV3/index.d.ts +1 -0
  11. package/AdapterDateFnsV3/index.js +1 -0
  12. package/AdapterDateFnsV3/package.json +6 -0
  13. package/CHANGELOG.md +42 -0
  14. package/hooks/useClearableField.d.ts +1 -1
  15. package/hooks/useClearableField.js +3 -3
  16. package/index.js +1 -1
  17. package/internals/models/helpers.d.ts +1 -0
  18. package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
  19. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  20. package/legacy/AdapterDateFnsBase/index.js +1 -0
  21. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
  22. package/legacy/AdapterDateFnsV3/index.js +1 -0
  23. package/legacy/hooks/useClearableField.js +3 -3
  24. package/legacy/index.js +1 -1
  25. package/legacy/locales/index.js +1 -0
  26. package/locales/index.d.ts +1 -0
  27. package/locales/index.js +1 -0
  28. package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
  29. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
  30. package/modern/AdapterDateFnsBase/index.js +1 -0
  31. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  32. package/modern/AdapterDateFnsV3/index.js +1 -0
  33. package/modern/hooks/useClearableField.js +3 -3
  34. package/modern/index.js +1 -1
  35. package/modern/locales/index.js +1 -0
  36. package/node/AdapterDateFns/AdapterDateFns.js +11 -271
  37. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
  38. package/node/AdapterDateFnsBase/index.js +12 -0
  39. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
  40. package/node/AdapterDateFnsV3/index.js +12 -0
  41. package/node/hooks/useClearableField.js +3 -3
  42. package/node/index.js +1 -1
  43. package/node/locales/index.js +11 -0
  44. package/package.json +2 -2
@@ -0,0 +1,357 @@
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
+ import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
63
+
64
+ /**
65
+ * Based on `@date-io/date-fns`
66
+ *
67
+ * MIT License
68
+ *
69
+ * Copyright (c) 2017 Dmitriy Kovalenko
70
+ *
71
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
72
+ * of this software and associated documentation files (the "Software"), to deal
73
+ * in the Software without restriction, including without limitation the rights
74
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
75
+ * copies of the Software, and to permit persons to whom the Software is
76
+ * furnished to do so, subject to the following conditions:
77
+ *
78
+ * The above copyright notice and this permission notice shall be included in all
79
+ * copies or substantial portions of the Software.
80
+ *
81
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
86
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
87
+ * SOFTWARE.
88
+ */
89
+ export class AdapterDateFns extends AdapterDateFnsBase {
90
+ constructor({
91
+ locale,
92
+ formats
93
+ } = {}) {
94
+ if (typeof addDays !== 'function') {
95
+ 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'));
96
+ }
97
+ if (!longFormatters) {
98
+ throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
99
+ }
100
+ super({
101
+ locale: locale ?? enUS,
102
+ formats,
103
+ longFormatters
104
+ });
105
+ this.parseISO = isoString => {
106
+ return parseISO(isoString);
107
+ };
108
+ this.toISO = value => {
109
+ return formatISO(value, {
110
+ format: 'extended'
111
+ });
112
+ };
113
+ this.parse = (value, format) => {
114
+ if (value === '') {
115
+ return null;
116
+ }
117
+ return dateFnsParse(value, format, new Date(), {
118
+ locale: this.locale
119
+ });
120
+ };
121
+ this.isValid = value => {
122
+ return isValid(this.date(value));
123
+ };
124
+ this.format = (value, formatKey) => {
125
+ return this.formatByString(value, this.formats[formatKey]);
126
+ };
127
+ this.formatByString = (value, formatString) => {
128
+ return dateFnsFormat(value, formatString, {
129
+ locale: this.locale
130
+ });
131
+ };
132
+ this.getDiff = (value, comparing, unit) => {
133
+ switch (unit) {
134
+ case 'years':
135
+ return differenceInYears(value, this.date(comparing));
136
+ case 'quarters':
137
+ return differenceInQuarters(value, this.date(comparing));
138
+ case 'months':
139
+ return differenceInMonths(value, this.date(comparing));
140
+ case 'weeks':
141
+ return differenceInWeeks(value, this.date(comparing));
142
+ case 'days':
143
+ return differenceInDays(value, this.date(comparing));
144
+ case 'hours':
145
+ return differenceInHours(value, this.date(comparing));
146
+ case 'minutes':
147
+ return differenceInMinutes(value, this.date(comparing));
148
+ case 'seconds':
149
+ return differenceInSeconds(value, this.date(comparing));
150
+ default:
151
+ {
152
+ return differenceInMilliseconds(value, this.date(comparing));
153
+ }
154
+ }
155
+ };
156
+ this.isEqual = (value, comparing) => {
157
+ if (value === null && comparing === null) {
158
+ return true;
159
+ }
160
+ return isEqual(value, comparing);
161
+ };
162
+ this.isSameYear = (value, comparing) => {
163
+ return isSameYear(value, comparing);
164
+ };
165
+ this.isSameMonth = (value, comparing) => {
166
+ return isSameMonth(value, comparing);
167
+ };
168
+ this.isSameDay = (value, comparing) => {
169
+ return isSameDay(value, comparing);
170
+ };
171
+ this.isSameHour = (value, comparing) => {
172
+ return isSameHour(value, comparing);
173
+ };
174
+ this.isAfter = (value, comparing) => {
175
+ return isAfter(value, comparing);
176
+ };
177
+ this.isAfterYear = (value, comparing) => {
178
+ return isAfter(value, endOfYear(comparing));
179
+ };
180
+ this.isAfterDay = (value, comparing) => {
181
+ return isAfter(value, endOfDay(comparing));
182
+ };
183
+ this.isBefore = (value, comparing) => {
184
+ return isBefore(value, comparing);
185
+ };
186
+ this.isBeforeYear = (value, comparing) => {
187
+ return isBefore(value, this.startOfYear(comparing));
188
+ };
189
+ this.isBeforeDay = (value, comparing) => {
190
+ return isBefore(value, this.startOfDay(comparing));
191
+ };
192
+ this.isWithinRange = (value, [start, end]) => {
193
+ return isWithinInterval(value, {
194
+ start,
195
+ end
196
+ });
197
+ };
198
+ this.startOfYear = value => {
199
+ return startOfYear(value);
200
+ };
201
+ this.startOfMonth = value => {
202
+ return startOfMonth(value);
203
+ };
204
+ this.startOfWeek = value => {
205
+ return startOfWeek(value, {
206
+ locale: this.locale
207
+ });
208
+ };
209
+ this.startOfDay = value => {
210
+ return startOfDay(value);
211
+ };
212
+ this.endOfYear = value => {
213
+ return endOfYear(value);
214
+ };
215
+ this.endOfMonth = value => {
216
+ return endOfMonth(value);
217
+ };
218
+ this.endOfWeek = value => {
219
+ return endOfWeek(value, {
220
+ locale: this.locale
221
+ });
222
+ };
223
+ this.endOfDay = value => {
224
+ return endOfDay(value);
225
+ };
226
+ this.addYears = (value, amount) => {
227
+ return addYears(value, amount);
228
+ };
229
+ this.addMonths = (value, amount) => {
230
+ return addMonths(value, amount);
231
+ };
232
+ this.addWeeks = (value, amount) => {
233
+ return addWeeks(value, amount);
234
+ };
235
+ this.addDays = (value, amount) => {
236
+ return addDays(value, amount);
237
+ };
238
+ this.addHours = (value, amount) => {
239
+ return addHours(value, amount);
240
+ };
241
+ this.addMinutes = (value, amount) => {
242
+ return addMinutes(value, amount);
243
+ };
244
+ this.addSeconds = (value, amount) => {
245
+ return addSeconds(value, amount);
246
+ };
247
+ this.getYear = value => {
248
+ return getYear(value);
249
+ };
250
+ this.getMonth = value => {
251
+ return getMonth(value);
252
+ };
253
+ this.getDate = value => {
254
+ return getDate(value);
255
+ };
256
+ this.getHours = value => {
257
+ return getHours(value);
258
+ };
259
+ this.getMinutes = value => {
260
+ return getMinutes(value);
261
+ };
262
+ this.getSeconds = value => {
263
+ return getSeconds(value);
264
+ };
265
+ this.getMilliseconds = value => {
266
+ return getMilliseconds(value);
267
+ };
268
+ this.setYear = (value, year) => {
269
+ return setYear(value, year);
270
+ };
271
+ this.setMonth = (value, month) => {
272
+ return setMonth(value, month);
273
+ };
274
+ this.setDate = (value, date) => {
275
+ return setDate(value, date);
276
+ };
277
+ this.setHours = (value, hours) => {
278
+ return setHours(value, hours);
279
+ };
280
+ this.setMinutes = (value, minutes) => {
281
+ return setMinutes(value, minutes);
282
+ };
283
+ this.setSeconds = (value, seconds) => {
284
+ return setSeconds(value, seconds);
285
+ };
286
+ this.setMilliseconds = (value, milliseconds) => {
287
+ return setMilliseconds(value, milliseconds);
288
+ };
289
+ this.getDaysInMonth = value => {
290
+ return getDaysInMonth(value);
291
+ };
292
+ this.getNextMonth = value => {
293
+ return addMonths(value, 1);
294
+ };
295
+ this.getPreviousMonth = value => {
296
+ return addMonths(value, -1);
297
+ };
298
+ this.getMonthArray = value => {
299
+ const firstMonth = startOfYear(value);
300
+ const monthArray = [firstMonth];
301
+ while (monthArray.length < 12) {
302
+ const prevMonth = monthArray[monthArray.length - 1];
303
+ monthArray.push(this.getNextMonth(prevMonth));
304
+ }
305
+ return monthArray;
306
+ };
307
+ this.mergeDateAndTime = (dateParam, timeParam) => {
308
+ return this.setSeconds(this.setMinutes(this.setHours(dateParam, this.getHours(timeParam)), this.getMinutes(timeParam)), this.getSeconds(timeParam));
309
+ };
310
+ this.getWeekdays = () => {
311
+ const now = new Date();
312
+ return eachDayOfInterval({
313
+ start: startOfWeek(now, {
314
+ locale: this.locale
315
+ }),
316
+ end: endOfWeek(now, {
317
+ locale: this.locale
318
+ })
319
+ }).map(day => this.formatByString(day, 'EEEEEE'));
320
+ };
321
+ this.getWeekArray = value => {
322
+ const start = startOfWeek(startOfMonth(value), {
323
+ locale: this.locale
324
+ });
325
+ const end = endOfWeek(endOfMonth(value), {
326
+ locale: this.locale
327
+ });
328
+ let count = 0;
329
+ let current = start;
330
+ const nestedWeeks = [];
331
+ while (isBefore(current, end)) {
332
+ const weekNumber = Math.floor(count / 7);
333
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
334
+ nestedWeeks[weekNumber].push(current);
335
+ current = addDays(current, 1);
336
+ count += 1;
337
+ }
338
+ return nestedWeeks;
339
+ };
340
+ this.getWeekNumber = value => {
341
+ return getWeek(value, {
342
+ locale: this.locale
343
+ });
344
+ };
345
+ this.getYearRange = (start, end) => {
346
+ const startDate = startOfYear(start);
347
+ const endDate = endOfYear(end);
348
+ const years = [];
349
+ let current = startDate;
350
+ while (isBefore(current, endDate)) {
351
+ years.push(current);
352
+ current = addYears(current, 1);
353
+ }
354
+ return years;
355
+ };
356
+ }
357
+ }
@@ -0,0 +1 @@
1
+ export { AdapterDateFns } from './AdapterDateFnsV3';
@@ -39,8 +39,8 @@ export const useClearableField = ({
39
39
  ownerState: {}
40
40
  });
41
41
  const InputProps = _extends({}, ForwardedInputProps, {
42
- endAdornment: clearable ? /*#__PURE__*/_jsxs(React.Fragment, {
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
- }) : ForwardedInputProps?.endAdornment
55
+ })
56
56
  });
57
57
  const fieldProps = _extends({}, forwardedFieldProps, {
58
58
  sx: [{
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.18.7
2
+ * @mui/x-date-pickers v6.19.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,7 @@
1
1
  export * from './beBY';
2
2
  export * from './caES';
3
3
  export * from './csCZ';
4
+ export * from './daDK';
4
5
  export * from './deDE';
5
6
  export * from './elGR';
6
7
  export * from './enUS';