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AC5B,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,oBAAoB,MAAM,kBAAkB;YAC5C,2DAA2D;YAC3D,CAAC,CAAA,GAAA,+EAAyB,EAAE,EAAE;YAC9B,WAAW,MAAM,SAAS;YAC1B,MAAM,MAAM,IAAI;YAChB,MAAM,MAAM,IAAI;QAClB;0BACA;2BACA;QACA,aAAa;YACX,GAAG,SAAS;YACZ,IAAI;YACJ,iBAAiB;YACjB,cAAc,gBAAgB,MAAM,CAAC;YACrC,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;YAC9C,oBAAoB;YACpB,iBAAiB,MAAM,MAAM;YAC7B,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;YAChD,SAAS,IAAM,MAAM,OAAO,CAAC;QAC/B;QACA,aAAa;YACX,IAAI;YACJ,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;QAChD;QACA,eAAe;YACb,WAAW;YACX,OAAO,MAAM,SAAS;YACtB,UAAU,MAAM,YAAY;YAC5B,UAAU,MAAM,QAAQ;YACxB,UAAU,MAAM,QAAQ;YACxB,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/react-aria/src/datepicker/useDatePicker.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 {AriaButtonProps} from '../button/useButton';\n\nimport {AriaDialogProps} from '../dialog/useDialog';\nimport {AriaLabelingProps, DOMAttributes, DOMProps, GroupDOMAttributes, InputDOMProps, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {CalendarProps} from 'react-stately/useCalendarState';\nimport {createFocusManager} from '../focus/FocusScope';\nimport {DatePickerProps, DatePickerState, DateValue} from 'react-stately/useDatePickerState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/datepicker/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\n// @ts-ignore\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\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 AriaDatePickerProps<T extends DateValue> extends DatePickerProps<T>, AriaLabelingProps, InputDOMProps, DOMProps, InputDOMProps {\n  /**\n   * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n   */\n  autoComplete?: string\n}\n\nexport interface DatePickerAria extends ValidationResult {\n  /** Props for the date picker's visible label element, if any. */\n  labelProps: DOMAttributes,\n  /** Props for the grouping element containing the date field and button. */\n  groupProps: GroupDOMAttributes,\n  /** Props for the date field. */\n  fieldProps: 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 calendar within the popover dialog. */\n  calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {\n  let buttonId = useId();\n  let dialogId = useId();\n  let fieldId = useId();\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\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 groupProps = useDatePickerGroup(state, ref);\n\n  let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n  let {locale} = useLocale();\n  let date = state.formatValue(locale, {month: 'long'});\n  let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n  let descProps = useDescription(description);\n  let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n  let domProps = filterDOMProps(props);\n  let focusManager = useMemo(() => createFocusManager(ref), [ref]);\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  return {\n    groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n      role: 'group' as const,\n      'aria-disabled': props.isDisabled || null,\n      'aria-labelledby': labelledBy,\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    fieldProps: {\n      ...fieldProps,\n      id: fieldId,\n      [roleSymbol]: 'presentation',\n      'aria-describedby': ariaDescribedBy,\n      value: state.value,\n      defaultValue: state.defaultValue,\n      onChange: state.setValue,\n      placeholderValue: props.placeholderValue,\n      hideTimeZone: props.hideTimeZone,\n      hourCycle: props.hourCycle,\n      shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n      granularity: props.granularity,\n      isDisabled: props.isDisabled,\n      isReadOnly: props.isReadOnly,\n      isRequired: props.isRequired,\n      validationBehavior: props.validationBehavior,\n      // DatePicker owns the validation state for the date field.\n      [privateValidationStateProp]: state,\n      autoFocus: props.autoFocus,\n      name: props.name,\n      form: props.form\n    },\n    descriptionProps,\n    errorMessageProps,\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    calendarProps: {\n      autoFocus: true,\n      value: state.dateValue,\n      onChange: state.setDateValue,\n      minValue: props.minValue,\n      maxValue: props.maxValue,\n      isDisabled: props.isDisabled,\n      isReadOnly: props.isReadOnly,\n      isDateUnavailable: props.isDateUnavailable,\n      defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n      isInvalid: state.isInvalid,\n      errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (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":"useDatePicker.cjs.map"}