@mui/x-date-pickers 7.0.0-alpha.7 → 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.
- package/AdapterDateFns/AdapterDateFns.d.ts +4 -21
- package/AdapterDateFns/AdapterDateFns.js +11 -255
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +62 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +291 -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 +80 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/CHANGELOG.md +175 -49
- package/DatePicker/DatePickerToolbar.d.ts +2 -2
- package/DatePicker/DatePickerToolbar.js +2 -7
- package/DigitalClock/DigitalClock.js +1 -0
- package/DigitalClock/DigitalClock.types.d.ts +5 -0
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
- package/PickersSectionList/PickersSectionList.js +1 -1
- package/TimeClock/TimeClock.js +1 -0
- package/TimeClock/TimeClock.types.d.ts +5 -0
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/components/PickersInput/PickersInput.d.ts +2 -4
- package/internals/components/PickersInput/PickersInput.js +2 -3
- package/internals/hooks/useField/useField.utils.js +5 -5
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/internals/hooks/useUtils.js +2 -2
- package/internals/hooks/useViews.js +2 -2
- package/internals/index.d.ts +9 -3
- package/internals/index.js +6 -2
- package/internals/models/common.d.ts +1 -1
- package/internals/models/helpers.d.ts +1 -0
- package/internals/utils/views.js +1 -1
- package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
- package/legacy/DatePicker/DatePickerToolbar.js +2 -7
- package/legacy/DigitalClock/DigitalClock.js +1 -0
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/legacy/PickersSectionList/PickersSectionList.js +1 -1
- package/legacy/TimeClock/TimeClock.js +1 -0
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
- package/legacy/internals/hooks/useField/useField.utils.js +5 -5
- package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/legacy/internals/hooks/useUtils.js +2 -2
- package/legacy/internals/hooks/useViews.js +2 -2
- package/legacy/internals/index.js +6 -2
- package/legacy/internals/utils/views.js +1 -1
- package/legacy/locales/index.js +1 -0
- package/locales/enUS.d.ts +1 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/mk.d.ts +1 -1
- package/locales/utils/getPickersLocalization.d.ts +1 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/DatePicker/DatePickerToolbar.js +2 -7
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersSectionList/PickersSectionList.js +1 -1
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersInput/PickersInput.js +2 -3
- package/modern/internals/hooks/useField/useField.utils.js +5 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/modern/internals/hooks/useUtils.js +2 -2
- package/modern/internals/hooks/useViews.js +2 -2
- package/modern/internals/index.js +6 -2
- package/modern/internals/utils/views.js +1 -1
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -254
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/DatePicker/DatePickerToolbar.js +0 -4
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersSectionList/PickersSectionList.js +1 -1
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/components/PickersInput/PickersInput.js +2 -3
- package/node/internals/hooks/useField/useField.utils.js +5 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/node/internals/hooks/useUtils.js +2 -2
- package/node/internals/hooks/useViews.js +2 -2
- package/node/internals/index.js +47 -1
- package/node/internals/utils/views.js +1 -1
- package/node/locales/index.js +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,293 @@
|
|
|
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
|
+
keyboardDate: 'P',
|
|
185
|
+
shortDate: 'MMM d',
|
|
186
|
+
normalDate: 'd MMMM',
|
|
187
|
+
normalDateWithWeekday: 'EEE, MMM d',
|
|
188
|
+
fullTime: 'p',
|
|
189
|
+
fullTime12h: 'hh:mm aa',
|
|
190
|
+
fullTime24h: 'HH:mm',
|
|
191
|
+
keyboardDateTime: 'P p',
|
|
192
|
+
keyboardDateTime12h: 'P hh:mm aa',
|
|
193
|
+
keyboardDateTime24h: 'P HH:mm'
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Based on `@date-io/date-fns`
|
|
197
|
+
*
|
|
198
|
+
* MIT License
|
|
199
|
+
*
|
|
200
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
201
|
+
*
|
|
202
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
203
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
204
|
+
* in the Software without restriction, including without limitation the rights
|
|
205
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
206
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
207
|
+
* furnished to do so, subject to the following conditions:
|
|
208
|
+
*
|
|
209
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
210
|
+
* copies or substantial portions of the Software.
|
|
211
|
+
*
|
|
212
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
213
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
214
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
215
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
216
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
217
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
218
|
+
* SOFTWARE.
|
|
219
|
+
*/
|
|
220
|
+
export var AdapterDateFnsBase = /*#__PURE__*/_createClass(function AdapterDateFnsBase(props) {
|
|
221
|
+
var _this = this;
|
|
222
|
+
_classCallCheck(this, AdapterDateFnsBase);
|
|
223
|
+
this.isMUIAdapter = true;
|
|
224
|
+
this.isTimezoneCompatible = false;
|
|
225
|
+
this.lib = 'date-fns';
|
|
226
|
+
this.locale = void 0;
|
|
227
|
+
this.formats = void 0;
|
|
228
|
+
this.formatTokenMap = formatTokenMap;
|
|
229
|
+
this.escapedCharacters = {
|
|
230
|
+
start: "'",
|
|
231
|
+
end: "'"
|
|
232
|
+
};
|
|
233
|
+
this.longFormatters = void 0;
|
|
234
|
+
this.date = function (value) {
|
|
235
|
+
if (typeof value === 'undefined') {
|
|
236
|
+
return new Date();
|
|
237
|
+
}
|
|
238
|
+
if (value === null) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
return new Date(value);
|
|
242
|
+
};
|
|
243
|
+
this.getInvalidDate = function () {
|
|
244
|
+
return new Date('Invalid Date');
|
|
245
|
+
};
|
|
246
|
+
this.getTimezone = function () {
|
|
247
|
+
return 'default';
|
|
248
|
+
};
|
|
249
|
+
this.setTimezone = function (value) {
|
|
250
|
+
return value;
|
|
251
|
+
};
|
|
252
|
+
this.toJsDate = function (value) {
|
|
253
|
+
return value;
|
|
254
|
+
};
|
|
255
|
+
this.getCurrentLocaleCode = function () {
|
|
256
|
+
var _this$locale;
|
|
257
|
+
return ((_this$locale = _this.locale) == null ? void 0 : _this$locale.code) || 'en-US';
|
|
258
|
+
};
|
|
259
|
+
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
260
|
+
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
261
|
+
this.is12HourCycleInCurrentLocale = function () {
|
|
262
|
+
if (_this.locale) {
|
|
263
|
+
return /a/.test(_this.locale.formatLong.time({
|
|
264
|
+
width: 'short'
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// By default, date-fns is using en-US locale with am/pm enabled
|
|
269
|
+
return true;
|
|
270
|
+
};
|
|
271
|
+
this.expandFormat = function (format) {
|
|
272
|
+
var longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
273
|
+
|
|
274
|
+
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
275
|
+
return format.match(longFormatRegexp).map(function (token) {
|
|
276
|
+
var firstCharacter = token[0];
|
|
277
|
+
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
278
|
+
var longFormatter = _this.longFormatters[firstCharacter];
|
|
279
|
+
return longFormatter(token, _this.locale.formatLong);
|
|
280
|
+
}
|
|
281
|
+
return token;
|
|
282
|
+
}).join('');
|
|
283
|
+
};
|
|
284
|
+
this.formatNumber = function (numberToFormat) {
|
|
285
|
+
return numberToFormat;
|
|
286
|
+
};
|
|
287
|
+
var locale = props.locale,
|
|
288
|
+
formats = props.formats,
|
|
289
|
+
longFormatters = props.longFormatters;
|
|
290
|
+
this.locale = locale;
|
|
291
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
292
|
+
this.longFormatters = longFormatters;
|
|
293
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFnsBase } from './AdapterDateFnsBase';
|
|
@@ -0,0 +1,306 @@
|
|
|
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 _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; })(); }
|
|
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 { endOfDay } from 'date-fns/endOfDay';
|
|
20
|
+
import { endOfWeek } from 'date-fns/endOfWeek';
|
|
21
|
+
import { endOfYear } from 'date-fns/endOfYear';
|
|
22
|
+
// @ts-ignore TODO remove when date-fns-v3 is the default
|
|
23
|
+
import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
|
|
24
|
+
import { getDate } from 'date-fns/getDate';
|
|
25
|
+
import { getDaysInMonth } from 'date-fns/getDaysInMonth';
|
|
26
|
+
import { getHours } from 'date-fns/getHours';
|
|
27
|
+
import { getMinutes } from 'date-fns/getMinutes';
|
|
28
|
+
import { getMonth } from 'date-fns/getMonth';
|
|
29
|
+
import { getSeconds } from 'date-fns/getSeconds';
|
|
30
|
+
import { getMilliseconds } from 'date-fns/getMilliseconds';
|
|
31
|
+
import { getWeek } from 'date-fns/getWeek';
|
|
32
|
+
import { getYear } from 'date-fns/getYear';
|
|
33
|
+
import { isAfter } from 'date-fns/isAfter';
|
|
34
|
+
import { isBefore } from 'date-fns/isBefore';
|
|
35
|
+
import { isEqual } from 'date-fns/isEqual';
|
|
36
|
+
import { isSameDay } from 'date-fns/isSameDay';
|
|
37
|
+
import { isSameYear } from 'date-fns/isSameYear';
|
|
38
|
+
import { isSameMonth } from 'date-fns/isSameMonth';
|
|
39
|
+
import { isSameHour } from 'date-fns/isSameHour';
|
|
40
|
+
import { isValid } from 'date-fns/isValid';
|
|
41
|
+
import { parse as dateFnsParse } from 'date-fns/parse';
|
|
42
|
+
import { setDate } from 'date-fns/setDate';
|
|
43
|
+
import { setHours } from 'date-fns/setHours';
|
|
44
|
+
import { setMinutes } from 'date-fns/setMinutes';
|
|
45
|
+
import { setMonth } from 'date-fns/setMonth';
|
|
46
|
+
import { setSeconds } from 'date-fns/setSeconds';
|
|
47
|
+
import { setMilliseconds } from 'date-fns/setMilliseconds';
|
|
48
|
+
import { setYear } from 'date-fns/setYear';
|
|
49
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
50
|
+
import { startOfMonth } from 'date-fns/startOfMonth';
|
|
51
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
52
|
+
import { startOfWeek } from 'date-fns/startOfWeek';
|
|
53
|
+
import { startOfYear } from 'date-fns/startOfYear';
|
|
54
|
+
import { isWithinInterval } from 'date-fns/isWithinInterval';
|
|
55
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
56
|
+
// date-fns v2 does not export types
|
|
57
|
+
// @ts-ignore TODO remove when date-fns-v3 is the default
|
|
58
|
+
|
|
59
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Based on `@date-io/date-fns`
|
|
63
|
+
*
|
|
64
|
+
* MIT License
|
|
65
|
+
*
|
|
66
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
67
|
+
*
|
|
68
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
69
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
70
|
+
* in the Software without restriction, including without limitation the rights
|
|
71
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
72
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
73
|
+
* furnished to do so, subject to the following conditions:
|
|
74
|
+
*
|
|
75
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
76
|
+
* copies or substantial portions of the Software.
|
|
77
|
+
*
|
|
78
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
79
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
80
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
81
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
82
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
83
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
84
|
+
* SOFTWARE.
|
|
85
|
+
*/
|
|
86
|
+
export var AdapterDateFns = /*#__PURE__*/function (_ref) {
|
|
87
|
+
_inherits(AdapterDateFns, _ref);
|
|
88
|
+
function AdapterDateFns() {
|
|
89
|
+
var _this;
|
|
90
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
91
|
+
locale = _ref2.locale,
|
|
92
|
+
formats = _ref2.formats;
|
|
93
|
+
_classCallCheck(this, AdapterDateFns);
|
|
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
|
+
_this = _callSuper(this, AdapterDateFns, [{
|
|
101
|
+
locale: locale != null ? locale : enUS,
|
|
102
|
+
formats: formats,
|
|
103
|
+
longFormatters: longFormatters
|
|
104
|
+
}]);
|
|
105
|
+
_this.parse = function (value, format) {
|
|
106
|
+
if (value === '') {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
return dateFnsParse(value, format, new Date(), {
|
|
110
|
+
locale: _this.locale
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
_this.isValid = function (value) {
|
|
114
|
+
if (value == null) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return isValid(value);
|
|
118
|
+
};
|
|
119
|
+
_this.format = function (value, formatKey) {
|
|
120
|
+
return _this.formatByString(value, _this.formats[formatKey]);
|
|
121
|
+
};
|
|
122
|
+
_this.formatByString = function (value, formatString) {
|
|
123
|
+
return dateFnsFormat(value, formatString, {
|
|
124
|
+
locale: _this.locale
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
_this.isEqual = function (value, comparing) {
|
|
128
|
+
if (value === null && comparing === null) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
if (value === null || comparing === null) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return isEqual(value, comparing);
|
|
135
|
+
};
|
|
136
|
+
_this.isSameYear = function (value, comparing) {
|
|
137
|
+
return isSameYear(value, comparing);
|
|
138
|
+
};
|
|
139
|
+
_this.isSameMonth = function (value, comparing) {
|
|
140
|
+
return isSameMonth(value, comparing);
|
|
141
|
+
};
|
|
142
|
+
_this.isSameDay = function (value, comparing) {
|
|
143
|
+
return isSameDay(value, comparing);
|
|
144
|
+
};
|
|
145
|
+
_this.isSameHour = function (value, comparing) {
|
|
146
|
+
return isSameHour(value, comparing);
|
|
147
|
+
};
|
|
148
|
+
_this.isAfter = function (value, comparing) {
|
|
149
|
+
return isAfter(value, comparing);
|
|
150
|
+
};
|
|
151
|
+
_this.isAfterYear = function (value, comparing) {
|
|
152
|
+
return isAfter(value, endOfYear(comparing));
|
|
153
|
+
};
|
|
154
|
+
_this.isAfterDay = function (value, comparing) {
|
|
155
|
+
return isAfter(value, endOfDay(comparing));
|
|
156
|
+
};
|
|
157
|
+
_this.isBefore = function (value, comparing) {
|
|
158
|
+
return isBefore(value, comparing);
|
|
159
|
+
};
|
|
160
|
+
_this.isBeforeYear = function (value, comparing) {
|
|
161
|
+
return isBefore(value, _this.startOfYear(comparing));
|
|
162
|
+
};
|
|
163
|
+
_this.isBeforeDay = function (value, comparing) {
|
|
164
|
+
return isBefore(value, _this.startOfDay(comparing));
|
|
165
|
+
};
|
|
166
|
+
_this.isWithinRange = function (value, _ref3) {
|
|
167
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
168
|
+
start = _ref4[0],
|
|
169
|
+
end = _ref4[1];
|
|
170
|
+
return isWithinInterval(value, {
|
|
171
|
+
start: start,
|
|
172
|
+
end: end
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
_this.startOfYear = function (value) {
|
|
176
|
+
return startOfYear(value);
|
|
177
|
+
};
|
|
178
|
+
_this.startOfMonth = function (value) {
|
|
179
|
+
return startOfMonth(value);
|
|
180
|
+
};
|
|
181
|
+
_this.startOfWeek = function (value) {
|
|
182
|
+
return startOfWeek(value, {
|
|
183
|
+
locale: _this.locale
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
_this.startOfDay = function (value) {
|
|
187
|
+
return startOfDay(value);
|
|
188
|
+
};
|
|
189
|
+
_this.endOfYear = function (value) {
|
|
190
|
+
return endOfYear(value);
|
|
191
|
+
};
|
|
192
|
+
_this.endOfMonth = function (value) {
|
|
193
|
+
return endOfMonth(value);
|
|
194
|
+
};
|
|
195
|
+
_this.endOfWeek = function (value) {
|
|
196
|
+
return endOfWeek(value, {
|
|
197
|
+
locale: _this.locale
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
_this.endOfDay = function (value) {
|
|
201
|
+
return endOfDay(value);
|
|
202
|
+
};
|
|
203
|
+
_this.addYears = function (value, amount) {
|
|
204
|
+
return addYears(value, amount);
|
|
205
|
+
};
|
|
206
|
+
_this.addMonths = function (value, amount) {
|
|
207
|
+
return addMonths(value, amount);
|
|
208
|
+
};
|
|
209
|
+
_this.addWeeks = function (value, amount) {
|
|
210
|
+
return addWeeks(value, amount);
|
|
211
|
+
};
|
|
212
|
+
_this.addDays = function (value, amount) {
|
|
213
|
+
return addDays(value, amount);
|
|
214
|
+
};
|
|
215
|
+
_this.addHours = function (value, amount) {
|
|
216
|
+
return addHours(value, amount);
|
|
217
|
+
};
|
|
218
|
+
_this.addMinutes = function (value, amount) {
|
|
219
|
+
return addMinutes(value, amount);
|
|
220
|
+
};
|
|
221
|
+
_this.addSeconds = function (value, amount) {
|
|
222
|
+
return addSeconds(value, amount);
|
|
223
|
+
};
|
|
224
|
+
_this.getYear = function (value) {
|
|
225
|
+
return getYear(value);
|
|
226
|
+
};
|
|
227
|
+
_this.getMonth = function (value) {
|
|
228
|
+
return getMonth(value);
|
|
229
|
+
};
|
|
230
|
+
_this.getDate = function (value) {
|
|
231
|
+
return getDate(value);
|
|
232
|
+
};
|
|
233
|
+
_this.getHours = function (value) {
|
|
234
|
+
return getHours(value);
|
|
235
|
+
};
|
|
236
|
+
_this.getMinutes = function (value) {
|
|
237
|
+
return getMinutes(value);
|
|
238
|
+
};
|
|
239
|
+
_this.getSeconds = function (value) {
|
|
240
|
+
return getSeconds(value);
|
|
241
|
+
};
|
|
242
|
+
_this.getMilliseconds = function (value) {
|
|
243
|
+
return getMilliseconds(value);
|
|
244
|
+
};
|
|
245
|
+
_this.setYear = function (value, year) {
|
|
246
|
+
return setYear(value, year);
|
|
247
|
+
};
|
|
248
|
+
_this.setMonth = function (value, month) {
|
|
249
|
+
return setMonth(value, month);
|
|
250
|
+
};
|
|
251
|
+
_this.setDate = function (value, date) {
|
|
252
|
+
return setDate(value, date);
|
|
253
|
+
};
|
|
254
|
+
_this.setHours = function (value, hours) {
|
|
255
|
+
return setHours(value, hours);
|
|
256
|
+
};
|
|
257
|
+
_this.setMinutes = function (value, minutes) {
|
|
258
|
+
return setMinutes(value, minutes);
|
|
259
|
+
};
|
|
260
|
+
_this.setSeconds = function (value, seconds) {
|
|
261
|
+
return setSeconds(value, seconds);
|
|
262
|
+
};
|
|
263
|
+
_this.setMilliseconds = function (value, milliseconds) {
|
|
264
|
+
return setMilliseconds(value, milliseconds);
|
|
265
|
+
};
|
|
266
|
+
_this.getDaysInMonth = function (value) {
|
|
267
|
+
return getDaysInMonth(value);
|
|
268
|
+
};
|
|
269
|
+
_this.getWeekArray = function (value) {
|
|
270
|
+
var start = _this.startOfWeek(_this.startOfMonth(value));
|
|
271
|
+
var end = _this.endOfWeek(_this.endOfMonth(value));
|
|
272
|
+
var count = 0;
|
|
273
|
+
var current = start;
|
|
274
|
+
var nestedWeeks = [];
|
|
275
|
+
while (_this.isBefore(current, end)) {
|
|
276
|
+
var weekNumber = Math.floor(count / 7);
|
|
277
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
278
|
+
nestedWeeks[weekNumber].push(current);
|
|
279
|
+
current = _this.addDays(current, 1);
|
|
280
|
+
count += 1;
|
|
281
|
+
}
|
|
282
|
+
return nestedWeeks;
|
|
283
|
+
};
|
|
284
|
+
_this.getWeekNumber = function (value) {
|
|
285
|
+
return getWeek(value, {
|
|
286
|
+
locale: _this.locale
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
_this.getYearRange = function (_ref5) {
|
|
290
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
291
|
+
start = _ref6[0],
|
|
292
|
+
end = _ref6[1];
|
|
293
|
+
var startDate = _this.startOfYear(start);
|
|
294
|
+
var endDate = _this.endOfYear(end);
|
|
295
|
+
var years = [];
|
|
296
|
+
var current = startDate;
|
|
297
|
+
while (_this.isBefore(current, endDate)) {
|
|
298
|
+
years.push(current);
|
|
299
|
+
current = _this.addYears(current, 1);
|
|
300
|
+
}
|
|
301
|
+
return years;
|
|
302
|
+
};
|
|
303
|
+
return _this;
|
|
304
|
+
}
|
|
305
|
+
return _createClass(AdapterDateFns);
|
|
306
|
+
}(AdapterDateFnsBase);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFns } from './AdapterDateFnsV3';
|
|
@@ -2,13 +2,13 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
6
|
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
7
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
8
8
|
import _get from "@babel/runtime/helpers/esm/get";
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
|
-
function
|
|
11
|
-
function _isNativeReflectConstruct() {
|
|
10
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
12
|
/* eslint-disable class-methods-use-this */
|
|
13
13
|
import defaultHMoment from 'moment-hijri';
|
|
14
14
|
import { AdapterMoment } from '../AdapterMoment';
|
|
@@ -140,17 +140,16 @@ var NUMBER_SYMBOL_MAP = {
|
|
|
140
140
|
*/
|
|
141
141
|
export var AdapterMomentHijri = /*#__PURE__*/function (_AdapterMoment) {
|
|
142
142
|
_inherits(AdapterMomentHijri, _AdapterMoment);
|
|
143
|
-
var _super = _createSuper(AdapterMomentHijri);
|
|
144
143
|
function AdapterMomentHijri() {
|
|
145
144
|
var _thisSuper, _this;
|
|
146
145
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
147
146
|
formats = _ref.formats,
|
|
148
147
|
instance = _ref.instance;
|
|
149
148
|
_classCallCheck(this, AdapterMomentHijri);
|
|
150
|
-
_this =
|
|
149
|
+
_this = _callSuper(this, AdapterMomentHijri, [{
|
|
151
150
|
locale: 'ar-SA',
|
|
152
151
|
instance: instance
|
|
153
|
-
});
|
|
152
|
+
}]);
|
|
154
153
|
_this.lib = 'moment-hijri';
|
|
155
154
|
_this.moment = void 0;
|
|
156
155
|
_this.isTimezoneCompatible = false;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
-
|
|
8
|
-
function
|
|
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; })(); }
|
|
9
9
|
/* eslint-disable class-methods-use-this */
|
|
10
10
|
import defaultJMoment from 'moment-jalaali';
|
|
11
11
|
import { AdapterMoment } from '../AdapterMoment';
|
|
@@ -135,17 +135,16 @@ var NUMBER_SYMBOL_MAP = {
|
|
|
135
135
|
*/
|
|
136
136
|
export var AdapterMomentJalaali = /*#__PURE__*/function (_AdapterMoment) {
|
|
137
137
|
_inherits(AdapterMomentJalaali, _AdapterMoment);
|
|
138
|
-
var _super = _createSuper(AdapterMomentJalaali);
|
|
139
138
|
function AdapterMomentJalaali() {
|
|
140
139
|
var _this;
|
|
141
140
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
142
141
|
formats = _ref.formats,
|
|
143
142
|
instance = _ref.instance;
|
|
144
143
|
_classCallCheck(this, AdapterMomentJalaali);
|
|
145
|
-
_this =
|
|
144
|
+
_this = _callSuper(this, AdapterMomentJalaali, [{
|
|
146
145
|
locale: 'fa',
|
|
147
146
|
instance: instance
|
|
148
|
-
});
|
|
147
|
+
}]);
|
|
149
148
|
_this.isTimezoneCompatible = false;
|
|
150
149
|
_this.lib = 'moment-jalaali';
|
|
151
150
|
_this.moment = void 0;
|