@react-stately/datepicker 3.0.0-nightly.3180 → 3.0.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/dist/main.js +503 -103
- package/dist/main.js.map +1 -1
- package/dist/module.js +499 -87
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +21 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +9 -4
- package/src/placeholders.ts +108 -0
- package/src/useDateFieldState.ts +71 -45
- package/src/useDatePickerState.ts +9 -7
- package/src/useDateRangePickerState.ts +49 -33
- package/src/useTimeFieldState.ts +2 -2
- package/src/utils.ts +6 -1
package/dist/main.js
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
var $h2qOe$internationalizeddate = require("@internationalized/date");
|
|
2
2
|
var $h2qOe$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $h2qOe$reactstatelyoverlays = require("@react-stately/overlays");
|
|
3
4
|
var $h2qOe$react = require("react");
|
|
5
|
+
var $h2qOe$internationalizedmessage = require("@internationalized/message");
|
|
4
6
|
|
|
5
|
-
function $parcel$exportWildcard(dest, source) {
|
|
6
|
-
Object.keys(source).forEach(function(key) {
|
|
7
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(dest, key, {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function get() {
|
|
14
|
-
return source[key];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return dest;
|
|
20
|
-
}
|
|
21
7
|
function $parcel$export(e, n, v, s) {
|
|
22
8
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
9
|
}
|
|
24
|
-
var $aaab7a647e17e1fd$exports = {};
|
|
25
10
|
|
|
26
|
-
$parcel$export(
|
|
11
|
+
$parcel$export(module.exports, "useDatePickerState", () => $aaab7a647e17e1fd$export$87194bb378cc3ac2);
|
|
12
|
+
$parcel$export(module.exports, "useDateFieldState", () => $596a1f0f523d6752$export$60e84778edff6d26);
|
|
13
|
+
$parcel$export(module.exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
14
|
+
$parcel$export(module.exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
27
15
|
|
|
28
16
|
|
|
29
17
|
|
|
@@ -60,6 +48,7 @@ function $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
60
48
|
opts1.timeZone = options.timeZone || 'UTC';
|
|
61
49
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
|
|
62
50
|
if (hasTime && options.timeZone && !options.hideTimeZone) opts1.timeZoneName = 'short';
|
|
51
|
+
if (options.showEra && startIdx === 0) opts1.era = 'short';
|
|
63
52
|
return opts1;
|
|
64
53
|
}
|
|
65
54
|
function $50d5d6a623389320$export$c5221a78ef73c5e9(placeholderValue) {
|
|
@@ -102,9 +91,10 @@ function $50d5d6a623389320$export$2440da353cedad43(v, granularity) {
|
|
|
102
91
|
|
|
103
92
|
|
|
104
93
|
|
|
94
|
+
|
|
105
95
|
function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
106
96
|
var ref;
|
|
107
|
-
let
|
|
97
|
+
let overlayState = $h2qOe$reactstatelyoverlays.useOverlayTriggerState(props);
|
|
108
98
|
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
109
99
|
let v = value || props.placeholderValue;
|
|
110
100
|
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
@@ -130,7 +120,7 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
130
120
|
if (selectedTime || shouldClose) commitValue(newValue, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
131
121
|
else setSelectedDate(newValue);
|
|
132
122
|
} else setValue(newValue);
|
|
133
|
-
if (shouldClose) setOpen(false);
|
|
123
|
+
if (shouldClose) overlayState.setOpen(false);
|
|
134
124
|
};
|
|
135
125
|
let selectTime = (newValue)=>{
|
|
136
126
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
@@ -146,13 +136,13 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
146
136
|
setTimeValue: selectTime,
|
|
147
137
|
granularity: granularity,
|
|
148
138
|
hasTime: hasTime,
|
|
149
|
-
isOpen:
|
|
139
|
+
isOpen: overlayState.isOpen,
|
|
150
140
|
setOpen (isOpen) {
|
|
151
141
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
152
142
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
153
143
|
// the user opens the popover again.
|
|
154
144
|
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
155
|
-
setOpen(isOpen);
|
|
145
|
+
overlayState.setOpen(isOpen);
|
|
156
146
|
},
|
|
157
147
|
validationState: validationState,
|
|
158
148
|
formatValue (locale, fieldOptions) {
|
|
@@ -161,7 +151,8 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
161
151
|
granularity: granularity,
|
|
162
152
|
timeZone: defaultTimeZone,
|
|
163
153
|
hideTimeZone: props.hideTimeZone,
|
|
164
|
-
hourCycle: props.hourCycle
|
|
154
|
+
hourCycle: props.hourCycle,
|
|
155
|
+
showEra: value.calendar.identifier === 'gregory' && value.era === 'BC'
|
|
165
156
|
});
|
|
166
157
|
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
167
158
|
return formatter.format(dateValue);
|
|
@@ -170,9 +161,396 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
170
161
|
}
|
|
171
162
|
|
|
172
163
|
|
|
173
|
-
var $596a1f0f523d6752$exports = {};
|
|
174
164
|
|
|
175
|
-
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// These placeholders are based on the strings used by the <input type="date">
|
|
168
|
+
// implementations in Chrome and Firefox. Additional languages are supported
|
|
169
|
+
// here than React Spectrum's typical translations.
|
|
170
|
+
const $e1e8ada727fae1a1$var$placeholders = new $h2qOe$internationalizedmessage.MessageDictionary({
|
|
171
|
+
ach: {
|
|
172
|
+
year: 'mwaka',
|
|
173
|
+
month: 'dwe',
|
|
174
|
+
day: 'nino'
|
|
175
|
+
},
|
|
176
|
+
af: {
|
|
177
|
+
year: 'jjjj',
|
|
178
|
+
month: 'mm',
|
|
179
|
+
day: 'dd'
|
|
180
|
+
},
|
|
181
|
+
am: {
|
|
182
|
+
year: 'ዓዓዓዓ',
|
|
183
|
+
month: 'ሚሜ',
|
|
184
|
+
day: 'ቀቀ'
|
|
185
|
+
},
|
|
186
|
+
an: {
|
|
187
|
+
year: 'aaaa',
|
|
188
|
+
month: 'mm',
|
|
189
|
+
day: 'dd'
|
|
190
|
+
},
|
|
191
|
+
ar: {
|
|
192
|
+
year: 'سنة',
|
|
193
|
+
month: 'شهر',
|
|
194
|
+
day: 'يوم'
|
|
195
|
+
},
|
|
196
|
+
ast: {
|
|
197
|
+
year: 'aaaa',
|
|
198
|
+
month: 'mm',
|
|
199
|
+
day: 'dd'
|
|
200
|
+
},
|
|
201
|
+
az: {
|
|
202
|
+
year: 'iiii',
|
|
203
|
+
month: 'aa',
|
|
204
|
+
day: 'gg'
|
|
205
|
+
},
|
|
206
|
+
be: {
|
|
207
|
+
year: 'гггг',
|
|
208
|
+
month: 'мм',
|
|
209
|
+
day: 'дд'
|
|
210
|
+
},
|
|
211
|
+
bg: {
|
|
212
|
+
year: 'гггг',
|
|
213
|
+
month: 'мм',
|
|
214
|
+
day: 'дд'
|
|
215
|
+
},
|
|
216
|
+
bn: {
|
|
217
|
+
year: 'yyyy',
|
|
218
|
+
month: 'মিমি',
|
|
219
|
+
day: 'dd'
|
|
220
|
+
},
|
|
221
|
+
br: {
|
|
222
|
+
year: 'bbbb',
|
|
223
|
+
month: 'mm',
|
|
224
|
+
day: 'dd'
|
|
225
|
+
},
|
|
226
|
+
bs: {
|
|
227
|
+
year: 'gggg',
|
|
228
|
+
month: 'mm',
|
|
229
|
+
day: 'dd'
|
|
230
|
+
},
|
|
231
|
+
ca: {
|
|
232
|
+
year: 'aaaa',
|
|
233
|
+
month: 'mm',
|
|
234
|
+
day: 'dd'
|
|
235
|
+
},
|
|
236
|
+
cak: {
|
|
237
|
+
year: 'jjjj',
|
|
238
|
+
month: 'ii',
|
|
239
|
+
day: "q'q'"
|
|
240
|
+
},
|
|
241
|
+
ckb: {
|
|
242
|
+
year: 'ساڵ',
|
|
243
|
+
month: 'مانگ',
|
|
244
|
+
day: 'ڕۆژ'
|
|
245
|
+
},
|
|
246
|
+
cs: {
|
|
247
|
+
year: 'rrrr',
|
|
248
|
+
month: 'mm',
|
|
249
|
+
day: 'dd'
|
|
250
|
+
},
|
|
251
|
+
cy: {
|
|
252
|
+
year: 'bbbb',
|
|
253
|
+
month: 'mm',
|
|
254
|
+
day: 'dd'
|
|
255
|
+
},
|
|
256
|
+
da: {
|
|
257
|
+
year: 'åååå',
|
|
258
|
+
month: 'mm',
|
|
259
|
+
day: 'dd'
|
|
260
|
+
},
|
|
261
|
+
de: {
|
|
262
|
+
year: 'jjjj',
|
|
263
|
+
month: 'mm',
|
|
264
|
+
day: 'tt'
|
|
265
|
+
},
|
|
266
|
+
dsb: {
|
|
267
|
+
year: 'llll',
|
|
268
|
+
month: 'mm',
|
|
269
|
+
day: 'źź'
|
|
270
|
+
},
|
|
271
|
+
el: {
|
|
272
|
+
year: 'εεεε',
|
|
273
|
+
month: 'μμ',
|
|
274
|
+
day: 'ηη'
|
|
275
|
+
},
|
|
276
|
+
en: {
|
|
277
|
+
year: 'yyyy',
|
|
278
|
+
month: 'mm',
|
|
279
|
+
day: 'dd'
|
|
280
|
+
},
|
|
281
|
+
eo: {
|
|
282
|
+
year: 'jjjj',
|
|
283
|
+
month: 'mm',
|
|
284
|
+
day: 'tt'
|
|
285
|
+
},
|
|
286
|
+
es: {
|
|
287
|
+
year: 'aaaa',
|
|
288
|
+
month: 'mm',
|
|
289
|
+
day: 'dd'
|
|
290
|
+
},
|
|
291
|
+
et: {
|
|
292
|
+
year: 'aaaa',
|
|
293
|
+
month: 'kk',
|
|
294
|
+
day: 'pp'
|
|
295
|
+
},
|
|
296
|
+
eu: {
|
|
297
|
+
year: 'uuuu',
|
|
298
|
+
month: 'hh',
|
|
299
|
+
day: 'ee'
|
|
300
|
+
},
|
|
301
|
+
fa: {
|
|
302
|
+
year: 'سال',
|
|
303
|
+
month: 'ماه',
|
|
304
|
+
day: 'روز'
|
|
305
|
+
},
|
|
306
|
+
ff: {
|
|
307
|
+
year: 'hhhh',
|
|
308
|
+
month: 'll',
|
|
309
|
+
day: 'ññ'
|
|
310
|
+
},
|
|
311
|
+
fi: {
|
|
312
|
+
year: 'vvvv',
|
|
313
|
+
month: 'kk',
|
|
314
|
+
day: 'pp'
|
|
315
|
+
},
|
|
316
|
+
fr: {
|
|
317
|
+
year: 'aaaa',
|
|
318
|
+
month: 'mm',
|
|
319
|
+
day: 'jj'
|
|
320
|
+
},
|
|
321
|
+
fy: {
|
|
322
|
+
year: 'jjjj',
|
|
323
|
+
month: 'mm',
|
|
324
|
+
day: 'dd'
|
|
325
|
+
},
|
|
326
|
+
ga: {
|
|
327
|
+
year: 'bbbb',
|
|
328
|
+
month: 'mm',
|
|
329
|
+
day: 'll'
|
|
330
|
+
},
|
|
331
|
+
gd: {
|
|
332
|
+
year: 'bbbb',
|
|
333
|
+
month: 'mm',
|
|
334
|
+
day: 'll'
|
|
335
|
+
},
|
|
336
|
+
gl: {
|
|
337
|
+
year: 'aaaa',
|
|
338
|
+
month: 'mm',
|
|
339
|
+
day: 'dd'
|
|
340
|
+
},
|
|
341
|
+
he: {
|
|
342
|
+
year: 'שנה',
|
|
343
|
+
month: 'חודש',
|
|
344
|
+
day: 'יום'
|
|
345
|
+
},
|
|
346
|
+
hr: {
|
|
347
|
+
year: 'gggg',
|
|
348
|
+
month: 'mm',
|
|
349
|
+
day: 'dd'
|
|
350
|
+
},
|
|
351
|
+
hsb: {
|
|
352
|
+
year: 'llll',
|
|
353
|
+
month: 'mm',
|
|
354
|
+
day: 'dd'
|
|
355
|
+
},
|
|
356
|
+
hu: {
|
|
357
|
+
year: 'éééé',
|
|
358
|
+
month: 'hh',
|
|
359
|
+
day: 'nn'
|
|
360
|
+
},
|
|
361
|
+
ia: {
|
|
362
|
+
year: 'aaaa',
|
|
363
|
+
month: 'mm',
|
|
364
|
+
day: 'dd'
|
|
365
|
+
},
|
|
366
|
+
id: {
|
|
367
|
+
year: 'tttt',
|
|
368
|
+
month: 'bb',
|
|
369
|
+
day: 'hh'
|
|
370
|
+
},
|
|
371
|
+
it: {
|
|
372
|
+
year: 'aaaa',
|
|
373
|
+
month: 'mm',
|
|
374
|
+
day: 'gg'
|
|
375
|
+
},
|
|
376
|
+
ja: {
|
|
377
|
+
year: ' 年 ',
|
|
378
|
+
month: '月',
|
|
379
|
+
day: '日'
|
|
380
|
+
},
|
|
381
|
+
ka: {
|
|
382
|
+
year: 'წწწწ',
|
|
383
|
+
month: 'თთ',
|
|
384
|
+
day: 'რრ'
|
|
385
|
+
},
|
|
386
|
+
kk: {
|
|
387
|
+
year: 'жжжж',
|
|
388
|
+
month: 'аа',
|
|
389
|
+
day: 'кк'
|
|
390
|
+
},
|
|
391
|
+
kn: {
|
|
392
|
+
year: 'ವವವವ',
|
|
393
|
+
month: 'ಮಿಮೀ',
|
|
394
|
+
day: 'ದಿದಿ'
|
|
395
|
+
},
|
|
396
|
+
ko: {
|
|
397
|
+
year: '연도',
|
|
398
|
+
month: '월',
|
|
399
|
+
day: '일'
|
|
400
|
+
},
|
|
401
|
+
lb: {
|
|
402
|
+
year: 'jjjj',
|
|
403
|
+
month: 'mm',
|
|
404
|
+
day: 'dd'
|
|
405
|
+
},
|
|
406
|
+
lo: {
|
|
407
|
+
year: 'ປປປປ',
|
|
408
|
+
month: 'ດດ',
|
|
409
|
+
day: 'ວວ'
|
|
410
|
+
},
|
|
411
|
+
lt: {
|
|
412
|
+
year: 'mmmm',
|
|
413
|
+
month: 'mm',
|
|
414
|
+
day: 'dd'
|
|
415
|
+
},
|
|
416
|
+
lv: {
|
|
417
|
+
year: 'gggg',
|
|
418
|
+
month: 'mm',
|
|
419
|
+
day: 'dd'
|
|
420
|
+
},
|
|
421
|
+
meh: {
|
|
422
|
+
year: 'aaaa',
|
|
423
|
+
month: 'mm',
|
|
424
|
+
day: 'dd'
|
|
425
|
+
},
|
|
426
|
+
ml: {
|
|
427
|
+
year: 'വർഷം',
|
|
428
|
+
month: 'മാസം',
|
|
429
|
+
day: 'തീയതി'
|
|
430
|
+
},
|
|
431
|
+
ms: {
|
|
432
|
+
year: 'tttt',
|
|
433
|
+
month: 'mm',
|
|
434
|
+
day: 'hh'
|
|
435
|
+
},
|
|
436
|
+
nl: {
|
|
437
|
+
year: 'jjjj',
|
|
438
|
+
month: 'mm',
|
|
439
|
+
day: 'dd'
|
|
440
|
+
},
|
|
441
|
+
nn: {
|
|
442
|
+
year: 'åååå',
|
|
443
|
+
month: 'mm',
|
|
444
|
+
day: 'dd'
|
|
445
|
+
},
|
|
446
|
+
no: {
|
|
447
|
+
year: 'åååå',
|
|
448
|
+
month: 'mm',
|
|
449
|
+
day: 'dd'
|
|
450
|
+
},
|
|
451
|
+
oc: {
|
|
452
|
+
year: 'aaaa',
|
|
453
|
+
month: 'mm',
|
|
454
|
+
day: 'jj'
|
|
455
|
+
},
|
|
456
|
+
pl: {
|
|
457
|
+
year: 'rrrr',
|
|
458
|
+
month: 'mm',
|
|
459
|
+
day: 'dd'
|
|
460
|
+
},
|
|
461
|
+
pt: {
|
|
462
|
+
year: 'aaaa',
|
|
463
|
+
month: 'mm',
|
|
464
|
+
day: 'dd'
|
|
465
|
+
},
|
|
466
|
+
rm: {
|
|
467
|
+
year: 'oooo',
|
|
468
|
+
month: 'mm',
|
|
469
|
+
day: 'dd'
|
|
470
|
+
},
|
|
471
|
+
ro: {
|
|
472
|
+
year: 'aaaa',
|
|
473
|
+
month: 'll',
|
|
474
|
+
day: 'zz'
|
|
475
|
+
},
|
|
476
|
+
ru: {
|
|
477
|
+
year: 'гггг',
|
|
478
|
+
month: 'мм',
|
|
479
|
+
day: 'дд'
|
|
480
|
+
},
|
|
481
|
+
sc: {
|
|
482
|
+
year: 'aaaa',
|
|
483
|
+
month: 'mm',
|
|
484
|
+
day: 'dd'
|
|
485
|
+
},
|
|
486
|
+
scn: {
|
|
487
|
+
year: 'aaaa',
|
|
488
|
+
month: 'mm',
|
|
489
|
+
day: 'jj'
|
|
490
|
+
},
|
|
491
|
+
sk: {
|
|
492
|
+
year: 'rrrr',
|
|
493
|
+
month: 'mm',
|
|
494
|
+
day: 'dd'
|
|
495
|
+
},
|
|
496
|
+
sl: {
|
|
497
|
+
year: 'llll',
|
|
498
|
+
month: 'mm',
|
|
499
|
+
day: 'dd'
|
|
500
|
+
},
|
|
501
|
+
sr: {
|
|
502
|
+
year: 'гггг',
|
|
503
|
+
month: 'мм',
|
|
504
|
+
day: 'дд'
|
|
505
|
+
},
|
|
506
|
+
sv: {
|
|
507
|
+
year: 'åååå',
|
|
508
|
+
month: 'mm',
|
|
509
|
+
day: 'dd'
|
|
510
|
+
},
|
|
511
|
+
szl: {
|
|
512
|
+
year: 'rrrr',
|
|
513
|
+
month: 'mm',
|
|
514
|
+
day: 'dd'
|
|
515
|
+
},
|
|
516
|
+
tg: {
|
|
517
|
+
year: 'сссс',
|
|
518
|
+
month: 'мм',
|
|
519
|
+
day: 'рр'
|
|
520
|
+
},
|
|
521
|
+
th: {
|
|
522
|
+
year: 'ปปปป',
|
|
523
|
+
month: 'ดด',
|
|
524
|
+
day: 'วว'
|
|
525
|
+
},
|
|
526
|
+
tr: {
|
|
527
|
+
year: 'yyyy',
|
|
528
|
+
month: 'aa',
|
|
529
|
+
day: 'gg'
|
|
530
|
+
},
|
|
531
|
+
uk: {
|
|
532
|
+
year: 'рррр',
|
|
533
|
+
month: 'мм',
|
|
534
|
+
day: 'дд'
|
|
535
|
+
},
|
|
536
|
+
'zh-CN': {
|
|
537
|
+
year: '年',
|
|
538
|
+
month: '月',
|
|
539
|
+
day: '日'
|
|
540
|
+
},
|
|
541
|
+
'zh-TW': {
|
|
542
|
+
year: '年',
|
|
543
|
+
month: '月',
|
|
544
|
+
day: '日'
|
|
545
|
+
}
|
|
546
|
+
}, 'en');
|
|
547
|
+
function $e1e8ada727fae1a1$export$d3f5c5e0a5023fa0(field, value, locale) {
|
|
548
|
+
// Use the actual placeholder value for the era and day period fields.
|
|
549
|
+
if (field === 'era' || field === 'dayPeriod') return value;
|
|
550
|
+
if (field === 'year' || field === 'month' || field === 'day') return $e1e8ada727fae1a1$var$placeholders.getStringForLocale(field, locale);
|
|
551
|
+
// For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.
|
|
552
|
+
return '––';
|
|
553
|
+
}
|
|
176
554
|
|
|
177
555
|
|
|
178
556
|
|
|
@@ -206,20 +584,45 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
206
584
|
let timeZone = defaultTimeZone || 'UTC';
|
|
207
585
|
// props.granularity must actually exist in the value if one is provided.
|
|
208
586
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
587
|
+
let defaultFormatter = $h2qOe$react.useMemo(()=>new $h2qOe$internationalizeddate.DateFormatter(locale)
|
|
588
|
+
, [
|
|
589
|
+
locale
|
|
590
|
+
]);
|
|
591
|
+
let calendar = $h2qOe$react.useMemo(()=>createCalendar(defaultFormatter.resolvedOptions().calendar)
|
|
592
|
+
, [
|
|
593
|
+
createCalendar,
|
|
594
|
+
defaultFormatter
|
|
595
|
+
]);
|
|
596
|
+
let [value1, setDate] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
597
|
+
let calendarValue = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$61a490a80c552550(value1, calendar)
|
|
598
|
+
, [
|
|
599
|
+
value1,
|
|
600
|
+
calendar
|
|
601
|
+
]);
|
|
602
|
+
// We keep track of the placeholder date separately in state so that onChange is not called
|
|
603
|
+
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
604
|
+
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
605
|
+
// change from uncontrolled to controlled and emit a warning.
|
|
606
|
+
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()=>$50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
607
|
+
);
|
|
608
|
+
let val = calendarValue || placeholderDate;
|
|
609
|
+
let showEra = calendar.identifier === 'gregory' && val.era === 'BC';
|
|
209
610
|
var _maxGranularity;
|
|
210
611
|
let formatOpts = $h2qOe$react.useMemo(()=>({
|
|
211
612
|
granularity: granularity,
|
|
212
613
|
maxGranularity: (_maxGranularity = props.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year',
|
|
213
614
|
timeZone: defaultTimeZone,
|
|
214
615
|
hideTimeZone: hideTimeZone,
|
|
215
|
-
hourCycle: props.hourCycle
|
|
616
|
+
hourCycle: props.hourCycle,
|
|
617
|
+
showEra: showEra
|
|
216
618
|
})
|
|
217
619
|
, [
|
|
218
620
|
props.maxGranularity,
|
|
219
621
|
granularity,
|
|
220
622
|
props.hourCycle,
|
|
221
623
|
defaultTimeZone,
|
|
222
|
-
hideTimeZone
|
|
624
|
+
hideTimeZone,
|
|
625
|
+
showEra
|
|
223
626
|
]);
|
|
224
627
|
let opts = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$7e319ea407e63bc0({
|
|
225
628
|
}, formatOpts)
|
|
@@ -235,11 +638,6 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
235
638
|
, [
|
|
236
639
|
dateFormatter
|
|
237
640
|
]);
|
|
238
|
-
let calendar = $h2qOe$react.useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
239
|
-
, [
|
|
240
|
-
createCalendar,
|
|
241
|
-
resolvedOptions.calendar
|
|
242
|
-
]);
|
|
243
641
|
// Determine how many editable segments there are for validation purposes.
|
|
244
642
|
// The result is cached for performance.
|
|
245
643
|
let allSegments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]
|
|
@@ -254,12 +652,6 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
254
652
|
} : {
|
|
255
653
|
}
|
|
256
654
|
);
|
|
257
|
-
// We keep track of the placeholder date separately in state so that onChange is not called
|
|
258
|
-
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
259
|
-
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
260
|
-
// change from uncontrolled to controlled and emit a warning.
|
|
261
|
-
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()=>$50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
262
|
-
);
|
|
263
655
|
// Reset placeholder when calendar changes
|
|
264
656
|
let lastCalendarIdentifier = $h2qOe$react.useRef(calendar.identifier);
|
|
265
657
|
$h2qOe$react.useEffect(()=>{
|
|
@@ -275,12 +667,6 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
275
667
|
defaultTimeZone,
|
|
276
668
|
props.placeholderValue
|
|
277
669
|
]);
|
|
278
|
-
let [value1, setDate] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
279
|
-
let calendarValue = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$61a490a80c552550(value1, calendar)
|
|
280
|
-
, [
|
|
281
|
-
value1,
|
|
282
|
-
calendar
|
|
283
|
-
]);
|
|
284
670
|
// If there is a value prop, and some segments were previously placeholders, mark them all as valid.
|
|
285
671
|
if (value1 && Object.keys(validSegments).length < Object.keys(allSegments).length) {
|
|
286
672
|
validSegments = {
|
|
@@ -314,11 +700,14 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
314
700
|
let segments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
315
701
|
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
316
702
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
703
|
+
let isPlaceholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
704
|
+
let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] ? $e1e8ada727fae1a1$export$d3f5c5e0a5023fa0(segment.type, segment.value, locale) : null;
|
|
317
705
|
return {
|
|
318
706
|
type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
319
|
-
text: segment.value,
|
|
707
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
320
708
|
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
321
|
-
isPlaceholder:
|
|
709
|
+
isPlaceholder: isPlaceholder,
|
|
710
|
+
placeholder: placeholder,
|
|
322
711
|
isEditable: isEditable
|
|
323
712
|
};
|
|
324
713
|
})
|
|
@@ -328,33 +717,47 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
328
717
|
dateFormatter,
|
|
329
718
|
resolvedOptions,
|
|
330
719
|
displayValue,
|
|
331
|
-
calendar
|
|
332
|
-
|
|
333
|
-
let hasEra = $h2qOe$react.useMemo(()=>segments.some((s)=>s.type === 'era'
|
|
334
|
-
)
|
|
335
|
-
, [
|
|
336
|
-
segments
|
|
720
|
+
calendar,
|
|
721
|
+
locale
|
|
337
722
|
]);
|
|
723
|
+
// When the era field appears, mark it valid if the year field is already valid.
|
|
724
|
+
// If the era field disappears, remove it from the valid segments.
|
|
725
|
+
if (allSegments.era && validSegments.year && !validSegments.era) {
|
|
726
|
+
validSegments.era = true;
|
|
727
|
+
setValidSegments({
|
|
728
|
+
...validSegments
|
|
729
|
+
});
|
|
730
|
+
} else if (!allSegments.era && validSegments.era) {
|
|
731
|
+
delete validSegments.era;
|
|
732
|
+
setValidSegments({
|
|
733
|
+
...validSegments
|
|
734
|
+
});
|
|
735
|
+
}
|
|
338
736
|
let markValid = (part)=>{
|
|
339
737
|
validSegments[part] = true;
|
|
340
|
-
if (part === 'year' &&
|
|
738
|
+
if (part === 'year' && allSegments.era) validSegments.era = true;
|
|
341
739
|
setValidSegments({
|
|
342
740
|
...validSegments
|
|
343
741
|
});
|
|
344
742
|
};
|
|
345
743
|
let adjustSegment = (type, amount)=>{
|
|
346
|
-
|
|
347
|
-
|
|
744
|
+
if (!validSegments[type]) {
|
|
745
|
+
markValid(type);
|
|
746
|
+
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) setValue(displayValue);
|
|
747
|
+
} else setValue($596a1f0f523d6752$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
348
748
|
};
|
|
349
749
|
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
750
|
+
var _maxGranularity1;
|
|
350
751
|
return {
|
|
351
752
|
value: calendarValue,
|
|
352
753
|
dateValue: dateValue,
|
|
754
|
+
calendar: calendar,
|
|
353
755
|
setValue: setValue,
|
|
354
756
|
segments: segments,
|
|
355
757
|
dateFormatter: dateFormatter,
|
|
356
758
|
validationState: validationState,
|
|
357
759
|
granularity: granularity,
|
|
760
|
+
maxGranularity: (_maxGranularity1 = props.maxGranularity) !== null && _maxGranularity1 !== void 0 ? _maxGranularity1 : 'year',
|
|
358
761
|
isDisabled: isDisabled,
|
|
359
762
|
isReadOnly: isReadOnly,
|
|
360
763
|
isRequired: isRequired,
|
|
@@ -374,20 +777,16 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
374
777
|
markValid(part);
|
|
375
778
|
setValue($596a1f0f523d6752$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
376
779
|
},
|
|
377
|
-
confirmPlaceholder (
|
|
780
|
+
confirmPlaceholder () {
|
|
378
781
|
if (props.isDisabled || props.isReadOnly) return;
|
|
379
|
-
if
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
setValue(displayValue.copy());
|
|
388
|
-
}
|
|
389
|
-
} else if (!validSegments[part]) {
|
|
390
|
-
markValid(part);
|
|
782
|
+
// Confirm the placeholder if only the day period is not filled in.
|
|
783
|
+
let validKeys = Object.keys(validSegments);
|
|
784
|
+
let allKeys = Object.keys(allSegments);
|
|
785
|
+
if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {
|
|
786
|
+
validSegments = {
|
|
787
|
+
...allSegments
|
|
788
|
+
};
|
|
789
|
+
setValidSegments(validSegments);
|
|
391
790
|
setValue(displayValue.copy());
|
|
392
791
|
}
|
|
393
792
|
},
|
|
@@ -522,6 +921,7 @@ function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
|
522
921
|
case 'day':
|
|
523
922
|
case 'month':
|
|
524
923
|
case 'year':
|
|
924
|
+
case 'era':
|
|
525
925
|
return value.set({
|
|
526
926
|
[part]: segmentValue
|
|
527
927
|
});
|
|
@@ -555,16 +955,14 @@ function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
|
555
955
|
}
|
|
556
956
|
|
|
557
957
|
|
|
558
|
-
var $7072d26f58deb33b$exports = {};
|
|
559
958
|
|
|
560
|
-
$parcel$export($7072d26f58deb33b$exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
561
959
|
|
|
562
960
|
|
|
563
961
|
|
|
564
962
|
|
|
565
963
|
function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
566
964
|
var ref, ref1;
|
|
567
|
-
let
|
|
965
|
+
let overlayState = $h2qOe$reactstatelyoverlays.useOverlayTriggerState(props);
|
|
568
966
|
let [controlledValue, setControlledValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
569
967
|
let [placeholderValue, setPlaceholderValue] = $h2qOe$react.useState(()=>controlledValue || {
|
|
570
968
|
start: null,
|
|
@@ -580,16 +978,13 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
580
978
|
setPlaceholderValue(placeholderValue);
|
|
581
979
|
}
|
|
582
980
|
let value1 = controlledValue || placeholderValue;
|
|
583
|
-
let valueRef = $h2qOe$react.useRef(value1);
|
|
584
|
-
valueRef.current = value1;
|
|
585
981
|
let setValue = (value)=>{
|
|
586
|
-
valueRef.current = value;
|
|
587
982
|
setPlaceholderValue(value);
|
|
588
983
|
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) setControlledValue(value);
|
|
589
984
|
else setControlledValue(null);
|
|
590
985
|
};
|
|
591
986
|
let v = (value1 === null || value1 === void 0 ? void 0 : value1.start) || (value1 === null || value1 === void 0 ? void 0 : value1.end) || props.placeholderValue;
|
|
592
|
-
let [granularity
|
|
987
|
+
let [granularity] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
593
988
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
594
989
|
var _shouldCloseOnSelect;
|
|
595
990
|
let shouldCloseOnSelect = (_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _shouldCloseOnSelect !== void 0 ? _shouldCloseOnSelect : true;
|
|
@@ -616,7 +1011,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
616
1011
|
else setSelectedDateRange(range);
|
|
617
1012
|
} else if (range.start && range.end) setValue(range);
|
|
618
1013
|
else setSelectedDateRange(range);
|
|
619
|
-
if (shouldClose) setOpen(false);
|
|
1014
|
+
if (shouldClose) overlayState.setOpen(false);
|
|
620
1015
|
};
|
|
621
1016
|
let setTimeRange = (range)=>{
|
|
622
1017
|
if ((dateRange1 === null || dateRange1 === void 0 ? void 0 : dateRange1.start) && (dateRange1 === null || dateRange1 === void 0 ? void 0 : dateRange1.end) && range.start && range.end) commitValue(dateRange1, range);
|
|
@@ -650,7 +1045,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
650
1045
|
},
|
|
651
1046
|
setDateRange: setDateRange,
|
|
652
1047
|
setTimeRange: setTimeRange,
|
|
653
|
-
isOpen:
|
|
1048
|
+
isOpen: overlayState.isOpen,
|
|
654
1049
|
setOpen (isOpen) {
|
|
655
1050
|
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
656
1051
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
@@ -659,11 +1054,11 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
659
1054
|
start: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
660
1055
|
end: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
661
1056
|
});
|
|
662
|
-
setOpen(isOpen);
|
|
1057
|
+
overlayState.setOpen(isOpen);
|
|
663
1058
|
},
|
|
664
1059
|
validationState: validationState,
|
|
665
1060
|
formatValue (locale, fieldOptions) {
|
|
666
|
-
if (!value1 || !value1.start || !value1.end) return
|
|
1061
|
+
if (!value1 || !value1.start || !value1.end) return null;
|
|
667
1062
|
let startTimeZone = 'timeZone' in value1.start ? value1.start.timeZone : undefined;
|
|
668
1063
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
669
1064
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
@@ -672,16 +1067,38 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
672
1067
|
granularity: startGranularity,
|
|
673
1068
|
timeZone: startTimeZone,
|
|
674
1069
|
hideTimeZone: props.hideTimeZone,
|
|
675
|
-
hourCycle: props.hourCycle
|
|
1070
|
+
hourCycle: props.hourCycle,
|
|
1071
|
+
showEra: value1.start.calendar.identifier === 'gregory' && value1.start.era === 'BC' || value1.end.calendar.identifier === 'gregory' && value1.end.era === 'BC'
|
|
676
1072
|
});
|
|
1073
|
+
let startDate = value1.start.toDate(startTimeZone || 'UTC');
|
|
1074
|
+
let endDate = value1.end.toDate(endTimeZone || 'UTC');
|
|
677
1075
|
let startFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, startOptions);
|
|
678
1076
|
let endFormatter;
|
|
679
|
-
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
1077
|
+
if (startTimeZone === endTimeZone && startGranularity === endGranularity && value1.start.compare(value1.end) !== 0) {
|
|
680
1078
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
681
1079
|
// are shared between the start and end dates (e.g. the same month).
|
|
682
1080
|
// Formatting will fail if the end date is before the start date. Fall back below when that happens.
|
|
683
1081
|
try {
|
|
684
|
-
|
|
1082
|
+
let parts = startFormatter.formatRangeToParts(startDate, endDate);
|
|
1083
|
+
// Find the separator between the start and end date. This is determined
|
|
1084
|
+
// by finding the last shared literal before the end range.
|
|
1085
|
+
let separatorIndex = -1;
|
|
1086
|
+
for(let i = 0; i < parts.length; i++){
|
|
1087
|
+
let part = parts[i];
|
|
1088
|
+
if (part.source === 'shared' && part.type === 'literal') separatorIndex = i;
|
|
1089
|
+
else if (part.source === 'endRange') break;
|
|
1090
|
+
}
|
|
1091
|
+
// Now we can combine the parts into start and end strings.
|
|
1092
|
+
let start = '';
|
|
1093
|
+
let end = '';
|
|
1094
|
+
for(let i1 = 0; i1 < parts.length; i1++){
|
|
1095
|
+
if (i1 < separatorIndex) start += parts[i1].value;
|
|
1096
|
+
else if (i1 > separatorIndex) end += parts[i1].value;
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
start: start,
|
|
1100
|
+
end: end
|
|
1101
|
+
};
|
|
685
1102
|
} catch (e) {
|
|
686
1103
|
// ignore
|
|
687
1104
|
}
|
|
@@ -695,28 +1112,15 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
695
1112
|
});
|
|
696
1113
|
endFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, endOptions);
|
|
697
1114
|
}
|
|
698
|
-
return
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
// a blur, which means the component won't have re-rendered yet.
|
|
703
|
-
let value = valueRef.current;
|
|
704
|
-
if (value && Boolean(value.start) !== Boolean(value.end)) {
|
|
705
|
-
let calendar = (value.start || value.end).calendar;
|
|
706
|
-
let placeholder = $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
707
|
-
setValue({
|
|
708
|
-
start: value.start || placeholder,
|
|
709
|
-
end: value.end || placeholder
|
|
710
|
-
});
|
|
711
|
-
}
|
|
1115
|
+
return {
|
|
1116
|
+
start: startFormatter.format(startDate),
|
|
1117
|
+
end: endFormatter.format(endDate)
|
|
1118
|
+
};
|
|
712
1119
|
}
|
|
713
1120
|
};
|
|
714
1121
|
}
|
|
715
1122
|
|
|
716
1123
|
|
|
717
|
-
var $2654e87be0231a69$exports = {};
|
|
718
|
-
|
|
719
|
-
$parcel$export($2654e87be0231a69$exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
720
1124
|
|
|
721
1125
|
|
|
722
1126
|
|
|
@@ -768,10 +1172,6 @@ function $2654e87be0231a69$var$convertValue(value, date = $h2qOe$internationaliz
|
|
|
768
1172
|
}
|
|
769
1173
|
|
|
770
1174
|
|
|
771
|
-
$parcel$exportWildcard(module.exports, $aaab7a647e17e1fd$exports);
|
|
772
|
-
$parcel$exportWildcard(module.exports, $596a1f0f523d6752$exports);
|
|
773
|
-
$parcel$exportWildcard(module.exports, $7072d26f58deb33b$exports);
|
|
774
|
-
$parcel$exportWildcard(module.exports, $2654e87be0231a69$exports);
|
|
775
1175
|
|
|
776
1176
|
|
|
777
1177
|
//# sourceMappingURL=main.js.map
|