UNPKG

@yamada-ui/calendar

Version:

Yamada UI calendar component

172 lines (170 loc) 4.36 kB
"use client" import { useCalendarHeader } from "./chunk-XFCFPRPJ.mjs"; import { useCalendarContext } from "./chunk-UMK6LUR5.mjs"; // src/calendar-header.tsx import { Button, IconButton } from "@yamada-ui/button"; import { ui } from "@yamada-ui/core"; import { ChevronIcon } from "@yamada-ui/icon"; import { cx, isValidElement } from "@yamada-ui/utils"; import { jsx, jsxs } from "react/jsx-runtime"; var CalendarHeader = ({ className, index, label, controlProps, labelProps, nextProps, prevProps, ...rest }) => { const { type, styles, withControls, withHeader, withLabel } = useCalendarContext(); const { getContainerProps, getControlProps, getLabelProps } = useCalendarHeader({ index }); const css = { alignItems: "center", display: "flex", w: "100%", ...styles.header }; const { icon: iconOrProps, ...computedLabelProps } = labelProps != null ? labelProps : {}; return withHeader ? /* @__PURE__ */ jsxs( ui.div, { className: cx("ui-calendar__header", className), __css: css, ...getContainerProps(rest), children: [ withControls ? /* @__PURE__ */ jsx( CalendarControlPrev, { ...getControlProps({ operation: "prev", ...controlProps, ...prevProps }) } ) : null, withLabel ? /* @__PURE__ */ jsxs(CalendarLabel, { ...getLabelProps({ ...computedLabelProps }), children: [ label, type !== "year" ? isValidElement(iconOrProps) ? iconOrProps : /* @__PURE__ */ jsx(CalendarLabelIcon, { ...iconOrProps }) : null ] }) : null, withControls ? /* @__PURE__ */ jsx( CalendarControlNext, { ...getControlProps({ operation: "next", ...controlProps, ...nextProps }) } ) : null ] } ) : null; }; CalendarHeader.displayName = "CalendarHeader"; CalendarHeader.__ui__ = "CalendarHeader"; var CalendarLabel = ({ className, ...rest }) => { const { styles } = useCalendarContext(); const css = { flex: 1, fontSize: void 0, fontWeight: "normal", gap: 1, h: "auto", ...styles.label }; return /* @__PURE__ */ jsx( Button, { className: cx("ui-calendar__header__label", className), variant: "ghost", __css: css, ...rest } ); }; CalendarLabel.displayName = "CalendarLabel"; CalendarLabel.__ui__ = "CalendarLabel"; var CalendarLabelIcon = ({ className, ...rest }) => { const { styles } = useCalendarContext(); const css = { ...styles.labelIcon }; return /* @__PURE__ */ jsx( ChevronIcon, { className: cx("ui-calendar__header__label__icon", className), __css: css, ...rest } ); }; CalendarLabelIcon.displayName = "CalendarLabelIcon"; CalendarLabelIcon.__ui__ = "CalendarLabelIcon"; var CalendarControlPrev = ({ className, ...rest }) => { return /* @__PURE__ */ jsx( CalendarControl, { className: cx("ui-calendar__header__control--prev", className), icon: /* @__PURE__ */ jsx(ChevronIcon, { __css: { transform: "rotate(90deg)" } }), operation: "prev", ...rest } ); }; CalendarControlPrev.displayName = "CalendarControlPrev"; CalendarControlPrev.__ui__ = "CalendarControlPrev"; var CalendarControlNext = ({ className, ...rest }) => { return /* @__PURE__ */ jsx( CalendarControl, { className: cx("ui-calendar__header__control--next", className), icon: /* @__PURE__ */ jsx(ChevronIcon, { __css: { transform: "rotate(-90deg)" } }), operation: "next", ...rest } ); }; CalendarControlNext.displayName = "CalendarControlNext"; CalendarControlNext.__ui__ = "CalendarControlNext"; var CalendarControl = ({ className, operation, ...rest }) => { const { styles } = useCalendarContext(); const css = { h: "auto", minW: "auto", ...styles.control, ...styles[operation] }; return /* @__PURE__ */ jsx( IconButton, { className: cx("ui-calendar__header__control", className), variant: "ghost", __css: css, ...rest } ); }; CalendarControl.displayName = "CalendarControl"; CalendarControl.__ui__ = "CalendarControl"; export { CalendarHeader }; //# sourceMappingURL=chunk-D7INJNSZ.mjs.map