@react-stately/datepicker 3.9.3 → 3.9.4

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.
Files changed (54) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/intlStrings.mjs +1 -1
  16. package/dist/it-IT.mjs +1 -1
  17. package/dist/ja-JP.mjs +1 -1
  18. package/dist/ko-KR.mjs +1 -1
  19. package/dist/lt-LT.mjs +1 -1
  20. package/dist/lv-LV.mjs +1 -1
  21. package/dist/nb-NO.mjs +1 -1
  22. package/dist/nl-NL.mjs +1 -1
  23. package/dist/pl-PL.mjs +1 -1
  24. package/dist/placeholders.main.js +155 -155
  25. package/dist/placeholders.mjs +156 -156
  26. package/dist/placeholders.module.js +155 -155
  27. package/dist/pt-BR.mjs +1 -1
  28. package/dist/pt-PT.mjs +1 -1
  29. package/dist/ro-RO.mjs +1 -1
  30. package/dist/ru-RU.mjs +1 -1
  31. package/dist/sk-SK.mjs +1 -1
  32. package/dist/sl-SI.mjs +1 -1
  33. package/dist/sr-SP.mjs +1 -1
  34. package/dist/sv-SE.mjs +1 -1
  35. package/dist/tr-TR.mjs +1 -1
  36. package/dist/uk-UA.mjs +1 -1
  37. package/dist/useDateFieldState.main.js +41 -41
  38. package/dist/useDateFieldState.mjs +42 -42
  39. package/dist/useDateFieldState.module.js +41 -41
  40. package/dist/useDatePickerState.main.js +9 -9
  41. package/dist/useDatePickerState.mjs +10 -10
  42. package/dist/useDatePickerState.module.js +9 -9
  43. package/dist/useDateRangePickerState.main.js +18 -18
  44. package/dist/useDateRangePickerState.mjs +19 -19
  45. package/dist/useDateRangePickerState.module.js +18 -18
  46. package/dist/useTimeFieldState.main.js +7 -7
  47. package/dist/useTimeFieldState.mjs +8 -8
  48. package/dist/useTimeFieldState.module.js +7 -7
  49. package/dist/utils.main.js +31 -31
  50. package/dist/utils.mjs +32 -32
  51. package/dist/utils.module.js +31 -31
  52. package/dist/zh-CN.mjs +1 -1
  53. package/dist/zh-TW.mjs +1 -1
  54. package/package.json +9 -9
@@ -41,15 +41,15 @@ const $3c0fc76039f1c516$var$PAGE_STEP = {
41
41
  };
42
42
  // Node seems to convert everything to lowercase...
43
43
  const $3c0fc76039f1c516$var$TYPE_MAPPING = {
44
- dayperiod: "dayPeriod"
44
+ dayperiod: 'dayPeriod'
45
45
  };
46
46
  function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
47
47
  let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
48
48
  let v = props.value || props.defaultValue || props.placeholderValue;
49
49
  let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
50
- let timeZone = defaultTimeZone || "UTC";
50
+ let timeZone = defaultTimeZone || 'UTC';
51
51
  // props.granularity must actually exist in the value if one is provided.
52
- if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
52
+ if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
53
53
  let defaultFormatter = (0, $g03ag$useMemo)(()=>new (0, $g03ag$DateFormatter)(locale), [
54
54
  locale
55
55
  ]);
@@ -68,12 +68,12 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
68
68
  // change from uncontrolled to controlled and emit a warning.
