@react-stately/datepicker 3.0.0-nightly.1383 → 3.0.0-nightly.1395
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 +109 -109
- package/dist/module.js +106 -106
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
1
|
+
var $17UYf$internationalizeddate = require("@internationalized/date");
|
|
2
|
+
var $17UYf$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $17UYf$react = require("react");
|
|
4
4
|
|
|
5
5
|
function $parcel$exportWildcard(dest, source) {
|
|
6
6
|
Object.keys(source).forEach(function(key) {
|
|
@@ -21,16 +21,16 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
21
21
|
function $parcel$export(e, n, v, s) {
|
|
22
22
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
23
|
}
|
|
24
|
-
var $
|
|
24
|
+
var $0c9ae69d60d14242$exports = {};
|
|
25
25
|
|
|
26
|
-
$parcel$export($
|
|
26
|
+
$parcel$export($0c9ae69d60d14242$exports, "useDatePickerState", () => $0c9ae69d60d14242$export$87194bb378cc3ac2);
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
function $
|
|
30
|
+
function $a1a093054004b094$export$eac50920cf2fd59a(value, minValue, maxValue) {
|
|
31
31
|
return value != null && (minValue != null && value.compare(minValue) < 0 || maxValue != null && value.compare(maxValue) > 0);
|
|
32
32
|
}
|
|
33
|
-
const $
|
|
33
|
+
const $a1a093054004b094$var$DEFAULT_FIELD_OPTIONS = {
|
|
34
34
|
year: 'numeric',
|
|
35
35
|
month: 'numeric',
|
|
36
36
|
day: 'numeric',
|
|
@@ -38,9 +38,9 @@ const $b15d33af207752c1$var$DEFAULT_FIELD_OPTIONS = {
|
|
|
38
38
|
minute: '2-digit',
|
|
39
39
|
second: '2-digit'
|
|
40
40
|
};
|
|
41
|
-
function $
|
|
41
|
+
function $a1a093054004b094$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
42
42
|
fieldOptions = {
|
|
43
|
-
...$
|
|
43
|
+
...$a1a093054004b094$var$DEFAULT_FIELD_OPTIONS,
|
|
44
44
|
...fieldOptions
|
|
45
45
|
};
|
|
46
46
|
let granularity = options.granularity || 'minute';
|
|
@@ -61,30 +61,30 @@ function $b15d33af207752c1$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
61
61
|
if (hasTime && options.timeZone && !options.hideTimeZone) opts1.timeZoneName = 'short';
|
|
62
62
|
return opts1;
|
|
63
63
|
}
|
|
64
|
-
function $
|
|
64
|
+
function $a1a093054004b094$export$c5221a78ef73c5e9(placeholderValue) {
|
|
65
65
|
if (placeholderValue && 'hour' in placeholderValue) return placeholderValue;
|
|
66
|
-
return new $
|
|
66
|
+
return new $17UYf$internationalizeddate.Time();
|
|
67
67
|
}
|
|
68
|
-
function $
|
|
68
|
+
function $a1a093054004b094$export$61a490a80c552550(value, calendar) {
|
|
69
69
|
if (value === null) return null;
|
|
70
70
|
if (!value) return undefined;
|
|
71
|
-
return $
|
|
71
|
+
return $17UYf$internationalizeddate.toCalendar(value, calendar);
|
|
72
72
|
}
|
|
73
|
-
function $
|
|
74
|
-
if (placeholderValue) return $
|
|
75
|
-
let date = $
|
|
73
|
+
function $a1a093054004b094$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
|
|
74
|
+
if (placeholderValue) return $a1a093054004b094$export$61a490a80c552550(placeholderValue, calendar);
|
|
75
|
+
let date = $17UYf$internationalizeddate.toCalendar($17UYf$internationalizeddate.now(timeZone).set({
|
|
76
76
|
hour: 0,
|
|
77
77
|
minute: 0,
|
|
78
78
|
second: 0,
|
|
79
79
|
millisecond: 0
|
|
80
80
|
}), calendar);
|
|
81
|
-
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $
|
|
82
|
-
if (!timeZone) return $
|
|
81
|
+
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $17UYf$internationalizeddate.toCalendarDate(date);
|
|
82
|
+
if (!timeZone) return $17UYf$internationalizeddate.toCalendarDateTime(date);
|
|
83
83
|
return date;
|
|
84
84
|
}
|
|
85
|
-
function $
|
|
85
|
+
function $a1a093054004b094$export$2440da353cedad43(v, granularity) {
|
|
86
86
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
87
|
-
let lastValue = $
|
|
87
|
+
let lastValue = $17UYf$react.useRef(v);
|
|
88
88
|
if (v) lastValue.current = v;
|
|
89
89
|
v = lastValue.current;
|
|
90
90
|
let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
@@ -101,15 +101,15 @@ function $b15d33af207752c1$export$2440da353cedad43(v, granularity) {
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
function $
|
|
105
|
-
let [isOpen1, setOpen] = $
|
|
106
|
-
let [value, setValue] = $
|
|
104
|
+
function $0c9ae69d60d14242$export$87194bb378cc3ac2(props) {
|
|
105
|
+
let [isOpen1, setOpen] = $17UYf$react.useState(false);
|
|
106
|
+
let [value, setValue] = $17UYf$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
107
107
|
let v = value || props.placeholderValue;
|
|
108
|
-
let [granularity, defaultTimeZone] = $
|
|
108
|
+
let [granularity, defaultTimeZone] = $a1a093054004b094$export$2440da353cedad43(v, props.granularity);
|
|
109
109
|
let dateValue = value != null ? value.toDate(defaultTimeZone ?? 'UTC') : null;
|
|
110
110
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
111
|
-
let [selectedDate, setSelectedDate] = $
|
|
112
|
-
let [selectedTime, setSelectedTime] = $
|
|
111
|
+
let [selectedDate, setSelectedDate] = $17UYf$react.useState(null);
|
|
112
|
+
let [selectedTime, setSelectedTime] = $17UYf$react.useState(null);
|
|
113
113
|
if (value) {
|
|
114
114
|
selectedDate = value;
|
|
115
115
|
if ('hour' in value) selectedTime = value;
|
|
@@ -117,7 +117,7 @@ function $f0afaa11cdb4d9e5$export$87194bb378cc3ac2(props) {
|
|
|
117
117
|
// props.granularity must actually exist in the value if one is provided.
|
|
118
118
|
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
119
119
|
let commitValue = (date, time)=>{
|
|
120
|
-
setValue('timeZone' in time ? time.set($
|
|
120
|
+
setValue('timeZone' in time ? time.set($17UYf$internationalizeddate.toDateFields(date)) : $17UYf$internationalizeddate.toCalendarDateTime(date, time));
|
|
121
121
|
};
|
|
122
122
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
123
123
|
let selectDate = (newValue)=>{
|
|
@@ -131,7 +131,7 @@ function $f0afaa11cdb4d9e5$export$87194bb378cc3ac2(props) {
|
|
|
131
131
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
132
132
|
else setSelectedTime(newValue);
|
|
133
133
|
};
|
|
134
|
-
let validationState = props.validationState || ($
|
|
134
|
+
let validationState = props.validationState || ($a1a093054004b094$export$eac50920cf2fd59a(value, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
135
135
|
return {
|
|
136
136
|
value: value,
|
|
137
137
|
setValue: setValue,
|
|
@@ -145,33 +145,33 @@ function $f0afaa11cdb4d9e5$export$87194bb378cc3ac2(props) {
|
|
|
145
145
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
146
146
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
147
147
|
// the user opens the popover again.
|
|
148
|
-
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $
|
|
148
|
+
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $a1a093054004b094$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
149
149
|
setOpen(isOpen);
|
|
150
150
|
},
|
|
151
151
|
validationState: validationState,
|
|
152
152
|
formatValue (locale, fieldOptions) {
|
|
153
153
|
if (!dateValue) return '';
|
|
154
|
-
let formatOptions = $
|
|
154
|
+
let formatOptions = $a1a093054004b094$export$7e319ea407e63bc0(fieldOptions, {
|
|
155
155
|
granularity: granularity,
|
|
156
156
|
timeZone: defaultTimeZone,
|
|
157
157
|
hideTimeZone: props.hideTimeZone,
|
|
158
158
|
hourCycle: props.hourCycle
|
|
159
159
|
});
|
|
160
|
-
let formatter = new $
|
|
160
|
+
let formatter = new $17UYf$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
161
161
|
return formatter.format(dateValue);
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
|
|
167
|
-
var $
|
|
167
|
+
var $f23cc841f3588f43$exports = {};
|
|
168
168
|
|
|
169
|
-
$parcel$export($
|
|
169
|
+
$parcel$export($f23cc841f3588f43$exports, "useDatePickerFieldState", () => $f23cc841f3588f43$export$714a241b39a650d6);
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
const $
|
|
174
|
+
const $f23cc841f3588f43$var$EDITABLE_SEGMENTS = {
|
|
175
175
|
year: true,
|
|
176
176
|
month: true,
|
|
177
177
|
day: true,
|
|
@@ -181,7 +181,7 @@ const $db920376312b84b4$var$EDITABLE_SEGMENTS = {
|
|
|
181
181
|
dayPeriod: true,
|
|
182
182
|
era: true
|
|
183
183
|
};
|
|
184
|
-
const $
|
|
184
|
+
const $f23cc841f3588f43$var$PAGE_STEP = {
|
|
185
185
|
year: 5,
|
|
186
186
|
month: 2,
|
|
187
187
|
day: 7,
|
|
@@ -190,17 +190,17 @@ const $db920376312b84b4$var$PAGE_STEP = {
|
|
|
190
190
|
second: 15
|
|
191
191
|
};
|
|
192
192
|
// Node seems to convert everything to lowercase...
|
|
193
|
-
const $
|
|
193
|
+
const $f23cc841f3588f43$var$TYPE_MAPPING = {
|
|
194
194
|
dayperiod: 'dayPeriod'
|
|
195
195
|
};
|
|
196
|
-
function $
|
|
196
|
+
function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
197
197
|
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone } = props;
|
|
198
198
|
let v1 = props.value || props.defaultValue || props.placeholderValue;
|
|
199
|
-
let [granularity, defaultTimeZone] = $
|
|
199
|
+
let [granularity, defaultTimeZone] = $a1a093054004b094$export$2440da353cedad43(v1, props.granularity);
|
|
200
200
|
let timeZone = defaultTimeZone || 'UTC';
|
|
201
201
|
// props.granularity must actually exist in the value if one is provided.
|
|
202
202
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
203
|
-
let formatOpts = $
|
|
203
|
+
let formatOpts = $17UYf$react.useMemo(()=>({
|
|
204
204
|
granularity: granularity,
|
|
205
205
|
maxGranularity: props.maxGranularity ?? 'year',
|
|
206
206
|
timeZone: defaultTimeZone,
|
|
@@ -214,35 +214,35 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
214
214
|
defaultTimeZone,
|
|
215
215
|
hideTimeZone
|
|
216
216
|
]);
|
|
217
|
-
let opts = $
|
|
217
|
+
let opts = $17UYf$react.useMemo(()=>$a1a093054004b094$export$7e319ea407e63bc0({
|
|
218
218
|
}, formatOpts)
|
|
219
219
|
, [
|
|
220
220
|
formatOpts
|
|
221
221
|
]);
|
|
222
|
-
let dateFormatter = $
|
|
222
|
+
let dateFormatter = $17UYf$react.useMemo(()=>new $17UYf$internationalizeddate.DateFormatter(locale, opts)
|
|
223
223
|
, [
|
|
224
224
|
locale,
|
|
225
225
|
opts
|
|
226
226
|
]);
|
|
227
|
-
let resolvedOptions = $
|
|
227
|
+
let resolvedOptions = $17UYf$react.useMemo(()=>dateFormatter.resolvedOptions()
|
|
228
228
|
, [
|
|
229
229
|
dateFormatter
|
|
230
230
|
]);
|
|
231
|
-
let calendar = $
|
|
231
|
+
let calendar = $17UYf$react.useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
232
232
|
, [
|
|
233
233
|
createCalendar,
|
|
234
234
|
resolvedOptions.calendar
|
|
235
235
|
]);
|
|
236
236
|
// Determine how many editable segments there are for validation purposes.
|
|
237
237
|
// The result is cached for performance.
|
|
238
|
-
let allSegments = $
|
|
238
|
+
let allSegments = $17UYf$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$f23cc841f3588f43$var$EDITABLE_SEGMENTS[seg.type]
|
|
239
239
|
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
240
240
|
, {
|
|
241
241
|
})
|
|
242
242
|
, [
|
|
243
243
|
dateFormatter
|
|
244
244
|
]);
|
|
245
|
-
let [validSegments, setValidSegments] = $
|
|
245
|
+
let [validSegments, setValidSegments] = $17UYf$react.useState(()=>props.value || props.defaultValue ? {
|
|
246
246
|
...allSegments
|
|
247
247
|
} : {
|
|
248
248
|
}
|
|
@@ -251,14 +251,14 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
251
251
|
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
252
252
|
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
253
253
|
// change from uncontrolled to controlled and emit a warning.
|
|
254
|
-
let [placeholderDate, setPlaceholderDate] = $
|
|
254
|
+
let [placeholderDate, setPlaceholderDate] = $17UYf$react.useState(()=>$a1a093054004b094$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
255
255
|
);
|
|
256
256
|
// Reset placeholder when calendar changes
|
|
257
|
-
let lastCalendarIdentifier = $
|
|
258
|
-
$
|
|
257
|
+
let lastCalendarIdentifier = $17UYf$react.useRef(calendar.identifier);
|
|
258
|
+
$17UYf$react.useEffect(()=>{
|
|
259
259
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
260
260
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
261
|
-
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $
|
|
261
|
+
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $17UYf$internationalizeddate.toCalendar(placeholder, calendar) : $a1a093054004b094$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
264
|
}, [
|
|
@@ -268,8 +268,8 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
268
268
|
defaultTimeZone,
|
|
269
269
|
props.placeholderValue
|
|
270
270
|
]);
|
|
271
|
-
let [value1, setDate] = $
|
|
272
|
-
let calendarValue = $
|
|
271
|
+
let [value1, setDate] = $17UYf$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
272
|
+
let calendarValue = $17UYf$react.useMemo(()=>$a1a093054004b094$export$61a490a80c552550(value1, calendar)
|
|
273
273
|
, [
|
|
274
274
|
value1,
|
|
275
275
|
calendar
|
|
@@ -286,7 +286,7 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
286
286
|
validSegments = {
|
|
287
287
|
};
|
|
288
288
|
setValidSegments(validSegments);
|
|
289
|
-
setPlaceholderDate($
|
|
289
|
+
setPlaceholderDate($a1a093054004b094$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
290
290
|
}
|
|
291
291
|
// If all segments are valid, use the date from state, otherwise use the placeholder date.
|
|
292
292
|
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
|
|
@@ -295,23 +295,23 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
295
295
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) {
|
|
296
296
|
// The display calendar should not have any effect on the emitted value.
|
|
297
297
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
298
|
-
newValue = $
|
|
298
|
+
newValue = $17UYf$internationalizeddate.toCalendar(newValue, v1?.calendar || new $17UYf$internationalizeddate.GregorianCalendar());
|
|
299
299
|
setDate(newValue);
|
|
300
300
|
} else setPlaceholderDate(newValue);
|
|
301
301
|
};
|
|
302
|
-
let dateValue = $
|
|
302
|
+
let dateValue = $17UYf$react.useMemo(()=>displayValue.toDate(timeZone)
|
|
303
303
|
, [
|
|
304
304
|
displayValue,
|
|
305
305
|
timeZone
|
|
306
306
|
]);
|
|
307
|
-
let segments = $
|
|
308
|
-
let isEditable = $
|
|
307
|
+
let segments = $17UYf$react.useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
308
|
+
let isEditable = $f23cc841f3588f43$var$EDITABLE_SEGMENTS[segment.type];
|
|
309
309
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
310
310
|
return {
|
|
311
|
-
type: $
|
|
311
|
+
type: $f23cc841f3588f43$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
312
312
|
text: segment.value,
|
|
313
|
-
...$
|
|
314
|
-
isPlaceholder: $
|
|
313
|
+
...$f23cc841f3588f43$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
314
|
+
isPlaceholder: $f23cc841f3588f43$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type],
|
|
315
315
|
isEditable: isEditable
|
|
316
316
|
};
|
|
317
317
|
})
|
|
@@ -323,7 +323,7 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
323
323
|
displayValue,
|
|
324
324
|
calendar
|
|
325
325
|
]);
|
|
326
|
-
let hasEra = $
|
|
326
|
+
let hasEra = $17UYf$react.useMemo(()=>segments.some((s)=>s.type === 'era'
|
|
327
327
|
)
|
|
328
328
|
, [
|
|
329
329
|
segments
|
|
@@ -337,9 +337,9 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
337
337
|
};
|
|
338
338
|
let adjustSegment = (type, amount)=>{
|
|
339
339
|
markValid(type);
|
|
340
|
-
setValue($
|
|
340
|
+
setValue($f23cc841f3588f43$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
341
341
|
};
|
|
342
|
-
let validationState = props.validationState || ($
|
|
342
|
+
let validationState = props.validationState || ($a1a093054004b094$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
343
343
|
return {
|
|
344
344
|
value: calendarValue,
|
|
345
345
|
dateValue: dateValue,
|
|
@@ -355,14 +355,14 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
355
355
|
adjustSegment(part, -1);
|
|
356
356
|
},
|
|
357
357
|
incrementPage (part) {
|
|
358
|
-
adjustSegment(part, $
|
|
358
|
+
adjustSegment(part, $f23cc841f3588f43$var$PAGE_STEP[part] || 1);
|
|
359
359
|
},
|
|
360
360
|
decrementPage (part) {
|
|
361
|
-
adjustSegment(part, -($
|
|
361
|
+
adjustSegment(part, -($f23cc841f3588f43$var$PAGE_STEP[part] || 1));
|
|
362
362
|
},
|
|
363
363
|
setSegment (part, v) {
|
|
364
364
|
markValid(part);
|
|
365
|
-
setValue($
|
|
365
|
+
setValue($f23cc841f3588f43$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
366
366
|
},
|
|
367
367
|
confirmPlaceholder (part) {
|
|
368
368
|
if (props.isDisabled || props.isReadOnly) return;
|
|
@@ -386,7 +386,7 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
386
386
|
setValidSegments({
|
|
387
387
|
...validSegments
|
|
388
388
|
});
|
|
389
|
-
let placeholder = $
|
|
389
|
+
let placeholder = $a1a093054004b094$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
390
390
|
let value = displayValue;
|
|
391
391
|
// Reset day period to default without changing the hour.
|
|
392
392
|
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
@@ -405,11 +405,11 @@ function $db920376312b84b4$export$714a241b39a650d6(props) {
|
|
|
405
405
|
setValue(value);
|
|
406
406
|
},
|
|
407
407
|
getFormatOptions (fieldOptions) {
|
|
408
|
-
return $
|
|
408
|
+
return $a1a093054004b094$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
|
-
function $
|
|
412
|
+
function $f23cc841f3588f43$var$getSegmentLimits(date, type, options) {
|
|
413
413
|
switch(type){
|
|
414
414
|
case 'era':
|
|
415
415
|
{
|
|
@@ -429,13 +429,13 @@ function $db920376312b84b4$var$getSegmentLimits(date, type, options) {
|
|
|
429
429
|
case 'month':
|
|
430
430
|
return {
|
|
431
431
|
value: date.month,
|
|
432
|
-
minValue: $
|
|
432
|
+
minValue: $17UYf$internationalizeddate.getMinimumMonthInYear(date),
|
|
433
433
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
434
434
|
};
|
|
435
435
|
case 'day':
|
|
436
436
|
return {
|
|
437
437
|
value: date.day,
|
|
438
|
-
minValue: $
|
|
438
|
+
minValue: $17UYf$internationalizeddate.getMinimumDayInMonth(date),
|
|
439
439
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
440
440
|
};
|
|
441
441
|
}
|
|
@@ -476,7 +476,7 @@ function $db920376312b84b4$var$getSegmentLimits(date, type, options) {
|
|
|
476
476
|
return {
|
|
477
477
|
};
|
|
478
478
|
}
|
|
479
|
-
function $
|
|
479
|
+
function $f23cc841f3588f43$var$addSegment(value, part, amount, options) {
|
|
480
480
|
switch(part){
|
|
481
481
|
case 'era':
|
|
482
482
|
case 'year':
|
|
@@ -504,7 +504,7 @@ function $db920376312b84b4$var$addSegment(value, part, amount, options) {
|
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
function $
|
|
507
|
+
function $f23cc841f3588f43$var$setSegment(value, part, segmentValue, options) {
|
|
508
508
|
switch(part){
|
|
509
509
|
case 'day':
|
|
510
510
|
case 'month':
|
|
@@ -542,17 +542,17 @@ function $db920376312b84b4$var$setSegment(value, part, segmentValue, options) {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
|
|
545
|
-
var $
|
|
545
|
+
var $85a6c757c811abb9$exports = {};
|
|
546
546
|
|
|
547
|
-
$parcel$export($
|
|
547
|
+
$parcel$export($85a6c757c811abb9$exports, "useDateRangePickerState", () => $85a6c757c811abb9$export$e50a61c1de9f574);
|
|
548
548
|
|
|
549
549
|
|
|
550
550
|
|
|
551
551
|
|
|
552
|
-
function $
|
|
553
|
-
let [isOpen1, setOpen] = $
|
|
554
|
-
let [controlledValue, setControlledValue] = $
|
|
555
|
-
let [placeholderValue, setPlaceholderValue] = $
|
|
552
|
+
function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
553
|
+
let [isOpen1, setOpen] = $17UYf$react.useState(false);
|
|
554
|
+
let [controlledValue, setControlledValue] = $17UYf$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
555
|
+
let [placeholderValue, setPlaceholderValue] = $17UYf$react.useState(()=>controlledValue || {
|
|
556
556
|
start: null,
|
|
557
557
|
end: null
|
|
558
558
|
}
|
|
@@ -566,7 +566,7 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
566
566
|
setPlaceholderValue(placeholderValue);
|
|
567
567
|
}
|
|
568
568
|
let value1 = controlledValue || placeholderValue;
|
|
569
|
-
let valueRef = $
|
|
569
|
+
let valueRef = $17UYf$react.useRef(value1);
|
|
570
570
|
valueRef.current = value1;
|
|
571
571
|
let setValue = (value)=>{
|
|
572
572
|
valueRef.current = value;
|
|
@@ -575,18 +575,18 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
575
575
|
else setControlledValue(null);
|
|
576
576
|
};
|
|
577
577
|
let v = value1?.start || value1?.end || props.placeholderValue;
|
|
578
|
-
let [granularity, defaultTimeZone] = $
|
|
578
|
+
let [granularity, defaultTimeZone] = $a1a093054004b094$export$2440da353cedad43(v, props.granularity);
|
|
579
579
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
580
|
-
let [dateRange1, setSelectedDateRange] = $
|
|
581
|
-
let [timeRange1, setSelectedTimeRange] = $
|
|
580
|
+
let [dateRange1, setSelectedDateRange] = $17UYf$react.useState(null);
|
|
581
|
+
let [timeRange1, setSelectedTimeRange] = $17UYf$react.useState(null);
|
|
582
582
|
if (value1 && value1.start && value1.end) {
|
|
583
583
|
dateRange1 = value1;
|
|
584
584
|
if ('hour' in value1.start) timeRange1 = value1;
|
|
585
585
|
}
|
|
586
586
|
let commitValue = (dateRange, timeRange)=>{
|
|
587
587
|
setValue({
|
|
588
|
-
start: 'timeZone' in timeRange.start ? timeRange.start.set($
|
|
589
|
-
end: 'timeZone' in timeRange.end ? timeRange.end.set($
|
|
588
|
+
start: 'timeZone' in timeRange.start ? timeRange.start.set($17UYf$internationalizeddate.toDateFields(dateRange.start)) : $17UYf$internationalizeddate.toCalendarDateTime(dateRange.start, timeRange.start),
|
|
589
|
+
end: 'timeZone' in timeRange.end ? timeRange.end.set($17UYf$internationalizeddate.toDateFields(dateRange.end)) : $17UYf$internationalizeddate.toCalendarDateTime(dateRange.end, timeRange.end)
|
|
590
590
|
});
|
|
591
591
|
};
|
|
592
592
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
@@ -602,7 +602,7 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
602
602
|
if (dateRange1?.start && dateRange1?.end && range.start && range.end) commitValue(dateRange1, range);
|
|
603
603
|
else setSelectedTimeRange(range);
|
|
604
604
|
};
|
|
605
|
-
let validationState = props.validationState || (value1 != null && ($
|
|
605
|
+
let validationState = props.validationState || (value1 != null && ($a1a093054004b094$export$eac50920cf2fd59a(value1.start, props.minValue, props.maxValue) || $a1a093054004b094$export$eac50920cf2fd59a(value1.end, props.minValue, props.maxValue) || value1.end != null && value1.start != null && value1.end.compare(value1.start) < 0) ? 'invalid' : null);
|
|
606
606
|
return {
|
|
607
607
|
value: value1,
|
|
608
608
|
setValue: setValue,
|
|
@@ -635,8 +635,8 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
635
635
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
636
636
|
// the user opens the popover again.
|
|
637
637
|
if (!isOpen && !(value1?.start && value1?.end) && dateRange1?.start && dateRange1?.end && hasTime) commitValue(dateRange1, {
|
|
638
|
-
start: timeRange1?.start || $
|
|
639
|
-
end: timeRange1?.end || $
|
|
638
|
+
start: timeRange1?.start || $a1a093054004b094$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
639
|
+
end: timeRange1?.end || $a1a093054004b094$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
640
640
|
});
|
|
641
641
|
setOpen(isOpen);
|
|
642
642
|
},
|
|
@@ -647,13 +647,13 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
647
647
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
648
648
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
649
649
|
let endGranularity = props.granularity || (value1.end && 'minute' in value1.end ? 'minute' : 'day');
|
|
650
|
-
let startOptions = $
|
|
650
|
+
let startOptions = $a1a093054004b094$export$7e319ea407e63bc0(fieldOptions, {
|
|
651
651
|
granularity: startGranularity,
|
|
652
652
|
timeZone: startTimeZone,
|
|
653
653
|
hideTimeZone: props.hideTimeZone,
|
|
654
654
|
hourCycle: props.hourCycle
|
|
655
655
|
});
|
|
656
|
-
let startFormatter = new $
|
|
656
|
+
let startFormatter = new $17UYf$internationalizeddate.DateFormatter(locale, startOptions);
|
|
657
657
|
let endFormatter;
|
|
658
658
|
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
659
659
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
@@ -666,13 +666,13 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
666
666
|
}
|
|
667
667
|
endFormatter = startFormatter;
|
|
668
668
|
} else {
|
|
669
|
-
let endOptions = $
|
|
669
|
+
let endOptions = $a1a093054004b094$export$7e319ea407e63bc0(fieldOptions, {
|
|
670
670
|
granularity: endGranularity,
|
|
671
671
|
timeZone: endTimeZone,
|
|
672
672
|
hideTimeZone: props.hideTimeZone,
|
|
673
673
|
hourCycle: props.hourCycle
|
|
674
674
|
});
|
|
675
|
-
endFormatter = new $
|
|
675
|
+
endFormatter = new $17UYf$internationalizeddate.DateFormatter(locale, endOptions);
|
|
676
676
|
}
|
|
677
677
|
return `${startFormatter.format(value1.start.toDate(startTimeZone))} – ${endFormatter.format(value1.end.toDate(endTimeZone))}`;
|
|
678
678
|
},
|
|
@@ -682,7 +682,7 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
682
682
|
let value = valueRef.current;
|
|
683
683
|
if (value && Boolean(value.start) !== Boolean(value.end)) {
|
|
684
684
|
let calendar = (value.start || value.end).calendar;
|
|
685
|
-
let placeholder = $
|
|
685
|
+
let placeholder = $a1a093054004b094$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
686
686
|
setValue({
|
|
687
687
|
start: value.start || placeholder,
|
|
688
688
|
end: value.end || placeholder
|
|
@@ -693,40 +693,40 @@ function $142433ca1a8bbced$export$e50a61c1de9f574(props) {
|
|
|
693
693
|
}
|
|
694
694
|
|
|
695
695
|
|
|
696
|
-
var $
|
|
696
|
+
var $ef228128a792346b$exports = {};
|
|
697
697
|
|
|
698
|
-
$parcel$export($
|
|
698
|
+
$parcel$export($ef228128a792346b$exports, "useTimeFieldState", () => $ef228128a792346b$export$fd53cef0cc796101);
|
|
699
699
|
|
|
700
700
|
|
|
701
701
|
|
|
702
702
|
|
|
703
|
-
function $
|
|
704
|
-
let { placeholderValue: placeholderValue = new $
|
|
705
|
-
let [value, setValue] = $
|
|
703
|
+
function $ef228128a792346b$export$fd53cef0cc796101(props) {
|
|
704
|
+
let { placeholderValue: placeholderValue = new $17UYf$internationalizeddate.Time() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
705
|
+
let [value, setValue] = $17UYf$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
706
706
|
let v = value || placeholderValue;
|
|
707
707
|
let day = v && 'day' in v ? v : undefined;
|
|
708
|
-
let placeholderDate = $
|
|
708
|
+
let placeholderDate = $17UYf$react.useMemo(()=>$ef228128a792346b$var$convertValue(placeholderValue)
|
|
709
709
|
, [
|
|
710
710
|
placeholderValue
|
|
711
711
|
]);
|
|
712
|
-
let minDate = $
|
|
712
|
+
let minDate = $17UYf$react.useMemo(()=>$ef228128a792346b$var$convertValue(minValue, day)
|
|
713
713
|
, [
|
|
714
714
|
minValue,
|
|
715
715
|
day
|
|
716
716
|
]);
|
|
717
|
-
let maxDate = $
|
|
717
|
+
let maxDate = $17UYf$react.useMemo(()=>$ef228128a792346b$var$convertValue(maxValue, day)
|
|
718
718
|
, [
|
|
719
719
|
maxValue,
|
|
720
720
|
day
|
|
721
721
|
]);
|
|
722
|
-
let dateTime = $
|
|
722
|
+
let dateTime = $17UYf$react.useMemo(()=>value == null ? null : $ef228128a792346b$var$convertValue(value)
|
|
723
723
|
, [
|
|
724
724
|
value
|
|
725
725
|
]);
|
|
726
726
|
let onChange = (newValue)=>{
|
|
727
|
-
setValue(v && 'day' in v ? newValue : newValue && $
|
|
727
|
+
setValue(v && 'day' in v ? newValue : newValue && $17UYf$internationalizeddate.toTime(newValue));
|
|
728
728
|
};
|
|
729
|
-
return $
|
|
729
|
+
return $f23cc841f3588f43$export$714a241b39a650d6({
|
|
730
730
|
...props,
|
|
731
731
|
value: dateTime,
|
|
732
732
|
defaultValue: undefined,
|
|
@@ -738,17 +738,17 @@ function $15e3a6cb74406331$export$fd53cef0cc796101(props) {
|
|
|
738
738
|
placeholderValue: placeholderDate
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
|
-
function $
|
|
741
|
+
function $ef228128a792346b$var$convertValue(value, date = $17UYf$internationalizeddate.today($17UYf$internationalizeddate.getLocalTimeZone())) {
|
|
742
742
|
if (!value) return null;
|
|
743
743
|
if ('day' in value) return value;
|
|
744
|
-
return $
|
|
744
|
+
return $17UYf$internationalizeddate.toCalendarDateTime(date, value);
|
|
745
745
|
}
|
|
746
746
|
|
|
747
747
|
|
|
748
|
-
$parcel$exportWildcard(module.exports, $
|
|
749
|
-
$parcel$exportWildcard(module.exports, $
|
|
750
|
-
$parcel$exportWildcard(module.exports, $
|
|
751
|
-
$parcel$exportWildcard(module.exports, $
|
|
748
|
+
$parcel$exportWildcard(module.exports, $0c9ae69d60d14242$exports);
|
|
749
|
+
$parcel$exportWildcard(module.exports, $f23cc841f3588f43$exports);
|
|
750
|
+
$parcel$exportWildcard(module.exports, $85a6c757c811abb9$exports);
|
|
751
|
+
$parcel$exportWildcard(module.exports, $ef228128a792346b$exports);
|
|
752
752
|
|
|
753
753
|
|
|
754
754
|
//# sourceMappingURL=main.js.map
|
package/dist/module.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {toDateFields as $
|
|
2
|
-
import {useControlledState as $
|
|
3
|
-
import {useState as $
|
|
1
|
+
import {toDateFields as $j2a4F$toDateFields, toCalendarDateTime as $j2a4F$toCalendarDateTime, DateFormatter as $j2a4F$DateFormatter, Time as $j2a4F$Time, toCalendar as $j2a4F$toCalendar, now as $j2a4F$now, toCalendarDate as $j2a4F$toCalendarDate, GregorianCalendar as $j2a4F$GregorianCalendar, getMinimumMonthInYear as $j2a4F$getMinimumMonthInYear, getMinimumDayInMonth as $j2a4F$getMinimumDayInMonth, toTime as $j2a4F$toTime, today as $j2a4F$today, getLocalTimeZone as $j2a4F$getLocalTimeZone} from "@internationalized/date";
|
|
2
|
+
import {useControlledState as $j2a4F$useControlledState} from "@react-stately/utils";
|
|
3
|
+
import {useState as $j2a4F$useState, useRef as $j2a4F$useRef, useMemo as $j2a4F$useMemo, useEffect as $j2a4F$useEffect} from "react";
|
|
4
4
|
|
|
5
5
|
function $parcel$export(e, n, v, s) {
|
|
6
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
7
|
}
|
|
8
|
-
var $
|
|
8
|
+
var $e9af7896aa0f34cc$exports = {};
|
|
9
9
|
|
|
10
|
-
$parcel$export($
|
|
10
|
+
$parcel$export($e9af7896aa0f34cc$exports, "useDatePickerState", () => $e9af7896aa0f34cc$export$87194bb378cc3ac2);
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
function $
|
|
14
|
+
function $1041af8c30a3d476$export$eac50920cf2fd59a(value, minValue, maxValue) {
|
|
15
15
|
return value != null && (minValue != null && value.compare(minValue) < 0 || maxValue != null && value.compare(maxValue) > 0);
|
|
16
16
|
}
|
|
17
|
-
const $
|
|
17
|
+
const $1041af8c30a3d476$var$DEFAULT_FIELD_OPTIONS = {
|
|
18
18
|
year: 'numeric',
|
|
19
19
|
month: 'numeric',
|
|
20
20
|
day: 'numeric',
|
|
@@ -22,9 +22,9 @@ const $0482414725a5065f$var$DEFAULT_FIELD_OPTIONS = {
|
|
|
22
22
|
minute: '2-digit',
|
|
23
23
|
second: '2-digit'
|
|
24
24
|
};
|
|
25
|
-
function $
|
|
25
|
+
function $1041af8c30a3d476$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
26
26
|
fieldOptions = {
|
|
27
|
-
...$
|
|
27
|
+
...$1041af8c30a3d476$var$DEFAULT_FIELD_OPTIONS,
|
|
28
28
|
...fieldOptions
|
|
29
29
|
};
|
|
30
30
|
let granularity = options.granularity || 'minute';
|
|
@@ -45,30 +45,30 @@ function $0482414725a5065f$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
45
45
|
if (hasTime && options.timeZone && !options.hideTimeZone) opts1.timeZoneName = 'short';
|
|
46
46
|
return opts1;
|
|
47
47
|
}
|
|
48
|
-
function $
|
|
48
|
+
function $1041af8c30a3d476$export$c5221a78ef73c5e9(placeholderValue) {
|
|
49
49
|
if (placeholderValue && 'hour' in placeholderValue) return placeholderValue;
|
|
50
|
-
return new $
|
|
50
|
+
return new $j2a4F$Time();
|
|
51
51
|
}
|
|
52
|
-
function $
|
|
52
|
+
function $1041af8c30a3d476$export$61a490a80c552550(value, calendar) {
|
|
53
53
|
if (value === null) return null;
|
|
54
54
|
if (!value) return undefined;
|
|
55
|
-
return $
|
|
55
|
+
return $j2a4F$toCalendar(value, calendar);
|
|
56
56
|
}
|
|
57
|
-
function $
|
|
58
|
-
if (placeholderValue) return $
|
|
59
|
-
let date = $
|
|
57
|
+
function $1041af8c30a3d476$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
|
|
58
|
+
if (placeholderValue) return $1041af8c30a3d476$export$61a490a80c552550(placeholderValue, calendar);
|
|
59
|
+
let date = $j2a4F$toCalendar($j2a4F$now(timeZone).set({
|
|
60
60
|
hour: 0,
|
|
61
61
|
minute: 0,
|
|
62
62
|
second: 0,
|
|
63
63
|
millisecond: 0
|
|
64
64
|
}), calendar);
|
|
65
|
-
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $
|
|
66
|
-
if (!timeZone) return $
|
|
65
|
+
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $j2a4F$toCalendarDate(date);
|
|
66
|
+
if (!timeZone) return $j2a4F$toCalendarDateTime(date);
|
|
67
67
|
return date;
|
|
68
68
|
}
|
|
69
|
-
function $
|
|
69
|
+
function $1041af8c30a3d476$export$2440da353cedad43(v, granularity) {
|
|
70
70
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
71
|
-
let lastValue = $
|
|
71
|
+
let lastValue = $j2a4F$useRef(v);
|
|
72
72
|
if (v) lastValue.current = v;
|
|
73
73
|
v = lastValue.current;
|
|
74
74
|
let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
@@ -85,15 +85,15 @@ function $0482414725a5065f$export$2440da353cedad43(v, granularity) {
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
function $
|
|
89
|
-
let [isOpen1, setOpen] = $
|
|
90
|
-
let [value, setValue] = $
|
|
88
|
+
function $e9af7896aa0f34cc$export$87194bb378cc3ac2(props) {
|
|
89
|
+
let [isOpen1, setOpen] = $j2a4F$useState(false);
|
|
90
|
+
let [value, setValue] = $j2a4F$useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
91
91
|
let v = value || props.placeholderValue;
|
|
92
|
-
let [granularity, defaultTimeZone] = $
|
|
92
|
+
let [granularity, defaultTimeZone] = $1041af8c30a3d476$export$2440da353cedad43(v, props.granularity);
|
|
93
93
|
let dateValue = value != null ? value.toDate(defaultTimeZone ?? 'UTC') : null;
|
|
94
94
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
95
|
-
let [selectedDate, setSelectedDate] = $
|
|
96
|
-
let [selectedTime, setSelectedTime] = $
|
|
95
|
+
let [selectedDate, setSelectedDate] = $j2a4F$useState(null);
|
|
96
|
+
let [selectedTime, setSelectedTime] = $j2a4F$useState(null);
|
|
97
97
|
if (value) {
|
|
98
98
|
selectedDate = value;
|
|
99
99
|
if ('hour' in value) selectedTime = value;
|
|
@@ -101,7 +101,7 @@ function $26fdc69faf7f6df5$export$87194bb378cc3ac2(props) {
|
|
|
101
101
|
// props.granularity must actually exist in the value if one is provided.
|
|
102
102
|
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
103
103
|
let commitValue = (date, time)=>{
|
|
104
|
-
setValue('timeZone' in time ? time.set($
|
|
104
|
+
setValue('timeZone' in time ? time.set($j2a4F$toDateFields(date)) : $j2a4F$toCalendarDateTime(date, time));
|
|
105
105
|
};
|
|
106
106
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
107
107
|
let selectDate = (newValue)=>{
|
|
@@ -115,7 +115,7 @@ function $26fdc69faf7f6df5$export$87194bb378cc3ac2(props) {
|
|
|
115
115
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
116
116
|
else setSelectedTime(newValue);
|
|
117
117
|
};
|
|
118
|
-
let validationState = props.validationState || ($
|
|
118
|
+
let validationState = props.validationState || ($1041af8c30a3d476$export$eac50920cf2fd59a(value, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
119
119
|
return {
|
|
120
120
|
value: value,
|
|
121
121
|
setValue: setValue,
|
|
@@ -129,33 +129,33 @@ function $26fdc69faf7f6df5$export$87194bb378cc3ac2(props) {
|
|
|
129
129
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
130
130
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
131
131
|
// the user opens the popover again.
|
|
132
|
-
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $
|
|
132
|
+
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $1041af8c30a3d476$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
133
133
|
setOpen(isOpen);
|
|
134
134
|
},
|
|
135
135
|
validationState: validationState,
|
|
136
136
|
formatValue (locale, fieldOptions) {
|
|
137
137
|
if (!dateValue) return '';
|
|
138
|
-
let formatOptions = $
|
|
138
|
+
let formatOptions = $1041af8c30a3d476$export$7e319ea407e63bc0(fieldOptions, {
|
|
139
139
|
granularity: granularity,
|
|
140
140
|
timeZone: defaultTimeZone,
|
|
141
141
|
hideTimeZone: props.hideTimeZone,
|
|
142
142
|
hourCycle: props.hourCycle
|
|
143
143
|
});
|
|
144
|
-
let formatter = new $
|
|
144
|
+
let formatter = new $j2a4F$DateFormatter(locale, formatOptions);
|
|
145
145
|
return formatter.format(dateValue);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
var $
|
|
151
|
+
var $4398a1af81ae1348$exports = {};
|
|
152
152
|
|
|
153
|
-
$parcel$export($
|
|
153
|
+
$parcel$export($4398a1af81ae1348$exports, "useDatePickerFieldState", () => $4398a1af81ae1348$export$714a241b39a650d6);
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
const $
|
|
158
|
+
const $4398a1af81ae1348$var$EDITABLE_SEGMENTS = {
|
|
159
159
|
year: true,
|
|
160
160
|
month: true,
|
|
161
161
|
day: true,
|
|
@@ -165,7 +165,7 @@ const $14e72de17b214ee8$var$EDITABLE_SEGMENTS = {
|
|
|
165
165
|
dayPeriod: true,
|
|
166
166
|
era: true
|
|
167
167
|
};
|
|
168
|
-
const $
|
|
168
|
+
const $4398a1af81ae1348$var$PAGE_STEP = {
|
|
169
169
|
year: 5,
|
|
170
170
|
month: 2,
|
|
171
171
|
day: 7,
|
|
@@ -174,17 +174,17 @@ const $14e72de17b214ee8$var$PAGE_STEP = {
|
|
|
174
174
|
second: 15
|
|
175
175
|
};
|
|
176
176
|
// Node seems to convert everything to lowercase...
|
|
177
|
-
const $
|
|
177
|
+
const $4398a1af81ae1348$var$TYPE_MAPPING = {
|
|
178
178
|
dayperiod: 'dayPeriod'
|
|
179
179
|
};
|
|
180
|
-
function $
|
|
180
|
+
function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
181
181
|
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone } = props;
|
|
182
182
|
let v1 = props.value || props.defaultValue || props.placeholderValue;
|
|
183
|
-
let [granularity, defaultTimeZone] = $
|
|
183
|
+
let [granularity, defaultTimeZone] = $1041af8c30a3d476$export$2440da353cedad43(v1, props.granularity);
|
|
184
184
|
let timeZone = defaultTimeZone || 'UTC';
|
|
185
185
|
// props.granularity must actually exist in the value if one is provided.
|
|
186
186
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
187
|
-
let formatOpts = $
|
|
187
|
+
let formatOpts = $j2a4F$useMemo(()=>({
|
|
188
188
|
granularity: granularity,
|
|
189
189
|
maxGranularity: props.maxGranularity ?? 'year',
|
|
190
190
|
timeZone: defaultTimeZone,
|
|
@@ -198,35 +198,35 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
198
198
|
defaultTimeZone,
|
|
199
199
|
hideTimeZone
|
|
200
200
|
]);
|
|
201
|
-
let opts = $
|
|
201
|
+
let opts = $j2a4F$useMemo(()=>$1041af8c30a3d476$export$7e319ea407e63bc0({
|
|
202
202
|
}, formatOpts)
|
|
203
203
|
, [
|
|
204
204
|
formatOpts
|
|
205
205
|
]);
|
|
206
|
-
let dateFormatter = $
|
|
206
|
+
let dateFormatter = $j2a4F$useMemo(()=>new $j2a4F$DateFormatter(locale, opts)
|
|
207
207
|
, [
|
|
208
208
|
locale,
|
|
209
209
|
opts
|
|
210
210
|
]);
|
|
211
|
-
let resolvedOptions = $
|
|
211
|
+
let resolvedOptions = $j2a4F$useMemo(()=>dateFormatter.resolvedOptions()
|
|
212
212
|
, [
|
|
213
213
|
dateFormatter
|
|
214
214
|
]);
|
|
215
|
-
let calendar = $
|
|
215
|
+
let calendar = $j2a4F$useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
216
216
|
, [
|
|
217
217
|
createCalendar,
|
|
218
218
|
resolvedOptions.calendar
|
|
219
219
|
]);
|
|
220
220
|
// Determine how many editable segments there are for validation purposes.
|
|
221
221
|
// The result is cached for performance.
|
|
222
|
-
let allSegments = $
|
|
222
|
+
let allSegments = $j2a4F$useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$4398a1af81ae1348$var$EDITABLE_SEGMENTS[seg.type]
|
|
223
223
|
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
224
224
|
, {
|
|
225
225
|
})
|
|
226
226
|
, [
|
|
227
227
|
dateFormatter
|
|
228
228
|
]);
|
|
229
|
-
let [validSegments, setValidSegments] = $
|
|
229
|
+
let [validSegments, setValidSegments] = $j2a4F$useState(()=>props.value || props.defaultValue ? {
|
|
230
230
|
...allSegments
|
|
231
231
|
} : {
|
|
232
232
|
}
|
|
@@ -235,14 +235,14 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
235
235
|
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
236
236
|
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
237
237
|
// change from uncontrolled to controlled and emit a warning.
|
|
238
|
-
let [placeholderDate, setPlaceholderDate] = $
|
|
238
|
+
let [placeholderDate, setPlaceholderDate] = $j2a4F$useState(()=>$1041af8c30a3d476$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
239
239
|
);
|
|
240
240
|
// Reset placeholder when calendar changes
|
|
241
|
-
let lastCalendarIdentifier = $
|
|
242
|
-
$
|
|
241
|
+
let lastCalendarIdentifier = $j2a4F$useRef(calendar.identifier);
|
|
242
|
+
$j2a4F$useEffect(()=>{
|
|
243
243
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
244
244
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
245
|
-
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $
|
|
245
|
+
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $j2a4F$toCalendar(placeholder, calendar) : $1041af8c30a3d476$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
248
|
}, [
|
|
@@ -252,8 +252,8 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
252
252
|
defaultTimeZone,
|
|
253
253
|
props.placeholderValue
|
|
254
254
|
]);
|
|
255
|
-
let [value1, setDate] = $
|
|
256
|
-
let calendarValue = $
|
|
255
|
+
let [value1, setDate] = $j2a4F$useControlledState(props.value, props.defaultValue, props.onChange);
|
|
256
|
+
let calendarValue = $j2a4F$useMemo(()=>$1041af8c30a3d476$export$61a490a80c552550(value1, calendar)
|
|
257
257
|
, [
|
|
258
258
|
value1,
|
|
259
259
|
calendar
|
|
@@ -270,7 +270,7 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
270
270
|
validSegments = {
|
|
271
271
|
};
|
|
272
272
|
setValidSegments(validSegments);
|
|
273
|
-
setPlaceholderDate($
|
|
273
|
+
setPlaceholderDate($1041af8c30a3d476$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
274
274
|
}
|
|
275
275
|
// If all segments are valid, use the date from state, otherwise use the placeholder date.
|
|
276
276
|
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
|
|
@@ -279,23 +279,23 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
279
279
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) {
|
|
280
280
|
// The display calendar should not have any effect on the emitted value.
|
|
281
281
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
282
|
-
newValue = $
|
|
282
|
+
newValue = $j2a4F$toCalendar(newValue, v1?.calendar || new $j2a4F$GregorianCalendar());
|
|
283
283
|
setDate(newValue);
|
|
284
284
|
} else setPlaceholderDate(newValue);
|
|
285
285
|
};
|
|
286
|
-
let dateValue = $
|
|
286
|
+
let dateValue = $j2a4F$useMemo(()=>displayValue.toDate(timeZone)
|
|
287
287
|
, [
|
|
288
288
|
displayValue,
|
|
289
289
|
timeZone
|
|
290
290
|
]);
|
|
291
|
-
let segments = $
|
|
292
|
-
let isEditable = $
|
|
291
|
+
let segments = $j2a4F$useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
292
|
+
let isEditable = $4398a1af81ae1348$var$EDITABLE_SEGMENTS[segment.type];
|
|
293
293
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
294
294
|
return {
|
|
295
|
-
type: $
|
|
295
|
+
type: $4398a1af81ae1348$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
296
296
|
text: segment.value,
|
|
297
|
-
...$
|
|
298
|
-
isPlaceholder: $
|
|
297
|
+
...$4398a1af81ae1348$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
298
|
+
isPlaceholder: $4398a1af81ae1348$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type],
|
|
299
299
|
isEditable: isEditable
|
|
300
300
|
};
|
|
301
301
|
})
|
|
@@ -307,7 +307,7 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
307
307
|
displayValue,
|
|
308
308
|
calendar
|
|
309
309
|
]);
|
|
310
|
-
let hasEra = $
|
|
310
|
+
let hasEra = $j2a4F$useMemo(()=>segments.some((s)=>s.type === 'era'
|
|
311
311
|
)
|
|
312
312
|
, [
|
|
313
313
|
segments
|
|
@@ -321,9 +321,9 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
321
321
|
};
|
|
322
322
|
let adjustSegment = (type, amount)=>{
|
|
323
323
|
markValid(type);
|
|
324
|
-
setValue($
|
|
324
|
+
setValue($4398a1af81ae1348$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
325
325
|
};
|
|
326
|
-
let validationState = props.validationState || ($
|
|
326
|
+
let validationState = props.validationState || ($1041af8c30a3d476$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
327
327
|
return {
|
|
328
328
|
value: calendarValue,
|
|
329
329
|
dateValue: dateValue,
|
|
@@ -339,14 +339,14 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
339
339
|
adjustSegment(part, -1);
|
|
340
340
|
},
|
|
341
341
|
incrementPage (part) {
|
|
342
|
-
adjustSegment(part, $
|
|
342
|
+
adjustSegment(part, $4398a1af81ae1348$var$PAGE_STEP[part] || 1);
|
|
343
343
|
},
|
|
344
344
|
decrementPage (part) {
|
|
345
|
-
adjustSegment(part, -($
|
|
345
|
+
adjustSegment(part, -($4398a1af81ae1348$var$PAGE_STEP[part] || 1));
|
|
346
346
|
},
|
|
347
347
|
setSegment (part, v) {
|
|
348
348
|
markValid(part);
|
|
349
|
-
setValue($
|
|
349
|
+
setValue($4398a1af81ae1348$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
350
350
|
},
|
|
351
351
|
confirmPlaceholder (part) {
|
|
352
352
|
if (props.isDisabled || props.isReadOnly) return;
|
|
@@ -370,7 +370,7 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
370
370
|
setValidSegments({
|
|
371
371
|
...validSegments
|
|
372
372
|
});
|
|
373
|
-
let placeholder = $
|
|
373
|
+
let placeholder = $1041af8c30a3d476$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
374
374
|
let value = displayValue;
|
|
375
375
|
// Reset day period to default without changing the hour.
|
|
376
376
|
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
@@ -389,11 +389,11 @@ function $14e72de17b214ee8$export$714a241b39a650d6(props) {
|
|
|
389
389
|
setValue(value);
|
|
390
390
|
},
|
|
391
391
|
getFormatOptions (fieldOptions) {
|
|
392
|
-
return $
|
|
392
|
+
return $1041af8c30a3d476$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
|
-
function $
|
|
396
|
+
function $4398a1af81ae1348$var$getSegmentLimits(date, type, options) {
|
|
397
397
|
switch(type){
|
|
398
398
|
case 'era':
|
|
399
399
|
{
|
|
@@ -413,13 +413,13 @@ function $14e72de17b214ee8$var$getSegmentLimits(date, type, options) {
|
|
|
413
413
|
case 'month':
|
|
414
414
|
return {
|
|
415
415
|
value: date.month,
|
|
416
|
-
minValue: $
|
|
416
|
+
minValue: $j2a4F$getMinimumMonthInYear(date),
|
|
417
417
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
418
418
|
};
|
|
419
419
|
case 'day':
|
|
420
420
|
return {
|
|
421
421
|
value: date.day,
|
|
422
|
-
minValue: $
|
|
422
|
+
minValue: $j2a4F$getMinimumDayInMonth(date),
|
|
423
423
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
424
424
|
};
|
|
425
425
|
}
|
|
@@ -460,7 +460,7 @@ function $14e72de17b214ee8$var$getSegmentLimits(date, type, options) {
|
|
|
460
460
|
return {
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
|
-
function $
|
|
463
|
+
function $4398a1af81ae1348$var$addSegment(value, part, amount, options) {
|
|
464
464
|
switch(part){
|
|
465
465
|
case 'era':
|
|
466
466
|
case 'year':
|
|
@@ -488,7 +488,7 @@ function $14e72de17b214ee8$var$addSegment(value, part, amount, options) {
|
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
function $
|
|
491
|
+
function $4398a1af81ae1348$var$setSegment(value, part, segmentValue, options) {
|
|
492
492
|
switch(part){
|
|
493
493
|
case 'day':
|
|
494
494
|
case 'month':
|
|
@@ -526,17 +526,17 @@ function $14e72de17b214ee8$var$setSegment(value, part, segmentValue, options) {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
|
|
529
|
-
var $
|
|
529
|
+
var $377b3fe9df21ff1a$exports = {};
|
|
530
530
|
|
|
531
|
-
$parcel$export($
|
|
531
|
+
$parcel$export($377b3fe9df21ff1a$exports, "useDateRangePickerState", () => $377b3fe9df21ff1a$export$e50a61c1de9f574);
|
|
532
532
|
|
|
533
533
|
|
|
534
534
|
|
|
535
535
|
|
|
536
|
-
function $
|
|
537
|
-
let [isOpen1, setOpen] = $
|
|
538
|
-
let [controlledValue, setControlledValue] = $
|
|
539
|
-
let [placeholderValue, setPlaceholderValue] = $
|
|
536
|
+
function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
537
|
+
let [isOpen1, setOpen] = $j2a4F$useState(false);
|
|
538
|
+
let [controlledValue, setControlledValue] = $j2a4F$useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
539
|
+
let [placeholderValue, setPlaceholderValue] = $j2a4F$useState(()=>controlledValue || {
|
|
540
540
|
start: null,
|
|
541
541
|
end: null
|
|
542
542
|
}
|
|
@@ -550,7 +550,7 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
550
550
|
setPlaceholderValue(placeholderValue);
|
|
551
551
|
}
|
|
552
552
|
let value1 = controlledValue || placeholderValue;
|
|
553
|
-
let valueRef = $
|
|
553
|
+
let valueRef = $j2a4F$useRef(value1);
|
|
554
554
|
valueRef.current = value1;
|
|
555
555
|
let setValue = (value)=>{
|
|
556
556
|
valueRef.current = value;
|
|
@@ -559,18 +559,18 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
559
559
|
else setControlledValue(null);
|
|
560
560
|
};
|
|
561
561
|
let v = value1?.start || value1?.end || props.placeholderValue;
|
|
562
|
-
let [granularity, defaultTimeZone] = $
|
|
562
|
+
let [granularity, defaultTimeZone] = $1041af8c30a3d476$export$2440da353cedad43(v, props.granularity);
|
|
563
563
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
564
|
-
let [dateRange1, setSelectedDateRange] = $
|
|
565
|
-
let [timeRange1, setSelectedTimeRange] = $
|
|
564
|
+
let [dateRange1, setSelectedDateRange] = $j2a4F$useState(null);
|
|
565
|
+
let [timeRange1, setSelectedTimeRange] = $j2a4F$useState(null);
|
|
566
566
|
if (value1 && value1.start && value1.end) {
|
|
567
567
|
dateRange1 = value1;
|
|
568
568
|
if ('hour' in value1.start) timeRange1 = value1;
|
|
569
569
|
}
|
|
570
570
|
let commitValue = (dateRange, timeRange)=>{
|
|
571
571
|
setValue({
|
|
572
|
-
start: 'timeZone' in timeRange.start ? timeRange.start.set($
|
|
573
|
-
end: 'timeZone' in timeRange.end ? timeRange.end.set($
|
|
572
|
+
start: 'timeZone' in timeRange.start ? timeRange.start.set($j2a4F$toDateFields(dateRange.start)) : $j2a4F$toCalendarDateTime(dateRange.start, timeRange.start),
|
|
573
|
+
end: 'timeZone' in timeRange.end ? timeRange.end.set($j2a4F$toDateFields(dateRange.end)) : $j2a4F$toCalendarDateTime(dateRange.end, timeRange.end)
|
|
574
574
|
});
|
|
575
575
|
};
|
|
576
576
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
@@ -586,7 +586,7 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
586
586
|
if (dateRange1?.start && dateRange1?.end && range.start && range.end) commitValue(dateRange1, range);
|
|
587
587
|
else setSelectedTimeRange(range);
|
|
588
588
|
};
|
|
589
|
-
let validationState = props.validationState || (value1 != null && ($
|
|
589
|
+
let validationState = props.validationState || (value1 != null && ($1041af8c30a3d476$export$eac50920cf2fd59a(value1.start, props.minValue, props.maxValue) || $1041af8c30a3d476$export$eac50920cf2fd59a(value1.end, props.minValue, props.maxValue) || value1.end != null && value1.start != null && value1.end.compare(value1.start) < 0) ? 'invalid' : null);
|
|
590
590
|
return {
|
|
591
591
|
value: value1,
|
|
592
592
|
setValue: setValue,
|
|
@@ -619,8 +619,8 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
619
619
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
620
620
|
// the user opens the popover again.
|
|
621
621
|
if (!isOpen && !(value1?.start && value1?.end) && dateRange1?.start && dateRange1?.end && hasTime) commitValue(dateRange1, {
|
|
622
|
-
start: timeRange1?.start || $
|
|
623
|
-
end: timeRange1?.end || $
|
|
622
|
+
start: timeRange1?.start || $1041af8c30a3d476$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
623
|
+
end: timeRange1?.end || $1041af8c30a3d476$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
624
624
|
});
|
|
625
625
|
setOpen(isOpen);
|
|
626
626
|
},
|
|
@@ -631,13 +631,13 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
631
631
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
632
632
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
633
633
|
let endGranularity = props.granularity || (value1.end && 'minute' in value1.end ? 'minute' : 'day');
|
|
634
|
-
let startOptions = $
|
|
634
|
+
let startOptions = $1041af8c30a3d476$export$7e319ea407e63bc0(fieldOptions, {
|
|
635
635
|
granularity: startGranularity,
|
|
636
636
|
timeZone: startTimeZone,
|
|
637
637
|
hideTimeZone: props.hideTimeZone,
|
|
638
638
|
hourCycle: props.hourCycle
|
|
639
639
|
});
|
|
640
|
-
let startFormatter = new $
|
|
640
|
+
let startFormatter = new $j2a4F$DateFormatter(locale, startOptions);
|
|
641
641
|
let endFormatter;
|
|
642
642
|
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
643
643
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
@@ -650,13 +650,13 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
650
650
|
}
|
|
651
651
|
endFormatter = startFormatter;
|
|
652
652
|
} else {
|
|
653
|
-
let endOptions = $
|
|
653
|
+
let endOptions = $1041af8c30a3d476$export$7e319ea407e63bc0(fieldOptions, {
|
|
654
654
|
granularity: endGranularity,
|
|
655
655
|
timeZone: endTimeZone,
|
|
656
656
|
hideTimeZone: props.hideTimeZone,
|
|
657
657
|
hourCycle: props.hourCycle
|
|
658
658
|
});
|
|
659
|
-
endFormatter = new $
|
|
659
|
+
endFormatter = new $j2a4F$DateFormatter(locale, endOptions);
|
|
660
660
|
}
|
|
661
661
|
return `${startFormatter.format(value1.start.toDate(startTimeZone))} – ${endFormatter.format(value1.end.toDate(endTimeZone))}`;
|
|
662
662
|
},
|
|
@@ -666,7 +666,7 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
666
666
|
let value = valueRef.current;
|
|
667
667
|
if (value && Boolean(value.start) !== Boolean(value.end)) {
|
|
668
668
|
let calendar = (value.start || value.end).calendar;
|
|
669
|
-
let placeholder = $
|
|
669
|
+
let placeholder = $1041af8c30a3d476$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
670
670
|
setValue({
|
|
671
671
|
start: value.start || placeholder,
|
|
672
672
|
end: value.end || placeholder
|
|
@@ -677,40 +677,40 @@ function $305e7a177ba4287c$export$e50a61c1de9f574(props) {
|
|
|
677
677
|
}
|
|
678
678
|
|
|
679
679
|
|
|
680
|
-
var $
|
|
680
|
+
var $bee84d327e9289f2$exports = {};
|
|
681
681
|
|
|
682
|
-
$parcel$export($
|
|
682
|
+
$parcel$export($bee84d327e9289f2$exports, "useTimeFieldState", () => $bee84d327e9289f2$export$fd53cef0cc796101);
|
|
683
683
|
|
|
684
684
|
|
|
685
685
|
|
|
686
686
|
|
|
687
|
-
function $
|
|
688
|
-
let { placeholderValue: placeholderValue = new $
|
|
689
|
-
let [value, setValue] = $
|
|
687
|
+
function $bee84d327e9289f2$export$fd53cef0cc796101(props) {
|
|
688
|
+
let { placeholderValue: placeholderValue = new $j2a4F$Time() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
689
|
+
let [value, setValue] = $j2a4F$useControlledState(props.value, props.defaultValue, props.onChange);
|
|
690
690
|
let v = value || placeholderValue;
|
|
691
691
|
let day = v && 'day' in v ? v : undefined;
|
|
692
|
-
let placeholderDate = $
|
|
692
|
+
let placeholderDate = $j2a4F$useMemo(()=>$bee84d327e9289f2$var$convertValue(placeholderValue)
|
|
693
693
|
, [
|
|
694
694
|
placeholderValue
|
|
695
695
|
]);
|
|
696
|
-
let minDate = $
|
|
696
|
+
let minDate = $j2a4F$useMemo(()=>$bee84d327e9289f2$var$convertValue(minValue, day)
|
|
697
697
|
, [
|
|
698
698
|
minValue,
|
|
699
699
|
day
|
|
700
700
|
]);
|
|
701
|
-
let maxDate = $
|
|
701
|
+
let maxDate = $j2a4F$useMemo(()=>$bee84d327e9289f2$var$convertValue(maxValue, day)
|
|
702
702
|
, [
|
|
703
703
|
maxValue,
|
|
704
704
|
day
|
|
705
705
|
]);
|
|
706
|
-
let dateTime = $
|
|
706
|
+
let dateTime = $j2a4F$useMemo(()=>value == null ? null : $bee84d327e9289f2$var$convertValue(value)
|
|
707
707
|
, [
|
|
708
708
|
value
|
|
709
709
|
]);
|
|
710
710
|
let onChange = (newValue)=>{
|
|
711
|
-
setValue(v && 'day' in v ? newValue : newValue && $
|
|
711
|
+
setValue(v && 'day' in v ? newValue : newValue && $j2a4F$toTime(newValue));
|
|
712
712
|
};
|
|
713
|
-
return $
|
|
713
|
+
return $4398a1af81ae1348$export$714a241b39a650d6({
|
|
714
714
|
...props,
|
|
715
715
|
value: dateTime,
|
|
716
716
|
defaultValue: undefined,
|
|
@@ -722,14 +722,14 @@ function $082e5bed996af9f7$export$fd53cef0cc796101(props) {
|
|
|
722
722
|
placeholderValue: placeholderDate
|
|
723
723
|
});
|
|
724
724
|
}
|
|
725
|
-
function $
|
|
725
|
+
function $bee84d327e9289f2$var$convertValue(value, date = $j2a4F$today($j2a4F$getLocalTimeZone())) {
|
|
726
726
|
if (!value) return null;
|
|
727
727
|
if ('day' in value) return value;
|
|
728
|
-
return $
|
|
728
|
+
return $j2a4F$toCalendarDateTime(date, value);
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
|
|
732
732
|
|
|
733
733
|
|
|
734
|
-
export {$
|
|
734
|
+
export {$e9af7896aa0f34cc$export$87194bb378cc3ac2 as useDatePickerState, $4398a1af81ae1348$export$714a241b39a650d6 as useDatePickerFieldState, $377b3fe9df21ff1a$export$e50a61c1de9f574 as useDateRangePickerState, $bee84d327e9289f2$export$fd53cef0cc796101 as useTimeFieldState};
|
|
735
735
|
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/datepicker",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.1395+b2abc5d94",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@internationalized/date": "3.0.0-nightly.
|
|
22
|
-
"@react-stately/utils": "3.0.0-nightly.
|
|
23
|
-
"@react-types/datepicker": "3.0.0-nightly.
|
|
24
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
21
|
+
"@internationalized/date": "3.0.0-nightly.3086+b2abc5d94",
|
|
22
|
+
"@react-stately/utils": "3.0.0-nightly.1395+b2abc5d94",
|
|
23
|
+
"@react-types/datepicker": "3.0.0-nightly.1395+b2abc5d94",
|
|
24
|
+
"@react-types/shared": "3.0.0-nightly.1395+b2abc5d94",
|
|
25
25
|
"date-fns": "^1.30.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "b2abc5d94162a7bd614fffcdf11e3d3754dc7d9f"
|
|
34
34
|
}
|