@mui/x-date-pickers 7.0.0-alpha.6 → 7.0.0-alpha.8

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 (128) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +4 -21
  2. package/AdapterDateFns/AdapterDateFns.js +11 -255
  3. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +62 -0
  4. package/AdapterDateFnsBase/AdapterDateFnsBase.js +291 -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/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
  9. package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +80 -0
  10. package/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
  11. package/AdapterDateFnsV3/index.d.ts +1 -0
  12. package/AdapterDateFnsV3/index.js +1 -0
  13. package/AdapterDateFnsV3/package.json +6 -0
  14. package/CHANGELOG.md +357 -49
  15. package/DateCalendar/DateCalendar.js +6 -4
  16. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  17. package/DatePicker/DatePickerToolbar.d.ts +2 -2
  18. package/DatePicker/DatePickerToolbar.js +2 -7
  19. package/DigitalClock/DigitalClock.js +4 -2
  20. package/DigitalClock/DigitalClock.types.d.ts +5 -0
  21. package/LocalizationProvider/LocalizationProvider.js +1 -1
  22. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  23. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
  24. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  25. package/PickersSectionList/PickersSectionList.js +1 -1
  26. package/TimeClock/TimeClock.js +4 -2
  27. package/TimeClock/TimeClock.types.d.ts +5 -0
  28. package/hooks/useClearableField.js +3 -3
  29. package/index.js +1 -1
  30. package/internals/components/PickersInput/PickersFilledInput.js +2 -2
  31. package/internals/components/PickersInput/PickersInput.d.ts +2 -4
  32. package/internals/components/PickersInput/PickersInput.js +2 -3
  33. package/internals/components/PickersInput/PickersStandardInput.js +2 -2
  34. package/internals/hooks/useField/useField.utils.js +5 -5
  35. package/internals/hooks/usePicker/index.d.ts +1 -1
  36. package/internals/hooks/usePicker/usePickerValue.js +2 -2
  37. package/internals/hooks/useUtils.js +2 -2
  38. package/internals/hooks/useViews.d.ts +4 -4
  39. package/internals/hooks/useViews.js +15 -15
  40. package/internals/index.d.ts +9 -3
  41. package/internals/index.js +6 -2
  42. package/internals/models/common.d.ts +1 -1
  43. package/internals/models/helpers.d.ts +1 -0
  44. package/internals/models/props/clock.d.ts +0 -9
  45. package/internals/utils/views.js +1 -1
  46. package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
  47. package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
  48. package/legacy/AdapterDateFnsBase/index.js +1 -0
  49. package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
  50. package/legacy/AdapterDateFnsV3/index.js +1 -0
  51. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
  52. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
  53. package/legacy/DateCalendar/DateCalendar.js +6 -4
  54. package/legacy/DatePicker/DatePickerToolbar.js +2 -7
  55. package/legacy/DigitalClock/DigitalClock.js +4 -2
  56. package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
  57. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  58. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  59. package/legacy/PickersSectionList/PickersSectionList.js +1 -1
  60. package/legacy/TimeClock/TimeClock.js +4 -2
  61. package/legacy/hooks/useClearableField.js +3 -3
  62. package/legacy/index.js +1 -1
  63. package/legacy/internals/components/PickersInput/PickersFilledInput.js +2 -2
  64. package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
  65. package/legacy/internals/components/PickersInput/PickersStandardInput.js +2 -2
  66. package/legacy/internals/hooks/useField/useField.utils.js +5 -5
  67. package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
  68. package/legacy/internals/hooks/useUtils.js +2 -2
  69. package/legacy/internals/hooks/useViews.js +15 -15
  70. package/legacy/internals/index.js +6 -2
  71. package/legacy/internals/utils/views.js +1 -1
  72. package/legacy/locales/index.js +1 -0
  73. package/locales/enUS.d.ts +1 -1
  74. package/locales/index.d.ts +1 -0
  75. package/locales/index.js +1 -0
  76. package/locales/mk.d.ts +1 -1
  77. package/locales/utils/getPickersLocalization.d.ts +1 -1
  78. package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
  79. package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
  80. package/modern/AdapterDateFnsBase/index.js +1 -0
  81. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
  82. package/modern/AdapterDateFnsV3/index.js +1 -0
  83. package/modern/DateCalendar/DateCalendar.js +6 -4
  84. package/modern/DatePicker/DatePickerToolbar.js +2 -7
  85. package/modern/DigitalClock/DigitalClock.js +4 -2
  86. package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
  87. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  88. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  89. package/modern/PickersSectionList/PickersSectionList.js +1 -1
  90. package/modern/TimeClock/TimeClock.js +4 -2
  91. package/modern/hooks/useClearableField.js +3 -3
  92. package/modern/index.js +1 -1
  93. package/modern/internals/components/PickersInput/PickersFilledInput.js +2 -2
  94. package/modern/internals/components/PickersInput/PickersInput.js +2 -3
  95. package/modern/internals/components/PickersInput/PickersStandardInput.js +2 -2
  96. package/modern/internals/hooks/useField/useField.utils.js +5 -5
  97. package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
  98. package/modern/internals/hooks/useUtils.js +2 -2
  99. package/modern/internals/hooks/useViews.js +15 -15
  100. package/modern/internals/index.js +6 -2
  101. package/modern/internals/utils/views.js +1 -1
  102. package/modern/locales/index.js +1 -0
  103. package/node/AdapterDateFns/AdapterDateFns.js +11 -254
  104. package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
  105. package/node/AdapterDateFnsBase/index.js +12 -0
  106. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
  107. package/node/AdapterDateFnsV3/index.js +12 -0
  108. package/node/DateCalendar/DateCalendar.js +6 -4
  109. package/node/DatePicker/DatePickerToolbar.js +0 -4
  110. package/node/DigitalClock/DigitalClock.js +4 -2
  111. package/node/LocalizationProvider/LocalizationProvider.js +1 -1
  112. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +10 -13
  113. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  114. package/node/PickersSectionList/PickersSectionList.js +1 -1
  115. package/node/TimeClock/TimeClock.js +4 -2
  116. package/node/hooks/useClearableField.js +3 -3
  117. package/node/index.js +1 -1
  118. package/node/internals/components/PickersInput/PickersFilledInput.js +2 -2
  119. package/node/internals/components/PickersInput/PickersInput.js +2 -3
  120. package/node/internals/components/PickersInput/PickersStandardInput.js +2 -2
  121. package/node/internals/hooks/useField/useField.utils.js +5 -5
  122. package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
  123. package/node/internals/hooks/useUtils.js +2 -2
  124. package/node/internals/hooks/useViews.js +15 -15
  125. package/node/internals/index.js +47 -1
  126. package/node/internals/utils/views.js +1 -1
  127. package/node/locales/index.js +11 -0
  128. package/package.json +6 -6
