@mui/x-date-pickers 6.18.6 → 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 (72) 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/AdapterLuxon/AdapterLuxon.d.ts +32 -32
  14. package/CHANGELOG.md +85 -1
  15. package/DateCalendar/DateCalendar.js +6 -4
  16. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  17. package/DigitalClock/DigitalClock.js +3 -2
  18. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  19. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  20. package/TimeClock/TimeClock.js +3 -2
  21. package/hooks/useClearableField.d.ts +1 -1
  22. package/hooks/useClearableField.js +3 -3
  23. package/index.js +1 -1
  24. package/internals/hooks/useViews.d.ts +4 -4
  25. package/internals/hooks/useViews.js +13 -13
  26. package/internals/models/helpers.d.ts +1 -0
  27. package/internals/models/props/clock.d.ts +0 -9
  28. package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
  29. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
  30. package/legacy/AdapterDateFnsBase/index.js +1 -0
  31. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
  32. package/legacy/AdapterDateFnsV3/index.js +1 -0
  33. package/legacy/DateCalendar/DateCalendar.js +6 -4
  34. package/legacy/DigitalClock/DigitalClock.js +3 -2
  35. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  36. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  37. package/legacy/TimeClock/TimeClock.js +3 -2
  38. package/legacy/hooks/useClearableField.js +3 -3
  39. package/legacy/index.js +1 -1
  40. package/legacy/internals/hooks/useViews.js +13 -13
  41. package/legacy/locales/index.js +1 -0
  42. package/locales/index.d.ts +1 -0
  43. package/locales/index.js +1 -0
  44. package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
  45. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
  46. package/modern/AdapterDateFnsBase/index.js +1 -0
  47. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
  48. package/modern/AdapterDateFnsV3/index.js +1 -0
  49. package/modern/DateCalendar/DateCalendar.js +6 -4
  50. package/modern/DigitalClock/DigitalClock.js +3 -2
  51. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  52. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  53. package/modern/TimeClock/TimeClock.js +3 -2
  54. package/modern/hooks/useClearableField.js +3 -3
  55. package/modern/index.js +1 -1
  56. package/modern/internals/hooks/useViews.js +13 -13
  57. package/modern/locales/index.js +1 -0
  58. package/node/AdapterDateFns/AdapterDateFns.js +11 -271
  59. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
  60. package/node/AdapterDateFnsBase/index.js +12 -0
  61. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
  62. package/node/AdapterDateFnsV3/index.js +12 -0
  63. package/node/DateCalendar/DateCalendar.js +6 -4
  64. package/node/DigitalClock/DigitalClock.js +3 -2
  65. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  66. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +8 -12
  67. package/node/TimeClock/TimeClock.js +3 -2
  68. package/node/hooks/useClearableField.js +3 -3
  69. package/node/index.js +1 -1
  70. package/node/internals/hooks/useViews.js +13 -13
  71. package/node/locales/index.js +11 -0
  72. package/package.json +2 -2
