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obe. 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 {AriaButtonProps} from '../button/useButton';\n\nimport {AriaDatePickerProps} from './useDatePicker';\nimport {AriaDialogProps} from '../dialog/useDialog';\nimport {\n  AriaLabelingProps,\n  DOMAttributes,\n  DOMProps,\n  GroupDOMAttributes,\n  InputDOMProps,\n  KeyboardEvent,\n  RefObject,\n  ValidationResult\n} from '@react-types/shared';\nimport {createFocusManager} from '../focus/FocusScope';\nimport {\n  DateRange,\n  DateRangePickerProps,\n  DateRangePickerState,\n  DateValue\n} from 'react-stately/useDateRangePickerState';\nimport {\n  DEFAULT_VALIDATION_RESULT,\n  mergeValidation,\n  privateValidationStateProp\n} from 'react-stately/private/form/useFormValidationState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {focusManagerSymbol, roleSymbol} from './useDateField';\nimport intlMessages from '../../intl/datepicker/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {RangeCalendarProps} from 'react-stately/useRangeCalendarState';\nimport {useDatePickerGroup} from './useDatePickerGroup';\n// @ts-ignore\nimport {useDescription} from '../utils/useDescription';\nimport {useField} from '../label/useField';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo, useRef} from 'react';\n\nexport interface AriaDateRangePickerProps<T extends DateValue>\n  extends DateRangePickerProps<T>, AriaLabelingProps, Omit<InputDOMProps, 'name'>, DOMProps {}\n\nexport interface DateRangePickerAria extends ValidationResult {\n  /** Props for the date range picker's visible label element, if any. */\n  labelProps: DOMAttributes;\n  /** Props for the grouping element containing the date fields and button. */\n  groupProps: GroupDOMAttributes;\n  /** Props for the start date field. */\n  startFieldProps: AriaDatePickerProps<DateValue>;\n  /** Props for the end date field. */\n  endFieldProps: AriaDatePickerProps<DateValue>;\n  /** Props for the popover trigger button. */\n  buttonProps: AriaButtonProps;\n  /** Props for the description element, if any. */\n  descriptionProps: DOMAttributes;\n  /** Props for the error message element, if any. */\n  errorMessageProps: DOMAttributes;\n  /** Props for the popover dialog. */\n  dialogProps: AriaDialogProps;\n  /** Props for the range calendar within the popover dialog. */\n  calendarProps: RangeCalendarProps<DateValue>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date 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 useDateRangePicker<T extends DateValue>(\n  props: AriaDateRangePickerProps<T>,\n  state: DateRangePickerState,\n  ref: RefObject<Element | null>\n): DateRangePickerAria {\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n  let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n  let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n    ...props,\n    labelElementType: 'span',\n    isInvalid,\n    errorMessage: props.errorMessage || validationErrors\n  });\n\n  let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n  let {locale} = useLocale();\n  let range = state.formatValue(locale, {month: 'long'});\n  let description = range\n    ? stringFormatter.format('selectedRangeDescription', {\n        startDate: range.start,\n        endDate: range.end\n      })\n    : '';\n  let descProps = useDescription(description);\n\n  let startFieldProps = {\n    'aria-label': stringFormatter.format('startDate'),\n    'aria-labelledby': labelledBy\n  };\n\n  let endFieldProps = {\n    'aria-label': stringFormatter.format('endDate'),\n    'aria-labelledby': labelledBy\n  };\n\n  let buttonId = useId();\n  let dialogId = useId();\n\n  let groupProps = useDatePickerGroup(state, ref);\n\n  let ariaDescribedBy =\n    [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') ||\n    undefined;\n  let focusManager = useMemo(\n    () =>\n      createFocusManager(ref, {\n        // Exclude the button from the focus manager.\n        accept: element => element.id !== buttonId\n      }),\n    [ref, buttonId]\n  );\n\n  let commonFieldProps = {\n    [focusManagerSymbol]: focusManager,\n    [roleSymbol]: 'presentation',\n    'aria-describedby': ariaDescribedBy,\n    placeholderValue: props.placeholderValue,\n    hideTimeZone: props.hideTimeZone,\n    hourCycle: props.hourCycle,\n    granularity: props.granularity,\n    shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n    isDisabled: props.isDisabled,\n    isReadOnly: props.isReadOnly,\n    isRequired: props.isRequired,\n    validationBehavior: props.validationBehavior\n  };\n\n  let domProps = filterDOMProps(props);\n\n  let isFocused = useRef(false);\n  let {focusWithinProps} = useFocusWithin({\n    ...props,\n    isDisabled: state.isOpen,\n    onBlurWithin: e => {\n      // Ignore when focus moves into the popover.\n      let dialog = document.getElementById(dialogId);\n      if (!nodeContains(dialog, e.relatedTarget)) {\n        isFocused.current = false;\n        props.onBlur?.(e);\n        props.onFocusChange?.(false);\n      }\n    },\n    onFocusWithin: e => {\n      if (!isFocused.current) {\n        isFocused.current = true;\n        props.onFocus?.(e);\n        props.onFocusChange?.(true);\n      }\n    }\n  });\n\n  let startFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n  let endFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n\n  return {\n    groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n      role: 'group' as const,\n      'aria-disabled': props.isDisabled || null,\n      'aria-describedby': ariaDescribedBy,\n      onKeyDown(e: KeyboardEvent) {\n        if (state.isOpen) {\n          return;\n        }\n\n        if (props.onKeyDown) {\n          props.onKeyDown(e);\n        }\n      },\n      onKeyUp(e: KeyboardEvent) {\n        if (state.isOpen) {\n          return;\n        }\n\n        if (props.onKeyUp) {\n          props.onKeyUp(e);\n        }\n      }\n    }),\n    labelProps: {\n      ...labelProps,\n      onClick: () => {\n        focusManager.focusFirst();\n      }\n    },\n    buttonProps: {\n      ...descProps,\n      id: buttonId,\n      'aria-haspopup': 'dialog',\n      'aria-label': stringFormatter.format('calendar'),\n      'aria-labelledby': `${buttonId} ${labelledBy}`,\n      'aria-describedby': ariaDescribedBy,\n      'aria-expanded': state.isOpen,\n      isDisabled: props.isDisabled || props.isReadOnly,\n      onPress: () => state.setOpen(true)\n    },\n    dialogProps: {\n      id: dialogId,\n      'aria-labelledby': `${buttonId} ${labelledBy}`\n    },\n    startFieldProps: {\n      ...startFieldProps,\n      ...commonFieldProps,\n      value: state.value?.start ?? null,\n      defaultValue: state.defaultValue?.start,\n      onChange: start => state.setDateTime('start', start),\n      autoFocus: props.autoFocus,\n      name: props.startName,\n      form: props.form,\n      [privateValidationStateProp]: {\n        realtimeValidation: state.realtimeValidation,\n        displayValidation: state.displayValidation,\n        updateValidation(e) {\n          startFieldValidation.current = e;\n          state.updateValidation(mergeValidation(e, endFieldValidation.current));\n        },\n        resetValidation: state.resetValidation,\n        commitValidation: state.commitValidation\n      }\n    },\n    endFieldProps: {\n      ...endFieldProps,\n      ...commonFieldProps,\n      value: state.value?.end ?? null,\n      defaultValue: state.defaultValue?.end,\n      onChange: end => state.setDateTime('end', end),\n      name: props.endName,\n      form: props.form,\n      [privateValidationStateProp]: {\n        realtimeValidation: state.realtimeValidation,\n        displayValidation: state.displayValidation,\n        updateValidation(e) {\n          endFieldValidation.current = e;\n          state.updateValidation(mergeValidation(startFieldValidation.current, e));\n        },\n        resetValidation: state.resetValidation,\n        commitValidation: state.commitValidation\n      }\n    },\n    descriptionProps,\n    errorMessageProps,\n    calendarProps: {\n      autoFocus: true,\n      value: state.dateRange?.start && state.dateRange.end ? (state.dateRange as DateRange) : null,\n      onChange: state.setDateRange,\n      minValue: props.minValue,\n      maxValue: props.maxValue,\n      isDisabled: props.isDisabled,\n      isReadOnly: props.isReadOnly,\n      isDateUnavailable: props.isDateUnavailable,\n      allowsNonContiguousRanges: props.allowsNonContiguousRanges,\n      defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,\n      isInvalid: state.isInvalid,\n      errorMessage:\n        typeof props.errorMessage === 'function'\n          ? props.errorMessage(state.displayValidation)\n          : props.errorMessage || state.displayValidation.validationErrors.join(' '),\n      firstDayOfWeek: props.firstDayOfWeek,\n      pageBehavior: props.pageBehavior\n    },\n    isInvalid,\n    validationErrors,\n    validationDetails\n  };\n}\n"],"names":[],"version":3,"file":"useDateRangePicker.cjs.map"}