@@ -1,7 +1,11 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5
9
  /* eslint-disable class-methods-use-this */
6
10
  import addDays from 'date-fns/addDays';
7
11
  import addSeconds from 'date-fns/addSeconds';
@@ -48,196 +52,7 @@ import isWithinInterval from 'date-fns/isWithinInterval';
48
52
  import defaultLocale from 'date-fns/locale/en-US';
49
53
  // @ts-ignore
50
54
  import longFormatters from 'date-fns/_lib/format/longFormatters';
51
- var formatTokenMap = {
52
- // Year
53
- y: {
54
- sectionType: 'year',
55
- contentType: 'digit',
56
- maxLength: 4
57
- },
58
- yy: 'year',
59
- yyy: {
60
- sectionType: 'year',
61
- contentType: 'digit',
62
- maxLength: 4
63
- },
64
- yyyy: 'year',
65
- // Month
66
- M: {
67
- sectionType: 'month',
68
- contentType: 'digit',
69
- maxLength: 2
70
- },
71
- MM: 'month',
72
- MMMM: {
73
- sectionType: 'month',
74
- contentType: 'letter'
75
- },
76
- MMM: {
77
- sectionType: 'month',
78
- contentType: 'letter'
79
- },
80
- L: {
81
- sectionType: 'month',
82
- contentType: 'digit',
83
- maxLength: 2
84
- },
85
- LL: 'month',
86
- LLL: {
87
- sectionType: 'month',
88
- contentType: 'letter'
89
- },
90
- LLLL: {
91
- sectionType: 'month',
92
- contentType: 'letter'
93
- },
94
- // Day of the month
95
- d: {
96
- sectionType: 'day',
97
- contentType: 'digit',
98
- maxLength: 2
99
- },
100
- dd: 'day',
101
- do: {
102
- sectionType: 'day',
103
- contentType: 'digit-with-letter'
104
- },
105
- // Day of the week
106
- E: {
107
- sectionType: 'weekDay',
108
- contentType: 'letter'
109
- },
110
- EE: {
111
- sectionType: 'weekDay',
112
- contentType: 'letter'
113
- },
114
- EEE: {
115
- sectionType: 'weekDay',
116
- contentType: 'letter'
117
- },
118
- EEEE: {
119
- sectionType: 'weekDay',
120
- contentType: 'letter'
121
- },
122
- EEEEE: {
123
- sectionType: 'weekDay',
124
- contentType: 'letter'
125
- },
126
- i: {
127
- sectionType: 'weekDay',
128
- contentType: 'digit',
129
- maxLength: 1
130
- },
131
- ii: 'weekDay',
132
- iii: {
133
- sectionType: 'weekDay',
134
- contentType: 'letter'
135
- },
136
- iiii: {
137
- sectionType: 'weekDay',
138
- contentType: 'letter'
139
- },
140
- e: {
141
- sectionType: 'weekDay',
142
- contentType: 'digit',
143
- maxLength: 1
144
- },
145
- ee: 'weekDay',
146
- eee: {
147
- sectionType: 'weekDay',
148
- contentType: 'letter'
149
- },
150
- eeee: {
151
- sectionType: 'weekDay',
152
- contentType: 'letter'
153
- },
154
- eeeee: {
155
- sectionType: 'weekDay',
156
- contentType: 'letter'
157
- },
158
- eeeeee: {
159
- sectionType: 'weekDay',
160
- contentType: 'letter'
161
- },
162
- c: {
163
- sectionType: 'weekDay',
164
- contentType: 'digit',
165
- maxLength: 1
166
- },
167
- cc: 'weekDay',
168
- ccc: {
169
- sectionType: 'weekDay',
170
- contentType: 'letter'
171
- },
172
- cccc: {
173
- sectionType: 'weekDay',
174
- contentType: 'letter'
175
- },
176
- ccccc: {
177
- sectionType: 'weekDay',
178
- contentType: 'letter'
179
- },
180
- cccccc: {
181
- sectionType: 'weekDay',
182
- contentType: 'letter'
183
- },
184
- // Meridiem
185
- a: 'meridiem',
186
- aa: 'meridiem',
187
- aaa: 'meridiem',
188
- // Hours
189
- H: {
190
- sectionType: 'hours',
191
- contentType: 'digit',
192
- maxLength: 2
193
- },
194
- HH: 'hours',
195
- h: {
196
- sectionType: 'hours',
197
- contentType: 'digit',
198
- maxLength: 2
199
- },
200
- hh: 'hours',
201
- // Minutes
202
- m: {
203
- sectionType: 'minutes',
204
- contentType: 'digit',
205
- maxLength: 2
206
- },
207
- mm: 'minutes',
208
- // Seconds
209
- s: {
210
- sectionType: 'seconds',
211
- contentType: 'digit',
212
- maxLength: 2
213
- },
214
- ss: 'seconds'
215
- };
216
- var defaultFormats = {
217
- year: 'yyyy',
218
- month: 'LLLL',
219
- monthShort: 'MMM',
220
- dayOfMonth: 'd',
221
- weekday: 'EEEE',
222
- weekdayShort: 'EEEEEE',
223
- hours24h: 'HH',
224
- hours12h: 'hh',
225
- meridiem: 'aa',
226
- minutes: 'mm',
227
- seconds: 'ss',
228
- fullDate: 'PP',
229
- keyboardDate: 'P',
230
- shortDate: 'MMM d',
231
- normalDate: 'd MMMM',
232
- normalDateWithWeekday: 'EEE, MMM d',
233
- fullTime: 'p',
234
- fullTime12h: 'hh:mm aa',
235
- fullTime24h: 'HH:mm',
236
- keyboardDateTime: 'P p',
237
- keyboardDateTime12h: 'P hh:mm aa',
238
- keyboardDateTime24h: 'P HH:mm'
239
- };
240
-
55
+ import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
241
56
  /**
242
57
  * Based on `@date-io/date-fns`
243
58
  *
@@ -263,272 +78,221 @@ var defaultFormats = {
263
78
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
264
79
  * SOFTWARE.
265
80
  */
