impact-nova 0.1.11 → 0.1.13
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.
- package/dist/components/ui/ag-grid-react/headers/custom-header.js +42 -35
- package/dist/components/ui/ag-grid-react/headers/header-search-input.d.ts +4 -1
- package/dist/components/ui/ag-grid-react/headers/header-search-input.js +217 -209
- package/dist/components/ui/ag-grid-react/headers/utils/filter-utils.d.ts +5 -1
- package/dist/components/ui/ag-grid-react/headers/utils/filter-utils.js +210 -204
- package/dist/components/ui/ag-grid-react/process-backend-columndefs.js +26 -11
- package/dist/components/ui/calendar.d.ts +2 -1
- package/dist/components/ui/calendar.js +272 -264
- package/dist/components/ui/date-picker/date-picker.js +59 -55
- package/dist/components/ui/date-picker/date-range-picker.js +76 -73
- package/dist/components/ui/date-picker/month-picker.js +67 -63
- package/dist/components/ui/date-picker/month-range-picker.js +62 -58
- package/dist/components/ui/date-picker/week-picker.js +51 -47
- package/dist/components/ui/date-picker/week-range-picker.js +55 -51
- package/dist/components/ui/types/ag-grid.types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,76 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as f, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import * as c from "react";
|
|
3
|
-
import { X as
|
|
4
|
-
import { CalendarMonth as
|
|
5
|
-
import { parse as
|
|
3
|
+
import { X as L } from "lucide-react";
|
|
4
|
+
import { CalendarMonth as Q, Info as U } from "../../../icons/index.js";
|
|
5
|
+
import { parse as S, isValid as v } from "date-fns";
|
|
6
6
|
import { cn as w, maskDate as D } from "../../../lib/utils.js";
|
|
7
|
-
import { Popover as
|
|
8
|
-
import { Calendar as
|
|
9
|
-
const
|
|
7
|
+
import { Popover as W, PopoverTrigger as Z, PopoverContent as F } from "../popover.js";
|
|
8
|
+
import { Calendar as _ } from "../calendar.js";
|
|
9
|
+
const m = (e) => `${(e.month + 1).toString().padStart(2, "0")}/${e.year}`, ee = c.forwardRef(
|
|
10
10
|
({
|
|
11
11
|
value: e,
|
|
12
12
|
onChange: a,
|
|
13
|
-
placeholder:
|
|
13
|
+
placeholder: te = "Select Month Range",
|
|
14
14
|
minDate: Y,
|
|
15
15
|
maxDate: I,
|
|
16
16
|
fromYear: V,
|
|
17
17
|
toYear: A,
|
|
18
|
-
showFooter:
|
|
18
|
+
showFooter: p = !0,
|
|
19
19
|
disabled: h,
|
|
20
20
|
className: O,
|
|
21
21
|
isError: g,
|
|
22
22
|
size: R,
|
|
23
|
-
label:
|
|
24
|
-
helperText:
|
|
23
|
+
label: P,
|
|
24
|
+
helperText: k,
|
|
25
25
|
required: j,
|
|
26
|
-
prefix:
|
|
27
|
-
prefixClick:
|
|
26
|
+
prefix: ne,
|
|
27
|
+
prefixClick: oe,
|
|
28
28
|
...B
|
|
29
29
|
}, E) => {
|
|
30
|
-
const [s, u] = c.useState(!1), [d, l] = c.useState(e), [T,
|
|
30
|
+
const [s, u] = c.useState(!1), [d, l] = c.useState(e), [T, y] = c.useState(e?.from ? m(e.from) : ""), [$, x] = c.useState(e?.to ? m(e.to) : ""), [z, b] = c.useState(() => e?.from ? new Date(e.from.year, e.from.month, 1) : /* @__PURE__ */ new Date());
|
|
31
31
|
c.useEffect(() => {
|
|
32
|
-
|
|
32
|
+
y(e?.from ? m(e.from) : ""), x(e?.to ? m(e.to) : "");
|
|
33
33
|
}, [e]), c.useEffect(() => {
|
|
34
34
|
console.log("[MonthRangePicker] useEffect - open:", s, "value:", e, "pendingRange:", d), s && (l(e), b(e?.from ? new Date(e.from.year, e.from.month, 1) : /* @__PURE__ */ new Date()));
|
|
35
35
|
}, [s]);
|
|
36
36
|
const X = (t) => {
|
|
37
|
-
console.log("[MonthRangePicker] handleSelect called:", t), l(t), !
|
|
37
|
+
console.log("[MonthRangePicker] handleSelect called:", t), l(t), !p && t?.from && t?.to && (console.log("[MonthRangePicker] No footer - applying immediately"), a?.(t), u(!1));
|
|
38
38
|
}, q = (t) => {
|
|
39
|
+
const n = t;
|
|
40
|
+
y(n?.from ? m(n.from) : ""), x(n?.to ? m(n.to) : "");
|
|
41
|
+
}, G = (t) => {
|
|
39
42
|
const n = t !== void 0 ? t : d;
|
|
40
43
|
console.log("[MonthRangePicker] handleApply called, appliedRange:", t, "pendingRange:", d, "using:", n), a?.(n), u(!1);
|
|
41
|
-
},
|
|
44
|
+
}, H = () => {
|
|
42
45
|
console.log("[MonthRangePicker] handleCancel called"), l(e), u(!1);
|
|
43
|
-
},
|
|
44
|
-
console.log("[MonthRangePicker] handleClear called"), l(void 0),
|
|
45
|
-
},
|
|
46
|
+
}, C = () => {
|
|
47
|
+
console.log("[MonthRangePicker] handleClear called"), l(void 0), y(""), x(""), a?.(void 0), p || u(!1);
|
|
48
|
+
}, J = (t) => {
|
|
46
49
|
const n = D(t.target.value, "MM/yyyy");
|
|
47
|
-
if (
|
|
50
|
+
if (y(n), n === "") {
|
|
48
51
|
const i = { from: void 0, to: e?.to };
|
|
49
|
-
l(i),
|
|
52
|
+
l(i), p || a?.(i);
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
|
-
const r =
|
|
55
|
+
const r = S(n, "MM/yyyy", /* @__PURE__ */ new Date());
|
|
53
56
|
if (v(r)) {
|
|
54
|
-
const
|
|
55
|
-
l(
|
|
57
|
+
const M = { from: { month: r.getMonth(), year: r.getFullYear() }, to: e?.to };
|
|
58
|
+
l(M), b(r), p || a?.(M);
|
|
56
59
|
}
|
|
57
|
-
},
|
|
60
|
+
}, K = (t) => {
|
|
58
61
|
const n = D(t.target.value, "MM/yyyy");
|
|
59
|
-
if (
|
|
62
|
+
if (x(n), n === "") {
|
|
60
63
|
const i = { from: e?.from, to: void 0 };
|
|
61
|
-
l(i),
|
|
64
|
+
l(i), p || a?.(i);
|
|
62
65
|
return;
|
|
63
66
|
}
|
|
64
|
-
const r =
|
|
67
|
+
const r = S(n, "MM/yyyy", /* @__PURE__ */ new Date());
|
|
65
68
|
if (v(r)) {
|
|
66
|
-
const i = { month: r.getMonth(), year: r.getFullYear() },
|
|
67
|
-
l(
|
|
69
|
+
const i = { month: r.getMonth(), year: r.getFullYear() }, M = { from: e?.from, to: i };
|
|
70
|
+
l(M), b(r), p || a?.(M);
|
|
68
71
|
}
|
|
69
|
-
},
|
|
70
|
-
|
|
72
|
+
}, N = () => {
|
|
73
|
+
y(d?.from ? m(d.from) : ""), x(d?.to ? m(d.to) : "");
|
|
71
74
|
};
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
|
|
75
|
+
return /* @__PURE__ */ f("div", { className: "w-full space-y-1.5 min-w-[240px]", children: [
|
|
76
|
+
P && /* @__PURE__ */ f(
|
|
74
77
|
"label",
|
|
75
78
|
{
|
|
76
79
|
className: w(
|
|
@@ -79,14 +82,14 @@ const f = (e) => `${(e.month + 1).toString().padStart(2, "0")}/${e.year}`, _ = c
|
|
|
79
82
|
g && "text-destructive"
|
|
80
83
|
),
|
|
81
84
|
children: [
|
|
82
|
-
|
|
85
|
+
P,
|
|
83
86
|
" ",
|
|
84
87
|
j && /* @__PURE__ */ o("span", { className: "text-destructive", children: "*" })
|
|
85
88
|
]
|
|
86
89
|
}
|
|
87
90
|
),
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */ o(
|
|
91
|
+
/* @__PURE__ */ f(W, { open: s, onOpenChange: u, children: [
|
|
92
|
+
/* @__PURE__ */ o(Z, { asChild: !0, children: /* @__PURE__ */ f(
|
|
90
93
|
"div",
|
|
91
94
|
{
|
|
92
95
|
className: w(
|
|
@@ -98,15 +101,15 @@ const f = (e) => `${(e.month + 1).toString().padStart(2, "0")}/${e.year}`, _ = c
|
|
|
98
101
|
O
|
|
99
102
|
),
|
|
100
103
|
children: [
|
|
101
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ f("div", { className: "flex items-center gap-4 flex-1 min-w-0", children: [
|
|
102
105
|
/* @__PURE__ */ o(
|
|
103
106
|
"input",
|
|
104
107
|
{
|
|
105
108
|
ref: E,
|
|
106
109
|
type: "text",
|
|
107
110
|
value: T,
|
|
108
|
-
onChange:
|
|
109
|
-
onBlur:
|
|
111
|
+
onChange: J,
|
|
112
|
+
onBlur: N,
|
|
110
113
|
onClick: (t) => s && t.stopPropagation(),
|
|
111
114
|
placeholder: s ? "MM/YYYY" : "Start Month",
|
|
112
115
|
disabled: !!h,
|
|
@@ -119,8 +122,8 @@ const f = (e) => `${(e.month + 1).toString().padStart(2, "0")}/${e.year}`, _ = c
|
|
|
119
122
|
{
|
|
120
123
|
type: "text",
|
|
121
124
|
value: $,
|
|
122
|
-
onChange:
|
|
123
|
-
onBlur:
|
|
125
|
+
onChange: K,
|
|
126
|
+
onBlur: N,
|
|
124
127
|
onClick: (t) => s && t.stopPropagation(),
|
|
125
128
|
placeholder: s ? "MM/YYYY" : "End Month",
|
|
126
129
|
disabled: !!h,
|
|
@@ -128,52 +131,53 @@ const f = (e) => `${(e.month + 1).toString().padStart(2, "0")}/${e.year}`, _ = c
|
|
|
128
131
|
}
|
|
129
132
|
)
|
|
130
133
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ f("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
132
135
|
e?.from && !h && /* @__PURE__ */ o(
|
|
133
|
-
|
|
136
|
+
L,
|
|
134
137
|
{
|
|
135
138
|
className: "h-4 w-4 cursor-pointer hover:text-foreground text-muted-foreground",
|
|
136
139
|
onClick: (t) => {
|
|
137
|
-
t.stopPropagation(),
|
|
140
|
+
t.stopPropagation(), C();
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
),
|
|
141
|
-
/* @__PURE__ */ o(
|
|
144
|
+
/* @__PURE__ */ o(Q, { className: "h-4 w-4 text-secondary-foreground" })
|
|
142
145
|
] })
|
|
143
146
|
]
|
|
144
147
|
}
|
|
145
148
|
) }),
|
|
146
149
|
/* @__PURE__ */ o(
|
|
147
|
-
|
|
150
|
+
F,
|
|
148
151
|
{
|
|
149
152
|
className: "w-auto p-0",
|
|
150
153
|
align: "start",
|
|
151
154
|
onOpenAutoFocus: (t) => t.preventDefault(),
|
|
152
155
|
onInteractOutside: (t) => t.preventDefault(),
|
|
153
156
|
children: /* @__PURE__ */ o(
|
|
154
|
-
|
|
157
|
+
_,
|
|
155
158
|
{
|
|
156
159
|
pickerType: "month",
|
|
157
160
|
monthMode: "range",
|
|
158
161
|
selectedMonths: d,
|
|
159
162
|
onMonthSelect: X,
|
|
163
|
+
onPendingChange: q,
|
|
160
164
|
month: z,
|
|
161
165
|
onMonthChange: b,
|
|
162
166
|
fromDate: Y,
|
|
163
167
|
toDate: I,
|
|
164
168
|
fromYear: V,
|
|
165
169
|
toYear: A,
|
|
166
|
-
showFooter:
|
|
167
|
-
onApply:
|
|
168
|
-
onCancel:
|
|
169
|
-
onClear:
|
|
170
|
+
showFooter: p,
|
|
171
|
+
onApply: G,
|
|
172
|
+
onCancel: H,
|
|
173
|
+
onClear: C
|
|
170
174
|
}
|
|
171
175
|
)
|
|
172
176
|
}
|
|
173
177
|
)
|
|
174
178
|
] }),
|
|
175
|
-
|
|
176
|
-
!g && /* @__PURE__ */ o(
|
|
179
|
+
k && /* @__PURE__ */ f("div", { className: w("flex items-center gap-1", g && "text-destructive"), children: [
|
|
180
|
+
!g && /* @__PURE__ */ o(U, { size: 10, className: "shrink-0 text-muted-foreground" }),
|
|
177
181
|
/* @__PURE__ */ o(
|
|
178
182
|
"p",
|
|
179
183
|
{
|
|
@@ -181,14 +185,14 @@ const f = (e) => `${(e.month + 1).toString().padStart(2, "0")}/${e.year}`, _ = c
|
|
|
181
185
|
"text-[10px] text-[#7a8294]",
|
|
182
186
|
g && "text-destructive"
|
|
183
187
|
),
|
|
184
|
-
children:
|
|
188
|
+
children: k
|
|
185
189
|
}
|
|
186
190
|
)
|
|
187
191
|
] })
|
|
188
192
|
] });
|
|
189
193
|
}
|
|
190
194
|
);
|
|
191
|
-
|
|
195
|
+
ee.displayName = "MonthRangePicker";
|
|
192
196
|
export {
|
|
193
|
-
|
|
197
|
+
ee as MonthRangePicker
|
|
194
198
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as M, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { X as
|
|
4
|
-
import { CalendarMonth as
|
|
5
|
-
import { format as P, parse as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Input as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { Calendar as
|
|
10
|
-
const
|
|
3
|
+
import { X as R } from "lucide-react";
|
|
4
|
+
import { CalendarMonth as Y } from "../../../icons/index.js";
|
|
5
|
+
import { format as P, parse as X, isValid as q } from "date-fns";
|
|
6
|
+
import { cn as z, maskDate as G } from "../../../lib/utils.js";
|
|
7
|
+
import { Input as H } from "../input.js";
|
|
8
|
+
import { Popover as J, PopoverTrigger as K, PopoverContent as Q } from "../popover.js";
|
|
9
|
+
import { Calendar as U } from "../calendar.js";
|
|
10
|
+
const h = (n, a = "MM/dd/yyyy") => {
|
|
11
11
|
const o = P(n.startDate, a), k = P(n.endDate, a);
|
|
12
12
|
return `${o} - ${k}`;
|
|
13
|
-
},
|
|
13
|
+
}, Z = s.forwardRef(
|
|
14
14
|
({
|
|
15
15
|
value: n,
|
|
16
16
|
onChange: a,
|
|
@@ -25,103 +25,107 @@ const y = (n, a = "MM/dd/yyyy") => {
|
|
|
25
25
|
className: v,
|
|
26
26
|
...x
|
|
27
27
|
}, I) => {
|
|
28
|
-
const [
|
|
28
|
+
const [c, d] = s.useState(!1), [l, i] = s.useState(n), [W, g] = s.useState(n ? h(n, o) : ""), [N, u] = s.useState(n?.startDate || /* @__PURE__ */ new Date());
|
|
29
29
|
s.useEffect(() => {
|
|
30
|
-
|
|
30
|
+
g(n ? h(n, o) : "");
|
|
31
31
|
}, [n, o]), s.useEffect(() => {
|
|
32
|
-
console.log("[WeekPicker] useEffect - open:",
|
|
33
|
-
}, [
|
|
32
|
+
console.log("[WeekPicker] useEffect - open:", c, "value:", n, "pendingWeek:", l), c && (i(n), u(n?.startDate || /* @__PURE__ */ new Date()));
|
|
33
|
+
}, [c]);
|
|
34
34
|
const A = (e) => {
|
|
35
35
|
console.log("[WeekPicker] handleSelect called:", e), i(e), f || (console.log("[WeekPicker] No footer - applying immediately"), a?.(e), d(!1));
|
|
36
36
|
}, V = (e) => {
|
|
37
|
-
const t = e
|
|
38
|
-
|
|
39
|
-
}, $ = () => {
|
|
37
|
+
const t = e;
|
|
38
|
+
g(t ? h(t, o) : "");
|
|
39
|
+
}, $ = (e) => {
|
|
40
|
+
const t = e !== void 0 ? e : l;
|
|
41
|
+
console.log("[WeekPicker] handleApply called, appliedWeek:", e, "pendingWeek:", l, "using:", t), a?.(t), d(!1);
|
|
42
|
+
}, B = () => {
|
|
40
43
|
console.log("[WeekPicker] handleCancel called"), i(n), d(!1);
|
|
41
|
-
},
|
|
42
|
-
console.log("[WeekPicker] handleClear called"), i(void 0),
|
|
43
|
-
},
|
|
44
|
+
}, D = () => {
|
|
45
|
+
console.log("[WeekPicker] handleClear called"), i(void 0), g(""), a?.(void 0), f || d(!1);
|
|
46
|
+
}, E = (e) => {
|
|
44
47
|
const t = new Date(e);
|
|
45
48
|
t.setDate(e.getDate() - e.getDay());
|
|
46
49
|
const p = new Date(t);
|
|
47
50
|
p.setDate(t.getDate() + 6);
|
|
48
|
-
const
|
|
51
|
+
const T = new Date(t.getFullYear(), t.getMonth(), 1).getDay(), j = t.getDate(), L = Math.ceil((j + T) / 7);
|
|
49
52
|
return {
|
|
50
53
|
year: t.getFullYear(),
|
|
51
54
|
month: t.getMonth(),
|
|
52
|
-
weekOfMonth:
|
|
55
|
+
weekOfMonth: L,
|
|
53
56
|
startDate: t,
|
|
54
57
|
endDate: p
|
|
55
58
|
};
|
|
56
59
|
};
|
|
57
|
-
return /* @__PURE__ */ M(
|
|
58
|
-
/* @__PURE__ */ r(
|
|
59
|
-
|
|
60
|
+
return /* @__PURE__ */ M(J, { open: c, onOpenChange: d, children: [
|
|
61
|
+
/* @__PURE__ */ r(K, { asChild: !0, children: /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
|
|
62
|
+
H,
|
|
60
63
|
{
|
|
61
64
|
ref: I,
|
|
62
65
|
value: W,
|
|
63
66
|
onChange: (e) => {
|
|
64
|
-
const t =
|
|
65
|
-
if (
|
|
67
|
+
const t = G(e.target.value, o);
|
|
68
|
+
if (g(t), t === "") {
|
|
66
69
|
i(void 0), f || a?.(void 0);
|
|
67
70
|
return;
|
|
68
71
|
}
|
|
69
|
-
const p =
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
i(
|
|
72
|
+
const p = X(t, o, /* @__PURE__ */ new Date());
|
|
73
|
+
if (q(p)) {
|
|
74
|
+
const y = E(p);
|
|
75
|
+
i(y), u(p), f || a?.(y);
|
|
73
76
|
}
|
|
74
77
|
},
|
|
75
78
|
onBlur: () => {
|
|
76
79
|
if (W === "") {
|
|
77
|
-
|
|
80
|
+
D();
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
|
-
|
|
83
|
+
g(l ? h(l, o) : "");
|
|
81
84
|
},
|
|
82
|
-
onClick: (e) =>
|
|
83
|
-
placeholder:
|
|
85
|
+
onClick: (e) => c && e.stopPropagation(),
|
|
86
|
+
placeholder: c ? `${o} - ${o}` : k,
|
|
84
87
|
disabled: m,
|
|
85
|
-
className:
|
|
88
|
+
className: z("cursor-pointer", v),
|
|
86
89
|
suffix: /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
|
|
87
90
|
n && !m && /* @__PURE__ */ r(
|
|
88
|
-
|
|
91
|
+
R,
|
|
89
92
|
{
|
|
90
93
|
className: "h-4 w-4 cursor-pointer hover:text-foreground",
|
|
91
94
|
onClick: (e) => {
|
|
92
|
-
e.stopPropagation(),
|
|
95
|
+
e.stopPropagation(), D();
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
),
|
|
96
|
-
/* @__PURE__ */ r(
|
|
99
|
+
/* @__PURE__ */ r(Y, { className: "h-4 w-4 text-secondary-foreground" })
|
|
97
100
|
] }),
|
|
98
101
|
...x
|
|
99
102
|
}
|
|
100
103
|
) }) }),
|
|
101
104
|
/* @__PURE__ */ r(
|
|
102
|
-
|
|
105
|
+
Q,
|
|
103
106
|
{
|
|
104
107
|
className: "w-auto p-0",
|
|
105
108
|
align: "start",
|
|
106
109
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
107
110
|
onInteractOutside: (e) => e.preventDefault(),
|
|
108
111
|
children: /* @__PURE__ */ r(
|
|
109
|
-
|
|
112
|
+
U,
|
|
110
113
|
{
|
|
111
114
|
pickerType: "week",
|
|
112
115
|
weekMode: "single",
|
|
113
|
-
selectedWeeks:
|
|
116
|
+
selectedWeeks: l,
|
|
114
117
|
onWeekSelect: A,
|
|
118
|
+
onPendingChange: V,
|
|
115
119
|
month: N,
|
|
116
|
-
onMonthChange:
|
|
120
|
+
onMonthChange: u,
|
|
117
121
|
fromDate: C,
|
|
118
122
|
toDate: w,
|
|
119
123
|
fromYear: S,
|
|
120
124
|
toYear: O,
|
|
121
125
|
showFooter: f,
|
|
122
|
-
onApply:
|
|
123
|
-
onCancel:
|
|
124
|
-
onClear:
|
|
126
|
+
onApply: $,
|
|
127
|
+
onCancel: B,
|
|
128
|
+
onClear: D,
|
|
125
129
|
captionLayout: "dropdown"
|
|
126
130
|
}
|
|
127
131
|
)
|
|
@@ -130,7 +134,7 @@ const y = (n, a = "MM/dd/yyyy") => {
|
|
|
130
134
|
] });
|
|
131
135
|
}
|
|
132
136
|
);
|
|
133
|
-
|
|
137
|
+
Z.displayName = "WeekPicker";
|
|
134
138
|
export {
|
|
135
|
-
|
|
139
|
+
Z as WeekPicker
|
|
136
140
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as u, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import * as d from "react";
|
|
3
|
-
import { X as
|
|
4
|
-
import { CalendarMonth as
|
|
5
|
-
import { format as
|
|
3
|
+
import { X as $ } from "lucide-react";
|
|
4
|
+
import { CalendarMonth as _, Info as F } from "../../../icons/index.js";
|
|
5
|
+
import { format as f, parse as M, isValid as S } from "date-fns";
|
|
6
6
|
import { cn as w, maskDate as O } from "../../../lib/utils.js";
|
|
7
|
-
import { Popover as
|
|
8
|
-
import { Calendar as
|
|
9
|
-
const
|
|
7
|
+
import { Popover as ee, PopoverTrigger as te, PopoverContent as ne } from "../popover.js";
|
|
8
|
+
import { Calendar as oe } from "../calendar.js";
|
|
9
|
+
const ae = d.forwardRef(
|
|
10
10
|
({
|
|
11
11
|
value: n,
|
|
12
12
|
onChange: p,
|
|
@@ -15,72 +15,75 @@ const oe = d.forwardRef(
|
|
|
15
15
|
maxDate: V,
|
|
16
16
|
fromYear: A,
|
|
17
17
|
toYear: j,
|
|
18
|
-
showFooter:
|
|
18
|
+
showFooter: m = !0,
|
|
19
19
|
disabled: h,
|
|
20
20
|
className: B,
|
|
21
21
|
isError: x,
|
|
22
22
|
size: v,
|
|
23
23
|
label: W,
|
|
24
|
-
helperText:
|
|
24
|
+
helperText: P,
|
|
25
25
|
required: E,
|
|
26
|
-
prefix:
|
|
27
|
-
prefixClick:
|
|
26
|
+
prefix: re,
|
|
27
|
+
prefixClick: se,
|
|
28
28
|
...L
|
|
29
29
|
}, T) => {
|
|
30
|
-
const [c, k] = d.useState(!1), [a, i] = d.useState(n), [Y,
|
|
30
|
+
const [c, k] = d.useState(!1), [a, i] = d.useState(n), [Y, D] = d.useState(n?.from ? f(n.from.startDate, o) : ""), [z, y] = d.useState(n?.to ? f(n.to.endDate, o) : ""), [X, b] = d.useState(n?.from?.startDate || /* @__PURE__ */ new Date());
|
|
31
31
|
d.useEffect(() => {
|
|
32
|
-
|
|
32
|
+
D(n?.from ? f(n.from.startDate, o) : ""), y(n?.to ? f(n.to.endDate, o) : "");
|
|
33
33
|
}, [n, o]), d.useEffect(() => {
|
|
34
34
|
console.log("[WeekRangePicker] useEffect - open:", c, "value:", n, "pendingRange:", a), c && (i(n), b(n?.from?.startDate || /* @__PURE__ */ new Date()));
|
|
35
35
|
}, [c]);
|
|
36
36
|
const q = (e) => {
|
|
37
|
-
console.log("[WeekRangePicker] handleSelect called:", e), i(e), !
|
|
37
|
+
console.log("[WeekRangePicker] handleSelect called:", e), i(e), !m && e?.from && e?.to && (console.log("[WeekRangePicker] No footer - applying immediately"), p?.(e), k(!1));
|
|
38
38
|
}, G = (e) => {
|
|
39
|
+
const t = e;
|
|
40
|
+
D(t?.from ? f(t.from.startDate, o) : ""), y(t?.to ? f(t.to.endDate, o) : "");
|
|
41
|
+
}, H = (e) => {
|
|
39
42
|
const t = e !== void 0 ? e : a;
|
|
40
43
|
console.log("[WeekRangePicker] handleApply called, appliedRange:", e, "pendingRange:", a, "using:", t), p?.(t), k(!1);
|
|
41
|
-
},
|
|
44
|
+
}, J = () => {
|
|
42
45
|
console.log("[WeekRangePicker] handleCancel called"), i(n), k(!1);
|
|
43
|
-
},
|
|
44
|
-
console.log("[WeekRangePicker] handleClear called"), i(void 0),
|
|
45
|
-
},
|
|
46
|
+
}, R = () => {
|
|
47
|
+
console.log("[WeekRangePicker] handleClear called"), i(void 0), D(""), y(""), p?.(void 0), m || k(!1);
|
|
48
|
+
}, C = (e) => {
|
|
46
49
|
const t = new Date(e);
|
|
47
50
|
t.setDate(e.getDate() - e.getDay());
|
|
48
51
|
const r = new Date(t);
|
|
49
52
|
r.setDate(t.getDate() + 6);
|
|
50
|
-
const
|
|
53
|
+
const g = new Date(t.getFullYear(), t.getMonth(), 1).getDay(), U = t.getDate(), Z = Math.ceil((U + g) / 7);
|
|
51
54
|
return {
|
|
52
55
|
year: t.getFullYear(),
|
|
53
56
|
month: t.getMonth(),
|
|
54
|
-
weekOfMonth:
|
|
57
|
+
weekOfMonth: Z,
|
|
55
58
|
startDate: t,
|
|
56
59
|
endDate: r
|
|
57
60
|
};
|
|
58
|
-
},
|
|
61
|
+
}, K = (e) => {
|
|
59
62
|
const t = O(e.target.value, o);
|
|
60
|
-
if (
|
|
63
|
+
if (D(t), t === "") {
|
|
61
64
|
const l = { from: void 0, to: a?.to };
|
|
62
|
-
i(l),
|
|
65
|
+
i(l), m || p?.(l);
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
68
|
const r = M(t, o, /* @__PURE__ */ new Date());
|
|
66
69
|
if (S(r)) {
|
|
67
|
-
const
|
|
68
|
-
i(
|
|
70
|
+
const g = { from: C(r), to: a?.to };
|
|
71
|
+
i(g), b(r), m || p?.(g);
|
|
69
72
|
}
|
|
70
|
-
},
|
|
73
|
+
}, Q = (e) => {
|
|
71
74
|
const t = O(e.target.value, o);
|
|
72
|
-
if (
|
|
75
|
+
if (y(t), t === "") {
|
|
73
76
|
const l = { from: a?.from, to: void 0 };
|
|
74
|
-
i(l),
|
|
77
|
+
i(l), m || p?.(l);
|
|
75
78
|
return;
|
|
76
79
|
}
|
|
77
80
|
const r = M(t, o, /* @__PURE__ */ new Date());
|
|
78
81
|
if (S(r)) {
|
|
79
|
-
const l =
|
|
80
|
-
i(
|
|
82
|
+
const l = C(r), g = { from: a?.from, to: l };
|
|
83
|
+
i(g), b(r), m || p?.(g);
|
|
81
84
|
}
|
|
82
|
-
},
|
|
83
|
-
|
|
85
|
+
}, N = () => {
|
|
86
|
+
D(a?.from ? f(a.from.startDate, o) : ""), y(a?.to ? f(a.to.endDate, o) : "");
|
|
84
87
|
};
|
|
85
88
|
return /* @__PURE__ */ u("div", { className: "w-full space-y-1.5 min-w-[240px]", children: [
|
|
86
89
|
W && /* @__PURE__ */ u(
|
|
@@ -98,8 +101,8 @@ const oe = d.forwardRef(
|
|
|
98
101
|
]
|
|
99
102
|
}
|
|
100
103
|
),
|
|
101
|
-
/* @__PURE__ */ u(
|
|
102
|
-
/* @__PURE__ */ s(
|
|
104
|
+
/* @__PURE__ */ u(ee, { open: c, onOpenChange: k, children: [
|
|
105
|
+
/* @__PURE__ */ s(te, { asChild: !0, children: /* @__PURE__ */ u(
|
|
103
106
|
"div",
|
|
104
107
|
{
|
|
105
108
|
className: w(
|
|
@@ -118,8 +121,8 @@ const oe = d.forwardRef(
|
|
|
118
121
|
ref: T,
|
|
119
122
|
type: "text",
|
|
120
123
|
value: Y,
|
|
121
|
-
onChange:
|
|
122
|
-
onBlur:
|
|
124
|
+
onChange: K,
|
|
125
|
+
onBlur: N,
|
|
123
126
|
onClick: (e) => c && e.stopPropagation(),
|
|
124
127
|
placeholder: c ? o : "Start Week",
|
|
125
128
|
disabled: !!h,
|
|
@@ -132,8 +135,8 @@ const oe = d.forwardRef(
|
|
|
132
135
|
{
|
|
133
136
|
type: "text",
|
|
134
137
|
value: z,
|
|
135
|
-
onChange:
|
|
136
|
-
onBlur:
|
|
138
|
+
onChange: Q,
|
|
139
|
+
onBlur: N,
|
|
137
140
|
onClick: (e) => c && e.stopPropagation(),
|
|
138
141
|
placeholder: c ? o : "End Week",
|
|
139
142
|
disabled: !!h,
|
|
@@ -143,51 +146,52 @@ const oe = d.forwardRef(
|
|
|
143
146
|
] }),
|
|
144
147
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
145
148
|
n?.from && !h && /* @__PURE__ */ s(
|
|
146
|
-
|
|
149
|
+
$,
|
|
147
150
|
{
|
|
148
151
|
className: "h-4 w-4 cursor-pointer hover:text-foreground text-muted-foreground",
|
|
149
152
|
onClick: (e) => {
|
|
150
|
-
e.stopPropagation(),
|
|
153
|
+
e.stopPropagation(), R();
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
),
|
|
154
|
-
/* @__PURE__ */ s(
|
|
157
|
+
/* @__PURE__ */ s(_, { className: "h-4 w-4 text-secondary-foreground" })
|
|
155
158
|
] })
|
|
156
159
|
]
|
|
157
160
|
}
|
|
158
161
|
) }),
|
|
159
162
|
/* @__PURE__ */ s(
|
|
160
|
-
|
|
163
|
+
ne,
|
|
161
164
|
{
|
|
162
165
|
className: "w-auto p-0",
|
|
163
166
|
align: "start",
|
|
164
167
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
165
168
|
onInteractOutside: (e) => e.preventDefault(),
|
|
166
169
|
children: /* @__PURE__ */ s(
|
|
167
|
-
|
|
170
|
+
oe,
|
|
168
171
|
{
|
|
169
172
|
pickerType: "week",
|
|
170
173
|
weekMode: "range",
|
|
171
174
|
selectedWeeks: a,
|
|
172
175
|
onWeekSelect: q,
|
|
176
|
+
onPendingChange: G,
|
|
173
177
|
month: X,
|
|
174
178
|
onMonthChange: b,
|
|
175
179
|
fromDate: I,
|
|
176
180
|
toDate: V,
|
|
177
181
|
fromYear: A,
|
|
178
182
|
toYear: j,
|
|
179
|
-
showFooter:
|
|
180
|
-
onApply:
|
|
181
|
-
onCancel:
|
|
182
|
-
onClear:
|
|
183
|
+
showFooter: m,
|
|
184
|
+
onApply: H,
|
|
185
|
+
onCancel: J,
|
|
186
|
+
onClear: R,
|
|
183
187
|
captionLayout: "dropdown"
|
|
184
188
|
}
|
|
185
189
|
)
|
|
186
190
|
}
|
|
187
191
|
)
|
|
188
192
|
] }),
|
|
189
|
-
|
|
190
|
-
!x && /* @__PURE__ */ s(
|
|
193
|
+
P && /* @__PURE__ */ u("div", { className: w("flex items-center gap-1", x && "text-destructive"), children: [
|
|
194
|
+
!x && /* @__PURE__ */ s(F, { size: 10, className: "shrink-0 text-muted-foreground" }),
|
|
191
195
|
/* @__PURE__ */ s(
|
|
192
196
|
"p",
|
|
193
197
|
{
|
|
@@ -195,14 +199,14 @@ const oe = d.forwardRef(
|
|
|
195
199
|
"text-[10px] text-[#7a8294]",
|
|
196
200
|
x && "text-destructive"
|
|
197
201
|
),
|
|
198
|
-
children:
|
|
202
|
+
children: P
|
|
199
203
|
}
|
|
200
204
|
)
|
|
201
205
|
] })
|
|
202
206
|
] });
|
|
203
207
|
}
|
|
204
208
|
);
|
|
205
|
-
|
|
209
|
+
ae.displayName = "WeekRangePicker";
|
|
206
210
|
export {
|
|
207
|
-
|
|
211
|
+
ae as WeekRangePicker
|
|
208
212
|
};
|