@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
1 lines • 4.18 kB
Source Map (JSON)
{"version":3,"file":"WeekdaysRow.cjs","names":["useDatesContext","getWeekdayNames","Box","classes"],"sources":["../../../src/components/WeekdaysRow/WeekdaysRow.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getFontSize,\n getSpacing,\n MantineSize,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport type { DateLabelFormat, DayOfWeek } from '../../types';\nimport { useDatesContext } from '../DatesProvider';\nimport { getWeekdayNames } from './get-weekdays-names/get-weekdays-names';\nimport classes from './WeekdaysRow.module.css';\n\nexport type WeekdaysRowStylesNames = 'weekday' | 'weekdaysRow';\nexport type WeekdaysRowCssVariables = {\n weekdaysRow: '--wr-fz' | '--wr-spacing';\n};\n\nexport interface WeekdaysRowProps\n extends BoxProps, StylesApiProps<WeekdaysRowFactory>, ElementProps<'tr'> {\n __staticSelector?: string;\n\n /** Controls size */\n size?: MantineSize;\n\n /** dayjs locale */\n locale?: string;\n\n /** Number 0-6, 0 – Sunday, 6 – Saturday @default 1 – Monday */\n firstDayOfWeek?: DayOfWeek;\n\n /** dayjs format to get weekday name @default 'dd' */\n weekdayFormat?: DateLabelFormat;\n\n /** Sets cell type that is used for weekdays @default 'th' */\n cellComponent?: 'td' | 'th';\n\n /** If set, heading for week numbers is displayed */\n withWeekNumbers?: boolean;\n}\n\nexport type WeekdaysRowFactory = Factory<{\n props: WeekdaysRowProps;\n ref: HTMLTableRowElement;\n stylesNames: WeekdaysRowStylesNames;\n vars: WeekdaysRowCssVariables;\n}>;\n\nconst varsResolver = createVarsResolver<WeekdaysRowFactory>((_, { size }) => ({\n weekdaysRow: {\n '--wr-fz': getFontSize(size),\n '--wr-spacing': getSpacing(size),\n },\n}));\n\nexport const WeekdaysRow = factory<WeekdaysRowFactory>((_props) => {\n const props = useProps('WeekdaysRow', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n locale,\n firstDayOfWeek,\n weekdayFormat,\n cellComponent: CellComponent = 'th',\n __staticSelector,\n withWeekNumbers,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<WeekdaysRowFactory>({\n name: __staticSelector || 'WeekdaysRow',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n rootSelector: 'weekdaysRow',\n });\n\n const ctx = useDatesContext();\n\n const weekdays = getWeekdayNames({\n locale: ctx.getLocale(locale),\n format: weekdayFormat,\n firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),\n }).map((weekday, index) => (\n <CellComponent key={index} {...getStyles('weekday')}>\n {weekday}\n </CellComponent>\n ));\n\n return (\n <Box component=\"tr\" {...getStyles('weekdaysRow')} {...others}>\n {withWeekNumbers && <CellComponent {...getStyles('weekday')}>#</CellComponent>}\n {weekdays}\n </Box>\n );\n});\n\nWeekdaysRow.classes = classes;\nWeekdaysRow.varsResolver = varsResolver;\nWeekdaysRow.displayName = '@mantine/dates/WeekdaysRow';\n"],"mappings":";;;;;;;AAsDA,MAAM,gBAAA,GAAA,cAAA,mBAAA,EAAuD,GAAG,EAAE,YAAY,EAC5E,aAAa;CACX,YAAA,GAAA,cAAA,YAAA,CAAuB,IAAI;CAC3B,iBAAA,GAAA,cAAA,WAAA,CAA2B,IAAI;AACjC,EACF,EAAE;AAEF,MAAa,eAAA,GAAA,cAAA,QAAA,EAA2C,WAAW;CACjE,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB,eAAe,MAAM,MAAM;CAClD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,gBACA,eACA,eAAe,gBAAgB,MAC/B,kBACA,iBACA,YACA,GAAG,WACD;CAEJ,MAAM,aAAA,GAAA,cAAA,UAAA,CAA0C;EAC9C,MAAM,oBAAoB;EAC1B,SAAA,2BAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA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