@yamada-ui/calendar
Version:
Yamada UI calendar component
101 lines (99 loc) • 3.55 kB
JavaScript
"use client"
import {
useYearList
} from "./chunk-4JE7HHCS.mjs";
import {
CalendarHeader
} from "./chunk-D7INJNSZ.mjs";
import {
useCalendarContext
} from "./chunk-UMK6LUR5.mjs";
import {
getFormattedLabel
} from "./chunk-BPJGE3HG.mjs";
// src/year-list.tsx
import { Button } from "@yamada-ui/button";
import { ui } from "@yamada-ui/core";
import { cx, filterUndefined } from "@yamada-ui/utils";
import { jsx, jsxs } from "react/jsx-runtime";
var YearList = ({
className,
controlProps,
headerProps,
labelProps,
nextProps,
prevProps,
yearGridProps,
yearProps,
...rest
}) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
const { locale, styles, yearFormat } = useCalendarContext();
const { label, rangeYears, getButtonProps, getGridProps } = useYearList();
const { component: customYear, ...computedYearProps } = yearProps != null ? yearProps : {};
const w = (_a = rest.w) != null ? _a : rest.width;
const minW = (_b = rest.minW) != null ? _b : rest.minWidth;
const maxW = (_c = rest.maxW) != null ? _c : rest.maxWidth;
const h = (_d = rest.h) != null ? _d : rest.height;
const minH = (_e = rest.minH) != null ? _e : rest.minHeight;
const maxH = (_f = rest.maxH) != null ? _f : rest.maxHeight;
return /* @__PURE__ */ jsxs(ui.div, { __css: { ...styles.content }, ...filterUndefined(rest), children: [
/* @__PURE__ */ jsx(
CalendarHeader,
{
...{
...headerProps,
label,
controlProps,
labelProps,
nextProps,
prevProps
}
}
),
/* @__PURE__ */ jsx(
ui.div,
{
className: cx("ui-calendar__year-list", className),
__css: {
display: "grid",
h: (_i = (_g = styles.content) == null ? void 0 : _g.h) != null ? _i : (_h = styles.content) == null ? void 0 : _h.height,
maxH: (_l = (_j = styles.content) == null ? void 0 : _j.maxH) != null ? _l : (_k = styles.content) == null ? void 0 : _k.maxHeight,
maxW: (_o = (_m = styles.content) == null ? void 0 : _m.maxW) != null ? _o : (_n = styles.content) == null ? void 0 : _n.maxWidth,
minH: (_r = (_p = styles.content) == null ? void 0 : _p.minH) != null ? _r : (_q = styles.content) == null ? void 0 : _q.minHeight,
minW: (_u = (_s = styles.content) == null ? void 0 : _s.minW) != null ? _u : (_t = styles.content) == null ? void 0 : _t.minWidth,
w: (_x = (_v = styles.content) == null ? void 0 : _v.w) != null ? _x : (_w = styles.content) == null ? void 0 : _w.width,
...styles.year
},
...getGridProps({
...filterUndefined({ h, maxH, maxW, minH, minW, w }),
...yearGridProps
}),
children: rangeYears.map((year, index) => /* @__PURE__ */ jsx(
Button,
{
className: "ui-calendar__year-list__button",
variant: "ghost",
__css: {
fontSize: void 0,
fontWeight: "normal",
h: "auto",
minW: "auto",
p: 0,
...styles.button
},
...getButtonProps({ ...computedYearProps, index, value: year }),
children: customYear ? customYear({ index, year }) : getFormattedLabel(year, locale, yearFormat)
},
index
))
}
)
] });
};
YearList.displayName = "YearList";
YearList.__ui__ = "YearList";
export {
YearList
};
//# sourceMappingURL=chunk-RX7RC3OK.mjs.map