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