UNPKG

@mantine/dates

Version:

Calendars, date and time pickers based on Mantine components

74 lines (73 loc) 2.69 kB
"use client"; import { useDatesContext } from "../DatesProvider/use-dates-context.mjs"; import { MonthsList } from "../MonthsList/MonthsList.mjs"; import { CalendarHeader } from "../CalendarHeader/CalendarHeader.mjs"; import dayjs from "dayjs"; import { jsx, jsxs } from "react/jsx-runtime"; import { Box, factory, useProps } from "@mantine/core"; //#region packages/@mantine/dates/src/components/YearLevel/YearLevel.tsx const defaultProps = { yearLabelFormat: "YYYY" }; const YearLevel = factory((_props) => { const { year, locale, minDate, maxDate, monthsListFormat, getMonthControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, withCellSpacing, __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, headerControlsOrder, yearLabelFormat, __staticSelector, __stopPropagation, size, classNames, styles, unstyled, fullWidth, attributes, ...others } = useProps("YearLevel", defaultProps, _props); const ctx = useDatesContext(); const stylesApiProps = { __staticSelector: __staticSelector || "YearLevel", classNames, styles, unstyled, size, attributes }; const _nextDisabled = typeof nextDisabled === "boolean" ? nextDisabled : maxDate ? !dayjs(year).endOf("year").isBefore(maxDate) : false; const _previousDisabled = typeof previousDisabled === "boolean" ? previousDisabled : minDate ? !dayjs(year).startOf("year").isAfter(minDate) : false; return /* @__PURE__ */ jsxs(Box, { "data-year-level": true, size, ...others, children: [/* @__PURE__ */ jsx(CalendarHeader, { label: typeof yearLabelFormat === "function" ? yearLabelFormat(year) : dayjs(year).locale(locale || ctx.locale).format(yearLabelFormat), __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled: _nextDisabled, previousDisabled: _previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, headerControlsOrder, fullWidth, ...stylesApiProps }), /* @__PURE__ */ jsx(MonthsList, { year, locale, minDate, maxDate, monthsListFormat, getMonthControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, __preventFocus, __stopPropagation, withCellSpacing, fullWidth, ...stylesApiProps })] }); }); YearLevel.classes = { ...CalendarHeader.classes, ...MonthsList.classes }; YearLevel.displayName = "@mantine/dates/YearLevel"; //#endregion export { YearLevel }; //# sourceMappingURL=YearLevel.mjs.map