266
- export var AdapterDateFns = /*#__PURE__*/_createClass(function AdapterDateFns() {
267
- var _this = this;
268
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
269
- _locale = _ref.locale,
270
- formats = _ref.formats;
271
- _classCallCheck(this, AdapterDateFns);
272
- this.isMUIAdapter = true;
273
- this.isTimezoneCompatible = false;
274
- this.lib = 'date-fns';
275
- this.locale = void 0;
276
- this.formats = void 0;
277
- this.formatTokenMap = formatTokenMap;
278
- this.escapedCharacters = {
279
- start: "'",
280
- end: "'"
281
- };
282
- this.date = function (value) {
283
- if (typeof value === 'undefined') {
284
- return new Date();
81
+ export var AdapterDateFns = /*#__PURE__*/function (_ref) {
82
+ _inherits(AdapterDateFns, _ref);
83
+ function AdapterDateFns() {
84
+ var _this;
85
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
86
+ locale = _ref2.locale,
87
+ formats = _ref2.formats;
88
+ _classCallCheck(this, AdapterDateFns);
89
+ if (typeof addDays !== 'function') {
90
+ throw new Error(['MUI: The `date-fns` package v3.x is not compatible with this adapter.', 'Please, install v2.x of the package or use the `AdapterDateFnsV3` instead.'].join('\n'));
285
91
  }
286
- if (value === null) {
287
- return null;
288
- }
289
- return new Date(value);
290
- };
291
- this.getInvalidDate = function () {
292
- return new Date('Invalid Date');
293
- };
294
- this.getTimezone = function () {
295
- return 'default';
296
- };
297
- this.setTimezone = function (value) {
298
- return value;
299
- };
300
- this.toJsDate = function (value) {
301
- return value;
302
- };
303
- this.parse = function (value, format) {
304
- if (value === '') {
305
- return null;
306
- }
307
- return dateFnsParse(value, format, new Date(), {
308
- locale: _this.locale
309
- });
310
- };
311
- this.getCurrentLocaleCode = function () {
312
- var _this$locale;
313
- return ((_this$locale = _this.locale) == null ? void 0 : _this$locale.code) || 'en-US';
314
- };
315
- // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
316
- // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
317
- this.is12HourCycleInCurrentLocale = function () {
318
- if (_this.locale) {
319
- return /a/.test(_this.locale.formatLong.time());
320
- }
321
-
322
- // By default, date-fns is using en-US locale with am/pm enabled
323
- return true;
324
- };
325
- this.expandFormat = function (format) {
326
- var longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
327
-
328
- // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
329
- return format.match(longFormatRegexp).map(function (token) {
330
- var firstCharacter = token[0];
331
- if (firstCharacter === 'p' || firstCharacter === 'P') {
332
- var longFormatter = longFormatters[firstCharacter];
333
- var locale = _this.locale || defaultLocale;
334
- return longFormatter(token, locale.formatLong, {});
92
+ _this = _callSuper(this, AdapterDateFns, [{
93
+ locale: locale != null ? locale : defaultLocale,
94
+ formats: formats,
95
+ longFormatters: longFormatters
96
+ }]);
97
+ _this.parse = function (value, format) {
98
+ if (value === '') {
99
+ return null;
335
100
  }
336
- return token;
337
- }).join('');
338
- };
339
- this.isValid = function (value) {
340
- if (value == null) {
341
- return false;
342
- }
343
- return isValid(value);
344
- };
345
- this.format = function (value, formatKey) {
346
- return _this.formatByString(value, _this.formats[formatKey]);
347
- };
348
- this.formatByString = function (value, formatString) {
349
- return dateFnsFormat(value, formatString, {
350
- locale: _this.locale
351
- });
352
- };
353
- this.formatNumber = function (numberToFormat) {
354
- return numberToFormat;
355
- };
356
- this.isEqual = function (value, comparing) {
357
- if (value === null && comparing === null) {
358
- return true;
359
- }
360
- if (value === null || comparing === null) {
361
- return false;
362
- }
363
- return isEqual(value, comparing);
364
- };
365
- this.isSameYear = function (value, comparing) {
366
- return isSameYear(value, comparing);
367
- };
368
- this.isSameMonth = function (value, comparing) {
369
- return isSameMonth(value, comparing);
370
- };
371
- this.isSameDay = function (value, comparing) {
372
- return isSameDay(value, comparing);
373
- };
374
- this.isSameHour = function (value, comparing) {
375
- return isSameHour(value, comparing);
376
- };
377
- this.isAfter = function (value, comparing) {
378
- return isAfter(value, comparing);
379
- };
380
- this.isAfterYear = function (value, comparing) {
381
- return isAfter(value, endOfYear(comparing));
382
- };
383
- this.isAfterDay = function (value, comparing) {
384
- return isAfter(value, endOfDay(comparing));
385
- };
386
- this.isBefore = function (value, comparing) {
387
- return isBefore(value, comparing);
388
- };
389
- this.isBeforeYear = function (value, comparing) {
390
- return isBefore(value, _this.startOfYear(comparing));
391
- };
392
- this.isBeforeDay = function (value, comparing) {
393
- return isBefore(value, _this.startOfDay(comparing));
394
- };
395
- this.isWithinRange = function (value, _ref2) {
396
- var _ref3 = _slicedToArray(_ref2, 2),
397
- start = _ref3[0],
398
- end = _ref3[1];
399
- return isWithinInterval(value, {
400
- start: start,
401
- end: end
402
- });
403
- };
404
- this.startOfYear = function (value) {
405
- return startOfYear(value);
406
- };
407
- this.startOfMonth = function (value) {
408
- return startOfMonth(value);
409
- };
410
- this.startOfWeek = function (value) {
411
- return startOfWeek(value, {
412
- locale: _this.locale
413
- });
414
- };
415
- this.startOfDay = function (value) {
416
- return startOfDay(value);
417
- };
418
- this.endOfYear = function (value) {
419
- return endOfYear(value);
420
- };
421
- this.endOfMonth = function (value) {
422
- return endOfMonth(value);
423
- };
424
- this.endOfWeek = function (value) {
425
- return endOfWeek(value, {
426
- locale: _this.locale
427
- });
428
- };
429
- this.endOfDay = function (value) {
430
- return endOfDay(value);
431
- };
432
- this.addYears = function (value, amount) {
433
- return addYears(value, amount);
434
- };
435
- this.addMonths = function (value, amount) {
436
- return addMonths(value, amount);
437
- };
438
- this.addWeeks = function (value, amount) {
439
- return addWeeks(value, amount);
440
- };
441
- this.addDays = function (value, amount) {
442
- return addDays(value, amount);
443
- };
444
- this.addHours = function (value, amount) {
445
- return addHours(value, amount);
446
- };
447
- this.addMinutes = function (value, amount) {
448
- return addMinutes(value, amount);
449
- };
450
- this.addSeconds = function (value, amount) {
451
- return addSeconds(value, amount);
452
- };
453
- this.getYear = function (value) {
454
- return getYear(value);
455
- };
456
- this.getMonth = function (value) {
457
- return getMonth(value);
458
- };
459
- this.getDate = function (value) {
460
- return getDate(value);
461
- };
462
- this.getHours = function (value) {
463
- return getHours(value);
464
- };
465
- this.getMinutes = function (value) {
466
- return getMinutes(value);
467
- };
468
- this.getSeconds = function (value) {
469
- return getSeconds(value);
470
- };
471
- this.getMilliseconds = function (value) {
472
- return getMilliseconds(value);
473
- };
474
- this.setYear = function (value, year) {
475
- return setYear(value, year);
476
- };
477
- this.setMonth = function (value, month) {
478
- return setMonth(value, month);
479
- };
480
- this.setDate = function (value, date) {
481
- return setDate(value, date);
482
- };
483
- this.setHours = function (value, hours) {
484
- return setHours(value, hours);
485
- };
486
- this.setMinutes = function (value, minutes) {
487
- return setMinutes(value, minutes);
488
- };
489
- this.setSeconds = function (value, seconds) {
490
- return setSeconds(value, seconds);
491
- };
492
- this.setMilliseconds = function (value, milliseconds) {
493
- return setMilliseconds(value, milliseconds);
494
- };
495
- this.getDaysInMonth = function (value) {
496
- return getDaysInMonth(value);
497
- };
498
- this.getWeekArray = function (value) {
499
- var start = _this.startOfWeek(_this.startOfMonth(value));
500
- var end = _this.endOfWeek(_this.endOfMonth(value));
501
- var count = 0;
502
- var current = start;
503
- var nestedWeeks = [];
504
- while (_this.isBefore(current, end)) {
505
- var weekNumber = Math.floor(count / 7);
506
- nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
507
- nestedWeeks[weekNumber].push(current);
508
- current = _this.addDays(current, 1);
509
- count += 1;
510
- }
511
- return nestedWeeks;
512
- };
513
- this.getWeekNumber = function (value) {
514
- return getWeek(value, {
515
- locale: _this.locale
516
- });
517
- };
518
- this.getYearRange = function (_ref4) {
519
- var _ref5 = _slicedToArray(_ref4, 2),
520
- start = _ref5[0],
521
- end = _ref5[1];
522
- var startDate = _this.startOfYear(start);
523
- var endDate = _this.endOfYear(end);
524
- var years = [];
525
- var current = startDate;
526
- while (_this.isBefore(current, endDate)) {
527
- years.push(current);
528
- current = _this.addYears(current, 1);
529
- }
530
- return years;
531
- };
532
- this.locale = _locale;
533
- this.formats = _extends({}, defaultFormats, formats);
534
- });
101
+ return dateFnsParse(value, format, new Date(), {
102
+ locale: _this.locale
103
+ });
104
+ };
105
+ _this.isValid = function (value) {
106
+ if (value == null) {
107
+ return false;
108
+ }
109
+ return isValid(value);
110
+ };
111
+ _this.format = function (value, formatKey) {
112
+ return _this.formatByString(value, _this.formats[formatKey]);
113
+ };
114
+ _this.formatByString = function (value, formatString) {
115
+ return dateFnsFormat(value, formatString, {
116
+ locale: _this.locale
117
+ });
118
+ };
119
+ _this.isEqual = function (value, comparing) {
120
+ if (value === null && comparing === null) {
121
+ return true;
122
+ }
123
+ if (value === null || comparing === null) {
124
+ return false;
125
+ }
126
+ return isEqual(value, comparing);
127
+ };
128
+ _this.isSameYear = function (value, comparing) {
129
+ return isSameYear(value, comparing);
130
+ };
131
+ _this.isSameMonth = function (value, comparing) {
132
+ return isSameMonth(value, comparing);
133
+ };
134
+ _this.isSameDay = function (value, comparing) {
135
+ return isSameDay(value, comparing);
136
+ };
137
+ _this.isSameHour = function (value, comparing) {
138
+ return isSameHour(value, comparing);
139
+ };
140
+ _this.isAfter = function (value, comparing) {
141
+ return isAfter(value, comparing);
142
+ };
143
+ _this.isAfterYear = function (value, comparing) {
144
+ return isAfter(value, endOfYear(comparing));
145
+ };
146
+ _this.isAfterDay = function (value, comparing) {
147
+ return isAfter(value, endOfDay(comparing));
148
+ };
149
+ _this.isBefore = function (value, comparing) {
150
+ return isBefore(value, comparing);
151
+ };
152
+ _this.isBeforeYear = function (value, comparing) {
153
+ return isBefore(value, _this.startOfYear(comparing));
154
+ };
155
+ _this.isBeforeDay = function (value, comparing) {
156
+ return isBefore(value, _this.startOfDay(comparing));
157
+ };
158
+ _this.isWithinRange = function (value, _ref3) {
159
+ var _ref4 = _slicedToArray(_ref3, 2),
160
+ start = _ref4[0],
161
+ end = _ref4[1];
162
+ return isWithinInterval(value, {
163
+ start: start,
164
+ end: end
165
+ });
166
+ };
167
+ _this.startOfYear = function (value) {
168
+ return startOfYear(value);
169
+ };
170
+ _this.startOfMonth = function (value) {
171
+ return startOfMonth(value);
172
+ };
173
+ _this.startOfWeek = function (value) {
174
+ return startOfWeek(value, {
175
+ locale: _this.locale
176
+ });
177
+ };
178
+ _this.startOfDay = function (value) {
179
+ return startOfDay(value);
180
+ };
181
+ _this.endOfYear = function (value) {
182
+ return endOfYear(value);
183
+ };
184
+ _this.endOfMonth = function (value) {
185
+ return endOfMonth(value);
186
+ };
187
+ _this.endOfWeek = function (value) {
188
+ return endOfWeek(value, {
189
+ locale: _this.locale
190
+ });
191
+ };
192
+ _this.endOfDay = function (value) {
193
+ return endOfDay(value);
194
+ };
195
+ _this.addYears = function (value, amount) {
196
+ return addYears(value, amount);
197
+ };
198
+ _this.addMonths = function (value, amount) {
199
+ return addMonths(value, amount);
200
+ };
201
+ _this.addWeeks = function (value, amount) {
202
+ return addWeeks(value, amount);
203
+ };
204
+ _this.addDays = function (value, amount) {
205
+ return addDays(value, amount);
206
+ };
207
+ _this.addHours = function (value, amount) {
208
+ return addHours(value, amount);
209
+ };
210
+ _this.addMinutes = function (value, amount) {
211
+ return addMinutes(value, amount);
212
+ };
213
+ _this.addSeconds = function (value, amount) {
214
+ return addSeconds(value, amount);
215
+ };
216
+ _this.getYear = function (value) {
217
+ return getYear(value);
218
+ };
219
+ _this.getMonth = function (value) {
220
+ return getMonth(value);
221
+ };
222
+ _this.getDate = function (value) {
223
+ return getDate(value);
224
+ };
225
+ _this.getHours = function (value) {
226
+ return getHours(value);
227
+ };
228
+ _this.getMinutes = function (value) {
229
+ return getMinutes(value);
230
+ };
231
+ _this.getSeconds = function (value) {
232
+ return getSeconds(value);
233
+ };
234
+ _this.getMilliseconds = function (value) {
235
+ return getMilliseconds(value);
236
+ };
237
+ _this.setYear = function (value, year) {
238
+ return setYear(value, year);
239
+ };
240
+ _this.setMonth = function (value, month) {
241
+ return setMonth(value, month);
242
+ };
243
+ _this.setDate = function (value, date) {
244
+ return setDate(value, date);
245
+ };
246
+ _this.setHours = function (value, hours) {
247
+ return setHours(value, hours);
248
+ };
249
+ _this.setMinutes = function (value, minutes) {
250
+ return setMinutes(value, minutes);
251
+ };
252
+ _this.setSeconds = function (value, seconds) {
253
+ return setSeconds(value, seconds);
254
+ };
255
+ _this.setMilliseconds = function (value, milliseconds) {
256
+ return setMilliseconds(value, milliseconds);
257
+ };
258
+ _this.getDaysInMonth = function (value) {
259
+ return getDaysInMonth(value);
260
+ };
261
+ _this.getWeekArray = function (value) {
262
+ var start = _this.startOfWeek(_this.startOfMonth(value));
263
+ var end = _this.endOfWeek(_this.endOfMonth(value));
264
+ var count = 0;
265
+ var current = start;
266
+ var nestedWeeks = [];
267
+ while (_this.isBefore(current, end)) {
268
+ var weekNumber = Math.floor(count / 7);
269
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
270
+ nestedWeeks[weekNumber].push(current);
271
+ current = _this.addDays(current, 1);
272
+ count += 1;
273
+ }
274
+ return nestedWeeks;
275
+ };
276
+ _this.getWeekNumber = function (value) {
277
+ return getWeek(value, {
278
+ locale: _this.locale
279
+ });
280
+ };
281
+ _this.getYearRange = function (_ref5) {
282
+ var _ref6 = _slicedToArray(_ref5, 2),
283
+ start = _ref6[0],
284
+ end = _ref6[1];
285
+ var startDate = _this.startOfYear(start);
286
+ var endDate = _this.endOfYear(end);
287
+ var years = [];
288
+ var current = startDate;
289
+ while (_this.isBefore(current, endDate)) {
290
+ years.push(current);
291
+ current = _this.addYears(current, 1);
292
+ }
293
+ return years;
294
+ };
295
+ return _this;
296
+ }
297
+ return _createClass(AdapterDateFns);
298
+ }(AdapterDateFnsBase);