{"version":3,"file":"CalendarHeader.mjs","names":["classes"],"sources":["../../../src/components/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import {\n  AccordionChevron,\n  Box,\n  BoxProps,\n  createVarsResolver,\n  ElementProps,\n  factory,\n  Factory,\n  getFontSize,\n  getSize,\n  MantineSize,\n  StylesApiProps,\n  UnstyledButton,\n  useProps,\n  useStyles,\n} from '@mantine/core';\nimport classes from './CalendarHeader.module.css';\n\nexport type CalendarHeaderStylesNames =\n  | 'calendarHeader'\n  | 'calendarHeaderControl'\n  | 'calendarHeaderLevel'\n  | 'calendarHeaderControlIcon';\nexport type CalendarHeaderCssVariables = {\n  calendarHeader: '--dch-control-size' | '--dch-fz';\n};\n\nexport interface CalendarHeaderSettings {\n  __preventFocus?: boolean;\n\n  /** Determines whether propagation for `Escape` key should be stopped */\n  __stopPropagation?: boolean;\n\n  /** Change next icon */\n  nextIcon?: React.ReactNode;\n\n  /** Change previous icon */\n  previousIcon?: React.ReactNode;\n\n  /** Next button `aria-label` */\n  nextLabel?: string;\n\n  /** Previous button `aria-label` */\n  previousLabel?: string;\n\n  /** Called when the next button is clicked */\n  onNext?: () => void;\n\n  /** Called when the previous button is clicked */\n  onPrevious?: () => void;\n\n  /** Called when the level button is clicked */\n  onLevelClick?: () => void;\n\n  /** Disables next control */\n  nextDisabled?: boolean;\n\n  /** Disables previous control */\n  previousDisabled?: boolean;\n\n  /** Determines whether next level button should be enabled @default true */\n  hasNextLevel?: boolean;\n\n  /** Determines whether next control should be rendered @default true */\n  withNext?: boolean;\n\n  /** Determines whether previous control should be rendered @default true */\n  withPrevious?: boolean;\n\n  /** Component size */\n  size?: MantineSize;\n\n  /** Controls order @default ['previous', 'level', 'next'] */\n  headerControlsOrder?: ('previous' | 'next' | 'level')[];\n\n  /** Determines whether the header should take the full width of its container @default false */\n  fullWidth?: boolean;\n}\n\nexport interface CalendarHeaderProps\n  extends\n    BoxProps,\n    CalendarHeaderSettings,\n    StylesApiProps<CalendarHeaderFactory>,\n    ElementProps<'div'> {\n  __staticSelector?: string;\n\n  /** Label displayed between next and previous buttons */\n  label: React.ReactNode;\n\n  /** Level control `aria-label` */\n  levelControlAriaLabel?: string;\n}\n\nexport type CalendarHeaderFactory = Factory<{\n  props: CalendarHeaderProps;\n  ref: HTMLDivElement;\n  stylesNames: CalendarHeaderStylesNames;\n  vars: CalendarHeaderCssVariables;\n}>;\n\nconst defaultProps = {\n  hasNextLevel: true,\n  withNext: true,\n  withPrevious: true,\n  headerControlsOrder: ['previous', 'level', 'next'],\n} satisfies Partial<CalendarHeaderProps>;\n\nconst varsResolver = createVarsResolver<CalendarHeaderFactory>((_, { size }) => ({\n  calendarHeader: {\n    '--dch-control-size': getSize(size, 'dch-control-size'),\n    '--dch-fz': getFontSize(size),\n  },\n}));\n\nexport const CalendarHeader = factory<CalendarHeaderFactory>((_props) => {\n  const props = useProps('CalendarHeader', defaultProps, _props);\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    unstyled,\n    vars,\n    nextIcon,\n    previousIcon,\n    nextLabel,\n    previousLabel,\n    onNext,\n    onPrevious,\n    onLevelClick,\n    label,\n    nextDisabled,\n    previousDisabled,\n    hasNextLevel,\n    levelControlAriaLabel,\n    withNext,\n    withPrevious,\n    headerControlsOrder,\n    fullWidth,\n    __staticSelector,\n    __preventFocus,\n    __stopPropagation,\n    attributes,\n    ...others\n  } = props;\n\n  const getStyles = useStyles<CalendarHeaderFactory>({\n    name: __staticSelector || 'CalendarHeader',\n    classes,\n    props,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    attributes,\n    vars,\n    varsResolver,\n    rootSelector: 'calendarHeader',\n  });\n\n  const preventFocus = __preventFocus\n    ? (event: React.MouseEvent<HTMLElement>) => event.preventDefault()\n    : undefined;\n\n  const previousControl = withPrevious && (\n    <UnstyledButton\n      {...getStyles('calendarHeaderControl')}\n      key=\"previous\"\n      data-direction=\"previous\"\n      aria-label={previousLabel}\n      onClick={onPrevious}\n      unstyled={unstyled}\n      onMouseDown={preventFocus}\n      disabled={previousDisabled}\n      data-disabled={previousDisabled || undefined}\n      tabIndex={__preventFocus || previousDisabled ? -1 : 0}\n      data-mantine-stop-propagation={__stopPropagation || undefined}\n    >\n      {previousIcon || (\n        <AccordionChevron\n          {...getStyles('calendarHeaderControlIcon')}\n          data-direction=\"previous\"\n          size=\"45%\"\n        />\n      )}\n    </UnstyledButton>\n  );\n\n  const levelControl = (\n    <UnstyledButton\n      component={hasNextLevel ? 'button' : 'div'}\n      {...getStyles('calendarHeaderLevel')}\n      key=\"level\"\n      onClick={hasNextLevel ? onLevelClick : undefined}\n      unstyled={unstyled}\n      onMouseDown={hasNextLevel ? preventFocus : undefined}\n      disabled={!hasNextLevel}\n      data-static={!hasNextLevel || undefined}\n      aria-label={levelControlAriaLabel}\n      tabIndex={__preventFocus || !hasNextLevel ? -1 : 0}\n      data-mantine-stop-propagation={__stopPropagation || undefined}\n    >\n      {label}\n    </UnstyledButton>\n  );\n\n  const nextControl = withNext && (\n    <UnstyledButton\n      {...getStyles('calendarHeaderControl')}\n      key=\"next\"\n      data-direction=\"next\"\n      aria-label={nextLabel}\n      onClick={onNext}\n      unstyled={unstyled}\n      onMouseDown={preventFocus}\n      disabled={nextDisabled}\n      data-disabled={nextDisabled || undefined}\n      tabIndex={__preventFocus || nextDisabled ? -1 : 0}\n      data-mantine-stop-propagation={__stopPropagation || undefined}\n    >\n      {nextIcon || (\n        <AccordionChevron\n          {...getStyles('calendarHeaderControlIcon')}\n          data-direction=\"next\"\n          size=\"45%\"\n        />\n      )}\n    </UnstyledButton>\n  );\n\n  const controls = headerControlsOrder.map((control) => {\n    if (control === 'previous') {\n      return previousControl;\n    }\n    if (control === 'level') {\n      return levelControl;\n    }\n    if (control === 'next') {\n      return nextControl;\n    }\n    return null;\n  });\n\n  return (\n    <Box {...getStyles('calendarHeader')} data-full-width={fullWidth || undefined} {...others}>\n      {controls}\n    </Box>\n  );\n});\n\nCalendarHeader.classes = classes;\nCalendarHeader.varsResolver = varsResolver;\nCalendarHeader.displayName = '@mantine/dates/CalendarHeader';\n\nexport namespace CalendarHeader {\n  export type Props = CalendarHeaderProps;\n  export type StylesNames = CalendarHeaderStylesNames;\n  export type CssVariables = CalendarHeaderCssVariables;\n  export type Settings = CalendarHeaderSettings;\n  export type Factory = CalendarHeaderFactory;\n}\n"],"mappings":";;;;;;AAqGA,MAAM,eAAe;CACnB,cAAc;CACd,UAAU;CACV,cAAc;CACd,qBAAqB;EAAC;EAAY;EAAS;CAAM;AACnD;AAEA,MAAM,eAAe,oBAA2C,GAAG,EAAE,YAAY,EAC/E,gBAAgB;CACd,sBAAsB,QAAQ,MAAM,kBAAkB;CACtD,YAAY,YAAY,IAAI;AAC9B,EACF,EAAE;AAEF,MAAa,iBAAiB,SAAgC,WAAW;CACvE,MAAM,QAAQ,SAAS,kBAAkB,cAAc,MAAM;CAC7D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,cACA,WACA,eACA,QACA,YACA,cACA,OACA,cACA,kBACA,cACA,uBACA,UACA,cACA,qBACA,WACA,kBACA,gBACA,mBACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAAiC;EACjD,MAAM,oBAAoB;EAC1B,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;CAChB,CAAC;CAED,MAAM,eAAe,kBAChB,UAAyC,MAAM,eAAe,IAC/D,KAAA;CAEJ,MAAM,kBAAkB,gBACtB,8BAAC,gBAAD;EACE,GAAI,UAAU,uBAAuB;EACrC,KAAI;EACJ,kBAAe;EACf,cAAY;EACZ,SAAS;EACC;EACV,aAAa;EACb,UAAU;EACV,iBAAe,oBAAoB,KAAA;EACnC,UAAU,kBAAkB,mBAAmB,KAAK;EACpD,iCAA+B,qBAAqB,KAAA;CAStC,GAPb,gBACC,oBAAC,kBAAD;EACE,GAAI,UAAU,2BAA2B;EACzC,kBAAe;EACf,MAAK;CACN,CAAA,CAEW;CAGlB,MAAM,eACJ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