@react-stately/datepicker 3.0.0-nightly.1409 → 3.0.0-nightly.1484
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 +146 -123
- package/dist/main.js.map +1 -1
- package/dist/module.js +143 -120
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +159 -33
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +1 -1
- package/src/{useDatePickerFieldState.ts → useDateFieldState.ts} +86 -18
- package/src/useDatePickerState.ts +48 -13
- package/src/useDateRangePickerState.ts +61 -17
- package/src/useTimeFieldState.ts +15 -8
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,18 @@ function $a1a093054004b094$export$2440da353cedad43(v, granularity) {
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
|
|
104
|
-
function $
|
|
105
|
-
|
|
106
|
-
let [
|
|
105
|
+
function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
|
|
106
|
+
var ref;
|
|
107
|
+
let [isOpen1, setOpen] = $h2qOe$react.useState(false);
|
|
108
|
+
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
107
109
|
let v = value || props.placeholderValue;
|
|
108
|
-
let [granularity, defaultTimeZone] = $
|
|
109
|
-
let dateValue = value != null ? value.toDate(defaultTimeZone
|
|
110
|
+
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
111
|
+
let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : 'UTC') : null;
|
|
110
112
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
111
|
-
|
|
112
|
-
let
|
|
113
|
+
var _shouldCloseOnSelect;
|
|
114
|
+
let shouldCloseOnSelect = (_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _shouldCloseOnSelect !== void 0 ? _shouldCloseOnSelect : true;
|
|
115
|
+
let [selectedDate, setSelectedDate] = $h2qOe$react.useState(null);
|
|
116
|
+
let [selectedTime, setSelectedTime] = $h2qOe$react.useState(null);
|
|
113
117
|
if (value) {
|
|
114
118
|
selectedDate = value;
|
|
115
119
|
if ('hour' in value) selectedTime = value;
|
|
@@ -117,21 +121,22 @@ function $0c9ae69d60d14242$export$87194bb378cc3ac2(props) {
|
|
|
117
121
|
// props.granularity must actually exist in the value if one is provided.
|
|
118
122
|
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
119
123
|
let commitValue = (date, time)=>{
|
|
120
|
-
setValue('timeZone' in time ? time.set($
|
|
124
|
+
setValue('timeZone' in time ? time.set($h2qOe$internationalizeddate.toCalendarDate(date)) : $h2qOe$internationalizeddate.toCalendarDateTime(date, time));
|
|
121
125
|
};
|
|
122
126
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
123
127
|
let selectDate = (newValue)=>{
|
|
128
|
+
let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
|
|
124
129
|
if (hasTime) {
|
|
125
|
-
if (selectedTime) commitValue(newValue, selectedTime);
|
|
130
|
+
if (selectedTime || shouldClose) commitValue(newValue, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
126
131
|
else setSelectedDate(newValue);
|
|
127
132
|
} else setValue(newValue);
|
|
128
|
-
if (
|
|
133
|
+
if (shouldClose) setOpen(false);
|
|
129
134
|
};
|
|
130
135
|
let selectTime = (newValue)=>{
|
|
131
136
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
132
137
|
else setSelectedTime(newValue);
|
|
133
138
|
};
|
|
134
|
-
let validationState = props.validationState || ($
|
|
139
|
+
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(value, props.minValue, props.maxValue) ? 'invalid' : null) || (value && ((ref = props.isDateUnavailable) === null || ref === void 0 ? void 0 : ref.call(props, value)) ? 'invalid' : null);
|
|
135
140
|
return {
|
|
136
141
|
value: value,
|
|
137
142
|
setValue: setValue,
|
|
@@ -140,38 +145,39 @@ function $0c9ae69d60d14242$export$87194bb378cc3ac2(props) {
|
|
|
140
145
|
setDateValue: selectDate,
|
|
141
146
|
setTimeValue: selectTime,
|
|
142
147
|
granularity: granularity,
|
|
148
|
+
hasTime: hasTime,
|
|
143
149
|
isOpen: isOpen1,
|
|
144
150
|
setOpen (isOpen) {
|
|
145
151
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
146
152
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
147
153
|
// the user opens the popover again.
|
|
148
|
-
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $
|
|
154
|
+
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
149
155
|
setOpen(isOpen);
|
|
150
156
|
},
|
|
151
157
|
validationState: validationState,
|
|
152
158
|
formatValue (locale, fieldOptions) {
|
|
153
159
|
if (!dateValue) return '';
|
|
154
|
-
let formatOptions = $
|
|
160
|
+
let formatOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
155
161
|
granularity: granularity,
|
|
156
162
|
timeZone: defaultTimeZone,
|
|
157
163
|
hideTimeZone: props.hideTimeZone,
|
|
158
164
|
hourCycle: props.hourCycle
|
|
159
165
|
});
|
|
160
|
-
let formatter = new $
|
|
166
|
+
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
161
167
|
return formatter.format(dateValue);
|
|
162
168
|
}
|
|
163
169
|
};
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
|
|
167
|
-
var $
|
|
173
|
+
var $596a1f0f523d6752$exports = {};
|
|
168
174
|
|
|
169
|
-
$parcel$export($
|
|
175
|
+
$parcel$export($596a1f0f523d6752$exports, "useDateFieldState", () => $596a1f0f523d6752$export$60e84778edff6d26);
|
|
170
176
|
|
|
171
177
|
|
|
172
178
|
|
|
173
179
|
|
|
174
|
-
const $
|
|
180
|
+
const $596a1f0f523d6752$var$EDITABLE_SEGMENTS = {
|
|
175
181
|
year: true,
|
|
176
182
|
month: true,
|
|
177
183
|
day: true,
|
|
@@ -181,7 +187,7 @@ const $f23cc841f3588f43$var$EDITABLE_SEGMENTS = {
|
|
|
181
187
|
dayPeriod: true,
|
|
182
188
|
era: true
|
|
183
189
|
};
|
|
184
|
-
const $
|
|
190
|
+
const $596a1f0f523d6752$var$PAGE_STEP = {
|
|
185
191
|
year: 5,
|
|
186
192
|
month: 2,
|
|
187
193
|
day: 7,
|
|
@@ -190,19 +196,20 @@ const $f23cc841f3588f43$var$PAGE_STEP = {
|
|
|
190
196
|
second: 15
|
|
191
197
|
};
|
|
192
198
|
// Node seems to convert everything to lowercase...
|
|
193
|
-
const $
|
|
199
|
+
const $596a1f0f523d6752$var$TYPE_MAPPING = {
|
|
194
200
|
dayperiod: 'dayPeriod'
|
|
195
201
|
};
|
|
196
|
-
function $
|
|
197
|
-
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone } = props;
|
|
202
|
+
function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
203
|
+
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone , isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired } = props;
|
|
198
204
|
let v1 = props.value || props.defaultValue || props.placeholderValue;
|
|
199
|
-
let [granularity, defaultTimeZone] = $
|
|
205
|
+
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v1, props.granularity);
|
|
200
206
|
let timeZone = defaultTimeZone || 'UTC';
|
|
201
207
|
// props.granularity must actually exist in the value if one is provided.
|
|
202
208
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
203
|
-
|
|
209
|
+
var _maxGranularity;
|
|
210
|
+
let formatOpts = $h2qOe$react.useMemo(()=>({
|
|
204
211
|
granularity: granularity,
|
|
205
|
-
maxGranularity: props.maxGranularity
|
|
212
|
+
maxGranularity: (_maxGranularity = props.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year',
|
|
206
213
|
timeZone: defaultTimeZone,
|
|
207
214
|
hideTimeZone: hideTimeZone,
|
|
208
215
|
hourCycle: props.hourCycle
|
|
@@ -214,35 +221,35 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
214
221
|
defaultTimeZone,
|
|
215
222
|
hideTimeZone
|
|
216
223
|
]);
|
|
217
|
-
let opts = $
|
|
224
|
+
let opts = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$7e319ea407e63bc0({
|
|
218
225
|
}, formatOpts)
|
|
219
226
|
, [
|
|
220
227
|
formatOpts
|
|
221
228
|
]);
|
|
222
|
-
let dateFormatter = $
|
|
229
|
+
let dateFormatter = $h2qOe$react.useMemo(()=>new $h2qOe$internationalizeddate.DateFormatter(locale, opts)
|
|
223
230
|
, [
|
|
224
231
|
locale,
|
|
225
232
|
opts
|
|
226
233
|
]);
|
|
227
|
-
let resolvedOptions = $
|
|
234
|
+
let resolvedOptions = $h2qOe$react.useMemo(()=>dateFormatter.resolvedOptions()
|
|
228
235
|
, [
|
|
229
236
|
dateFormatter
|
|
230
237
|
]);
|
|
231
|
-
let calendar = $
|
|
238
|
+
let calendar = $h2qOe$react.useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
232
239
|
, [
|
|
233
240
|
createCalendar,
|
|
234
241
|
resolvedOptions.calendar
|
|
235
242
|
]);
|
|
236
243
|
// Determine how many editable segments there are for validation purposes.
|
|
237
244
|
// The result is cached for performance.
|
|
238
|
-
let allSegments = $
|
|
245
|
+
let allSegments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]
|
|
239
246
|
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
240
247
|
, {
|
|
241
248
|
})
|
|
242
249
|
, [
|
|
243
250
|
dateFormatter
|
|
244
251
|
]);
|
|
245
|
-
let [validSegments, setValidSegments] = $
|
|
252
|
+
let [validSegments, setValidSegments] = $h2qOe$react.useState(()=>props.value || props.defaultValue ? {
|
|
246
253
|
...allSegments
|
|
247
254
|
} : {
|
|
248
255
|
}
|
|
@@ -251,14 +258,14 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
251
258
|
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
252
259
|
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
253
260
|
// change from uncontrolled to controlled and emit a warning.
|
|
254
|
-
let [placeholderDate, setPlaceholderDate] = $
|
|
261
|
+
let [placeholderDate, setPlaceholderDate] = $h2qOe$react.useState(()=>$50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
255
262
|
);
|
|
256
263
|
// Reset placeholder when calendar changes
|
|
257
|
-
let lastCalendarIdentifier = $
|
|
258
|
-
$
|
|
264
|
+
let lastCalendarIdentifier = $h2qOe$react.useRef(calendar.identifier);
|
|
265
|
+
$h2qOe$react.useEffect(()=>{
|
|
259
266
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
260
267
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
261
|
-
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $
|
|
268
|
+
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $h2qOe$internationalizeddate.toCalendar(placeholder, calendar) : $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
262
269
|
);
|
|
263
270
|
}
|
|
264
271
|
}, [
|
|
@@ -268,8 +275,8 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
268
275
|
defaultTimeZone,
|
|
269
276
|
props.placeholderValue
|
|
270
277
|
]);
|
|
271
|
-
let [value1, setDate] = $
|
|
272
|
-
let calendarValue = $
|
|
278
|
+
let [value1, setDate] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
279
|
+
let calendarValue = $h2qOe$react.useMemo(()=>$50d5d6a623389320$export$61a490a80c552550(value1, calendar)
|
|
273
280
|
, [
|
|
274
281
|
value1,
|
|
275
282
|
calendar
|
|
@@ -286,7 +293,7 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
286
293
|
validSegments = {
|
|
287
294
|
};
|
|
288
295
|
setValidSegments(validSegments);
|
|
289
|
-
setPlaceholderDate($
|
|
296
|
+
setPlaceholderDate($50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
290
297
|
}
|
|
291
298
|
// If all segments are valid, use the date from state, otherwise use the placeholder date.
|
|
292
299
|
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
|
|
@@ -295,23 +302,23 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
295
302
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) {
|
|
296
303
|
// The display calendar should not have any effect on the emitted value.
|
|
297
304
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
298
|
-
newValue = $
|
|
305
|
+
newValue = $h2qOe$internationalizeddate.toCalendar(newValue, (v1 === null || v1 === void 0 ? void 0 : v1.calendar) || new $h2qOe$internationalizeddate.GregorianCalendar());
|
|
299
306
|
setDate(newValue);
|
|
300
307
|
} else setPlaceholderDate(newValue);
|
|
301
308
|
};
|
|
302
|
-
let dateValue = $
|
|
309
|
+
let dateValue = $h2qOe$react.useMemo(()=>displayValue.toDate(timeZone)
|
|
303
310
|
, [
|
|
304
311
|
displayValue,
|
|
305
312
|
timeZone
|
|
306
313
|
]);
|
|
307
|
-
let segments = $
|
|
308
|
-
let isEditable = $
|
|
314
|
+
let segments = $h2qOe$react.useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
315
|
+
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
309
316
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
310
317
|
return {
|
|
311
|
-
type: $
|
|
318
|
+
type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
312
319
|
text: segment.value,
|
|
313
|
-
...$
|
|
314
|
-
isPlaceholder: $
|
|
320
|
+
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
321
|
+
isPlaceholder: $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type],
|
|
315
322
|
isEditable: isEditable
|
|
316
323
|
};
|
|
317
324
|
})
|
|
@@ -323,7 +330,7 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
323
330
|
displayValue,
|
|
324
331
|
calendar
|
|
325
332
|
]);
|
|
326
|
-
let hasEra = $
|
|
333
|
+
let hasEra = $h2qOe$react.useMemo(()=>segments.some((s)=>s.type === 'era'
|
|
327
334
|
)
|
|
328
335
|
, [
|
|
329
336
|
segments
|
|
@@ -337,9 +344,9 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
337
344
|
};
|
|
338
345
|
let adjustSegment = (type, amount)=>{
|
|
339
346
|
markValid(type);
|
|
340
|
-
setValue($
|
|
347
|
+
setValue($596a1f0f523d6752$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
341
348
|
};
|
|
342
|
-
let validationState = props.validationState || ($
|
|
349
|
+
let validationState = props.validationState || ($50d5d6a623389320$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
343
350
|
return {
|
|
344
351
|
value: calendarValue,
|
|
345
352
|
dateValue: dateValue,
|
|
@@ -348,6 +355,9 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
348
355
|
dateFormatter: dateFormatter,
|
|
349
356
|
validationState: validationState,
|
|
350
357
|
granularity: granularity,
|
|
358
|
+
isDisabled: isDisabled,
|
|
359
|
+
isReadOnly: isReadOnly,
|
|
360
|
+
isRequired: isRequired,
|
|
351
361
|
increment (part) {
|
|
352
362
|
adjustSegment(part, 1);
|
|
353
363
|
},
|
|
@@ -355,14 +365,14 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
355
365
|
adjustSegment(part, -1);
|
|
356
366
|
},
|
|
357
367
|
incrementPage (part) {
|
|
358
|
-
adjustSegment(part, $
|
|
368
|
+
adjustSegment(part, $596a1f0f523d6752$var$PAGE_STEP[part] || 1);
|
|
359
369
|
},
|
|
360
370
|
decrementPage (part) {
|
|
361
|
-
adjustSegment(part, -($
|
|
371
|
+
adjustSegment(part, -($596a1f0f523d6752$var$PAGE_STEP[part] || 1));
|
|
362
372
|
},
|
|
363
373
|
setSegment (part, v) {
|
|
364
374
|
markValid(part);
|
|
365
|
-
setValue($
|
|
375
|
+
setValue($596a1f0f523d6752$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
366
376
|
},
|
|
367
377
|
confirmPlaceholder (part) {
|
|
368
378
|
if (props.isDisabled || props.isReadOnly) return;
|
|
@@ -386,7 +396,7 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
386
396
|
setValidSegments({
|
|
387
397
|
...validSegments
|
|
388
398
|
});
|
|
389
|
-
let placeholder = $
|
|
399
|
+
let placeholder = $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
390
400
|
let value = displayValue;
|
|
391
401
|
// Reset day period to default without changing the hour.
|
|
392
402
|
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
@@ -404,12 +414,15 @@ function $f23cc841f3588f43$export$714a241b39a650d6(props) {
|
|
|
404
414
|
setDate(null);
|
|
405
415
|
setValue(value);
|
|
406
416
|
},
|
|
407
|
-
|
|
408
|
-
|
|
417
|
+
formatValue (fieldOptions) {
|
|
418
|
+
if (!calendarValue) return '';
|
|
419
|
+
let formatOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
420
|
+
let formatter = new $h2qOe$internationalizeddate.DateFormatter(locale, formatOptions);
|
|
421
|
+
return formatter.format(dateValue);
|
|
409
422
|
}
|
|
410
423
|
};
|
|
411
424
|
}
|
|
412
|
-
function $
|
|
425
|
+
function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
413
426
|
switch(type){
|
|
414
427
|
case 'era':
|
|
415
428
|
{
|
|
@@ -429,13 +442,13 @@ function $f23cc841f3588f43$var$getSegmentLimits(date, type, options) {
|
|
|
429
442
|
case 'month':
|
|
430
443
|
return {
|
|
431
444
|
value: date.month,
|
|
432
|
-
minValue: $
|
|
445
|
+
minValue: $h2qOe$internationalizeddate.getMinimumMonthInYear(date),
|
|
433
446
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
434
447
|
};
|
|
435
448
|
case 'day':
|
|
436
449
|
return {
|
|
437
450
|
value: date.day,
|
|
438
|
-
minValue: $
|
|
451
|
+
minValue: $h2qOe$internationalizeddate.getMinimumDayInMonth(date),
|
|
439
452
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
440
453
|
};
|
|
441
454
|
}
|
|
@@ -476,7 +489,7 @@ function $f23cc841f3588f43$var$getSegmentLimits(date, type, options) {
|
|
|
476
489
|
return {
|
|
477
490
|
};
|
|
478
491
|
}
|
|
479
|
-
function $
|
|
492
|
+
function $596a1f0f523d6752$var$addSegment(value, part, amount, options) {
|
|
480
493
|
switch(part){
|
|
481
494
|
case 'era':
|
|
482
495
|
case 'year':
|
|
@@ -504,7 +517,7 @@ function $f23cc841f3588f43$var$addSegment(value, part, amount, options) {
|
|
|
504
517
|
});
|
|
505
518
|
}
|
|
506
519
|
}
|
|
507
|
-
function $
|
|
520
|
+
function $596a1f0f523d6752$var$setSegment(value, part, segmentValue, options) {
|
|
508
521
|
switch(part){
|
|
509
522
|
case 'day':
|
|
510
523
|
case 'month':
|
|
@@ -542,17 +555,18 @@ function $f23cc841f3588f43$var$setSegment(value, part, segmentValue, options) {
|
|
|
542
555
|
}
|
|
543
556
|
|
|
544
557
|
|
|
545
|
-
var $
|
|
558
|
+
var $7072d26f58deb33b$exports = {};
|
|
546
559
|
|
|
547
|
-
$parcel$export($
|
|
560
|
+
$parcel$export($7072d26f58deb33b$exports, "useDateRangePickerState", () => $7072d26f58deb33b$export$e50a61c1de9f574);
|
|
548
561
|
|
|
549
562
|
|
|
550
563
|
|
|
551
564
|
|
|
552
|
-
function $
|
|
553
|
-
|
|
554
|
-
let [
|
|
555
|
-
let [
|
|
565
|
+
function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
|
|
566
|
+
var ref, ref1;
|
|
567
|
+
let [isOpen1, setOpen] = $h2qOe$react.useState(false);
|
|
568
|
+
let [controlledValue, setControlledValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
569
|
+
let [placeholderValue, setPlaceholderValue] = $h2qOe$react.useState(()=>controlledValue || {
|
|
556
570
|
start: null,
|
|
557
571
|
end: null
|
|
558
572
|
}
|
|
@@ -566,49 +580,56 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
566
580
|
setPlaceholderValue(placeholderValue);
|
|
567
581
|
}
|
|
568
582
|
let value1 = controlledValue || placeholderValue;
|
|
569
|
-
let valueRef = $
|
|
583
|
+
let valueRef = $h2qOe$react.useRef(value1);
|
|
570
584
|
valueRef.current = value1;
|
|
571
585
|
let setValue = (value)=>{
|
|
572
586
|
valueRef.current = value;
|
|
573
587
|
setPlaceholderValue(value);
|
|
574
|
-
if (value
|
|
588
|
+
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) setControlledValue(value);
|
|
575
589
|
else setControlledValue(null);
|
|
576
590
|
};
|
|
577
|
-
let v = value1
|
|
578
|
-
let [granularity, defaultTimeZone] = $
|
|
591
|
+
let v = (value1 === null || value1 === void 0 ? void 0 : value1.start) || (value1 === null || value1 === void 0 ? void 0 : value1.end) || props.placeholderValue;
|
|
592
|
+
let [granularity, defaultTimeZone] = $50d5d6a623389320$export$2440da353cedad43(v, props.granularity);
|
|
579
593
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
580
|
-
|
|
581
|
-
let
|
|
594
|
+
var _shouldCloseOnSelect;
|
|
595
|
+
let shouldCloseOnSelect = (_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _shouldCloseOnSelect !== void 0 ? _shouldCloseOnSelect : true;
|
|
596
|
+
let [dateRange1, setSelectedDateRange] = $h2qOe$react.useState(null);
|
|
597
|
+
let [timeRange1, setSelectedTimeRange] = $h2qOe$react.useState(null);
|
|
582
598
|
if (value1 && value1.start && value1.end) {
|
|
583
599
|
dateRange1 = value1;
|
|
584
600
|
if ('hour' in value1.start) timeRange1 = value1;
|
|
585
601
|
}
|
|
586
602
|
let commitValue = (dateRange, timeRange)=>{
|
|
587
603
|
setValue({
|
|
588
|
-
start: 'timeZone' in timeRange.start ? timeRange.start.set($
|
|
589
|
-
end: 'timeZone' in timeRange.end ? timeRange.end.set($
|
|
604
|
+
start: 'timeZone' in timeRange.start ? timeRange.start.set($h2qOe$internationalizeddate.toCalendarDate(dateRange.start)) : $h2qOe$internationalizeddate.toCalendarDateTime(dateRange.start, timeRange.start),
|
|
605
|
+
end: 'timeZone' in timeRange.end ? timeRange.end.set($h2qOe$internationalizeddate.toCalendarDate(dateRange.end)) : $h2qOe$internationalizeddate.toCalendarDateTime(dateRange.end, timeRange.end)
|
|
590
606
|
});
|
|
591
607
|
};
|
|
592
608
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
593
609
|
let setDateRange = (range)=>{
|
|
610
|
+
let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
|
|
594
611
|
if (hasTime) {
|
|
595
|
-
if (range.start && range.end && timeRange1
|
|
612
|
+
if (shouldClose || range.start && range.end && (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) && (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end)) commitValue(range, {
|
|
613
|
+
start: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
614
|
+
end: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
615
|
+
});
|
|
596
616
|
else setSelectedDateRange(range);
|
|
597
617
|
} else if (range.start && range.end) setValue(range);
|
|
598
618
|
else setSelectedDateRange(range);
|
|
599
|
-
if (
|
|
619
|
+
if (shouldClose) setOpen(false);
|
|
600
620
|
};
|
|
601
621
|
let setTimeRange = (range)=>{
|
|
602
|
-
if (dateRange1
|
|
622
|
+
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
623
|
else setSelectedTimeRange(range);
|
|
604
624
|
};
|
|
605
|
-
let validationState = props.validationState || (value1 != null && ($
|
|
625
|
+
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 || (value1 === null || value1 === void 0 ? void 0 : value1.start) && ((ref = props.isDateUnavailable) === null || ref === void 0 ? void 0 : ref.call(props, value1.start)) || (value1 === null || value1 === void 0 ? void 0 : value1.end) && ((ref1 = props.isDateUnavailable) === null || ref1 === void 0 ? void 0 : ref1.call(props, value1.end))) ? 'invalid' : null);
|
|
606
626
|
return {
|
|
607
627
|
value: value1,
|
|
608
628
|
setValue: setValue,
|
|
609
629
|
dateRange: dateRange1,
|
|
610
630
|
timeRange: timeRange1,
|
|
611
631
|
granularity: granularity,
|
|
632
|
+
hasTime: hasTime,
|
|
612
633
|
setDate (part, date) {
|
|
613
634
|
setDateRange({
|
|
614
635
|
...dateRange1,
|
|
@@ -634,9 +655,9 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
634
655
|
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
635
656
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
636
657
|
// the user opens the popover again.
|
|
637
|
-
if (!isOpen && !(value1
|
|
638
|
-
start: timeRange1
|
|
639
|
-
end: timeRange1
|
|
658
|
+
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, {
|
|
659
|
+
start: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
660
|
+
end: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end) || $50d5d6a623389320$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
640
661
|
});
|
|
641
662
|
setOpen(isOpen);
|
|
642
663
|
},
|
|
@@ -647,13 +668,13 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
647
668
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
648
669
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
649
670
|
let endGranularity = props.granularity || (value1.end && 'minute' in value1.end ? 'minute' : 'day');
|
|
650
|
-
let startOptions = $
|
|
671
|
+
let startOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
651
672
|
granularity: startGranularity,
|
|
652
673
|
timeZone: startTimeZone,
|
|
653
674
|
hideTimeZone: props.hideTimeZone,
|
|
654
675
|
hourCycle: props.hourCycle
|
|
655
676
|
});
|
|
656
|
-
let startFormatter = new $
|
|
677
|
+
let startFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, startOptions);
|
|
657
678
|
let endFormatter;
|
|
658
679
|
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
659
680
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
@@ -666,13 +687,13 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
666
687
|
}
|
|
667
688
|
endFormatter = startFormatter;
|
|
668
689
|
} else {
|
|
669
|
-
let endOptions = $
|
|
690
|
+
let endOptions = $50d5d6a623389320$export$7e319ea407e63bc0(fieldOptions, {
|
|
670
691
|
granularity: endGranularity,
|
|
671
692
|
timeZone: endTimeZone,
|
|
672
693
|
hideTimeZone: props.hideTimeZone,
|
|
673
694
|
hourCycle: props.hourCycle
|
|
674
695
|
});
|
|
675
|
-
endFormatter = new $
|
|
696
|
+
endFormatter = new $h2qOe$internationalizeddate.DateFormatter(locale, endOptions);
|
|
676
697
|
}
|
|
677
698
|
return `${startFormatter.format(value1.start.toDate(startTimeZone))} – ${endFormatter.format(value1.end.toDate(endTimeZone))}`;
|
|
678
699
|
},
|
|
@@ -682,7 +703,7 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
682
703
|
let value = valueRef.current;
|
|
683
704
|
if (value && Boolean(value.start) !== Boolean(value.end)) {
|
|
684
705
|
let calendar = (value.start || value.end).calendar;
|
|
685
|
-
let placeholder = $
|
|
706
|
+
let placeholder = $50d5d6a623389320$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
686
707
|
setValue({
|
|
687
708
|
start: value.start || placeholder,
|
|
688
709
|
end: value.end || placeholder
|
|
@@ -693,40 +714,40 @@ function $85a6c757c811abb9$export$e50a61c1de9f574(props) {
|
|
|
693
714
|
}
|
|
694
715
|
|
|
695
716
|
|
|
696
|
-
var $
|
|
717
|
+
var $2654e87be0231a69$exports = {};
|
|
697
718
|
|
|
698
|
-
$parcel$export($
|
|
719
|
+
$parcel$export($2654e87be0231a69$exports, "useTimeFieldState", () => $2654e87be0231a69$export$fd53cef0cc796101);
|
|
699
720
|
|
|
700
721
|
|
|
701
722
|
|
|
702
723
|
|
|
703
|
-
function $
|
|
704
|
-
let { placeholderValue: placeholderValue = new $
|
|
705
|
-
let [value, setValue] = $
|
|
724
|
+
function $2654e87be0231a69$export$fd53cef0cc796101(props) {
|
|
725
|
+
let { placeholderValue: placeholderValue = new $h2qOe$internationalizeddate.Time() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
726
|
+
let [value, setValue] = $h2qOe$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
|
|
706
727
|
let v = value || placeholderValue;
|
|
707
728
|
let day = v && 'day' in v ? v : undefined;
|
|
708
|
-
let placeholderDate = $
|
|
729
|
+
let placeholderDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(placeholderValue)
|
|
709
730
|
, [
|
|
710
731
|
placeholderValue
|
|
711
732
|
]);
|
|
712
|
-
let minDate = $
|
|
733
|
+
let minDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(minValue, day)
|
|
713
734
|
, [
|
|
714
735
|
minValue,
|
|
715
736
|
day
|
|
716
737
|
]);
|
|
717
|
-
let maxDate = $
|
|
738
|
+
let maxDate = $h2qOe$react.useMemo(()=>$2654e87be0231a69$var$convertValue(maxValue, day)
|
|
718
739
|
, [
|
|
719
740
|
maxValue,
|
|
720
741
|
day
|
|
721
742
|
]);
|
|
722
|
-
let dateTime = $
|
|
743
|
+
let dateTime = $h2qOe$react.useMemo(()=>value == null ? null : $2654e87be0231a69$var$convertValue(value)
|
|
723
744
|
, [
|
|
724
745
|
value
|
|
725
746
|
]);
|
|
726
747
|
let onChange = (newValue)=>{
|
|
727
|
-
setValue(v && 'day' in v ? newValue : newValue && $
|
|
748
|
+
setValue(v && 'day' in v ? newValue : newValue && $h2qOe$internationalizeddate.toTime(newValue));
|
|
728
749
|
};
|
|
729
|
-
return $
|
|
750
|
+
return $596a1f0f523d6752$export$60e84778edff6d26({
|
|
730
751
|
...props,
|
|
731
752
|
value: dateTime,
|
|
732
753
|
defaultValue: undefined,
|
|
@@ -735,20 +756,22 @@ function $ef228128a792346b$export$fd53cef0cc796101(props) {
|
|
|
735
756
|
onChange: onChange,
|
|
736
757
|
granularity: granularity || 'minute',
|
|
737
758
|
maxGranularity: 'hour',
|
|
738
|
-
placeholderValue: placeholderDate
|
|
759
|
+
placeholderValue: placeholderDate,
|
|
760
|
+
// Calendar should not matter for time fields.
|
|
761
|
+
createCalendar: ()=>new $h2qOe$internationalizeddate.GregorianCalendar()
|
|
739
762
|
});
|
|
740
763
|
}
|
|
741
|
-
function $
|
|
764
|
+
function $2654e87be0231a69$var$convertValue(value, date = $h2qOe$internationalizeddate.today($h2qOe$internationalizeddate.getLocalTimeZone())) {
|
|
742
765
|
if (!value) return null;
|
|
743
766
|
if ('day' in value) return value;
|
|
744
|
-
return $
|
|
767
|
+
return $h2qOe$internationalizeddate.toCalendarDateTime(date, value);
|
|
745
768
|
}
|
|
746
769
|
|
|
747
770
|
|
|
748
|
-
$parcel$exportWildcard(module.exports, $
|
|
749
|
-
$parcel$exportWildcard(module.exports, $
|
|
750
|
-
$parcel$exportWildcard(module.exports, $
|
|
751
|
-
$parcel$exportWildcard(module.exports, $
|
|
771
|
+
$parcel$exportWildcard(module.exports, $aaab7a647e17e1fd$exports);
|
|
772
|
+
$parcel$exportWildcard(module.exports, $596a1f0f523d6752$exports);
|
|
773
|
+
$parcel$exportWildcard(module.exports, $7072d26f58deb33b$exports);
|
|
774
|
+
$parcel$exportWildcard(module.exports, $2654e87be0231a69$exports);
|
|
752
775
|
|
|
753
776
|
|
|
754
777
|
//# sourceMappingURL=main.js.map
|