@react-spectrum/s2
Version:
Spectrum 2 UI components in React
1 lines • 23.1 kB
Source Map (JSON)
{"mappings":"ACwEuB;EAAA;;;;EAAA;;;;EAeD;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAQF;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EASK;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAeN;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA+BK;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA+IE;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAWE;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAgEH;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA+BR;;;;EAAA;;;;EAAA;;;;EAkEa;;;;EACA;;;;EAAA;;;;EAetB;;;;EAAA;;;;EAAA;;;;EAqGS;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAveG;EASK;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA8CD;;;;EAAA;;;;;AAvDJ;EASK;;;;EAAA;;;;EA8CD;;;;;AAvDJ;EASK;;;;EAAA;;;;EA8CD;;;;;AAvDJ;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAuDI;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IA0JI;;;;IAAA","sources":["2295035483c3fe80","packages/@react-spectrum/s2/src/Calendar.tsx"],"sourcesContent":["@import \"a4515f5bffb5f062\";\n@import \"92a594e88a8aef1b\";\n@import \"690c8ff771746c3e\";\n@import \"61eae6535d6fcdf4\";\n@import \"45a026ed74f55e85\";\n@import \"948f79e4cbbbc206\";\n@import \"6fbf78b81e66a464\";\n@import \"98b3aa52e9389b9d\";\n@import \"b5160d992ac49c4a\";\n@import \"84221aa63b6aa322\";\n@import \"898fc73cd9eb6ae4\";\n@import \"b3de9a7ca57d6dcd\";\n@import \"630d2c7b496b99dc\";\n@import \"4ba51db32e5676ac\";\n@import \"956185cd03a3f917\";\n@import \"b1221915ab95cea2\";\n","/*\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 {ActionButton, Header, HeaderContext, Heading, HeadingContext, pressScale} from './';\nimport {\n Calendar as AriaCalendar,\n CalendarCell as AriaCalendarCell,\n CalendarContext as AriaCalendarContext,\n CalendarGrid as AriaCalendarGrid,\n CalendarHeaderCell as AriaCalendarHeaderCell,\n CalendarProps as AriaCalendarProps,\n ButtonProps,\n CalendarCellProps,\n CalendarCellRenderProps,\n CalendarGridBody,\n CalendarGridHeader,\n CalendarHeaderCellProps,\n CalendarState,\n CalendarStateContext,\n ContextValue,\n DateValue,\n Provider,\n RangeCalendarContext,\n RangeCalendarState,\n RangeCalendarStateContext,\n Text,\n useSlottedContext\n} from 'react-aria-components';\nimport {AriaCalendarGridProps} from '@react-aria/calendar';\nimport {baseColor, focusRing, lightDark, style} from '../style' with {type: 'macro'};\nimport {\n CalendarDate,\n getDayOfWeek,\n startOfMonth\n} from '@internationalized/date';\nimport ChevronLeftIcon from '../s2wf-icons/S2_Icon_ChevronLeft_20_N.svg';\nimport ChevronRightIcon from '../s2wf-icons/S2_Icon_ChevronRight_20_N.svg';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {helpTextStyles} from './Field';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport React, {createContext, CSSProperties, ForwardedRef, forwardRef, Fragment, PropsWithChildren, ReactElement, ReactNode, useContext, useMemo, useRef} from 'react';\nimport {useDateFormatter, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\n\nexport interface CalendarProps<T extends DateValue>\n extends Omit<AriaCalendarProps<T>, 'visibleDuration' | 'style' | 'className' | 'styles' | 'children' | 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 CalendarContext = createContext<ContextValue<Partial<CalendarProps<any>>, HTMLDivElement>>(null);\n\nconst calendarStyles = style({\n display: 'flex',\n flexDirection: 'column',\n gap: 24,\n width: 'fit',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nconst headerStyles = style({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n width: 'full'\n});\n\nconst headingStyles = style({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n margin: 0,\n width: 'full'\n});\n\nconst titleStyles = style({\n font: 'title-lg',\n textAlign: 'center',\n flexGrow: 1,\n flexShrink: 0,\n flexBasis: '0%',\n minWidth: 0\n});\n\nconst headerCellStyles = style({\n font: 'title-sm',\n cursor: 'default',\n textAlign: 'center',\n paddingStart: {\n default: 4,\n ':first-child': 0\n },\n paddingEnd: {\n default: 4,\n ':last-child': 0\n },\n paddingBottom: 12\n});\n\nconst cellStyles = style({\n outlineStyle: 'none',\n '--cell-gap': {\n type: 'paddingStart',\n value: 4\n },\n paddingStart: {\n default: 4,\n isFirstChild: 0\n },\n paddingEnd: {\n default: 4,\n isLastChild: 0\n },\n paddingTop: {\n default: 2,\n isFirstWeek: 0\n },\n paddingBottom: 2,\n position: 'relative',\n width: 32,\n height: 32,\n display: {\n default: 'flex',\n isOutsideMonth: 'none'\n },\n alignItems: 'center',\n justifyContent: 'center',\n disableTapHighlight: true\n});\n\nconst cellInnerStyles = style<CalendarCellRenderProps & {selectionMode: 'single' | 'range'}>({\n ...focusRing(),\n transition: {\n default: 'default',\n forcedColors: 'none'\n },\n outlineOffset: {\n default: -2,\n isToday: 2,\n isSelected: {\n selectionMode: {\n single: 2,\n range: -2\n }\n },\n isSelectionStart: 2,\n isSelectionEnd: 2\n },\n position: 'relative',\n font: 'body-sm',\n cursor: 'default',\n width: 'full',\n height: 32,\n borderRadius: 'full',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n forcedColorAdjust: 'none',\n backgroundColor: {\n default: 'transparent',\n isHovered: {\n default: 'gray-100',\n isUnavailable: 'transparent'\n },\n isPressed: 'gray-100',\n isDisabled: 'transparent',\n isToday: {\n default: baseColor('gray-300'),\n isDisabled: 'disabled'\n },\n isSelected: {\n selectionMode: {\n single: {\n default: lightDark('accent-900', 'accent-700'),\n isHovered: lightDark('accent-1000', 'accent-600'),\n isPressed: lightDark('accent-1000', 'accent-600'),\n isFocusVisible: lightDark('accent-1000', 'accent-600'),\n isDisabled: 'transparent',\n isInvalid: {\n default: lightDark('negative-900', 'negative-700'),\n isHovered: lightDark('negative-1000', 'negative-600'),\n isPressed: lightDark('negative-1000', 'negative-600'),\n isFocusVisible: lightDark('negative-1000', 'negative-600')\n }\n },\n range: {\n isHovered: {\n default: 'blue-500',\n isInvalid: {\n default: 'negative-300',\n isUnavailable: 'transparent'\n }\n }\n }\n }\n },\n isSelectionStart: {\n default: lightDark('accent-900', 'accent-700'),\n isHovered: lightDark('accent-1000', 'accent-600'),\n isPressed: lightDark('accent-1000', 'accent-600'),\n isFocusVisible: lightDark('accent-1000', 'accent-600'),\n isDisabled: 'transparent',\n isInvalid: {\n default: lightDark('negative-900', 'negative-700'),\n isHovered: {\n default: lightDark('negative-1000', 'negative-600'),\n isUnavailable: lightDark('negative-900', 'negative-700')\n },\n isPressed: lightDark('negative-1000', 'negative-600'),\n isFocusVisible: {\n default: lightDark('negative-1000', 'negative-600'),\n isUnavailable: lightDark('negative-900', 'negative-700')\n }\n }\n },\n isSelectionEnd: {\n default: lightDark('accent-900', 'accent-700'),\n isHovered: lightDark('accent-1000', 'accent-600'),\n isPressed: lightDark('accent-1000', 'accent-600'),\n isFocusVisible: lightDark('accent-1000', 'accent-600'),\n isDisabled: 'transparent',\n isInvalid: {\n default: lightDark('negative-900', 'negative-700'),\n isHovered: {\n default: lightDark('negative-1000', 'negative-600'),\n isUnavailable: lightDark('negative-900', 'negative-700')\n },\n isPressed: lightDark('negative-1000', 'negative-600'),\n isFocusVisible: {\n default: lightDark('negative-1000', 'negative-600'),\n isUnavailable: lightDark('negative-900', 'negative-700')\n }\n }\n },\n forcedColors: {\n default: 'transparent',\n isToday: 'ButtonFace',\n isHovered: 'Highlight',\n isSelected: {\n selectionMode: {\n single: 'Highlight',\n range: {\n isHovered: 'Highlight'\n }\n }\n },\n isSelectionStart: 'Highlight',\n isSelectionEnd: 'Highlight',\n isUnavailable: 'transparent'\n }\n },\n color: {\n default: 'neutral',\n isSelected: {\n default: 'white',\n selectionMode: {\n range: 'neutral'\n }\n },\n isSelectionStart: 'white',\n isSelectionEnd: 'white',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'ButtonText',\n isToday: 'ButtonFace',\n isSelected: 'HighlightText',\n isSelectionStart: 'HighlightText',\n isSelectionEnd: 'HighlightText',\n isDisabled: 'GrayText'\n }\n }\n});\n\nconst unavailableStyles = style({\n position: 'absolute',\n top: 'calc(50% - 1px)',\n left: 'calc(25% - 1px)',\n right: 'calc(25% - 1px)',\n height: 2,\n transform: 'rotate(-16deg)',\n borderRadius: 'full',\n backgroundColor: '[currentColor]'\n});\n\nconst selectionSpanStyles = style<{isInvalid?: boolean}>({\n position: 'absolute',\n zIndex: -1,\n top: 0,\n insetStart: 'calc(-1 * var(--selection-span) * (var(--cell-width) + var(--cell-gap) + var(--cell-gap)))',\n insetEnd: 0,\n bottom: 0,\n borderWidth: 2,\n borderStyle: 'dashed',\n borderColor: {\n default: 'blue-800', // focus-indicator-color\n isInvalid: 'negative-900',\n forcedColors: {\n default: 'ButtonText'\n }\n },\n borderStartRadius: 'full',\n borderEndRadius: 'full',\n backgroundColor: {\n default: 'blue-subtle',\n isInvalid: 'negative-100',\n forcedColors: {\n default: 'Highlight'\n }\n },\n forcedColorAdjust: 'none'\n});\n\n/**\n * Calendars display a grid of days in one or more months and allow users to select a single date.\n */\nexport const Calendar = /*#__PURE__*/ (forwardRef as forwardRefType)(function Calendar<T extends DateValue>(props: CalendarProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, CalendarContext);\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 return (\n <AriaCalendar\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: 1})}\n </Text>\n )}\n </>\n );\n }}\n </AriaCalendar>\n );\n});\n\nexport const CalendarGrid = (props: Omit<AriaCalendarGridProps, 'children'> & PropsWithChildren & {months: number}): ReactElement => {\n let rangeCalendarProps = useSlottedContext(RangeCalendarContext);\n let calendarProps = useSlottedContext(AriaCalendarContext);\n let firstDayOfWeek = rangeCalendarProps?.firstDayOfWeek ?? calendarProps?.firstDayOfWeek;\n\n // use isolation to start a new stacking context so that we can use zIndex -1 for the selection span.\n return (\n <AriaCalendarGrid\n className={style({\n borderCollapse: 'collapse',\n borderSpacing: 0,\n isolation: 'isolate'\n })}\n offset={{months: props.months}}>\n <CalendarGridHeader className=\"\">\n {(day) => (\n <CalendarHeaderCell>\n {day}\n </CalendarHeaderCell>\n )}\n </CalendarGridHeader>\n <CalendarGridBody className=\"\">\n {(date) => (\n <CalendarCell date={date} firstDayOfWeek={firstDayOfWeek} />\n )}\n </CalendarGridBody>\n </AriaCalendarGrid>\n );\n};\n\n// Ordinarily the heading is a formatted date range, ie January 2025 - February 2025.\n// However, we want to show each month individually.\nexport const CalendarHeading = (): ReactElement => {\n let calendarStateContext = useContext(CalendarStateContext);\n let rangeCalendarStateContext = useContext(RangeCalendarStateContext);\n let {visibleRange, timeZone} = calendarStateContext ?? rangeCalendarStateContext ?? {};\n let currentMonth = visibleRange?.start ?? visibleRange?.end;\n let monthFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n era: currentMonth && currentMonth.calendar.identifier === 'gregory' && currentMonth.era === 'BC' ? 'short' : undefined,\n calendar: visibleRange?.start.calendar.identifier,\n timeZone\n });\n let months = useMemo(() => {\n if (!visibleRange) {\n return [];\n }\n let months: string[] = [];\n for (let i = visibleRange.start; i.compare(visibleRange.end) <= 0; i = i.add({months: 1})) {\n // TODO: account for the first week possibly overlapping, like with a custom 454 calendar.\n // there has to be a better way to do this...\n if (i.month === visibleRange.start.month) {\n i = i.add({weeks: 1});\n }\n months.push(monthFormatter.format(i.toDate(timeZone!)));\n }\n return months;\n }, [visibleRange, monthFormatter, timeZone]);\n\n return (\n <Heading styles={headingStyles}>\n {months.map((month, i) => {\n if (i === 0) {\n return (\n <Fragment key={month}>\n <div className={titleStyles}>{month}</div>\n </Fragment>\n );\n } else {\n return (\n <Fragment key={month}>\n {/* Spacers to account for Next/Previous buttons and gap, spelled out to show the math */}\n <div className={style({visibility: 'hidden', width: 32})} />\n <div className={style({visibility: 'hidden', width: 24})} />\n <div className={style({visibility: 'hidden', width: 32})} />\n <div className={titleStyles}>{month}</div>\n </Fragment>\n );\n }\n })}\n </Heading>\n );\n};\n\nexport const CalendarButton = (props: Omit<ButtonProps, 'children'> & {children: ReactNode}): ReactElement => {\n let {direction} = useLocale();\n return (\n <div\n className={\n style({\n scale: {\n direction: {\n rtl: -1\n }\n }\n })({direction})\n }>\n <ActionButton\n {...props}\n isQuiet>\n {props.children}\n </ActionButton>\n </div>\n );\n};\n\nconst CalendarHeaderCell = (props: Omit<CalendarHeaderCellProps, 'children'> & PropsWithChildren): ReactElement => {\n return (\n <AriaCalendarHeaderCell className={headerCellStyles}>\n {props.children}\n </AriaCalendarHeaderCell>\n );\n};\n\nconst CalendarCell = (props: Omit<CalendarCellProps, 'children'> & {firstDayOfWeek: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | undefined}): ReactElement => {\n let {locale} = useLocale();\n let firstDayOfWeek = props.firstDayOfWeek;\n // Calculate the day and week index based on the date.\n let {dayIndex, weekIndex} = useWeekAndDayIndices(props.date, locale, firstDayOfWeek);\n\n let calendarStateContext = useContext(CalendarStateContext);\n let rangeCalendarStateContext = useContext(RangeCalendarStateContext);\n let state = (calendarStateContext ?? rangeCalendarStateContext)!;\n\n let isFirstWeek = weekIndex === 0;\n let isFirstChild = dayIndex === 0;\n let isLastChild = dayIndex === 6;\n\n return (\n <AriaCalendarCell\n date={props.date}\n className={(renderProps) => cellStyles({...renderProps, isFirstChild, isLastChild, isFirstWeek})}>\n {(renderProps) => <CalendarCellInner {...props} weekIndex={weekIndex} dayIndex={dayIndex} state={state} isRangeSelection={!!rangeCalendarStateContext} renderProps={renderProps} />}\n </AriaCalendarCell>\n );\n};\n\nconst CalendarCellInner = (props: Omit<CalendarCellProps, 'children'> & {isRangeSelection: boolean, state: CalendarState | RangeCalendarState, weekIndex: number, dayIndex: number, renderProps?: CalendarCellRenderProps, date: DateValue}): ReactElement => {\n let {weekIndex, dayIndex, date, renderProps, state, isRangeSelection} = props;\n let {getDatesInWeek} = state;\n let ref = useRef<HTMLDivElement>(null);\n let {isUnavailable, formattedDate, isSelected, isSelectionStart, isSelectionEnd, isInvalid} = renderProps!;\n // only apply the selection start/end styles if the start/end date is actually selectable (aka not unavailable)\n // or if the range is invalid and thus we still want to show the styles even if the start/end date is an unavailable one\n isSelectionStart = isSelectionStart && (!isUnavailable || isInvalid);\n isSelectionEnd = isSelectionEnd && (!isUnavailable || isInvalid);\n\n let startDate = startOfMonth(date);\n let datesInWeek = getDatesInWeek(weekIndex, startDate);\n\n let isDateInRange = (checkDate: CalendarDate) => {\n if (!('highlightedRange' in state) || !state.highlightedRange) {\n return state.isSelected(checkDate);\n }\n // if invalid, check if date is within the full range boundaries\n if (isInvalid) {\n return checkDate.compare(state.highlightedRange.start) >= 0 &&\n checkDate.compare(state.highlightedRange.end) <= 0;\n }\n\n return state.isSelected(checkDate);\n };\n\n // Starting from the current day, find the first day before it in the current week that is not selected.\n // Then, the span of selected days is the current day minus the first unselected day.\n let firstUnselectedInRangeInWeek = datesInWeek.slice(0, dayIndex + 1).reverse().findIndex((date, i) => {\n return date && i > 0 && (!isDateInRange(date) || date.month !== props.date.month);\n });\n\n let selectionSpan = -1;\n if (firstUnselectedInRangeInWeek > -1 && isSelected) {\n selectionSpan = firstUnselectedInRangeInWeek - 1;\n } else if (isSelected) {\n selectionSpan = dayIndex;\n }\n let prevDay = date.subtract({days: 1});\n let nextDay = date.add({days: 1});\n\n // when invalid, show background for all selected dates (including unavailable) to make continuous range appearance\n // when valid, only show background for available selected dates\n let isBackgroundStyleApplied = (\n isSelected\n && isRangeSelection\n && (isInvalid || !isUnavailable)\n && (isDateInRange(prevDay)\n || (nextDay.month === date.month && isDateInRange(nextDay)))\n );\n\n return (\n <div\n className={style({\n position: 'relative',\n width: 32,\n '--cell-width': {\n type: 'width',\n value: '[self(width)]'\n }\n })}>\n <div\n ref={ref}\n style={pressScale(ref, {})(renderProps!)}\n className={cellInnerStyles({...renderProps!, isSelectionStart, isSelectionEnd, selectionMode: isRangeSelection ? 'range' : 'single'})}>\n <div>\n {formattedDate}\n </div>\n {isUnavailable && <div className={unavailableStyles} role=\"presentation\" />}\n </div>\n {isBackgroundStyleApplied && <div style={{'--selection-span': selectionSpan} as CSSProperties} className={selectionSpanStyles({isInvalid})} role=\"presentation\" />}\n </div>\n );\n};\n\ntype DayOfWeek = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';\n\n/**\n * Calculate the week index (0-based) and day index (0-based) for a given date within a month in a calendar.\n * @param date - The date to calculate indices for.\n * @param locale - The locale string (e.g., 'en-US', 'fr-FR', 'hi-IN-u-ca-indian').\n * @param firstDayOfWeek - Optional override for the first day of the week ('sun', 'mon', 'tue', etc.).\n * @returns Object with weekIndex and dayIndex.\n */\nfunction useWeekAndDayIndices(\n date: CalendarDate,\n locale: string,\n firstDayOfWeek?: DayOfWeek\n) {\n let {dayIndex, weekIndex} = useMemo(() => {\n // Get the day index within the week (0-6)\n const dayIndex = getDayOfWeek(date, locale, firstDayOfWeek);\n\n const monthStart = startOfMonth(date);\n\n // Calculate the week index by finding which week this date falls into\n // within the month's calendar grid\n const monthStartDayOfWeek = getDayOfWeek(monthStart, locale, firstDayOfWeek);\n const dayOfMonth = date.day;\n\n const weekIndex = Math.floor((dayOfMonth + monthStartDayOfWeek - 1) / 7);\n\n return {\n weekIndex,\n dayIndex\n };\n }, [date, locale, firstDayOfWeek]);\n\n return {dayIndex, weekIndex};\n}\n"],"names":[],"version":3,"file":"Calendar.css.map"}