@yuno-payments/dashboard-design-system 1.1.2-beta.3 → 1.1.2
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.
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { j as o } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { forwardRef as S, useState as
|
|
3
|
-
import { Button as
|
|
2
|
+
import { forwardRef as S, useState as E, useRef as F, useCallback as k, useEffect as Y } from "react";
|
|
3
|
+
import { Button as T } from "../../../vendor/shadcn/button.js";
|
|
4
4
|
import { Separator as $ } from "../../../vendor/shadcn/separator.js";
|
|
5
|
-
import { Icon as
|
|
5
|
+
import { Icon as j } from "../icon/icon.js";
|
|
6
6
|
import { FilterSection as q } from "../filter/filter.js";
|
|
7
|
-
import { FilterDateRangeValue as
|
|
7
|
+
import { FilterDateRangeValue as N, FilterDateRange as ke } from "../filter/filter-date-range.js";
|
|
8
8
|
import { cn as h } from "../../../lib/utils.js";
|
|
9
9
|
const G = S(
|
|
10
|
-
({ icon:
|
|
10
|
+
({ icon: d, label: p, isActive: l = !1, showChevron: g = !1, className: b, ...u }, V) => /* @__PURE__ */ o.jsxs(
|
|
11
11
|
"button",
|
|
12
12
|
{
|
|
13
|
-
ref:
|
|
13
|
+
ref: V,
|
|
14
14
|
className: h(
|
|
15
15
|
"flex items-center gap-2 h-8 px-2 rounded-md w-full transition-colors shrink-0 hover:bg-secondary",
|
|
16
16
|
b
|
|
17
17
|
),
|
|
18
18
|
...u,
|
|
19
19
|
children: [
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
d && /* @__PURE__ */ o.jsx(
|
|
21
|
+
j,
|
|
22
22
|
{
|
|
23
|
-
name:
|
|
23
|
+
name: d,
|
|
24
24
|
className: h(
|
|
25
25
|
"size-4 shrink-0",
|
|
26
|
-
|
|
26
|
+
l ? "text-primary" : "text-foreground"
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
29
|
),
|
|
@@ -32,18 +32,18 @@ const G = S(
|
|
|
32
32
|
{
|
|
33
33
|
className: h(
|
|
34
34
|
"flex-1 text-sm font-normal text-left truncate",
|
|
35
|
-
|
|
35
|
+
l ? "text-primary" : "text-foreground"
|
|
36
36
|
),
|
|
37
|
-
children:
|
|
37
|
+
children: p
|
|
38
38
|
}
|
|
39
39
|
),
|
|
40
|
-
(
|
|
41
|
-
|
|
40
|
+
(l || g) && /* @__PURE__ */ o.jsx(
|
|
41
|
+
j,
|
|
42
42
|
{
|
|
43
43
|
name: "CaretRight",
|
|
44
44
|
className: h(
|
|
45
45
|
"size-4 shrink-0",
|
|
46
|
-
|
|
46
|
+
l ? "text-primary" : "text-foreground"
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
49
|
)
|
|
@@ -53,7 +53,7 @@ const G = S(
|
|
|
53
53
|
);
|
|
54
54
|
G.displayName = "FilterMenuItem";
|
|
55
55
|
const J = S(
|
|
56
|
-
({ items:
|
|
56
|
+
({ items: d, activeItemId: p, onItemClick: l, className: g }, b) => /* @__PURE__ */ o.jsx(
|
|
57
57
|
"div",
|
|
58
58
|
{
|
|
59
59
|
ref: b,
|
|
@@ -61,14 +61,14 @@ const J = S(
|
|
|
61
61
|
"flex flex-col gap-2 w-64 h-full p-2 bg-muted border border-border rounded-md overflow-y-auto",
|
|
62
62
|
g
|
|
63
63
|
),
|
|
64
|
-
children:
|
|
64
|
+
children: d.map((u) => /* @__PURE__ */ o.jsx(
|
|
65
65
|
G,
|
|
66
66
|
{
|
|
67
67
|
icon: u.icon,
|
|
68
68
|
label: u.label,
|
|
69
|
-
isActive:
|
|
69
|
+
isActive: p === u.id,
|
|
70
70
|
showChevron: u.showChevron,
|
|
71
|
-
onClick: () =>
|
|
71
|
+
onClick: () => l?.(u.id)
|
|
72
72
|
},
|
|
73
73
|
u.id
|
|
74
74
|
))
|
|
@@ -76,37 +76,37 @@ const J = S(
|
|
|
76
76
|
)
|
|
77
77
|
);
|
|
78
78
|
J.displayName = "FilterMenu";
|
|
79
|
-
const
|
|
79
|
+
const Te = S(
|
|
80
80
|
({
|
|
81
|
-
filters:
|
|
82
|
-
buttonText:
|
|
83
|
-
appliedFilters:
|
|
81
|
+
filters: d,
|
|
82
|
+
buttonText: p = "Add filter",
|
|
83
|
+
appliedFilters: l = [],
|
|
84
84
|
onRemoveFilter: g,
|
|
85
85
|
onClearAllFilters: b,
|
|
86
86
|
onOpenChange: u,
|
|
87
|
-
maxVisibleTags:
|
|
87
|
+
maxVisibleTags: V = 4,
|
|
88
88
|
className: Q,
|
|
89
89
|
disabled: Z = !1,
|
|
90
90
|
applyOnClose: s = !1
|
|
91
|
-
},
|
|
92
|
-
const [f, O] =
|
|
91
|
+
}, C) => {
|
|
92
|
+
const [f, O] = E(!1), [m, ee] = E({}), D = F({}), I = F(d), c = k(
|
|
93
93
|
(e) => {
|
|
94
94
|
ee((r) => {
|
|
95
95
|
const a = typeof e == "function" ? e(r) : e;
|
|
96
|
-
return
|
|
96
|
+
return D.current = a, a;
|
|
97
97
|
});
|
|
98
98
|
},
|
|
99
99
|
[]
|
|
100
100
|
);
|
|
101
101
|
Y(() => {
|
|
102
|
-
|
|
103
|
-
}, [
|
|
104
|
-
const
|
|
102
|
+
I.current = d;
|
|
103
|
+
}, [d]);
|
|
104
|
+
const y = k(() => {
|
|
105
105
|
if (console.log("[FilterDropdown] applyBufferedChanges called", {
|
|
106
106
|
applyOnClose: s,
|
|
107
|
-
bufferedChanges:
|
|
107
|
+
bufferedChanges: D.current
|
|
108
108
|
}), !s) return;
|
|
109
|
-
const e =
|
|
109
|
+
const e = D.current, r = I.current;
|
|
110
110
|
console.log("[FilterDropdown] Processing buffered changes", {
|
|
111
111
|
changesCount: Object.keys(e).length,
|
|
112
112
|
changes: e,
|
|
@@ -128,69 +128,69 @@ const Ve = S(
|
|
|
128
128
|
n.customValue !== void 0 && i.onCustomChange?.(n.customValue);
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
131
|
-
}),
|
|
132
|
-
}, [s,
|
|
131
|
+
}), c({});
|
|
132
|
+
}, [s, c]), w = k(
|
|
133
133
|
(e) => {
|
|
134
134
|
console.log("[FilterDropdown] setIsOpen called", {
|
|
135
135
|
open: e,
|
|
136
136
|
isOpen: f,
|
|
137
137
|
applyOnClose: s,
|
|
138
|
-
bufferedChanges:
|
|
139
|
-
}), !e && f && s && (console.log("[FilterDropdown] Applying buffered changes on close",
|
|
138
|
+
bufferedChanges: D.current
|
|
139
|
+
}), !e && f && s && (console.log("[FilterDropdown] Applying buffered changes on close", D.current), y()), e && !f && s && (console.log("[FilterDropdown] Clearing buffered changes on open"), c({})), O(e), u?.(e);
|
|
140
140
|
},
|
|
141
|
-
[u, f, s,
|
|
142
|
-
), [
|
|
143
|
-
|
|
144
|
-
),
|
|
141
|
+
[u, f, s, y, c]
|
|
142
|
+
), [B, A] = E(
|
|
143
|
+
d.length > 0 && d[0]?.id || ""
|
|
144
|
+
), M = F(null), te = k(
|
|
145
145
|
(e) => {
|
|
146
|
-
|
|
146
|
+
M.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
|
|
147
147
|
},
|
|
148
|
-
[
|
|
148
|
+
[C]
|
|
149
149
|
);
|
|
150
150
|
Y(() => {
|
|
151
151
|
if (!f) return;
|
|
152
152
|
const e = (n) => {
|
|
153
153
|
const i = n.target;
|
|
154
|
-
|
|
154
|
+
M.current?.contains(i) || i.closest?.(
|
|
155
155
|
"[data-radix-popper-content-wrapper], [data-radix-portal]"
|
|
156
156
|
) || i.closest?.(
|
|
157
157
|
".rdp, .rdp-root, [data-calendar]"
|
|
158
|
-
) ||
|
|
158
|
+
) || w(!1);
|
|
159
159
|
}, r = (n) => {
|
|
160
|
-
n.key === "Escape" &&
|
|
160
|
+
n.key === "Escape" && w(!1);
|
|
161
161
|
}, a = setTimeout(() => {
|
|
162
162
|
document.addEventListener("mousedown", e), document.addEventListener("keydown", r);
|
|
163
163
|
}, 0);
|
|
164
164
|
return () => {
|
|
165
165
|
clearTimeout(a), document.removeEventListener("mousedown", e), document.removeEventListener("keydown", r);
|
|
166
166
|
};
|
|
167
|
-
}, [f,
|
|
168
|
-
const ne =
|
|
169
|
-
if (
|
|
167
|
+
}, [f, w]);
|
|
168
|
+
const ne = l.length > 0, re = l.slice(0, V), R = l.length - V, H = (e) => {
|
|
169
|
+
if (d.find((n) => n.id === e)) return e;
|
|
170
170
|
const a = e.split("-");
|
|
171
171
|
if (a.length > 1) {
|
|
172
172
|
const n = a[0];
|
|
173
|
-
if (
|
|
173
|
+
if (d.find((x) => x.id === n)) return n;
|
|
174
174
|
}
|
|
175
175
|
return e;
|
|
176
176
|
}, P = (e) => {
|
|
177
177
|
const r = H(e);
|
|
178
|
-
return
|
|
178
|
+
return d.find((n) => n.id === r)?.clearable !== !1;
|
|
179
179
|
}, ae = (e) => {
|
|
180
180
|
const r = H(e);
|
|
181
|
-
A(r),
|
|
182
|
-
}, oe =
|
|
181
|
+
A(r), w(!0);
|
|
182
|
+
}, oe = l.some(
|
|
183
183
|
(e) => P(e.id)
|
|
184
|
-
), se =
|
|
184
|
+
), se = d.map((e) => ({
|
|
185
185
|
id: e.id,
|
|
186
186
|
icon: e.icon,
|
|
187
187
|
label: e.label
|
|
188
|
-
})), t =
|
|
188
|
+
})), t = d.find((e) => e.id === B), ie = (e, r) => s ? m[e]?.checkboxValues ?? r : r, de = (e, r) => s ? m[e]?.radioValue ?? r : r, ce = (e, r) => s ? m[e]?.dateValue ?? r : r, le = (e, r) => s ? m[e]?.dateInit ?? r : r, ue = (e, r) => s ? m[e]?.dateEnd ?? r : r, fe = (e, r) => s ? m[e]?.startTime ?? r : r, me = (e, r) => s ? m[e]?.endTime ?? r : r, he = (e, r, a) => (n) => {
|
|
189
189
|
if (console.log("[FilterDropdown] Checkbox handler called", { filterId: e, values: n, applyOnClose: s, minSelection: a }), a !== void 0 && a > 0 && n.length < a) {
|
|
190
190
|
console.log("[FilterDropdown] Blocked: minimum selection not met", { minSelection: a, actualLength: n.length });
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
|
-
s ? (console.log("[FilterDropdown] Buffering checkbox values", { filterId: e, values: n }),
|
|
193
|
+
s ? (console.log("[FilterDropdown] Buffering checkbox values", { filterId: e, values: n }), c((i) => ({
|
|
194
194
|
...i,
|
|
195
195
|
[e]: {
|
|
196
196
|
...i[e],
|
|
@@ -199,7 +199,7 @@ const Ve = S(
|
|
|
199
199
|
}
|
|
200
200
|
}))) : r?.(n);
|
|
201
201
|
}, ge = (e, r) => (a) => {
|
|
202
|
-
s ?
|
|
202
|
+
s ? c((n) => ({
|
|
203
203
|
...n,
|
|
204
204
|
[e]: {
|
|
205
205
|
...n[e],
|
|
@@ -208,7 +208,7 @@ const Ve = S(
|
|
|
208
208
|
}
|
|
209
209
|
})) : r?.(a);
|
|
210
210
|
}, be = (e, r) => (a) => {
|
|
211
|
-
s ?
|
|
211
|
+
s ? c((n) => ({
|
|
212
212
|
...n,
|
|
213
213
|
[e]: {
|
|
214
214
|
...n[e],
|
|
@@ -217,7 +217,7 @@ const Ve = S(
|
|
|
217
217
|
}
|
|
218
218
|
})) : r?.(a);
|
|
219
219
|
}, xe = (e, r) => (a) => {
|
|
220
|
-
s ?
|
|
220
|
+
s ? c((n) => ({
|
|
221
221
|
...n,
|
|
222
222
|
[e]: {
|
|
223
223
|
...n[e],
|
|
@@ -225,8 +225,8 @@ const Ve = S(
|
|
|
225
225
|
dateInit: a
|
|
226
226
|
}
|
|
227
227
|
})) : r?.(a);
|
|
228
|
-
},
|
|
229
|
-
s ?
|
|
228
|
+
}, pe = (e, r) => (a) => {
|
|
229
|
+
s ? c((n) => ({
|
|
230
230
|
...n,
|
|
231
231
|
[e]: {
|
|
232
232
|
...n[e],
|
|
@@ -234,8 +234,8 @@ const Ve = S(
|
|
|
234
234
|
dateEnd: a
|
|
235
235
|
}
|
|
236
236
|
})) : r?.(a);
|
|
237
|
-
},
|
|
238
|
-
|
|
237
|
+
}, Ce = (e, r) => (a) => {
|
|
238
|
+
s ? c((n) => ({
|
|
239
239
|
...n,
|
|
240
240
|
[e]: {
|
|
241
241
|
...n[e],
|
|
@@ -243,8 +243,8 @@ const Ve = S(
|
|
|
243
243
|
startTime: a
|
|
244
244
|
}
|
|
245
245
|
})) : r?.(a);
|
|
246
|
-
},
|
|
247
|
-
|
|
246
|
+
}, De = (e, r) => (a) => {
|
|
247
|
+
s ? c((n) => ({
|
|
248
248
|
...n,
|
|
249
249
|
[e]: {
|
|
250
250
|
...n[e],
|
|
@@ -252,7 +252,7 @@ const Ve = S(
|
|
|
252
252
|
endTime: a
|
|
253
253
|
}
|
|
254
254
|
})) : r?.(a);
|
|
255
|
-
},
|
|
255
|
+
}, we = () => {
|
|
256
256
|
if (!t) return null;
|
|
257
257
|
switch (t.type) {
|
|
258
258
|
case "checkbox": {
|
|
@@ -284,7 +284,7 @@ const Ve = S(
|
|
|
284
284
|
type: "radio",
|
|
285
285
|
title: t.label,
|
|
286
286
|
items: t.items || [],
|
|
287
|
-
selectedValue:
|
|
287
|
+
selectedValue: de(
|
|
288
288
|
t.id,
|
|
289
289
|
t.selectedValue || ""
|
|
290
290
|
),
|
|
@@ -299,39 +299,38 @@ const Ve = S(
|
|
|
299
299
|
}
|
|
300
300
|
);
|
|
301
301
|
case "date": {
|
|
302
|
-
const e =
|
|
302
|
+
const e = ce(
|
|
303
303
|
t.id,
|
|
304
|
-
t.dateValue ||
|
|
305
|
-
), r =
|
|
304
|
+
t.dateValue || N.LAST_7_DAYS
|
|
305
|
+
), r = le(t.id, t.dateInit), a = ue(t.id, t.dateEnd), n = fe(t.id, t.startTime || ""), i = me(t.id, t.endTime || ""), x = be(
|
|
306
306
|
t.id,
|
|
307
307
|
t.onDateValueChange
|
|
308
|
-
),
|
|
308
|
+
), v = xe(
|
|
309
309
|
t.id,
|
|
310
310
|
t.onDateInitChange
|
|
311
|
-
),
|
|
311
|
+
), z = pe(
|
|
312
312
|
t.id,
|
|
313
313
|
t.onDateEndChange
|
|
314
|
-
),
|
|
314
|
+
), L = Ce(
|
|
315
315
|
t.id,
|
|
316
316
|
t.onStartTimeChange
|
|
317
|
-
),
|
|
317
|
+
), U = De(
|
|
318
318
|
t.id,
|
|
319
319
|
t.onEndTimeChange
|
|
320
|
-
),
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
X.setHours(0, 0, 0, 0), j(X), L(K), n || (console.log("[FilterDropdown] Initializing start time"), U("00:00:00")), i || (console.log("[FilterDropdown] Initializing end time"), W("23:59:59"));
|
|
320
|
+
), Ve = (_) => {
|
|
321
|
+
if (x(_), _ === N.CUSTOM && !r && !a) {
|
|
322
|
+
const K = /* @__PURE__ */ new Date(), W = new Date(K);
|
|
323
|
+
W.setHours(23, 59, 59, 999);
|
|
324
|
+
const X = new Date(K);
|
|
325
|
+
X.setHours(0, 0, 0, 0), v(X), z(W), n || L("00:00:00"), i || U("23:59:59");
|
|
327
326
|
}
|
|
328
327
|
};
|
|
329
328
|
return /* @__PURE__ */ o.jsx(
|
|
330
|
-
|
|
329
|
+
ke,
|
|
331
330
|
{
|
|
332
331
|
value: e,
|
|
333
|
-
onValueChange:
|
|
334
|
-
showCustomFields: e ===
|
|
332
|
+
onValueChange: Ve,
|
|
333
|
+
showCustomFields: e === N.CUSTOM,
|
|
335
334
|
startDate: r,
|
|
336
335
|
endDate: a,
|
|
337
336
|
startTime: n,
|
|
@@ -339,10 +338,10 @@ const Ve = S(
|
|
|
339
338
|
mode: t.dateMode || "range",
|
|
340
339
|
singleDayLabel: t.singleDayLabel,
|
|
341
340
|
showAllTime: t.showAllTime,
|
|
342
|
-
onStartDateChange:
|
|
343
|
-
onEndDateChange:
|
|
344
|
-
onStartTimeChange:
|
|
345
|
-
onEndTimeChange:
|
|
341
|
+
onStartDateChange: v,
|
|
342
|
+
onEndDateChange: z,
|
|
343
|
+
onStartTimeChange: L,
|
|
344
|
+
onEndTimeChange: U,
|
|
346
345
|
announcement: t.description
|
|
347
346
|
}
|
|
348
347
|
);
|
|
@@ -351,7 +350,7 @@ const Ve = S(
|
|
|
351
350
|
const e = s ? {
|
|
352
351
|
bufferedValue: m[t.id]?.customValue,
|
|
353
352
|
onDeferredChange: (r) => {
|
|
354
|
-
|
|
353
|
+
c((a) => ({
|
|
355
354
|
...a,
|
|
356
355
|
[t.id]: {
|
|
357
356
|
...a[t.id],
|
|
@@ -376,16 +375,16 @@ const Ve = S(
|
|
|
376
375
|
children: [
|
|
377
376
|
/* @__PURE__ */ o.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
378
377
|
/* @__PURE__ */ o.jsxs(
|
|
379
|
-
|
|
378
|
+
T,
|
|
380
379
|
{
|
|
381
380
|
variant: "outline",
|
|
382
381
|
size: "sm",
|
|
383
382
|
className: "gap-2",
|
|
384
|
-
onClick: () =>
|
|
383
|
+
onClick: () => w(!f),
|
|
385
384
|
disabled: Z,
|
|
386
385
|
children: [
|
|
387
|
-
/* @__PURE__ */ o.jsx(
|
|
388
|
-
|
|
386
|
+
/* @__PURE__ */ o.jsx(j, { name: "FunnelSimple", className: "size-4" }),
|
|
387
|
+
p
|
|
389
388
|
]
|
|
390
389
|
}
|
|
391
390
|
),
|
|
@@ -395,7 +394,7 @@ const Ve = S(
|
|
|
395
394
|
re.map((e) => {
|
|
396
395
|
const r = P(e.id);
|
|
397
396
|
return /* @__PURE__ */ o.jsxs(
|
|
398
|
-
|
|
397
|
+
T,
|
|
399
398
|
{
|
|
400
399
|
variant: "secondary",
|
|
401
400
|
onClick: () => ae(e.id),
|
|
@@ -411,7 +410,7 @@ const Ve = S(
|
|
|
411
410
|
},
|
|
412
411
|
className: "inline-flex items-center justify-center",
|
|
413
412
|
"aria-label": `Remove ${e.label} filter`,
|
|
414
|
-
children: /* @__PURE__ */ o.jsx(
|
|
413
|
+
children: /* @__PURE__ */ o.jsx(j, { name: "X", className: "size-4" })
|
|
415
414
|
}
|
|
416
415
|
)
|
|
417
416
|
]
|
|
@@ -419,13 +418,13 @@ const Ve = S(
|
|
|
419
418
|
e.id
|
|
420
419
|
);
|
|
421
420
|
}),
|
|
422
|
-
|
|
421
|
+
R > 0 && /* @__PURE__ */ o.jsxs(T, { children: [
|
|
423
422
|
"+",
|
|
424
|
-
|
|
423
|
+
R,
|
|
425
424
|
" more"
|
|
426
425
|
] }),
|
|
427
426
|
b && oe && /* @__PURE__ */ o.jsx(
|
|
428
|
-
|
|
427
|
+
T,
|
|
429
428
|
{
|
|
430
429
|
variant: "ghost",
|
|
431
430
|
size: "sm",
|
|
@@ -455,11 +454,11 @@ const Ve = S(
|
|
|
455
454
|
J,
|
|
456
455
|
{
|
|
457
456
|
items: se,
|
|
458
|
-
activeItemId:
|
|
457
|
+
activeItemId: B,
|
|
459
458
|
onItemClick: A
|
|
460
459
|
}
|
|
461
460
|
),
|
|
462
|
-
/* @__PURE__ */ o.jsx("div", { className: "flex flex-col gap-4 p-6 bg-popover w-[448px] h-full rounded-md overflow-y-auto", children:
|
|
461
|
+
/* @__PURE__ */ o.jsx("div", { className: "flex flex-col gap-4 p-6 bg-popover w-[448px] h-full rounded-md overflow-y-auto", children: we() })
|
|
463
462
|
]
|
|
464
463
|
}
|
|
465
464
|
)
|
|
@@ -468,9 +467,9 @@ const Ve = S(
|
|
|
468
467
|
);
|
|
469
468
|
}
|
|
470
469
|
);
|
|
471
|
-
|
|
470
|
+
Te.displayName = "FilterDropdown";
|
|
472
471
|
export {
|
|
473
|
-
|
|
472
|
+
Te as FilterDropdown,
|
|
474
473
|
J as FilterMenu,
|
|
475
474
|
G as FilterMenuItem
|
|
476
475
|
};
|