@react-stately/datepicker 3.0.0-nightly.3175 → 3.0.0-rc.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 +98 -82
- package/dist/main.js.map +1 -1
- package/dist/module.js +95 -67
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +148 -35
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +9 -4
- package/src/{useDatePickerFieldState.ts → useDateFieldState.ts} +103 -36
- package/src/useDatePickerState.ts +37 -13
- package/src/useDateRangePickerState.ts +82 -21
- package/src/useTimeFieldState.ts +10 -4
- package/src/utils.ts +6 -1
package/dist/main.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
var $h2qOe$internationalizeddate = require("@internationalized/date");
|
|
2
2
|
var $h2qOe$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $h2qOe$reactstatelyoverlays = require("@react-stately/overlays");
|
|
3
4
|
var $h2qOe$react = require("react");
|
|
4
5
|
|
|
5
|
-
function $parcel$exportWildcard(dest, source) {
|
|
6
|
-
Object.keys(source).forEach(function(key) {
|
|
7
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(dest, key, {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function get() {
|
|
14
|
-
return source[key];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return dest;
|
|
20
|
-
}
|
|
21
6
|
function $parcel$export(e, n, v, s) {
|
|
22
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
8
|
}
|
|
24
|
-
var $aaab7a647e17e1fd$exports = {};
|
|
25
9
|
|
|
26
|
-
$parcel$export(
|
|
10
|
+
$parcel$export(module.exports, "useDatePickerState", () => $aaab7a647e17e1fd$export$87194bb378cc3ac2);
|
|
11
|
+
$parcel$export(module.exports, "useDateFieldState", () => $596a1f0f523d6752$export$60e84778edff6d26);
|
|
12
|
+
$parcel$export(module.exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
13
|
+
$parcel$export(module.exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
27
14
|
|
|
28
15
|
|
|
29
16
|
|
|
@@ -60,6 +47,7 @@ function $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
60
47
|
opts1.timeZone = options.timeZone || 'UTC';
|
|
61
48
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
|
|
62
49
|
if (hasTime && options.timeZone && !options.hideTimeZone) opts1.timeZoneName = 'short';
|
|
50
|
+
if (options.showEra && startIdx === 0) opts1.era = 'short';
|
|
63
51
|
return opts1;
|
|
64
52
|
}
|
|
65
53
|
function $50d5d6a623389320$export$c5221a78ef73c5e9(placeholderValue) {
|
|
@@ -102,9 +90,10 @@ function $50d5d6a623389320$export$2440da353cedad43(v, granularity) {
|
|
|
102
90
|
|
|
103
91
|
|
|
104
92
|
|
|
93
|
+
|
|
105
94
|
function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
106
95
|
var ref;
|
|
107
|
-
let
|
|
96
|
+
let overlayState = $h2qOe$reactstatelyoverlays.useOverlayTriggerState(props);
|
|
108
97
|
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
109
98
|
let v = value || props.placeholderValue;
|
|
110
99
|
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
@@ -130,7 +119,7 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
130
119
|
if (selectedTime || shouldClose) commitValue(newValue, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
131
120
|
else setSelectedDate(newValue);
|
|
132
121
|
} else setValue(newValue);
|
|
133
|
-
if (shouldClose) setOpen(false);
|
|
122
|
+
if (shouldClose) overlayState.setOpen(false);
|
|
134
123
|
};
|
|
135
124
|
let selectTime = (newValue)=>{
|
|
136
125
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
@@ -146,13 +135,13 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
146
135
|
setTimeValue: selectTime,
|
|
147
136
|
granularity: granularity,
|
|
148
137
|
hasTime: hasTime,
|
|
149
|
-
isOpen:
|
|
138
|
+
isOpen: overlayState.isOpen,
|
|
150
139
|
setOpen (isOpen) {
|
|
151
140
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
152
141
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
153
142
|
// the user opens the popover again.
|
|
154
143
|
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
155
|
-
setOpen(isOpen);
|
|
144
|
+
overlayState.setOpen(isOpen);
|
|
156
145
|
},
|
|
157
146
|
validationState: validationState,
|
|
158
147
|
formatValue (locale, fieldOptions) {
|
|
@@ -161,7 +150,8 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
161
150
|
granularity: granularity,
|
|
162
151
|
timeZone: defaultTimeZone,
|
|
163
152
|
hideTimeZone: props.hideTimeZone,
|
|
164
|
-
hourCycle: props.hourCycle
|
|
153
|
+
hourCycle: props.hourCycle,
|
|
154
|
+
showEra: value.calendar.identifier === 'gregory' && value.era === 'BC'
|
|
165
155
|
});
|
|
166
156
|
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
167
157
|
return formatter.format(dateValue);
|
|
@@ -170,14 +160,11 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
|
170
160
|
}
|
|
171
161
|
|
|
172
162
|
|
|
173
|
-
var $6d4e641deb83cb9e$exports = {};
|
|
174
163
|
|
|
175
|
-
$parcel$export($6d4e641deb83cb9e$exports, "useDatePickerFieldState", () => $6d4e641deb83cb9e$export$714a241b39a650d6);
|
|
176
164
|
|
|
177
165
|
|
|
178
166
|
|
|
179
|
-
|
|
180
|
-
const $6d4e641deb83cb9e$var$EDITABLE_SEGMENTS = {
|
|
167
|
+
const $596a1f0f523d6752$var$EDITABLE_SEGMENTS = {
|
|
181
168
|
year: true,
|
|
182
169
|
month: true,
|
|
183
170
|
day: true,
|
|
@@ -187,7 +174,7 @@ const $6d4e641deb83cb9e$var$EDITABLE_SEGMENTS = {
|
|
|
187
174
|
dayPeriod: true,
|
|
188
175
|
era: true
|
|
189
176
|
};
|
|
190
|
-
const $
|
|
177
|
+
const $596a1f0f523d6752$var$PAGE_STEP = {
|
|
191
178
|
year: 5,
|
|
192
179
|
month: 2,
|
|
193
180
|
day: 7,
|
|
@@ -196,30 +183,55 @@ const $6d4e641deb83cb9e$var$PAGE_STEP = {
|
|
|
196
183
|
second: 15
|
|
197
184
|
};
|
|
198
185
|
// Node seems to convert everything to lowercase...
|
|
199
|
-
const $
|
|
186
|
+
const $596a1f0f523d6752$var$TYPE_MAPPING = {
|
|
200
187
|
dayperiod: 'dayPeriod'
|
|
201
188
|
};
|
|
202
|
-
function $
|
|
189
|
+
function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
203
190
|
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone , isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired } = props;
|
|
204
191
|
let v1 = props.value || props.defaultValue || props.placeholderValue;
|
|
205
192
|
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v1, props.granularity);
|
|
206
193
|
let timeZone = defaultTimeZone || 'UTC';
|
|
207
194
|
// props.granularity must actually exist in the value if one is provided.
|
|
208
195
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
196
|
+
let defaultFormatter = $h2qOe$react.useMemo(()=>new $h2qOe$internationalizeddate.DateFormatter(locale)
|
|
197
|
+
, [
|
|
198
|
+
locale
|
|
199
|
+
]);
|
|
200
|
+
let calendar = $h2qOe$react.useMemo(()=>createCalendar(defaultFormatter.resolvedOptions().calendar)
|
|
201
|
+
, [
|
|
202
|
+
createCalendar,
|
|
203
|
+
defaultFormatter
|
|
204
|
+
]);
|
|
205
|
+
let [value1, setDate] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
206
|
+
let calendarValue = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$61a490a80c552550(value1, calendar)
|
|
207
|
+
, [
|
|
208
|
+
value1,
|
|
209
|
+
calendar
|
|
210
|
+
]);
|
|
211
|
+
// We keep track of the placeholder date separately in state so that onChange is not called
|
|
212
|
+
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
213
|
+
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
214
|
+
// change from uncontrolled to controlled and emit a warning.
|
|
215
|
+
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()=>$50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
216
|
+
);
|
|
217
|
+
let val = calendarValue || placeholderDate;
|
|
218
|
+
let showEra = calendar.identifier === 'gregory' && val.era === 'BC';
|
|
209
219
|
var _maxGranularity;
|
|
210
220
|
let formatOpts = $h2qOe$react.useMemo(()=>({
|
|
211
221
|
granularity: granularity,
|
|
212
222
|
maxGranularity: (_maxGranularity = props.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year',
|
|
213
223
|
timeZone: defaultTimeZone,
|
|
214
224
|
hideTimeZone: hideTimeZone,
|
|
215
|
-
hourCycle: props.hourCycle
|
|
225
|
+
hourCycle: props.hourCycle,
|
|
226
|
+
showEra: showEra
|
|
216
227
|
})
|
|
217
228
|
, [
|
|
218
229
|
props.maxGranularity,
|
|
219
230
|
granularity,
|
|
220
231
|
props.hourCycle,
|
|
221
232
|
defaultTimeZone,
|
|
222
|
-
hideTimeZone
|
|
233
|
+
hideTimeZone,
|
|
234
|
+
showEra
|
|
223
235
|
]);
|
|
224
236
|
let opts = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$7e319ea407e63bc0({
|
|
225
237
|
}, formatOpts)
|
|
@@ -235,14 +247,9 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
235
247
|
, [
|
|
236
248
|
dateFormatter
|
|
237
249
|
]);
|
|
238
|
-
let calendar = $h2qOe$react.useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
239
|
-
, [
|
|
240
|
-
createCalendar,
|
|
241
|
-
resolvedOptions.calendar
|
|
242
|
-
]);
|
|
243
250
|
// Determine how many editable segments there are for validation purposes.
|
|
244
251
|
// The result is cached for performance.
|
|
245
|
-
let allSegments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$
|
|
252
|
+
let allSegments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]
|
|
246
253
|
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
247
254
|
, {
|
|
248
255
|
})
|
|
@@ -254,12 +261,6 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
254
261
|
} : {
|
|
255
262
|
}
|
|
256
263
|
);
|
|
257
|
-
// We keep track of the placeholder date separately in state so that onChange is not called
|
|
258
|
-
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
259
|
-
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
260
|
-
// change from uncontrolled to controlled and emit a warning.
|
|
261
|
-
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()=>$50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
262
|
-
);
|
|
263
264
|
// Reset placeholder when calendar changes
|
|
264
265
|
let lastCalendarIdentifier = $h2qOe$react.useRef(calendar.identifier);
|
|
265
266
|
$h2qOe$react.useEffect(()=>{
|
|
@@ -275,12 +276,6 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
275
276
|
defaultTimeZone,
|
|
276
277
|
props.placeholderValue
|
|
277
278
|
]);
|
|
278
|
-
let [value1, setDate] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
279
|
-
let calendarValue = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$61a490a80c552550(value1, calendar)
|
|
280
|
-
, [
|
|
281
|
-
value1,
|
|
282
|
-
calendar
|
|
283
|
-
]);
|
|
284
279
|
// If there is a value prop, and some segments were previously placeholders, mark them all as valid.
|
|
285
280
|
if (value1 && Object.keys(validSegments).length < Object.keys(allSegments).length) {
|
|
286
281
|
validSegments = {
|
|
@@ -312,13 +307,13 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
312
307
|
timeZone
|
|
313
308
|
]);
|
|
314
309
|
let segments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
315
|
-
let isEditable = $
|
|
310
|
+
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
316
311
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
317
312
|
return {
|
|
318
|
-
type: $
|
|
313
|
+
type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
319
314
|
text: segment.value,
|
|
320
|
-
...$
|
|
321
|
-
isPlaceholder: $
|
|
315
|
+
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
316
|
+
isPlaceholder: $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type],
|
|
322
317
|
isEditable: isEditable
|
|
323
318
|
};
|
|
324
319
|
})
|
|
@@ -344,9 +339,10 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
344
339
|
};
|
|
345
340
|
let adjustSegment = (type, amount)=>{
|
|
346
341
|
markValid(type);
|
|
347
|
-
setValue($
|
|
342
|
+
setValue($596a1f0f523d6752$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
348
343
|
};
|
|
349
344
|
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
345
|
+
var _maxGranularity1;
|
|
350
346
|
return {
|
|
351
347
|
value: calendarValue,
|
|
352
348
|
dateValue: dateValue,
|
|
@@ -355,6 +351,7 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
355
351
|
dateFormatter: dateFormatter,
|
|
356
352
|
validationState: validationState,
|
|
357
353
|
granularity: granularity,
|
|
354
|
+
maxGranularity: (_maxGranularity1 = props.maxGranularity) !== null && _maxGranularity1 !== void 0 ? _maxGranularity1 : 'year',
|
|
358
355
|
isDisabled: isDisabled,
|
|
359
356
|
isReadOnly: isReadOnly,
|
|
360
357
|
isRequired: isRequired,
|
|
@@ -365,14 +362,14 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
365
362
|
adjustSegment(part, -1);
|
|
366
363
|
},
|
|
367
364
|
incrementPage (part) {
|
|
368
|
-
adjustSegment(part, $
|
|
365
|
+
adjustSegment(part, $596a1f0f523d6752$var$PAGE_STEP[part] || 1);
|
|
369
366
|
},
|
|
370
367
|
decrementPage (part) {
|
|
371
|
-
adjustSegment(part, -($
|
|
368
|
+
adjustSegment(part, -($596a1f0f523d6752$var$PAGE_STEP[part] || 1));
|
|
372
369
|
},
|
|
373
370
|
setSegment (part, v) {
|
|
374
371
|
markValid(part);
|
|
375
|
-
setValue($
|
|
372
|
+
setValue($596a1f0f523d6752$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
376
373
|
},
|
|
377
374
|
confirmPlaceholder (part) {
|
|
378
375
|
if (props.isDisabled || props.isReadOnly) return;
|
|
@@ -414,12 +411,15 @@ function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
|
414
411
|
setDate(null);
|
|
415
412
|
setValue(value);
|
|
416
413
|
},
|
|
417
|
-
|
|
418
|
-
|
|
414
|
+
formatValue (fieldOptions) {
|
|
415
|
+
if (!calendarValue) return '';
|
|
416
|
+
let formatOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
417
|
+
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
418
|
+
return formatter.format(dateValue);
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
function $
|
|
422
|
+
function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
423
423
|
switch(type){
|
|
424
424
|
case 'era':
|
|
425
425
|
{
|
|
@@ -486,7 +486,7 @@ function $6d4e641deb83cb9e$var$getSegmentLimits(date, type, options) {
|
|
|
486
486
|
return {
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
|
-
function $
|
|
489
|
+
function $596a1f0f523d6752$var$addSegment(value, part, amount, options) {
|
|
490
490
|
switch(part){
|
|
491
491
|
case 'era':
|
|
492
492
|
case 'year':
|
|
@@ -514,7 +514,7 @@ function $6d4e641deb83cb9e$var$addSegment(value, part, amount, options) {
|
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
function $
|
|
517
|
+
function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
518
518
|
switch(part){
|
|
519
519
|
case 'day':
|
|
520
520
|
case 'month':
|
|
@@ -552,16 +552,14 @@ function $6d4e641deb83cb9e$var$setSegment(value, part, segmentValue, options) {
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
|
|
555
|
-
var $7072d26f58deb33b$exports = {};
|
|
556
555
|
|
|
557
|
-
$parcel$export($7072d26f58deb33b$exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
558
556
|
|
|
559
557
|
|
|
560
558
|
|
|
561
559
|
|
|
562
560
|
function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
563
561
|
var ref, ref1;
|
|
564
|
-
let
|
|
562
|
+
let overlayState = $h2qOe$reactstatelyoverlays.useOverlayTriggerState(props);
|
|
565
563
|
let [controlledValue, setControlledValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
566
564
|
let [placeholderValue, setPlaceholderValue] = $h2qOe$react.useState(()=>controlledValue || {
|
|
567
565
|
start: null,
|
|
@@ -613,7 +611,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
613
611
|
else setSelectedDateRange(range);
|
|
614
612
|
} else if (range.start && range.end) setValue(range);
|
|
615
613
|
else setSelectedDateRange(range);
|
|
616
|
-
if (shouldClose) setOpen(false);
|
|
614
|
+
if (shouldClose) overlayState.setOpen(false);
|
|
617
615
|
};
|
|
618
616
|
let setTimeRange = (range)=>{
|
|
619
617
|
if ((dateRange1 === null || dateRange1 === void 0 ? void 0 : dateRange1.start) && (dateRange1 === null || dateRange1 === void 0 ? void 0 : dateRange1.end) && range.start && range.end) commitValue(dateRange1, range);
|
|
@@ -647,7 +645,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
647
645
|
},
|
|
648
646
|
setDateRange: setDateRange,
|
|
649
647
|
setTimeRange: setTimeRange,
|
|
650
|
-
isOpen:
|
|
648
|
+
isOpen: overlayState.isOpen,
|
|
651
649
|
setOpen (isOpen) {
|
|
652
650
|
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
653
651
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
@@ -656,11 +654,11 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
656
654
|
start: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
657
655
|
end: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
658
656
|
});
|
|
659
|
-
setOpen(isOpen);
|
|
657
|
+
overlayState.setOpen(isOpen);
|
|
660
658
|
},
|
|
661
659
|
validationState: validationState,
|
|
662
660
|
formatValue (locale, fieldOptions) {
|
|
663
|
-
if (!value1 || !value1.start || !value1.end) return
|
|
661
|
+
if (!value1 || !value1.start || !value1.end) return null;
|
|
664
662
|
let startTimeZone = 'timeZone' in value1.start ? value1.start.timeZone : undefined;
|
|
665
663
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
666
664
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
@@ -669,16 +667,38 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
669
667
|
granularity: startGranularity,
|
|
670
668
|
timeZone: startTimeZone,
|
|
671
669
|
hideTimeZone: props.hideTimeZone,
|
|
672
|
-
hourCycle: props.hourCycle
|
|
670
|
+
hourCycle: props.hourCycle,
|
|
671
|
+
showEra: value1.start.calendar.identifier === 'gregory' && value1.start.era === 'BC' || value1.end.calendar.identifier === 'gregory' && value1.end.era === 'BC'
|
|
673
672
|
});
|
|
673
|
+
let startDate = value1.start.toDate(startTimeZone || 'UTC');
|
|
674
|
+
let endDate = value1.end.toDate(endTimeZone || 'UTC');
|
|
674
675
|
let startFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, startOptions);
|
|
675
676
|
let endFormatter;
|
|
676
|
-
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
677
|
+
if (startTimeZone === endTimeZone && startGranularity === endGranularity && value1.start.compare(value1.end) !== 0) {
|
|
677
678
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
678
679
|
// are shared between the start and end dates (e.g. the same month).
|
|
679
680
|
// Formatting will fail if the end date is before the start date. Fall back below when that happens.
|
|
680
681
|
try {
|
|
681
|
-
|
|
682
|
+
let parts = startFormatter.formatRangeToParts(startDate, endDate);
|
|
683
|
+
// Find the separator between the start and end date. This is determined
|
|
684
|
+
// by finding the last shared literal before the end range.
|
|
685
|
+
let separatorIndex = -1;
|
|
686
|
+
for(let i = 0; i < parts.length; i++){
|
|
687
|
+
let part = parts[i];
|
|
688
|
+
if (part.source === 'shared' && part.type === 'literal') separatorIndex = i;
|
|
689
|
+
else if (part.source === 'endRange') break;
|
|
690
|
+
}
|
|
691
|
+
// Now we can combine the parts into start and end strings.
|
|
692
|
+
let start = '';
|
|
693
|
+
let end = '';
|
|
694
|
+
for(let i1 = 0; i1 < parts.length; i1++){
|
|
695
|
+
if (i1 < separatorIndex) start += parts[i1].value;
|
|
696
|
+
else if (i1 > separatorIndex) end += parts[i1].value;
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
start: start,
|
|
700
|
+
end: end
|
|
701
|
+
};
|
|
682
702
|
} catch (e) {
|
|
683
703
|
// ignore
|
|
684
704
|
}
|
|
@@ -692,7 +712,10 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
692
712
|
});
|
|
693
713
|
endFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, endOptions);
|
|
694
714
|
}
|
|
695
|
-
return
|
|
715
|
+
return {
|
|
716
|
+
start: startFormatter.format(startDate),
|
|
717
|
+
end: endFormatter.format(endDate)
|
|
718
|
+
};
|
|
696
719
|
},
|
|
697
720
|
confirmPlaceholder () {
|
|
698
721
|
// Need to use ref value here because the value can be set in the same tick as
|
|
@@ -711,9 +734,6 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
|
711
734
|
}
|
|
712
735
|
|
|
713
736
|
|
|
714
|
-
var $2654e87be0231a69$exports = {};
|
|
715
|
-
|
|
716
|
-
$parcel$export($2654e87be0231a69$exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
717
737
|
|
|
718
738
|
|
|
719
739
|
|
|
@@ -744,7 +764,7 @@ function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
|
744
764
|
let onChange = (newValue)=>{
|
|
745
765
|
setValue(v && 'day' in v ? newValue : newValue && $h2qOe$internationalizeddate.toTime(newValue));
|
|
746
766
|
};
|
|
747
|
-
return $
|
|
767
|
+
return $596a1f0f523d6752$export$60e84778edff6d26({
|
|
748
768
|
...props,
|
|
749
769
|
value: dateTime,
|
|
750
770
|
defaultValue: undefined,
|
|
@@ -765,10 +785,6 @@ function $2654e87be0231a69$var$convertValue(value, date = $h2qOe$internationaliz
|
|
|
765
785
|
}
|
|
766
786
|
|
|
767
787
|
|
|
768
|
-
$parcel$exportWildcard(module.exports, $aaab7a647e17e1fd$exports);
|
|
769
|
-
$parcel$exportWildcard(module.exports, $6d4e641deb83cb9e$exports);
|
|
770
|
-
$parcel$exportWildcard(module.exports, $7072d26f58deb33b$exports);
|
|
771
|
-
$parcel$exportWildcard(module.exports, $2654e87be0231a69$exports);
|
|
772
788
|
|
|
773
789
|
|
|
774
790
|
//# sourceMappingURL=main.js.map
|