@@ -0,0 +1,308 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ /* eslint-disable class-methods-use-this */
5
+
6
+ var formatTokenMap = {
7
+ // Year
8
+ y: {
9
+ sectionType: 'year',
10
+ contentType: 'digit',
11
+ maxLength: 4
12
+ },
13
+ yy: 'year',
14
+ yyy: {
15
+ sectionType: 'year',
16
+ contentType: 'digit',
17
+ maxLength: 4
18
+ },
19
+ yyyy: 'year',
20
+ // Month
21
+ M: {
22
+ sectionType: 'month',
23
+ contentType: 'digit',
24
+ maxLength: 2
25
+ },
26
+ MM: 'month',
27
+ MMMM: {
28
+ sectionType: 'month',
29
+ contentType: 'letter'
30
+ },
31
+ MMM: {
32
+ sectionType: 'month',
33
+ contentType: 'letter'
34
+ },
35
+ L: {
36
+ sectionType: 'month',
37
+ contentType: 'digit',
38
+ maxLength: 2
39
+ },
40
+ LL: 'month',
41
+ LLL: {
42
+ sectionType: 'month',
43
+ contentType: 'letter'
44
+ },
45
+ LLLL: {
46
+ sectionType: 'month',
47
+ contentType: 'letter'
48
+ },
49
+ // Day of the month
50
+ d: {
51
+ sectionType: 'day',
52
+ contentType: 'digit',
53
+ maxLength: 2
54
+ },
55
+ dd: 'day',
56
+ do: {
57
+ sectionType: 'day',
58
+ contentType: 'digit-with-letter'
59
+ },
60
+ // Day of the week
61
+ E: {
62
+ sectionType: 'weekDay',
63
+ contentType: 'letter'
64
+ },
65
+ EE: {
66
+ sectionType: 'weekDay',
67
+ contentType: 'letter'
68
+ },
69
+ EEE: {
70
+ sectionType: 'weekDay',
71
+ contentType: 'letter'
72
+ },
73
+ EEEE: {
74
+ sectionType: 'weekDay',
75
+ contentType: 'letter'
76
+ },
77
+ EEEEE: {
78
+ sectionType: 'weekDay',
79
+ contentType: 'letter'
80
+ },
81
+ i: {
82
+ sectionType: 'weekDay',
83
+ contentType: 'digit',
84
+ maxLength: 1
85
+ },
86
+ ii: 'weekDay',
87
+ iii: {
88
+ sectionType: 'weekDay',
89
+ contentType: 'letter'
90
+ },
91
+ iiii: {
92
+ sectionType: 'weekDay',
93
+ contentType: 'letter'
94
+ },
95
+ e: {
96
+ sectionType: 'weekDay',
97
+ contentType: 'digit',
98
+ maxLength: 1
99
+ },
100
+ ee: 'weekDay',
101
+ eee: {
102
+ sectionType: 'weekDay',
103
+ contentType: 'letter'
104
+ },
105
+ eeee: {
106
+ sectionType: 'weekDay',
107
+ contentType: 'letter'
108
+ },
109
+ eeeee: {
110
+ sectionType: 'weekDay',
111
+ contentType: 'letter'
112
+ },
113
+ eeeeee: {
114
+ sectionType: 'weekDay',
115
+ contentType: 'letter'
116
+ },
117
+ c: {
118
+ sectionType: 'weekDay',
119
+ contentType: 'digit',
120
+ maxLength: 1
121
+ },
122
+ cc: 'weekDay',
123
+ ccc: {
124
+ sectionType: 'weekDay',
125
+ contentType: 'letter'
126
+ },
127
+ cccc: {
128
+ sectionType: 'weekDay',
129
+ contentType: 'letter'
130
+ },
131
+ ccccc: {
132
+ sectionType: 'weekDay',
133
+ contentType: 'letter'
134
+ },
135
+ cccccc: {
136
+ sectionType: 'weekDay',
137
+ contentType: 'letter'
138
+ },
139
+ // Meridiem
140
+ a: 'meridiem',
141
+ aa: 'meridiem',
142
+ aaa: 'meridiem',
143
+ // Hours
144
+ H: {
145
+ sectionType: 'hours',
146
+ contentType: 'digit',
147
+ maxLength: 2
148
+ },
149
+ HH: 'hours',
150
+ h: {
151
+ sectionType: 'hours',
152
+ contentType: 'digit',
153
+ maxLength: 2
154
+ },
155
+ hh: 'hours',
156
+ // Minutes
157
+ m: {
158
+ sectionType: 'minutes',
159
+ contentType: 'digit',
160
+ maxLength: 2
161
+ },
162
+ mm: 'minutes',
163
+ // Seconds
164
+ s: {
165
+ sectionType: 'seconds',
166
+ contentType: 'digit',
167
+ maxLength: 2
168
+ },
169
+ ss: 'seconds'
170
+ };
171
+ var defaultFormats = {
172
+ year: 'yyyy',
173
+ month: 'LLLL',
174
+ monthShort: 'MMM',
175
+ dayOfMonth: 'd',
176
+ weekday: 'EEEE',
177
+ weekdayShort: 'EEEEEE',
178
+ hours24h: 'HH',
179
+ hours12h: 'hh',
180
+ meridiem: 'aa',
181
+ minutes: 'mm',
182
+ seconds: 'ss',
183
+ fullDate: 'PP',
184
+ fullDateWithWeekday: 'PPPP',
185
+ keyboardDate: 'P',
186
+ shortDate: 'MMM d',
187
+ normalDate: 'd MMMM',
188
+ normalDateWithWeekday: 'EEE, MMM d',
189
+ monthAndYear: 'LLLL yyyy',
190
+ monthAndDate: 'MMMM d',
191
+ fullTime: 'p',
192
+ fullTime12h: 'hh:mm aa',
193
+ fullTime24h: 'HH:mm',
194
+ fullDateTime: 'PP p',
195
+ fullDateTime12h: 'PP hh:mm aa',
196
+ fullDateTime24h: 'PP HH:mm',
197
+ keyboardDateTime: 'P p',
198
+ keyboardDateTime12h: 'P hh:mm aa',
199
+ keyboardDateTime24h: 'P HH:mm'
200
+ };
201
+ /**
202
+ * Based on `@date-io/date-fns`
203
+ *
204
+ * MIT License
205
+ *
206
+ * Copyright (c) 2017 Dmitriy Kovalenko
207
+ *
208
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
209
+ * of this software and associated documentation files (the "Software"), to deal
210
+ * in the Software without restriction, including without limitation the rights
211
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
212
+ * copies of the Software, and to permit persons to whom the Software is
213
+ * furnished to do so, subject to the following conditions:
214
+ *
215
+ * The above copyright notice and this permission notice shall be included in all
216
+ * copies or substantial portions of the Software.
217
+ *
218
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
219
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
220
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
221
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
222
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
223
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
224
+ * SOFTWARE.
225
+ */
226
+ export var AdapterDateFnsBase = /*#__PURE__*/_createClass(function AdapterDateFnsBase(props) {
227
+ var _this = this;
228
+ _classCallCheck(this, AdapterDateFnsBase);
229
+ this.isMUIAdapter = true;
230
+ this.isTimezoneCompatible = false;
231
+ this.lib = 'date-fns';
232
+ this.locale = void 0;
233
+ this.formats = void 0;
234
+ this.formatTokenMap = formatTokenMap;
235
+ this.escapedCharacters = {
236
+ start: "'",
237
+ end: "'"
238
+ };
239
+ this.longFormatters = void 0;
240
+ this.date = function (value) {
241
+ if (typeof value === 'undefined') {
242
+ return new Date();
243
+ }
244
+ if (value === null) {
245
+ return null;
246
+ }
247
+ return new Date(value);
248
+ };
249
+ this.dateWithTimezone = function (value) {
250
+ return _this.date(value);
251
+ };
252
+ this.getTimezone = function () {
253
+ return 'default';
254
+ };
255
+ this.setTimezone = function (value) {
256
+ return value;
257
+ };
258
+ this.toJsDate = function (value) {
259
+ return value;
260
+ };
261
+ this.getCurrentLocaleCode = function () {
262
+ var _this$locale;
263
+ return ((_this$locale = _this.locale) == null ? void 0 : _this$locale.code) || 'en-US';
264
+ };
265
+ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
266
+ // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
267
+ this.is12HourCycleInCurrentLocale = function () {
268
+ if (_this.locale) {
269
+ return /a/.test(_this.locale.formatLong.time({
270
+ width: 'short'
271
+ }));
272
+ }
273
+
274
+ // By default, date-fns is using en-US locale with am/pm enabled
275
+ return true;
276
+ };
277
+ this.expandFormat = function (format) {
278
+ var longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
279
+
280
+ // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
281
+ return format.match(longFormatRegexp).map(function (token) {
282
+ var firstCharacter = token[0];
283
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
284
+ var longFormatter = _this.longFormatters[firstCharacter];
285
+ return longFormatter(token, _this.locale.formatLong);
286
+ }
287
+ return token;
288
+ }).join('');
289
+ };
290
+ this.getFormatHelperText = function (format) {
291
+ return _this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
292
+ };
293
+ this.isNull = function (value) {
294
+ return value === null;
295
+ };
296
+ this.formatNumber = function (numberToFormat) {
297
+ return numberToFormat;
298
+ };
299
+ this.getMeridiemText = function (ampm) {
300
+ return ampm === 'am' ? 'AM' : 'PM';
301
+ };
302
+ var locale = props.locale,
303
+ formats = props.formats,
304
+ longFormatters = props.longFormatters;
305
+ this.locale = locale;
306
+ this.formats = _extends({}, defaultFormats, formats);
307
+ this.longFormatters = longFormatters;
308
+ });
@@ -0,0 +1 @@
1
+ export { AdapterDateFnsBase } from './AdapterDateFnsBase';
@@ -0,0 +1,376 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
9
+ /* eslint-disable class-methods-use-this */
10
+ // TODO remove when date-fns-v3 is the default
11
+ // @ts-nocheck
12
+ import { addDays } from 'date-fns/addDays';
13
+ import { addSeconds } from 'date-fns/addSeconds';
14
+ import { addMinutes } from 'date-fns/addMinutes';
15
+ import { addHours } from 'date-fns/addHours';
16
+ import { addWeeks } from 'date-fns/addWeeks';
17
+ import { addMonths } from 'date-fns/addMonths';
18
+ import { addYears } from 'date-fns/addYears';
19
+ import { differenceInYears } from 'date-fns/differenceInYears';
20
+ import { differenceInQuarters } from 'date-fns/differenceInQuarters';
21
+ import { differenceInMonths } from 'date-fns/differenceInMonths';
22
+ import { differenceInWeeks } from 'date-fns/differenceInWeeks';
23
+ import { differenceInDays } from 'date-fns/differenceInDays';
24
+ import { differenceInHours } from 'date-fns/differenceInHours';
25
+ import { differenceInMinutes } from 'date-fns/differenceInMinutes';
26
+ import { differenceInSeconds } from 'date-fns/differenceInSeconds';
27
+ import { differenceInMilliseconds } from 'date-fns/differenceInMilliseconds';
28
+ import { eachDayOfInterval } from 'date-fns/eachDayOfInterval';
29
+ import { endOfDay } from 'date-fns/endOfDay';
30
+ import { endOfWeek } from 'date-fns/endOfWeek';
31
+ import { endOfYear } from 'date-fns/endOfYear';
32
+ // @ts-ignore TODO remove when date-fns-v3 is the default
33
+ import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
34
+ import { getDate } from 'date-fns/getDate';
35
+ import { getDaysInMonth } from 'date-fns/getDaysInMonth';
36
+ import { getHours } from 'date-fns/getHours';
37
+ import { getMinutes } from 'date-fns/getMinutes';
38
+ import { getMonth } from 'date-fns/getMonth';
39
+ import { getSeconds } from 'date-fns/getSeconds';
40
+ import { getMilliseconds } from 'date-fns/getMilliseconds';
41
+ import { getWeek } from 'date-fns/getWeek';
42
+ import { getYear } from 'date-fns/getYear';
43
+ import { isAfter } from 'date-fns/isAfter';
44
+ import { isBefore } from 'date-fns/isBefore';
45
+ import { isEqual } from 'date-fns/isEqual';
46
+ import { isSameDay } from 'date-fns/isSameDay';
47
+ import { isSameYear } from 'date-fns/isSameYear';
48
+ import { isSameMonth } from 'date-fns/isSameMonth';
49
+ import { isSameHour } from 'date-fns/isSameHour';
50
+ import { isValid } from 'date-fns/isValid';
51
+ import { parse as dateFnsParse } from 'date-fns/parse';
52
+ import { setDate } from 'date-fns/setDate';
53
+ import { setHours } from 'date-fns/setHours';
54
+ import { setMinutes } from 'date-fns/setMinutes';
55
+ import { setMonth } from 'date-fns/setMonth';
56
+ import { setSeconds } from 'date-fns/setSeconds';
57
+ import { setMilliseconds } from 'date-fns/setMilliseconds';
58
+ import { setYear } from 'date-fns/setYear';
59
+ import { startOfDay } from 'date-fns/startOfDay';
60
+ import { startOfMonth } from 'date-fns/startOfMonth';
61
+ import { endOfMonth } from 'date-fns/endOfMonth';
62
+ import { startOfWeek } from 'date-fns/startOfWeek';
63
+ import { startOfYear } from 'date-fns/startOfYear';
64
+ import { formatISO } from 'date-fns/formatISO';
65
+ import { parseISO } from 'date-fns/parseISO';
66
+ import { isWithinInterval } from 'date-fns/isWithinInterval';
67
+ import { enUS } from 'date-fns/locale/en-US';
68
+ // date-fns v2 does not export types
69
+ // @ts-ignore TODO remove when date-fns-v3 is the default
70
+ import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
71
+
72
+ /**
73
+ * Based on `@date-io/date-fns`
74
+ *
75
+ * MIT License
76
+ *
77
+ * Copyright (c) 2017 Dmitriy Kovalenko
78
+ *
79
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
80
+ * of this software and associated documentation files (the "Software"), to deal
81
+ * in the Software without restriction, including without limitation the rights
82
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
83
+ * copies of the Software, and to permit persons to whom the Software is
84
+ * furnished to do so, subject to the following conditions:
85
+ *
86
+ * The above copyright notice and this permission notice shall be included in all
87
+ * copies or substantial portions of the Software.
88
+ *
89
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
90
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
91
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
92
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
93
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
94
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
95
+ * SOFTWARE.
96
+ */
97
+ export var AdapterDateFns = /*#__PURE__*/function (_ref) {
98
+ _inherits(AdapterDateFns, _ref);
99
+ var _super = _createSuper(AdapterDateFns);
100
+ function AdapterDateFns() {
101
+ var _this;
102
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
103
+ locale = _ref2.locale,
104
+ formats = _ref2.formats;
105
+ _classCallCheck(this, AdapterDateFns);
106
+ if (typeof addDays !== 'function') {
107
+ 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'));
108
+ }
109
+ if (!longFormatters) {
110
+ throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
111
+ }
112
+ _this = _super.call(this, {
113
+ locale: locale != null ? locale : enUS,
114
+ formats: formats,
115
+ longFormatters: longFormatters
116
+ });
117
+ _this.parseISO = function (isoString) {
118
+ return parseISO(isoString);
119
+ };
120
+ _this.toISO = function (value) {
121
+ return formatISO(value, {
122
+ format: 'extended'
123
+ });
124
+ };
125
+ _this.parse = function (value, format) {
126
+ if (value === '') {
127
+ return null;
128
+ }
129
+ return dateFnsParse(value, format, new Date(), {
130
+ locale: _this.locale
131
+ });
132
+ };
133
+ _this.isValid = function (value) {
134
+ return isValid(_this.date(value));
135
+ };
136
+ _this.format = function (value, formatKey) {
137
+ return _this.formatByString(value, _this.formats[formatKey]);
138
+ };
139
+ _this.formatByString = function (value, formatString) {
140
+ return dateFnsFormat(value, formatString, {
141
+ locale: _this.locale
142
+ });
143
+ };
144
+ _this.getDiff = function (value, comparing, unit) {
145
+ switch (unit) {
146
+ case 'years':
147
+ return differenceInYears(value, _this.date(comparing));
148
+ case 'quarters':
149
+ return differenceInQuarters(value, _this.date(comparing));
150
+ case 'months':
151
+ return differenceInMonths(value, _this.date(comparing));
152
+ case 'weeks':
153
+ return differenceInWeeks(value, _this.date(comparing));
154
+ case 'days':
155
+ return differenceInDays(value, _this.date(comparing));
156
+ case 'hours':
157
+ return differenceInHours(value, _this.date(comparing));
158
+ case 'minutes':
159
+ return differenceInMinutes(value, _this.date(comparing));
160
+ case 'seconds':
161
+ return differenceInSeconds(value, _this.date(comparing));
162
+ default:
163
+ {
164
+ return differenceInMilliseconds(value, _this.date(comparing));
165
+ }
166
+ }
167
+ };
168
+ _this.isEqual = function (value, comparing) {
169
+ if (value === null && comparing === null) {
170
+ return true;
171
+ }
172
+ return isEqual(value, comparing);
173
+ };
174
+ _this.isSameYear = function (value, comparing) {
175
+ return isSameYear(value, comparing);
176
+ };
177
+ _this.isSameMonth = function (value, comparing) {
178
+ return isSameMonth(value, comparing);
179
+ };
180
+ _this.isSameDay = function (value, comparing) {
181
+ return isSameDay(value, comparing);
182
+ };
183
+ _this.isSameHour = function (value, comparing) {
184
+ return isSameHour(value, comparing);
185
+ };
186
+ _this.isAfter = function (value, comparing) {
187
+ return isAfter(value, comparing);
188
+ };
189
+ _this.isAfterYear = function (value, comparing) {
190
+ return isAfter(value, endOfYear(comparing));
191
+ };
192
+ _this.isAfterDay = function (value, comparing) {
193
+ return isAfter(value, endOfDay(comparing));
194
+ };
195
+ _this.isBefore = function (value, comparing) {
196
+ return isBefore(value, comparing);
197
+ };
198
+ _this.isBeforeYear = function (value, comparing) {
199
+ return isBefore(value, _this.startOfYear(comparing));
200
+ };
201
+ _this.isBeforeDay = function (value, comparing) {
202
+ return isBefore(value, _this.startOfDay(comparing));
203
+ };
204
+ _this.isWithinRange = function (value, _ref3) {
205
+ var _ref4 = _slicedToArray(_ref3, 2),
206
+ start = _ref4[0],
207
+ end = _ref4[1];
208
+ return isWithinInterval(value, {
209
+ start: start,
210
+ end: end
211
+ });
212
+ };
213
+ _this.startOfYear = function (value) {
214
+ return startOfYear(value);
215
+ };
216
+ _this.startOfMonth = function (value) {
217
+ return startOfMonth(value);
218
+ };
219
+ _this.startOfWeek = function (value) {
220
+ return startOfWeek(value, {
221
+ locale: _this.locale
222
+ });
223
+ };
224
+ _this.startOfDay = function (value) {
225
+ return startOfDay(value);
226
+ };
227
+ _this.endOfYear = function (value) {
228
+ return endOfYear(value);
229
+ };
230
+ _this.endOfMonth = function (value) {
231
+ return endOfMonth(value);
232
+ };
233
+ _this.endOfWeek = function (value) {
234
+ return endOfWeek(value, {
235
+ locale: _this.locale
236
+ });
237
+ };
238
+ _this.endOfDay = function (value) {
239
+ return endOfDay(value);
240
+ };
241
+ _this.addYears = function (value, amount) {
242
+ return addYears(value, amount);
243
+ };
244
+ _this.addMonths = function (value, amount) {
245
+ return addMonths(value, amount);
246
+ };
247
+ _this.addWeeks = function (value, amount) {
248
+ return addWeeks(value, amount);
249
+ };
250
+ _this.addDays = function (value, amount) {
251
+ return addDays(value, amount);
252
+ };
253
+ _this.addHours = function (value, amount) {
254
+ return addHours(value, amount);
255
+ };
256
+ _this.addMinutes = function (value, amount) {
257
+ return addMinutes(value, amount);
258
+ };
259
+ _this.addSeconds = function (value, amount) {
260
+ return addSeconds(value, amount);
261
+ };
262
+ _this.getYear = function (value) {
263
+ return getYear(value);
264
+ };
265
+ _this.getMonth = function (value) {
266
+ return getMonth(value);
267
+ };
268
+ _this.getDate = function (value) {
269
+ return getDate(value);
270
+ };
271
+ _this.getHours = function (value) {
272
+ return getHours(value);
273
+ };
274
+ _this.getMinutes = function (value) {
275
+ return getMinutes(value);
276
+ };
277
+ _this.getSeconds = function (value) {
278
+ return getSeconds(value);
279
+ };
280
+ _this.getMilliseconds = function (value) {
281
+ return getMilliseconds(value);
282
+ };
283
+ _this.setYear = function (value, year) {
284
+ return setYear(value, year);
285
+ };
286
+ _this.setMonth = function (value, month) {
287
+ return setMonth(value, month);
288
+ };
289
+ _this.setDate = function (value, date) {
290
+ return setDate(value, date);
291
+ };
292
+ _this.setHours = function (value, hours) {
293
+ return setHours(value, hours);
294
+ };
295
+ _this.setMinutes = function (value, minutes) {
296
+ return setMinutes(value, minutes);
297
+ };
298
+ _this.setSeconds = function (value, seconds) {
299
+ return setSeconds(value, seconds);
300
+ };
301
+ _this.setMilliseconds = function (value, milliseconds) {
302
+ return setMilliseconds(value, milliseconds);
303
+ };
304
+ _this.getDaysInMonth = function (value) {
305
+ return getDaysInMonth(value);
306
+ };
307
+ _this.getNextMonth = function (value) {
308
+ return addMonths(value, 1);
309
+ };
310
+ _this.getPreviousMonth = function (value) {
311
+ return addMonths(value, -1);
312
+ };
313
+ _this.getMonthArray = function (value) {
314
+ var firstMonth = startOfYear(value);
315
+ var monthArray = [firstMonth];
316
+ while (monthArray.length < 12) {
317
+ var prevMonth = monthArray[monthArray.length - 1];
318
+ monthArray.push(_this.getNextMonth(prevMonth));
319
+ }
320
+ return monthArray;
321
+ };
322
+ _this.mergeDateAndTime = function (dateParam, timeParam) {
323
+ return _this.setSeconds(_this.setMinutes(_this.setHours(dateParam, _this.getHours(timeParam)), _this.getMinutes(timeParam)), _this.getSeconds(timeParam));
324
+ };
325
+ _this.getWeekdays = function () {
326
+ var now = new Date();
327
+ return eachDayOfInterval({
328
+ start: startOfWeek(now, {
329
+ locale: _this.locale
330
+ }),
331
+ end: endOfWeek(now, {
332
+ locale: _this.locale
333
+ })
334
+ }).map(function (day) {
335
+ return _this.formatByString(day, 'EEEEEE');
336
+ });
337
+ };
338
+ _this.getWeekArray = function (value) {
339
+ var start = startOfWeek(startOfMonth(value), {
340
+ locale: _this.locale
341
+ });
342
+ var end = endOfWeek(endOfMonth(value), {
343
+ locale: _this.locale
344
+ });
345
+ var count = 0;
346
+ var current = start;
347
+ var nestedWeeks = [];
348
+ while (isBefore(current, end)) {
349
+ var weekNumber = Math.floor(count / 7);
350
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
351
+ nestedWeeks[weekNumber].push(current);
352
+ current = addDays(current, 1);
353
+ count += 1;
354
+ }
355
+ return nestedWeeks;
356
+ };
357
+ _this.getWeekNumber = function (value) {
358
+ return getWeek(value, {
359
+ locale: _this.locale
360
+ });
361
+ };
362
+ _this.getYearRange = function (start, end) {
363
+ var startDate = startOfYear(start);
364
+ var endDate = endOfYear(end);
365
+ var years = [];
366
+ var current = startDate;
367
+ while (isBefore(current, endDate)) {
368
+ years.push(current);
369
+ current = addYears(current, 1);
370
+ }
371
+ return years;
372
+ };
373
+ return _this;
374
+ }
375
+ return _createClass(AdapterDateFns);
376
+ }(AdapterDateFnsBase);
@@ -0,0 +1 @@
1
+ export { AdapterDateFns } from './AdapterDateFnsV3';