@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.
- package/AdapterDateFns/AdapterDateFns.d.ts +3 -24
- package/AdapterDateFns/AdapterDateFns.js +11 -272
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +65 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +88 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/CHANGELOG.md +42 -0
- package/hooks/useClearableField.d.ts +1 -1
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/models/helpers.d.ts +1 -0
- package/legacy/AdapterDateFns/AdapterDateFns.js +278 -528
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +308 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +376 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/locales/index.js +1 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -271
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +307 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +357 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -271
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +315 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +366 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/locales/index.js +11 -0
- package/package.json +2 -2
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.AdapterDateFns = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
8
|
var _addDays = _interopRequireDefault(require("date-fns/addDays"));
|
|
10
9
|
var _addSeconds = _interopRequireDefault(require("date-fns/addSeconds"));
|
|
11
10
|
var _addMinutes = _interopRequireDefault(require("date-fns/addMinutes"));
|
|
@@ -62,206 +61,11 @@ var _formatISO = _interopRequireDefault(require("date-fns/formatISO"));
|
|
|
62
61
|
var _isWithinInterval = _interopRequireDefault(require("date-fns/isWithinInterval"));
|
|
63
62
|
var _enUS = _interopRequireDefault(require("date-fns/locale/en-US"));
|
|
64
63
|
var _longFormatters = _interopRequireDefault(require("date-fns/_lib/format/longFormatters"));
|
|
64
|
+
var _AdapterDateFnsBase = require("../AdapterDateFnsBase");
|
|
65
65
|
/* eslint-disable class-methods-use-this */
|
|
66
66
|
|
|
67
67
|
// @ts-ignore
|
|
68
68
|
|
|
69
|
-
const formatTokenMap = {
|
|
70
|
-
// Year
|
|
71
|
-
y: {
|
|
72
|
-
sectionType: 'year',
|
|
73
|
-
contentType: 'digit',
|
|
74
|
-
maxLength: 4
|
|
75
|
-
},
|
|
76
|
-
yy: 'year',
|
|
77
|
-
yyy: {
|
|
78
|
-
sectionType: 'year',
|
|
79
|
-
contentType: 'digit',
|
|
80
|
-
maxLength: 4
|
|
81
|
-
},
|
|
82
|
-
yyyy: 'year',
|
|
83
|
-
// Month
|
|
84
|
-
M: {
|
|
85
|
-
sectionType: 'month',
|
|
86
|
-
contentType: 'digit',
|
|
87
|
-
maxLength: 2
|
|
88
|
-
},
|
|
89
|
-
MM: 'month',
|
|
90
|
-
MMMM: {
|
|
91
|
-
sectionType: 'month',
|
|
92
|
-
contentType: 'letter'
|
|
93
|
-
},
|
|
94
|
-
MMM: {
|
|
95
|
-
sectionType: 'month',
|
|
96
|
-
contentType: 'letter'
|
|
97
|
-
},
|
|
98
|
-
L: {
|
|
99
|
-
sectionType: 'month',
|
|
100
|
-
contentType: 'digit',
|
|
101
|
-
maxLength: 2
|
|
102
|
-
},
|
|
103
|
-
LL: 'month',
|
|
104
|
-
LLL: {
|
|
105
|
-
sectionType: 'month',
|
|
106
|
-
contentType: 'letter'
|
|
107
|
-
},
|
|
108
|
-
LLLL: {
|
|
109
|
-
sectionType: 'month',
|
|
110
|
-
contentType: 'letter'
|
|
111
|
-
},
|
|
112
|
-
// Day of the month
|
|
113
|
-
d: {
|
|
114
|
-
sectionType: 'day',
|
|
115
|
-
contentType: 'digit',
|
|
116
|
-
maxLength: 2
|
|
117
|
-
},
|
|
118
|
-
dd: 'day',
|
|
119
|
-
do: {
|
|
120
|
-
sectionType: 'day',
|
|
121
|
-
contentType: 'digit-with-letter'
|
|
122
|
-
},
|
|
123
|
-
// Day of the week
|
|
124
|
-
E: {
|
|
125
|
-
sectionType: 'weekDay',
|
|
126
|
-
contentType: 'letter'
|
|
127
|
-
},
|
|
128
|
-
EE: {
|
|
129
|
-
sectionType: 'weekDay',
|
|
130
|
-
contentType: 'letter'
|
|
131
|
-
},
|
|
132
|
-
EEE: {
|
|
133
|
-
sectionType: 'weekDay',
|
|
134
|
-
contentType: 'letter'
|
|
135
|
-
},
|
|
136
|
-
EEEE: {
|
|
137
|
-
sectionType: 'weekDay',
|
|
138
|
-
contentType: 'letter'
|
|
139
|
-
},
|
|
140
|
-
EEEEE: {
|
|
141
|
-
sectionType: 'weekDay',
|
|
142
|
-
contentType: 'letter'
|
|
143
|
-
},
|
|
144
|
-
i: {
|
|
145
|
-
sectionType: 'weekDay',
|
|
146
|
-
contentType: 'digit',
|
|
147
|
-
maxLength: 1
|
|
148
|
-
},
|
|
149
|
-
ii: 'weekDay',
|
|
150
|
-
iii: {
|
|
151
|
-
sectionType: 'weekDay',
|
|
152
|
-
contentType: 'letter'
|
|
153
|
-
},
|
|
154
|
-
iiii: {
|
|
155
|
-
sectionType: 'weekDay',
|
|
156
|
-
contentType: 'letter'
|
|
157
|
-
},
|
|
158
|
-
e: {
|
|
159
|
-
sectionType: 'weekDay',
|
|
160
|
-
contentType: 'digit',
|
|
161
|
-
maxLength: 1
|
|
162
|
-
},
|
|
163
|
-
ee: 'weekDay',
|
|
164
|
-
eee: {
|
|
165
|
-
sectionType: 'weekDay',
|
|
166
|
-
contentType: 'letter'
|
|
167
|
-
},
|
|
168
|
-
eeee: {
|
|
169
|
-
sectionType: 'weekDay',
|
|
170
|
-
contentType: 'letter'
|
|
171
|
-
},
|
|
172
|
-
eeeee: {
|
|
173
|
-
sectionType: 'weekDay',
|
|
174
|
-
contentType: 'letter'
|
|
175
|
-
},
|
|
176
|
-
eeeeee: {
|
|
177
|
-
sectionType: 'weekDay',
|
|
178
|
-
contentType: 'letter'
|
|
179
|
-
},
|
|
180
|
-
c: {
|
|
181
|
-
sectionType: 'weekDay',
|
|
182
|
-
contentType: 'digit',
|
|
183
|
-
maxLength: 1
|
|
184
|
-
},
|
|
185
|
-
cc: 'weekDay',
|
|
186
|
-
ccc: {
|
|
187
|
-
sectionType: 'weekDay',
|
|
188
|
-
contentType: 'letter'
|
|
189
|
-
},
|
|
190
|
-
cccc: {
|
|
191
|
-
sectionType: 'weekDay',
|
|
192
|
-
contentType: 'letter'
|
|
193
|
-
},
|
|
194
|
-
ccccc: {
|
|
195
|
-
sectionType: 'weekDay',
|
|
196
|
-
contentType: 'letter'
|
|
197
|
-
},
|
|
198
|
-
cccccc: {
|
|
199
|
-
sectionType: 'weekDay',
|
|
200
|
-
contentType: 'letter'
|
|
201
|
-
},
|
|
202
|
-
// Meridiem
|
|
203
|
-
a: 'meridiem',
|
|
204
|
-
aa: 'meridiem',
|
|
205
|
-
aaa: 'meridiem',
|
|
206
|
-
// Hours
|
|
207
|
-
H: {
|
|
208
|
-
sectionType: 'hours',
|
|
209
|
-
contentType: 'digit',
|
|
210
|
-
maxLength: 2
|
|
211
|
-
},
|
|
212
|
-
HH: 'hours',
|
|
213
|
-
h: {
|
|
214
|
-
sectionType: 'hours',
|
|
215
|
-
contentType: 'digit',
|
|
216
|
-
maxLength: 2
|
|
217
|
-
},
|
|
218
|
-
hh: 'hours',
|
|
219
|
-
// Minutes
|
|
220
|
-
m: {
|
|
221
|
-
sectionType: 'minutes',
|
|
222
|
-
contentType: 'digit',
|
|
223
|
-
maxLength: 2
|
|
224
|
-
},
|
|
225
|
-
mm: 'minutes',
|
|
226
|
-
// Seconds
|
|
227
|
-
s: {
|
|
228
|
-
sectionType: 'seconds',
|
|
229
|
-
contentType: 'digit',
|
|
230
|
-
maxLength: 2
|
|
231
|
-
},
|
|
232
|
-
ss: 'seconds'
|
|
233
|
-
};
|
|
234
|
-
const defaultFormats = {
|
|
235
|
-
year: 'yyyy',
|
|
236
|
-
month: 'LLLL',
|
|
237
|
-
monthShort: 'MMM',
|
|
238
|
-
dayOfMonth: 'd',
|
|
239
|
-
weekday: 'EEEE',
|
|
240
|
-
weekdayShort: 'EEEEEE',
|
|
241
|
-
hours24h: 'HH',
|
|
242
|
-
hours12h: 'hh',
|
|
243
|
-
meridiem: 'aa',
|
|
244
|
-
minutes: 'mm',
|
|
245
|
-
seconds: 'ss',
|
|
246
|
-
fullDate: 'PP',
|
|
247
|
-
fullDateWithWeekday: 'PPPP',
|
|
248
|
-
keyboardDate: 'P',
|
|
249
|
-
shortDate: 'MMM d',
|
|
250
|
-
normalDate: 'd MMMM',
|
|
251
|
-
normalDateWithWeekday: 'EEE, MMM d',
|
|
252
|
-
monthAndYear: 'LLLL yyyy',
|
|
253
|
-
monthAndDate: 'MMMM d',
|
|
254
|
-
fullTime: 'p',
|
|
255
|
-
fullTime12h: 'hh:mm aa',
|
|
256
|
-
fullTime24h: 'HH:mm',
|
|
257
|
-
fullDateTime: 'PP p',
|
|
258
|
-
fullDateTime12h: 'PP hh:mm aa',
|
|
259
|
-
fullDateTime24h: 'PP HH:mm',
|
|
260
|
-
keyboardDateTime: 'P p',
|
|
261
|
-
keyboardDateTime12h: 'P hh:mm aa',
|
|
262
|
-
keyboardDateTime24h: 'P HH:mm'
|
|
263
|
-
};
|
|
264
|
-
|
|
265
69
|
/**
|
|
266
70
|
* Based on `@date-io/date-fns`
|
|
267
71
|
*
|
|
@@ -287,42 +91,19 @@ const defaultFormats = {
|
|
|
287
91
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
288
92
|
* SOFTWARE.
|
|
289
93
|
*/
|
|
290
|
-
class AdapterDateFns {
|
|
94
|
+
class AdapterDateFns extends _AdapterDateFnsBase.AdapterDateFnsBase {
|
|
291
95
|
constructor({
|
|
292
|
-
locale
|
|
96
|
+
locale,
|
|
293
97
|
formats
|
|
294
98
|
} = {}) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
end: "'"
|
|
304
|
-
};
|
|
305
|
-
this.date = value => {
|
|
306
|
-
if (typeof value === 'undefined') {
|
|
307
|
-
return new Date();
|
|
308
|
-
}
|
|
309
|
-
if (value === null) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
return new Date(value);
|
|
313
|
-
};
|
|
314
|
-
this.dateWithTimezone = value => {
|
|
315
|
-
return this.date(value);
|
|
316
|
-
};
|
|
317
|
-
this.getTimezone = () => {
|
|
318
|
-
return 'default';
|
|
319
|
-
};
|
|
320
|
-
this.setTimezone = value => {
|
|
321
|
-
return value;
|
|
322
|
-
};
|
|
323
|
-
this.toJsDate = value => {
|
|
324
|
-
return value;
|
|
325
|
-
};
|
|
99
|
+
if (typeof _addDays.default !== 'function') {
|
|
100
|
+
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'));
|
|
101
|
+
}
|
|
102
|
+
super({
|
|
103
|
+
locale: locale ?? _enUS.default,
|
|
104
|
+
formats,
|
|
105
|
+
longFormatters: _longFormatters.default
|
|
106
|
+
});
|
|
326
107
|
this.parseISO = isoString => {
|
|
327
108
|
return (0, _parseISO.default)(isoString);
|
|
328
109
|
};
|
|
@@ -339,39 +120,6 @@ class AdapterDateFns {
|
|
|
339
120
|
locale: this.locale
|
|
340
121
|
});
|
|
341
122
|
};
|
|
342
|
-
this.getCurrentLocaleCode = () => {
|
|
343
|
-
return this.locale?.code || 'en-US';
|
|
344
|
-
};
|
|
345
|
-
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
346
|
-
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
347
|
-
this.is12HourCycleInCurrentLocale = () => {
|
|
348
|
-
if (this.locale) {
|
|
349
|
-
return /a/.test(this.locale.formatLong.time());
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// By default, date-fns is using en-US locale with am/pm enabled
|
|
353
|
-
return true;
|
|
354
|
-
};
|
|
355
|
-
this.expandFormat = format => {
|
|
356
|
-
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
357
|
-
|
|
358
|
-
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
359
|
-
return format.match(longFormatRegexp).map(token => {
|
|
360
|
-
const firstCharacter = token[0];
|
|
361
|
-
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
362
|
-
const longFormatter = _longFormatters.default[firstCharacter];
|
|
363
|
-
const locale = this.locale || _enUS.default;
|
|
364
|
-
return longFormatter(token, locale.formatLong, {});
|
|
365
|
-
}
|
|
366
|
-
return token;
|
|
367
|
-
}).join('');
|
|
368
|
-
};
|
|
369
|
-
this.getFormatHelperText = format => {
|
|
370
|
-
return this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
|
|
371
|
-
};
|
|
372
|
-
this.isNull = value => {
|
|
373
|
-
return value === null;
|
|
374
|
-
};
|
|
375
123
|
this.isValid = value => {
|
|
376
124
|
return (0, _isValid.default)(this.date(value));
|
|
377
125
|
};
|
|
@@ -383,9 +131,6 @@ class AdapterDateFns {
|
|
|
383
131
|
locale: this.locale
|
|
384
132
|
});
|
|
385
133
|
};
|
|
386
|
-
this.formatNumber = numberToFormat => {
|
|
387
|
-
return numberToFormat;
|
|
388
|
-
};
|
|
389
134
|
this.getDiff = (value, comparing, unit) => {
|
|
390
135
|
switch (unit) {
|
|
391
136
|
case 'years':
|
|
@@ -610,11 +355,6 @@ class AdapterDateFns {
|
|
|
610
355
|
}
|
|
611
356
|
return years;
|
|
612
357
|
};
|
|
613
|
-
this.getMeridiemText = ampm => {
|
|
614
|
-
return ampm === 'am' ? 'AM' : 'PM';
|
|
615
|
-
};
|
|
616
|
-
this.locale = _locale;
|
|
617
|
-
this.formats = (0, _extends2.default)({}, defaultFormats, formats);
|
|
618
358
|
}
|
|
619
359
|
}
|
|
620
360
|
exports.AdapterDateFns = AdapterDateFns;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AdapterDateFnsBase = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
/* eslint-disable class-methods-use-this */
|
|
10
|
+
|
|
11
|
+
const formatTokenMap = {
|
|
12
|
+
// Year
|
|
13
|
+
y: {
|
|
14
|
+
sectionType: 'year',
|
|
15
|
+
contentType: 'digit',
|
|
16
|
+
maxLength: 4
|
|
17
|
+
},
|
|
18
|
+
yy: 'year',
|
|
19
|
+
yyy: {
|
|
20
|
+
sectionType: 'year',
|
|
21
|
+
contentType: 'digit',
|
|
22
|
+
maxLength: 4
|
|
23
|
+
},
|
|
24
|
+
yyyy: 'year',
|
|
25
|
+
// Month
|
|
26
|
+
M: {
|
|
27
|
+
sectionType: 'month',
|
|
28
|
+
contentType: 'digit',
|
|
29
|
+
maxLength: 2
|
|
30
|
+
},
|
|
31
|
+
MM: 'month',
|
|
32
|
+
MMMM: {
|
|
33
|
+
sectionType: 'month',
|
|
34
|
+
contentType: 'letter'
|
|
35
|
+
},
|
|
36
|
+
MMM: {
|
|
37
|
+
sectionType: 'month',
|
|
38
|
+
contentType: 'letter'
|
|
39
|
+
},
|
|
40
|
+
L: {
|
|
41
|
+
sectionType: 'month',
|
|
42
|
+
contentType: 'digit',
|
|
43
|
+
maxLength: 2
|
|
44
|
+
},
|
|
45
|
+
LL: 'month',
|
|
46
|
+
LLL: {
|
|
47
|
+
sectionType: 'month',
|
|
48
|
+
contentType: 'letter'
|
|
49
|
+
},
|
|
50
|
+
LLLL: {
|
|
51
|
+
sectionType: 'month',
|
|
52
|
+
contentType: 'letter'
|
|
53
|
+
},
|
|
54
|
+
// Day of the month
|
|
55
|
+
d: {
|
|
56
|
+
sectionType: 'day',
|
|
57
|
+
contentType: 'digit',
|
|
58
|
+
maxLength: 2
|
|
59
|
+
},
|
|
60
|
+
dd: 'day',
|
|
61
|
+
do: {
|
|
62
|
+
sectionType: 'day',
|
|
63
|
+
contentType: 'digit-with-letter'
|
|
64
|
+
},
|
|
65
|
+
// Day of the week
|
|
66
|
+
E: {
|
|
67
|
+
sectionType: 'weekDay',
|
|
68
|
+
contentType: 'letter'
|
|
69
|
+
},
|
|
70
|
+
EE: {
|
|
71
|
+
sectionType: 'weekDay',
|
|
72
|
+
contentType: 'letter'
|
|
73
|
+
},
|
|
74
|
+
EEE: {
|
|
75
|
+
sectionType: 'weekDay',
|
|
76
|
+
contentType: 'letter'
|
|
77
|
+
},
|
|
78
|
+
EEEE: {
|
|
79
|
+
sectionType: 'weekDay',
|
|
80
|
+
contentType: 'letter'
|
|
81
|
+
},
|
|
82
|
+
EEEEE: {
|
|
83
|
+
sectionType: 'weekDay',
|
|
84
|
+
contentType: 'letter'
|
|
85
|
+
},
|
|
86
|
+
i: {
|
|
87
|
+
sectionType: 'weekDay',
|
|
88
|
+
contentType: 'digit',
|
|
89
|
+
maxLength: 1
|
|
90
|
+
},
|
|
91
|
+
ii: 'weekDay',
|
|
92
|
+
iii: {
|
|
93
|
+
sectionType: 'weekDay',
|
|
94
|
+
contentType: 'letter'
|
|
95
|
+
},
|
|
96
|
+
iiii: {
|
|
97
|
+
sectionType: 'weekDay',
|
|
98
|
+
contentType: 'letter'
|
|
99
|
+
},
|
|
100
|
+
e: {
|
|
101
|
+
sectionType: 'weekDay',
|
|
102
|
+
contentType: 'digit',
|
|
103
|
+
maxLength: 1
|
|
104
|
+
},
|
|
105
|
+
ee: 'weekDay',
|
|
106
|
+
eee: {
|
|
107
|
+
sectionType: 'weekDay',
|
|
108
|
+
contentType: 'letter'
|
|
109
|
+
},
|
|
110
|
+
eeee: {
|
|
111
|
+
sectionType: 'weekDay',
|
|
112
|
+
contentType: 'letter'
|
|
113
|
+
},
|
|
114
|
+
eeeee: {
|
|
115
|
+
sectionType: 'weekDay',
|
|
116
|
+
contentType: 'letter'
|
|
117
|
+
},
|
|
118
|
+
eeeeee: {
|
|
119
|
+
sectionType: 'weekDay',
|
|
120
|
+
contentType: 'letter'
|
|
121
|
+
},
|
|
122
|
+
c: {
|
|
123
|
+
sectionType: 'weekDay',
|
|
124
|
+
contentType: 'digit',
|
|
125
|
+
maxLength: 1
|
|
126
|
+
},
|
|
127
|
+
cc: 'weekDay',
|
|
128
|
+
ccc: {
|
|
129
|
+
sectionType: 'weekDay',
|
|
130
|
+
contentType: 'letter'
|
|
131
|
+
},
|
|
132
|
+
cccc: {
|
|
133
|
+
sectionType: 'weekDay',
|
|
134
|
+
contentType: 'letter'
|
|
135
|
+
},
|
|
136
|
+
ccccc: {
|
|
137
|
+
sectionType: 'weekDay',
|
|
138
|
+
contentType: 'letter'
|
|
139
|
+
},
|
|
140
|
+
cccccc: {
|
|
141
|
+
sectionType: 'weekDay',
|
|
142
|
+
contentType: 'letter'
|
|
143
|
+
},
|
|
144
|
+
// Meridiem
|
|
145
|
+
a: 'meridiem',
|
|
146
|
+
aa: 'meridiem',
|
|
147
|
+
aaa: 'meridiem',
|
|
148
|
+
// Hours
|
|
149
|
+
H: {
|
|
150
|
+
sectionType: 'hours',
|
|
151
|
+
contentType: 'digit',
|
|
152
|
+
maxLength: 2
|
|
153
|
+
},
|
|
154
|
+
HH: 'hours',
|
|
155
|
+
h: {
|
|
156
|
+
sectionType: 'hours',
|
|
157
|
+
contentType: 'digit',
|
|
158
|
+
maxLength: 2
|
|
159
|
+
},
|
|
160
|
+
hh: 'hours',
|
|
161
|
+
// Minutes
|
|
162
|
+
m: {
|
|
163
|
+
sectionType: 'minutes',
|
|
164
|
+
contentType: 'digit',
|
|
165
|
+
maxLength: 2
|
|
166
|
+
},
|
|
167
|
+
mm: 'minutes',
|
|
168
|
+
// Seconds
|
|
169
|
+
s: {
|
|
170
|
+
sectionType: 'seconds',
|
|
171
|
+
contentType: 'digit',
|
|
172
|
+
maxLength: 2
|
|
173
|
+
},
|
|
174
|
+
ss: 'seconds'
|
|
175
|
+
};
|
|
176
|
+
const defaultFormats = {
|
|
177
|
+
year: 'yyyy',
|
|
178
|
+
month: 'LLLL',
|
|
179
|
+
monthShort: 'MMM',
|
|
180
|
+
dayOfMonth: 'd',
|
|
181
|
+
weekday: 'EEEE',
|
|
182
|
+
weekdayShort: 'EEEEEE',
|
|
183
|
+
hours24h: 'HH',
|
|
184
|
+
hours12h: 'hh',
|
|
185
|
+
meridiem: 'aa',
|
|
186
|
+
minutes: 'mm',
|
|
187
|
+
seconds: 'ss',
|
|
188
|
+
fullDate: 'PP',
|
|
189
|
+
fullDateWithWeekday: 'PPPP',
|
|
190
|
+
keyboardDate: 'P',
|
|
191
|
+
shortDate: 'MMM d',
|
|
192
|
+
normalDate: 'd MMMM',
|
|
193
|
+
normalDateWithWeekday: 'EEE, MMM d',
|
|
194
|
+
monthAndYear: 'LLLL yyyy',
|
|
195
|
+
monthAndDate: 'MMMM d',
|
|
196
|
+
fullTime: 'p',
|
|
197
|
+
fullTime12h: 'hh:mm aa',
|
|
198
|
+
fullTime24h: 'HH:mm',
|
|
199
|
+
fullDateTime: 'PP p',
|
|
200
|
+
fullDateTime12h: 'PP hh:mm aa',
|
|
201
|
+
fullDateTime24h: 'PP HH:mm',
|
|
202
|
+
keyboardDateTime: 'P p',
|
|
203
|
+
keyboardDateTime12h: 'P hh:mm aa',
|
|
204
|
+
keyboardDateTime24h: 'P HH:mm'
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Based on `@date-io/date-fns`
|
|
208
|
+
*
|
|
209
|
+
* MIT License
|
|
210
|
+
*
|
|
211
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
212
|
+
*
|
|
213
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
214
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
215
|
+
* in the Software without restriction, including without limitation the rights
|
|
216
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
217
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
218
|
+
* furnished to do so, subject to the following conditions:
|
|
219
|
+
*
|
|
220
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
221
|
+
* copies or substantial portions of the Software.
|
|
222
|
+
*
|
|
223
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
224
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
225
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
226
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
227
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
228
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
229
|
+
* SOFTWARE.
|
|
230
|
+
*/
|
|
231
|
+
class AdapterDateFnsBase {
|
|
232
|
+
constructor(props) {
|
|
233
|
+
this.isMUIAdapter = true;
|
|
234
|
+
this.isTimezoneCompatible = false;
|
|
235
|
+
this.lib = 'date-fns';
|
|
236
|
+
this.locale = void 0;
|
|
237
|
+
this.formats = void 0;
|
|
238
|
+
this.formatTokenMap = formatTokenMap;
|
|
239
|
+
this.escapedCharacters = {
|
|
240
|
+
start: "'",
|
|
241
|
+
end: "'"
|
|
242
|
+
};
|
|
243
|
+
this.longFormatters = void 0;
|
|
244
|
+
this.date = value => {
|
|
245
|
+
if (typeof value === 'undefined') {
|
|
246
|
+
return new Date();
|
|
247
|
+
}
|
|
248
|
+
if (value === null) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
return new Date(value);
|
|
252
|
+
};
|
|
253
|
+
this.dateWithTimezone = value => {
|
|
254
|
+
return this.date(value);
|
|
255
|
+
};
|
|
256
|
+
this.getTimezone = () => {
|
|
257
|
+
return 'default';
|
|
258
|
+
};
|
|
259
|
+
this.setTimezone = value => {
|
|
260
|
+
return value;
|
|
261
|
+
};
|
|
262
|
+
this.toJsDate = value => {
|
|
263
|
+
return value;
|
|
264
|
+
};
|
|
265
|
+
this.getCurrentLocaleCode = () => {
|
|
266
|
+
return this.locale?.code || 'en-US';
|
|
267
|
+
};
|
|
268
|
+
// Note: date-fns input types are more lenient than this adapter, so we need to expose our more
|
|
269
|
+
// strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
|
|
270
|
+
this.is12HourCycleInCurrentLocale = () => {
|
|
271
|
+
if (this.locale) {
|
|
272
|
+
return /a/.test(this.locale.formatLong.time({
|
|
273
|
+
width: 'short'
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// By default, date-fns is using en-US locale with am/pm enabled
|
|
278
|
+
return true;
|
|
279
|
+
};
|
|
280
|
+
this.expandFormat = format => {
|
|
281
|
+
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
282
|
+
|
|
283
|
+
// @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
|
|
284
|
+
return format.match(longFormatRegexp).map(token => {
|
|
285
|
+
const firstCharacter = token[0];
|
|
286
|
+
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
287
|
+
const longFormatter = this.longFormatters[firstCharacter];
|
|
288
|
+
return longFormatter(token, this.locale.formatLong);
|
|
289
|
+
}
|
|
290
|
+
return token;
|
|
291
|
+
}).join('');
|
|
292
|
+
};
|
|
293
|
+
this.getFormatHelperText = format => {
|
|
294
|
+
return this.expandFormat(format).replace(/(aaa|aa|a)/g, '(a|p)m').toLocaleLowerCase();
|
|
295
|
+
};
|
|
296
|
+
this.isNull = value => {
|
|
297
|
+
return value === null;
|
|
298
|
+
};
|
|
299
|
+
this.formatNumber = numberToFormat => {
|
|
300
|
+
return numberToFormat;
|
|
301
|
+
};
|
|
302
|
+
this.getMeridiemText = ampm => {
|
|
303
|
+
return ampm === 'am' ? 'AM' : 'PM';
|
|
304
|
+
};
|
|
305
|
+
const {
|
|
306
|
+
locale,
|
|
307
|
+
formats,
|
|
308
|
+
longFormatters
|
|
309
|
+
} = props;
|
|
310
|
+
this.locale = locale;
|
|
311
|
+
this.formats = (0, _extends2.default)({}, defaultFormats, formats);
|
|
312
|
+
this.longFormatters = longFormatters;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.AdapterDateFnsBase = AdapterDateFnsBase;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AdapterDateFnsBase", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AdapterDateFnsBase.AdapterDateFnsBase;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _AdapterDateFnsBase = require("./AdapterDateFnsBase");
|