@react-stately/datepicker 3.1.0 → 3.2.1
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 -459
- package/dist/main.js.map +1 -1
- package/dist/module.js +503 -459
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/useDatePickerState.ts +2 -2
package/dist/main.js
CHANGED
|
@@ -12,75 +12,104 @@ $parcel$export(module.exports, "useDatePickerState", () => $aaab7a647e17e1fd$exp
|
|
|
12
12
|
$parcel$export(module.exports, "useDateFieldState", () => $596a1f0f523d6752$export$60e84778edff6d26);
|
|
13
13
|
$parcel$export(module.exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
14
14
|
$parcel$export(module.exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/*
|
|
16
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
17
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
+
* governing permissions and limitations under the License.
|
|
25
|
+
*/ /*
|
|
26
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
|
+
* governing permissions and limitations under the License.
|
|
35
|
+
*/
|
|
36
|
+
/*
|
|
37
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
38
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
39
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
40
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
41
|
+
*
|
|
42
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
43
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
44
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
45
|
+
* governing permissions and limitations under the License.
|
|
46
|
+
*/
|
|
17
47
|
|
|
18
48
|
function $50d5d6a623389320$export$eac50920cf2fd59a(value, minValue, maxValue) {
|
|
19
49
|
return value != null && (minValue != null && value.compare(minValue) < 0 || maxValue != null && value.compare(maxValue) > 0);
|
|
20
50
|
}
|
|
21
51
|
const $50d5d6a623389320$var$DEFAULT_FIELD_OPTIONS = {
|
|
22
|
-
year:
|
|
23
|
-
month:
|
|
24
|
-
day:
|
|
25
|
-
hour:
|
|
26
|
-
minute:
|
|
27
|
-
second:
|
|
52
|
+
year: "numeric",
|
|
53
|
+
month: "numeric",
|
|
54
|
+
day: "numeric",
|
|
55
|
+
hour: "numeric",
|
|
56
|
+
minute: "2-digit",
|
|
57
|
+
second: "2-digit"
|
|
28
58
|
};
|
|
29
59
|
function $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
30
60
|
fieldOptions = {
|
|
31
61
|
...$50d5d6a623389320$var$DEFAULT_FIELD_OPTIONS,
|
|
32
62
|
...fieldOptions
|
|
33
63
|
};
|
|
34
|
-
let granularity = options.granularity ||
|
|
64
|
+
let granularity = options.granularity || "minute";
|
|
35
65
|
let keys = Object.keys(fieldOptions);
|
|
36
|
-
var
|
|
37
|
-
let startIdx = keys.indexOf((
|
|
66
|
+
var _options_maxGranularity;
|
|
67
|
+
let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity : "year");
|
|
38
68
|
if (startIdx < 0) startIdx = 0;
|
|
39
69
|
let endIdx = keys.indexOf(granularity);
|
|
40
70
|
if (endIdx < 0) endIdx = 2;
|
|
41
|
-
if (startIdx > endIdx) throw new Error(
|
|
42
|
-
let
|
|
71
|
+
if (startIdx > endIdx) throw new Error("maxGranularity must be greater than granularity");
|
|
72
|
+
let opts = keys.slice(startIdx, endIdx + 1).reduce((opts, key)=>{
|
|
43
73
|
opts[key] = fieldOptions[key];
|
|
44
74
|
return opts;
|
|
45
|
-
}, {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
return opts1;
|
|
75
|
+
}, {});
|
|
76
|
+
if (options.hourCycle != null) opts.hour12 = options.hourCycle === 12;
|
|
77
|
+
opts.timeZone = options.timeZone || "UTC";
|
|
78
|
+
let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
|
|
79
|
+
if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName = "short";
|
|
80
|
+
if (options.showEra && startIdx === 0) opts.era = "short";
|
|
81
|
+
return opts;
|
|
53
82
|
}
|
|
54
83
|
function $50d5d6a623389320$export$c5221a78ef73c5e9(placeholderValue) {
|
|
55
|
-
if (placeholderValue &&
|
|
56
|
-
return new $h2qOe$internationalizeddate.Time();
|
|
84
|
+
if (placeholderValue && "hour" in placeholderValue) return placeholderValue;
|
|
85
|
+
return new (0, $h2qOe$internationalizeddate.Time)();
|
|
57
86
|
}
|
|
58
87
|
function $50d5d6a623389320$export$61a490a80c552550(value, calendar) {
|
|
59
88
|
if (value === null) return null;
|
|
60
89
|
if (!value) return undefined;
|
|
61
|
-
return $h2qOe$internationalizeddate.toCalendar(value, calendar);
|
|
90
|
+
return (0, $h2qOe$internationalizeddate.toCalendar)(value, calendar);
|
|
62
91
|
}
|
|
63
92
|
function $50d5d6a623389320$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
|
|
64
93
|
if (placeholderValue) return $50d5d6a623389320$export$61a490a80c552550(placeholderValue, calendar);
|
|
65
|
-
let date = $h2qOe$internationalizeddate.toCalendar($h2qOe$internationalizeddate.now(timeZone).set({
|
|
94
|
+
let date = (0, $h2qOe$internationalizeddate.toCalendar)((0, $h2qOe$internationalizeddate.now)(timeZone).set({
|
|
66
95
|
hour: 0,
|
|
67
96
|
minute: 0,
|
|
68
97
|
second: 0,
|
|
69
98
|
millisecond: 0
|
|
70
99
|
}), calendar);
|
|
71
|
-
if (granularity ===
|
|
72
|
-
if (!timeZone) return $h2qOe$internationalizeddate.toCalendarDateTime(date);
|
|
100
|
+
if (granularity === "year" || granularity === "month" || granularity === "day") return (0, $h2qOe$internationalizeddate.toCalendarDate)(date);
|
|
101
|
+
if (!timeZone) return (0, $h2qOe$internationalizeddate.toCalendarDateTime)(date);
|
|
73
102
|
return date;
|
|
74
103
|
}
|
|
75
104
|
function $50d5d6a623389320$export$2440da353cedad43(v, granularity) {
|
|
76
105
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
77
|
-
let lastValue = $h2qOe$react.useRef(v);
|
|
106
|
+
let lastValue = (0, $h2qOe$react.useRef)(v);
|
|
78
107
|
if (v) lastValue.current = v;
|
|
79
108
|
v = lastValue.current;
|
|
80
|
-
let defaultTimeZone = v &&
|
|
81
|
-
granularity = granularity || (v &&
|
|
109
|
+
let defaultTimeZone = v && "timeZone" in v ? v.timeZone : undefined;
|
|
110
|
+
granularity = granularity || (v && "minute" in v ? "minute" : "day");
|
|
82
111
|
// props.granularity must actually exist in the value if one is provided.
|
|
83
|
-
if (v && !(granularity in v)) throw new Error(
|
|
112
|
+
if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
|
|
84
113
|
return [
|
|
85
114
|
granularity,
|
|
86
115
|
defaultTimeZone
|
|
@@ -93,31 +122,31 @@ function $50d5d6a623389320$export$2440da353cedad43(v, granularity) {
|
|
|
93
122
|
|
|
94
123
|
|
|
95
124
|
function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
96
|
-
var
|
|
97
|
-
let overlayState = $h2qOe$reactstatelyoverlays.useOverlayTriggerState(props);
|
|
98
|
-
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
125
|
+
var _props_isDateUnavailable;
|
|
126
|
+
let overlayState = (0, $h2qOe$reactstatelyoverlays.useOverlayTriggerState)(props);
|
|
127
|
+
let [value, setValue] = (0, $h2qOe$reactstatelyutils.useControlledState)(props.value, props.defaultValue || null, props.onChange);
|
|
99
128
|
let v = value || props.placeholderValue;
|
|
100
|
-
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
101
|
-
let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone :
|
|
102
|
-
let hasTime = granularity ===
|
|
103
|
-
var
|
|
104
|
-
let shouldCloseOnSelect = (
|
|
105
|
-
let [selectedDate, setSelectedDate] = $h2qOe$react.useState(null);
|
|
106
|
-
let [selectedTime, setSelectedTime] = $h2qOe$react.useState(null);
|
|
129
|
+
let [granularity, defaultTimeZone] = (0, $50d5d6a623389320$export$2440da353cedad43)(v, props.granularity);
|
|
130
|
+
let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : "UTC") : null;
|
|
131
|
+
let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
|
|
132
|
+
var _props_shouldCloseOnSelect;
|
|
133
|
+
let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
|
|
134
|
+
let [selectedDate, setSelectedDate] = (0, $h2qOe$react.useState)(null);
|
|
135
|
+
let [selectedTime, setSelectedTime] = (0, $h2qOe$react.useState)(null);
|
|
107
136
|
if (value) {
|
|
108
137
|
selectedDate = value;
|
|
109
|
-
if (
|
|
138
|
+
if ("hour" in value) selectedTime = value;
|
|
110
139
|
}
|
|
111
140
|
// props.granularity must actually exist in the value if one is provided.
|
|
112
|
-
if (v && !(granularity in v)) throw new Error(
|
|
141
|
+
if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
|
|
113
142
|
let commitValue = (date, time)=>{
|
|
114
|
-
setValue(
|
|
143
|
+
setValue("timeZone" in time ? time.set((0, $h2qOe$internationalizeddate.toCalendarDate)(date)) : (0, $h2qOe$internationalizeddate.toCalendarDateTime)(date, time));
|
|
115
144
|
};
|
|
116
145
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
117
146
|
let selectDate = (newValue)=>{
|
|
118
|
-
let shouldClose = typeof shouldCloseOnSelect ===
|
|
147
|
+
let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
|
|
119
148
|
if (hasTime) {
|
|
120
|
-
if (selectedTime || shouldClose) commitValue(newValue, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
149
|
+
if (selectedTime || shouldClose) commitValue(newValue, selectedTime || (0, $50d5d6a623389320$export$c5221a78ef73c5e9)(props.placeholderValue));
|
|
121
150
|
else setSelectedDate(newValue);
|
|
122
151
|
} else setValue(newValue);
|
|
123
152
|
if (shouldClose) overlayState.setOpen(false);
|
|
@@ -126,7 +155,7 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
126
155
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
127
156
|
else setSelectedTime(newValue);
|
|
128
157
|
};
|
|
129
|
-
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(value, props.minValue, props.maxValue) ?
|
|
158
|
+
let validationState = props.validationState || ((0, $50d5d6a623389320$export$eac50920cf2fd59a)(value, props.minValue, props.maxValue) ? "invalid" : null) || (value && ((_props_isDateUnavailable = props.isDateUnavailable) === null || _props_isDateUnavailable === void 0 ? void 0 : _props_isDateUnavailable.call(props, value)) ? "invalid" : null);
|
|
130
159
|
return {
|
|
131
160
|
value: value,
|
|
132
161
|
setValue: setValue,
|
|
@@ -141,415 +170,435 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
141
170
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
142
171
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
143
172
|
// the user opens the popover again.
|
|
144
|
-
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
173
|
+
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || (0, $50d5d6a623389320$export$c5221a78ef73c5e9)(props.placeholderValue));
|
|
145
174
|
overlayState.setOpen(isOpen);
|
|
146
175
|
},
|
|
147
176
|
validationState: validationState,
|
|
148
177
|
formatValue (locale, fieldOptions) {
|
|
149
|
-
if (!dateValue) return
|
|
150
|
-
let formatOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
178
|
+
if (!dateValue) return "";
|
|
179
|
+
let formatOptions = (0, $50d5d6a623389320$export$7e319ea407e63bc0)(fieldOptions, {
|
|
151
180
|
granularity: granularity,
|
|
152
181
|
timeZone: defaultTimeZone,
|
|
153
182
|
hideTimeZone: props.hideTimeZone,
|
|
154
183
|
hourCycle: props.hourCycle,
|
|
155
|
-
showEra: value.calendar.identifier ===
|
|
184
|
+
showEra: value.calendar.identifier === "gregory" && value.era === "BC"
|
|
156
185
|
});
|
|
157
|
-
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
186
|
+
let formatter = new (0, $h2qOe$internationalizeddate.DateFormatter)(locale, formatOptions);
|
|
158
187
|
return formatter.format(dateValue);
|
|
159
188
|
}
|
|
160
189
|
};
|
|
161
190
|
}
|
|
162
191
|
|
|
163
192
|
|
|
193
|
+
/*
|
|
194
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
195
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
196
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
197
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
*
|
|
199
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
200
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
201
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
202
|
+
* governing permissions and limitations under the License.
|
|
203
|
+
*/
|
|
164
204
|
|
|
165
|
-
|
|
166
|
-
|
|
205
|
+
/*
|
|
206
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
207
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
208
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
209
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
210
|
+
*
|
|
211
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
212
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
213
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
214
|
+
* governing permissions and limitations under the License.
|
|
215
|
+
*/
|
|
167
216
|
// These placeholders are based on the strings used by the <input type="date">
|
|
168
217
|
// implementations in Chrome and Firefox. Additional languages are supported
|
|
169
218
|
// here than React Spectrum's typical translations.
|
|
170
|
-
const $e1e8ada727fae1a1$var$placeholders = new $h2qOe$internationalizedstring.LocalizedStringDictionary({
|
|
219
|
+
const $e1e8ada727fae1a1$var$placeholders = new (0, $h2qOe$internationalizedstring.LocalizedStringDictionary)({
|
|
171
220
|
ach: {
|
|
172
|
-
year:
|
|
173
|
-
month:
|
|
174
|
-
day:
|
|
221
|
+
year: "mwaka",
|
|
222
|
+
month: "dwe",
|
|
223
|
+
day: "nino"
|
|
175
224
|
},
|
|
176
225
|
af: {
|
|
177
|
-
year:
|
|
178
|
-
month:
|
|
179
|
-
day:
|
|
226
|
+
year: "jjjj",
|
|
227
|
+
month: "mm",
|
|
228
|
+
day: "dd"
|
|
180
229
|
},
|
|
181
230
|
am: {
|
|
182
|
-
year:
|
|
183
|
-
month:
|
|
184
|
-
day:
|
|
231
|
+
year: "ዓዓዓዓ",
|
|
232
|
+
month: "ሚሜ",
|
|
233
|
+
day: "ቀቀ"
|
|
185
234
|
},
|
|
186
235
|
an: {
|
|
187
|
-
year:
|
|
188
|
-
month:
|
|
189
|
-
day:
|
|
236
|
+
year: "aaaa",
|
|
237
|
+
month: "mm",
|
|
238
|
+
day: "dd"
|
|
190
239
|
},
|
|
191
240
|
ar: {
|
|
192
|
-
year:
|
|
193
|
-
month:
|
|
194
|
-
day:
|
|
241
|
+
year: "سنة",
|
|
242
|
+
month: "شهر",
|
|
243
|
+
day: "يوم"
|
|
195
244
|
},
|
|
196
245
|
ast: {
|
|
197
|
-
year:
|
|
198
|
-
month:
|
|
199
|
-
day:
|
|
246
|
+
year: "aaaa",
|
|
247
|
+
month: "mm",
|
|
248
|
+
day: "dd"
|
|
200
249
|
},
|
|
201
250
|
az: {
|
|
202
|
-
year:
|
|
203
|
-
month:
|
|
204
|
-
day:
|
|
251
|
+
year: "iiii",
|
|
252
|
+
month: "aa",
|
|
253
|
+
day: "gg"
|
|
205
254
|
},
|
|
206
255
|
be: {
|
|
207
|
-
year:
|
|
208
|
-
month:
|
|
209
|
-
day:
|
|
256
|
+
year: "гггг",
|
|
257
|
+
month: "мм",
|
|
258
|
+
day: "дд"
|
|
210
259
|
},
|
|
211
260
|
bg: {
|
|
212
|
-
year:
|
|
213
|
-
month:
|
|
214
|
-
day:
|
|
261
|
+
year: "гггг",
|
|
262
|
+
month: "мм",
|
|
263
|
+
day: "дд"
|
|
215
264
|
},
|
|
216
265
|
bn: {
|
|
217
|
-
year:
|
|
218
|
-
month:
|
|
219
|
-
day:
|
|
266
|
+
year: "yyyy",
|
|
267
|
+
month: "মিমি",
|
|
268
|
+
day: "dd"
|
|
220
269
|
},
|
|
221
270
|
br: {
|
|
222
|
-
year:
|
|
223
|
-
month:
|
|
224
|
-
day:
|
|
271
|
+
year: "bbbb",
|
|
272
|
+
month: "mm",
|
|
273
|
+
day: "dd"
|
|
225
274
|
},
|
|
226
275
|
bs: {
|
|
227
|
-
year:
|
|
228
|
-
month:
|
|
229
|
-
day:
|
|
276
|
+
year: "gggg",
|
|
277
|
+
month: "mm",
|
|
278
|
+
day: "dd"
|
|
230
279
|
},
|
|
231
280
|
ca: {
|
|
232
|
-
year:
|
|
233
|
-
month:
|
|
234
|
-
day:
|
|
281
|
+
year: "aaaa",
|
|
282
|
+
month: "mm",
|
|
283
|
+
day: "dd"
|
|
235
284
|
},
|
|
236
285
|
cak: {
|
|
237
|
-
year:
|
|
238
|
-
month:
|
|
286
|
+
year: "jjjj",
|
|
287
|
+
month: "ii",
|
|
239
288
|
day: "q'q'"
|
|
240
289
|
},
|
|
241
290
|
ckb: {
|
|
242
|
-
year:
|
|
243
|
-
month:
|
|
244
|
-
day:
|
|
291
|
+
year: "ساڵ",
|
|
292
|
+
month: "مانگ",
|
|
293
|
+
day: "ڕۆژ"
|
|
245
294
|
},
|
|
246
295
|
cs: {
|
|
247
|
-
year:
|
|
248
|
-
month:
|
|
249
|
-
day:
|
|
296
|
+
year: "rrrr",
|
|
297
|
+
month: "mm",
|
|
298
|
+
day: "dd"
|
|
250
299
|
},
|
|
251
300
|
cy: {
|
|
252
|
-
year:
|
|
253
|
-
month:
|
|
254
|
-
day:
|
|
301
|
+
year: "bbbb",
|
|
302
|
+
month: "mm",
|
|
303
|
+
day: "dd"
|
|
255
304
|
},
|
|
256
305
|
da: {
|
|
257
|
-
year:
|
|
258
|
-
month:
|
|
259
|
-
day:
|
|
306
|
+
year: "\xe5\xe5\xe5\xe5",
|
|
307
|
+
month: "mm",
|
|
308
|
+
day: "dd"
|
|
260
309
|
},
|
|
261
310
|
de: {
|
|
262
|
-
year:
|
|
263
|
-
month:
|
|
264
|
-
day:
|
|
311
|
+
year: "jjjj",
|
|
312
|
+
month: "mm",
|
|
313
|
+
day: "tt"
|
|
265
314
|
},
|
|
266
315
|
dsb: {
|
|
267
|
-
year:
|
|
268
|
-
month:
|
|
269
|
-
day:
|
|
316
|
+
year: "llll",
|
|
317
|
+
month: "mm",
|
|
318
|
+
day: "źź"
|
|
270
319
|
},
|
|
271
320
|
el: {
|
|
272
|
-
year:
|
|
273
|
-
month:
|
|
274
|
-
day:
|
|
321
|
+
year: "εεεε",
|
|
322
|
+
month: "μμ",
|
|
323
|
+
day: "ηη"
|
|
275
324
|
},
|
|
276
325
|
en: {
|
|
277
|
-
year:
|
|
278
|
-
month:
|
|
279
|
-
day:
|
|
326
|
+
year: "yyyy",
|
|
327
|
+
month: "mm",
|
|
328
|
+
day: "dd"
|
|
280
329
|
},
|
|
281
330
|
eo: {
|
|
282
|
-
year:
|
|
283
|
-
month:
|
|
284
|
-
day:
|
|
331
|
+
year: "jjjj",
|
|
332
|
+
month: "mm",
|
|
333
|
+
day: "tt"
|
|
285
334
|
},
|
|
286
335
|
es: {
|
|
287
|
-
year:
|
|
288
|
-
month:
|
|
289
|
-
day:
|
|
336
|
+
year: "aaaa",
|
|
337
|
+
month: "mm",
|
|
338
|
+
day: "dd"
|
|
290
339
|
},
|
|
291
340
|
et: {
|
|
292
|
-
year:
|
|
293
|
-
month:
|
|
294
|
-
day:
|
|
341
|
+
year: "aaaa",
|
|
342
|
+
month: "kk",
|
|
343
|
+
day: "pp"
|
|
295
344
|
},
|
|
296
345
|
eu: {
|
|
297
|
-
year:
|
|
298
|
-
month:
|
|
299
|
-
day:
|
|
346
|
+
year: "uuuu",
|
|
347
|
+
month: "hh",
|
|
348
|
+
day: "ee"
|
|
300
349
|
},
|
|
301
350
|
fa: {
|
|
302
|
-
year:
|
|
303
|
-
month:
|
|
304
|
-
day:
|
|
351
|
+
year: "سال",
|
|
352
|
+
month: "ماه",
|
|
353
|
+
day: "روز"
|
|
305
354
|
},
|
|
306
355
|
ff: {
|
|
307
|
-
year:
|
|
308
|
-
month:
|
|
309
|
-
day:
|
|
356
|
+
year: "hhhh",
|
|
357
|
+
month: "ll",
|
|
358
|
+
day: "\xf1\xf1"
|
|
310
359
|
},
|
|
311
360
|
fi: {
|
|
312
|
-
year:
|
|
313
|
-
month:
|
|
314
|
-
day:
|
|
361
|
+
year: "vvvv",
|
|
362
|
+
month: "kk",
|
|
363
|
+
day: "pp"
|
|
315
364
|
},
|
|
316
365
|
fr: {
|
|
317
|
-
year:
|
|
318
|
-
month:
|
|
319
|
-
day:
|
|
366
|
+
year: "aaaa",
|
|
367
|
+
month: "mm",
|
|
368
|
+
day: "jj"
|
|
320
369
|
},
|
|
321
370
|
fy: {
|
|
322
|
-
year:
|
|
323
|
-
month:
|
|
324
|
-
day:
|
|
371
|
+
year: "jjjj",
|
|
372
|
+
month: "mm",
|
|
373
|
+
day: "dd"
|
|
325
374
|
},
|
|
326
375
|
ga: {
|
|
327
|
-
year:
|
|
328
|
-
month:
|
|
329
|
-
day:
|
|
376
|
+
year: "bbbb",
|
|
377
|
+
month: "mm",
|
|
378
|
+
day: "ll"
|
|
330
379
|
},
|
|
331
380
|
gd: {
|
|
332
|
-
year:
|
|
333
|
-
month:
|
|
334
|
-
day:
|
|
381
|
+
year: "bbbb",
|
|
382
|
+
month: "mm",
|
|
383
|
+
day: "ll"
|
|
335
384
|
},
|
|
336
385
|
gl: {
|
|
337
|
-
year:
|
|
338
|
-
month:
|
|
339
|
-
day:
|
|
386
|
+
year: "aaaa",
|
|
387
|
+
month: "mm",
|
|
388
|
+
day: "dd"
|
|
340
389
|
},
|
|
341
390
|
he: {
|
|
342
|
-
year:
|
|
343
|
-
month:
|
|
344
|
-
day:
|
|
391
|
+
year: "שנה",
|
|
392
|
+
month: "חודש",
|
|
393
|
+
day: "יום"
|
|
345
394
|
},
|
|
346
395
|
hr: {
|
|
347
|
-
year:
|
|
348
|
-
month:
|
|
349
|
-
day:
|
|
396
|
+
year: "gggg",
|
|
397
|
+
month: "mm",
|
|
398
|
+
day: "dd"
|
|
350
399
|
},
|
|
351
400
|
hsb: {
|
|
352
|
-
year:
|
|
353
|
-
month:
|
|
354
|
-
day:
|
|
401
|
+
year: "llll",
|
|
402
|
+
month: "mm",
|
|
403
|
+
day: "dd"
|
|
355
404
|
},
|
|
356
405
|
hu: {
|
|
357
|
-
year:
|
|
358
|
-
month:
|
|
359
|
-
day:
|
|
406
|
+
year: "\xe9\xe9\xe9\xe9",
|
|
407
|
+
month: "hh",
|
|
408
|
+
day: "nn"
|
|
360
409
|
},
|
|
361
410
|
ia: {
|
|
362
|
-
year:
|
|
363
|
-
month:
|
|
364
|
-
day:
|
|
411
|
+
year: "aaaa",
|
|
412
|
+
month: "mm",
|
|
413
|
+
day: "dd"
|
|
365
414
|
},
|
|
366
415
|
id: {
|
|
367
|
-
year:
|
|
368
|
-
month:
|
|
369
|
-
day:
|
|
416
|
+
year: "tttt",
|
|
417
|
+
month: "bb",
|
|
418
|
+
day: "hh"
|
|
370
419
|
},
|
|
371
420
|
it: {
|
|
372
|
-
year:
|
|
373
|
-
month:
|
|
374
|
-
day:
|
|
421
|
+
year: "aaaa",
|
|
422
|
+
month: "mm",
|
|
423
|
+
day: "gg"
|
|
375
424
|
},
|
|
376
425
|
ja: {
|
|
377
|
-
year:
|
|
378
|
-
month:
|
|
379
|
-
day:
|
|
426
|
+
year: " 年 ",
|
|
427
|
+
month: "月",
|
|
428
|
+
day: "日"
|
|
380
429
|
},
|
|
381
430
|
ka: {
|
|
382
|
-
year:
|
|
383
|
-
month:
|
|
384
|
-
day:
|
|
431
|
+
year: "წწწწ",
|
|
432
|
+
month: "თთ",
|
|
433
|
+
day: "რრ"
|
|
385
434
|
},
|
|
386
435
|
kk: {
|
|
387
|
-
year:
|
|
388
|
-
month:
|
|
389
|
-
day:
|
|
436
|
+
year: "жжжж",
|
|
437
|
+
month: "аа",
|
|
438
|
+
day: "кк"
|
|
390
439
|
},
|
|
391
440
|
kn: {
|
|
392
|
-
year:
|
|
393
|
-
month:
|
|
394
|
-
day:
|
|
441
|
+
year: "ವವವವ",
|
|
442
|
+
month: "ಮಿಮೀ",
|
|
443
|
+
day: "ದಿದಿ"
|
|
395
444
|
},
|
|
396
445
|
ko: {
|
|
397
|
-
year:
|
|
398
|
-
month:
|
|
399
|
-
day:
|
|
446
|
+
year: "연도",
|
|
447
|
+
month: "월",
|
|
448
|
+
day: "일"
|
|
400
449
|
},
|
|
401
450
|
lb: {
|
|
402
|
-
year:
|
|
403
|
-
month:
|
|
404
|
-
day:
|
|
451
|
+
year: "jjjj",
|
|
452
|
+
month: "mm",
|
|
453
|
+
day: "dd"
|
|
405
454
|
},
|
|
406
455
|
lo: {
|
|
407
|
-
year:
|
|
408
|
-
month:
|
|
409
|
-
day:
|
|
456
|
+
year: "ປປປປ",
|
|
457
|
+
month: "ດດ",
|
|
458
|
+
day: "ວວ"
|
|
410
459
|
},
|
|
411
460
|
lt: {
|
|
412
|
-
year:
|
|
413
|
-
month:
|
|
414
|
-
day:
|
|
461
|
+
year: "mmmm",
|
|
462
|
+
month: "mm",
|
|
463
|
+
day: "dd"
|
|
415
464
|
},
|
|
416
465
|
lv: {
|
|
417
|
-
year:
|
|
418
|
-
month:
|
|
419
|
-
day:
|
|
466
|
+
year: "gggg",
|
|
467
|
+
month: "mm",
|
|
468
|
+
day: "dd"
|
|
420
469
|
},
|
|
421
470
|
meh: {
|
|
422
|
-
year:
|
|
423
|
-
month:
|
|
424
|
-
day:
|
|
471
|
+
year: "aaaa",
|
|
472
|
+
month: "mm",
|
|
473
|
+
day: "dd"
|
|
425
474
|
},
|
|
426
475
|
ml: {
|
|
427
|
-
year:
|
|
428
|
-
month:
|
|
429
|
-
day:
|
|
476
|
+
year: "വർഷം",
|
|
477
|
+
month: "മാസം",
|
|
478
|
+
day: "തീയതി"
|
|
430
479
|
},
|
|
431
480
|
ms: {
|
|
432
|
-
year:
|
|
433
|
-
month:
|
|
434
|
-
day:
|
|
481
|
+
year: "tttt",
|
|
482
|
+
month: "mm",
|
|
483
|
+
day: "hh"
|
|
435
484
|
},
|
|
436
485
|
nl: {
|
|
437
|
-
year:
|
|
438
|
-
month:
|
|
439
|
-
day:
|
|
486
|
+
year: "jjjj",
|
|
487
|
+
month: "mm",
|
|
488
|
+
day: "dd"
|
|
440
489
|
},
|
|
441
490
|
nn: {
|
|
442
|
-
year:
|
|
443
|
-
month:
|
|
444
|
-
day:
|
|
491
|
+
year: "\xe5\xe5\xe5\xe5",
|
|
492
|
+
month: "mm",
|
|
493
|
+
day: "dd"
|
|
445
494
|
},
|
|
446
495
|
no: {
|
|
447
|
-
year:
|
|
448
|
-
month:
|
|
449
|
-
day:
|
|
496
|
+
year: "\xe5\xe5\xe5\xe5",
|
|
497
|
+
month: "mm",
|
|
498
|
+
day: "dd"
|
|
450
499
|
},
|
|
451
500
|
oc: {
|
|
452
|
-
year:
|
|
453
|
-
month:
|
|
454
|
-
day:
|
|
501
|
+
year: "aaaa",
|
|
502
|
+
month: "mm",
|
|
503
|
+
day: "jj"
|
|
455
504
|
},
|
|
456
505
|
pl: {
|
|
457
|
-
year:
|
|
458
|
-
month:
|
|
459
|
-
day:
|
|
506
|
+
year: "rrrr",
|
|
507
|
+
month: "mm",
|
|
508
|
+
day: "dd"
|
|
460
509
|
},
|
|
461
510
|
pt: {
|
|
462
|
-
year:
|
|
463
|
-
month:
|
|
464
|
-
day:
|
|
511
|
+
year: "aaaa",
|
|
512
|
+
month: "mm",
|
|
513
|
+
day: "dd"
|
|
465
514
|
},
|
|
466
515
|
rm: {
|
|
467
|
-
year:
|
|
468
|
-
month:
|
|
469
|
-
day:
|
|
516
|
+
year: "oooo",
|
|
517
|
+
month: "mm",
|
|
518
|
+
day: "dd"
|
|
470
519
|
},
|
|
471
520
|
ro: {
|
|
472
|
-
year:
|
|
473
|
-
month:
|
|
474
|
-
day:
|
|
521
|
+
year: "aaaa",
|
|
522
|
+
month: "ll",
|
|
523
|
+
day: "zz"
|
|
475
524
|
},
|
|
476
525
|
ru: {
|
|
477
|
-
year:
|
|
478
|
-
month:
|
|
479
|
-
day:
|
|
526
|
+
year: "гггг",
|
|
527
|
+
month: "мм",
|
|
528
|
+
day: "дд"
|
|
480
529
|
},
|
|
481
530
|
sc: {
|
|
482
|
-
year:
|
|
483
|
-
month:
|
|
484
|
-
day:
|
|
531
|
+
year: "aaaa",
|
|
532
|
+
month: "mm",
|
|
533
|
+
day: "dd"
|
|
485
534
|
},
|
|
486
535
|
scn: {
|
|
487
|
-
year:
|
|
488
|
-
month:
|
|
489
|
-
day:
|
|
536
|
+
year: "aaaa",
|
|
537
|
+
month: "mm",
|
|
538
|
+
day: "jj"
|
|
490
539
|
},
|
|
491
540
|
sk: {
|
|
492
|
-
year:
|
|
493
|
-
month:
|
|
494
|
-
day:
|
|
541
|
+
year: "rrrr",
|
|
542
|
+
month: "mm",
|
|
543
|
+
day: "dd"
|
|
495
544
|
},
|
|
496
545
|
sl: {
|
|
497
|
-
year:
|
|
498
|
-
month:
|
|
499
|
-
day:
|
|
546
|
+
year: "llll",
|
|
547
|
+
month: "mm",
|
|
548
|
+
day: "dd"
|
|
500
549
|
},
|
|
501
550
|
sr: {
|
|
502
|
-
year:
|
|
503
|
-
month:
|
|
504
|
-
day:
|
|
551
|
+
year: "гггг",
|
|
552
|
+
month: "мм",
|
|
553
|
+
day: "дд"
|
|
505
554
|
},
|
|
506
555
|
sv: {
|
|
507
|
-
year:
|
|
508
|
-
month:
|
|
509
|
-
day:
|
|
556
|
+
year: "\xe5\xe5\xe5\xe5",
|
|
557
|
+
month: "mm",
|
|
558
|
+
day: "dd"
|
|
510
559
|
},
|
|
511
560
|
szl: {
|
|
512
|
-
year:
|
|
513
|
-
month:
|
|
514
|
-
day:
|
|
561
|
+
year: "rrrr",
|
|
562
|
+
month: "mm",
|
|
563
|
+
day: "dd"
|
|
515
564
|
},
|
|
516
565
|
tg: {
|
|
517
|
-
year:
|
|
518
|
-
month:
|
|
519
|
-
day:
|
|
566
|
+
year: "сссс",
|
|
567
|
+
month: "мм",
|
|
568
|
+
day: "рр"
|
|
520
569
|
},
|
|
521
570
|
th: {
|
|
522
|
-
year:
|
|
523
|
-
month:
|
|
524
|
-
day:
|
|
571
|
+
year: "ปปปป",
|
|
572
|
+
month: "ดด",
|
|
573
|
+
day: "วว"
|
|
525
574
|
},
|
|
526
575
|
tr: {
|
|
527
|
-
year:
|
|
528
|
-
month:
|
|
529
|
-
day:
|
|
576
|
+
year: "yyyy",
|
|
577
|
+
month: "aa",
|
|
578
|
+
day: "gg"
|
|
530
579
|
},
|
|
531
580
|
uk: {
|
|
532
|
-
year:
|
|
533
|
-
month:
|
|
534
|
-
day:
|
|
535
|
-
},
|
|
536
|
-
|
|
537
|
-
year:
|
|
538
|
-
month:
|
|
539
|
-
day:
|
|
540
|
-
},
|
|
541
|
-
|
|
542
|
-
year:
|
|
543
|
-
month:
|
|
544
|
-
day:
|
|
581
|
+
year: "рррр",
|
|
582
|
+
month: "мм",
|
|
583
|
+
day: "дд"
|
|
584
|
+
},
|
|
585
|
+
"zh-CN": {
|
|
586
|
+
year: "年",
|
|
587
|
+
month: "月",
|
|
588
|
+
day: "日"
|
|
589
|
+
},
|
|
590
|
+
"zh-TW": {
|
|
591
|
+
year: "年",
|
|
592
|
+
month: "月",
|
|
593
|
+
day: "日"
|
|
545
594
|
}
|
|
546
|
-
},
|
|
595
|
+
}, "en");
|
|
547
596
|
function $e1e8ada727fae1a1$export$d3f5c5e0a5023fa0(field, value, locale) {
|
|
548
597
|
// Use the actual placeholder value for the era and day period fields.
|
|
549
|
-
if (field ===
|
|
550
|
-
if (field ===
|
|
598
|
+
if (field === "era" || field === "dayPeriod") return value;
|
|
599
|
+
if (field === "year" || field === "month" || field === "day") return $e1e8ada727fae1a1$var$placeholders.getStringForLocale(field, locale);
|
|
551
600
|
// For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.
|
|
552
|
-
return
|
|
601
|
+
return "––";
|
|
553
602
|
}
|
|
554
603
|
|
|
555
604
|
|
|
@@ -575,48 +624,43 @@ const $596a1f0f523d6752$var$PAGE_STEP = {
|
|
|
575
624
|
};
|
|
576
625
|
// Node seems to convert everything to lowercase...
|
|
577
626
|
const $596a1f0f523d6752$var$TYPE_MAPPING = {
|
|
578
|
-
dayperiod:
|
|
627
|
+
dayperiod: "dayPeriod"
|
|
579
628
|
};
|
|
580
629
|
function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
581
630
|
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone , isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired } = props;
|
|
582
|
-
let
|
|
583
|
-
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(
|
|
584
|
-
let timeZone = defaultTimeZone ||
|
|
631
|
+
let v = props.value || props.defaultValue || props.placeholderValue;
|
|
632
|
+
let [granularity, defaultTimeZone] = (0, $50d5d6a623389320$export$2440da353cedad43)(v, props.granularity);
|
|
633
|
+
let timeZone = defaultTimeZone || "UTC";
|
|
585
634
|
// props.granularity must actually exist in the value if one is provided.
|
|
586
|
-
if (
|
|
587
|
-
let defaultFormatter = $h2qOe$react.useMemo(()=>new $h2qOe$internationalizeddate.DateFormatter(locale)
|
|
588
|
-
, [
|
|
635
|
+
if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
|
|
636
|
+
let defaultFormatter = (0, $h2qOe$react.useMemo)(()=>new (0, $h2qOe$internationalizeddate.DateFormatter)(locale), [
|
|
589
637
|
locale
|
|
590
638
|
]);
|
|
591
|
-
let calendar = $h2qOe$react.useMemo(()=>createCalendar(defaultFormatter.resolvedOptions().calendar)
|
|
592
|
-
, [
|
|
639
|
+
let calendar = (0, $h2qOe$react.useMemo)(()=>createCalendar(defaultFormatter.resolvedOptions().calendar), [
|
|
593
640
|
createCalendar,
|
|
594
641
|
defaultFormatter
|
|
595
642
|
]);
|
|
596
|
-
let [
|
|
597
|
-
let calendarValue = $h2qOe$react.useMemo(()
|
|
598
|
-
|
|
599
|
-
value1,
|
|
643
|
+
let [value, setDate] = (0, $h2qOe$reactstatelyutils.useControlledState)(props.value, props.defaultValue, props.onChange);
|
|
644
|
+
let calendarValue = (0, $h2qOe$react.useMemo)(()=>(0, $50d5d6a623389320$export$61a490a80c552550)(value, calendar), [
|
|
645
|
+
value,
|
|
600
646
|
calendar
|
|
601
647
|
]);
|
|
602
648
|
// We keep track of the placeholder date separately in state so that onChange is not called
|
|
603
649
|
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
604
650
|
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
605
651
|
// change from uncontrolled to controlled and emit a warning.
|
|
606
|
-
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()
|
|
607
|
-
);
|
|
652
|
+
let [placeholderDate, setPlaceholderDate] = (0, $h2qOe$react.useState)(()=>(0, $50d5d6a623389320$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
608
653
|
let val = calendarValue || placeholderDate;
|
|
609
|
-
let showEra = calendar.identifier ===
|
|
610
|
-
var
|
|
611
|
-
let formatOpts = $h2qOe$react.useMemo(()=>({
|
|
654
|
+
let showEra = calendar.identifier === "gregory" && val.era === "BC";
|
|
655
|
+
var _props_maxGranularity;
|
|
656
|
+
let formatOpts = (0, $h2qOe$react.useMemo)(()=>({
|
|
612
657
|
granularity: granularity,
|
|
613
|
-
maxGranularity: (
|
|
658
|
+
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : "year",
|
|
614
659
|
timeZone: defaultTimeZone,
|
|
615
660
|
hideTimeZone: hideTimeZone,
|
|
616
661
|
hourCycle: props.hourCycle,
|
|
617
662
|
showEra: showEra
|
|
618
|
-
})
|
|
619
|
-
, [
|
|
663
|
+
}), [
|
|
620
664
|
props.maxGranularity,
|
|
621
665
|
granularity,
|
|
622
666
|
props.hourCycle,
|
|
@@ -624,41 +668,30 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
624
668
|
hideTimeZone,
|
|
625
669
|
showEra
|
|
626
670
|
]);
|
|
627
|
-
let opts = $h2qOe$react.useMemo(()
|
|
628
|
-
}, formatOpts)
|
|
629
|
-
, [
|
|
671
|
+
let opts = (0, $h2qOe$react.useMemo)(()=>(0, $50d5d6a623389320$export$7e319ea407e63bc0)({}, formatOpts), [
|
|
630
672
|
formatOpts
|
|
631
673
|
]);
|
|
632
|
-
let dateFormatter = $h2qOe$react.useMemo(()=>new $h2qOe$internationalizeddate.DateFormatter(locale, opts)
|
|
633
|
-
, [
|
|
674
|
+
let dateFormatter = (0, $h2qOe$react.useMemo)(()=>new (0, $h2qOe$internationalizeddate.DateFormatter)(locale, opts), [
|
|
634
675
|
locale,
|
|
635
676
|
opts
|
|
636
677
|
]);
|
|
637
|
-
let resolvedOptions = $h2qOe$react.useMemo(()=>dateFormatter.resolvedOptions()
|
|
638
|
-
, [
|
|
678
|
+
let resolvedOptions = (0, $h2qOe$react.useMemo)(()=>dateFormatter.resolvedOptions(), [
|
|
639
679
|
dateFormatter
|
|
640
680
|
]);
|
|
641
681
|
// Determine how many editable segments there are for validation purposes.
|
|
642
682
|
// The result is cached for performance.
|
|
643
|
-
let allSegments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]
|
|
644
|
-
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
645
|
-
, {
|
|
646
|
-
})
|
|
647
|
-
, [
|
|
683
|
+
let allSegments = (0, $h2qOe$react.useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[seg.type] = true, p), {}), [
|
|
648
684
|
dateFormatter
|
|
649
685
|
]);
|
|
650
|
-
let [validSegments, setValidSegments] = $h2qOe$react.useState(()=>props.value || props.defaultValue ? {
|
|
686
|
+
let [validSegments, setValidSegments] = (0, $h2qOe$react.useState)(()=>props.value || props.defaultValue ? {
|
|
651
687
|
...allSegments
|
|
652
|
-
} : {
|
|
653
|
-
}
|
|
654
|
-
);
|
|
688
|
+
} : {});
|
|
655
689
|
// Reset placeholder when calendar changes
|
|
656
|
-
let lastCalendarIdentifier = $h2qOe$react.useRef(calendar.identifier);
|
|
657
|
-
$h2qOe$react.useEffect(()=>{
|
|
690
|
+
let lastCalendarIdentifier = (0, $h2qOe$react.useRef)(calendar.identifier);
|
|
691
|
+
(0, $h2qOe$react.useEffect)(()=>{
|
|
658
692
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
659
693
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
660
|
-
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $h2qOe$internationalizeddate.toCalendar(placeholder, calendar) : $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
661
|
-
);
|
|
694
|
+
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? (0, $h2qOe$internationalizeddate.toCalendar)(placeholder, calendar) : (0, $50d5d6a623389320$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
662
695
|
}
|
|
663
696
|
}, [
|
|
664
697
|
calendar,
|
|
@@ -668,18 +701,17 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
668
701
|
props.placeholderValue
|
|
669
702
|
]);
|
|
670
703
|
// If there is a value prop, and some segments were previously placeholders, mark them all as valid.
|
|
671
|
-
if (
|
|
704
|
+
if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {
|
|
672
705
|
validSegments = {
|
|
673
706
|
...allSegments
|
|
674
707
|
};
|
|
675
708
|
setValidSegments(validSegments);
|
|
676
709
|
}
|
|
677
710
|
// If the value is set to null and all segments are valid, reset the placeholder.
|
|
678
|
-
if (
|
|
679
|
-
validSegments = {
|
|
680
|
-
};
|
|
711
|
+
if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {
|
|
712
|
+
validSegments = {};
|
|
681
713
|
setValidSegments(validSegments);
|
|
682
|
-
setPlaceholderDate($50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
714
|
+
setPlaceholderDate((0, $50d5d6a623389320$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
683
715
|
}
|
|
684
716
|
// If all segments are valid, use the date from state, otherwise use the placeholder date.
|
|
685
717
|
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
|
|
@@ -688,20 +720,19 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
688
720
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) {
|
|
689
721
|
// The display calendar should not have any effect on the emitted value.
|
|
690
722
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
691
|
-
newValue = $h2qOe$internationalizeddate.toCalendar(newValue, (
|
|
723
|
+
newValue = (0, $h2qOe$internationalizeddate.toCalendar)(newValue, (v === null || v === void 0 ? void 0 : v.calendar) || new (0, $h2qOe$internationalizeddate.GregorianCalendar)());
|
|
692
724
|
setDate(newValue);
|
|
693
725
|
} else setPlaceholderDate(newValue);
|
|
694
726
|
};
|
|
695
|
-
let dateValue = $h2qOe$react.useMemo(()=>displayValue.toDate(timeZone)
|
|
696
|
-
, [
|
|
727
|
+
let dateValue = (0, $h2qOe$react.useMemo)(()=>displayValue.toDate(timeZone), [
|
|
697
728
|
displayValue,
|
|
698
729
|
timeZone
|
|
699
730
|
]);
|
|
700
|
-
let segments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
731
|
+
let segments = (0, $h2qOe$react.useMemo)(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
701
732
|
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
702
|
-
if (segment.type ===
|
|
733
|
+
if (segment.type === "era" && calendar.getEras().length === 1) isEditable = false;
|
|
703
734
|
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;
|
|
735
|
+
let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] ? (0, $e1e8ada727fae1a1$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
|
|
705
736
|
return {
|
|
706
737
|
type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
707
738
|
text: isPlaceholder ? placeholder : segment.value,
|
|
@@ -710,8 +741,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
710
741
|
placeholder: placeholder,
|
|
711
742
|
isEditable: isEditable
|
|
712
743
|
};
|
|
713
|
-
})
|
|
714
|
-
, [
|
|
744
|
+
}), [
|
|
715
745
|
dateValue,
|
|
716
746
|
validSegments,
|
|
717
747
|
dateFormatter,
|
|
@@ -735,7 +765,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
735
765
|
}
|
|
736
766
|
let markValid = (part)=>{
|
|
737
767
|
validSegments[part] = true;
|
|
738
|
-
if (part ===
|
|
768
|
+
if (part === "year" && allSegments.era) validSegments.era = true;
|
|
739
769
|
setValidSegments({
|
|
740
770
|
...validSegments
|
|
741
771
|
});
|
|
@@ -746,8 +776,8 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
746
776
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) setValue(displayValue);
|
|
747
777
|
} else setValue($596a1f0f523d6752$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
748
778
|
};
|
|
749
|
-
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ?
|
|
750
|
-
var
|
|
779
|
+
let validationState = props.validationState || ((0, $50d5d6a623389320$export$eac50920cf2fd59a)(calendarValue, props.minValue, props.maxValue) ? "invalid" : null);
|
|
780
|
+
var _props_maxGranularity1;
|
|
751
781
|
return {
|
|
752
782
|
value: calendarValue,
|
|
753
783
|
dateValue: dateValue,
|
|
@@ -757,7 +787,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
757
787
|
dateFormatter: dateFormatter,
|
|
758
788
|
validationState: validationState,
|
|
759
789
|
granularity: granularity,
|
|
760
|
-
maxGranularity: (
|
|
790
|
+
maxGranularity: (_props_maxGranularity1 = props.maxGranularity) !== null && _props_maxGranularity1 !== void 0 ? _props_maxGranularity1 : "year",
|
|
761
791
|
isDisabled: isDisabled,
|
|
762
792
|
isReadOnly: isReadOnly,
|
|
763
793
|
isRequired: isRequired,
|
|
@@ -795,10 +825,10 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
795
825
|
setValidSegments({
|
|
796
826
|
...validSegments
|
|
797
827
|
});
|
|
798
|
-
let placeholder = $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
828
|
+
let placeholder = (0, $50d5d6a623389320$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
799
829
|
let value = displayValue;
|
|
800
830
|
// Reset day period to default without changing the hour.
|
|
801
|
-
if (part ===
|
|
831
|
+
if (part === "dayPeriod" && "hour" in displayValue && "hour" in placeholder) {
|
|
802
832
|
let isPM = displayValue.hour >= 12;
|
|
803
833
|
let shouldBePM = placeholder.hour >= 12;
|
|
804
834
|
if (isPM && !shouldBePM) value = displayValue.set({
|
|
@@ -814,16 +844,16 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
814
844
|
setValue(value);
|
|
815
845
|
},
|
|
816
846
|
formatValue (fieldOptions) {
|
|
817
|
-
if (!calendarValue) return
|
|
818
|
-
let formatOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
819
|
-
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
847
|
+
if (!calendarValue) return "";
|
|
848
|
+
let formatOptions = (0, $50d5d6a623389320$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
|
|
849
|
+
let formatter = new (0, $h2qOe$internationalizeddate.DateFormatter)(locale, formatOptions);
|
|
820
850
|
return formatter.format(dateValue);
|
|
821
851
|
}
|
|
822
852
|
};
|
|
823
853
|
}
|
|
824
854
|
function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
825
855
|
switch(type){
|
|
826
|
-
case
|
|
856
|
+
case "era":
|
|
827
857
|
{
|
|
828
858
|
let eras = date.calendar.getEras();
|
|
829
859
|
return {
|
|
@@ -832,33 +862,33 @@ function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
|
832
862
|
maxValue: eras.length - 1
|
|
833
863
|
};
|
|
834
864
|
}
|
|
835
|
-
case
|
|
865
|
+
case "year":
|
|
836
866
|
return {
|
|
837
867
|
value: date.year,
|
|
838
868
|
minValue: 1,
|
|
839
869
|
maxValue: date.calendar.getYearsInEra(date)
|
|
840
870
|
};
|
|
841
|
-
case
|
|
871
|
+
case "month":
|
|
842
872
|
return {
|
|
843
873
|
value: date.month,
|
|
844
|
-
minValue: $h2qOe$internationalizeddate.getMinimumMonthInYear(date),
|
|
874
|
+
minValue: (0, $h2qOe$internationalizeddate.getMinimumMonthInYear)(date),
|
|
845
875
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
846
876
|
};
|
|
847
|
-
case
|
|
877
|
+
case "day":
|
|
848
878
|
return {
|
|
849
879
|
value: date.day,
|
|
850
|
-
minValue: $h2qOe$internationalizeddate.getMinimumDayInMonth(date),
|
|
880
|
+
minValue: (0, $h2qOe$internationalizeddate.getMinimumDayInMonth)(date),
|
|
851
881
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
852
882
|
};
|
|
853
883
|
}
|
|
854
|
-
if (
|
|
855
|
-
case
|
|
884
|
+
if ("hour" in date) switch(type){
|
|
885
|
+
case "dayPeriod":
|
|
856
886
|
return {
|
|
857
887
|
value: date.hour >= 12 ? 12 : 0,
|
|
858
888
|
minValue: 0,
|
|
859
889
|
maxValue: 12
|
|
860
890
|
};
|
|
861
|
-
case
|
|
891
|
+
case "hour":
|
|
862
892
|
if (options.hour12) {
|
|
863
893
|
let isPM = date.hour >= 12;
|
|
864
894
|
return {
|
|
@@ -872,34 +902,33 @@ function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
|
872
902
|
minValue: 0,
|
|
873
903
|
maxValue: 23
|
|
874
904
|
};
|
|
875
|
-
case
|
|
905
|
+
case "minute":
|
|
876
906
|
return {
|
|
877
907
|
value: date.minute,
|
|
878
908
|
minValue: 0,
|
|
879
909
|
maxValue: 59
|
|
880
910
|
};
|
|
881
|
-
case
|
|
911
|
+
case "second":
|
|
882
912
|
return {
|
|
883
913
|
value: date.second,
|
|
884
914
|
minValue: 0,
|
|
885
915
|
maxValue: 59
|
|
886
916
|
};
|
|
887
917
|
}
|
|
888
|
-
return {
|
|
889
|
-
};
|
|
918
|
+
return {};
|
|
890
919
|
}
|
|
891
920
|
function $596a1f0f523d6752$var$addSegment(value, part, amount, options) {
|
|
892
921
|
switch(part){
|
|
893
|
-
case
|
|
894
|
-
case
|
|
895
|
-
case
|
|
896
|
-
case
|
|
922
|
+
case "era":
|
|
923
|
+
case "year":
|
|
924
|
+
case "month":
|
|
925
|
+
case "day":
|
|
897
926
|
return value.cycle(part, amount, {
|
|
898
|
-
round: part ===
|
|
927
|
+
round: part === "year"
|
|
899
928
|
});
|
|
900
929
|
}
|
|
901
|
-
if (
|
|
902
|
-
case
|
|
930
|
+
if ("hour" in value) switch(part){
|
|
931
|
+
case "dayPeriod":
|
|
903
932
|
{
|
|
904
933
|
let hours = value.hour;
|
|
905
934
|
let isPM = hours >= 12;
|
|
@@ -907,27 +936,27 @@ function $596a1f0f523d6752$var$addSegment(value, part, amount, options) {
|
|
|
907
936
|
hour: isPM ? hours - 12 : hours + 12
|
|
908
937
|
});
|
|
909
938
|
}
|
|
910
|
-
case
|
|
911
|
-
case
|
|
912
|
-
case
|
|
939
|
+
case "hour":
|
|
940
|
+
case "minute":
|
|
941
|
+
case "second":
|
|
913
942
|
return value.cycle(part, amount, {
|
|
914
|
-
round: part !==
|
|
943
|
+
round: part !== "hour",
|
|
915
944
|
hourCycle: options.hour12 ? 12 : 24
|
|
916
945
|
});
|
|
917
946
|
}
|
|
918
947
|
}
|
|
919
948
|
function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
920
949
|
switch(part){
|
|
921
|
-
case
|
|
922
|
-
case
|
|
923
|
-
case
|
|
924
|
-
case
|
|
950
|
+
case "day":
|
|
951
|
+
case "month":
|
|
952
|
+
case "year":
|
|
953
|
+
case "era":
|
|
925
954
|
return value.set({
|
|
926
955
|
[part]: segmentValue
|
|
927
956
|
});
|
|
928
957
|
}
|
|
929
|
-
if (
|
|
930
|
-
case
|
|
958
|
+
if ("hour" in value) switch(part){
|
|
959
|
+
case "dayPeriod":
|
|
931
960
|
{
|
|
932
961
|
let hours = value.hour;
|
|
933
962
|
let wasPM = hours >= 12;
|
|
@@ -937,17 +966,17 @@ function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
|
937
966
|
hour: wasPM ? hours - 12 : hours + 12
|
|
938
967
|
});
|
|
939
968
|
}
|
|
940
|
-
case
|
|
969
|
+
case "hour":
|
|
941
970
|
// In 12 hour time, ensure that AM/PM does not change
|
|
942
971
|
if (options.hour12) {
|
|
943
|
-
let
|
|
944
|
-
let
|
|
945
|
-
if (!
|
|
946
|
-
if (
|
|
972
|
+
let hours1 = value.hour;
|
|
973
|
+
let wasPM1 = hours1 >= 12;
|
|
974
|
+
if (!wasPM1 && segmentValue === 12) segmentValue = 0;
|
|
975
|
+
if (wasPM1 && segmentValue < 12) segmentValue += 12;
|
|
947
976
|
}
|
|
948
977
|
// fallthrough
|
|
949
|
-
case
|
|
950
|
-
case
|
|
978
|
+
case "minute":
|
|
979
|
+
case "second":
|
|
951
980
|
return value.set({
|
|
952
981
|
[part]: segmentValue
|
|
953
982
|
});
|
|
@@ -955,20 +984,29 @@ function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
|
955
984
|
}
|
|
956
985
|
|
|
957
986
|
|
|
958
|
-
|
|
987
|
+
/*
|
|
988
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
989
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
990
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
991
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
992
|
+
*
|
|
993
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
994
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
995
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
996
|
+
* governing permissions and limitations under the License.
|
|
997
|
+
*/
|
|
959
998
|
|
|
960
999
|
|
|
961
1000
|
|
|
962
1001
|
|
|
963
1002
|
function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
964
|
-
var
|
|
965
|
-
let overlayState = $h2qOe$reactstatelyoverlays.useOverlayTriggerState(props);
|
|
966
|
-
let [controlledValue, setControlledValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
967
|
-
let [placeholderValue, setPlaceholderValue] = $h2qOe$react.useState(()=>controlledValue || {
|
|
1003
|
+
var _props_isDateUnavailable, _props_isDateUnavailable1;
|
|
1004
|
+
let overlayState = (0, $h2qOe$reactstatelyoverlays.useOverlayTriggerState)(props);
|
|
1005
|
+
let [controlledValue, setControlledValue] = (0, $h2qOe$reactstatelyutils.useControlledState)(props.value, props.defaultValue || null, props.onChange);
|
|
1006
|
+
let [placeholderValue, setPlaceholderValue] = (0, $h2qOe$react.useState)(()=>controlledValue || {
|
|
968
1007
|
start: null,
|
|
969
1008
|
end: null
|
|
970
|
-
}
|
|
971
|
-
);
|
|
1009
|
+
});
|
|
972
1010
|
// Reset the placeholder if the value prop is set to null.
|
|
973
1011
|
if (controlledValue == null && placeholderValue.start && placeholderValue.end) {
|
|
974
1012
|
placeholderValue = {
|
|
@@ -977,36 +1015,36 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
977
1015
|
};
|
|
978
1016
|
setPlaceholderValue(placeholderValue);
|
|
979
1017
|
}
|
|
980
|
-
let
|
|
1018
|
+
let value = controlledValue || placeholderValue;
|
|
981
1019
|
let setValue = (value)=>{
|
|
982
1020
|
setPlaceholderValue(value);
|
|
983
1021
|
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) setControlledValue(value);
|
|
984
1022
|
else setControlledValue(null);
|
|
985
1023
|
};
|
|
986
|
-
let v = (
|
|
987
|
-
let [granularity] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
988
|
-
let hasTime = granularity ===
|
|
989
|
-
var
|
|
990
|
-
let shouldCloseOnSelect = (
|
|
991
|
-
let [
|
|
992
|
-
let [
|
|
993
|
-
if (
|
|
994
|
-
|
|
995
|
-
if (
|
|
1024
|
+
let v = (value === null || value === void 0 ? void 0 : value.start) || (value === null || value === void 0 ? void 0 : value.end) || props.placeholderValue;
|
|
1025
|
+
let [granularity] = (0, $50d5d6a623389320$export$2440da353cedad43)(v, props.granularity);
|
|
1026
|
+
let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
|
|
1027
|
+
var _props_shouldCloseOnSelect;
|
|
1028
|
+
let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
|
|
1029
|
+
let [dateRange, setSelectedDateRange] = (0, $h2qOe$react.useState)(null);
|
|
1030
|
+
let [timeRange, setSelectedTimeRange] = (0, $h2qOe$react.useState)(null);
|
|
1031
|
+
if (value && value.start && value.end) {
|
|
1032
|
+
dateRange = value;
|
|
1033
|
+
if ("hour" in value.start) timeRange = value;
|
|
996
1034
|
}
|
|
997
1035
|
let commitValue = (dateRange, timeRange)=>{
|
|
998
1036
|
setValue({
|
|
999
|
-
start:
|
|
1000
|
-
end:
|
|
1037
|
+
start: "timeZone" in timeRange.start ? timeRange.start.set((0, $h2qOe$internationalizeddate.toCalendarDate)(dateRange.start)) : (0, $h2qOe$internationalizeddate.toCalendarDateTime)(dateRange.start, timeRange.start),
|
|
1038
|
+
end: "timeZone" in timeRange.end ? timeRange.end.set((0, $h2qOe$internationalizeddate.toCalendarDate)(dateRange.end)) : (0, $h2qOe$internationalizeddate.toCalendarDateTime)(dateRange.end, timeRange.end)
|
|
1001
1039
|
});
|
|
1002
1040
|
};
|
|
1003
1041
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
1004
1042
|
let setDateRange = (range)=>{
|
|
1005
|
-
let shouldClose = typeof shouldCloseOnSelect ===
|
|
1043
|
+
let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
|
|
1006
1044
|
if (hasTime) {
|
|
1007
|
-
if (shouldClose || range.start && range.end && (
|
|
1008
|
-
start: (
|
|
1009
|
-
end: (
|
|
1045
|
+
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, {
|
|
1046
|
+
start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $50d5d6a623389320$export$c5221a78ef73c5e9)(props.placeholderValue),
|
|
1047
|
+
end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $50d5d6a623389320$export$c5221a78ef73c5e9)(props.placeholderValue)
|
|
1010
1048
|
});
|
|
1011
1049
|
else setSelectedDateRange(range);
|
|
1012
1050
|
} else if (range.start && range.end) setValue(range);
|
|
@@ -1014,32 +1052,32 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
1014
1052
|
if (shouldClose) overlayState.setOpen(false);
|
|
1015
1053
|
};
|
|
1016
1054
|
let setTimeRange = (range)=>{
|
|
1017
|
-
if ((
|
|
1055
|
+
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);
|
|
1018
1056
|
else setSelectedTimeRange(range);
|
|
1019
1057
|
};
|
|
1020
|
-
let validationState = props.validationState || (
|
|
1058
|
+
let validationState = props.validationState || (value != null && ((0, $50d5d6a623389320$export$eac50920cf2fd59a)(value.start, props.minValue, props.maxValue) || (0, $50d5d6a623389320$export$eac50920cf2fd59a)(value.end, props.minValue, props.maxValue) || value.end != null && value.start != null && value.end.compare(value.start) < 0 || (value === null || value === void 0 ? void 0 : value.start) && ((_props_isDateUnavailable = props.isDateUnavailable) === null || _props_isDateUnavailable === void 0 ? void 0 : _props_isDateUnavailable.call(props, value.start)) || (value === null || value === void 0 ? void 0 : value.end) && ((_props_isDateUnavailable1 = props.isDateUnavailable) === null || _props_isDateUnavailable1 === void 0 ? void 0 : _props_isDateUnavailable1.call(props, value.end))) ? "invalid" : null);
|
|
1021
1059
|
return {
|
|
1022
|
-
value:
|
|
1060
|
+
value: value,
|
|
1023
1061
|
setValue: setValue,
|
|
1024
|
-
dateRange:
|
|
1025
|
-
timeRange:
|
|
1062
|
+
dateRange: dateRange,
|
|
1063
|
+
timeRange: timeRange,
|
|
1026
1064
|
granularity: granularity,
|
|
1027
1065
|
hasTime: hasTime,
|
|
1028
1066
|
setDate (part, date) {
|
|
1029
1067
|
setDateRange({
|
|
1030
|
-
...
|
|
1068
|
+
...dateRange,
|
|
1031
1069
|
[part]: date
|
|
1032
1070
|
});
|
|
1033
1071
|
},
|
|
1034
1072
|
setTime (part, time) {
|
|
1035
1073
|
setTimeRange({
|
|
1036
|
-
...
|
|
1074
|
+
...timeRange,
|
|
1037
1075
|
[part]: time
|
|
1038
1076
|
});
|
|
1039
1077
|
},
|
|
1040
1078
|
setDateTime (part, dateTime) {
|
|
1041
1079
|
setValue({
|
|
1042
|
-
...
|
|
1080
|
+
...value,
|
|
1043
1081
|
[part]: dateTime
|
|
1044
1082
|
});
|
|
1045
1083
|
},
|
|
@@ -1050,31 +1088,31 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
1050
1088
|
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
1051
1089
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
1052
1090
|
// the user opens the popover again.
|
|
1053
|
-
if (!isOpen && !((
|
|
1054
|
-
start: (
|
|
1055
|
-
end: (
|
|
1091
|
+
if (!isOpen && !((value === null || value === void 0 ? void 0 : value.start) && (value === null || value === void 0 ? void 0 : value.end)) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && hasTime) commitValue(dateRange, {
|
|
1092
|
+
start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $50d5d6a623389320$export$c5221a78ef73c5e9)(props.placeholderValue),
|
|
1093
|
+
end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $50d5d6a623389320$export$c5221a78ef73c5e9)(props.placeholderValue)
|
|
1056
1094
|
});
|
|
1057
1095
|
overlayState.setOpen(isOpen);
|
|
1058
1096
|
},
|
|
1059
1097
|
validationState: validationState,
|
|
1060
1098
|
formatValue (locale, fieldOptions) {
|
|
1061
|
-
if (!
|
|
1062
|
-
let startTimeZone =
|
|
1063
|
-
let startGranularity = props.granularity || (
|
|
1064
|
-
let endTimeZone =
|
|
1065
|
-
let endGranularity = props.granularity || (
|
|
1066
|
-
let startOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
1099
|
+
if (!value || !value.start || !value.end) return null;
|
|
1100
|
+
let startTimeZone = "timeZone" in value.start ? value.start.timeZone : undefined;
|
|
1101
|
+
let startGranularity = props.granularity || (value.start && "minute" in value.start ? "minute" : "day");
|
|
1102
|
+
let endTimeZone = "timeZone" in value.end ? value.end.timeZone : undefined;
|
|
1103
|
+
let endGranularity = props.granularity || (value.end && "minute" in value.end ? "minute" : "day");
|
|
1104
|
+
let startOptions = (0, $50d5d6a623389320$export$7e319ea407e63bc0)(fieldOptions, {
|
|
1067
1105
|
granularity: startGranularity,
|
|
1068
1106
|
timeZone: startTimeZone,
|
|
1069
1107
|
hideTimeZone: props.hideTimeZone,
|
|
1070
1108
|
hourCycle: props.hourCycle,
|
|
1071
|
-
showEra:
|
|
1109
|
+
showEra: value.start.calendar.identifier === "gregory" && value.start.era === "BC" || value.end.calendar.identifier === "gregory" && value.end.era === "BC"
|
|
1072
1110
|
});
|
|
1073
|
-
let startDate =
|
|
1074
|
-
let endDate =
|
|
1075
|
-
let startFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, startOptions);
|
|
1111
|
+
let startDate = value.start.toDate(startTimeZone || "UTC");
|
|
1112
|
+
let endDate = value.end.toDate(endTimeZone || "UTC");
|
|
1113
|
+
let startFormatter = new (0, $h2qOe$internationalizeddate.DateFormatter)(locale, startOptions);
|
|
1076
1114
|
let endFormatter;
|
|
1077
|
-
if (startTimeZone === endTimeZone && startGranularity === endGranularity &&
|
|
1115
|
+
if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {
|
|
1078
1116
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
1079
1117
|
// are shared between the start and end dates (e.g. the same month).
|
|
1080
1118
|
// Formatting will fail if the end date is before the start date. Fall back below when that happens.
|
|
@@ -1085,12 +1123,12 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
1085
1123
|
let separatorIndex = -1;
|
|
1086
1124
|
for(let i = 0; i < parts.length; i++){
|
|
1087
1125
|
let part = parts[i];
|
|
1088
|
-
if (part.source ===
|
|
1089
|
-
else if (part.source ===
|
|
1126
|
+
if (part.source === "shared" && part.type === "literal") separatorIndex = i;
|
|
1127
|
+
else if (part.source === "endRange") break;
|
|
1090
1128
|
}
|
|
1091
1129
|
// Now we can combine the parts into start and end strings.
|
|
1092
|
-
let start =
|
|
1093
|
-
let end =
|
|
1130
|
+
let start = "";
|
|
1131
|
+
let end = "";
|
|
1094
1132
|
for(let i1 = 0; i1 < parts.length; i1++){
|
|
1095
1133
|
if (i1 < separatorIndex) start += parts[i1].value;
|
|
1096
1134
|
else if (i1 > separatorIndex) end += parts[i1].value;
|
|
@@ -1104,13 +1142,13 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
1104
1142
|
}
|
|
1105
1143
|
endFormatter = startFormatter;
|
|
1106
1144
|
} else {
|
|
1107
|
-
let endOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
1145
|
+
let endOptions = (0, $50d5d6a623389320$export$7e319ea407e63bc0)(fieldOptions, {
|
|
1108
1146
|
granularity: endGranularity,
|
|
1109
1147
|
timeZone: endTimeZone,
|
|
1110
1148
|
hideTimeZone: props.hideTimeZone,
|
|
1111
1149
|
hourCycle: props.hourCycle
|
|
1112
1150
|
});
|
|
1113
|
-
endFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, endOptions);
|
|
1151
|
+
endFormatter = new (0, $h2qOe$internationalizeddate.DateFormatter)(locale, endOptions);
|
|
1114
1152
|
}
|
|
1115
1153
|
return {
|
|
1116
1154
|
start: startFormatter.format(startDate),
|
|
@@ -1121,54 +1159,60 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
1121
1159
|
}
|
|
1122
1160
|
|
|
1123
1161
|
|
|
1124
|
-
|
|
1162
|
+
/*
|
|
1163
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1164
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
|
|
1165
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1166
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1167
|
+
*
|
|
1168
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1169
|
+
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1170
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1171
|
+
* governing permissions and limitations under the License.
|
|
1172
|
+
*/
|
|
1125
1173
|
|
|
1126
1174
|
|
|
1127
1175
|
|
|
1128
1176
|
function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
1129
|
-
let { placeholderValue: placeholderValue = new $h2qOe$internationalizeddate.Time() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
1130
|
-
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
1177
|
+
let { placeholderValue: placeholderValue = new (0, $h2qOe$internationalizeddate.Time)() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
1178
|
+
let [value, setValue] = (0, $h2qOe$reactstatelyutils.useControlledState)(props.value, props.defaultValue, props.onChange);
|
|
1131
1179
|
let v = value || placeholderValue;
|
|
1132
|
-
let day = v &&
|
|
1133
|
-
let placeholderDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(placeholderValue)
|
|
1134
|
-
, [
|
|
1180
|
+
let day = v && "day" in v ? v : undefined;
|
|
1181
|
+
let placeholderDate = (0, $h2qOe$react.useMemo)(()=>$2654e87be0231a69$var$convertValue(placeholderValue), [
|
|
1135
1182
|
placeholderValue
|
|
1136
1183
|
]);
|
|
1137
|
-
let minDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(minValue, day)
|
|
1138
|
-
, [
|
|
1184
|
+
let minDate = (0, $h2qOe$react.useMemo)(()=>$2654e87be0231a69$var$convertValue(minValue, day), [
|
|
1139
1185
|
minValue,
|
|
1140
1186
|
day
|
|
1141
1187
|
]);
|
|
1142
|
-
let maxDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(maxValue, day)
|
|
1143
|
-
, [
|
|
1188
|
+
let maxDate = (0, $h2qOe$react.useMemo)(()=>$2654e87be0231a69$var$convertValue(maxValue, day), [
|
|
1144
1189
|
maxValue,
|
|
1145
1190
|
day
|
|
1146
1191
|
]);
|
|
1147
|
-
let dateTime = $h2qOe$react.useMemo(()=>value == null ? null : $2654e87be0231a69$var$convertValue(value)
|
|
1148
|
-
, [
|
|
1192
|
+
let dateTime = (0, $h2qOe$react.useMemo)(()=>value == null ? null : $2654e87be0231a69$var$convertValue(value), [
|
|
1149
1193
|
value
|
|
1150
1194
|
]);
|
|
1151
1195
|
let onChange = (newValue)=>{
|
|
1152
|
-
setValue(v &&
|
|
1196
|
+
setValue(v && "day" in v ? newValue : newValue && (0, $h2qOe$internationalizeddate.toTime)(newValue));
|
|
1153
1197
|
};
|
|
1154
|
-
return $596a1f0f523d6752$export$60e84778edff6d26({
|
|
1198
|
+
return (0, $596a1f0f523d6752$export$60e84778edff6d26)({
|
|
1155
1199
|
...props,
|
|
1156
1200
|
value: dateTime,
|
|
1157
1201
|
defaultValue: undefined,
|
|
1158
1202
|
minValue: minDate,
|
|
1159
1203
|
maxValue: maxDate,
|
|
1160
1204
|
onChange: onChange,
|
|
1161
|
-
granularity: granularity ||
|
|
1162
|
-
maxGranularity:
|
|
1205
|
+
granularity: granularity || "minute",
|
|
1206
|
+
maxGranularity: "hour",
|
|
1163
1207
|
placeholderValue: placeholderDate,
|
|
1164
1208
|
// Calendar should not matter for time fields.
|
|
1165
|
-
createCalendar: ()=>new $h2qOe$internationalizeddate.GregorianCalendar()
|
|
1209
|
+
createCalendar: ()=>new (0, $h2qOe$internationalizeddate.GregorianCalendar)()
|
|
1166
1210
|
});
|
|
1167
1211
|
}
|
|
1168
|
-
function $2654e87be0231a69$var$convertValue(value, date = $h2qOe$internationalizeddate.today($h2qOe$internationalizeddate.getLocalTimeZone())) {
|
|
1212
|
+
function $2654e87be0231a69$var$convertValue(value, date = (0, $h2qOe$internationalizeddate.today)((0, $h2qOe$internationalizeddate.getLocalTimeZone)())) {
|
|
1169
1213
|
if (!value) return null;
|
|
1170
|
-
if (
|
|
1171
|
-
return $h2qOe$internationalizeddate.toCalendarDateTime(date, value);
|
|
1214
|
+
if ("day" in value) return value;
|
|
1215
|
+
return (0, $h2qOe$internationalizeddate.toCalendarDateTime)(date, value);
|
|
1172
1216
|
}
|
|
1173
1217
|
|
|
1174
1218
|
|