UNPKG

@yamada-ui/calendar

Version:

Yamada UI calendar component

147 lines (145 loc) 3.94 kB
"use client" import { YearList } from "./chunk-RX7RC3OK.mjs"; import { MonthList } from "./chunk-4UGZ5WA3.mjs"; import { Month } from "./chunk-PRPD4DHS.mjs"; import { CalendarProvider, useCalendar } from "./chunk-UMK6LUR5.mjs"; // src/calendar.tsx import { omitThemeProps, ui, useComponentMultiStyle } from "@yamada-ui/core"; import { cx } from "@yamada-ui/utils"; import { forwardRef } from "react"; import { jsx, jsxs } from "react/jsx-runtime"; var Calendar = forwardRef( (props, ref) => { var _a, _b, _c, _d, _e, _f; const [styles, mergedProps] = useComponentMultiStyle("Calendar", props); const { className, defaultValue, value, controlProps, dayProps, headerProps, labelProps, monthGridProps, monthProps, nextProps, prevProps, tableProps, weekdayProps, yearGridProps, yearProps, onChange, ...computedProps } = omitThemeProps(mergedProps); const { type, getContainerProps, ...rest } = useCalendar({ defaultValue, value, onChange, ...computedProps }); const css = { alignItems: "flex-start", display: "flex", flexWrap: "wrap", ...styles.container }; const w = (_a = computedProps.w) != null ? _a : computedProps.width; const minW = (_b = computedProps.minW) != null ? _b : computedProps.minWidth; const maxW = (_c = computedProps.maxW) != null ? _c : computedProps.maxWidth; const h = (_d = computedProps.h) != null ? _d : computedProps.height; const minH = (_e = computedProps.minH) != null ? _e : computedProps.minHeight; const maxH = (_f = computedProps.maxH) != null ? _f : computedProps.maxHeight; return /* @__PURE__ */ jsx( CalendarProvider, { value: { type, styles, ...rest }, children: /* @__PURE__ */ jsxs( ui.div, { className: cx("ui-calendar", className), __css: css, ...getContainerProps({}, ref), children: [ type === "year" ? /* @__PURE__ */ jsx( YearList, { ...{ h, maxH, maxW, minH, minW, w, controlProps, headerProps, labelProps, nextProps, prevProps, yearGridProps, yearProps } } ) : null, type === "month" ? /* @__PURE__ */ jsx( MonthList, { ...{ h, maxH, maxW, minH, minW, w, controlProps, headerProps, labelProps, monthGridProps, monthProps, nextProps, prevProps } } ) : null, type === "date" ? /* @__PURE__ */ jsx( Month, { ...{ h, maxH, maxW, minH, minW, w, controlProps, dayProps, headerProps, labelProps, nextProps, prevProps, tableProps, weekdayProps } } ) : null ] } ) } ); } ); Calendar.displayName = "Calendar"; Calendar.__ui__ = "Calendar"; export { Calendar }; //# sourceMappingURL=chunk-FICMIEAE.mjs.map