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kBACA;sBACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarGrid.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 {CalendarDate, getWeeksInMonth, startOfWeek, today} from '@internationalized/date';\nimport {CalendarState} from 'react-stately/useCalendarState';\nimport {DOMAttributes} from '@react-types/shared';\nimport {hookData, useVisibleRangeDescription} from './utils';\nimport {KeyboardEvent, useMemo} from 'react';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useDateFormatter} from '../i18n/useDateFormatter';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\n\nexport interface AriaCalendarGridProps {\n  /**\n   * The first date displayed in the calendar grid.\n   * Defaults to the first visible date in the calendar.\n   * Override this to display multiple date grids in a calendar.\n   */\n  startDate?: CalendarDate,\n  /**\n   * The last date displayed in the calendar grid.\n   * Defaults to the last visible date in the calendar.\n   * Override this to display multiple date grids in a calendar.\n   */\n  endDate?: CalendarDate,\n  /**\n   * The style of weekday names to display in the calendar grid header,\n   * e.g. single letter, abbreviation, or full day name.\n   * @default \"narrow\"\n   */\n  weekdayStyle?: 'narrow' | 'short' | 'long',\n  /**\n   * The day that starts the week.\n   */\n  firstDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'\n}\n\nexport interface CalendarGridAria {\n  /** Props for the date grid element (e.g. `<table>`). */\n  gridProps: DOMAttributes,\n  /** Props for the grid header element (e.g. `<thead>`). */\n  headerProps: DOMAttributes,\n  /** A list of week day abbreviations formatted for the current locale, typically used in column headers. */\n  weekDays: string[],\n  /** The number of weeks in the month. */\n  weeksInMonth: number\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar grid component.\n * A calendar grid displays a single grid of days within a calendar or range calendar which\n * can be keyboard navigated and selected by the user.\n */\nexport function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarState | RangeCalendarState): CalendarGridAria {\n  let {\n    startDate = state.visibleRange.start,\n    endDate = state.visibleRange.end,\n    firstDayOfWeek\n  } = props;\n\n  let {direction} = useLocale();\n\n  let onKeyDown = (e: KeyboardEvent) => {\n    switch (e.key) {\n      case 'Enter':\n      case ' ':\n        e.preventDefault();\n        state.selectFocusedDate();\n        break;\n      case 'PageUp':\n        e.preventDefault();\n        e.stopPropagation();\n        state.focusPreviousSection(e.shiftKey);\n        break;\n      case 'PageDown':\n        e.preventDefault();\n        e.stopPropagation();\n        state.focusNextSection(e.shiftKey);\n        break;\n      case 'End':\n        e.preventDefault();\n        e.stopPropagation();\n        state.focusSectionEnd();\n        break;\n      case 'Home':\n        e.preventDefault();\n        e.stopPropagation();\n        state.focusSectionStart();\n        break;\n      case 'ArrowLeft':\n        e.preventDefault();\n        e.stopPropagation();\n        if (direction === 'rtl') {\n          state.focusNextDay();\n        } else {\n          state.focusPreviousDay();\n        }\n        break;\n      case 'ArrowUp':\n        e.preventDefault();\n        e.stopPropagation();\n        state.focusPreviousRow();\n        break;\n      case 'ArrowRight':\n        e.preventDefault();\n        e.stopPropagation();\n        if (direction === 'rtl') {\n          state.focusPreviousDay();\n        } else {\n          state.focusNextDay();\n        }\n        break;\n      case 'ArrowDown':\n        e.preventDefault();\n        e.stopPropagation();\n        state.focusNextRow();\n        break;\n      case 'Escape':\n        // Cancel the selection.\n        if ('setAnchorDate' in state) {\n          e.preventDefault();\n          state.setAnchorDate(null);\n        }\n        break;\n    }\n  };\n\n  let visibleRangeDescription = useVisibleRangeDescription(startDate, endDate, state.timeZone, true);\n\n  let {ariaLabel, ariaLabelledBy} = hookData.get(state)!;\n  let labelProps = useLabels({\n    'aria-label': [ariaLabel, visibleRangeDescription].filter(Boolean).join(', '),\n    'aria-labelledby': ariaLabelledBy\n  });\n\n  let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});\n  let {locale} = useLocale();\n  let weekDays = useMemo(() => {\n    let weekStart = startOfWeek(today(state.timeZone), locale, firstDayOfWeek);\n    return [...new Array(7).keys()].map((index) => {\n      let date = weekStart.add({days: index});\n      let dateDay = date.toDate(state.timeZone);\n      return dayFormatter.format(dateDay);\n    });\n  }, [locale, state.timeZone, dayFormatter, firstDayOfWeek]);\n  let weeksInMonth = getWeeksInMonth(startDate, locale, firstDayOfWeek);\n\n  return {\n    gridProps: mergeProps(labelProps, {\n      role: 'grid',\n      'aria-readonly': state.isReadOnly || undefined,\n      'aria-disabled': state.isDisabled || undefined,\n      'aria-multiselectable': ('highlightedRange' in state) || undefined,\n      onKeyDown,\n      onFocus: () => state.setFocused(true),\n      onBlur: () => state.setFocused(false)\n    }),\n    headerProps: {\n      // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.\n      // The day names are already included in the label of each cell, so there's no need to announce them twice.\n      'aria-hidden': true\n    },\n    weekDays,\n    weeksInMonth\n  };\n}\n"],"names":[],"version":3,"file":"useCalendarGrid.cjs.map"}