@srimandir/pitru-paksh-common 2.35.0-alpha.0 → 2.35.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,5 +19,9 @@ export interface DatePickerSheetProps {
|
|
|
19
19
|
initialDate?: PickedDate;
|
|
20
20
|
minYear?: number;
|
|
21
21
|
maxYear?: number;
|
|
22
|
+
/** Day-precise lower bound. Takes precedence over `minYear` and also restricts month/day within its own year. */
|
|
23
|
+
minDate?: PickedDate;
|
|
24
|
+
/** Day-precise upper bound. Takes precedence over `maxYear` and also restricts month/day within its own year. */
|
|
25
|
+
maxDate?: PickedDate;
|
|
22
26
|
}
|
|
23
|
-
export declare function DatePickerSheet({ isOpen, onClose, avatarUrl, heading, monthLabels, confirmLabel, onConfirm, timezoneLabel, initialDate, minYear, maxYear, }: DatePickerSheetProps): import("react").JSX.Element;
|
|
27
|
+
export declare function DatePickerSheet({ isOpen, onClose, avatarUrl, heading, monthLabels, confirmLabel, onConfirm, timezoneLabel, initialDate, minYear, maxYear, minDate, maxDate, }: DatePickerSheetProps): import("react").JSX.Element;
|
|
@@ -1,58 +1,78 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { BottomSheet as
|
|
4
|
-
import { WheelColumn as
|
|
5
|
-
import { Button as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
isOpen:
|
|
9
|
-
onClose:
|
|
10
|
-
avatarUrl:
|
|
11
|
-
heading:
|
|
12
|
-
monthLabels:
|
|
13
|
-
confirmLabel:
|
|
14
|
-
onConfirm:
|
|
15
|
-
timezoneLabel:
|
|
16
|
-
initialDate:
|
|
17
|
-
minYear:
|
|
18
|
-
maxYear:
|
|
1
|
+
import { jsx as t, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as u, useState as x, useEffect as Y } from "react";
|
|
3
|
+
import { BottomSheet as H } from "@srimandir/common";
|
|
4
|
+
import { WheelColumn as g } from "./WheelColumn.js";
|
|
5
|
+
import { Button as F } from "../Button/Button.js";
|
|
6
|
+
const j = Array.from({ length: 31 }, (i, f) => f + 1), P = Array.from({ length: 12 }, (i, f) => f);
|
|
7
|
+
function L({
|
|
8
|
+
isOpen: i,
|
|
9
|
+
onClose: f,
|
|
10
|
+
avatarUrl: y,
|
|
11
|
+
heading: v,
|
|
12
|
+
monthLabels: k,
|
|
13
|
+
confirmLabel: A,
|
|
14
|
+
onConfirm: B,
|
|
15
|
+
timezoneLabel: N,
|
|
16
|
+
initialDate: l,
|
|
17
|
+
minYear: _,
|
|
18
|
+
maxYear: O = (/* @__PURE__ */ new Date()).getFullYear(),
|
|
19
|
+
minDate: n,
|
|
20
|
+
maxDate: o
|
|
19
21
|
}) {
|
|
20
|
-
const n =
|
|
21
|
-
const
|
|
22
|
-
return Array.from({ length:
|
|
23
|
-
}, [
|
|
24
|
-
() =>
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const b = n?.year ?? _, p = o?.year ?? O, h = u(() => {
|
|
23
|
+
const e = b ?? p - 120;
|
|
24
|
+
return Array.from({ length: p - e + 1 }, (r, E) => e + E);
|
|
25
|
+
}, [b, p]), [I, w] = x(() => l ? l.day - 1 : Math.floor(j.length / 2)), [M, C] = x(() => l ? l.month - 1 : 0), [S, z] = x(
|
|
26
|
+
() => l ? Math.max(0, h.indexOf(l.year)) : Math.floor(h.length / 2)
|
|
27
|
+
), s = h[S], c = u(() => {
|
|
28
|
+
let e = P;
|
|
29
|
+
return o && s === o.year && (e = e.filter((r) => r <= o.month - 1)), n && s === n.year && (e = e.filter((r) => r >= n.month - 1)), e;
|
|
30
|
+
}, [s, n, o]), a = (c[M] ?? c[c.length - 1] ?? 0) + 1, d = u(() => {
|
|
31
|
+
let e = j;
|
|
32
|
+
return o && s === o.year && a === o.month && (e = e.filter((r) => r <= o.day)), n && s === n.year && a === n.month && (e = e.filter((r) => r >= n.day)), e;
|
|
33
|
+
}, [s, a, n, o]);
|
|
34
|
+
return Y(() => {
|
|
35
|
+
C((e) => Math.min(e, c.length - 1));
|
|
36
|
+
}, [c]), Y(() => {
|
|
37
|
+
w((e) => Math.min(e, d.length - 1));
|
|
38
|
+
}, [d]), /* @__PURE__ */ t(
|
|
39
|
+
H,
|
|
28
40
|
{
|
|
29
|
-
isOpen:
|
|
30
|
-
onClose:
|
|
41
|
+
isOpen: i,
|
|
42
|
+
onClose: f,
|
|
31
43
|
showDragHandle: !0,
|
|
32
44
|
showCloseButton: !1,
|
|
33
45
|
closeButtonOutside: !0,
|
|
34
|
-
ariaLabel:
|
|
46
|
+
ariaLabel: v,
|
|
35
47
|
overlayClassName: "pitru-paksh-common-root",
|
|
36
|
-
header: /* @__PURE__ */
|
|
37
|
-
|
|
38
|
-
/* @__PURE__ */
|
|
48
|
+
header: /* @__PURE__ */ m("div", { className: "flex w-full items-center gap-3 px-5 pt-5", children: [
|
|
49
|
+
y && /* @__PURE__ */ t("div", { className: "flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full bg-[#fff9e9]", children: /* @__PURE__ */ t("img", { src: y, alt: "", className: "size-full object-cover" }) }),
|
|
50
|
+
/* @__PURE__ */ t("p", { className: "flex-1 text-[18px] leading-6 font-bold text-[#1d2125]", children: v })
|
|
39
51
|
] }),
|
|
40
|
-
footer: /* @__PURE__ */
|
|
41
|
-
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
footer: /* @__PURE__ */ m("div", { className: "flex w-full items-center gap-6 px-5 pt-2 pb-5", children: [
|
|
53
|
+
N && /* @__PURE__ */ t("p", { className: "shrink-0 text-[12px] leading-4 font-semibold whitespace-nowrap text-[#6b7280]", children: N }),
|
|
54
|
+
/* @__PURE__ */ t(F, { variant: "primary", size: "lg", className: "flex-1 rounded-xl", onClick: () => {
|
|
55
|
+
const e = d[I] ?? d[d.length - 1] ?? 1;
|
|
56
|
+
B({ day: e, month: a, year: s });
|
|
57
|
+
}, children: A })
|
|
45
58
|
] }),
|
|
46
|
-
children: /* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
children: /* @__PURE__ */ m("div", { className: "relative flex w-full items-center justify-center gap-11 px-5 py-4", children: [
|
|
60
|
+
/* @__PURE__ */ t(g, { options: d.map(String), selectedIndex: I, onChange: w }),
|
|
61
|
+
/* @__PURE__ */ t(
|
|
62
|
+
g,
|
|
63
|
+
{
|
|
64
|
+
options: c.map((e) => k[e]),
|
|
65
|
+
selectedIndex: M,
|
|
66
|
+
onChange: C
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ t(g, { options: h.map(String), selectedIndex: S, onChange: z }),
|
|
70
|
+
/* @__PURE__ */ t("div", { className: "pointer-events-none absolute inset-x-5 top-16 h-px bg-[#e5e7eb]" }),
|
|
71
|
+
/* @__PURE__ */ t("div", { className: "pointer-events-none absolute inset-x-5 top-28 h-px bg-[#e5e7eb]" })
|
|
52
72
|
] })
|
|
53
73
|
}
|
|
54
74
|
);
|
|
55
75
|
}
|
|
56
76
|
export {
|
|
57
|
-
|
|
77
|
+
L as DatePickerSheet
|
|
58
78
|
};
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as o, jsxs as h } from "react/jsx-runtime";
|
|
2
2
|
import c from "react";
|
|
3
|
-
const
|
|
4
|
-
function p({ options:
|
|
5
|
-
const
|
|
3
|
+
const e = 48;
|
|
4
|
+
function p({ options: a, selectedIndex: l, onChange: u }) {
|
|
5
|
+
const r = c.useRef(null), s = c.useRef(!1);
|
|
6
6
|
c.useEffect(() => {
|
|
7
|
-
|
|
8
|
-
}, [])
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
s.current || !r.current || (s.current = !0, r.current.scrollTop = l * e);
|
|
8
|
+
}, []), c.useEffect(() => {
|
|
9
|
+
!s.current || !r.current || (r.current.scrollTop = l * e);
|
|
10
|
+
}, [a.length, l]);
|
|
11
|
+
const i = () => {
|
|
12
|
+
if (!r.current) return;
|
|
13
|
+
const t = Math.round(r.current.scrollTop / e), n = Math.max(0, Math.min(a.length - 1, t));
|
|
14
|
+
n !== l && u(n);
|
|
15
|
+
}, f = (t) => {
|
|
16
|
+
r.current?.scrollTo({ top: t * e, behavior: "smooth" }), u(t);
|
|
15
17
|
};
|
|
16
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ o("div", { className: "relative h-36 w-full", children: /* @__PURE__ */ h(
|
|
17
19
|
"div",
|
|
18
20
|
{
|
|
19
|
-
ref:
|
|
20
|
-
onScroll:
|
|
21
|
+
ref: r,
|
|
22
|
+
onScroll: i,
|
|
21
23
|
className: "h-36 snap-y snap-mandatory overflow-y-auto [&::-webkit-scrollbar]:hidden",
|
|
22
24
|
style: { scrollbarWidth: "none" },
|
|
23
25
|
children: [
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
|
|
26
|
+
/* @__PURE__ */ o("div", { style: { height: e }, "aria-hidden": !0 }),
|
|
27
|
+
a.map((t, n) => /* @__PURE__ */ o(
|
|
26
28
|
"button",
|
|
27
29
|
{
|
|
28
30
|
type: "button",
|
|
29
|
-
onClick: () =>
|
|
30
|
-
className: `flex h-12 w-full snap-center items-center justify-center whitespace-nowrap border-0 bg-transparent text-[20px] leading-7 ${
|
|
31
|
-
children:
|
|
31
|
+
onClick: () => f(n),
|
|
32
|
+
className: `flex h-12 w-full snap-center items-center justify-center whitespace-nowrap border-0 bg-transparent text-[20px] leading-7 ${n === l ? "font-bold text-[#f75e22]" : "font-semibold text-[#d1d5db]"}`,
|
|
33
|
+
children: t
|
|
32
34
|
},
|
|
33
|
-
|
|
35
|
+
t
|
|
34
36
|
)),
|
|
35
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ o("div", { style: { height: e }, "aria-hidden": !0 })
|
|
36
38
|
]
|
|
37
39
|
}
|
|
38
40
|
) });
|