@rnwonder/react-date-picker
Version:
A lightweight, customizable, and accessible date picker component for React applications.
60 lines (59 loc) • 1.95 kB
JavaScript
import { jsx as a, Fragment as r } from "react/jsx-runtime";
import { a as i, b as c } from "./index-C-0w3u6j.js";
import h, { memo as y, useMemo as S } from "react";
const T = y(
h.forwardRef((t, l) => {
const e = S(() => Array.from({ length: 12 }, (n, o) => new Date(0, o + 1, 0).toLocaleDateString(t.locale || "en", {
month: t != null && t.monthSelectorFormat ? t.monthSelectorFormat : t.monthSelectorType === "compact-dropdown" ? "short" : "long"
})), [t.locale, t.monthSelectorFormat, t.monthSelectorType]), m = () => {
var n, o;
(n = t.setSelectorTwoProps) == null || n.call(t, {
...t,
optionsArray: e,
option: t.month,
setOption: t.setMonth,
attributes: {
"data-month": "true"
},
className: "month-selector-option",
zIndex: t.zIndex,
primaryTextColor: t.primaryTextColor,
primaryColor: t.primaryColor,
twoMonthsDisplay: t.twoMonthsDisplay
}), (o = t.setShowSelectorTwo) == null || o.call(t, !0);
};
return /* @__PURE__ */ a(r, { children: t.monthSelectorType === "compact-dropdown" ? /* @__PURE__ */ a(
i,
{
...t,
optionsArray: e,
option: t.month,
setOption: t.setMonth,
ref: l,
gridTemplateColumnsNo: t.monthSelectorFormat === "long" ? "3" : "6",
attributes: {
"data-month": "true"
},
className: "month-selector-option",
zIndex: t.zIndex,
primaryColor: t.primaryColor,
primaryTextColor: t.primaryTextColor,
twoMonthsDisplay: t.twoMonthsDisplay
}
) : /* @__PURE__ */ a(
c,
{
option: t.month,
optionsArray: e,
type: "full-size",
isOpen: t.showSelectorTwo || !1,
twoMonthsDisplay: t.twoMonthsDisplay,
onClick: m,
noButtonAnimation: t.noButtonAnimation
}
) });
})
);
export {
T as M
};