📄 useDateRangePickerState.mjs.map
/home/palash/git/site/node_modules/react-stately/dist/private/datepicker/useDateRangePickerState.mjs.map
Language: map • Lines: 1
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAkGM,SAAS,yCACd,KAAqC;IAErC,IAAI,eAAe,CAAA,GAAA,yCAAqB,EAAE;IAC1C,IAAI,CAAC,iBAAiB,mBAAmB,GAAG,CAAA,GAAA,yCAAiB,EAG3D,MAAM,KAAK,EAAE,MAAM,YAAY,IAAI,MAAM,MAAM,QAAQ;IACzD,IAAI,CAAC,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC9B,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EACnD,IAAM,mBAAmB;YAAC,OAAO;YAAM,KAAK;QAAI;IAGlD,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,QAAQ,YAAY;YAAC,OAAO;YAAM,KAAK;QAAI;QAC3C,oBAAoB;QACpB,IAAI,sCAAgB,QAClB,mBAAmB;aAEnB,mBAAmB;IAEvB;IAEA,IAAI,IAAI,OAAO,SAAS,OAAO,OAAO,MAAM,gBAAgB,IAAI;IAChE,IAAI,CAAC,aAAa,gBAAgB,GAAG,CAAA,GAAA,yCAAc,EAAE,GAAG,MAAM,WAAW;IACzE,IAAI,UAAU,gBAAgB,UAAU,gBAAgB,YAAY,gBAAgB;IACpF,IAAI,sBAAsB,MAAM,mBAAmB,IAAI;IAEvD,IAAI,CAAC,WAAW,qBAAqB,GAAG,CAAA,GAAA,eAAO,EAAuC;IACtF,IAAI,CAAC,WAAW,qBAAqB,GAAG,CAAA,GAAA,eAAO,EAAuC;IAEtF,IAAI,SAAS,sCAAgB,QAAQ;QAC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,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,OAAO,SAAS,QAAQ,MAAM,GAAG,IAAI;AAC9C","sources":["packages/react-stately/src/datepicker/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\nimport {DateFormatter, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {\n  DateRange,\n  DateRangePickerProps,\n  DateValue,\n  Granularity,\n  MappedDateValue,\n  TimeValue\n} from './types';\nimport {\n  FieldOptions,\n  FormatterOptions,\n  getFormatOptions,\n  getPlaceholderTime,\n  getRangeValidationResult,\n  useDefaultProps\n} from './utils';\nimport {FormValidationState, useFormValidationState} from '../form/useFormValidationState';\nimport {OverlayTriggerState, useOverlayTriggerState} from '../overlays/useOverlayTriggerState';\nimport {RangeValue, ValidationState} from '@react-types/shared';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useMemo, useState} from 'react';\n\nexport interface DateRangePickerStateOptions<\n  T extends DateValue = DateValue\n> extends DateRangePickerProps<T> {\n  /**\n   * Determines whether the date picker popover should close automatically when a date is selected.\n   *\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  /** The default selected date range. */\n  defaultValue: DateRange | 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  /**\n   * Whether the date range picker supports selecting times, according to the `granularity` prop and\n   * current value.\n   */\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`,\n   * `minValue`, and `maxValue` props.\n   *\n   * @deprecated Use `isInvalid` instead.\n   */\n  validationState: ValidationState | null;\n  /**\n   * Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue`\n   * props.\n   */\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>(\n  props: DateRangePickerStateOptions<T>\n): DateRangePickerState {\n  let overlayState = useOverlayTriggerState(props);\n  let [controlledValue, setControlledValue] = useControlledState<\n    DateRange | null,\n    RangeValue<MappedDateValue<T>> | null\n  >(props.value, props.defaultValue || null, props.onChange);\n  let [initialValue] = useState(controlledValue);\n  let [placeholderValue, setPlaceholderValue] = useState<RangeValue<DateValue | null>>(\n    () => controlledValue || {start: null, end: null}\n  );\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 = (newValue: RangeValue<DateValue | null> | null) => {\n    value = newValue || {start: null, end: null};\n    setPlaceholderValue(value);\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:\n        'timeZone' in timeRange.start\n          ? timeRange.start.set(toCalendarDate(dateRange.start))\n          : toCalendarDateTime(dateRange.start, timeRange.start),\n      end:\n        'timeZone' in timeRange.end\n          ? timeRange.end.set(toCalendarDate(dateRange.end))\n          : 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 =\n      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 =\n    (value?.start?.calendar.identifier === 'gregory' && value.start.era === 'BC') ||\n    (value?.end?.calendar.identifier === 'gregory' && value.end.era === 'BC');\n  let formatOpts = useMemo(\n    () => ({\n      granularity,\n      timeZone: defaultTimeZone,\n      hideTimeZone: props.hideTimeZone,\n      hourCycle: props.hourCycle,\n      shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n      showEra\n    }),\n    [\n      granularity,\n      props.hourCycle,\n      props.shouldForceLeadingZeros,\n      defaultTimeZone,\n      props.hideTimeZone,\n      showEra\n    ]\n  );\n\n  let {minValue, maxValue, isDateUnavailable} = props;\n  let builtinValidation = useMemo(\n    () =>\n      getRangeValidationResult(\n        value,\n        minValue,\n        maxValue,\n        isDateUnavailable ? date => isDateUnavailable(date, null) : undefined,\n        formatOpts\n      ),\n    [value, minValue, maxValue, isDateUnavailable, formatOpts]\n  );\n\n  let validation = useFormValidationState({\n    ...props,\n    value: controlledValue as RangeValue<MappedDateValue<T>> | null,\n    name: useMemo(\n      () => [props.startName, props.endName].filter(n => n != null),\n      [props.startName, props.endName]\n    ),\n    builtinValidation\n  });\n\n  let isValueInvalid = validation.displayValidation.isInvalid;\n  let validationState: ValidationState | null =\n    props.validationState || (isValueInvalid ? 'invalid' : null);\n\n  return {\n    ...validation,\n    value,\n    defaultValue: props.defaultValue ?? initialValue,\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 =\n        props.granularity || (value.start && 'minute' in value.start ? 'minute' : 'day');\n      let endTimeZone = 'timeZone' in value.end ? value.end.timeZone : undefined;\n      let endGranularity =\n        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:\n          (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 (\n        startTimeZone === endTimeZone &&\n        startGranularity === endGranularity &&\n        value.start.compare(value.end) !== 0\n      ) {\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.mjs.map"}