@react-stately/datepicker 3.0.0-nightly.1400 → 3.0.0-nightly.3113
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 +119 -117
- package/dist/main.js.map +1 -1
- package/dist/module.js +116 -114
- package/dist/module.js.map +1 -1
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
1
|
+
var $h2qOe$internationalizeddate = require("@internationalized/date");
|
|
2
|
+
var $h2qOe$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $h2qOe$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 $aaab7a647e17e1fd$exports = {};
|
|
25
25
|
|
|
26
|
-
$parcel$export($
|
|
26
|
+
$parcel$export($aaab7a647e17e1fd$exports, "useDatePickerState", () => $aaab7a647e17e1fd$export$87194bb378cc3ac2);
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
function $
|
|
30
|
+
function $50d5d6a623389320$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 $50d5d6a623389320$var$DEFAULT_FIELD_OPTIONS = {
|
|
34
34
|
year: 'numeric',
|
|
35
35
|
month: 'numeric',
|
|
36
36
|
day: 'numeric',
|
|
@@ -38,14 +38,15 @@ const $a1a093054004b094$var$DEFAULT_FIELD_OPTIONS = {
|
|
|
38
38
|
minute: '2-digit',
|
|
39
39
|
second: '2-digit'
|
|
40
40
|
};
|
|
41
|
-
function $
|
|
41
|
+
function $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
42
42
|
fieldOptions = {
|
|
43
|
-
...$
|
|
43
|
+
...$50d5d6a623389320$var$DEFAULT_FIELD_OPTIONS,
|
|
44
44
|
...fieldOptions
|
|
45
45
|
};
|
|
46
46
|
let granularity = options.granularity || 'minute';
|
|
47
47
|
let keys = Object.keys(fieldOptions);
|
|
48
|
-
|
|
48
|
+
var _maxGranularity;
|
|
49
|
+
let startIdx = keys.indexOf((_maxGranularity = options.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year');
|
|
49
50
|
if (startIdx < 0) startIdx = 0;
|
|
50
51
|
let endIdx = keys.indexOf(granularity);
|
|
51
52
|
if (endIdx < 0) endIdx = 2;
|
|
@@ -61,30 +62,30 @@ function $a1a093054004b094$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
61
62
|
if (hasTime && options.timeZone && !options.hideTimeZone) opts1.timeZoneName = 'short';
|
|
62
63
|
return opts1;
|
|
63
64
|
}
|
|
64
|
-
function $
|
|
65
|
+
function $50d5d6a623389320$export$c5221a78ef73c5e9(placeholderValue) {
|
|
65
66
|
if (placeholderValue && 'hour' in placeholderValue) return placeholderValue;
|
|
66
|
-
return new $
|
|
67
|
+
return new $h2qOe$internationalizeddate.Time();
|
|
67
68
|
}
|
|
68
|
-
function $
|
|
69
|
+
function $50d5d6a623389320$export$61a490a80c552550(value, calendar) {
|
|
69
70
|
if (value === null) return null;
|
|
70
71
|
if (!value) return undefined;
|
|
71
|
-
return $
|
|
72
|
+
return $h2qOe$internationalizeddate.toCalendar(value, calendar);
|
|
72
73
|
}
|
|
73
|
-
function $
|
|
74
|
-
if (placeholderValue) return $
|
|
75
|
-
let date = $
|
|
74
|
+
function $50d5d6a623389320$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
|
|
75
|
+
if (placeholderValue) return $50d5d6a623389320$export$61a490a80c552550(placeholderValue, calendar);
|
|
76
|
+
let date = $h2qOe$internationalizeddate.toCalendar($h2qOe$internationalizeddate.now(timeZone).set({
|
|
76
77
|
hour: 0,
|
|
77
78
|
minute: 0,
|
|
78
79
|
second: 0,
|
|
79
80
|
millisecond: 0
|
|
80
81
|
}), calendar);
|
|
81
|
-
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $
|
|
82
|
-
if (!timeZone) return $
|
|
82
|
+
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $h2qOe$internationalizeddate.toCalendarDate(date);
|
|
83
|
+
if (!timeZone) return $h2qOe$internationalizeddate.toCalendarDateTime(date);
|
|
83
84
|
return date;
|
|
84
85
|
}
|
|
85
|
-
function $
|
|
86
|
+
function $50d5d6a623389320$export$2440da353cedad43(v, granularity) {
|
|
86
87
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
87
|
-
let lastValue = $
|
|
88
|
+
let lastValue = $h2qOe$react.useRef(v);
|
|
88
89
|
if (v) lastValue.current = v;
|
|
89
90
|
v = lastValue.current;
|
|
90
91
|
let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
@@ -101,15 +102,15 @@ function $a1a093054004b094$export$2440da353cedad43(v, granularity) {
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
|
|
104
|
-
function $
|
|
105
|
-
let [isOpen1, setOpen] = $
|
|
106
|
-
let [value, setValue] = $
|
|
105
|
+
function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
106
|
+
let [isOpen1, setOpen] = $h2qOe$react.useState(false);
|
|
107
|
+
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
107
108
|
let v = value || props.placeholderValue;
|
|
108
|
-
let [granularity, defaultTimeZone] = $
|
|
109
|
-
let dateValue = value != null ? value.toDate(defaultTimeZone
|
|
109
|
+
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
110
|
+
let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : 'UTC') : null;
|
|
110
111
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
111
|
-
let [selectedDate, setSelectedDate] = $
|
|
112
|
-
let [selectedTime, setSelectedTime] = $
|
|
112
|
+
let [selectedDate, setSelectedDate] = $h2qOe$react.useState(null);
|
|
113
|
+
let [selectedTime, setSelectedTime] = $h2qOe$react.useState(null);
|
|
113
114
|
if (value) {
|
|
114
115
|
selectedDate = value;
|
|
115
116
|
if ('hour' in value) selectedTime = value;
|
|
@@ -117,7 +118,7 @@ function $0c9ae69d60d14242$export$87194bb378cc3ac2(props) {
|
|
|
117
118
|
// props.granularity must actually exist in the value if one is provided.
|
|
118
119
|
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
119
120
|
let commitValue = (date, time)=>{
|
|
120
|
-
setValue('timeZone' in time ? time.set($
|
|
121
|
+
setValue('timeZone' in time ? time.set($h2qOe$internationalizeddate.toDateFields(date)) : $h2qOe$internationalizeddate.toCalendarDateTime(date, time));
|
|
121
122
|
};
|
|
122
123
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
123
124
|
let selectDate = (newValue)=>{
|
|
@@ -131,7 +132,7 @@ function $0c9ae69d60d14242$export$87194bb378cc3ac2(props) {
|
|
|
131
132
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
132
133
|
else setSelectedTime(newValue);
|
|
133
134
|
};
|
|
134
|
-
let validationState = props.validationState || ($
|
|
135
|
+
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(value, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
135
136
|
return {
|
|
136
137
|
value: value,
|
|
137
138
|
setValue: setValue,
|
|
@@ -145,33 +146,33 @@ function $0c9ae69d60d14242$export$87194bb378cc3ac2(props) {
|
|
|
145
146
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
146
147
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
147
148
|
// the user opens the popover again.
|
|
148
|
-
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $
|
|
149
|
+
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
149
150
|
setOpen(isOpen);
|
|
150
151
|
},
|
|
151
152
|
validationState: validationState,
|
|
152
153
|
formatValue (locale, fieldOptions) {
|
|
153
154
|
if (!dateValue) return '';
|
|
154
|
-
let formatOptions = $
|
|
155
|
+
let formatOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
155
156
|
granularity: granularity,
|
|
156
157
|
timeZone: defaultTimeZone,
|
|
157
158
|
hideTimeZone: props.hideTimeZone,
|
|
158
159
|
hourCycle: props.hourCycle
|
|
159
160
|
});
|
|
160
|
-
let formatter = new $
|
|
161
|
+
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
161
162
|
return formatter.format(dateValue);
|
|
162
163
|
}
|
|
163
164
|
};
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
|
|
167
|
-
var $
|
|
168
|
+
var $6d4e641deb83cb9e$exports = {};
|
|
168
169
|
|
|
169
|
-
$parcel$export($
|
|
170
|
+
$parcel$export($6d4e641deb83cb9e$exports, "useDatePickerFieldState", () => $6d4e641deb83cb9e$export$714a241b39a650d6);
|
|
170
171
|
|
|
171
172
|
|
|
172
173
|
|
|
173
174
|
|
|
174
|
-
const $
|
|
175
|
+
const $6d4e641deb83cb9e$var$EDITABLE_SEGMENTS = {
|
|
175
176
|
year: true,
|
|
176
177
|
month: true,
|
|
177
178
|
day: true,
|
|
@@ -181,7 +182,7 @@ const $f23cc841f3588f43$var$EDITABLE_SEGMENTS = {
|
|
|
181
182
|
dayPeriod: true,
|
|
182
183
|
era: true
|
|
183
184
|
};
|
|
184
|
-
const $
|
|
185
|
+
const $6d4e641deb83cb9e$var$PAGE_STEP = {
|
|
185
186
|
year: 5,
|
|
186
187
|
month: 2,
|
|
187
188
|
day: 7,
|
|
@@ -190,19 +191,20 @@ const $f23cc841f3588f43$var$PAGE_STEP = {
|
|
|
190
191
|
second: 15
|
|
191
192
|
};
|
|
192
193
|
// Node seems to convert everything to lowercase...
|
|
193
|
-
const $
|
|
194
|
+
const $6d4e641deb83cb9e$var$TYPE_MAPPING = {
|
|
194
195
|
dayperiod: 'dayPeriod'
|
|
195
196
|
};
|
|
196
|
-
function $
|
|
197
|
+
function $6d4e641deb83cb9e$export$714a241b39a650d6(props) {
|
|
197
198
|
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone } = props;
|
|
198
199
|
let v1 = props.value || props.defaultValue || props.placeholderValue;
|
|
199
|
-
let [granularity, defaultTimeZone] = $
|
|
200
|
+
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v1, props.granularity);
|
|
200
201
|
let timeZone = defaultTimeZone || 'UTC';
|
|
201
202
|
// props.granularity must actually exist in the value if one is provided.
|
|
202
203
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
203
|
-
|
|
204
|
+
var _maxGranularity;
|
|
205
|
+
let formatOpts = $h2qOe$react.useMemo(()=>({
|
|
204
206
|
granularity: granularity,
|
|
205
|
-
maxGranularity: props.maxGranularity
|
|
207
|
+
maxGranularity: (_maxGranularity = props.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year',
|
|
206
208
|
timeZone: defaultTimeZone,
|
|
207
209
|
hideTimeZone: hideTimeZone,
|
|
208
210
|
hourCycle: props.hourCycle
|
|
@@ -214,35 +216,35 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
214
216
|
defaultTimeZone,
|
|
215
217
|
hideTimeZone
|
|
216
218
|
]);
|
|
217
|
-
let opts = $
|
|
219
|
+
let opts = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$7e319ea407e63bc0({
|
|
218
220
|
}, formatOpts)
|
|
219
221
|
, [
|
|
220
222
|
formatOpts
|
|
221
223
|
]);
|
|
222
|
-
let dateFormatter = $
|
|
224
|
+
let dateFormatter = $h2qOe$react.useMemo(()=>new $h2qOe$internationalizeddate.DateFormatter(locale, opts)
|
|
223
225
|
, [
|
|
224
226
|
locale,
|
|
225
227
|
opts
|
|
226
228
|
]);
|
|
227
|
-
let resolvedOptions = $
|
|
229
|
+
let resolvedOptions = $h2qOe$react.useMemo(()=>dateFormatter.resolvedOptions()
|
|
228
230
|
, [
|
|
229
231
|
dateFormatter
|
|
230
232
|
]);
|
|
231
|
-
let calendar = $
|
|
233
|
+
let calendar = $h2qOe$react.useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
232
234
|
, [
|
|
233
235
|
createCalendar,
|
|
234
236
|
resolvedOptions.calendar
|
|
235
237
|
]);
|
|
236
238
|
// Determine how many editable segments there are for validation purposes.
|
|
237
239
|
// The result is cached for performance.
|
|
238
|
-
let allSegments = $
|
|
240
|
+
let allSegments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$6d4e641deb83cb9e$var$EDITABLE_SEGMENTS[seg.type]
|
|
239
241
|
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
240
242
|
, {
|
|
241
243
|
})
|
|
242
244
|
, [
|
|
243
245
|
dateFormatter
|
|
244
246
|
]);
|
|
245
|
-
let [validSegments, setValidSegments] = $
|
|
247
|
+
let [validSegments, setValidSegments] = $h2qOe$react.useState(()=>props.value || props.defaultValue ? {
|
|
246
248
|
...allSegments
|
|
247
249
|
} : {
|
|
248
250
|
}
|
|
@@ -251,14 +253,14 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
251
253
|
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
252
254
|
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
253
255
|
// change from uncontrolled to controlled and emit a warning.
|
|
254
|
-
let [placeholderDate, setPlaceholderDate] = $
|
|
256
|
+
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()=>$50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
255
257
|
);
|
|
256
258
|
// Reset placeholder when calendar changes
|
|
257
|
-
let lastCalendarIdentifier = $
|
|
258
|
-
$
|
|
259
|
+
let lastCalendarIdentifier = $h2qOe$react.useRef(calendar.identifier);
|
|
260
|
+
$h2qOe$react.useEffect(()=>{
|
|
259
261
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
260
262
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
261
|
-
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $
|
|
263
|
+
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $h2qOe$internationalizeddate.toCalendar(placeholder, calendar) : $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
262
264
|
);
|
|
263
265
|
}
|
|
264
266
|
}, [
|
|
@@ -268,8 +270,8 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
268
270
|
defaultTimeZone,
|
|
269
271
|
props.placeholderValue
|
|
270
272
|
]);
|
|
271
|
-
let [value1, setDate] = $
|
|
272
|
-
let calendarValue = $
|
|
273
|
+
let [value1, setDate] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
274
|
+
let calendarValue = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$61a490a80c552550(value1, calendar)
|
|
273
275
|
, [
|
|
274
276
|
value1,
|
|
275
277
|
calendar
|
|
@@ -286,7 +288,7 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
286
288
|
validSegments = {
|
|
287
289
|
};
|
|
288
290
|
setValidSegments(validSegments);
|
|
289
|
-
setPlaceholderDate($
|
|
291
|
+
setPlaceholderDate($50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
290
292
|
}
|
|
291
293
|
// If all segments are valid, use the date from state, otherwise use the placeholder date.
|
|
292
294
|
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
|
|
@@ -295,23 +297,23 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
295
297
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) {
|
|
296
298
|
// The display calendar should not have any effect on the emitted value.
|
|
297
299
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
298
|
-
newValue = $
|
|
300
|
+
newValue = $h2qOe$internationalizeddate.toCalendar(newValue, (v1 === null || v1 === void 0 ? void 0 : v1.calendar) || new $h2qOe$internationalizeddate.GregorianCalendar());
|
|
299
301
|
setDate(newValue);
|
|
300
302
|
} else setPlaceholderDate(newValue);
|
|
301
303
|
};
|
|
302
|
-
let dateValue = $
|
|
304
|
+
let dateValue = $h2qOe$react.useMemo(()=>displayValue.toDate(timeZone)
|
|
303
305
|
, [
|
|
304
306
|
displayValue,
|
|
305
307
|
timeZone
|
|
306
308
|
]);
|
|
307
|
-
let segments = $
|
|
308
|
-
let isEditable = $
|
|
309
|
+
let segments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
310
|
+
let isEditable = $6d4e641deb83cb9e$var$EDITABLE_SEGMENTS[segment.type];
|
|
309
311
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
310
312
|
return {
|
|
311
|
-
type: $
|
|
313
|
+
type: $6d4e641deb83cb9e$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
312
314
|
text: segment.value,
|
|
313
|
-
...$
|
|
314
|
-
isPlaceholder: $
|
|
315
|
+
...$6d4e641deb83cb9e$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
316
|
+
isPlaceholder: $6d4e641deb83cb9e$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type],
|
|
315
317
|
isEditable: isEditable
|
|
316
318
|
};
|
|
317
319
|
})
|
|
@@ -323,7 +325,7 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
323
325
|
displayValue,
|
|
324
326
|
calendar
|
|
325
327
|
]);
|
|
326
|
-
let hasEra = $
|
|
328
|
+
let hasEra = $h2qOe$react.useMemo(()=>segments.some((s)=>s.type === 'era'
|
|
327
329
|
)
|
|
328
330
|
, [
|
|
329
331
|
segments
|
|
@@ -337,9 +339,9 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
337
339
|
};
|
|
338
340
|
let adjustSegment = (type, amount)=>{
|
|
339
341
|
markValid(type);
|
|
340
|
-
setValue($
|
|
342
|
+
setValue($6d4e641deb83cb9e$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
341
343
|
};
|
|
342
|
-
let validationState = props.validationState || ($
|
|
344
|
+
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
343
345
|
return {
|
|
344
346
|
value: calendarValue,
|
|
345
347
|
dateValue: dateValue,
|
|
@@ -355,14 +357,14 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
355
357
|
adjustSegment(part, -1);
|
|
356
358
|
},
|
|
357
359
|
incrementPage (part) {
|
|
358
|
-
adjustSegment(part, $
|
|
360
|
+
adjustSegment(part, $6d4e641deb83cb9e$var$PAGE_STEP[part] || 1);
|
|
359
361
|
},
|
|
360
362
|
decrementPage (part) {
|
|
361
|
-
adjustSegment(part, -($
|
|
363
|
+
adjustSegment(part, -($6d4e641deb83cb9e$var$PAGE_STEP[part] || 1));
|
|
362
364
|
},
|
|
363
365
|
setSegment (part, v) {
|
|
364
366
|
markValid(part);
|
|
365
|
-
setValue($
|
|
367
|
+
setValue($6d4e641deb83cb9e$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
366
368
|
},
|
|
367
369
|
confirmPlaceholder (part) {
|
|
368
370
|
if (props.isDisabled || props.isReadOnly) return;
|
|
@@ -386,7 +388,7 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
386
388
|
setValidSegments({
|
|
387
389
|
...validSegments
|
|
388
390
|
});
|
|
389
|
-
let placeholder = $
|
|
391
|
+
let placeholder = $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
390
392
|
let value = displayValue;
|
|
391
393
|
// Reset day period to default without changing the hour.
|
|
392
394
|
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
@@ -405,11 +407,11 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
405
407
|
setValue(value);
|
|
406
408
|
},
|
|
407
409
|
getFormatOptions (fieldOptions) {
|
|
408
|
-
return $
|
|
410
|
+
return $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
409
411
|
}
|
|
410
412
|
};
|
|
411
413
|
}
|
|
412
|
-
function $
|
|
414
|
+
function $6d4e641deb83cb9e$var$getSegmentLimits(date, type, options) {
|
|
413
415
|
switch(type){
|
|
414
416
|
case 'era':
|
|
415
417
|
{
|
|
@@ -429,13 +431,13 @@ function $f23cc841f3588f43$var$getSegmentLimits(date, type, options) {
|
|
|
429
431
|
case 'month':
|
|
430
432
|
return {
|
|
431
433
|
value: date.month,
|
|
432
|
-
minValue: $
|
|
434
|
+
minValue: $h2qOe$internationalizeddate.getMinimumMonthInYear(date),
|
|
433
435
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
434
436
|
};
|
|
435
437
|
case 'day':
|
|
436
438
|
return {
|
|
437
439
|
value: date.day,
|
|
438
|
-
minValue: $
|
|
440
|
+
minValue: $h2qOe$internationalizeddate.getMinimumDayInMonth(date),
|
|
439
441
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
440
442
|
};
|
|
441
443
|
}
|
|
@@ -476,7 +478,7 @@ function $f23cc841f3588f43$var$getSegmentLimits(date, type, options) {
|
|
|
476
478
|
return {
|
|
477
479
|
};
|
|
478
480
|
}
|
|
479
|
-
function $
|
|
481
|
+
function $6d4e641deb83cb9e$var$addSegment(value, part, amount, options) {
|
|
480
482
|
switch(part){
|
|
481
483
|
case 'era':
|
|
482
484
|
case 'year':
|
|
@@ -504,7 +506,7 @@ function $f23cc841f3588f43$var$addSegment(value, part, amount, options) {
|
|
|
504
506
|
});
|
|
505
507
|
}
|
|
506
508
|
}
|
|
507
|
-
function $
|
|
509
|
+
function $6d4e641deb83cb9e$var$setSegment(value, part, segmentValue, options) {
|
|
508
510
|
switch(part){
|
|
509
511
|
case 'day':
|
|
510
512
|
case 'month':
|
|
@@ -542,17 +544,17 @@ function $f23cc841f3588f43$var$setSegment(value, part, segmentValue, options) {
|
|
|
542
544
|
}
|
|
543
545
|
|
|
544
546
|
|
|
545
|
-
var $
|
|
547
|
+
var $7072d26f58deb33b$exports = {};
|
|
546
548
|
|
|
547
|
-
$parcel$export($
|
|
549
|
+
$parcel$export($7072d26f58deb33b$exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
548
550
|
|
|
549
551
|
|
|
550
552
|
|
|
551
553
|
|
|
552
|
-
function $
|
|
553
|
-
let [isOpen1, setOpen] = $
|
|
554
|
-
let [controlledValue, setControlledValue] = $
|
|
555
|
-
let [placeholderValue, setPlaceholderValue] = $
|
|
554
|
+
function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
555
|
+
let [isOpen1, setOpen] = $h2qOe$react.useState(false);
|
|
556
|
+
let [controlledValue, setControlledValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
557
|
+
let [placeholderValue, setPlaceholderValue] = $h2qOe$react.useState(()=>controlledValue || {
|
|
556
558
|
start: null,
|
|
557
559
|
end: null
|
|
558
560
|
}
|
|
@@ -566,43 +568,43 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
566
568
|
setPlaceholderValue(placeholderValue);
|
|
567
569
|
}
|
|
568
570
|
let value1 = controlledValue || placeholderValue;
|
|
569
|
-
let valueRef = $
|
|
571
|
+
let valueRef = $h2qOe$react.useRef(value1);
|
|
570
572
|
valueRef.current = value1;
|
|
571
573
|
let setValue = (value)=>{
|
|
572
574
|
valueRef.current = value;
|
|
573
575
|
setPlaceholderValue(value);
|
|
574
|
-
if (value
|
|
576
|
+
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) setControlledValue(value);
|
|
575
577
|
else setControlledValue(null);
|
|
576
578
|
};
|
|
577
|
-
let v = value1
|
|
578
|
-
let [granularity, defaultTimeZone] = $
|
|
579
|
+
let v = (value1 === null || value1 === void 0 ? void 0 : value1.start) || (value1 === null || value1 === void 0 ? void 0 : value1.end) || props.placeholderValue;
|
|
580
|
+
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
579
581
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
580
|
-
let [dateRange1, setSelectedDateRange] = $
|
|
581
|
-
let [timeRange1, setSelectedTimeRange] = $
|
|
582
|
+
let [dateRange1, setSelectedDateRange] = $h2qOe$react.useState(null);
|
|
583
|
+
let [timeRange1, setSelectedTimeRange] = $h2qOe$react.useState(null);
|
|
582
584
|
if (value1 && value1.start && value1.end) {
|
|
583
585
|
dateRange1 = value1;
|
|
584
586
|
if ('hour' in value1.start) timeRange1 = value1;
|
|
585
587
|
}
|
|
586
588
|
let commitValue = (dateRange, timeRange)=>{
|
|
587
589
|
setValue({
|
|
588
|
-
start: 'timeZone' in timeRange.start ? timeRange.start.set($
|
|
589
|
-
end: 'timeZone' in timeRange.end ? timeRange.end.set($
|
|
590
|
+
start: 'timeZone' in timeRange.start ? timeRange.start.set($h2qOe$internationalizeddate.toDateFields(dateRange.start)) : $h2qOe$internationalizeddate.toCalendarDateTime(dateRange.start, timeRange.start),
|
|
591
|
+
end: 'timeZone' in timeRange.end ? timeRange.end.set($h2qOe$internationalizeddate.toDateFields(dateRange.end)) : $h2qOe$internationalizeddate.toCalendarDateTime(dateRange.end, timeRange.end)
|
|
590
592
|
});
|
|
591
593
|
};
|
|
592
594
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
593
595
|
let setDateRange = (range)=>{
|
|
594
596
|
if (hasTime) {
|
|
595
|
-
if (range.start && range.end && timeRange1
|
|
597
|
+
if (range.start && range.end && (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) && (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end)) commitValue(range, timeRange1);
|
|
596
598
|
else setSelectedDateRange(range);
|
|
597
599
|
} else if (range.start && range.end) setValue(range);
|
|
598
600
|
else setSelectedDateRange(range);
|
|
599
601
|
if (!hasTime) setOpen(false);
|
|
600
602
|
};
|
|
601
603
|
let setTimeRange = (range)=>{
|
|
602
|
-
if (dateRange1
|
|
604
|
+
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);
|
|
603
605
|
else setSelectedTimeRange(range);
|
|
604
606
|
};
|
|
605
|
-
let validationState = props.validationState || (value1 != null && ($
|
|
607
|
+
let validationState = props.validationState || (value1 != null && ($50d5d6a623389320$export$eac50920cf2fd59a(value1.start, props.minValue, props.maxValue) || $50d5d6a623389320$export$eac50920cf2fd59a(value1.end, props.minValue, props.maxValue) || value1.end != null && value1.start != null && value1.end.compare(value1.start) < 0) ? 'invalid' : null);
|
|
606
608
|
return {
|
|
607
609
|
value: value1,
|
|
608
610
|
setValue: setValue,
|
|
@@ -634,9 +636,9 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
634
636
|
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
635
637
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
636
638
|
// the user opens the popover again.
|
|
637
|
-
if (!isOpen && !(value1
|
|
638
|
-
start: timeRange1
|
|
639
|
-
end: timeRange1
|
|
639
|
+
if (!isOpen && !((value1 === null || value1 === void 0 ? void 0 : value1.start) && (value1 === null || value1 === void 0 ? void 0 : value1.end)) && (dateRange1 === null || dateRange1 === void 0 ? void 0 : dateRange1.start) && (dateRange1 === null || dateRange1 === void 0 ? void 0 : dateRange1.end) && hasTime) commitValue(dateRange1, {
|
|
640
|
+
start: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
641
|
+
end: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
640
642
|
});
|
|
641
643
|
setOpen(isOpen);
|
|
642
644
|
},
|
|
@@ -647,13 +649,13 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
647
649
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
648
650
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
649
651
|
let endGranularity = props.granularity || (value1.end && 'minute' in value1.end ? 'minute' : 'day');
|
|
650
|
-
let startOptions = $
|
|
652
|
+
let startOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
651
653
|
granularity: startGranularity,
|
|
652
654
|
timeZone: startTimeZone,
|
|
653
655
|
hideTimeZone: props.hideTimeZone,
|
|
654
656
|
hourCycle: props.hourCycle
|
|
655
657
|
});
|
|
656
|
-
let startFormatter = new $
|
|
658
|
+
let startFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, startOptions);
|
|
657
659
|
let endFormatter;
|
|
658
660
|
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
659
661
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
@@ -666,13 +668,13 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
666
668
|
}
|
|
667
669
|
endFormatter = startFormatter;
|
|
668
670
|
} else {
|
|
669
|
-
let endOptions = $
|
|
671
|
+
let endOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
670
672
|
granularity: endGranularity,
|
|
671
673
|
timeZone: endTimeZone,
|
|
672
674
|
hideTimeZone: props.hideTimeZone,
|
|
673
675
|
hourCycle: props.hourCycle
|
|
674
676
|
});
|
|
675
|
-
endFormatter = new $
|
|
677
|
+
endFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, endOptions);
|
|
676
678
|
}
|
|
677
679
|
return `${startFormatter.format(value1.start.toDate(startTimeZone))} – ${endFormatter.format(value1.end.toDate(endTimeZone))}`;
|
|
678
680
|
},
|
|
@@ -682,7 +684,7 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
682
684
|
let value = valueRef.current;
|
|
683
685
|
if (value && Boolean(value.start) !== Boolean(value.end)) {
|
|
684
686
|
let calendar = (value.start || value.end).calendar;
|
|
685
|
-
let placeholder = $
|
|
687
|
+
let placeholder = $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
686
688
|
setValue({
|
|
687
689
|
start: value.start || placeholder,
|
|
688
690
|
end: value.end || placeholder
|
|
@@ -693,40 +695,40 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
693
695
|
}
|
|
694
696
|
|
|
695
697
|
|
|
696
|
-
var $
|
|
698
|
+
var $2654e87be0231a69$exports = {};
|
|
697
699
|
|
|
698
|
-
$parcel$export($
|
|
700
|
+
$parcel$export($2654e87be0231a69$exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
699
701
|
|
|
700
702
|
|
|
701
703
|
|
|
702
704
|
|
|
703
|
-
function $
|
|
704
|
-
let { placeholderValue: placeholderValue = new $
|
|
705
|
-
let [value, setValue] = $
|
|
705
|
+
function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
706
|
+
let { placeholderValue: placeholderValue = new $h2qOe$internationalizeddate.Time() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
707
|
+
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
706
708
|
let v = value || placeholderValue;
|
|
707
709
|
let day = v && 'day' in v ? v : undefined;
|
|
708
|
-
let placeholderDate = $
|
|
710
|
+
let placeholderDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(placeholderValue)
|
|
709
711
|
, [
|
|
710
712
|
placeholderValue
|
|
711
713
|
]);
|
|
712
|
-
let minDate = $
|
|
714
|
+
let minDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(minValue, day)
|
|
713
715
|
, [
|
|
714
716
|
minValue,
|
|
715
717
|
day
|
|
716
718
|
]);
|
|
717
|
-
let maxDate = $
|
|
719
|
+
let maxDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(maxValue, day)
|
|
718
720
|
, [
|
|
719
721
|
maxValue,
|
|
720
722
|
day
|
|
721
723
|
]);
|
|
722
|
-
let dateTime = $
|
|
724
|
+
let dateTime = $h2qOe$react.useMemo(()=>value == null ? null : $2654e87be0231a69$var$convertValue(value)
|
|
723
725
|
, [
|
|
724
726
|
value
|
|
725
727
|
]);
|
|
726
728
|
let onChange = (newValue)=>{
|
|
727
|
-
setValue(v && 'day' in v ? newValue : newValue && $
|
|
729
|
+
setValue(v && 'day' in v ? newValue : newValue && $h2qOe$internationalizeddate.toTime(newValue));
|
|
728
730
|
};
|
|
729
|
-
return $
|
|
731
|
+
return $6d4e641deb83cb9e$export$714a241b39a650d6({
|
|
730
732
|
...props,
|
|
731
733
|
value: dateTime,
|
|
732
734
|
defaultValue: undefined,
|
|
@@ -738,17 +740,17 @@ function $ef228128a792346b$export$fd53cef0cc796101(props) {
|
|
|
738
740
|
placeholderValue: placeholderDate
|
|
739
741
|
});
|
|
740
742
|
}
|
|
741
|
-
function $
|
|
743
|
+
function $2654e87be0231a69$var$convertValue(value, date = $h2qOe$internationalizeddate.today($h2qOe$internationalizeddate.getLocalTimeZone())) {
|
|
742
744
|
if (!value) return null;
|
|
743
745
|
if ('day' in value) return value;
|
|
744
|
-
return $
|
|
746
|
+
return $h2qOe$internationalizeddate.toCalendarDateTime(date, value);
|
|
745
747
|
}
|
|
746
748
|
|
|
747
749
|
|
|
748
|
-
$parcel$exportWildcard(module.exports, $
|
|
749
|
-
$parcel$exportWildcard(module.exports, $
|
|
750
|
-
$parcel$exportWildcard(module.exports, $
|
|
751
|
-
$parcel$exportWildcard(module.exports, $
|
|
750
|
+
$parcel$exportWildcard(module.exports, $aaab7a647e17e1fd$exports);
|
|
751
|
+
$parcel$exportWildcard(module.exports, $6d4e641deb83cb9e$exports);
|
|
752
|
+
$parcel$exportWildcard(module.exports, $7072d26f58deb33b$exports);
|
|
753
|
+
$parcel$exportWildcard(module.exports, $2654e87be0231a69$exports);
|
|
752
754
|
|
|
753
755
|
|
|
754
756
|
//# sourceMappingURL=main.js.map
|