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S;kCAOR,MAAM,IAAI,CAAC;4BAAC,QAAQ;wBAAa,GAAG,GAAG,CAAC,CAAC,GAAG,kBAC3C,gCAAC,CAAA,GAAA,sCAAW;gCAAE,QAAQ;+BAAQ;;oBAGjC,2BACC,gCAAC,CAAA,GAAA,+BAAG;wBAAE,MAAK;wBAAe,WAAW,CAAA,GAAA,wCAAa,EAAE;uCAAC;wCAAW;4BAAY,MAAM;wBAAG;kCAClF,gBAAgB,gBAAgB,MAAM,CAAC,6BAA6B;4BAAC,eAAe;wBAAC;;;;QAKhG;;AAGN","sources":["packages/@react-spectrum/s2/src/RangeCalendar.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {\n RangeCalendar as AriaRangeCalendar,\n RangeCalendarProps as AriaRangeCalendarProps,\n ContextValue,\n DateValue,\n Provider,\n Text\n} from 'react-aria-components';\nimport {CalendarButton, CalendarGrid, CalendarHeading} from './Calendar';\nimport ChevronLeftIcon from '../s2wf-icons/S2_Icon_ChevronLeft_20_N.svg';\nimport ChevronRightIcon from '../s2wf-icons/S2_Icon_ChevronRight_20_N.svg';\nimport {createContext, ForwardedRef, forwardRef, ReactNode} from 'react';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {Header, HeaderContext, HeadingContext} from './';\nimport {helpTextStyles} from './Field';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {style} from '../style' with {type: 'macro'};\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\n\nexport interface RangeCalendarProps<T extends DateValue>\n extends Omit<AriaRangeCalendarProps<T>, 'visibleDuration' | 'style' | 'className' | 'children' | 'styles' | keyof GlobalDOMAttributes>,\n StyleProps {\n /**\n * The error message to display when the calendar is invalid.\n */\n errorMessage?: ReactNode,\n /**\n * The number of months to display at once.\n * @default 1\n */\n visibleMonths?: number\n}\n\nexport const RangeCalendarContext = createContext<ContextValue<Partial<RangeCalendarProps<any>>, HTMLDivElement>>(null);\n\n\nconst calendarStyles = style({\n display: 'flex',\n flexDirection: 'column',\n gap: 24,\n width: 'fit'\n}, getAllowedOverrides());\n\nconst headerStyles = style({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n width: 'full'\n});\n\n/**\n * RangeCalendars display a grid of days in one or more months and allow users to select a contiguous range of dates.\n */\nexport const RangeCalendar = /*#__PURE__*/ (forwardRef as forwardRefType)(function RangeCalendar<T extends DateValue>(props: RangeCalendarProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, RangeCalendarContext);\n let {\n visibleMonths = 1,\n errorMessage,\n UNSAFE_style,\n UNSAFE_className,\n styles,\n ...otherProps\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n\n return (\n <AriaRangeCalendar\n {...otherProps}\n ref={ref}\n visibleDuration={{months: visibleMonths}}\n style={UNSAFE_style}\n className={(UNSAFE_className || '') + calendarStyles(null, styles)}>\n {({isInvalid, isDisabled}) => {\n return (\n <>\n <Provider\n values={[\n [HeaderContext, null],\n [HeadingContext, null]\n ]}>\n <Header styles={headerStyles}>\n <CalendarButton slot=\"previous\"><ChevronLeftIcon /></CalendarButton>\n <CalendarHeading />\n <CalendarButton slot=\"next\"><ChevronRightIcon /></CalendarButton>\n </Header>\n </Provider>\n <div\n className={style({\n display: 'flex',\n flexDirection: 'row',\n gap: 24,\n width: 'full',\n alignItems: 'start'\n })}>\n {Array.from({length: visibleMonths}).map((_, i) => (\n <CalendarGrid months={i} key={i} />\n ))}\n </div>\n {isInvalid && (\n <Text slot=\"errorMessage\" className={helpTextStyles({isInvalid, isDisabled, size: 'M'})}>\n {errorMessage || stringFormatter.format('calendar.invalidSelection', {selectedCount: 2})}\n </Text>\n )}\n </>\n );\n }}\n </AriaRangeCalendar>\n );\n});\n"],"names":[],"version":3,"file":"RangeCalendar.cjs.map"}