@react-stately/datepicker 3.14.1 → 3.14.2

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.
@@ -1 +1 @@
1
- {"mappings":";;;;;AA2HA,oBAA2B,IAAI,CAAC,KAAK,qBAAqB,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;AACrH;IACE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;IAClD,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;IACxE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC;AC/GD,wCAAwC,CAAC,SAAS,SAAS,CAAE,SAAQ,gBAAgB,CAAC,CAAC;IACrF;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAA;CAChD;AAED,gCAAiC,SAAQ,mBAAmB,EAAE,mBAAmB;IAC/E,mCAAmC;IACnC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,0CAA0C;IAC1C,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,0CAA0C;IAC1C,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC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AS,EAAE,IAAI,CAAA;CAChB;AAED;;;;GAIG;AACH,kCAAkC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG,cAAc,CAmDlH","sources":["packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/utils.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDatePickerState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/placeholders.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDateFieldState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDateRangePickerState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useTimeFieldState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/index.ts","packages/@react-stately/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useDatePickerState} from './useDatePickerState';\nexport {useDateFieldState} from './useDateFieldState';\nexport {useDateRangePickerState} from './useDateRangePickerState';\nexport {useTimeFieldState} from './useTimeFieldState';\n\nexport type {DateFieldStateOptions, DateFieldState, DateSegment, SegmentType} from './useDateFieldState';\nexport type {DatePickerStateOptions, DatePickerState} from './useDatePickerState';\nexport type {DateRangePickerStateOptions, DateRangePickerState} from './useDateRangePickerState';\nexport type {TimeFieldStateOptions, TimeFieldState} from './useTimeFieldState';\nexport type {FormatterOptions} from './utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;AA2HA,o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/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/utils.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDatePickerState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/placeholders.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDateFieldState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDateRangePickerState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useTimeFieldState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/index.ts","packages/@react-stately/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useDatePickerState} from './useDatePickerState';\nexport {useDateFieldState} from './useDateFieldState';\nexport {useDateRangePickerState} from './useDateRangePickerState';\nexport {useTimeFieldState} from './useTimeFieldState';\n\nexport type {DateFieldStateOptions, DateFieldState, DateSegment, SegmentType} from './useDateFieldState';\nexport type {DatePickerStateOptions, DatePickerState} from './useDatePickerState';\nexport type {DateRangePickerStateOptions, DateRangePickerState} from './useDateRangePickerState';\nexport type {TimeFieldStateOptions, TimeFieldState} from './useTimeFieldState';\nexport type {FormatterOptions} from './utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -45,9 +45,13 @@ const $596a1f0f523d6752$var$PAGE_STEP = {
45
45
  minute: 15,
46
46
  second: 15
47
47
  };
48
- // Node seems to convert everything to lowercase...
49
48
  const $596a1f0f523d6752$var$TYPE_MAPPING = {
50
- dayperiod: 'dayPeriod'
49
+ // Node seems to convert everything to lowercase...
50
+ dayperiod: 'dayPeriod',
51
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years
52
+ relatedYear: 'year',
53
+ yearName: 'literal',
54
+ unknown: 'literal'
51
55
  };
52
56
  function $596a1f0f523d6752$export$60e84778edff6d26(props) {
53
57
  let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, isRequired: isRequired = false, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
@@ -111,7 +115,7 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
111
115
  ]);
112
116
  // Determine how many editable segments there are for validation purposes.
113
117
  // The result is cached for performance.
114
- let allSegments = (0, $iqS8N$react.useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[seg.type] = true, p), {}), [
118
+ let allSegments = (0, $iqS8N$react.useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$596a1f0f523d6752$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[$596a1f0f523d6752$var$TYPE_MAPPING[seg.type] || seg.type] = true, p), {}), [
115
119
  dateFormatter
116
120
  ]);
