{"version":3,"file":"MonthLevelGroup.cjs","names":["MonthLevel","handleControlKeyDown","LevelsGroup"],"sources":["../../../src/components/MonthLevelGroup/MonthLevelGroup.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '@mantine/core';\nimport { DateStringValue } from '../../types';\nimport { handleControlKeyDown } from '../../utils';\nimport { LevelsGroup, LevelsGroupStylesNames } from '../LevelsGroup';\nimport { MonthLevel, MonthLevelSettings, MonthLevelStylesNames } from '../MonthLevel';\n\nexport type MonthLevelGroupStylesNames = MonthLevelStylesNames | LevelsGroupStylesNames;\n\nexport interface MonthLevelGroupProps\n  extends\n    BoxProps,\n    Omit<MonthLevelSettings, 'withPrevious' | 'withNext' | '__onDayKeyDown' | '__getDayRef'>,\n    Omit<StylesApiProps<MonthLevelGroupFactory>, 'classNames' | 'styles'>,\n    ElementProps<'div'> {\n  classNames?: Partial<Record<string, string>>;\n  styles?: Partial<Record<string, React.CSSProperties>>;\n  __staticSelector?: string;\n\n  /** Number of columns to display next to each other */\n  numberOfColumns?: number;\n\n  /** Month to display */\n  month: DateStringValue;\n\n  /** Function that returns level control `aria-label` based on month date */\n  levelControlAriaLabel?: ((month: DateStringValue) => string) | string;\n\n  /** Passed as `isStatic` prop to `Month` component */\n  static?: boolean;\n\n  /** Determines whether the calendar should take the full width of its container @default false */\n  fullWidth?: boolean;\n}\n\nexport type MonthLevelGroupFactory = Factory<{\n  props: MonthLevelGroupProps;\n  ref: HTMLDivElement;\n  stylesNames: MonthLevelGroupStylesNames;\n}>;\n\nconst defaultProps = {\n  numberOfColumns: 1,\n} satisfies Partial<MonthLevelGroupProps>;\n\nexport const MonthLevelGroup = factory<MonthLevelGroupFactory>((_props) => {\n  const props = useProps('MonthLevelGroup', defaultProps, _props);\n  const {\n    // Month settings\n    month,\n    locale,\n    firstDayOfWeek,\n    weekdayFormat,\n    weekendDays,\n    getDayProps,\n    excludeDate,\n    minDate,\n    maxDate,\n    renderDay,\n    hideOutsideDates,\n    hideWeekdays,\n    getDayAriaLabel,\n    __onDayClick,\n    __onDayMouseEnter,\n    withCellSpacing,\n    highlightToday,\n    withWeekNumbers,\n\n    // CalendarHeader settings\n    __preventFocus,\n    nextIcon,\n    previousIcon,\n    nextLabel,\n    previousLabel,\n    onNext,\n    onPrevious,\n    onLevelClick,\n    nextDisabled,\n    previousDisabled,\n    hasNextLevel,\n    headerControlsOrder,\n\n    // Other settings\n    classNames,\n    styles,\n    unstyled,\n    numberOfColumns,\n    levelControlAriaLabel,\n    monthLabelFormat,\n    __staticSelector,\n    __stopPropagation,\n    size,\n    static: isStatic,\n    fullWidth,\n    vars,\n    attributes,\n    ...others\n  } = props;\n\n  const daysRefs = useRef<HTMLButtonElement[][][]>([]);\n\n  const months = Array(numberOfColumns)\n    .fill(0)\n    .map((_, monthIndex) => {\n      const currentMonth = dayjs(month).add(monthIndex, 'months').format('YYYY-MM-DD');\n\n      return (\n        <MonthLevel\n          key={monthIndex}\n          month={currentMonth}\n          withNext={monthIndex === numberOfColumns - 1}\n          withPrevious={monthIndex === 0}\n          monthLabelFormat={monthLabelFormat}\n          __stopPropagation={__stopPropagation}\n          __onDayClick={__onDayClick}\n          __onDayMouseEnter={__onDayMouseEnter}\n          __onDayKeyDown={(event, payload) =>\n            handleControlKeyDown({\n              levelIndex: monthIndex,\n              rowIndex: payload.rowIndex,\n              cellIndex: payload.cellIndex,\n              event,\n              controlsRef: daysRefs,\n            })\n          }\n          __getDayRef={(rowIndex, cellIndex, node) => {\n            if (!Array.isArray(daysRefs.current[monthIndex])) {\n              daysRefs.current[monthIndex] = [];\n            }\n\n            if (!Array.isArray(daysRefs.current[monthIndex][rowIndex])) {\n              daysRefs.current[monthIndex][rowIndex] = [];\n            }\n\n            daysRefs.current[monthIndex][rowIndex][cellIndex] = node;\n          }}\n          levelControlAriaLabel={\n            typeof levelControlAriaLabel === 'function'\n              ? levelControlAriaLabel(currentMonth)\n              : levelControlAriaLabel\n          }\n          locale={locale}\n          firstDayOfWeek={firstDayOfWeek}\n          weekdayFormat={weekdayFormat}\n          weekendDays={weekendDays}\n          getDayProps={getDayProps}\n          excludeDate={excludeDate}\n          minDate={minDate}\n          maxDate={maxDate}\n          renderDay={renderDay}\n          hideOutsideDates={hideOutsideDates}\n          hideWeekdays={hideWeekdays}\n          getDayAriaLabel={getDayAriaLabel}\n          __preventFocus={__preventFocus}\n          nextIcon={nextIcon}\n          previousIcon={previousIcon}\n          nextLabel={nextLabel}\n          previousLabel={previousLabel}\n          onNext={onNext}\n          onPrevious={onPrevious}\n          onLevelClick={onLevelClick}\n          nextDisabled={nextDisabled}\n          previousDisabled={previousDisabled}\n          hasNextLevel={hasNextLevel}\n          classNames={classNames}\n          styles={styles}\n          unstyled={unstyled}\n          __staticSelector={__staticSelector || 'MonthLevelGroup'}\n          size={size}\n          static={isStatic}\n          withCellSpacing={withCellSpacing}\n          highlightToday={highlightToday}\n          withWeekNumbers={withWeekNumbers}\n          headerControlsOrder={headerControlsOrder}\n          fullWidth={fullWidth}\n          attributes={attributes}\n        />\n      );\n    });\n\n  return (\n    <LevelsGroup\n      classNames={classNames}\n      styles={styles}\n      __staticSelector={__staticSelector || 'MonthLevelGroup'}\n      size={size}\n      fullWidth={fullWidth}\n      attributes={attributes}\n      {...others}\n    >\n      {months}\n    </LevelsGroup>\n  );\n});\n\nMonthLevelGroup.classes = { ...LevelsGroup.classes, ...MonthLevel.classes };\nMonthLevelGroup.displayName = '@mantine/dates/MonthLevelGroup';\n"],"mappings":";;;;;;;;;;;AA0CA,MAAM,eAAe,EACnB,iBAAiB,EACnB;AAEA,MAAa,mBAAA,GAAA,cAAA,QAAA,EAAmD,WAAW;CAEzE,MAAM,EAEJ,OACA,QACA,gBACA,eACA,aACA,aACA,aACA,SACA,SACA,WACA,kBACA,cACA,iBACA,cACA,mBACA,iBACA,gBACA,iBAGA,gBACA,UACA,cACA,WACA,eACA,QACA,YACA,cACA,cACA,kBACA,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