react-box-tools
Version:
Box tools react components, utils and hooks
117 lines (116 loc) • 2.76 kB
JavaScript
import { jsx as o, jsxs as f } from "react/jsx-runtime";
import { D as A } from "./dropdown-B4geQ7fC.js";
import { c as B } from "./clsx-DG-5vF7T.js";
import { useRef as E, useState as G } from "react";
import { b as n, d as s } from "./useCalendar-BxuMJgtF.js";
import { C as J } from "./calendar-B5hEn7T_.js";
const Z = (u) => {
const {
offset: D = 1,
format: t = "dd/mm/yyyy",
culture: a,
range: r = !1,
monthsToShow: h = 1,
monthDropDown: y = {},
yearDropDown: x = {},
refilldays: g = !1,
arrow: R = !1,
style: w,
className: C,
contentClass: S,
direction: N = "down-left",
width: $ = "auto",
mode: I = "toggle",
onFirstOpen: O,
onOpen: T,
onClose: v,
intersect: L = !0,
todayText: j,
minDate: k,
maxDate: F,
value: H,
onSelected: b = () => {
},
onSelectedRange: M = () => {
},
icons: c = {}
} = u, d = E(null), [P, l] = G(""), m = () => {
var e;
(e = d.current) == null || e.setOpen(!1);
}, q = (e) => {
m(), p(e), b(e);
}, z = (e) => {
m(), i(e), M(e);
}, p = (e) => {
l(s(e, t, a));
}, i = (e) => {
l(
`${s(e.from, t, a)} - ${s(e.to, t, a)}`
);
};
return /* @__PURE__ */ o(
n,
{
format: t,
monthsToShow: h,
culture: a,
refilldays: g,
range: r,
todayText: j,
onSelected: q,
onSelectedRange: z,
onLoad: (e) => {
e.date && p(e.date), e.dateRange && i(e.dateRange);
},
minDate: k,
maxDate: F,
value: H,
children: /* @__PURE__ */ f(
A,
{
ref: d,
direction: N,
arrow: R,
mode: I,
width: $,
className: B(`datepicker ${C}`),
offset: D,
onFirstOpen: O,
onOpen: T,
onClose: v,
intersect: L,
style: w,
contentClass: S,
target: /* @__PURE__ */ f("div", { className: "dp-input", children: [
/* @__PURE__ */ o(
"input",
{
className: "dp-date",
type: "text",
placeholder: r ? `${t} - ${t}` : t,
readOnly: !0,
value: P
}
),
/* @__PURE__ */ o("span", { className: "dp-icon", children: c.calendar ?? /* @__PURE__ */ o(J, {}) })
] }),
children: [
/* @__PURE__ */ o(
n.Controls,
{
monthDropDown: y,
yearDropDown: x,
icons: c
}
),
/* @__PURE__ */ o(n.Months, {})
]
}
)
}
);
};
export {
Z as DatePicker,
s as dateFormat
};