@undp/design-system-react
Version:
React based design system for UNDP
64 lines (63 loc) • 2.3 kB
JavaScript
import { t as e } from "./arrow-right-DmXsnaI4.js";
import { DateTimePicker as t } from "./DateTimePicker.js";
import { useEffect as n, useState as r } from "react";
import { jsx as i, jsxs as a } from "react/jsx-runtime";
//#region src/components/ui/date-time-range-picker.tsx
function o({ disablePopover: o, classNames: s, variant: c, inputSize: l, rounded: u, onValueChange: d, value: f, defaultValue: p, disabled: m }) {
let [h, g] = r(f?.startDate || p?.startDate || void 0), [_, v] = r(f?.endDate || p?.endDate || void 0);
return n(() => {
d?.({
startDate: h,
endDate: _
});
}, [
h,
_,
d
]), /* @__PURE__ */ a("div", {
className: "flex w-full items-center gap-2",
children: [
/* @__PURE__ */ i(t, {
onValueChange: (e) => {
g(e);
},
placeHolder: "Start date and time",
rounded: u,
disablePopover: o,
variant: c,
inputSize: l,
classNames: s,
disabled: (e) => {
let t = _ ? e.getDate() > _.getDate() : !1;
return typeof m == "function" ? m(e) || t : Array.isArray(m) && m.some((t) => typeof t == "function" && t(e)) || t;
},
disabledHours: _ && _?.getDate() === h?.getDate() ? Array.from({ length: 24 }, (e, t) => t).filter((e) => e > _.getHours()) : [],
disabledMinutes: _ && _?.getDate() === h?.getDate() ? Array.from({ length: 60 }, (e, t) => t).filter((e) => e > _.getMinutes()) : []
}),
/* @__PURE__ */ i("div", {
className: "size-4 text-input-border",
children: /* @__PURE__ */ i(e, { size: 16 })
}),
/* @__PURE__ */ i(t, {
onValueChange: (e) => {
v(e);
},
placeHolder: "End date and time",
rounded: u,
disablePopover: o,
variant: c,
inputSize: l,
classNames: s,
disabled: (e) => {
let t = h ? e.getDate() < h.getDate() : !1;
return typeof m == "function" ? m(e) || t : Array.isArray(m) && m.some((t) => typeof t == "function" && t(e)) || t;
},
disabledHours: h && _?.getDate() === h.getDate() ? Array.from({ length: 24 }, (e, t) => t).filter((e) => e < h.getHours()) : [],
disabledMinutes: h && _?.getDate() === h.getDate() ? Array.from({ length: 60 }, (e, t) => t).filter((e) => e < h.getMinutes()) : []
})
]
});
}
//#endregion
export { o as DateTimeRangePicker };
//# sourceMappingURL=DateTimeRangePicker.js.map