@brightsoftware/date-np
Version:
Simple & minimal Nepali date picker that just works.
68 lines (67 loc) • 2.4 kB
JavaScript
import "../style.css";
import { jsx as t, jsxs as n, Fragment as g } from "react/jsx-runtime";
import { useRef as D } from "react";
import { cn as v } from "../utils/clsx.js";
import w from "./Components/helpers/direction-aware-container.js";
import P from "./Components/picker-body.js";
import N from "./Components/picker-header.js";
import I from "./Components/picker-input.js";
import { PickerProvider as b, usePicker as y } from "./hooks/usePicker.js";
import { isInvalidDateRange as C } from "../utils/validators.js";
/* empty css */
const q = (c) => {
const {
minDate: a,
maxDate: r,
shouldShowInput: l = !0,
className: s,
inputProps: e = {},
dAwareConProps: d = {},
onSelect: f,
label: i,
description: m
} = c, o = (e == null ? void 0 : e.ref) ?? D(null);
let u = () => {
const { updatePickerVisiblity: x, pickerState: p } = y(), h = p.isVisible, k = a && r && C(a, r);
return /* @__PURE__ */ t(
w,
{
direction: "bottom",
activateWith: "ref",
activatorRef: o,
onOutsideClick: () => x(!1),
centerAlignContainer: !0,
active: h,
className: "mt-2",
...d,
children: /* @__PURE__ */ t("div", { className: v(
"flex flex-col gap-0.5 w-72 h-max bg-white drop-shadow-sm p-2.5 rounded-md",
s
), children: k ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center p-4 text-red-600 text-sm font-medium", children: "Invalid date range: minimum date is greater than maximum date" }) : /* @__PURE__ */ n(g, { children: [
/* @__PURE__ */ t(N, {}),
/* @__PURE__ */ t(
P,
{
onSelect: f
}
)
] }) })
}
);
};
return /* @__PURE__ */ t(b, { minDate: a, maxDate: r, defaultDate: e == null ? void 0 : e.defaultDate, defaultLocale: e == null ? void 0 : e.defaultLocale, children: /* @__PURE__ */ n("div", { className: "flex flex-col gap-1 w-full", children: [
i && /* @__PURE__ */ t("span", { className: "text-m font-medium text-gray-700 text-start", children: i }),
l && /* @__PURE__ */ t(
I,
{
ref: o,
...e
}
),
/* @__PURE__ */ t(u, {}),
m && /* @__PURE__ */ t("span", { className: "text-sm text-gray-500 text-start", children: m })
] }) });
};
export {
q as default
};