69
69
  let [placeholderDate, setPlaceholderDate] = (0, $g03ag$useState)(()=>(0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
70
70
  let val = calendarValue || placeholderDate;
71
- let showEra = calendar.identifier === "gregory" && val.era === "BC";
71
+ let showEra = calendar.identifier === 'gregory' && val.era === 'BC';
72
72
  let formatOpts = (0, $g03ag$useMemo)(()=>{
73
73
  var _props_maxGranularity;
74
74
  return {
75
75
  granularity: granularity,
76
- maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : "year",
76
+ maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : 'year',
77
77
  timeZone: defaultTimeZone,
78
78
  hideTimeZone: hideTimeZone,
79
79
  hourCycle: props.hourCycle,
@@ -146,7 +146,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
146
146
  setDate(null);
147
147
  setPlaceholderDate((0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
148
148
  setValidSegments({});
149
- } else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== "dayPeriod") {
149
+ } else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod') {
150
150
  // The display calendar should not have any effect on the emitted value.
151
151
  // Emit dates in the same calendar as the original value, if any, otherwise gregorian.
152
152
  newValue = (0, $g03ag$toCalendar)(newValue, (v === null || v === void 0 ? void 0 : v.calendar) || new (0, $g03ag$GregorianCalendar)());
@@ -160,7 +160,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
160
160
  ]);
161
161
  let segments = (0, $g03ag$useMemo)(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
162
162
  let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
163
- if (segment.type === "era" && calendar.getEras().length === 1) isEditable = false;
163
+ if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
164
164
  let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
165
165
  let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
166
166
  return {
@@ -195,7 +195,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
195
195
  }
196
196
  let markValid = (part)=>{
197
197
  validSegments[part] = true;
198
- if (part === "year" && allSegments.era) validSegments.era = true;
198
+ if (part === 'year' && allSegments.era) validSegments.era = true;
199
199
  setValidSegments({
200
200
  ...validSegments
201
201
  });
@@ -221,7 +221,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
221
221
  builtinValidation: builtinValidation
222
222
  });
223
223
  let isValueInvalid = validation.displayValidation.isInvalid;
224
- let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
224
+ let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
225
225
  var _props_maxGranularity;
226
226
  return {
227
227
  ...validation,
@@ -234,7 +234,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
234
234
  validationState: validationState,
235
235
  isInvalid: isValueInvalid,
236
236
  granularity: granularity,
237
- maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : "year",
237
+ maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : 'year',
238
238
  isDisabled: isDisabled,
239
239
  isReadOnly: isReadOnly,
240
240
  isRequired: isRequired,
@@ -276,7 +276,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
276
276
  let placeholder = (0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone);
277
277
  let value = displayValue;
278
278
  // Reset day period to default without changing the hour.
279
- if (part === "dayPeriod" && "hour" in displayValue && "hour" in placeholder) {
279
+ if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {
280
280
  let isPM = displayValue.hour >= 12;
281
281
  let shouldBePM = placeholder.hour >= 12;
282
282
  if (isPM && !shouldBePM) value = displayValue.set({
@@ -292,7 +292,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
292
292
  setValue(value);
293
293
  },
294
294
  formatValue (fieldOptions) {
295
- if (!calendarValue) return "";
295
+ if (!calendarValue) return '';
296
296
  let formatOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
297
297
  let formatter = new (0, $g03ag$DateFormatter)(locale, formatOptions);
298
298
  return formatter.format(dateValue);
@@ -301,7 +301,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
301
301
  }
302
302
  function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
303
303
  switch(type){
304
- case "era":
304
+ case 'era':
305
305
  {
306
306
  let eras = date.calendar.getEras();
307
307
  return {
@@ -310,33 +310,33 @@ function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
310
310
  maxValue: eras.length - 1
311
311
  };
312
312
  }
313
- case "year":
313
+ case 'year':
314
314
  return {
315
315
  value: date.year,
316
316
  minValue: 1,
317
317
  maxValue: date.calendar.getYearsInEra(date)
318
318
  };
319
- case "month":
319
+ case 'month':
320
320
  return {
321
321
  value: date.month,
322
322
  minValue: (0, $g03ag$getMinimumMonthInYear)(date),
323
323
  maxValue: date.calendar.getMonthsInYear(date)
324
324
  };
325
- case "day":
325
+ case 'day':
326
326
  return {
327
327
  value: date.day,
328
328
  minValue: (0, $g03ag$getMinimumDayInMonth)(date),
329
329
  maxValue: date.calendar.getDaysInMonth(date)
330
330
  };
331
331
  }
332
- if ("hour" in date) switch(type){
333
- case "dayPeriod":
332
+ if ('hour' in date) switch(type){
333
+ case 'dayPeriod':
334
334
  return {
335
335
  value: date.hour >= 12 ? 12 : 0,
336
336
  minValue: 0,
337
337
  maxValue: 12
338
338
  };
339
- case "hour":
339
+ case 'hour':
340
340
  if (options.hour12) {
341
341
  let isPM = date.hour >= 12;
342
342
  return {
@@ -350,13 +350,13 @@ function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
350
350
  minValue: 0,
351
351
  maxValue: 23
352
352
  };
353
- case "minute":
353
+ case 'minute':
354
354
  return {
355
355
  value: date.minute,
356
356
  minValue: 0,
357
357
  maxValue: 59
358
358
  };
359
- case "second":
359
+ case 'second':
360
360
  return {
361
361
  value: date.second,
362
362
  minValue: 0,
@@ -367,16 +367,16 @@ function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
367
367
  }
368
368
  function $3c0fc76039f1c516$var$addSegment(value, part, amount, options) {
369
369
  switch(part){
370
- case "era":
371
- case "year":
372
- case "month":
373
- case "day":
370
+ case 'era':
371
+ case 'year':
372
+ case 'month':
373
+ case 'day':
374
374
  return value.cycle(part, amount, {
375
- round: part === "year"
375
+ round: part === 'year'
376
376
  });
377
377
  }
378
- if ("hour" in value) switch(part){
379
- case "dayPeriod":
378
+ if ('hour' in value) switch(part){
379
+ case 'dayPeriod':
380
380
  {
381
381
  let hours = value.hour;
382
382
  let isPM = hours >= 12;
@@ -384,27 +384,27 @@ function $3c0fc76039f1c516$var$addSegment(value, part, amount, options) {
384
384
  hour: isPM ? hours - 12 : hours + 12
385
385
  });
386
386
  }
387
- case "hour":
388
- case "minute":
389
- case "second":
387
+ case 'hour':
388
+ case 'minute':
389
+ case 'second':
390
390
  return value.cycle(part, amount, {
391
- round: part !== "hour",
391
+ round: part !== 'hour',
392
392
  hourCycle: options.hour12 ? 12 : 24
393
393
  });
394
394
  }
395
395
  }
396
396
  function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
397
397
  switch(part){
398
- case "day":
399
- case "month":
400
- case "year":
401
- case "era":
398
+ case 'day':
399
+ case 'month':
400
+ case 'year':
401
+ case 'era':
402
402
  return value.set({
403
403
  [part]: segmentValue
404
404
  });
405
405
  }
406
- if ("hour" in value) switch(part){
407
- case "dayPeriod":
406
+ if ('hour' in value) switch(part){
407
+ case 'dayPeriod':
408
408
  {
409
409
  let hours = value.hour;
410
410
  let wasPM = hours >= 12;
@@ -414,7 +414,7 @@ function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
414
414
  hour: wasPM ? hours - 12 : hours + 12
415
415
  });
416
416
  }
417
- case "hour":
417
+ case 'hour':
418
418
  // In 12 hour time, ensure that AM/PM does not change
419
419
  if (options.hour12) {
420
420
  let hours = value.hour;
@@ -423,8 +423,8 @@ function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
423
423
  if (wasPM && segmentValue < 12) segmentValue += 12;
424
424
  }
425
425
  // fallthrough
426
- case "minute":
427
- case "second":
426
+ case 'minute':
427
+ case 'second':
428
428
  return value.set({
429
429
  [part]: segmentValue
430
430
  });
@@ -32,19 +32,19 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
32
32
  let [value, setValue] = (0, $g6L8e$reactstatelyutils.useControlledState)(props.value, props.defaultValue || null, props.onChange);
33
33
  let v = value || props.placeholderValue;
34
34
  let [granularity, defaultTimeZone] = (0, $50d5d6a623389320$exports.useDefaultProps)(v, props.granularity);
35
- let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : "UTC") : null;
36
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
35
+ let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : 'UTC') : null;
36
+ let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
37
37
  var _props_shouldCloseOnSelect;
38
38
  let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
39
39
  let [selectedDate, setSelectedDate] = (0, $g6L8e$react.useState)(null);
40
40
  let [selectedTime, setSelectedTime] = (0, $g6L8e$react.useState)(null);
41
41
  if (value) {
42
42
  selectedDate = value;
43
- if ("hour" in value) selectedTime = value;
43
+ if ('hour' in value) selectedTime = value;
44
44
  }
45
45
  // props.granularity must actually exist in the value if one is provided.
46
- if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
47
- let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === "gregory" && value.era === "BC";
46
+ if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
47
+ let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === 'gregory' && value.era === 'BC';
48
48
  let formatOpts = (0, $g6L8e$react.useMemo)(()=>({
49
49
  granularity: granularity,
50
50
  timeZone: defaultTimeZone,
@@ -74,16 +74,16 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
74
74
  builtinValidation: builtinValidation
75
75
  });
76
76
  let isValueInvalid = validation.displayValidation.isInvalid;
77
- let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
77
+ let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
78
78
  let commitValue = (date, time)=>{
79
- setValue("timeZone" in time ? time.set((0, $g6L8e$internationalizeddate.toCalendarDate)(date)) : (0, $g6L8e$internationalizeddate.toCalendarDateTime)(date, time));
79
+ setValue('timeZone' in time ? time.set((0, $g6L8e$internationalizeddate.toCalendarDate)(date)) : (0, $g6L8e$internationalizeddate.toCalendarDateTime)(date, time));
80
80
  setSelectedDate(null);
81
81
  setSelectedTime(null);
82
82
  validation.commitValidation();
83
83
  };
84
84
  // Intercept setValue to make sure the Time section is not changed by date selection in Calendar
85
85
  let selectDate = (newValue)=>{
86
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
86
+ let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
87
87
  if (hasTime) {
88
88
  if (selectedTime || shouldClose) commitValue(newValue, selectedTime || (0, $50d5d6a623389320$exports.getPlaceholderTime)(props.placeholderValue));
89
89
  else setSelectedDate(newValue);
@@ -118,7 +118,7 @@ function $aaab7a647e17e1fd$export$87194bb378cc3ac2(props) {
118
118
  validationState: validationState,
119
119
  isInvalid: isValueInvalid,
120
120
  formatValue (locale, fieldOptions) {
121
- if (!dateValue) return "";
121
+ if (!dateValue) return '';
122
122
  let formatOptions = (0, $50d5d6a623389320$exports.getFormatOptions)(fieldOptions, formatOpts);
123
123
  let formatter = new (0, $g6L8e$internationalizeddate.DateFormatter)(locale, formatOptions);
124
124
  return formatter.format(dateValue);
@@ -26,19 +26,19 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
26
26
  let [value, setValue] = (0, $goopS$useControlledState)(props.value, props.defaultValue || null, props.onChange);
27
27
  let v = value || props.placeholderValue;
28
28
  let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
29
- let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : "UTC") : null;
30
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
29
+ let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : 'UTC') : null;
30
+ let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
31
31
  var _props_shouldCloseOnSelect;
32
32
  let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
33
33
  let [selectedDate, setSelectedDate] = (0, $goopS$useState)(null);
34
34
  let [selectedTime, setSelectedTime] = (0, $goopS$useState)(null);
35
35
  if (value) {
36
36
  selectedDate = value;
37
- if ("hour" in value) selectedTime = value;
37
+ if ('hour' in value) selectedTime = value;
38
38
  }
39
39
  // props.granularity must actually exist in the value if one is provided.
40
- if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
41
- let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === "gregory" && value.era === "BC";
40
+ if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
41
+ let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === 'gregory' && value.era === 'BC';
42
42
  let formatOpts = (0, $goopS$useMemo)(()=>({
43
43
  granularity: granularity,
44
44
  timeZone: defaultTimeZone,
@@ -68,16 +68,16 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
68
68
  builtinValidation: builtinValidation
69
69
  });
70
70
  let isValueInvalid = validation.displayValidation.isInvalid;
71
- let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
71
+ let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
72
72
  let commitValue = (date, time)=>{
73
- setValue("timeZone" in time ? time.set((0, $goopS$toCalendarDate)(date)) : (0, $goopS$toCalendarDateTime)(date, time));
73
+ setValue('timeZone' in time ? time.set((0, $goopS$toCalendarDate)(date)) : (0, $goopS$toCalendarDateTime)(date, time));
74
74
  setSelectedDate(null);
75
75
  setSelectedTime(null);
76
76
  validation.commitValidation();
77
77
  };
78
78
  // Intercept setValue to make sure the Time section is not changed by date selection in Calendar
79
79
  let selectDate = (newValue)=>{
80
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
80
+ let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
81
81
  if (hasTime) {
82
82
  if (selectedTime || shouldClose) commitValue(newValue, selectedTime || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue));
83
83
  else setSelectedDate(newValue);
@@ -112,7 +112,7 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
112
112
  validationState: validationState,
113
113
  isInvalid: isValueInvalid,
114
114
  formatValue (locale, fieldOptions) {
115
- if (!dateValue) return "";
115
+ if (!dateValue) return '';
116
116
  let formatOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
117
117
  let formatter = new (0, $goopS$DateFormatter)(locale, formatOptions);
118
118
  return formatter.format(dateValue);
@@ -122,4 +122,4 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
122
122
 
123
123
 
124
124
  export {$ab5bf3f618090389$export$87194bb378cc3ac2 as useDatePickerState};
125
- //# sourceMappingURL=useDatePickerState.mjs.map
125
+ //# sourceMappingURL=useDatePickerState.module.js.map
@@ -26,19 +26,19 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
26
26
  let [value, setValue] = (0, $goopS$useControlledState)(props.value, props.defaultValue || null, props.onChange);
27
27
  let v = value || props.placeholderValue;
28
28
  let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
29
- let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : "UTC") : null;
30
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
29
+ let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : 'UTC') : null;
30
+ let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
31
31
  var _props_shouldCloseOnSelect;
32
32
  let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
33
33
  let [selectedDate, setSelectedDate] = (0, $goopS$useState)(null);
34
34
  let [selectedTime, setSelectedTime] = (0, $goopS$useState)(null);
35
35
  if (value) {
36
36
  selectedDate = value;
37
- if ("hour" in value) selectedTime = value;
37
+ if ('hour' in value) selectedTime = value;
38
38
  }
39
39
  // props.granularity must actually exist in the value if one is provided.
40
- if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
41
- let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === "gregory" && value.era === "BC";
40
+ if (v && !(granularity in v)) throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());
41
+ let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === 'gregory' && value.era === 'BC';
42
42
  let formatOpts = (0, $goopS$useMemo)(()=>({
43
43
  granularity: granularity,
44
44
  timeZone: defaultTimeZone,
@@ -68,16 +68,16 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
68
68
  builtinValidation: builtinValidation
69
69
  });
70
70
  let isValueInvalid = validation.displayValidation.isInvalid;
71
- let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
71
+ let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
72
72
  let commitValue = (date, time)=>{
73
- setValue("timeZone" in time ? time.set((0, $goopS$toCalendarDate)(date)) : (0, $goopS$toCalendarDateTime)(date, time));
73
+ setValue('timeZone' in time ? time.set((0, $goopS$toCalendarDate)(date)) : (0, $goopS$toCalendarDateTime)(date, time));
74
74
  setSelectedDate(null);
75
75
  setSelectedTime(null);
76
76
  validation.commitValidation();
77
77
  };
78
78
  // Intercept setValue to make sure the Time section is not changed by date selection in Calendar
79
79
  let selectDate = (newValue)=>{
80
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
80
+ let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
81
81
  if (hasTime) {
82
82
  if (selectedTime || shouldClose) commitValue(newValue, selectedTime || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue));
83
83
  else setSelectedDate(newValue);
@@ -112,7 +112,7 @@ function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
112
112
  validationState: validationState,
113
113
  isInvalid: isValueInvalid,
114
114
  formatValue (locale, fieldOptions) {
115
- if (!dateValue) return "";
115
+ if (!dateValue) return '';
116
116
  let formatOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
117
117
  let formatter = new (0, $goopS$DateFormatter)(locale, formatOptions);
118
118
  return formatter.format(dateValue);
@@ -54,19 +54,19 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
54
54
  };
55
55
  let v = (value === null || value === void 0 ? void 0 : value.start) || (value === null || value === void 0 ? void 0 : value.end) || props.placeholderValue;
56
56
  let [granularity, defaultTimeZone] = (0, $50d5d6a623389320$exports.useDefaultProps)(v, props.granularity);
57
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
57
+ let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
58
58
  var _props_shouldCloseOnSelect;
59
59
  let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
60
60
  let [dateRange, setSelectedDateRange] = (0, $9LYIl$react.useState)(null);
61
61
  let [timeRange, setSelectedTimeRange] = (0, $9LYIl$react.useState)(null);
62
62
  if (value && value.start && value.end) {
63
63
  dateRange = value;
64
- if ("hour" in value.start) timeRange = value;
64
+ if ('hour' in value.start) timeRange = value;
65
65
  }
66
66
  let commitValue = (dateRange, timeRange)=>{
67
67
  setValue({
68
- start: "timeZone" in timeRange.start ? timeRange.start.set((0, $9LYIl$internationalizeddate.toCalendarDate)(dateRange.start)) : (0, $9LYIl$internationalizeddate.toCalendarDateTime)(dateRange.start, timeRange.start),
69
- end: "timeZone" in timeRange.end ? timeRange.end.set((0, $9LYIl$internationalizeddate.toCalendarDate)(dateRange.end)) : (0, $9LYIl$internationalizeddate.toCalendarDateTime)(dateRange.end, timeRange.end)
68
+ start: 'timeZone' in timeRange.start ? timeRange.start.set((0, $9LYIl$internationalizeddate.toCalendarDate)(dateRange.start)) : (0, $9LYIl$internationalizeddate.toCalendarDateTime)(dateRange.start, timeRange.start),
69
+ end: 'timeZone' in timeRange.end ? timeRange.end.set((0, $9LYIl$internationalizeddate.toCalendarDate)(dateRange.end)) : (0, $9LYIl$internationalizeddate.toCalendarDateTime)(dateRange.end, timeRange.end)
70
70
  });
71
71
  setSelectedDateRange(null);
72
72
  setSelectedTimeRange(null);
@@ -74,7 +74,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
74
74
  };
75
75
  // Intercept setValue to make sure the Time section is not changed by date selection in Calendar
76
76
  let setDateRange = (range)=>{
77
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
77
+ let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
78
78
  if (hasTime) {
79
79
  if (shouldClose || range.start && range.end && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
80
80
  start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $50d5d6a623389320$exports.getPlaceholderTime)(props.placeholderValue),
@@ -91,7 +91,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
91
91
  if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && range.start && range.end) commitValue(dateRange, range);
92
92
  else setSelectedTimeRange(range);
93
93
  };
94
- let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) === "gregory" && value.start.era === "BC" || (value === null || value === void 0 ? void 0 : (_value_end = value.end) === null || _value_end === void 0 ? void 0 : _value_end.calendar.identifier) === "gregory" && value.end.era === "BC";
94
+ let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) === 'gregory' && value.start.era === 'BC' || (value === null || value === void 0 ? void 0 : (_value_end = value.end) === null || _value_end === void 0 ? void 0 : _value_end.calendar.identifier) === 'gregory' && value.end.era === 'BC';
95
95
  let formatOpts = (0, $9LYIl$react.useMemo)(()=>({
96
96
  granularity: granularity,
97
97
  timeZone: defaultTimeZone,
@@ -128,7 +128,7 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
128
128
  builtinValidation: builtinValidation
129
129
  });
130
130
  let isValueInvalid = validation.displayValidation.isInvalid;
131
- let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
131
+ let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
132
132
  return {
133
133
  ...validation,
134
134
  value: value,
@@ -172,19 +172,19 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
172
172
  isInvalid: isValueInvalid,
173
173
  formatValue (locale, fieldOptions) {
174
174
  if (!value || !value.start || !value.end) return null;
175
- let startTimeZone = "timeZone" in value.start ? value.start.timeZone : undefined;
176
- let startGranularity = props.granularity || (value.start && "minute" in value.start ? "minute" : "day");
177
- let endTimeZone = "timeZone" in value.end ? value.end.timeZone : undefined;
178
- let endGranularity = props.granularity || (value.end && "minute" in value.end ? "minute" : "day");
175
+ let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;
176
+ let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');
177
+ let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;
178
+ let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');
179
179
  let startOptions = (0, $50d5d6a623389320$exports.getFormatOptions)(fieldOptions, {
180
180
  granularity: startGranularity,
181
181
  timeZone: startTimeZone,
182
182
  hideTimeZone: props.hideTimeZone,
183
183
  hourCycle: props.hourCycle,
184
- showEra: value.start.calendar.identifier === "gregory" && value.start.era === "BC" || value.end.calendar.identifier === "gregory" && value.end.era === "BC"
184
+ showEra: value.start.calendar.identifier === 'gregory' && value.start.era === 'BC' || value.end.calendar.identifier === 'gregory' && value.end.era === 'BC'
185
185
  });
186
- let startDate = value.start.toDate(startTimeZone || "UTC");
187
- let endDate = value.end.toDate(endTimeZone || "UTC");
186
+ let startDate = value.start.toDate(startTimeZone || 'UTC');
187
+ let endDate = value.end.toDate(endTimeZone || 'UTC');
188
188
  let startFormatter = new (0, $9LYIl$internationalizeddate.DateFormatter)(locale, startOptions);
189
189
  let endFormatter;
190
190
  if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {
@@ -198,12 +198,12 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
198
198
  let separatorIndex = -1;
199
199
  for(let i = 0; i < parts.length; i++){
200
200
  let part = parts[i];
201
- if (part.source === "shared" && part.type === "literal") separatorIndex = i;
202
- else if (part.source === "endRange") break;
201
+ if (part.source === 'shared' && part.type === 'literal') separatorIndex = i;
202
+ else if (part.source === 'endRange') break;
203
203
  }
204
204
  // Now we can combine the parts into start and end strings.
205
- let start = "";
206
- let end = "";
205
+ let start = '';
206
+ let end = '';
207
207
  for(let i = 0; i < parts.length; i++){
208
208
  if (i < separatorIndex) start += parts[i].value;
209
209
  else if (i > separatorIndex) end += parts[i].value;
@@ -48,19 +48,19 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
48
48
  };
49
49
  let v = (value === null || value === void 0 ? void 0 : value.start) || (value === null || value === void 0 ? void 0 : value.end) || props.placeholderValue;
50
50
  let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
51
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
51
+ let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
52
52
  var _props_shouldCloseOnSelect;
53
53
  let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
54
54
  let [dateRange, setSelectedDateRange] = (0, $hac8C$useState)(null);
55
55
  let [timeRange, setSelectedTimeRange] = (0, $hac8C$useState)(null);
56
56
  if (value && value.start && value.end) {
57
57
  dateRange = value;
58
- if ("hour" in value.start) timeRange = value;
58
+ if ('hour' in value.start) timeRange = value;
59
59
  }
60
60
  let commitValue = (dateRange, timeRange)=>{
61
61
  setValue({
62
- start: "timeZone" in timeRange.start ? timeRange.start.set((0, $hac8C$toCalendarDate)(dateRange.start)) : (0, $hac8C$toCalendarDateTime)(dateRange.start, timeRange.start),
63
- end: "timeZone" in timeRange.end ? timeRange.end.set((0, $hac8C$toCalendarDate)(dateRange.end)) : (0, $hac8C$toCalendarDateTime)(dateRange.end, timeRange.end)
62
+ start: 'timeZone' in timeRange.start ? timeRange.start.set((0, $hac8C$toCalendarDate)(dateRange.start)) : (0, $hac8C$toCalendarDateTime)(dateRange.start, timeRange.start),
63
+ end: 'timeZone' in timeRange.end ? timeRange.end.set((0, $hac8C$toCalendarDate)(dateRange.end)) : (0, $hac8C$toCalendarDateTime)(dateRange.end, timeRange.end)
64
64
  });
65
65
  setSelectedDateRange(null);
66
66
  setSelectedTimeRange(null);
@@ -68,7 +68,7 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
68
68
  };
69
69
  // Intercept setValue to make sure the Time section is not changed by date selection in Calendar
70
70
  let setDateRange = (range)=>{
71
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
71
+ let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
72
72
  if (hasTime) {
73
73
  if (shouldClose || range.start && range.end && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
74
74
  start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
@@ -85,7 +85,7 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
85
85
  if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && range.start && range.end) commitValue(dateRange, range);
86
86
  else setSelectedTimeRange(range);
87
87
  };
88
- let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) === "gregory" && value.start.era === "BC" || (value === null || value === void 0 ? void 0 : (_value_end = value.end) === null || _value_end === void 0 ? void 0 : _value_end.calendar.identifier) === "gregory" && value.end.era === "BC";
88
+ let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) === 'gregory' && value.start.era === 'BC' || (value === null || value === void 0 ? void 0 : (_value_end = value.end) === null || _value_end === void 0 ? void 0 : _value_end.calendar.identifier) === 'gregory' && value.end.era === 'BC';
89
89
  let formatOpts = (0, $hac8C$useMemo)(()=>({
90
90
  granularity: granularity,
91
91
  timeZone: defaultTimeZone,
@@ -122,7 +122,7 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
122
122
  builtinValidation: builtinValidation
123
123
  });
124
124
  let isValueInvalid = validation.displayValidation.isInvalid;
125
- let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
125
+ let validationState = props.validationState || (isValueInvalid ? 'invalid' : null);
126
126
  return {
127
127
  ...validation,
128
128
  value: value,
@@ -166,19 +166,19 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
166
166
  isInvalid: isValueInvalid,
167
167
  formatValue (locale, fieldOptions) {
168
168
  if (!value || !value.start || !value.end) return null;
169
- let startTimeZone = "timeZone" in value.start ? value.start.timeZone : undefined;
170
- let startGranularity = props.granularity || (value.start && "minute" in value.start ? "minute" : "day");
171
- let endTimeZone = "timeZone" in value.end ? value.end.timeZone : undefined;
172
- let endGranularity = props.granularity || (value.end && "minute" in value.end ? "minute" : "day");
169
+ let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;
170
+ let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');
171
+ let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;
172
+ let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');
173
173
  let startOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
174
174
  granularity: startGranularity,
175
175
  timeZone: startTimeZone,
176
176
  hideTimeZone: props.hideTimeZone,
177
177
  hourCycle: props.hourCycle,
178
- showEra: value.start.calendar.identifier === "gregory" && value.start.era === "BC" || value.end.calendar.identifier === "gregory" && value.end.era === "BC"
178
+ showEra: value.start.calendar.identifier === 'gregory' && value.start.era === 'BC' || value.end.calendar.identifier === 'gregory' && value.end.era === 'BC'
179
179
  });
180
- let startDate = value.start.toDate(startTimeZone || "UTC");
181
- let endDate = value.end.toDate(endTimeZone || "UTC");
180
+ let startDate = value.start.toDate(startTimeZone || 'UTC');
181
+ let endDate = value.end.toDate(endTimeZone || 'UTC');
182
182
  let startFormatter = new (0, $hac8C$DateFormatter)(locale, startOptions);
183
183
  let endFormatter;
184
184
  if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {
@@ -192,12 +192,12 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
192
192
  let separatorIndex = -1;
193
193
  for(let i = 0; i < parts.length; i++){
194
194
  let part = parts[i];
195
- if (part.source === "shared" && part.type === "literal") separatorIndex = i;
196
- else if (part.source === "endRange") break;
195
+ if (part.source === 'shared' && part.type === 'literal') separatorIndex = i;
196
+ else if (part.source === 'endRange') break;
197
197
  }
198
198
  // Now we can combine the parts into start and end strings.
199
- let start = "";
200
- let end = "";
199
+ let start = '';
200
+ let end = '';
201
201
  for(let i = 0; i < parts.length; i++){
202
202
  if (i < separatorIndex) start += parts[i].value;
203
203
  else if (i > separatorIndex) end += parts[i].value;
@@ -229,4 +229,4 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
229
229
 
230
230
 
231
231
  export {$93c38a5e28be6249$export$e50a61c1de9f574 as useDateRangePickerState};
232
- //# sourceMappingURL=useDateRangePickerState.mjs.map
232
+ //# sourceMappingURL=useDateRangePickerState.module.js.map