@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/module.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {toDateFields as $
|
|
2
|
-
import {useControlledState as $
|
|
3
|
-
import {useState as $
|
|
1
|
+
import {toDateFields as $7UzoM$toDateFields, toCalendarDateTime as $7UzoM$toCalendarDateTime, DateFormatter as $7UzoM$DateFormatter, Time as $7UzoM$Time, toCalendar as $7UzoM$toCalendar, now as $7UzoM$now, toCalendarDate as $7UzoM$toCalendarDate, GregorianCalendar as $7UzoM$GregorianCalendar, getMinimumMonthInYear as $7UzoM$getMinimumMonthInYear, getMinimumDayInMonth as $7UzoM$getMinimumDayInMonth, toTime as $7UzoM$toTime, today as $7UzoM$today, getLocalTimeZone as $7UzoM$getLocalTimeZone} from "@internationalized/date";
|
|
2
|
+
import {useControlledState as $7UzoM$useControlledState} from "@react-stately/utils";
|
|
3
|
+
import {useState as $7UzoM$useState, useRef as $7UzoM$useRef, useMemo as $7UzoM$useMemo, useEffect as $7UzoM$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 $ab5bf3f618090389$exports = {};
|
|
9
9
|
|
|
10
|
-
$parcel$export($
|
|
10
|
+
$parcel$export($ab5bf3f618090389$exports, "useDatePickerState", () => $ab5bf3f618090389$export$87194bb378cc3ac2);
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
function $
|
|
14
|
+
function $35a22f14a1f04b11$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 $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS = {
|
|
18
18
|
year: 'numeric',
|
|
19
19
|
month: 'numeric',
|
|
20
20
|
day: 'numeric',
|
|
@@ -22,14 +22,15 @@ const $1041af8c30a3d476$var$DEFAULT_FIELD_OPTIONS = {
|
|
|
22
22
|
minute: '2-digit',
|
|
23
23
|
second: '2-digit'
|
|
24
24
|
};
|
|
25
|
-
function $
|
|
25
|
+
function $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
26
26
|
fieldOptions = {
|
|
27
|
-
...$
|
|
27
|
+
...$35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS,
|
|
28
28
|
...fieldOptions
|
|
29
29
|
};
|
|
30
30
|
let granularity = options.granularity || 'minute';
|
|
31
31
|
let keys = Object.keys(fieldOptions);
|
|
32
|
-
|
|
32
|
+
var _maxGranularity;
|
|
33
|
+
let startIdx = keys.indexOf((_maxGranularity = options.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year');
|
|
33
34
|
if (startIdx < 0) startIdx = 0;
|
|
34
35
|
let endIdx = keys.indexOf(granularity);
|
|
35
36
|
if (endIdx < 0) endIdx = 2;
|
|
@@ -45,30 +46,30 @@ function $1041af8c30a3d476$export$7e319ea407e63bc0(fieldOptions, options) {
|
|
|
45
46
|
if (hasTime && options.timeZone && !options.hideTimeZone) opts1.timeZoneName = 'short';
|
|
46
47
|
return opts1;
|
|
47
48
|
}
|
|
48
|
-
function $
|
|
49
|
+
function $35a22f14a1f04b11$export$c5221a78ef73c5e9(placeholderValue) {
|
|
49
50
|
if (placeholderValue && 'hour' in placeholderValue) return placeholderValue;
|
|
50
|
-
return new $
|
|
51
|
+
return new $7UzoM$Time();
|
|
51
52
|
}
|
|
52
|
-
function $
|
|
53
|
+
function $35a22f14a1f04b11$export$61a490a80c552550(value, calendar) {
|
|
53
54
|
if (value === null) return null;
|
|
54
55
|
if (!value) return undefined;
|
|
55
|
-
return $
|
|
56
|
+
return $7UzoM$toCalendar(value, calendar);
|
|
56
57
|
}
|
|
57
|
-
function $
|
|
58
|
-
if (placeholderValue) return $
|
|
59
|
-
let date = $
|
|
58
|
+
function $35a22f14a1f04b11$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
|
|
59
|
+
if (placeholderValue) return $35a22f14a1f04b11$export$61a490a80c552550(placeholderValue, calendar);
|
|
60
|
+
let date = $7UzoM$toCalendar($7UzoM$now(timeZone).set({
|
|
60
61
|
hour: 0,
|
|
61
62
|
minute: 0,
|
|
62
63
|
second: 0,
|
|
63
64
|
millisecond: 0
|
|
64
65
|
}), calendar);
|
|
65
|
-
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $
|
|
66
|
-
if (!timeZone) return $
|
|
66
|
+
if (granularity === 'year' || granularity === 'month' || granularity === 'day') return $7UzoM$toCalendarDate(date);
|
|
67
|
+
if (!timeZone) return $7UzoM$toCalendarDateTime(date);
|
|
67
68
|
return date;
|
|
68
69
|
}
|
|
69
|
-
function $
|
|
70
|
+
function $35a22f14a1f04b11$export$2440da353cedad43(v, granularity) {
|
|
70
71
|
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
|
|
71
|
-
let lastValue = $
|
|
72
|
+
let lastValue = $7UzoM$useRef(v);
|
|
72
73
|
if (v) lastValue.current = v;
|
|
73
74
|
v = lastValue.current;
|
|
74
75
|
let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;
|
|
@@ -85,15 +86,15 @@ function $1041af8c30a3d476$export$2440da353cedad43(v, granularity) {
|
|
|
85
86
|
|
|
86
87
|
|
|
87
88
|
|
|
88
|
-
function $
|
|
89
|
-
let [isOpen1, setOpen] = $
|
|
90
|
-
let [value, setValue] = $
|
|
89
|
+
function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
|
|
90
|
+
let [isOpen1, setOpen] = $7UzoM$useState(false);
|
|
91
|
+
let [value, setValue] = $7UzoM$useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
91
92
|
let v = value || props.placeholderValue;
|
|
92
|
-
let [granularity, defaultTimeZone] = $
|
|
93
|
-
let dateValue = value != null ? value.toDate(defaultTimeZone
|
|
93
|
+
let [granularity, defaultTimeZone] = $35a22f14a1f04b11$export$2440da353cedad43(v, props.granularity);
|
|
94
|
+
let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : 'UTC') : null;
|
|
94
95
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
95
|
-
let [selectedDate, setSelectedDate] = $
|
|
96
|
-
let [selectedTime, setSelectedTime] = $
|
|
96
|
+
let [selectedDate, setSelectedDate] = $7UzoM$useState(null);
|
|
97
|
+
let [selectedTime, setSelectedTime] = $7UzoM$useState(null);
|
|
97
98
|
if (value) {
|
|
98
99
|
selectedDate = value;
|
|
99
100
|
if ('hour' in value) selectedTime = value;
|
|
@@ -101,7 +102,7 @@ function $e9af7896aa0f34cc$export$87194bb378cc3ac2(props) {
|
|
|
101
102
|
// props.granularity must actually exist in the value if one is provided.
|
|
102
103
|
if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
|
|
103
104
|
let commitValue = (date, time)=>{
|
|
104
|
-
setValue('timeZone' in time ? time.set($
|
|
105
|
+
setValue('timeZone' in time ? time.set($7UzoM$toDateFields(date)) : $7UzoM$toCalendarDateTime(date, time));
|
|
105
106
|
};
|
|
106
107
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
107
108
|
let selectDate = (newValue)=>{
|
|
@@ -115,7 +116,7 @@ function $e9af7896aa0f34cc$export$87194bb378cc3ac2(props) {
|
|
|
115
116
|
if (selectedDate) commitValue(selectedDate, newValue);
|
|
116
117
|
else setSelectedTime(newValue);
|
|
117
118
|
};
|
|
118
|
-
let validationState = props.validationState || ($
|
|
119
|
+
let validationState = props.validationState || ($35a22f14a1f04b11$export$eac50920cf2fd59a(value, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
119
120
|
return {
|
|
120
121
|
value: value,
|
|
121
122
|
setValue: setValue,
|
|
@@ -129,33 +130,33 @@ function $e9af7896aa0f34cc$export$87194bb378cc3ac2(props) {
|
|
|
129
130
|
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
130
131
|
// If only the time was set and not the date, don't commit. The state will be preserved until
|
|
131
132
|
// the user opens the popover again.
|
|
132
|
-
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $
|
|
133
|
+
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || $35a22f14a1f04b11$export$c5221a78ef73c5e9(props.placeholderValue));
|
|
133
134
|
setOpen(isOpen);
|
|
134
135
|
},
|
|
135
136
|
validationState: validationState,
|
|
136
137
|
formatValue (locale, fieldOptions) {
|
|
137
138
|
if (!dateValue) return '';
|
|
138
|
-
let formatOptions = $
|
|
139
|
+
let formatOptions = $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, {
|
|
139
140
|
granularity: granularity,
|
|
140
141
|
timeZone: defaultTimeZone,
|
|
141
142
|
hideTimeZone: props.hideTimeZone,
|
|
142
143
|
hourCycle: props.hourCycle
|
|
143
144
|
});
|
|
144
|
-
let formatter = new $
|
|
145
|
+
let formatter = new $7UzoM$DateFormatter(locale, formatOptions);
|
|
145
146
|
return formatter.format(dateValue);
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
|
|
151
|
-
var $
|
|
152
|
+
var $09e80d602234613d$exports = {};
|
|
152
153
|
|
|
153
|
-
$parcel$export($
|
|
154
|
+
$parcel$export($09e80d602234613d$exports, "useDatePickerFieldState", () => $09e80d602234613d$export$714a241b39a650d6);
|
|
154
155
|
|
|
155
156
|
|
|
156
157
|
|
|
157
158
|
|
|
158
|
-
const $
|
|
159
|
+
const $09e80d602234613d$var$EDITABLE_SEGMENTS = {
|
|
159
160
|
year: true,
|
|
160
161
|
month: true,
|
|
161
162
|
day: true,
|
|
@@ -165,7 +166,7 @@ const $4398a1af81ae1348$var$EDITABLE_SEGMENTS = {
|
|
|
165
166
|
dayPeriod: true,
|
|
166
167
|
era: true
|
|
167
168
|
};
|
|
168
|
-
const $
|
|
169
|
+
const $09e80d602234613d$var$PAGE_STEP = {
|
|
169
170
|
year: 5,
|
|
170
171
|
month: 2,
|
|
171
172
|
day: 7,
|
|
@@ -174,19 +175,20 @@ const $4398a1af81ae1348$var$PAGE_STEP = {
|
|
|
174
175
|
second: 15
|
|
175
176
|
};
|
|
176
177
|
// Node seems to convert everything to lowercase...
|
|
177
|
-
const $
|
|
178
|
+
const $09e80d602234613d$var$TYPE_MAPPING = {
|
|
178
179
|
dayperiod: 'dayPeriod'
|
|
179
180
|
};
|
|
180
|
-
function $
|
|
181
|
+
function $09e80d602234613d$export$714a241b39a650d6(props) {
|
|
181
182
|
let { locale: locale , createCalendar: createCalendar , hideTimeZone: hideTimeZone } = props;
|
|
182
183
|
let v1 = props.value || props.defaultValue || props.placeholderValue;
|
|
183
|
-
let [granularity, defaultTimeZone] = $
|
|
184
|
+
let [granularity, defaultTimeZone] = $35a22f14a1f04b11$export$2440da353cedad43(v1, props.granularity);
|
|
184
185
|
let timeZone = defaultTimeZone || 'UTC';
|
|
185
186
|
// props.granularity must actually exist in the value if one is provided.
|
|
186
187
|
if (v1 && !(granularity in v1)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v1.toString());
|
|
187
|
-
|
|
188
|
+
var _maxGranularity;
|
|
189
|
+
let formatOpts = $7UzoM$useMemo(()=>({
|
|
188
190
|
granularity: granularity,
|
|
189
|
-
maxGranularity: props.maxGranularity
|
|
191
|
+
maxGranularity: (_maxGranularity = props.maxGranularity) !== null && _maxGranularity !== void 0 ? _maxGranularity : 'year',
|
|
190
192
|
timeZone: defaultTimeZone,
|
|
191
193
|
hideTimeZone: hideTimeZone,
|
|
192
194
|
hourCycle: props.hourCycle
|
|
@@ -198,35 +200,35 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
198
200
|
defaultTimeZone,
|
|
199
201
|
hideTimeZone
|
|
200
202
|
]);
|
|
201
|
-
let opts = $
|
|
203
|
+
let opts = $7UzoM$useMemo(()=>$35a22f14a1f04b11$export$7e319ea407e63bc0({
|
|
202
204
|
}, formatOpts)
|
|
203
205
|
, [
|
|
204
206
|
formatOpts
|
|
205
207
|
]);
|
|
206
|
-
let dateFormatter = $
|
|
208
|
+
let dateFormatter = $7UzoM$useMemo(()=>new $7UzoM$DateFormatter(locale, opts)
|
|
207
209
|
, [
|
|
208
210
|
locale,
|
|
209
211
|
opts
|
|
210
212
|
]);
|
|
211
|
-
let resolvedOptions = $
|
|
213
|
+
let resolvedOptions = $7UzoM$useMemo(()=>dateFormatter.resolvedOptions()
|
|
212
214
|
, [
|
|
213
215
|
dateFormatter
|
|
214
216
|
]);
|
|
215
|
-
let calendar = $
|
|
217
|
+
let calendar = $7UzoM$useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
216
218
|
, [
|
|
217
219
|
createCalendar,
|
|
218
220
|
resolvedOptions.calendar
|
|
219
221
|
]);
|
|
220
222
|
// Determine how many editable segments there are for validation purposes.
|
|
221
223
|
// The result is cached for performance.
|
|
222
|
-
let allSegments = $
|
|
224
|
+
let allSegments = $7UzoM$useMemo(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$09e80d602234613d$var$EDITABLE_SEGMENTS[seg.type]
|
|
223
225
|
).reduce((p, seg)=>(p[seg.type] = true, p)
|
|
224
226
|
, {
|
|
225
227
|
})
|
|
226
228
|
, [
|
|
227
229
|
dateFormatter
|
|
228
230
|
]);
|
|
229
|
-
let [validSegments, setValidSegments] = $
|
|
231
|
+
let [validSegments, setValidSegments] = $7UzoM$useState(()=>props.value || props.defaultValue ? {
|
|
230
232
|
...allSegments
|
|
231
233
|
} : {
|
|
232
234
|
}
|
|
@@ -235,14 +237,14 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
235
237
|
// until all segments are set. If the value === null (not undefined), then assume the component
|
|
236
238
|
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
|
|
237
239
|
// change from uncontrolled to controlled and emit a warning.
|
|
238
|
-
let [placeholderDate, setPlaceholderDate] = $
|
|
240
|
+
let [placeholderDate, setPlaceholderDate] = $7UzoM$useState(()=>$35a22f14a1f04b11$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
239
241
|
);
|
|
240
242
|
// Reset placeholder when calendar changes
|
|
241
|
-
let lastCalendarIdentifier = $
|
|
242
|
-
$
|
|
243
|
+
let lastCalendarIdentifier = $7UzoM$useRef(calendar.identifier);
|
|
244
|
+
$7UzoM$useEffect(()=>{
|
|
243
245
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
244
246
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
245
|
-
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $
|
|
247
|
+
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? $7UzoM$toCalendar(placeholder, calendar) : $35a22f14a1f04b11$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone)
|
|
246
248
|
);
|
|
247
249
|
}
|
|
248
250
|
}, [
|
|
@@ -252,8 +254,8 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
252
254
|
defaultTimeZone,
|
|
253
255
|
props.placeholderValue
|
|
254
256
|
]);
|
|
255
|
-
let [value1, setDate] = $
|
|
256
|
-
let calendarValue = $
|
|
257
|
+
let [value1, setDate] = $7UzoM$useControlledState(props.value, props.defaultValue, props.onChange);
|
|
258
|
+
let calendarValue = $7UzoM$useMemo(()=>$35a22f14a1f04b11$export$61a490a80c552550(value1, calendar)
|
|
257
259
|
, [
|
|
258
260
|
value1,
|
|
259
261
|
calendar
|
|
@@ -270,7 +272,7 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
270
272
|
validSegments = {
|
|
271
273
|
};
|
|
272
274
|
setValidSegments(validSegments);
|
|
273
|
-
setPlaceholderDate($
|
|
275
|
+
setPlaceholderDate($35a22f14a1f04b11$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone));
|
|
274
276
|
}
|
|
275
277
|
// If all segments are valid, use the date from state, otherwise use the placeholder date.
|
|
276
278
|
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
|
|
@@ -279,23 +281,23 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
279
281
|
if (Object.keys(validSegments).length >= Object.keys(allSegments).length) {
|
|
280
282
|
// The display calendar should not have any effect on the emitted value.
|
|
281
283
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
282
|
-
newValue = $
|
|
284
|
+
newValue = $7UzoM$toCalendar(newValue, (v1 === null || v1 === void 0 ? void 0 : v1.calendar) || new $7UzoM$GregorianCalendar());
|
|
283
285
|
setDate(newValue);
|
|
284
286
|
} else setPlaceholderDate(newValue);
|
|
285
287
|
};
|
|
286
|
-
let dateValue = $
|
|
288
|
+
let dateValue = $7UzoM$useMemo(()=>displayValue.toDate(timeZone)
|
|
287
289
|
, [
|
|
288
290
|
displayValue,
|
|
289
291
|
timeZone
|
|
290
292
|
]);
|
|
291
|
-
let segments = $
|
|
292
|
-
let isEditable = $
|
|
293
|
+
let segments = $7UzoM$useMemo(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
|
|
294
|
+
let isEditable = $09e80d602234613d$var$EDITABLE_SEGMENTS[segment.type];
|
|
293
295
|
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
294
296
|
return {
|
|
295
|
-
type: $
|
|
297
|
+
type: $09e80d602234613d$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
296
298
|
text: segment.value,
|
|
297
|
-
...$
|
|
298
|
-
isPlaceholder: $
|
|
299
|
+
...$09e80d602234613d$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
300
|
+
isPlaceholder: $09e80d602234613d$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type],
|
|
299
301
|
isEditable: isEditable
|
|
300
302
|
};
|
|
301
303
|
})
|
|
@@ -307,7 +309,7 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
307
309
|
displayValue,
|
|
308
310
|
calendar
|
|
309
311
|
]);
|
|
310
|
-
let hasEra = $
|
|
312
|
+
let hasEra = $7UzoM$useMemo(()=>segments.some((s)=>s.type === 'era'
|
|
311
313
|
)
|
|
312
314
|
, [
|
|
313
315
|
segments
|
|
@@ -321,9 +323,9 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
321
323
|
};
|
|
322
324
|
let adjustSegment = (type, amount)=>{
|
|
323
325
|
markValid(type);
|
|
324
|
-
setValue($
|
|
326
|
+
setValue($09e80d602234613d$var$addSegment(displayValue, type, amount, resolvedOptions));
|
|
325
327
|
};
|
|
326
|
-
let validationState = props.validationState || ($
|
|
328
|
+
let validationState = props.validationState || ($35a22f14a1f04b11$export$eac50920cf2fd59a(calendarValue, props.minValue, props.maxValue) ? 'invalid' : null);
|
|
327
329
|
return {
|
|
328
330
|
value: calendarValue,
|
|
329
331
|
dateValue: dateValue,
|
|
@@ -339,14 +341,14 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
339
341
|
adjustSegment(part, -1);
|
|
340
342
|
},
|
|
341
343
|
incrementPage (part) {
|
|
342
|
-
adjustSegment(part, $
|
|
344
|
+
adjustSegment(part, $09e80d602234613d$var$PAGE_STEP[part] || 1);
|
|
343
345
|
},
|
|
344
346
|
decrementPage (part) {
|
|
345
|
-
adjustSegment(part, -($
|
|
347
|
+
adjustSegment(part, -($09e80d602234613d$var$PAGE_STEP[part] || 1));
|
|
346
348
|
},
|
|
347
349
|
setSegment (part, v) {
|
|
348
350
|
markValid(part);
|
|
349
|
-
setValue($
|
|
351
|
+
setValue($09e80d602234613d$var$setSegment(displayValue, part, v, resolvedOptions));
|
|
350
352
|
},
|
|
351
353
|
confirmPlaceholder (part) {
|
|
352
354
|
if (props.isDisabled || props.isReadOnly) return;
|
|
@@ -370,7 +372,7 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
370
372
|
setValidSegments({
|
|
371
373
|
...validSegments
|
|
372
374
|
});
|
|
373
|
-
let placeholder = $
|
|
375
|
+
let placeholder = $35a22f14a1f04b11$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
374
376
|
let value = displayValue;
|
|
375
377
|
// Reset day period to default without changing the hour.
|
|
376
378
|
if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
|
|
@@ -389,11 +391,11 @@ function $4398a1af81ae1348$export$714a241b39a650d6(props) {
|
|
|
389
391
|
setValue(value);
|
|
390
392
|
},
|
|
391
393
|
getFormatOptions (fieldOptions) {
|
|
392
|
-
return $
|
|
394
|
+
return $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, formatOpts);
|
|
393
395
|
}
|
|
394
396
|
};
|
|
395
397
|
}
|
|
396
|
-
function $
|
|
398
|
+
function $09e80d602234613d$var$getSegmentLimits(date, type, options) {
|
|
397
399
|
switch(type){
|
|
398
400
|
case 'era':
|
|
399
401
|
{
|
|
@@ -413,13 +415,13 @@ function $4398a1af81ae1348$var$getSegmentLimits(date, type, options) {
|
|
|
413
415
|
case 'month':
|
|
414
416
|
return {
|
|
415
417
|
value: date.month,
|
|
416
|
-
minValue: $
|
|
418
|
+
minValue: $7UzoM$getMinimumMonthInYear(date),
|
|
417
419
|
maxValue: date.calendar.getMonthsInYear(date)
|
|
418
420
|
};
|
|
419
421
|
case 'day':
|
|
420
422
|
return {
|
|
421
423
|
value: date.day,
|
|
422
|
-
minValue: $
|
|
424
|
+
minValue: $7UzoM$getMinimumDayInMonth(date),
|
|
423
425
|
maxValue: date.calendar.getDaysInMonth(date)
|
|
424
426
|
};
|
|
425
427
|
}
|
|
@@ -460,7 +462,7 @@ function $4398a1af81ae1348$var$getSegmentLimits(date, type, options) {
|
|
|
460
462
|
return {
|
|
461
463
|
};
|
|
462
464
|
}
|
|
463
|
-
function $
|
|
465
|
+
function $09e80d602234613d$var$addSegment(value, part, amount, options) {
|
|
464
466
|
switch(part){
|
|
465
467
|
case 'era':
|
|
466
468
|
case 'year':
|
|
@@ -488,7 +490,7 @@ function $4398a1af81ae1348$var$addSegment(value, part, amount, options) {
|
|
|
488
490
|
});
|
|
489
491
|
}
|
|
490
492
|
}
|
|
491
|
-
function $
|
|
493
|
+
function $09e80d602234613d$var$setSegment(value, part, segmentValue, options) {
|
|
492
494
|
switch(part){
|
|
493
495
|
case 'day':
|
|
494
496
|
case 'month':
|
|
@@ -526,17 +528,17 @@ function $4398a1af81ae1348$var$setSegment(value, part, segmentValue, options) {
|
|
|
526
528
|
}
|
|
527
529
|
|
|
528
530
|
|
|
529
|
-
var $
|
|
531
|
+
var $93c38a5e28be6249$exports = {};
|
|
530
532
|
|
|
531
|
-
$parcel$export($
|
|
533
|
+
$parcel$export($93c38a5e28be6249$exports, "useDateRangePickerState", () => $93c38a5e28be6249$export$e50a61c1de9f574);
|
|
532
534
|
|
|
533
535
|
|
|
534
536
|
|
|
535
537
|
|
|
536
|
-
function $
|
|
537
|
-
let [isOpen1, setOpen] = $
|
|
538
|
-
let [controlledValue, setControlledValue] = $
|
|
539
|
-
let [placeholderValue, setPlaceholderValue] = $
|
|
538
|
+
function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
|
|
539
|
+
let [isOpen1, setOpen] = $7UzoM$useState(false);
|
|
540
|
+
let [controlledValue, setControlledValue] = $7UzoM$useControlledState(props.value, props.defaultValue || null, props.onChange);
|
|
541
|
+
let [placeholderValue, setPlaceholderValue] = $7UzoM$useState(()=>controlledValue || {
|
|
540
542
|
start: null,
|
|
541
543
|
end: null
|
|
542
544
|
}
|
|
@@ -550,43 +552,43 @@ function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
|
550
552
|
setPlaceholderValue(placeholderValue);
|
|
551
553
|
}
|
|
552
554
|
let value1 = controlledValue || placeholderValue;
|
|
553
|
-
let valueRef = $
|
|
555
|
+
let valueRef = $7UzoM$useRef(value1);
|
|
554
556
|
valueRef.current = value1;
|
|
555
557
|
let setValue = (value)=>{
|
|
556
558
|
valueRef.current = value;
|
|
557
559
|
setPlaceholderValue(value);
|
|
558
|
-
if (value
|
|
560
|
+
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) setControlledValue(value);
|
|
559
561
|
else setControlledValue(null);
|
|
560
562
|
};
|
|
561
|
-
let v = value1
|
|
562
|
-
let [granularity, defaultTimeZone] = $
|
|
563
|
+
let v = (value1 === null || value1 === void 0 ? void 0 : value1.start) || (value1 === null || value1 === void 0 ? void 0 : value1.end) || props.placeholderValue;
|
|
564
|
+
let [granularity, defaultTimeZone] = $35a22f14a1f04b11$export$2440da353cedad43(v, props.granularity);
|
|
563
565
|
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
|
|
564
|
-
let [dateRange1, setSelectedDateRange] = $
|
|
565
|
-
let [timeRange1, setSelectedTimeRange] = $
|
|
566
|
+
let [dateRange1, setSelectedDateRange] = $7UzoM$useState(null);
|
|
567
|
+
let [timeRange1, setSelectedTimeRange] = $7UzoM$useState(null);
|
|
566
568
|
if (value1 && value1.start && value1.end) {
|
|
567
569
|
dateRange1 = value1;
|
|
568
570
|
if ('hour' in value1.start) timeRange1 = value1;
|
|
569
571
|
}
|
|
570
572
|
let commitValue = (dateRange, timeRange)=>{
|
|
571
573
|
setValue({
|
|
572
|
-
start: 'timeZone' in timeRange.start ? timeRange.start.set($
|
|
573
|
-
end: 'timeZone' in timeRange.end ? timeRange.end.set($
|
|
574
|
+
start: 'timeZone' in timeRange.start ? timeRange.start.set($7UzoM$toDateFields(dateRange.start)) : $7UzoM$toCalendarDateTime(dateRange.start, timeRange.start),
|
|
575
|
+
end: 'timeZone' in timeRange.end ? timeRange.end.set($7UzoM$toDateFields(dateRange.end)) : $7UzoM$toCalendarDateTime(dateRange.end, timeRange.end)
|
|
574
576
|
});
|
|
575
577
|
};
|
|
576
578
|
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
|
|
577
579
|
let setDateRange = (range)=>{
|
|
578
580
|
if (hasTime) {
|
|
579
|
-
if (range.start && range.end && timeRange1
|
|
581
|
+
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);
|
|
580
582
|
else setSelectedDateRange(range);
|
|
581
583
|
} else if (range.start && range.end) setValue(range);
|
|
582
584
|
else setSelectedDateRange(range);
|
|
583
585
|
if (!hasTime) setOpen(false);
|
|
584
586
|
};
|
|
585
587
|
let setTimeRange = (range)=>{
|
|
586
|
-
if (dateRange1
|
|
588
|
+
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);
|
|
587
589
|
else setSelectedTimeRange(range);
|
|
588
590
|
};
|
|
589
|
-
let validationState = props.validationState || (value1 != null && ($
|
|
591
|
+
let validationState = props.validationState || (value1 != null && ($35a22f14a1f04b11$export$eac50920cf2fd59a(value1.start, props.minValue, props.maxValue) || $35a22f14a1f04b11$export$eac50920cf2fd59a(value1.end, props.minValue, props.maxValue) || value1.end != null && value1.start != null && value1.end.compare(value1.start) < 0) ? 'invalid' : null);
|
|
590
592
|
return {
|
|
591
593
|
value: value1,
|
|
592
594
|
setValue: setValue,
|
|
@@ -618,9 +620,9 @@ function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
|
618
620
|
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
|
|
619
621
|
// If only the time range was set and not the date range, don't commit. The state will be preserved until
|
|
620
622
|
// the user opens the popover again.
|
|
621
|
-
if (!isOpen && !(value1
|
|
622
|
-
start: timeRange1
|
|
623
|
-
end: timeRange1
|
|
623
|
+
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, {
|
|
624
|
+
start: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.start) || $35a22f14a1f04b11$export$c5221a78ef73c5e9(props.placeholderValue),
|
|
625
|
+
end: (timeRange1 === null || timeRange1 === void 0 ? void 0 : timeRange1.end) || $35a22f14a1f04b11$export$c5221a78ef73c5e9(props.placeholderValue)
|
|
624
626
|
});
|
|
625
627
|
setOpen(isOpen);
|
|
626
628
|
},
|
|
@@ -631,13 +633,13 @@ function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
|
631
633
|
let startGranularity = props.granularity || (value1.start && 'minute' in value1.start ? 'minute' : 'day');
|
|
632
634
|
let endTimeZone = 'timeZone' in value1.end ? value1.end.timeZone : undefined;
|
|
633
635
|
let endGranularity = props.granularity || (value1.end && 'minute' in value1.end ? 'minute' : 'day');
|
|
634
|
-
let startOptions = $
|
|
636
|
+
let startOptions = $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, {
|
|
635
637
|
granularity: startGranularity,
|
|
636
638
|
timeZone: startTimeZone,
|
|
637
639
|
hideTimeZone: props.hideTimeZone,
|
|
638
640
|
hourCycle: props.hourCycle
|
|
639
641
|
});
|
|
640
|
-
let startFormatter = new $
|
|
642
|
+
let startFormatter = new $7UzoM$DateFormatter(locale, startOptions);
|
|
641
643
|
let endFormatter;
|
|
642
644
|
if (startTimeZone === endTimeZone && startGranularity === endGranularity) {
|
|
643
645
|
// Use formatRange, as it results in shorter output when some of the fields
|
|
@@ -650,13 +652,13 @@ function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
|
650
652
|
}
|
|
651
653
|
endFormatter = startFormatter;
|
|
652
654
|
} else {
|
|
653
|
-
let endOptions = $
|
|
655
|
+
let endOptions = $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, {
|
|
654
656
|
granularity: endGranularity,
|
|
655
657
|
timeZone: endTimeZone,
|
|
656
658
|
hideTimeZone: props.hideTimeZone,
|
|
657
659
|
hourCycle: props.hourCycle
|
|
658
660
|
});
|
|
659
|
-
endFormatter = new $
|
|
661
|
+
endFormatter = new $7UzoM$DateFormatter(locale, endOptions);
|
|
660
662
|
}
|
|
661
663
|
return `${startFormatter.format(value1.start.toDate(startTimeZone))} – ${endFormatter.format(value1.end.toDate(endTimeZone))}`;
|
|
662
664
|
},
|
|
@@ -666,7 +668,7 @@ function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
|
666
668
|
let value = valueRef.current;
|
|
667
669
|
if (value && Boolean(value.start) !== Boolean(value.end)) {
|
|
668
670
|
let calendar = (value.start || value.end).calendar;
|
|
669
|
-
let placeholder = $
|
|
671
|
+
let placeholder = $35a22f14a1f04b11$export$66aa2b09de4b1ea5(props.placeholderValue, granularity, calendar, defaultTimeZone);
|
|
670
672
|
setValue({
|
|
671
673
|
start: value.start || placeholder,
|
|
672
674
|
end: value.end || placeholder
|
|
@@ -677,40 +679,40 @@ function $377b3fe9df21ff1a$export$e50a61c1de9f574(props) {
|
|
|
677
679
|
}
|
|
678
680
|
|
|
679
681
|
|
|
680
|
-
var $
|
|
682
|
+
var $eff5d8ee529ac4bb$exports = {};
|
|
681
683
|
|
|
682
|
-
$parcel$export($
|
|
684
|
+
$parcel$export($eff5d8ee529ac4bb$exports, "useTimeFieldState", () => $eff5d8ee529ac4bb$export$fd53cef0cc796101);
|
|
683
685
|
|
|
684
686
|
|
|
685
687
|
|
|
686
688
|
|
|
687
|
-
function $
|
|
688
|
-
let { placeholderValue: placeholderValue = new $
|
|
689
|
-
let [value, setValue] = $
|
|
689
|
+
function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
|
|
690
|
+
let { placeholderValue: placeholderValue = new $7UzoM$Time() , minValue: minValue , maxValue: maxValue , granularity: granularity } = props;
|
|
691
|
+
let [value, setValue] = $7UzoM$useControlledState(props.value, props.defaultValue, props.onChange);
|
|
690
692
|
let v = value || placeholderValue;
|
|
691
693
|
let day = v && 'day' in v ? v : undefined;
|
|
692
|
-
let placeholderDate = $
|
|
694
|
+
let placeholderDate = $7UzoM$useMemo(()=>$eff5d8ee529ac4bb$var$convertValue(placeholderValue)
|
|
693
695
|
, [
|
|
694
696
|
placeholderValue
|
|
695
697
|
]);
|
|
696
|
-
let minDate = $
|
|
698
|
+
let minDate = $7UzoM$useMemo(()=>$eff5d8ee529ac4bb$var$convertValue(minValue, day)
|
|
697
699
|
, [
|
|
698
700
|
minValue,
|
|
699
701
|
day
|
|
700
702
|
]);
|
|
701
|
-
let maxDate = $
|
|
703
|
+
let maxDate = $7UzoM$useMemo(()=>$eff5d8ee529ac4bb$var$convertValue(maxValue, day)
|
|
702
704
|
, [
|
|
703
705
|
maxValue,
|
|
704
706
|
day
|
|
705
707
|
]);
|
|
706
|
-
let dateTime = $
|
|
708
|
+
let dateTime = $7UzoM$useMemo(()=>value == null ? null : $eff5d8ee529ac4bb$var$convertValue(value)
|
|
707
709
|
, [
|
|
708
710
|
value
|
|
709
711
|
]);
|
|
710
712
|
let onChange = (newValue)=>{
|
|
711
|
-
setValue(v && 'day' in v ? newValue : newValue && $
|
|
713
|
+
setValue(v && 'day' in v ? newValue : newValue && $7UzoM$toTime(newValue));
|
|
712
714
|
};
|
|
713
|
-
return $
|
|
715
|
+
return $09e80d602234613d$export$714a241b39a650d6({
|
|
714
716
|
...props,
|
|
715
717
|
value: dateTime,
|
|
716
718
|
defaultValue: undefined,
|
|
@@ -722,14 +724,14 @@ function $bee84d327e9289f2$export$fd53cef0cc796101(props) {
|
|
|
722
724
|
placeholderValue: placeholderDate
|
|
723
725
|
});
|
|
724
726
|
}
|
|
725
|
-
function $
|
|
727
|
+
function $eff5d8ee529ac4bb$var$convertValue(value, date = $7UzoM$today($7UzoM$getLocalTimeZone())) {
|
|
726
728
|
if (!value) return null;
|
|
727
729
|
if ('day' in value) return value;
|
|
728
|
-
return $
|
|
730
|
+
return $7UzoM$toCalendarDateTime(date, value);
|
|
729
731
|
}
|
|
730
732
|
|
|
731
733
|
|
|
732
734
|
|
|
733
735
|
|
|
734
|
-
export {$
|
|
736
|
+
export {$ab5bf3f618090389$export$87194bb378cc3ac2 as useDatePickerState, $09e80d602234613d$export$714a241b39a650d6 as useDatePickerFieldState, $93c38a5e28be6249$export$e50a61c1de9f574 as useDateRangePickerState, $eff5d8ee529ac4bb$export$fd53cef0cc796101 as useTimeFieldState};
|
|
735
737
|
//# sourceMappingURL=module.js.map
|