117
121
  let [validSegments, setValidSegments] = (0, $iqS8N$react.useState)(()=>props.value || props.defaultValue ? {
@@ -317,14 +321,15 @@ function $596a1f0f523d6752$var$processSegments(dateValue, validSegments, dateFor
317
321
  let segments = dateFormatter.formatToParts(dateValue);
318
322
  let processedSegments = [];
319
323
  for (let segment of segments){
320
- let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
321
- if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
322
- let isPlaceholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
323
- let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] ? (0, $e1e8ada727fae1a1$exports.getPlaceholder)(segment.type, segment.value, locale) : null;
324
+ let type = $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type;
325
+ let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[type];
326
+ if (type === 'era' && calendar.getEras().length === 1) isEditable = false;
327
+ let isPlaceholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[type] && !validSegments[type];
328
+ let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[type] ? (0, $e1e8ada727fae1a1$exports.getPlaceholder)(type, segment.value, locale) : null;
324
329
  let dateSegment = {
325
- type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
330
+ type: type,
326
331
  text: isPlaceholder ? placeholder : segment.value,
327
- ...$596a1f0f523d6752$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
332
+ ...$596a1f0f523d6752$var$getSegmentLimits(displayValue, type, resolvedOptions),
328
333
  isPlaceholder: isPlaceholder,
329
334
  placeholder: placeholder,
330
335
  isEditable: isEditable
@@ -332,7 +337,7 @@ function $596a1f0f523d6752$var$processSegments(dateValue, validSegments, dateFor
332
337
  // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
333
338
  // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
334
339
  // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
335
- if (segment.type === 'hour') {
340
+ if (type === 'hour') {
336
341
  // This marks the start of the embedded direction change.
337
342
  processedSegments.push({
338
343
  type: 'literal',
@@ -344,7 +349,7 @@ function $596a1f0f523d6752$var$processSegments(dateValue, validSegments, dateFor
344
349
  });
345
350
  processedSegments.push(dateSegment);
346
351
  // This marks the end of the embedded direction change in the case that the granularity it set to "hour".
347
- if (segment.type === granularity) processedSegments.push({
352
+ if (type === granularity) processedSegments.push({
348
353
  type: 'literal',
349
354
  text: '\u2069',
350
355
  ...$596a1f0f523d6752$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
@@ -352,7 +357,7 @@ function $596a1f0f523d6752$var$processSegments(dateValue, validSegments, dateFor
352
357
  placeholder: '',
353
358
  isEditable: false
354
359
  });
355
- } else if (timeValue.includes(segment.type) && segment.type === granularity) {
360
+ } else if (timeValue.includes(type) && type === granularity) {
356
361
  processedSegments.push(dateSegment);
357
362
  // This marks the end of the embedded direction change.
358
363
  processedSegments.push({
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,mDAAmD;AACnD,MAAM,qCAAe;IACnB,WAAW;AACb;AAwBO,SAAS,0CAAmD,KAA+B;IAChG,IAAI,UACF,MAAM,kBACN,cAAc,gBACd,YAAY,cACZ,aAAa,mBACb,aAAa,mBACb,aAAa,iBACb,QAAQ,YACR,QAAQ,qBACR,iBAAiB,EAClB,GAAG;IAEJ,IAAI,IAAsB,MAAM,KAAK,IAAI,MAAM,YAAY,IAAI,MAAM,gBAAgB,IAAI;IACzF,IAAI,CAAC,aAAa,gBAAgB,GAAG,CAAA,GAAA,yCAAc,EAAE,GAAG,MAAM,WAAW;IACzE,IAAI,WAAW,mBAAmB;IAElC,yEAAyE;IACzE,IAAI,KAAK,CAAE,CAAA,eAAe,CAAA,GACxB,MAAM,IAAI,MAAM,yBAAyB,cAAc,gBAAgB,EAAE,QAAQ;IAGnF,IAAI,mBAAmB,CAAA,GAAA,oBAAM,EAAE,IAAM,IAAI,CAAA,GAAA,0CAAY,EAAE,SAAS;QAAC;KAAO;IACxE,IAAI,WAAW,CA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,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,OAAO,SAAS;gBACpB,OAAO,MAAM,GAAG,CAAC;oBAAC,MAAM,OAAO,QAAQ,KAAK,QAAQ;gBAAE;YACxD;QACA,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO,MAAM,KAAK,CAAC,MAAM,QAAQ;gBAC/B,OAAO,SAAS;gBAChB,WAAW,QAAQ,MAAM,GAAG,KAAK;YACnC;IACJ;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC;AAEA,SAAS,iCAAW,KAAgB,EAAE,IAAY,EAAE,YAA6B,EAAE,OAA2C;IAC5H,OAAQ;QACN,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAEA,IAAI,UAAU,SAAS,OAAO,iBAAiB,UAC7C,OAAQ;QACN,KAAK;YAAa;gBAChB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,OAAO,gBAAgB;gBAC3B,IAAI,SAAS,OACX,OAAO;gBAET,OAAO,MAAM,GAAG,CAAC;oBAAC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;gBAAE;YACzD;QACA,KAAK;YACH,qDAAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Calendar, CalendarIdentifier, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, isEqualCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\n// Node seems to convert everything to lowercase...\nconst TYPE_MAPPING = {\n dayperiod: 'dayPeriod'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: CalendarIdentifier) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar as CalendarIdentifier), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendar = useRef(calendar);\n useEffect(() => {\n if (!isEqualCalendar(calendar, lastCalendar.current)) {\n lastCalendar.current = calendar;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() => \n processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), \n [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {\n value = displayValue.set({hour: placeholder['hour'] + 12});\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {\n let timeValue = ['hour', 'minute', 'second'];\n let segments = dateFormatter.formatToParts(dateValue);\n let processedSegments: DateSegment[] = [];\n for (let segment of segments) {\n let isEditable = EDITABLE_SEGMENTS[segment.type];\n if (segment.type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];\n let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;\n\n let dateSegment = {\n type: TYPE_MAPPING[segment.type] || segment.type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, segment.type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change. \n if (segment.type === 'hour') {\n // This marks the start of the embedded direction change. \n processedSegments.push({\n type: 'literal',\n text: '\\u2066',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (segment.type === granularity) {\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n }\n } else if (timeValue.includes(segment.type) && segment.type === granularity) {\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change.\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal. \n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new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xC;AAEA,SAAS,iCAAW,KAAgB,EAAE,IAAY,EAAE,YAA6B,EAAE,OAA2C;IAC5H,OAAQ;QACN,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAEA,IAAI,UAAU,SAAS,OAAO,iBAAiB,UAC7C,OAAQ;QACN,KAAK;YAAa;gBAChB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,OAAO,gBAAgB;gBAC3B,IAAI,SAAS,OACX,OAAO;gBAET,OAAO,MAAM,GAAG,CAAC;oBAAC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;gBAAE;YACzD;QACA,KAAK;YACH,qDAAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Calendar, CalendarIdentifier, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, isEqualCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\nconst TYPE_MAPPING = {\n // Node seems to convert everything to lowercase...\n dayperiod: 'dayPeriod',\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years\n relatedYear: 'year',\n yearName: 'literal', // not editable\n unknown: 'literal'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: CalendarIdentifier) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar as CalendarIdentifier), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[TYPE_MAPPING[seg.type] || seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendar = useRef(calendar);\n useEffect(() => {\n if (!isEqualCalendar(calendar, lastCalendar.current)) {\n lastCalendar.current = calendar;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() => \n processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), \n [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {\n value = displayValue.set({hour: placeholder['hour'] + 12});\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {\n let timeValue = ['hour', 'minute', 'second'];\n let segments = dateFormatter.formatToParts(dateValue);\n let processedSegments: DateSegment[] = [];\n for (let segment of segments) {\n let type = TYPE_MAPPING[segment.type] || segment.type;\n let isEditable = EDITABLE_SEGMENTS[type];\n if (type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[type] && !validSegments[type];\n let placeholder = EDITABLE_SEGMENTS[type] ? getPlaceholder(type, segment.value, locale) : null;\n\n let dateSegment = {\n type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change. \n if (type === 'hour') {\n // This marks the start of the embedded direction change. \n processedSegments.push({\n type: 'literal',\n text: '\\u2066',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (type === granularity) {\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n }\n } else if (timeValue.includes(type) && type === granularity) {\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change.\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal. \n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.main.js.map"}
@@ -39,9 +39,13 @@ const $3c0fc76039f1c516$var$PAGE_STEP = {
39
39
  minute: 15,
40
40
  second: 15
41
41
  };
42
- // Node seems to convert everything to lowercase...
43
42
  const $3c0fc76039f1c516$var$TYPE_MAPPING = {
44
- dayperiod: 'dayPeriod'
43
+ // Node seems to convert everything to lowercase...
44
+ dayperiod: 'dayPeriod',
45
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years
46
+ relatedYear: 'year',
47
+ yearName: 'literal',
48
+ unknown: 'literal'
45
49
  };
46
50
  function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
47
51
  let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, isRequired: isRequired = false, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
@@ -105,7 +109,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
105
109
  ]);
106
110
  // Determine how many editable segments there are for validation purposes.
107
111
  // The result is cached for performance.
108
- let allSegments = (0, $g03ag$useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$3c0fc76039f1c516$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[seg.type] = true, p), {}), [
112
+ let allSegments = (0, $g03ag$useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$3c0fc76039f1c516$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[$3c0fc76039f1c516$var$TYPE_MAPPING[seg.type] || seg.type] = true, p), {}), [
109
113
  dateFormatter
110
114
  ]);
111
115
  let [validSegments, setValidSegments] = (0, $g03ag$useState)(()=>props.value || props.defaultValue ? {
@@ -311,14 +315,15 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
311
315
  let segments = dateFormatter.formatToParts(dateValue);
312
316
  let processedSegments = [];
313
317
  for (let segment of segments){
314
- let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
315
- if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
316
- let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
317
- let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
318
+ let type = $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type;
319
+ let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[type];
320
+ if (type === 'era' && calendar.getEras().length === 1) isEditable = false;
321
+ let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[type] && !validSegments[type];
322
+ let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(type, segment.value, locale) : null;
318
323
  let dateSegment = {
319
- type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
324
+ type: type,
320
325
  text: isPlaceholder ? placeholder : segment.value,
321
- ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
326
+ ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, type, resolvedOptions),
322
327
  isPlaceholder: isPlaceholder,
323
328
  placeholder: placeholder,
324
329
  isEditable: isEditable
@@ -326,7 +331,7 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
326
331
  // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
327
332
  // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
328
333
  // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
329
- if (segment.type === 'hour') {
334
+ if (type === 'hour') {
330
335
  // This marks the start of the embedded direction change.
331
336
  processedSegments.push({
332
337
  type: 'literal',
@@ -338,7 +343,7 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
338
343
  });
339
344
  processedSegments.push(dateSegment);
340
345
  // This marks the end of the embedded direction change in the case that the granularity it set to "hour".
341
- if (segment.type === granularity) processedSegments.push({
346
+ if (type === granularity) processedSegments.push({
342
347
  type: 'literal',
343
348
  text: '\u2069',
344
349
  ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
@@ -346,7 +351,7 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
346
351
  placeholder: '',
347
352
  isEditable: false
348
353
  });
349
- } else if (timeValue.includes(segment.type) && segment.type === granularity) {
354
+ } else if (timeValue.includes(type) && type === granularity) {
350
355
  processedSegments.push(dateSegment);
351
356
  // This marks the end of the embedded direction change.
352
357
  processedSegments.push({
@@ -39,9 +39,13 @@ const $3c0fc76039f1c516$var$PAGE_STEP = {
39
39
  minute: 15,
40
40
  second: 15
41
41
  };
42
- // Node seems to convert everything to lowercase...
43
42
  const $3c0fc76039f1c516$var$TYPE_MAPPING = {
44
- dayperiod: 'dayPeriod'
43
+ // Node seems to convert everything to lowercase...
44
+ dayperiod: 'dayPeriod',
45
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years
46
+ relatedYear: 'year',
47
+ yearName: 'literal',
48
+ unknown: 'literal'
45
49
  };
46
50
  function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
47
51
  let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, isRequired: isRequired = false, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
@@ -105,7 +109,7 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
105
109
  ]);
106
110
  // Determine how many editable segments there are for validation purposes.
107
111
  // The result is cached for performance.
108
- let allSegments = (0, $g03ag$useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$3c0fc76039f1c516$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[seg.type] = true, p), {}), [
112
+ let allSegments = (0, $g03ag$useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$3c0fc76039f1c516$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[$3c0fc76039f1c516$var$TYPE_MAPPING[seg.type] || seg.type] = true, p), {}), [
109
113
  dateFormatter
110
114
  ]);
111
115
  let [validSegments, setValidSegments] = (0, $g03ag$useState)(()=>props.value || props.defaultValue ? {
@@ -311,14 +315,15 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
311
315
  let segments = dateFormatter.formatToParts(dateValue);
312
316
  let processedSegments = [];
313
317
  for (let segment of segments){
314
- let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
315
- if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
316
- let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
317
- let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
318
+ let type = $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type;
319
+ let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[type];
320
+ if (type === 'era' && calendar.getEras().length === 1) isEditable = false;
321
+ let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[type] && !validSegments[type];
322
+ let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(type, segment.value, locale) : null;
318
323
  let dateSegment = {
319
- type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
324
+ type: type,
320
325
  text: isPlaceholder ? placeholder : segment.value,
321
- ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
326
+ ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, type, resolvedOptions),
322
327
  isPlaceholder: isPlaceholder,
323
328
  placeholder: placeholder,
324
329
  isEditable: isEditable
@@ -326,7 +331,7 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
326
331
  // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
327
332
  // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
328
333
  // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
329
- if (segment.type === 'hour') {
334
+ if (type === 'hour') {
330
335
  // This marks the start of the embedded direction change.
331
336
  processedSegments.push({
332
337
  type: 'literal',
@@ -338,7 +343,7 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
338
343
  });
339
344
  processedSegments.push(dateSegment);
340
345
  // This marks the end of the embedded direction change in the case that the granularity it set to "hour".
341
- if (segment.type === granularity) processedSegments.push({
346
+ if (type === granularity) processedSegments.push({
342
347
  type: 'literal',
343
348
  text: '\u2069',
344
349
  ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
@@ -346,7 +351,7 @@ function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFor
346
351
  placeholder: '',
347
352
  isEditable: false
348
353
  });
349
- } else if (timeValue.includes(segment.type) && segment.type === granularity) {
354
+ } else if (timeValue.includes(type) && type === granularity) {
350
355
  processedSegments.push(dateSegment);
351
356
  // This marks the end of the embedded direction change.
352
357
  processedSegments.push({
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,mDAAmD;AACnD,MAAM,qCAAe;IACnB,WAAW;AACb;AAwBO,SAAS,0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AAI,SAAS,OACX,OAAO;gBAET,OAAO,MAAM,GAAG,CAAC;oBAAC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;gBAAE;YACzD;QACA,KAAK;YACH,qDAAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Calendar, CalendarIdentifier, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, isEqualCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\n// Node seems to convert everything to lowercase...\nconst TYPE_MAPPING = {\n dayperiod: 'dayPeriod'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: CalendarIdentifier) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar as CalendarIdentifier), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendar = useRef(calendar);\n useEffect(() => {\n if (!isEqualCalendar(calendar, lastCalendar.current)) {\n lastCalendar.current = calendar;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() => \n processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), \n [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {\n value = displayValue.set({hour: placeholder['hour'] + 12});\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {\n let timeValue = ['hour', 'minute', 'second'];\n let segments = dateFormatter.formatToParts(dateValue);\n let processedSegments: DateSegment[] = [];\n for (let segment of segments) {\n let isEditable = EDITABLE_SEGMENTS[segment.type];\n if (segment.type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];\n let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;\n\n let dateSegment = {\n type: TYPE_MAPPING[segment.type] || segment.type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, segment.type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change. \n if (segment.type === 'hour') {\n // This marks the start of the embedded direction change. \n processedSegments.push({\n type: 'literal',\n text: '\\u2066',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (segment.type === granularity) {\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n }\n } else if (timeValue.includes(segment.type) && segment.type === granularity) {\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change.\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal. \n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.module.js.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,MAAM,qCAAe;IACnB,mDAAmD;IACnD,WAAW;IACX,iIAAiI;IACjI,aAAa;IACb,UAAU;IACV,SAAS;AACX;AAwBO,SAAS,0CAAmD,KAA+B;IAChG,IAAI,UACF,MAAM,kBACN,cAAc,gBACd,YAAY,cACZ,aAAa,mBACb,aAAa,mBACb,aAAa,iBACb,QAAQ,YACR,QAAQ,qBACR,iBAAiB,EAClB,GAAG;IAEJ,IAAI,IAAsB,MAAM,KAAK,IAAI,MAAM,YAAY,IAAI,MAAM,gBAAgB,IAAI;IACzF,IAAI,CAAC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L,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Calendar, CalendarIdentifier, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, isEqualCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\nconst TYPE_MAPPING = {\n // Node seems to convert everything to lowercase...\n dayperiod: 'dayPeriod',\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years\n relatedYear: 'year',\n yearName: 'literal', // not editable\n unknown: 'literal'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: CalendarIdentifier) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar as CalendarIdentifier), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[TYPE_MAPPING[seg.type] || seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendar = useRef(calendar);\n useEffect(() => {\n if (!isEqualCalendar(calendar, lastCalendar.current)) {\n lastCalendar.current = calendar;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() => \n processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), \n [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {\n value = displayValue.set({hour: placeholder['hour'] + 12});\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {\n let timeValue = ['hour', 'minute', 'second'];\n let segments = dateFormatter.formatToParts(dateValue);\n let processedSegments: DateSegment[] = [];\n for (let segment of segments) {\n let type = TYPE_MAPPING[segment.type] || segment.type;\n let isEditable = EDITABLE_SEGMENTS[type];\n if (type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[type] && !validSegments[type];\n let placeholder = EDITABLE_SEGMENTS[type] ? getPlaceholder(type, segment.value, locale) : null;\n\n let dateSegment = {\n type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change. \n if (type === 'hour') {\n // This marks the start of the embedded direction change. \n processedSegments.push({\n type: 'literal',\n text: '\\u2066',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (type === granularity) {\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n }\n } else if (timeValue.includes(type) && type === granularity) {\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change.\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal. \n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.module.js.map"}
@@ -76,7 +76,8 @@ function $7072d26f58deb33b$export$e50a61c1de9f574(props) {
76
76
  let setDateRange = (range)=>{
77
77
  let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
78
78
  if (hasTime) {
79
- if ($7072d26f58deb33b$var$isCompleteRange(range) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
79
+ // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.
80
+ if ($7072d26f58deb33b$var$isCompleteRange(range) && (shouldClose || (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end))) commitValue(range, {
80
81
  start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $50d5d6a623389320$exports.getPlaceholderTime)(props.placeholderValue),
81
82
  end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $50d5d6a623389320$exports.getPlaceholderTime)(props.placeholderValue)
82
83
  });
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAwEM,SAAS,yCAAyD,KAAqC;QA+E7F,cAAiF;IA9EhG,IAAI,eAAe,CAAA,GAAA,kDAAqB,EAAE;IAC1C,IAAI,CAAC,iBA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AAI,MAAM,MAAM,EAAE,IAAK;wBACrC,IAAI,IAAI,gBACN,SAAS,KAAK,CAAC,EAAE,CAAC,KAAK;6BAClB,IAAI,IAAI,gBACb,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK;oBAEzB;oBAEA,OAAO;+BAAC;6BAAO;oBAAG;gBACpB,EAAE,OAAM;gBACN,SAAS;gBACX;gBAEA,eAAe;YACjB,OAAO;gBACL,IAAI,aAAa,CAAA,GAAA,0CAAe,EAAE,cAAc;oBAC9C,aAAa;oBACb,UAAU;oBACV,cAAc,MAAM,YAAY;oBAChC,WAAW,MAAM,SAAS;gBAC5B;gBAEA,eAAe,IAAI,CAAA,GAAA,0CAAY,EAAE,QAAQ;YAC3C;YAEA,OAAO;gBACL,OAAO,eAAe,MAAM,CAAC;gBAC7B,KAAK,aAAa,MAAM,CAAC;YAC3B;QACF;QACA,kBAAiB,MAAM,EAAE,aAA+B;YACtD,IAAI,aAAa;gBAAC,GAAG,UAAU;gBAAE,GAAG,aAAa;YAAA;YACjD,IAAI,mBAAmB,CAAA,GAAA,0CAAe,EAAE,CAAC,GAAG;YAC5C,OAAO,IAAI,CAAA,GAAA,0CAAY,EAAE,QAAQ;QACnC;IACF;AACF;AAEA,SAAS,sCAAmB,KAAkC;IAC5D,OAAO,CAAA,kBAAA,4BAAA,MAAO,KAAK,KAAI,QAAQ,MAAM,GAAG,IAAI;AAC9C","sources":["packages/@react-stately/datepicker/src/useDateRangePickerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n\nimport {DateFormatter, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {DateRange, DateRangePickerProps, DateValue, Granularity, MappedDateValue, TimeValue} from '@react-types/datepicker';\nimport {FieldOptions, FormatterOptions, getFormatOptions, getPlaceholderTime, getRangeValidationResult, useDefaultProps} from './utils';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {RangeValue, ValidationState} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface DateRangePickerStateOptions<T extends DateValue = DateValue> extends DateRangePickerProps<T> {\n /**\n * Determines whether the date picker popover should close automatically when a date is selected.\n * @default true\n */\n shouldCloseOnSelect?: boolean | (() => boolean)\n}\n\ntype TimeRange = RangeValue<TimeValue>;\nexport interface DateRangePickerState extends OverlayTriggerState, FormValidationState {\n /** The currently selected date range. */\n value: RangeValue<DateValue | null>,\n /** Sets the selected date range. */\n setValue(value: DateRange | null): void,\n /**\n * The date portion of the selected range. This may be set prior to `value` if the user has\n * selected a date range but has not yet selected a time range.\n */\n dateRange: RangeValue<DateValue | null> | null,\n /** Sets the date portion of the selected range. */\n setDateRange(value: DateRange): void,\n /**\n * The time portion of the selected range. This may be set prior to `value` if the user has\n * selected a time range but has not yet selected a date range.\n */\n timeRange: RangeValue<TimeValue | null> | null,\n /** Sets the time portion of the selected range. */\n setTimeRange(value: TimeRange): void,\n /** Sets the date portion of either the start or end of the selected range. */\n setDate(part: 'start' | 'end', value: DateValue | null): void,\n /** Sets the time portion of either the start or end of the selected range. */\n setTime(part: 'start' | 'end', value: TimeValue | null): void,\n /** Sets the date and time of either the start or end of the selected range. */\n setDateTime(part: 'start' | 'end', value: DateValue | null): void,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** Whether the date range picker supports selecting times, according to the `granularity` prop and current value. */\n hasTime: boolean,\n /** Whether the calendar popover is currently open. */\n isOpen: boolean,\n /** Sets whether the calendar popover is open. */\n setOpen(isOpen: boolean): void,\n /**\n * The current validation state of the date range picker, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** Formats the selected range using the given options. */\n formatValue(locale: string, fieldOptions: FieldOptions): {start: string, end: string} | null,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\n/**\n * Provides state management for a date range picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePickerState<T extends DateValue = DateValue>(props: DateRangePickerStateOptions<T>): DateRangePickerState {\n let overlayState = useOverlayTriggerState(props);\n let [controlledValue, setControlledValue] = useControlledState<DateRange | null, RangeValue<MappedDateValue<T>> | null>(props.value, props.defaultValue || null, props.onChange);\n let [placeholderValue, setPlaceholderValue] = useState<RangeValue<DateValue | null>>(() => controlledValue || {start: null, end: null});\n\n // Reset the placeholder if the value prop is set to null.\n if (controlledValue == null && placeholderValue.start && placeholderValue.end) {\n placeholderValue = {start: null, end: null};\n setPlaceholderValue(placeholderValue);\n }\n\n let value = controlledValue || placeholderValue;\n\n let setValue = (value: RangeValue<DateValue | null> | null) => {\n setPlaceholderValue(value || {start: null, end: null});\n if (isCompleteRange(value)) {\n setControlledValue(value);\n } else {\n setControlledValue(null);\n }\n };\n\n let v = (value?.start || value?.end || props.placeholderValue || null);\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;\n\n let [dateRange, setSelectedDateRange] = useState<RangeValue<DateValue | null> | null>(null);\n let [timeRange, setSelectedTimeRange] = useState<RangeValue<TimeValue | null> | null>(null);\n\n if (value && isCompleteRange(value)) {\n dateRange = value;\n if ('hour' in value.start) {\n timeRange = value as TimeRange;\n }\n }\n\n let commitValue = (dateRange: DateRange, timeRange: TimeRange) => {\n setValue({\n start: 'timeZone' in timeRange.start ? timeRange.start.set(toCalendarDate(dateRange.start)) : toCalendarDateTime(dateRange.start, timeRange.start),\n end: 'timeZone' in timeRange.end ? timeRange.end.set(toCalendarDate(dateRange.end)) : toCalendarDateTime(dateRange.end, timeRange.end)\n });\n setSelectedDateRange(null);\n setSelectedTimeRange(null);\n validation.commitValidation();\n };\n\n // Intercept setValue to make sure the Time section is not changed by date selection in Calendar\n let setDateRange = (range: RangeValue<DateValue | null>) => {\n let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;\n if (hasTime) {\n if (isCompleteRange(range) && timeRange?.start && timeRange?.end) {\n commitValue(range, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n } else {\n setSelectedDateRange(range);\n }\n } else if (isCompleteRange(range)) {\n setValue(range);\n validation.commitValidation();\n } else {\n setSelectedDateRange(range);\n }\n\n if (shouldClose) {\n overlayState.setOpen(false);\n }\n };\n\n let setTimeRange = (range: RangeValue<TimeValue | null>) => {\n if (isCompleteRange(dateRange) && isCompleteRange(range)) {\n commitValue(dateRange, range);\n } else {\n setSelectedTimeRange(range);\n }\n };\n\n let showEra = (value?.start?.calendar.identifier === 'gregory' && value.start.era === 'BC') || (value?.end?.calendar.identifier === 'gregory' && value.end.era === 'BC');\n let formatOpts = useMemo(() => ({\n granularity,\n timeZone: defaultTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n showEra\n }), [granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, props.hideTimeZone, showEra]);\n\n let {minValue, maxValue, isDateUnavailable} = props;\n let builtinValidation = useMemo(() => getRangeValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: controlledValue as RangeValue<MappedDateValue<T>> | null,\n name: useMemo(() => [props.startName, props.endName].filter(n => n != null), [props.startName, props.endName]),\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value,\n setValue,\n dateRange,\n timeRange,\n granularity,\n hasTime,\n setDate(part, date) {\n if (part === 'start') {\n setDateRange({start: date, end: dateRange?.end ?? null});\n } else {\n setDateRange({start: dateRange?.start ?? null, end: date});\n }\n },\n setTime(part, time) {\n if (part === 'start') {\n setTimeRange({start: time, end: timeRange?.end ?? null});\n } else {\n setTimeRange({start: timeRange?.start ?? null, end: time});\n }\n },\n setDateTime(part, dateTime) {\n if (part === 'start') {\n setValue({start: dateTime, end: value?.end ?? null});\n } else {\n setValue({start: value?.start ?? null, end: dateTime});\n }\n },\n setDateRange,\n setTimeRange,\n ...overlayState,\n setOpen(isOpen) {\n // Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.\n // If only the time range was set and not the date range, don't commit. The state will be preserved until\n // the user opens the popover again.\n if (!isOpen && !(value?.start && value?.end) && isCompleteRange(dateRange) && hasTime) {\n commitValue(dateRange, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n }\n\n overlayState.setOpen(isOpen);\n },\n validationState,\n isInvalid: isValueInvalid,\n formatValue(locale, fieldOptions) {\n if (!value || !value.start || !value.end) {\n return null;\n }\n\n let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;\n let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');\n let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;\n let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');\n\n let startOptions = getFormatOptions(fieldOptions, {\n granularity: startGranularity,\n timeZone: startTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n showEra: (value.start.calendar.identifier === 'gregory' && value.start.era === 'BC') ||\n (value.end.calendar.identifier === 'gregory' && value.end.era === 'BC')\n });\n\n let startDate = value.start.toDate(startTimeZone || 'UTC');\n let endDate = value.end.toDate(endTimeZone || 'UTC');\n\n let startFormatter = new DateFormatter(locale, startOptions);\n let endFormatter: Intl.DateTimeFormat;\n if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {\n // Use formatRange, as it results in shorter output when some of the fields\n // are shared between the start and end dates (e.g. the same month).\n // Formatting will fail if the end date is before the start date. Fall back below when that happens.\n try {\n let parts = startFormatter.formatRangeToParts(startDate, endDate);\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let start = '';\n let end = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n start += parts[i].value;\n } else if (i > separatorIndex) {\n end += parts[i].value;\n }\n }\n\n return {start, end};\n } catch {\n // ignore\n }\n\n endFormatter = startFormatter;\n } else {\n let endOptions = getFormatOptions(fieldOptions, {\n granularity: endGranularity,\n timeZone: endTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle\n });\n\n endFormatter = new DateFormatter(locale, endOptions);\n }\n\n return {\n start: startFormatter.format(startDate),\n end: endFormatter.format(endDate)\n };\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction isCompleteRange<T>(value: RangeValue<T | null> | null): value is RangeValue<T> {\n return value?.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AI,MAAM,MAAM,EAAE,IAAK;wBACrC,IAAI,OAAO,KAAK,CAAC,EAAE;wBACnB,IAAI,KAAK,MAAM,KAAK,YAAY,KAAK,IAAI,KAAK,WAC5C,iBAAiB;6BACZ,IAAI,KAAK,MAAM,KAAK,YACzB;oBAEJ;oBAEA,2DAA2D;oBAC3D,IAAI,QAAQ;oBACZ,IAAI,MAAM;oBACV,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;wBACrC,IAAI,IAAI,gBACN,SAAS,KAAK,CAAC,EAAE,CAAC,KAAK;6BAClB,IAAI,IAAI,gBACb,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK;oBAEzB;oBAEA,OAAO;+BAAC;6BAAO;oBAAG;gBACpB,EAAE,OAAM;gBACN,SAAS;gBACX;gBAEA,eAAe;YACjB,OAAO;gBACL,IAAI,aAAa,CAAA,GAAA,0CAAe,EAAE,cAAc;oBAC9C,aAAa;oBACb,UAAU;oBACV,cAAc,MAAM,YAAY;oBAChC,WAAW,MAAM,SAAS;gBAC5B;gBAEA,eAAe,IAAI,CAAA,GAAA,0CAAY,EAAE,QAAQ;YAC3C;YAEA,OAAO;gBACL,OAAO,eAAe,MAAM,CAAC;gBAC7B,KAAK,aAAa,MAAM,CAAC;YAC3B;QACF;QACA,kBAAiB,MAAM,EAAE,aAA+B;YACtD,IAAI,aAAa;gBAAC,GAAG,UAAU;gBAAE,GAAG,aAAa;YAAA;YACjD,IAAI,mBAAmB,CAAA,GAAA,0CAAe,EAAE,CAAC,GAAG;YAC5C,OAAO,IAAI,CAAA,GAAA,0CAAY,EAAE,QAAQ;QACnC;IACF;AACF;AAEA,SAAS,sCAAmB,KAAkC;IAC5D,OAAO,CAAA,kBAAA,4BAAA,MAAO,KAAK,KAAI,QAAQ,MAAM,GAAG,IAAI;AAC9C","sources":["packages/@react-stately/datepicker/src/useDateRangePickerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n\nimport {DateFormatter, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {DateRange, DateRangePickerProps, DateValue, Granularity, MappedDateValue, TimeValue} from '@react-types/datepicker';\nimport {FieldOptions, FormatterOptions, getFormatOptions, getPlaceholderTime, getRangeValidationResult, useDefaultProps} from './utils';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {RangeValue, ValidationState} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface DateRangePickerStateOptions<T extends DateValue = DateValue> extends DateRangePickerProps<T> {\n /**\n * Determines whether the date picker popover should close automatically when a date is selected.\n * @default true\n */\n shouldCloseOnSelect?: boolean | (() => boolean)\n}\n\ntype TimeRange = RangeValue<TimeValue>;\nexport interface DateRangePickerState extends OverlayTriggerState, FormValidationState {\n /** The currently selected date range. */\n value: RangeValue<DateValue | null>,\n /** Sets the selected date range. */\n setValue(value: DateRange | null): void,\n /**\n * The date portion of the selected range. This may be set prior to `value` if the user has\n * selected a date range but has not yet selected a time range.\n */\n dateRange: RangeValue<DateValue | null> | null,\n /** Sets the date portion of the selected range. */\n setDateRange(value: DateRange): void,\n /**\n * The time portion of the selected range. This may be set prior to `value` if the user has\n * selected a time range but has not yet selected a date range.\n */\n timeRange: RangeValue<TimeValue | null> | null,\n /** Sets the time portion of the selected range. */\n setTimeRange(value: TimeRange): void,\n /** Sets the date portion of either the start or end of the selected range. */\n setDate(part: 'start' | 'end', value: DateValue | null): void,\n /** Sets the time portion of either the start or end of the selected range. */\n setTime(part: 'start' | 'end', value: TimeValue | null): void,\n /** Sets the date and time of either the start or end of the selected range. */\n setDateTime(part: 'start' | 'end', value: DateValue | null): void,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** Whether the date range picker supports selecting times, according to the `granularity` prop and current value. */\n hasTime: boolean,\n /** Whether the calendar popover is currently open. */\n isOpen: boolean,\n /** Sets whether the calendar popover is open. */\n setOpen(isOpen: boolean): void,\n /**\n * The current validation state of the date range picker, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** Formats the selected range using the given options. */\n formatValue(locale: string, fieldOptions: FieldOptions): {start: string, end: string} | null,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\n/**\n * Provides state management for a date range picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePickerState<T extends DateValue = DateValue>(props: DateRangePickerStateOptions<T>): DateRangePickerState {\n let overlayState = useOverlayTriggerState(props);\n let [controlledValue, setControlledValue] = useControlledState<DateRange | null, RangeValue<MappedDateValue<T>> | null>(props.value, props.defaultValue || null, props.onChange);\n let [placeholderValue, setPlaceholderValue] = useState<RangeValue<DateValue | null>>(() => controlledValue || {start: null, end: null});\n\n // Reset the placeholder if the value prop is set to null.\n if (controlledValue == null && placeholderValue.start && placeholderValue.end) {\n placeholderValue = {start: null, end: null};\n setPlaceholderValue(placeholderValue);\n }\n\n let value = controlledValue || placeholderValue;\n\n let setValue = (value: RangeValue<DateValue | null> | null) => {\n setPlaceholderValue(value || {start: null, end: null});\n if (isCompleteRange(value)) {\n setControlledValue(value);\n } else {\n setControlledValue(null);\n }\n };\n\n let v = (value?.start || value?.end || props.placeholderValue || null);\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;\n\n let [dateRange, setSelectedDateRange] = useState<RangeValue<DateValue | null> | null>(null);\n let [timeRange, setSelectedTimeRange] = useState<RangeValue<TimeValue | null> | null>(null);\n\n if (value && isCompleteRange(value)) {\n dateRange = value;\n if ('hour' in value.start) {\n timeRange = value as TimeRange;\n }\n }\n\n let commitValue = (dateRange: DateRange, timeRange: TimeRange) => {\n setValue({\n start: 'timeZone' in timeRange.start ? timeRange.start.set(toCalendarDate(dateRange.start)) : toCalendarDateTime(dateRange.start, timeRange.start),\n end: 'timeZone' in timeRange.end ? timeRange.end.set(toCalendarDate(dateRange.end)) : toCalendarDateTime(dateRange.end, timeRange.end)\n });\n setSelectedDateRange(null);\n setSelectedTimeRange(null);\n validation.commitValidation();\n };\n\n // Intercept setValue to make sure the Time section is not changed by date selection in Calendar\n let setDateRange = (range: RangeValue<DateValue | null>) => {\n let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;\n if (hasTime) {\n // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.\n if (isCompleteRange(range) && (shouldClose || (timeRange?.start && timeRange?.end))) {\n commitValue(range, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n } else {\n setSelectedDateRange(range);\n }\n } else if (isCompleteRange(range)) {\n setValue(range);\n validation.commitValidation();\n } else {\n setSelectedDateRange(range);\n }\n\n if (shouldClose) {\n overlayState.setOpen(false);\n }\n };\n\n let setTimeRange = (range: RangeValue<TimeValue | null>) => {\n if (isCompleteRange(dateRange) && isCompleteRange(range)) {\n commitValue(dateRange, range);\n } else {\n setSelectedTimeRange(range);\n }\n };\n\n let showEra = (value?.start?.calendar.identifier === 'gregory' && value.start.era === 'BC') || (value?.end?.calendar.identifier === 'gregory' && value.end.era === 'BC');\n let formatOpts = useMemo(() => ({\n granularity,\n timeZone: defaultTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n showEra\n }), [granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, props.hideTimeZone, showEra]);\n\n let {minValue, maxValue, isDateUnavailable} = props;\n let builtinValidation = useMemo(() => getRangeValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: controlledValue as RangeValue<MappedDateValue<T>> | null,\n name: useMemo(() => [props.startName, props.endName].filter(n => n != null), [props.startName, props.endName]),\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value,\n setValue,\n dateRange,\n timeRange,\n granularity,\n hasTime,\n setDate(part, date) {\n if (part === 'start') {\n setDateRange({start: date, end: dateRange?.end ?? null});\n } else {\n setDateRange({start: dateRange?.start ?? null, end: date});\n }\n },\n setTime(part, time) {\n if (part === 'start') {\n setTimeRange({start: time, end: timeRange?.end ?? null});\n } else {\n setTimeRange({start: timeRange?.start ?? null, end: time});\n }\n },\n setDateTime(part, dateTime) {\n if (part === 'start') {\n setValue({start: dateTime, end: value?.end ?? null});\n } else {\n setValue({start: value?.start ?? null, end: dateTime});\n }\n },\n setDateRange,\n setTimeRange,\n ...overlayState,\n setOpen(isOpen) {\n // Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.\n // If only the time range was set and not the date range, don't commit. The state will be preserved until\n // the user opens the popover again.\n if (!isOpen && !(value?.start && value?.end) && isCompleteRange(dateRange) && hasTime) {\n commitValue(dateRange, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n }\n\n overlayState.setOpen(isOpen);\n },\n validationState,\n isInvalid: isValueInvalid,\n formatValue(locale, fieldOptions) {\n if (!value || !value.start || !value.end) {\n return null;\n }\n\n let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;\n let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');\n let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;\n let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');\n\n let startOptions = getFormatOptions(fieldOptions, {\n granularity: startGranularity,\n timeZone: startTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n showEra: (value.start.calendar.identifier === 'gregory' && value.start.era === 'BC') ||\n (value.end.calendar.identifier === 'gregory' && value.end.era === 'BC')\n });\n\n let startDate = value.start.toDate(startTimeZone || 'UTC');\n let endDate = value.end.toDate(endTimeZone || 'UTC');\n\n let startFormatter = new DateFormatter(locale, startOptions);\n let endFormatter: Intl.DateTimeFormat;\n if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {\n // Use formatRange, as it results in shorter output when some of the fields\n // are shared between the start and end dates (e.g. the same month).\n // Formatting will fail if the end date is before the start date. Fall back below when that happens.\n try {\n let parts = startFormatter.formatRangeToParts(startDate, endDate);\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let start = '';\n let end = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n start += parts[i].value;\n } else if (i > separatorIndex) {\n end += parts[i].value;\n }\n }\n\n return {start, end};\n } catch {\n // ignore\n }\n\n endFormatter = startFormatter;\n } else {\n let endOptions = getFormatOptions(fieldOptions, {\n granularity: endGranularity,\n timeZone: endTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle\n });\n\n endFormatter = new DateFormatter(locale, endOptions);\n }\n\n return {\n start: startFormatter.format(startDate),\n end: endFormatter.format(endDate)\n };\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction isCompleteRange<T>(value: RangeValue<T | null> | null): value is RangeValue<T> {\n return value?.start != null && value.end != null;\n}\n"],"names":[],"version":3,"file":"useDateRangePickerState.main.js.map"}
@@ -70,7 +70,8 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
70
70
  let setDateRange = (range)=>{
71
71
  let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
72
72
  if (hasTime) {
73
- if ($93c38a5e28be6249$var$isCompleteRange(range) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
73
+ // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.
74
+ if ($93c38a5e28be6249$var$isCompleteRange(range) && (shouldClose || (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end))) commitValue(range, {
74
75
  start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
75
76
  end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue)
76
77
  });
@@ -70,7 +70,8 @@ function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
70
70
  let setDateRange = (range)=>{
71
71
  let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
72
72
  if (hasTime) {
73
- if ($93c38a5e28be6249$var$isCompleteRange(range) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
73
+ // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.
74
+ if ($93c38a5e28be6249$var$isCompleteRange(range) && (shouldClose || (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end))) commitValue(range, {
74
75
  start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
75
76
  end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue)
76
77
  });
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAwEM,SAAS,yCAAyD,KAAqC;QA+E7F,cAAiF;IA9EhG,IAAI,eAAe,CAAA,GAAA,6BAAqB,EAAE;IAC1C,IAAI,CAAC,iBAAiB,mBAAmB,GAAG,CAAA,GAAA,yBAAiB,EAA2D,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,MAAM,MAAM,QAAQ;IAC/K,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EAAgC,IAAM,mBAAmB;YAAC,OAAO;YAAM,KAAK;QAAI;IAErI,0DAA0D;IAC1D,IAAI,mBAAmB,QAAQ,iBAAiB,KAAK,IAAI,iBAAiB,GAAG,EAAE;QAC7E,mBAAmB;YAAC,OAAO;YAAM,KAAK;QAAI;QAC1C,oBAAoB;IACtB;IAEA,IAAI,QAAQ,mBAAmB;IAE/B,IAAI,WAAW,CAAC;QACd,oBAAoB,SAAS;YAAC,OAAO;YAAM,KAAK;QAAI;QACpD,IAAI,sCAAgB,QAClB,mBAAmB;aAEnB,mBAAmB;IAEvB;IAEA,IAAI,IAAK,CAAA,kBAAA,4BAAA,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tD,IAAI,aAAa;gBAAC,GAAG,UAAU;gBAAE,GAAG,aAAa;YAAA;YACjD,IAAI,mBAAmB,CAAA,GAAA,yCAAe,EAAE,CAAC,GAAG;YAC5C,OAAO,IAAI,CAAA,GAAA,oBAAY,EAAE,QAAQ;QACnC;IACF;AACF;AAEA,SAAS,sCAAmB,KAAkC;IAC5D,OAAO,CAAA,kBAAA,4BAAA,MAAO,KAAK,KAAI,QAAQ,MAAM,GAAG,IAAI;AAC9C","sources":["packages/@react-stately/datepicker/src/useDateRangePickerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n\nimport {DateFormatter, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {DateRange, DateRangePickerProps, DateValue, Granularity, MappedDateValue, TimeValue} from '@react-types/datepicker';\nimport {FieldOptions, FormatterOptions, getFormatOptions, getPlaceholderTime, getRangeValidationResult, useDefaultProps} from './utils';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {RangeValue, ValidationState} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface DateRangePickerStateOptions<T extends DateValue = DateValue> extends DateRangePickerProps<T> {\n /**\n * Determines whether the date picker popover should close automatically when a date is selected.\n * @default true\n */\n shouldCloseOnSelect?: boolean | (() => boolean)\n}\n\ntype TimeRange = RangeValue<TimeValue>;\nexport interface DateRangePickerState extends OverlayTriggerState, FormValidationState {\n /** The currently selected date range. */\n value: RangeValue<DateValue | null>,\n /** Sets the selected date range. */\n setValue(value: DateRange | null): void,\n /**\n * The date portion of the selected range. This may be set prior to `value` if the user has\n * selected a date range but has not yet selected a time range.\n */\n dateRange: RangeValue<DateValue | null> | null,\n /** Sets the date portion of the selected range. */\n setDateRange(value: DateRange): void,\n /**\n * The time portion of the selected range. This may be set prior to `value` if the user has\n * selected a time range but has not yet selected a date range.\n */\n timeRange: RangeValue<TimeValue | null> | null,\n /** Sets the time portion of the selected range. */\n setTimeRange(value: TimeRange): void,\n /** Sets the date portion of either the start or end of the selected range. */\n setDate(part: 'start' | 'end', value: DateValue | null): void,\n /** Sets the time portion of either the start or end of the selected range. */\n setTime(part: 'start' | 'end', value: TimeValue | null): void,\n /** Sets the date and time of either the start or end of the selected range. */\n setDateTime(part: 'start' | 'end', value: DateValue | null): void,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** Whether the date range picker supports selecting times, according to the `granularity` prop and current value. */\n hasTime: boolean,\n /** Whether the calendar popover is currently open. */\n isOpen: boolean,\n /** Sets whether the calendar popover is open. */\n setOpen(isOpen: boolean): void,\n /**\n * The current validation state of the date range picker, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** Formats the selected range using the given options. */\n formatValue(locale: string, fieldOptions: FieldOptions): {start: string, end: string} | null,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\n/**\n * Provides state management for a date range picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePickerState<T extends DateValue = DateValue>(props: DateRangePickerStateOptions<T>): DateRangePickerState {\n let overlayState = useOverlayTriggerState(props);\n let [controlledValue, setControlledValue] = useControlledState<DateRange | null, RangeValue<MappedDateValue<T>> | null>(props.value, props.defaultValue || null, props.onChange);\n let [placeholderValue, setPlaceholderValue] = useState<RangeValue<DateValue | null>>(() => controlledValue || {start: null, end: null});\n\n // Reset the placeholder if the value prop is set to null.\n if (controlledValue == null && placeholderValue.start && placeholderValue.end) {\n placeholderValue = {start: null, end: null};\n setPlaceholderValue(placeholderValue);\n }\n\n let value = controlledValue || placeholderValue;\n\n let setValue = (value: RangeValue<DateValue | null> | null) => {\n setPlaceholderValue(value || {start: null, end: null});\n if (isCompleteRange(value)) {\n setControlledValue(value);\n } else {\n setControlledValue(null);\n }\n };\n\n let v = (value?.start || value?.end || props.placeholderValue || null);\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;\n\n let [dateRange, setSelectedDateRange] = useState<RangeValue<DateValue | null> | null>(null);\n let [timeRange, setSelectedTimeRange] = useState<RangeValue<TimeValue | null> | null>(null);\n\n if (value && isCompleteRange(value)) {\n dateRange = value;\n if ('hour' in value.start) {\n timeRange = value as TimeRange;\n }\n }\n\n let commitValue = (dateRange: DateRange, timeRange: TimeRange) => {\n setValue({\n start: 'timeZone' in timeRange.start ? timeRange.start.set(toCalendarDate(dateRange.start)) : toCalendarDateTime(dateRange.start, timeRange.start),\n end: 'timeZone' in timeRange.end ? timeRange.end.set(toCalendarDate(dateRange.end)) : toCalendarDateTime(dateRange.end, timeRange.end)\n });\n setSelectedDateRange(null);\n setSelectedTimeRange(null);\n validation.commitValidation();\n };\n\n // Intercept setValue to make sure the Time section is not changed by date selection in Calendar\n let setDateRange = (range: RangeValue<DateValue | null>) => {\n let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;\n if (hasTime) {\n if (isCompleteRange(range) && timeRange?.start && timeRange?.end) {\n commitValue(range, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n } else {\n setSelectedDateRange(range);\n }\n } else if (isCompleteRange(range)) {\n setValue(range);\n validation.commitValidation();\n } else {\n setSelectedDateRange(range);\n }\n\n if (shouldClose) {\n overlayState.setOpen(false);\n }\n };\n\n let setTimeRange = (range: RangeValue<TimeValue | null>) => {\n if (isCompleteRange(dateRange) && isCompleteRange(range)) {\n commitValue(dateRange, range);\n } else {\n setSelectedTimeRange(range);\n }\n };\n\n let showEra = (value?.start?.calendar.identifier === 'gregory' && value.start.era === 'BC') || (value?.end?.calendar.identifier === 'gregory' && value.end.era === 'BC');\n let formatOpts = useMemo(() => ({\n granularity,\n timeZone: defaultTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n showEra\n }), [granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, props.hideTimeZone, showEra]);\n\n let {minValue, maxValue, isDateUnavailable} = props;\n let builtinValidation = useMemo(() => getRangeValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: controlledValue as RangeValue<MappedDateValue<T>> | null,\n name: useMemo(() => [props.startName, props.endName].filter(n => n != null), [props.startName, props.endName]),\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value,\n setValue,\n dateRange,\n timeRange,\n granularity,\n hasTime,\n setDate(part, date) {\n if (part === 'start') {\n setDateRange({start: date, end: dateRange?.end ?? null});\n } else {\n setDateRange({start: dateRange?.start ?? null, end: date});\n }\n },\n setTime(part, time) {\n if (part === 'start') {\n setTimeRange({start: time, end: timeRange?.end ?? null});\n } else {\n setTimeRange({start: timeRange?.start ?? null, end: time});\n }\n },\n setDateTime(part, dateTime) {\n if (part === 'start') {\n setValue({start: dateTime, end: value?.end ?? null});\n } else {\n setValue({start: value?.start ?? null, end: dateTime});\n }\n },\n setDateRange,\n setTimeRange,\n ...overlayState,\n setOpen(isOpen) {\n // Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.\n // If only the time range was set and not the date range, don't commit. The state will be preserved until\n // the user opens the popover again.\n if (!isOpen && !(value?.start && value?.end) && isCompleteRange(dateRange) && hasTime) {\n commitValue(dateRange, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n }\n\n overlayState.setOpen(isOpen);\n },\n validationState,\n isInvalid: isValueInvalid,\n formatValue(locale, fieldOptions) {\n if (!value || !value.start || !value.end) {\n return null;\n }\n\n let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;\n let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');\n let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;\n let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');\n\n let startOptions = getFormatOptions(fieldOptions, {\n granularity: startGranularity,\n timeZone: startTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n showEra: (value.start.calendar.identifier === 'gregory' && value.start.era === 'BC') ||\n (value.end.calendar.identifier === 'gregory' && value.end.era === 'BC')\n });\n\n let startDate = value.start.toDate(startTimeZone || 'UTC');\n let endDate = value.end.toDate(endTimeZone || 'UTC');\n\n let startFormatter = new DateFormatter(locale, startOptions);\n let endFormatter: Intl.DateTimeFormat;\n if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {\n // Use formatRange, as it results in shorter output when some of the fields\n // are shared between the start and end dates (e.g. the same month).\n // Formatting will fail if the end date is before the start date. Fall back below when that happens.\n try {\n let parts = startFormatter.formatRangeToParts(startDate, endDate);\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let start = '';\n let end = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n start += parts[i].value;\n } else if (i > separatorIndex) {\n end += parts[i].value;\n }\n }\n\n return {start, end};\n } catch {\n // ignore\n }\n\n endFormatter = startFormatter;\n } else {\n let endOptions = getFormatOptions(fieldOptions, {\n granularity: endGranularity,\n timeZone: endTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle\n });\n\n endFormatter = new DateFormatter(locale, endOptions);\n }\n\n return {\n start: startFormatter.format(startDate),\n end: endFormatter.format(endDate)\n };\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction isCompleteRange<T>(value: RangeValue<T | null> | null): value is RangeValue<T> {\n return value?.start != null && value.end != null;\n}\n"],"names":[],"version":3,"file":"useDateRangePickerState.module.js.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAwEM,SAAS,yCAAyD,KAAqC;QAgF7F,cAAiF;IA/EhG,IAAI,eAAe,CAAA,GAAA,6BAAqB,EAAE;IAC1C,IAAI,CAAC,iBAAiB,mBAAmB,GAAG,CAAA,GAAA,yBAAiB,EAA2D,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,MAAM,MAAM,QAAQ;IAC/K,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EAAgC,IAAM,mBAAmB;YAAC,OAAO;YAAM,KAAK;QAAI;IAErI,0DAA0D;IAC1D,IAAI,mBAAmB,QAAQ,iBAAiB,KAAK,IAAI,iBAAiB,GAAG,EAAE;QAC7E,mBAAmB;YAAC,OAAO;YAAM,KAAK;QAAI;QAC1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AAa;oBACb,UAAU;oBACV,cAAc,MAAM,YAAY;oBAChC,WAAW,MAAM,SAAS;gBAC5B;gBAEA,eAAe,IAAI,CAAA,GAAA,oBAAY,EAAE,QAAQ;YAC3C;YAEA,OAAO;gBACL,OAAO,eAAe,MAAM,CAAC;gBAC7B,KAAK,aAAa,MAAM,CAAC;YAC3B;QACF;QACA,kBAAiB,MAAM,EAAE,aAA+B;YACtD,IAAI,aAAa;gBAAC,GAAG,UAAU;gBAAE,GAAG,aAAa;YAAA;YACjD,IAAI,mBAAmB,CAAA,GAAA,yCAAe,EAAE,CAAC,GAAG;YAC5C,OAAO,IAAI,CAAA,GAAA,oBAAY,EAAE,QAAQ;QACnC;IACF;AACF;AAEA,SAAS,sCAAmB,KAAkC;IAC5D,OAAO,CAAA,kBAAA,4BAAA,MAAO,KAAK,KAAI,QAAQ,MAAM,GAAG,IAAI;AAC9C","sources":["packages/@react-stately/datepicker/src/useDateRangePickerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n\nimport {DateFormatter, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {DateRange, DateRangePickerProps, DateValue, Granularity, MappedDateValue, TimeValue} from '@react-types/datepicker';\nimport {FieldOptions, FormatterOptions, getFormatOptions, getPlaceholderTime, getRangeValidationResult, useDefaultProps} from './utils';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {RangeValue, ValidationState} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface DateRangePickerStateOptions<T extends DateValue = DateValue> extends DateRangePickerProps<T> {\n /**\n * Determines whether the date picker popover should close automatically when a date is selected.\n * @default true\n */\n shouldCloseOnSelect?: boolean | (() => boolean)\n}\n\ntype TimeRange = RangeValue<TimeValue>;\nexport interface DateRangePickerState extends OverlayTriggerState, FormValidationState {\n /** The currently selected date range. */\n value: RangeValue<DateValue | null>,\n /** Sets the selected date range. */\n setValue(value: DateRange | null): void,\n /**\n * The date portion of the selected range. This may be set prior to `value` if the user has\n * selected a date range but has not yet selected a time range.\n */\n dateRange: RangeValue<DateValue | null> | null,\n /** Sets the date portion of the selected range. */\n setDateRange(value: DateRange): void,\n /**\n * The time portion of the selected range. This may be set prior to `value` if the user has\n * selected a time range but has not yet selected a date range.\n */\n timeRange: RangeValue<TimeValue | null> | null,\n /** Sets the time portion of the selected range. */\n setTimeRange(value: TimeRange): void,\n /** Sets the date portion of either the start or end of the selected range. */\n setDate(part: 'start' | 'end', value: DateValue | null): void,\n /** Sets the time portion of either the start or end of the selected range. */\n setTime(part: 'start' | 'end', value: TimeValue | null): void,\n /** Sets the date and time of either the start or end of the selected range. */\n setDateTime(part: 'start' | 'end', value: DateValue | null): void,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** Whether the date range picker supports selecting times, according to the `granularity` prop and current value. */\n hasTime: boolean,\n /** Whether the calendar popover is currently open. */\n isOpen: boolean,\n /** Sets whether the calendar popover is open. */\n setOpen(isOpen: boolean): void,\n /**\n * The current validation state of the date range picker, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** Formats the selected range using the given options. */\n formatValue(locale: string, fieldOptions: FieldOptions): {start: string, end: string} | null,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\n/**\n * Provides state management for a date range picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePickerState<T extends DateValue = DateValue>(props: DateRangePickerStateOptions<T>): DateRangePickerState {\n let overlayState = useOverlayTriggerState(props);\n let [controlledValue, setControlledValue] = useControlledState<DateRange | null, RangeValue<MappedDateValue<T>> | null>(props.value, props.defaultValue || null, props.onChange);\n let [placeholderValue, setPlaceholderValue] = useState<RangeValue<DateValue | null>>(() => controlledValue || {start: null, end: null});\n\n // Reset the placeholder if the value prop is set to null.\n if (controlledValue == null && placeholderValue.start && placeholderValue.end) {\n placeholderValue = {start: null, end: null};\n setPlaceholderValue(placeholderValue);\n }\n\n let value = controlledValue || placeholderValue;\n\n let setValue = (value: RangeValue<DateValue | null> | null) => {\n setPlaceholderValue(value || {start: null, end: null});\n if (isCompleteRange(value)) {\n setControlledValue(value);\n } else {\n setControlledValue(null);\n }\n };\n\n let v = (value?.start || value?.end || props.placeholderValue || null);\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;\n\n let [dateRange, setSelectedDateRange] = useState<RangeValue<DateValue | null> | null>(null);\n let [timeRange, setSelectedTimeRange] = useState<RangeValue<TimeValue | null> | null>(null);\n\n if (value && isCompleteRange(value)) {\n dateRange = value;\n if ('hour' in value.start) {\n timeRange = value as TimeRange;\n }\n }\n\n let commitValue = (dateRange: DateRange, timeRange: TimeRange) => {\n setValue({\n start: 'timeZone' in timeRange.start ? timeRange.start.set(toCalendarDate(dateRange.start)) : toCalendarDateTime(dateRange.start, timeRange.start),\n end: 'timeZone' in timeRange.end ? timeRange.end.set(toCalendarDate(dateRange.end)) : toCalendarDateTime(dateRange.end, timeRange.end)\n });\n setSelectedDateRange(null);\n setSelectedTimeRange(null);\n validation.commitValidation();\n };\n\n // Intercept setValue to make sure the Time section is not changed by date selection in Calendar\n let setDateRange = (range: RangeValue<DateValue | null>) => {\n let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;\n if (hasTime) {\n // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.\n if (isCompleteRange(range) && (shouldClose || (timeRange?.start && timeRange?.end))) {\n commitValue(range, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n } else {\n setSelectedDateRange(range);\n }\n } else if (isCompleteRange(range)) {\n setValue(range);\n validation.commitValidation();\n } else {\n setSelectedDateRange(range);\n }\n\n if (shouldClose) {\n overlayState.setOpen(false);\n }\n };\n\n let setTimeRange = (range: RangeValue<TimeValue | null>) => {\n if (isCompleteRange(dateRange) && isCompleteRange(range)) {\n commitValue(dateRange, range);\n } else {\n setSelectedTimeRange(range);\n }\n };\n\n let showEra = (value?.start?.calendar.identifier === 'gregory' && value.start.era === 'BC') || (value?.end?.calendar.identifier === 'gregory' && value.end.era === 'BC');\n let formatOpts = useMemo(() => ({\n granularity,\n timeZone: defaultTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n showEra\n }), [granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, props.hideTimeZone, showEra]);\n\n let {minValue, maxValue, isDateUnavailable} = props;\n let builtinValidation = useMemo(() => getRangeValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: controlledValue as RangeValue<MappedDateValue<T>> | null,\n name: useMemo(() => [props.startName, props.endName].filter(n => n != null), [props.startName, props.endName]),\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value,\n setValue,\n dateRange,\n timeRange,\n granularity,\n hasTime,\n setDate(part, date) {\n if (part === 'start') {\n setDateRange({start: date, end: dateRange?.end ?? null});\n } else {\n setDateRange({start: dateRange?.start ?? null, end: date});\n }\n },\n setTime(part, time) {\n if (part === 'start') {\n setTimeRange({start: time, end: timeRange?.end ?? null});\n } else {\n setTimeRange({start: timeRange?.start ?? null, end: time});\n }\n },\n setDateTime(part, dateTime) {\n if (part === 'start') {\n setValue({start: dateTime, end: value?.end ?? null});\n } else {\n setValue({start: value?.start ?? null, end: dateTime});\n }\n },\n setDateRange,\n setTimeRange,\n ...overlayState,\n setOpen(isOpen) {\n // Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.\n // If only the time range was set and not the date range, don't commit. The state will be preserved until\n // the user opens the popover again.\n if (!isOpen && !(value?.start && value?.end) && isCompleteRange(dateRange) && hasTime) {\n commitValue(dateRange, {\n start: timeRange?.start || getPlaceholderTime(props.placeholderValue),\n end: timeRange?.end || getPlaceholderTime(props.placeholderValue)\n });\n }\n\n overlayState.setOpen(isOpen);\n },\n validationState,\n isInvalid: isValueInvalid,\n formatValue(locale, fieldOptions) {\n if (!value || !value.start || !value.end) {\n return null;\n }\n\n let startTimeZone = 'timeZone' in value.start ? value.start.timeZone : undefined;\n let startGranularity = props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');\n let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;\n let endGranularity = props.granularity || (value.end && 'minute' in value.end ? 'minute' : 'day');\n\n let startOptions = getFormatOptions(fieldOptions, {\n granularity: startGranularity,\n timeZone: startTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n showEra: (value.start.calendar.identifier === 'gregory' && value.start.era === 'BC') ||\n (value.end.calendar.identifier === 'gregory' && value.end.era === 'BC')\n });\n\n let startDate = value.start.toDate(startTimeZone || 'UTC');\n let endDate = value.end.toDate(endTimeZone || 'UTC');\n\n let startFormatter = new DateFormatter(locale, startOptions);\n let endFormatter: Intl.DateTimeFormat;\n if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {\n // Use formatRange, as it results in shorter output when some of the fields\n // are shared between the start and end dates (e.g. the same month).\n // Formatting will fail if the end date is before the start date. Fall back below when that happens.\n try {\n let parts = startFormatter.formatRangeToParts(startDate, endDate);\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let start = '';\n let end = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n start += parts[i].value;\n } else if (i > separatorIndex) {\n end += parts[i].value;\n }\n }\n\n return {start, end};\n } catch {\n // ignore\n }\n\n endFormatter = startFormatter;\n } else {\n let endOptions = getFormatOptions(fieldOptions, {\n granularity: endGranularity,\n timeZone: endTimeZone,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle\n });\n\n endFormatter = new DateFormatter(locale, endOptions);\n }\n\n return {\n start: startFormatter.format(startDate),\n end: endFormatter.format(endDate)\n };\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction isCompleteRange<T>(value: RangeValue<T | null> | null): value is RangeValue<T> {\n return value?.start != null && value.end != null;\n}\n"],"names":[],"version":3,"file":"useDateRangePickerState.module.js.map"}
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@react-stately/datepicker",
3
- "version": "3.14.1",
3
+ "version": "3.14.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "types": "./dist/types.d.ts",
9
+ "source": "./src/index.ts",
10
+ "types": [
11
+ "./dist/types.d.ts",
12
+ "./src/index.ts"
13
+ ],
10
14
  "import": "./dist/import.mjs",
11
15
  "require": "./dist/main.js"
12
16
  },
@@ -22,13 +26,13 @@
22
26
  "url": "https://github.com/adobe/react-spectrum"
23
27
  },
24
28
  "dependencies": {
25
- "@internationalized/date": "^3.8.1",
26
- "@internationalized/string": "^3.2.6",
27
- "@react-stately/form": "^3.1.4",
28
- "@react-stately/overlays": "^3.6.16",
29
- "@react-stately/utils": "^3.10.6",
30
- "@react-types/datepicker": "^3.12.1",
31
- "@react-types/shared": "^3.29.1",
29
+ "@internationalized/date": "^3.8.2",
30
+ "@internationalized/string": "^3.2.7",
31
+ "@react-stately/form": "^3.1.5",
32
+ "@react-stately/overlays": "^3.6.17",
33
+ "@react-stately/utils": "^3.10.7",
34
+ "@react-types/datepicker": "^3.12.2",
35
+ "@react-types/shared": "^3.30.0",
32
36
  "@swc/helpers": "^0.5.0"
33
37
  },
34
38
  "peerDependencies": {
@@ -37,5 +41,5 @@
37
41
  "publishConfig": {
38
42
  "access": "public"
39
43
  },
40
- "gitHead": "9c77d4e8267ed39469c65f65da94ece7be509874"
44
+ "gitHead": "265b4d7f107905ee1c6e87a8af1613ab440a6849"
41
45
  }
@@ -118,9 +118,13 @@ const PAGE_STEP = {
118
118
  second: 15
119
119
  };
120
120
 
121
- // Node seems to convert everything to lowercase...
122
121
  const TYPE_MAPPING = {
123
- dayperiod: 'dayPeriod'
122
+ // Node seems to convert everything to lowercase...
123
+ dayperiod: 'dayPeriod',
124
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years
125
+ relatedYear: 'year',
126
+ yearName: 'literal', // not editable
127
+ unknown: 'literal'
124
128
  };
125
129
 
126
130
  export interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {
@@ -207,7 +211,7 @@ export function useDateFieldState<T extends DateValue = DateValue>(props: DateFi
207
211
  let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>
208
212
  dateFormatter.formatToParts(new Date())
209
213
  .filter(seg => EDITABLE_SEGMENTS[seg.type])
210
- .reduce((p, seg) => (p[seg.type] = true, p), {})
214
+ .reduce((p, seg) => (p[TYPE_MAPPING[seg.type] || seg.type] = true, p), {})
211
215
  , [dateFormatter]);
212
216
 
213
217
  let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(
@@ -413,18 +417,19 @@ function processSegments(dateValue, validSegments, dateFormatter, resolvedOption
413
417
  let segments = dateFormatter.formatToParts(dateValue);
414
418
  let processedSegments: DateSegment[] = [];
415
419
  for (let segment of segments) {
416
- let isEditable = EDITABLE_SEGMENTS[segment.type];
417
- if (segment.type === 'era' && calendar.getEras().length === 1) {
420
+ let type = TYPE_MAPPING[segment.type] || segment.type;
421
+ let isEditable = EDITABLE_SEGMENTS[type];
422
+ if (type === 'era' && calendar.getEras().length === 1) {
418
423
  isEditable = false;
419
424
  }
420
425
 
421
- let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
422
- let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;
426
+ let isPlaceholder = EDITABLE_SEGMENTS[type] && !validSegments[type];
427
+ let placeholder = EDITABLE_SEGMENTS[type] ? getPlaceholder(type, segment.value, locale) : null;
423
428
 
424
429
  let dateSegment = {
425
- type: TYPE_MAPPING[segment.type] || segment.type,
430
+ type,
426
431
  text: isPlaceholder ? placeholder : segment.value,
427
- ...getSegmentLimits(displayValue, segment.type, resolvedOptions),
432
+ ...getSegmentLimits(displayValue, type, resolvedOptions),
428
433
  isPlaceholder,
429
434
  placeholder,
430
435
  isEditable
@@ -433,7 +438,7 @@ function processSegments(dateValue, validSegments, dateFormatter, resolvedOption
433
438
  // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
434
439
  // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
435
440
  // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
436
- if (segment.type === 'hour') {
441
+ if (type === 'hour') {
437
442
  // This marks the start of the embedded direction change.
438
443
  processedSegments.push({
439
444
  type: 'literal',
@@ -445,7 +450,7 @@ function processSegments(dateValue, validSegments, dateFormatter, resolvedOption
445
450
  });
446
451
  processedSegments.push(dateSegment);
447
452
  // This marks the end of the embedded direction change in the case that the granularity it set to "hour".
448
- if (segment.type === granularity) {
453
+ if (type === granularity) {
449
454
  processedSegments.push({
450
455
  type: 'literal',
451
456
  text: '\u2069',
@@ -455,7 +460,7 @@ function processSegments(dateValue, validSegments, dateFormatter, resolvedOption
455
460
  isEditable: false
456
461
  });
457
462
  }
458
- } else if (timeValue.includes(segment.type) && segment.type === granularity) {
463
+ } else if (timeValue.includes(type) && type === granularity) {
459
464
  processedSegments.push(dateSegment);
460
465
  // This marks the end of the embedded direction change.
461
466
  processedSegments.push({
@@ -131,7 +131,8 @@ export function useDateRangePickerState<T extends DateValue = DateValue>(props:
131
131
  let setDateRange = (range: RangeValue<DateValue | null>) => {
132
132
  let shouldClose = typeof shouldCloseOnSelect === 'function' ? shouldCloseOnSelect() : shouldCloseOnSelect;
133
133
  if (hasTime) {
134
- if (isCompleteRange(range) && timeRange?.start && timeRange?.end) {
134
+ // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.
135
+ if (isCompleteRange(range) && (shouldClose || (timeRange?.start && timeRange?.end))) {
135
136
  commitValue(range, {
136
137
  start: timeRange?.start || getPlaceholderTime(props.placeholderValue),
137
138
  end: timeRange?.end || getPlaceholderTime(props.placeholderValue)