@react-stately/datepicker 3.9.3 → 3.9.4
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/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/intlStrings.mjs +1 -1
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/placeholders.main.js +155 -155
- package/dist/placeholders.mjs +156 -156
- package/dist/placeholders.module.js +155 -155
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useDateFieldState.main.js +41 -41
- package/dist/useDateFieldState.mjs +42 -42
- package/dist/useDateFieldState.module.js +41 -41
- package/dist/useDatePickerState.main.js +9 -9
- package/dist/useDatePickerState.mjs +10 -10
- package/dist/useDatePickerState.module.js +9 -9
- package/dist/useDateRangePickerState.main.js +18 -18
- package/dist/useDateRangePickerState.mjs +19 -19
- package/dist/useDateRangePickerState.module.js +18 -18
- package/dist/useTimeFieldState.main.js +7 -7
- package/dist/useTimeFieldState.mjs +8 -8
- package/dist/useTimeFieldState.module.js +7 -7
- package/dist/utils.main.js +31 -31
- package/dist/utils.mjs +32 -32
- package/dist/utils.module.js +31 -31
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +9 -9
|
@@ -47,15 +47,15 @@ const $596a1f0f523d6752$var$PAGE_STEP = {
|
|
|
47
47
|
};
|
|
48
48
|
// Node seems to convert everything to lowercase...
|
|
49
49
|
const $596a1f0f523d6752$var$TYPE_MAPPING = {
|
|
50
|
-
dayperiod:
|
|
50
|
+
dayperiod: 'dayPeriod'
|
|
51
51
|
};
|
|
52
52
|
function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
53
53
|
let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
|
|
54
54
|
let v = props.value || props.defaultValue || props.placeholderValue;
|
|
55
55
|
let [granularity, defaultTimeZone] = (0, $50d5d6a623389320$exports.useDefaultProps)(v, props.granularity);
|
|
56
|
-
let timeZone = defaultTimeZone ||
|
|
56
|
+
let timeZone = defaultTimeZone || 'UTC';
|
|
57
57
|
// props.granularity must actually exist in the value if one is provided.
|
|
58
|
-
if (v && !(granularity in v)) throw new Error(
|
|
58
|
+
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
59
59
|
let defaultFormatter = (0, $iqS8N$react.useMemo)(()=>new (0, $iqS8N$internationalizeddate.DateFormatter)(locale), [
|
|
60
60
|
locale
|
|
61
61
|
]);
|
|
@@ -74,12 +74,12 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
74
74
|
// change from uncontrolled to controlled and emit a warning.
|
|
75
75
|
let [placeholderDate, setPlaceholderDate] = (0, $iqS8N$react.useState)(()=>(0, $50d5d6a623389320$exports.createPlaceholderDate)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
76
76
|
let val = calendarValue || placeholderDate;
|
|
77
|
-
let showEra = calendar.identifier ===
|
|
77
|
+
let showEra = calendar.identifier === 'gregory' && val.era === 'BC';
|
|
78
78
|
let formatOpts = (0, $iqS8N$react.useMemo)(()=>{
|
|
79
79
|
var _props_maxGranularity;
|
|
80
80
|
return {
|
|
81
81
|
granularity: granularity,
|
|
82
|
-
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity :
|
|
82
|
+
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : 'year',
|
|
83
83
|
timeZone: defaultTimeZone,
|
|
84
84
|
hideTimeZone: hideTimeZone,
|
|
85
85
|
hourCycle: props.hourCycle,
|
|
@@ -152,7 +152,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
152
152
|
setDate(null);
|
|
153
153
|
setPlaceholderDate((0, $50d5d6a623389320$exports.createPlaceholderDate)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
154
154
|
setValidSegments({});
|
|
155
|
-
} else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !==
|
|
155
|
+
} else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod') {
|
|
156
156
|
// The display calendar should not have any effect on the emitted value.
|
|
157
157
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
158
158
|
newValue = (0, $iqS8N$internationalizeddate.toCalendar)(newValue, (v === null || v === void 0 ? void 0 : v.calendar) || new (0, $iqS8N$internationalizeddate.GregorianCalendar)());
|
|
@@ -166,7 +166,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
166
166
|
]);
|
|
167
167
|
let segments = (0, $iqS8N$react.useMemo)(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
168
168
|
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
169
|
-
if (segment.type ===
|
|
169
|
+
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
170
170
|
let isPlaceholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
171
171
|
let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] ? (0, $e1e8ada727fae1a1$exports.getPlaceholder)(segment.type, segment.value, locale) : null;
|
|
172
172
|
return {
|
|
@@ -201,7 +201,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
201
201
|
}
|
|
202
202
|
let markValid = (part)=>{
|
|
203
203
|
validSegments[part] = true;
|
|
204
|
-
if (part ===
|
|
204
|
+
if (part === 'year' && allSegments.era) validSegments.era = true;
|
|
205
205
|
setValidSegments({
|
|
206
206
|
...validSegments
|
|
207
207
|
});
|
|
@@ -227,7 +227,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
227
227
|
builtinValidation: builtinValidation
|
|
228
228
|
});
|
|
229
229
|
let isValueInvalid = validation.displayValidation.isInvalid;
|
|
230
|
-
let validationState = props.validationState || (isValueInvalid ?
|
|
230
|
+
let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
|
|
231
231
|
var _props_maxGranularity;
|
|
232
232
|
return {
|
|
233
233
|
...validation,
|
|
@@ -240,7 +240,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
240
240
|
validationState: validationState,
|
|
241
241
|
isInvalid: isValueInvalid,
|
|
242
242
|
granularity: granularity,
|
|
243
|
-
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity :
|
|
243
|
+
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : 'year',
|
|
244
244
|
isDisabled: isDisabled,
|
|
245
245
|
isReadOnly: isReadOnly,
|
|
246
246
|
isRequired: isRequired,
|
|
@@ -282,7 +282,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
282
282
|
let placeholder = (0, $50d5d6a623389320$exports.createPlaceholderDate)(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
283
283
|
let value = displayValue;
|
|
284
284
|
// Reset day period to default without changing the hour.
|
|
285
|
-
if (part ===
|
|
285
|
+
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
286
286
|
let isPM = displayValue.hour >= 12;
|
|
287
287
|
let shouldBePM = placeholder.hour >= 12;
|
|
288
288
|
if (isPM && !shouldBePM) value = displayValue.set({
|
|
@@ -298,7 +298,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
298
298
|
setValue(value);
|
|
299
299
|
},
|
|
300
300
|
formatValue (fieldOptions) {
|
|
301
|
-
if (!calendarValue) return
|
|
301
|
+
if (!calendarValue) return '';
|
|
302
302
|
let formatOptions = (0, $50d5d6a623389320$exports.getFormatOptions)(fieldOptions, formatOpts);
|
|
303
303
|
let formatter = new (0, $iqS8N$internationalizeddate.DateFormatter)(locale, formatOptions);
|
|
304
304
|
return formatter.format(dateValue);
|
|
@@ -307,7 +307,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
307
307
|
}
|
|
308
308
|
function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
309
309
|
switch(type){
|
|
310
|
-
case
|
|
310
|
+
case 'era':
|
|
311
311
|
{
|
|
312
312
|
let eras = date.calendar.getEras();
|
|
313
313
|
return {
|
|
@@ -316,33 +316,33 @@ function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
|
316
316
|
maxValue: eras.length - 1
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
|
-
case
|
|
319
|
+
case 'year':
|
|
320
320
|
return {
|
|
321
321
|
value: date.year,
|
|
322
322
|
minValue: 1,
|
|
323
323
|
maxValue: date.calendar.getYearsInEra(date)
|
|
324
324
|
};
|
|
325
|
-
case
|
|
325
|
+
case 'month':
|
|
326
326
|
return {
|
|
327
327
|
value: date.month,
|
|
328
328
|
minValue: (0, $iqS8N$internationalizeddate.getMinimumMonthInYear)(date),
|
|
329
329
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
330
330
|
};
|
|
331
|
-
case
|
|
331
|
+
case 'day':
|
|
332
332
|
return {
|
|
333
333
|
value: date.day,
|
|
334
334
|
minValue: (0, $iqS8N$internationalizeddate.getMinimumDayInMonth)(date),
|
|
335
335
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
|
-
if (
|
|
339
|
-
case
|
|
338
|
+
if ('hour' in date) switch(type){
|
|
339
|
+
case 'dayPeriod':
|
|
340
340
|
return {
|
|
341
341
|
value: date.hour >= 12 ? 12 : 0,
|
|
342
342
|
minValue: 0,
|
|
343
343
|
maxValue: 12
|
|
344
344
|
};
|
|
345
|
-
case
|
|
345
|
+
case 'hour':
|
|
346
346
|
if (options.hour12) {
|
|
347
347
|
let isPM = date.hour >= 12;
|
|
348
348
|
return {
|
|
@@ -356,13 +356,13 @@ function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
|
356
356
|
minValue: 0,
|
|
357
357
|
maxValue: 23
|
|
358
358
|
};
|
|
359
|
-
case
|
|
359
|
+
case 'minute':
|
|
360
360
|
return {
|
|
361
361
|
value: date.minute,
|
|
362
362
|
minValue: 0,
|
|
363
363
|
maxValue: 59
|
|
364
364
|
};
|
|
365
|
-
case
|
|
365
|
+
case 'second':
|
|
366
366
|
return {
|
|
367
367
|
value: date.second,
|
|
368
368
|
minValue: 0,
|
|
@@ -373,16 +373,16 @@ function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
|
373
373
|
}
|
|
374
374
|
function $596a1f0f523d6752$var$addSegment(value, part, amount, options) {
|
|
375
375
|
switch(part){
|
|
376
|
-
case
|
|
377
|
-
case
|
|
378
|
-
case
|
|
379
|
-
case
|
|
376
|
+
case 'era':
|
|
377
|
+
case 'year':
|
|
378
|
+
case 'month':
|
|
379
|
+
case 'day':
|
|
380
380
|
return value.cycle(part, amount, {
|
|
381
|
-
round: part ===
|
|
381
|
+
round: part === 'year'
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
|
-
if (
|
|
385
|
-
case
|
|
384
|
+
if ('hour' in value) switch(part){
|
|
385
|
+
case 'dayPeriod':
|
|
386
386
|
{
|
|
387
387
|
let hours = value.hour;
|
|
388
388
|
let isPM = hours >= 12;
|
|
@@ -390,27 +390,27 @@ function $596a1f0f523d6752$var$addSegment(value, part, amount, options) {
|
|
|
390
390
|
hour: isPM ? hours - 12 : hours + 12
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
|
-
case
|
|
394
|
-
case
|
|
395
|
-
case
|
|
393
|
+
case 'hour':
|
|
394
|
+
case 'minute':
|
|
395
|
+
case 'second':
|
|
396
396
|
return value.cycle(part, amount, {
|
|
397
|
-
round: part !==
|
|
397
|
+
round: part !== 'hour',
|
|
398
398
|
hourCycle: options.hour12 ? 12 : 24
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
403
403
|
switch(part){
|
|
404
|
-
case
|
|
405
|
-
case
|
|
406
|
-
case
|
|
407
|
-
case
|
|
404
|
+
case 'day':
|
|
405
|
+
case 'month':
|
|
406
|
+
case 'year':
|
|
407
|
+
case 'era':
|
|
408
408
|
return value.set({
|
|
409
409
|
[part]: segmentValue
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
-
if (
|
|
413
|
-
case
|
|
412
|
+
if ('hour' in value) switch(part){
|
|
413
|
+
case 'dayPeriod':
|
|
414
414
|
{
|
|
415
415
|
let hours = value.hour;
|
|
416
416
|
let wasPM = hours >= 12;
|
|
@@ -420,7 +420,7 @@ function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
|
420
420
|
hour: wasPM ? hours - 12 : hours + 12
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
|
-
case
|
|
423
|
+
case 'hour':
|
|
424
424
|
// In 12 hour time, ensure that AM/PM does not change
|
|
425
425
|
if (options.hour12) {
|
|
426
426
|
let hours = value.hour;
|
|
@@ -429,8 +429,8 @@ function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
|
429
429
|
if (wasPM && segmentValue < 12) segmentValue += 12;
|
|
430
430
|
}
|
|
431
431
|
// fallthrough
|
|
432
|
-
case
|
|
433
|
-
case
|
|
432
|
+
case 'minute':
|
|
433
|
+
case 'second':
|
|
434
434
|
return value.set({
|
|
435
435
|
[part]: segmentValue
|
|
436
436
|
});
|
|
@@ -41,15 +41,15 @@ const $3c0fc76039f1c516$var$PAGE_STEP = {
|
|
|
41
41
|
};
|
|
42
42
|
// Node seems to convert everything to lowercase...
|
|
43
43
|
const $3c0fc76039f1c516$var$TYPE_MAPPING = {
|
|
44
|
-
dayperiod:
|
|
44
|
+
dayperiod: 'dayPeriod'
|
|
45
45
|
};
|
|
46
46
|
function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
47
47
|
let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
|
|
48
48
|
let v = props.value || props.defaultValue || props.placeholderValue;
|
|
49
49
|
let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
|
|
50
|
-
let timeZone = defaultTimeZone ||
|
|
50
|
+
let timeZone = defaultTimeZone || 'UTC';
|
|
51
51
|
// props.granularity must actually exist in the value if one is provided.
|
|
52
|
-
if (v && !(granularity in v)) throw new Error(
|
|
52
|
+
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
53
53
|
let defaultFormatter = (0, $g03ag$useMemo)(()=>new (0, $g03ag$DateFormatter)(locale), [
|
|
54
54
|
locale
|
|
55
55
|
]);
|
|
@@ -68,12 +68,12 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
68
68
|
// change from uncontrolled to controlled and emit a warning.
|
|
69
69
|
let [placeholderDate, setPlaceholderDate] = (0, $g03ag$useState)(()=>(0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
70
70
|
let val = calendarValue || placeholderDate;
|
|
71
|
-
let showEra = calendar.identifier ===
|
|
71
|
+
let showEra = calendar.identifier === 'gregory' && val.era === 'BC';
|
|
72
72
|
let formatOpts = (0, $g03ag$useMemo)(()=>{
|
|
73
73
|
var _props_maxGranularity;
|
|
74
74
|
return {
|
|
75
75
|
granularity: granularity,
|
|
76
|
-
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity :
|
|
76
|
+
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : 'year',
|
|
77
77
|
timeZone: defaultTimeZone,
|
|
78
78
|
hideTimeZone: hideTimeZone,
|
|
79
79
|
hourCycle: props.hourCycle,
|
|
@@ -146,7 +146,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
146
146
|
setDate(null);
|
|
147
147
|
setPlaceholderDate((0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
148
148
|
setValidSegments({});
|
|
149
|
-
} else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !==
|
|
149
|
+
} else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod') {
|
|
150
150
|
// The display calendar should not have any effect on the emitted value.
|
|
151
151
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
152
152
|
newValue = (0, $g03ag$toCalendar)(newValue, (v === null || v === void 0 ? void 0 : v.calendar) || new (0, $g03ag$GregorianCalendar)());
|
|
@@ -160,7 +160,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
160
160
|
]);
|
|
161
161
|
let segments = (0, $g03ag$useMemo)(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
162
162
|
let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
|
|
163
|
-
if (segment.type ===
|
|
163
|
+
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
164
164
|
let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
165
165
|
let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
|
|
166
166
|
return {
|
|
@@ -195,7 +195,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
195
195
|
}
|
|
196
196
|
let markValid = (part)=>{
|
|
197
197
|
validSegments[part] = true;
|
|
198
|
-
if (part ===
|
|
198
|
+
if (part === 'year' && allSegments.era) validSegments.era = true;
|
|
199
199
|
setValidSegments({
|
|
200
200
|
...validSegments
|
|
201
201
|
});
|
|
@@ -221,7 +221,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
221
221
|
builtinValidation: builtinValidation
|
|
222
222
|
});
|
|
223
223
|
let isValueInvalid = validation.displayValidation.isInvalid;
|
|
224
|
-
let validationState = props.validationState || (isValueInvalid ?
|
|
224
|
+
let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
|
|
225
225
|
var _props_maxGranularity;
|
|
226
226
|
return {
|
|
227
227
|
...validation,
|
|
@@ -234,7 +234,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
234
234
|
validationState: validationState,
|
|
235
235
|
isInvalid: isValueInvalid,
|
|
236
236
|
granularity: granularity,
|
|
237
|
-
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity :
|
|
237
|
+
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : 'year',
|
|
238
238
|
isDisabled: isDisabled,
|
|
239
239
|
isReadOnly: isReadOnly,
|
|
240
240
|
isRequired: isRequired,
|
|
@@ -276,7 +276,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
276
276
|
let placeholder = (0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
277
277
|
let value = displayValue;
|
|
278
278
|
// Reset day period to default without changing the hour.
|
|
279
|
-
if (part ===
|
|
279
|
+
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
280
280
|
let isPM = displayValue.hour >= 12;
|
|
281
281
|
let shouldBePM = placeholder.hour >= 12;
|
|
282
282
|
if (isPM && !shouldBePM) value = displayValue.set({
|
|
@@ -292,7 +292,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
292
292
|
setValue(value);
|
|
293
293
|
},
|
|
294
294
|
formatValue (fieldOptions) {
|
|
295
|
-
if (!calendarValue) return
|
|
295
|
+
if (!calendarValue) return '';
|
|
296
296
|
let formatOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
|
|
297
297
|
let formatter = new (0, $g03ag$DateFormatter)(locale, formatOptions);
|
|
298
298
|
return formatter.format(dateValue);
|
|
@@ -301,7 +301,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
301
301
|
}
|
|
302
302
|
function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
|
|
303
303
|
switch(type){
|
|
304
|
-
case
|
|
304
|
+
case 'era':
|
|
305
305
|
{
|
|
306
306
|
let eras = date.calendar.getEras();
|
|
307
307
|
return {
|
|
@@ -310,33 +310,33 @@ function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
|
|
|
310
310
|
maxValue: eras.length - 1
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
-
case
|
|
313
|
+
case 'year':
|
|
314
314
|
return {
|
|
315
315
|
value: date.year,
|
|
316
316
|
minValue: 1,
|
|
317
317
|
maxValue: date.calendar.getYearsInEra(date)
|
|
318
318
|
};
|
|
319
|
-
case
|
|
319
|
+
case 'month':
|
|
320
320
|
return {
|
|
321
321
|
value: date.month,
|
|
322
322
|
minValue: (0, $g03ag$getMinimumMonthInYear)(date),
|
|
323
323
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
324
324
|
};
|
|
325
|
-
case
|
|
325
|
+
case 'day':
|
|
326
326
|
return {
|
|
327
327
|
value: date.day,
|
|
328
328
|
minValue: (0, $g03ag$getMinimumDayInMonth)(date),
|
|
329
329
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
if (
|
|
333
|
-
case
|
|
332
|
+
if ('hour' in date) switch(type){
|
|
333
|
+
case 'dayPeriod':
|
|
334
334
|
return {
|
|
335
335
|
value: date.hour >= 12 ? 12 : 0,
|
|
336
336
|
minValue: 0,
|
|
337
337
|
maxValue: 12
|
|
338
338
|
};
|
|
339
|
-
case
|
|
339
|
+
case 'hour':
|
|
340
340
|
if (options.hour12) {
|
|
341
341
|
let isPM = date.hour >= 12;
|
|
342
342
|
return {
|
|
@@ -350,13 +350,13 @@ function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
|
|
|
350
350
|
minValue: 0,
|
|
351
351
|
maxValue: 23
|
|
352
352
|
};
|
|
353
|
-
case
|
|
353
|
+
case 'minute':
|
|
354
354
|
return {
|
|
355
355
|
value: date.minute,
|
|
356
356
|
minValue: 0,
|
|
357
357
|
maxValue: 59
|
|
358
358
|
};
|
|
359
|
-
case
|
|
359
|
+
case 'second':
|
|
360
360
|
return {
|
|
361
361
|
value: date.second,
|
|
362
362
|
minValue: 0,
|
|
@@ -367,16 +367,16 @@ function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
|
|
|
367
367
|
}
|
|
368
368
|
function $3c0fc76039f1c516$var$addSegment(value, part, amount, options) {
|
|
369
369
|
switch(part){
|
|
370
|
-
case
|
|
371
|
-
case
|
|
372
|
-
case
|
|
373
|
-
case
|
|
370
|
+
case 'era':
|
|
371
|
+
case 'year':
|
|
372
|
+
case 'month':
|
|
373
|
+
case 'day':
|
|
374
374
|
return value.cycle(part, amount, {
|
|
375
|
-
round: part ===
|
|
375
|
+
round: part === 'year'
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
|
-
if (
|
|
379
|
-
case
|
|
378
|
+
if ('hour' in value) switch(part){
|
|
379
|
+
case 'dayPeriod':
|
|
380
380
|
{
|
|
381
381
|
let hours = value.hour;
|
|
382
382
|
let isPM = hours >= 12;
|
|
@@ -384,27 +384,27 @@ function $3c0fc76039f1c516$var$addSegment(value, part, amount, options) {
|
|
|
384
384
|
hour: isPM ? hours - 12 : hours + 12
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
|
-
case
|
|
388
|
-
case
|
|
389
|
-
case
|
|
387
|
+
case 'hour':
|
|
388
|
+
case 'minute':
|
|
389
|
+
case 'second':
|
|
390
390
|
return value.cycle(part, amount, {
|
|
391
|
-
round: part !==
|
|
391
|
+
round: part !== 'hour',
|
|
392
392
|
hourCycle: options.hour12 ? 12 : 24
|
|
393
393
|
});
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
|
|
397
397
|
switch(part){
|
|
398
|
-
case
|
|
399
|
-
case
|
|
400
|
-
case
|
|
401
|
-
case
|
|
398
|
+
case 'day':
|
|
399
|
+
case 'month':
|
|
400
|
+
case 'year':
|
|
401
|
+
case 'era':
|
|
402
402
|
return value.set({
|
|
403
403
|
[part]: segmentValue
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
|
-
if (
|
|
407
|
-
case
|
|
406
|
+
if ('hour' in value) switch(part){
|
|
407
|
+
case 'dayPeriod':
|
|
408
408
|
{
|
|
409
409
|
let hours = value.hour;
|
|
410
410
|
let wasPM = hours >= 12;
|
|
@@ -414,7 +414,7 @@ function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
|
|
|
414
414
|
hour: wasPM ? hours - 12 : hours + 12
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
-
case
|
|
417
|
+
case 'hour':
|
|
418
418
|
// In 12 hour time, ensure that AM/PM does not change
|
|
419
419
|
if (options.hour12) {
|
|
420
420
|
let hours = value.hour;
|
|
@@ -423,8 +423,8 @@ function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
|
|
|
423
423
|
if (wasPM && segmentValue < 12) segmentValue += 12;
|
|
424
424
|
}
|
|
425
425
|
// fallthrough
|
|
426
|
-
case
|
|
427
|
-
case
|
|
426
|
+
case 'minute':
|
|
427
|
+
case 'second':
|
|
428
428
|
return value.set({
|
|
429
429
|
[part]: segmentValue
|
|
430
430
|
});
|
|
@@ -433,4 +433,4 @@ function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
|
|
|
433
433
|
|
|
434
434
|
|
|
435
435
|
export {$3c0fc76039f1c516$export$60e84778edff6d26 as useDateFieldState};
|
|
436
|
-
//# sourceMappingURL=useDateFieldState.
|
|
436
|
+
//# sourceMappingURL=useDateFieldState.module.js.map
|