@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
|
@@ -48,19 +48,19 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
|
48
48
|
};
|
|
49
49
|
let v = (value === null || value === void 0 ? void 0 : value.start) || (value === null || value === void 0 ? void 0 : value.end) || props.placeholderValue;
|
|
50
50
|
let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
|
|
51
|
-
let hasTime = granularity ===
|
|
51
|
+
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
|
|
52
52
|
var _props_shouldCloseOnSelect;
|
|
53
53
|
let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
|
|
54
54
|
let [dateRange, setSelectedDateRange] = (0, $hac8C$useState)(null);
|
|
55
55
|
let [timeRange, setSelectedTimeRange] = (0, $hac8C$useState)(null);
|
|
56
56
|
if (value && value.start && value.end) {
|
|
57
57
|
dateRange = value;
|
|
58
|
-
if (
|
|
58
|
+
if ('hour' in value.start) timeRange = value;
|
|
59
59
|
}
|
|
60
60
|
let commitValue = (dateRange, timeRange)=>{
|
|
61
61
|
setValue({
|
|
62
|
-
start:
|
|
63
|
-
end:
|
|
62
|
+
start: 'timeZone' in timeRange.start ? timeRange.start.set((0, $hac8C$toCalendarDate)(dateRange.start)) : (0, $hac8C$toCalendarDateTime)(dateRange.start, timeRange.start),
|
|
63
|
+
end: 'timeZone' in timeRange.end ? timeRange.end.set((0, $hac8C$toCalendarDate)(dateRange.end)) : (0, $hac8C$toCalendarDateTime)(dateRange.end, timeRange.end)
|
|
64
64
|
});
|
|
65
65
|
setSelectedDateRange(null);
|
|
66
66
|
setSelectedTimeRange(null);
|
|
@@ -68,7 +68,7 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
|
68
68
|
};
|
|
69
69
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
70
70
|
let setDateRange = (range)=>{
|
|
71
|
-
let shouldClose = typeof shouldCloseOnSelect ===
|
|
71
|
+
let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
|
|
72
72
|
if (hasTime) {
|
|
73
73
|
if (shouldClose || range.start && range.end && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
|
|
74
74
|
start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
|
|
@@ -85,7 +85,7 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
|
85
85
|
if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && range.start && range.end) commitValue(dateRange, range);
|
|
86
86
|
else setSelectedTimeRange(range);
|
|
87
87
|
};
|
|
88
|
-
let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) ===
|
|
88
|
+
let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) === 'gregory' && value.start.era === 'BC' || (value === null || value === void 0 ? void 0 : (_value_end = value.end) === null || _value_end === void 0 ? void 0 : _value_end.calendar.identifier) === 'gregory' && value.end.era === 'BC';
|
|
89
89
|
let formatOpts = (0, $hac8C$useMemo)(()=>({
|
|
90
90
|
granularity: granularity,
|
|
91
91
|
timeZone: defaultTimeZone,
|
|
@@ -122,7 +122,7 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
|
122
122
|
builtinValidation: builtinValidation
|
|
123
123
|
});
|
|
124
124
|
let isValueInvalid = validation.displayValidation.isInvalid;
|
|
125
|
-
let validationState = props.validationState || (isValueInvalid ?
|
|
125
|
+
let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
|
|
126
126
|
return {
|
|
127
127
|
...validation,
|
|
128
128
|
value: value,
|
|
@@ -166,19 +166,19 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
|
166
166
|
isInvalid: isValueInvalid,
|
|
167
167
|
formatValue (locale, fieldOptions) {
|
|
168
168
|
if (!value || !value.start || !value.end) return null;
|
|
169
|
-
let startTimeZone =
|
|
170
|
-
let startGranularity = props.granularity || (value.start &&
|
|
171
|
-
let endTimeZone =
|
|
172
|
-
let endGranularity = props.granularity || (value.end &&
|
|
169
|
+
let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;
|
|
170
|
+
let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');
|
|
171
|
+
let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;
|
|
172
|
+
let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');
|
|
173
173
|
let startOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
|
|
174
174
|
granularity: startGranularity,
|
|
175
175
|
timeZone: startTimeZone,
|
|
176
176
|
hideTimeZone: props.hideTimeZone,
|
|
177
177
|
hourCycle: props.hourCycle,
|
|
178
|
-
showEra: value.start.calendar.identifier ===
|
|
178
|
+
showEra: value.start.calendar.identifier === 'gregory' && value.start.era === 'BC' || value.end.calendar.identifier === 'gregory' && value.end.era === 'BC'
|
|
179
179
|
});
|
|
180
|
-
let startDate = value.start.toDate(startTimeZone ||
|
|
181
|
-
let endDate = value.end.toDate(endTimeZone ||
|
|
180
|
+
let startDate = value.start.toDate(startTimeZone || 'UTC');
|
|
181
|
+
let endDate = value.end.toDate(endTimeZone || 'UTC');
|
|
182
182
|
let startFormatter = new (0, $hac8C$DateFormatter)(locale, startOptions);
|
|
183
183
|
let endFormatter;
|
|
184
184
|
if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {
|
|
@@ -192,12 +192,12 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
|
192
192
|
let separatorIndex = -1;
|
|
193
193
|
for(let i = 0; i < parts.length; i++){
|
|
194
194
|
let part = parts[i];
|
|
195
|
-
if (part.source ===
|
|
196
|
-
else if (part.source ===
|
|
195
|
+
if (part.source === 'shared' && part.type === 'literal') separatorIndex = i;
|
|
196
|
+
else if (part.source === 'endRange') break;
|
|
197
197
|
}
|
|
198
198
|
// Now we can combine the parts into start and end strings.
|
|
199
|
-
let start =
|
|
200
|
-
let end =
|
|
199
|
+
let start = '';
|
|
200
|
+
let end = '';
|
|
201
201
|
for(let i = 0; i < parts.length; i++){
|
|
202
202
|
if (i < separatorIndex) start += parts[i].value;
|
|
203
203
|
else if (i > separatorIndex) end += parts[i].value;
|
|
@@ -27,10 +27,10 @@ function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
|
27
27
|
let { placeholderValue: placeholderValue = new (0, $1Q50t$internationalizeddate.Time)(), minValue: minValue, maxValue: maxValue, granularity: granularity, validate: validate } = props;
|
|
28
28
|
let [value, setValue] = (0, $1Q50t$reactstatelyutils.useControlledState)(props.value, props.defaultValue, props.onChange);
|
|
29
29
|
let v = value || placeholderValue;
|
|
30
|
-
let day = v &&
|
|
31
|
-
let defaultValueTimeZone = props.defaultValue &&
|
|
30
|
+
let day = v && 'day' in v ? v : undefined;
|
|
31
|
+
let defaultValueTimeZone = props.defaultValue && 'timeZone' in props.defaultValue ? props.defaultValue.timeZone : undefined;
|
|
32
32
|
let placeholderDate = (0, $1Q50t$react.useMemo)(()=>{
|
|
33
|
-
let valueTimeZone = v &&
|
|
33
|
+
let valueTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
34
34
|
return (valueTimeZone || defaultValueTimeZone) && placeholderValue ? (0, $1Q50t$internationalizeddate.toZoned)($2654e87be0231a69$var$convertValue(placeholderValue), valueTimeZone || defaultValueTimeZone) : $2654e87be0231a69$var$convertValue(placeholderValue);
|
|
35
35
|
}, [
|
|
36
36
|
placeholderValue,
|
|
@@ -45,7 +45,7 @@ function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
|
45
45
|
maxValue,
|
|
46
46
|
day
|
|
47
47
|
]);
|
|
48
|
-
let timeValue = (0, $1Q50t$react.useMemo)(()=>value &&
|
|
48
|
+
let timeValue = (0, $1Q50t$react.useMemo)(()=>value && 'day' in value ? (0, $1Q50t$internationalizeddate.toTime)(value) : value, [
|
|
49
49
|
value
|
|
50
50
|
]);
|
|
51
51
|
let dateTime = (0, $1Q50t$react.useMemo)(()=>value == null ? null : $2654e87be0231a69$var$convertValue(value), [
|
|
@@ -61,8 +61,8 @@ function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
|
61
61
|
minValue: minDate,
|
|
62
62
|
maxValue: maxDate,
|
|
63
63
|
onChange: onChange,
|
|
64
|
-
granularity: granularity ||
|
|
65
|
-
maxGranularity:
|
|
64
|
+
granularity: granularity || 'minute',
|
|
65
|
+
maxGranularity: 'hour',
|
|
66
66
|
placeholderValue: placeholderDate,
|
|
67
67
|
// Calendar should not matter for time fields.
|
|
68
68
|
createCalendar: ()=>new (0, $1Q50t$internationalizeddate.GregorianCalendar)(),
|
|
@@ -78,7 +78,7 @@ function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
|
78
78
|
}
|
|
79
79
|
function $2654e87be0231a69$var$convertValue(value, date = (0, $1Q50t$internationalizeddate.today)((0, $1Q50t$internationalizeddate.getLocalTimeZone)())) {
|
|
80
80
|
if (!value) return null;
|
|
81
|
-
if (
|
|
81
|
+
if ('day' in value) return value;
|
|
82
82
|
return (0, $1Q50t$internationalizeddate.toCalendarDateTime)(date, value);
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -21,10 +21,10 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
21
21
|
let { placeholderValue: placeholderValue = new (0, $2PRh3$Time)(), minValue: minValue, maxValue: maxValue, granularity: granularity, validate: validate } = props;
|
|
22
22
|
let [value, setValue] = (0, $2PRh3$useControlledState)(props.value, props.defaultValue, props.onChange);
|
|
23
23
|
let v = value || placeholderValue;
|
|
24
|
-
let day = v &&
|
|
25
|
-
let defaultValueTimeZone = props.defaultValue &&
|
|
24
|
+
let day = v && 'day' in v ? v : undefined;
|
|
25
|
+
let defaultValueTimeZone = props.defaultValue && 'timeZone' in props.defaultValue ? props.defaultValue.timeZone : undefined;
|
|
26
26
|
let placeholderDate = (0, $2PRh3$useMemo)(()=>{
|
|
27
|
-
let valueTimeZone = v &&
|
|
27
|
+
let valueTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
28
28
|
return (valueTimeZone || defaultValueTimeZone) && placeholderValue ? (0, $2PRh3$toZoned)($eff5d8ee529ac4bb$var$convertValue(placeholderValue), valueTimeZone || defaultValueTimeZone) : $eff5d8ee529ac4bb$var$convertValue(placeholderValue);
|
|
29
29
|
}, [
|
|
30
30
|
placeholderValue,
|
|
@@ -39,7 +39,7 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
39
39
|
maxValue,
|
|
40
40
|
day
|
|
41
41
|
]);
|
|
42
|
-
let timeValue = (0, $2PRh3$useMemo)(()=>value &&
|
|
42
|
+
let timeValue = (0, $2PRh3$useMemo)(()=>value && 'day' in value ? (0, $2PRh3$toTime)(value) : value, [
|
|
43
43
|
value
|
|
44
44
|
]);
|
|
45
45
|
let dateTime = (0, $2PRh3$useMemo)(()=>value == null ? null : $eff5d8ee529ac4bb$var$convertValue(value), [
|
|
@@ -55,8 +55,8 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
55
55
|
minValue: minDate,
|
|
56
56
|
maxValue: maxDate,
|
|
57
57
|
onChange: onChange,
|
|
58
|
-
granularity: granularity ||
|
|
59
|
-
maxGranularity:
|
|
58
|
+
granularity: granularity || 'minute',
|
|
59
|
+
maxGranularity: 'hour',
|
|
60
60
|
placeholderValue: placeholderDate,
|
|
61
61
|
// Calendar should not matter for time fields.
|
|
62
62
|
createCalendar: ()=>new (0, $2PRh3$GregorianCalendar)(),
|
|
@@ -72,10 +72,10 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
72
72
|
}
|
|
73
73
|
function $eff5d8ee529ac4bb$var$convertValue(value, date = (0, $2PRh3$today)((0, $2PRh3$getLocalTimeZone)())) {
|
|
74
74
|
if (!value) return null;
|
|
75
|
-
if (
|
|
75
|
+
if ('day' in value) return value;
|
|
76
76
|
return (0, $2PRh3$toCalendarDateTime)(date, value);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
export {$eff5d8ee529ac4bb$export$fd53cef0cc796101 as useTimeFieldState};
|
|
81
|
-
//# sourceMappingURL=useTimeFieldState.
|
|
81
|
+
//# sourceMappingURL=useTimeFieldState.module.js.map
|
|
@@ -21,10 +21,10 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
21
21
|
let { placeholderValue: placeholderValue = new (0, $2PRh3$Time)(), minValue: minValue, maxValue: maxValue, granularity: granularity, validate: validate } = props;
|
|
22
22
|
let [value, setValue] = (0, $2PRh3$useControlledState)(props.value, props.defaultValue, props.onChange);
|
|
23
23
|
let v = value || placeholderValue;
|
|
24
|
-
let day = v &&
|
|
25
|
-
let defaultValueTimeZone = props.defaultValue &&
|
|
24
|
+
let day = v && 'day' in v ? v : undefined;
|
|
25
|
+
let defaultValueTimeZone = props.defaultValue && 'timeZone' in props.defaultValue ? props.defaultValue.timeZone : undefined;
|
|
26
26
|
let placeholderDate = (0, $2PRh3$useMemo)(()=>{
|
|
27
|
-
let valueTimeZone = v &&
|
|
27
|
+
let valueTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
28
28
|
return (valueTimeZone || defaultValueTimeZone) && placeholderValue ? (0, $2PRh3$toZoned)($eff5d8ee529ac4bb$var$convertValue(placeholderValue), valueTimeZone || defaultValueTimeZone) : $eff5d8ee529ac4bb$var$convertValue(placeholderValue);
|
|
29
29
|
}, [
|
|
30
30
|
placeholderValue,
|
|
@@ -39,7 +39,7 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
39
39
|
maxValue,
|
|
40
40
|
day
|
|
41
41
|
]);
|
|
42
|
-
let timeValue = (0, $2PRh3$useMemo)(()=>value &&
|
|
42
|
+
let timeValue = (0, $2PRh3$useMemo)(()=>value && 'day' in value ? (0, $2PRh3$toTime)(value) : value, [
|
|
43
43
|
value
|
|
44
44
|
]);
|
|
45
45
|
let dateTime = (0, $2PRh3$useMemo)(()=>value == null ? null : $eff5d8ee529ac4bb$var$convertValue(value), [
|
|
@@ -55,8 +55,8 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
55
55
|
minValue: minDate,
|
|
56
56
|
maxValue: maxDate,
|
|
57
57
|
onChange: onChange,
|
|
58
|
-
granularity: granularity ||
|
|
59
|
-
maxGranularity:
|
|
58
|
+
granularity: granularity || 'minute',
|
|
59
|
+
maxGranularity: 'hour',
|
|
60
60
|
placeholderValue: placeholderDate,
|
|
61
61
|
// Calendar should not matter for time fields.
|
|
62
62
|
createCalendar: ()=>new (0, $2PRh3$GregorianCalendar)(),
|
|
@@ -72,7 +72,7 @@ function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
|
72
72
|
}
|
|
73
73
|
function $eff5d8ee529ac4bb$var$convertValue(value, date = (0, $2PRh3$today)((0, $2PRh3$getLocalTimeZone)())) {
|
|
74
74
|
if (!value) return null;
|
|
75
|
-
if (
|
|
75
|
+
if ('day' in value) return value;
|
|
76
76
|
return (0, $2PRh3$toCalendarDateTime)(date, value);
|
|
77
77
|
}
|
|
78
78
|
|
package/dist/utils.main.js
CHANGED
|
@@ -40,7 +40,7 @@ function $50d5d6a623389320$var$getLocale() {
|
|
|
40
40
|
// Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided
|
|
41
41
|
// validation messages, which to not respect our provider's language.
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
return typeof navigator !==
|
|
43
|
+
return typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
44
44
|
}
|
|
45
45
|
function $50d5d6a623389320$export$f18627323ab57ac0(value, minValue, maxValue, isDateUnavailable, options) {
|
|
46
46
|
let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;
|
|
@@ -50,17 +50,17 @@ function $50d5d6a623389320$export$f18627323ab57ac0(value, minValue, maxValue, is
|
|
|
50
50
|
let errors = [];
|
|
51
51
|
if (isInvalid) {
|
|
52
52
|
let locale = $50d5d6a623389320$var$getLocale();
|
|
53
|
-
let strings = (0, $68Tdx$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage(
|
|
53
|
+
let strings = (0, $68Tdx$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage('@react-stately/datepicker') || $50d5d6a623389320$var$dictionary;
|
|
54
54
|
let formatter = new (0, $68Tdx$internationalizedstring.LocalizedStringFormatter)(locale, strings);
|
|
55
55
|
let dateFormatter = new (0, $68Tdx$internationalizeddate.DateFormatter)(locale, $50d5d6a623389320$export$7e319ea407e63bc0({}, options));
|
|
56
56
|
let timeZone = dateFormatter.resolvedOptions().timeZone;
|
|
57
|
-
if (rangeUnderflow) errors.push(formatter.format(
|
|
57
|
+
if (rangeUnderflow) errors.push(formatter.format('rangeUnderflow', {
|
|
58
58
|
minValue: dateFormatter.format(minValue.toDate(timeZone))
|
|
59
59
|
}));
|
|
60
|
-
if (rangeOverflow) errors.push(formatter.format(
|
|
60
|
+
if (rangeOverflow) errors.push(formatter.format('rangeOverflow', {
|
|
61
61
|
maxValue: dateFormatter.format(maxValue.toDate(timeZone))
|
|
62
62
|
}));
|
|
63
|
-
if (isUnavailable) errors.push(formatter.format(
|
|
63
|
+
if (isUnavailable) errors.push(formatter.format('unavailableDate'));
|
|
64
64
|
}
|
|
65
65
|
return {
|
|
66
66
|
isInvalid: isInvalid,
|
|
@@ -85,11 +85,11 @@ function $50d5d6a623389320$export$80ff8fc0ae339c13(value, minValue, maxValue, is
|
|
|
85
85
|
let endValidation = $50d5d6a623389320$export$f18627323ab57ac0(value === null || value === void 0 ? void 0 : value.end, minValue, maxValue, isDateUnavailable, options);
|
|
86
86
|
let result = (0, $68Tdx$reactstatelyform.mergeValidation)(startValidation, endValidation);
|
|
87
87
|
if (value.end != null && value.start != null && value.end.compare(value.start) < 0) {
|
|
88
|
-
let strings = (0, $68Tdx$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage(
|
|
88
|
+
let strings = (0, $68Tdx$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage('@react-stately/datepicker') || $50d5d6a623389320$var$dictionary;
|
|
89
89
|
result = (0, $68Tdx$reactstatelyform.mergeValidation)(result, {
|
|
90
90
|
isInvalid: true,
|
|
91
91
|
validationErrors: [
|
|
92
|
-
strings.getStringForLocale(
|
|
92
|
+
strings.getStringForLocale('rangeReversed', $50d5d6a623389320$var$getLocale())
|
|
93
93
|
],
|
|
94
94
|
validationDetails: {
|
|
95
95
|
...(0, $68Tdx$reactstatelyform.VALID_VALIDITY_STATE),
|
|
@@ -102,20 +102,20 @@ function $50d5d6a623389320$export$80ff8fc0ae339c13(value, minValue, maxValue, is
|
|
|
102
102
|
return result;
|
|
103
103
|
}
|
|
104
104
|
const $50d5d6a623389320$var$DEFAULT_FIELD_OPTIONS = {
|
|
105
|
-
year:
|
|
106
|
-
month:
|
|
107
|
-
day:
|
|
108
|
-
hour:
|
|
109
|
-
minute:
|
|
110
|
-
second:
|
|
105
|
+
year: 'numeric',
|
|
106
|
+
month: 'numeric',
|
|
107
|
+
day: 'numeric',
|
|
108
|
+
hour: 'numeric',
|
|
109
|
+
minute: '2-digit',
|
|
110
|
+
second: '2-digit'
|
|
111
111
|
};
|
|
112
112
|
const $50d5d6a623389320$var$TWO_DIGIT_FIELD_OPTIONS = {
|
|
113
|
-
year:
|
|
114
|
-
month:
|
|
115
|
-
day:
|
|
116
|
-
hour:
|
|
117
|
-
minute:
|
|
118
|
-
second:
|
|
113
|
+
year: 'numeric',
|
|
114
|
+
month: '2-digit',
|
|
115
|
+
day: '2-digit',
|
|
116
|
+
hour: '2-digit',
|
|
117
|
+
minute: '2-digit',
|
|
118
|
+
second: '2-digit'
|
|
119
119
|
};
|
|
120
120
|
function $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
121
121
|
let defaultFieldOptions = options.shouldForceLeadingZeros ? $50d5d6a623389320$var$TWO_DIGIT_FIELD_OPTIONS : $50d5d6a623389320$var$DEFAULT_FIELD_OPTIONS;
|
|
@@ -123,27 +123,27 @@ function $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
123
123
|
...defaultFieldOptions,
|
|
124
124
|
...fieldOptions
|
|
125
125
|
};
|
|
126
|
-
let granularity = options.granularity ||
|
|
126
|
+
let granularity = options.granularity || 'minute';
|
|
127
127
|
let keys = Object.keys(fieldOptions);
|
|
128
128
|
var _options_maxGranularity;
|
|
129
|
-
let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity :
|
|
129
|
+
let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity : 'year');
|
|
130
130
|
if (startIdx < 0) startIdx = 0;
|
|
131
131
|
let endIdx = keys.indexOf(granularity);
|
|
132
132
|
if (endIdx < 0) endIdx = 2;
|
|
133
|
-
if (startIdx > endIdx) throw new Error(
|
|
133
|
+
if (startIdx > endIdx) throw new Error('maxGranularity must be greater than granularity');
|
|
134
134
|
let opts = keys.slice(startIdx, endIdx + 1).reduce((opts, key)=>{
|
|
135
135
|
opts[key] = fieldOptions[key];
|
|
136
136
|
return opts;
|
|
137
137
|
}, {});
|
|
138
138
|
if (options.hourCycle != null) opts.hour12 = options.hourCycle === 12;
|
|
139
|
-
opts.timeZone = options.timeZone ||
|
|
140
|
-
let hasTime = granularity ===
|
|
141
|
-
if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName =
|
|
142
|
-
if (options.showEra && startIdx === 0) opts.era =
|
|
139
|
+
opts.timeZone = options.timeZone || 'UTC';
|
|
140
|
+
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
|
|
141
|
+
if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName = 'short';
|
|
142
|
+
if (options.showEra && startIdx === 0) opts.era = 'short';
|
|
143
143
|
return opts;
|
|
144
144
|
}
|
|
145
145
|
function $50d5d6a623389320$export$c5221a78ef73c5e9(placeholderValue) {
|
|
146
|
-
if (placeholderValue &&
|
|
146
|
+
if (placeholderValue && 'hour' in placeholderValue) return placeholderValue;
|
|
147
147
|
return new (0, $68Tdx$internationalizeddate.Time)();
|
|
148
148
|
}
|
|
149
149
|
function $50d5d6a623389320$export$61a490a80c552550(value, calendar) {
|
|
@@ -159,16 +159,16 @@ function $50d5d6a623389320$export$66aa2b09de4b1ea5(placeholderValue, granularity
|
|
|
159
159
|
second: 0,
|
|
160
160
|
millisecond: 0
|
|
161
161
|
}), calendar);
|
|
162
|
-
if (granularity ===
|
|
162
|
+
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return (0, $68Tdx$internationalizeddate.toCalendarDate)(date);
|
|
163
163
|
if (!timeZone) return (0, $68Tdx$internationalizeddate.toCalendarDateTime)(date);
|
|
164
164
|
return date;
|
|
165
165
|
}
|
|
166
166
|
function $50d5d6a623389320$export$2440da353cedad43(v, granularity) {
|
|
167
167
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
168
|
-
let defaultTimeZone = v &&
|
|
169
|
-
let defaultGranularity = v &&
|
|
168
|
+
let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
169
|
+
let defaultGranularity = v && 'minute' in v ? 'minute' : 'day';
|
|
170
170
|
// props.granularity must actually exist in the value if one is provided.
|
|
171
|
-
if (v && granularity && !(granularity in v)) throw new Error(
|
|
171
|
+
if (v && granularity && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
172
172
|
let [lastValue, setLastValue] = (0, $68Tdx$react.useState)([
|
|
173
173
|
defaultGranularity,
|
|
174
174
|
defaultTimeZone
|
package/dist/utils.mjs
CHANGED
|
@@ -28,7 +28,7 @@ function $35a22f14a1f04b11$var$getLocale() {
|
|
|
28
28
|
// Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided
|
|
29
29
|
// validation messages, which to not respect our provider's language.
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
return typeof navigator !==
|
|
31
|
+
return typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
32
32
|
}
|
|
33
33
|
function $35a22f14a1f04b11$export$f18627323ab57ac0(value, minValue, maxValue, isDateUnavailable, options) {
|
|
34
34
|
let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;
|
|
@@ -38,17 +38,17 @@ function $35a22f14a1f04b11$export$f18627323ab57ac0(value, minValue, maxValue, is
|
|
|
38
38
|
let errors = [];
|
|
39
39
|
if (isInvalid) {
|
|
40
40
|
let locale = $35a22f14a1f04b11$var$getLocale();
|
|
41
|
-
let strings = (0, $bUJMr$LocalizedStringDictionary).getGlobalDictionaryForPackage(
|
|
41
|
+
let strings = (0, $bUJMr$LocalizedStringDictionary).getGlobalDictionaryForPackage('@react-stately/datepicker') || $35a22f14a1f04b11$var$dictionary;
|
|
42
42
|
let formatter = new (0, $bUJMr$LocalizedStringFormatter)(locale, strings);
|
|
43
43
|
let dateFormatter = new (0, $bUJMr$DateFormatter)(locale, $35a22f14a1f04b11$export$7e319ea407e63bc0({}, options));
|
|
44
44
|
let timeZone = dateFormatter.resolvedOptions().timeZone;
|
|
45
|
-
if (rangeUnderflow) errors.push(formatter.format(
|
|
45
|
+
if (rangeUnderflow) errors.push(formatter.format('rangeUnderflow', {
|
|
46
46
|
minValue: dateFormatter.format(minValue.toDate(timeZone))
|
|
47
47
|
}));
|
|
48
|
-
if (rangeOverflow) errors.push(formatter.format(
|
|
48
|
+
if (rangeOverflow) errors.push(formatter.format('rangeOverflow', {
|
|
49
49
|
maxValue: dateFormatter.format(maxValue.toDate(timeZone))
|
|
50
50
|
}));
|
|
51
|
-
if (isUnavailable) errors.push(formatter.format(
|
|
51
|
+
if (isUnavailable) errors.push(formatter.format('unavailableDate'));
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
54
54
|
isInvalid: isInvalid,
|
|
@@ -73,11 +73,11 @@ function $35a22f14a1f04b11$export$80ff8fc0ae339c13(value, minValue, maxValue, is
|
|
|
73
73
|
let endValidation = $35a22f14a1f04b11$export$f18627323ab57ac0(value === null || value === void 0 ? void 0 : value.end, minValue, maxValue, isDateUnavailable, options);
|
|
74
74
|
let result = (0, $bUJMr$mergeValidation)(startValidation, endValidation);
|
|
75
75
|
if (value.end != null && value.start != null && value.end.compare(value.start) < 0) {
|
|
76
|
-
let strings = (0, $bUJMr$LocalizedStringDictionary).getGlobalDictionaryForPackage(
|
|
76
|
+
let strings = (0, $bUJMr$LocalizedStringDictionary).getGlobalDictionaryForPackage('@react-stately/datepicker') || $35a22f14a1f04b11$var$dictionary;
|
|
77
77
|
result = (0, $bUJMr$mergeValidation)(result, {
|
|
78
78
|
isInvalid: true,
|
|
79
79
|
validationErrors: [
|
|
80
|
-
strings.getStringForLocale(
|
|
80
|
+
strings.getStringForLocale('rangeReversed', $35a22f14a1f04b11$var$getLocale())
|
|
81
81
|
],
|
|
82
82
|
validationDetails: {
|
|
83
83
|
...(0, $bUJMr$VALID_VALIDITY_STATE),
|
|
@@ -90,20 +90,20 @@ function $35a22f14a1f04b11$export$80ff8fc0ae339c13(value, minValue, maxValue, is
|
|
|
90
90
|
return result;
|
|
91
91
|
}
|
|
92
92
|
const $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS = {
|
|
93
|
-
year:
|
|
94
|
-
month:
|
|
95
|
-
day:
|
|
96
|
-
hour:
|
|
97
|
-
minute:
|
|
98
|
-
second:
|
|
93
|
+
year: 'numeric',
|
|
94
|
+
month: 'numeric',
|
|
95
|
+
day: 'numeric',
|
|
96
|
+
hour: 'numeric',
|
|
97
|
+
minute: '2-digit',
|
|
98
|
+
second: '2-digit'
|
|
99
99
|
};
|
|
100
100
|
const $35a22f14a1f04b11$var$TWO_DIGIT_FIELD_OPTIONS = {
|
|
101
|
-
year:
|
|
102
|
-
month:
|
|
103
|
-
day:
|
|
104
|
-
hour:
|
|
105
|
-
minute:
|
|
106
|
-
second:
|
|
101
|
+
year: 'numeric',
|
|
102
|
+
month: '2-digit',
|
|
103
|
+
day: '2-digit',
|
|
104
|
+
hour: '2-digit',
|
|
105
|
+
minute: '2-digit',
|
|
106
|
+
second: '2-digit'
|
|
107
107
|
};
|
|
108
108
|
function $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
109
109
|
let defaultFieldOptions = options.shouldForceLeadingZeros ? $35a22f14a1f04b11$var$TWO_DIGIT_FIELD_OPTIONS : $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS;
|
|
@@ -111,27 +111,27 @@ function $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
111
111
|
...defaultFieldOptions,
|
|
112
112
|
...fieldOptions
|
|
113
113
|
};
|
|
114
|
-
let granularity = options.granularity ||
|
|
114
|
+
let granularity = options.granularity || 'minute';
|
|
115
115
|
let keys = Object.keys(fieldOptions);
|
|
116
116
|
var _options_maxGranularity;
|
|
117
|
-
let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity :
|
|
117
|
+
let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity : 'year');
|
|
118
118
|
if (startIdx < 0) startIdx = 0;
|
|
119
119
|
let endIdx = keys.indexOf(granularity);
|
|
120
120
|
if (endIdx < 0) endIdx = 2;
|
|
121
|
-
if (startIdx > endIdx) throw new Error(
|
|
121
|
+
if (startIdx > endIdx) throw new Error('maxGranularity must be greater than granularity');
|
|
122
122
|
let opts = keys.slice(startIdx, endIdx + 1).reduce((opts, key)=>{
|
|
123
123
|
opts[key] = fieldOptions[key];
|
|
124
124
|
return opts;
|
|
125
125
|
}, {});
|
|
126
126
|
if (options.hourCycle != null) opts.hour12 = options.hourCycle === 12;
|
|
127
|
-
opts.timeZone = options.timeZone ||
|
|
128
|
-
let hasTime = granularity ===
|
|
129
|
-
if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName =
|
|
130
|
-
if (options.showEra && startIdx === 0) opts.era =
|
|
127
|
+
opts.timeZone = options.timeZone || 'UTC';
|
|
128
|
+
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
|
|
129
|
+
if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName = 'short';
|
|
130
|
+
if (options.showEra && startIdx === 0) opts.era = 'short';
|
|
131
131
|
return opts;
|
|
132
132
|
}
|
|
133
133
|
function $35a22f14a1f04b11$export$c5221a78ef73c5e9(placeholderValue) {
|
|
134
|
-
if (placeholderValue &&
|
|
134
|
+
if (placeholderValue && 'hour' in placeholderValue) return placeholderValue;
|
|
135
135
|
return new (0, $bUJMr$Time)();
|
|
136
136
|
}
|
|
137
137
|
function $35a22f14a1f04b11$export$61a490a80c552550(value, calendar) {
|
|
@@ -147,16 +147,16 @@ function $35a22f14a1f04b11$export$66aa2b09de4b1ea5(placeholderValue, granularity
|
|
|
147
147
|
second: 0,
|
|
148
148
|
millisecond: 0
|
|
149
149
|
}), calendar);
|
|
150
|
-
if (granularity ===
|
|
150
|
+
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return (0, $bUJMr$toCalendarDate)(date);
|
|
151
151
|
if (!timeZone) return (0, $bUJMr$toCalendarDateTime)(date);
|
|
152
152
|
return date;
|
|
153
153
|
}
|
|
154
154
|
function $35a22f14a1f04b11$export$2440da353cedad43(v, granularity) {
|
|
155
155
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
156
|
-
let defaultTimeZone = v &&
|
|
157
|
-
let defaultGranularity = v &&
|
|
156
|
+
let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
157
|
+
let defaultGranularity = v && 'minute' in v ? 'minute' : 'day';
|
|
158
158
|
// props.granularity must actually exist in the value if one is provided.
|
|
159
|
-
if (v && granularity && !(granularity in v)) throw new Error(
|
|
159
|
+
if (v && granularity && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
160
160
|
let [lastValue, setLastValue] = (0, $bUJMr$useState)([
|
|
161
161
|
defaultGranularity,
|
|
162
162
|
defaultTimeZone
|
|
@@ -176,4 +176,4 @@ function $35a22f14a1f04b11$export$2440da353cedad43(v, granularity) {
|
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
export {$35a22f14a1f04b11$export$f18627323ab57ac0 as getValidationResult, $35a22f14a1f04b11$export$7e319ea407e63bc0 as getFormatOptions, $35a22f14a1f04b11$export$80ff8fc0ae339c13 as getRangeValidationResult, $35a22f14a1f04b11$export$c5221a78ef73c5e9 as getPlaceholderTime, $35a22f14a1f04b11$export$61a490a80c552550 as convertValue, $35a22f14a1f04b11$export$66aa2b09de4b1ea5 as createPlaceholderDate, $35a22f14a1f04b11$export$2440da353cedad43 as useDefaultProps};
|
|
179
|
-
//# sourceMappingURL=utils.
|
|
179
|
+
//# sourceMappingURL=utils.module.js.map
|