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AAkB,EAClB,QAAgB,EAChB,kBAAuD;IAEvD,IAAI,KAAK,QAAQ,CAAC,mBAAmB,EACnC,OAAO,KAAK,QAAQ,CAAC,mBAAmB,CAAC;IAE3C,OAAO,mBAAmB,MAAM,CAAC,KAAK,MAAM,CAAC;AAC/C","sources":["packages/@adobe/react-spectrum/src/calendar/CalendarBase.tsx"],"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 {ActionButton} from '../button/ActionButton';\n\nimport {AriaButtonProps} from 'react-aria/useButton';\nimport {CalendarDate} from '@internationalized/date';\nimport {CalendarMonth} from './CalendarMonth';\nimport {CalendarPropsBase, CalendarState} from 'react-stately/useCalendarState';\nimport ChevronLeft from '@spectrum-icons/ui/ChevronLeftLarge';\nimport ChevronRight from '@spectrum-icons/ui/ChevronRightLarge';\nimport {classNames} from '../utils/classNames';\nimport {DOMProps, RefObject, StyleProps} from '@react-types/shared';\nimport {HelpText} from '../label/HelpText';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\n// @ts-ignore\nimport React, {HTMLAttributes, JSX} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/calendar/vars.css';\nimport {useDateFormatter} from 'react-aria/useDateFormatter';\nimport {useLocale} from 'react-aria/I18nProvider';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\nimport {useStyleProps} from '../utils/styleProps';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\ninterface CalendarBaseProps<T extends CalendarState | RangeCalendarState>\n  extends CalendarPropsBase, DOMProps, StyleProps {\n  state: T;\n  visibleMonths?: number;\n  calendarProps: HTMLAttributes<HTMLElement>;\n  nextButtonProps: AriaButtonProps;\n  prevButtonProps: AriaButtonProps;\n  errorMessageProps: HTMLAttributes<HTMLElement>;\n  calendarRef: RefObject<HTMLDivElement | null>;\n}\n\nexport function CalendarBase<T extends CalendarState | RangeCalendarState>(\n  props: CalendarBaseProps<T>\n): JSX.Element {\n  let {\n    state,\n    calendarProps,\n    nextButtonProps,\n    prevButtonProps,\n    errorMessageProps,\n    calendarRef: ref,\n    visibleMonths = 1,\n    firstDayOfWeek\n  } = props;\n  let {styleProps} = useStyleProps(props);\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/calendar');\n  let {direction} = useLocale();\n  let currentMonth = state.visibleRange.start;\n  let monthDateFormatter = useDateFormatter({\n    month: 'long',\n    year: 'numeric',\n    era:\n      currentMonth.calendar.identifier === 'gregory' && currentMonth.era === 'BC'\n        ? 'short'\n        : undefined,\n    calendar: currentMonth.calendar.identifier,\n    timeZone: state.timeZone\n  });\n\n  let titles: JSX.Element[] = [];\n  let calendars: JSX.Element[] = [];\n  for (let i = 0; i < visibleMonths; i++) {\n    let d = currentMonth.add({months: i});\n    titles.push(\n      <div key={i} className={classNames(styles, 'spectrum-Calendar-monthHeader')}>\n        {i === 0 && (\n          <ActionButton\n            {...prevButtonProps}\n            UNSAFE_className={classNames(styles, 'spectrum-Calendar-prevMonth')}\n            isQuiet>\n            {direction === 'rtl' ? <ChevronRight /> : <ChevronLeft />}\n          </ActionButton>\n        )}\n        <h2\n          // We have a visually hidden heading describing the entire visible range,\n          // and the calendar itself describes the individual month\n          // so we don't need to repeat that here for screen reader users.\n          aria-hidden\n          className={classNames(styles, 'spectrum-Calendar-title')}>\n          {getCurrentMonthName(d, state.timeZone, monthDateFormatter)}\n        </h2>\n        {i === visibleMonths - 1 && (\n          <ActionButton\n            {...nextButtonProps}\n            UNSAFE_className={classNames(styles, 'spectrum-Calendar-nextMonth')}\n            isQuiet>\n            {direction === 'rtl' ? <ChevronLeft /> : <ChevronRight />}\n          </ActionButton>\n        )}\n      </div>\n    );\n\n    calendars.push(\n      <CalendarMonth\n        {...props}\n        key={i}\n        state={state}\n        startDate={d}\n        firstDayOfWeek={firstDayOfWeek}\n      />\n    );\n  }\n\n  return (\n    <div\n      {...styleProps}\n      {...calendarProps}\n      ref={ref}\n      className={classNames(styles, 'spectrum-Calendar', styleProps.className)}>\n      {/* Add a screen reader only description of the entire visible range rather than\n       * a separate heading above each month grid. This is placed first in the DOM order\n       * so that it is the first thing a touch screen reader user encounters.\n       * In addition, VoiceOver on iOS does not announce the aria-label of the grid\n       * elements, so the aria-label of the Calendar is included here as well. */}\n      <VisuallyHidden>\n        <h2>{calendarProps['aria-label']}</h2>\n      </VisuallyHidden>\n      <div className={classNames(styles, 'spectrum-Calendar-header')}>{titles}</div>\n      <div className={classNames(styles, 'spectrum-Calendar-months')}>{calendars}</div>\n      {/* For touch screen readers, add a visually hidden next button after the month grid\n       * so it's easy to navigate after reaching the end without going all the way\n       * back to the start of the month. */}\n      <VisuallyHidden>\n        <button\n          aria-label={nextButtonProps['aria-label']}\n          disabled={nextButtonProps.isDisabled}\n          onClick={() => state.focusNextPage()}\n          tabIndex={-1}\n        />\n      </VisuallyHidden>\n      {state.isValueInvalid && (\n        <HelpText\n          showErrorIcon\n          errorMessage={\n            props.errorMessage ||\n            stringFormatter.format('invalidSelection', {\n              selectedCount: 'highlightedRange' in state ? 2 : 1\n            })\n          }\n          errorMessageProps={errorMessageProps}\n          isInvalid\n          // Intentionally a global class name so it can be targeted in DatePicker CSS...\n          UNSAFE_className=\"spectrum-Calendar-helpText\"\n        />\n      )}\n    </div>\n  );\n}\n\nfunction getCurrentMonthName(\n  date: CalendarDate,\n  timezone: string,\n  monthDateFormatter: ReturnType<typeof useDateFormatter>\n): string {\n  if (date.calendar.getFormattableMonth) {\n    date = date.calendar.getFormattableMonth(date);\n  }\n  return monthDateFormatter.format(date.toDate(timezone));\n}\n"],"names":[],"version":3,"file":"CalendarBase.cjs.map"}