@yuno-payments/dashboard-design-system 0.0.205 → 0.0.207
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.
|
@@ -141,7 +141,7 @@ const q = x(
|
|
|
141
141
|
b && /* @__PURE__ */ e.jsx("p", { className: "text-xs font-normal text-muted-foreground mb-4", children: b }),
|
|
142
142
|
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between mb-1", children: [
|
|
143
143
|
/* @__PURE__ */ e.jsx("span", { className: "text-sm font-normal text-foreground", children: n }),
|
|
144
|
-
c && o === "checkbox" && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-end gap-
|
|
144
|
+
c && o === "checkbox" && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-end gap-4", children: [
|
|
145
145
|
N && /* @__PURE__ */ e.jsx(
|
|
146
146
|
f,
|
|
147
147
|
{
|
|
@@ -231,6 +231,11 @@ interface FilterDropdownProps {
|
|
|
231
231
|
* Callback fired when "Clear filters" button is clicked
|
|
232
232
|
*/
|
|
233
233
|
onClearAllFilters?: () => void;
|
|
234
|
+
/**
|
|
235
|
+
* Callback fired when the dropdown open state changes
|
|
236
|
+
* Useful for applying filters only when the dropdown closes
|
|
237
|
+
*/
|
|
238
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
234
239
|
/**
|
|
235
240
|
* Text to display in the trigger button
|
|
236
241
|
* @default "Add filter"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { j as n } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { forwardRef as v, useState as E,
|
|
3
|
-
import { Button as
|
|
4
|
-
import { Separator as
|
|
5
|
-
import { Icon as
|
|
6
|
-
import { FilterSection as
|
|
7
|
-
import { FilterDateRange as
|
|
2
|
+
import { forwardRef as v, useState as E, useCallback as S, useRef as X, useEffect as Y } from "react";
|
|
3
|
+
import { Button as b } from "../../../vendor/shadcn/button.js";
|
|
4
|
+
import { Separator as k } from "../../../vendor/shadcn/separator.js";
|
|
5
|
+
import { Icon as j } from "../icon/icon.js";
|
|
6
|
+
import { FilterSection as M } from "../filter/filter.js";
|
|
7
|
+
import { FilterDateRange as $, FilterDateRangeValue as C } from "../filter/filter-date-range.js";
|
|
8
8
|
import { cn as d } from "../../../lib/utils.js";
|
|
9
|
-
const
|
|
10
|
-
({ icon: r, label: h, isActive: l = !1, showChevron: m = !1, className: u, ...o },
|
|
9
|
+
const A = v(
|
|
10
|
+
({ icon: r, label: h, isActive: l = !1, showChevron: m = !1, className: u, ...o }, p) => /* @__PURE__ */ n.jsxs(
|
|
11
11
|
"button",
|
|
12
12
|
{
|
|
13
|
-
ref:
|
|
13
|
+
ref: p,
|
|
14
14
|
className: d(
|
|
15
15
|
"flex items-center gap-2 h-8 px-2 rounded-md w-full transition-colors",
|
|
16
16
|
"hover:bg-secondary",
|
|
@@ -19,7 +19,7 @@ const M = v(
|
|
|
19
19
|
...o,
|
|
20
20
|
children: [
|
|
21
21
|
r && /* @__PURE__ */ n.jsx(
|
|
22
|
-
|
|
22
|
+
j,
|
|
23
23
|
{
|
|
24
24
|
name: r,
|
|
25
25
|
className: d(
|
|
@@ -39,7 +39,7 @@ const M = v(
|
|
|
39
39
|
}
|
|
40
40
|
),
|
|
41
41
|
(l || m) && /* @__PURE__ */ n.jsx(
|
|
42
|
-
|
|
42
|
+
j,
|
|
43
43
|
{
|
|
44
44
|
name: "CaretRight",
|
|
45
45
|
className: d(
|
|
@@ -52,8 +52,8 @@ const M = v(
|
|
|
52
52
|
}
|
|
53
53
|
)
|
|
54
54
|
);
|
|
55
|
-
|
|
56
|
-
const
|
|
55
|
+
A.displayName = "FilterMenuItem";
|
|
56
|
+
const V = v(
|
|
57
57
|
({ items: r, activeItemId: h, onItemClick: l, className: m }, u) => /* @__PURE__ */ n.jsx(
|
|
58
58
|
"div",
|
|
59
59
|
{
|
|
@@ -63,7 +63,7 @@ const A = v(
|
|
|
63
63
|
m
|
|
64
64
|
),
|
|
65
65
|
children: r.map((o) => /* @__PURE__ */ n.jsx(
|
|
66
|
-
|
|
66
|
+
A,
|
|
67
67
|
{
|
|
68
68
|
icon: o.icon,
|
|
69
69
|
label: o.label,
|
|
@@ -76,70 +76,76 @@ const A = v(
|
|
|
76
76
|
}
|
|
77
77
|
)
|
|
78
78
|
);
|
|
79
|
-
|
|
80
|
-
const
|
|
79
|
+
V.displayName = "FilterMenu";
|
|
80
|
+
const q = v(
|
|
81
81
|
({
|
|
82
82
|
filters: r,
|
|
83
83
|
buttonText: h = "Add filter",
|
|
84
84
|
appliedFilters: l = [],
|
|
85
85
|
onRemoveFilter: m,
|
|
86
86
|
onClearAllFilters: u,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
onOpenChange: o,
|
|
88
|
+
maxVisibleTags: p = 4,
|
|
89
|
+
className: z,
|
|
90
|
+
disabled: O = !1
|
|
90
91
|
}, f) => {
|
|
91
|
-
const [
|
|
92
|
+
const [x, R] = E(!1), g = S(
|
|
93
|
+
(t) => {
|
|
94
|
+
R(t), o?.(t);
|
|
95
|
+
},
|
|
96
|
+
[o]
|
|
97
|
+
), [w, N] = E(
|
|
92
98
|
r.length > 0 && r[0]?.id || ""
|
|
93
|
-
), y =
|
|
99
|
+
), y = X(null), L = S(
|
|
94
100
|
(t) => {
|
|
95
101
|
y.current = t, typeof f == "function" ? f(t) : f && (f.current = t);
|
|
96
102
|
},
|
|
97
103
|
[f]
|
|
98
104
|
);
|
|
99
|
-
|
|
100
|
-
if (!
|
|
105
|
+
Y(() => {
|
|
106
|
+
if (!x) return;
|
|
101
107
|
const t = (s) => {
|
|
102
108
|
const c = s.target;
|
|
103
109
|
y.current?.contains(c) || c.closest?.(
|
|
104
110
|
"[data-radix-popper-content-wrapper], [data-radix-portal]"
|
|
105
111
|
) || c.closest?.(
|
|
106
112
|
".rdp, .rdp-root, [data-calendar]"
|
|
107
|
-
) ||
|
|
113
|
+
) || g(!1);
|
|
108
114
|
}, a = (s) => {
|
|
109
|
-
s.key === "Escape" &&
|
|
115
|
+
s.key === "Escape" && g(!1);
|
|
110
116
|
}, i = setTimeout(() => {
|
|
111
117
|
document.addEventListener("mousedown", t), document.addEventListener("keydown", a);
|
|
112
118
|
}, 0);
|
|
113
119
|
return () => {
|
|
114
120
|
clearTimeout(i), document.removeEventListener("mousedown", t), document.removeEventListener("keydown", a);
|
|
115
121
|
};
|
|
116
|
-
}, [
|
|
117
|
-
const
|
|
122
|
+
}, [x]);
|
|
123
|
+
const P = l.length > 0, U = l.slice(0, p), I = l.length - p, T = (t) => {
|
|
118
124
|
if (r.find((s) => s.id === t)) return t;
|
|
119
125
|
const i = t.split("-");
|
|
120
126
|
if (i.length > 1) {
|
|
121
127
|
const s = i[0];
|
|
122
|
-
if (r.find((
|
|
128
|
+
if (r.find((F) => F.id === s)) return s;
|
|
123
129
|
}
|
|
124
130
|
return t;
|
|
125
|
-
},
|
|
126
|
-
const a =
|
|
131
|
+
}, D = (t) => {
|
|
132
|
+
const a = T(t);
|
|
127
133
|
return r.find((s) => s.id === a)?.clearable !== !1;
|
|
128
|
-
},
|
|
129
|
-
const a =
|
|
130
|
-
N(a),
|
|
131
|
-
},
|
|
132
|
-
(t) =>
|
|
133
|
-
),
|
|
134
|
+
}, B = (t) => {
|
|
135
|
+
const a = T(t);
|
|
136
|
+
N(a), g(!0);
|
|
137
|
+
}, H = l.some(
|
|
138
|
+
(t) => D(t.id)
|
|
139
|
+
), _ = r.map((t) => ({
|
|
134
140
|
id: t.id,
|
|
135
141
|
icon: t.icon,
|
|
136
142
|
label: t.label
|
|
137
|
-
})), e = r.find((t) => t.id === w),
|
|
143
|
+
})), e = r.find((t) => t.id === w), K = () => {
|
|
138
144
|
if (!e) return null;
|
|
139
145
|
switch (e.type) {
|
|
140
146
|
case "checkbox":
|
|
141
147
|
return /* @__PURE__ */ n.jsx(
|
|
142
|
-
|
|
148
|
+
M,
|
|
143
149
|
{
|
|
144
150
|
title: e.label,
|
|
145
151
|
items: e.items || [],
|
|
@@ -157,7 +163,7 @@ const Y = v(
|
|
|
157
163
|
);
|
|
158
164
|
case "radio":
|
|
159
165
|
return /* @__PURE__ */ n.jsx(
|
|
160
|
-
|
|
166
|
+
M,
|
|
161
167
|
{
|
|
162
168
|
type: "radio",
|
|
163
169
|
title: e.label,
|
|
@@ -176,7 +182,7 @@ const Y = v(
|
|
|
176
182
|
);
|
|
177
183
|
case "date": {
|
|
178
184
|
const t = (a) => {
|
|
179
|
-
if (e.onDateValueChange?.(a), a ===
|
|
185
|
+
if (e.onDateValueChange?.(a), a === C.CUSTOM && !e.dateInit && !e.dateEnd) {
|
|
180
186
|
const i = /* @__PURE__ */ new Date(), s = new Date(i);
|
|
181
187
|
s.setHours(23, 59, 59, 999);
|
|
182
188
|
const c = new Date(i);
|
|
@@ -184,13 +190,13 @@ const Y = v(
|
|
|
184
190
|
}
|
|
185
191
|
};
|
|
186
192
|
return /* @__PURE__ */ n.jsx(
|
|
187
|
-
|
|
193
|
+
$,
|
|
188
194
|
{
|
|
189
|
-
value: e.dateValue ||
|
|
195
|
+
value: e.dateValue || C.LAST_7_DAYS,
|
|
190
196
|
onValueChange: t,
|
|
191
|
-
showCustomFields: e.dateValue ===
|
|
197
|
+
showCustomFields: e.dateValue === C.CUSTOM,
|
|
192
198
|
onCustomFieldsChange: (a) => {
|
|
193
|
-
a && t(
|
|
199
|
+
a && t(C.CUSTOM);
|
|
194
200
|
},
|
|
195
201
|
startDate: e.dateInit,
|
|
196
202
|
endDate: e.dateEnd,
|
|
@@ -215,34 +221,34 @@ const Y = v(
|
|
|
215
221
|
return /* @__PURE__ */ n.jsxs(
|
|
216
222
|
"div",
|
|
217
223
|
{
|
|
218
|
-
ref:
|
|
219
|
-
className: d("flex flex-col gap-1 relative",
|
|
224
|
+
ref: L,
|
|
225
|
+
className: d("flex flex-col gap-1 relative", z),
|
|
220
226
|
children: [
|
|
221
227
|
/* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
222
228
|
/* @__PURE__ */ n.jsxs(
|
|
223
|
-
|
|
229
|
+
b,
|
|
224
230
|
{
|
|
225
231
|
variant: "outline",
|
|
226
232
|
size: "sm",
|
|
227
233
|
className: "gap-2",
|
|
228
|
-
onClick: () =>
|
|
229
|
-
disabled:
|
|
234
|
+
onClick: () => g(!x),
|
|
235
|
+
disabled: O,
|
|
230
236
|
children: [
|
|
231
|
-
/* @__PURE__ */ n.jsx(
|
|
237
|
+
/* @__PURE__ */ n.jsx(j, { name: "FunnelSimple", className: "size-4" }),
|
|
232
238
|
h
|
|
233
239
|
]
|
|
234
240
|
}
|
|
235
241
|
),
|
|
236
|
-
|
|
237
|
-
/* @__PURE__ */ n.jsx(
|
|
242
|
+
P ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
243
|
+
/* @__PURE__ */ n.jsx(k, { orientation: "vertical", className: "h-5" }),
|
|
238
244
|
/* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
239
|
-
|
|
240
|
-
const a =
|
|
245
|
+
U.map((t) => {
|
|
246
|
+
const a = D(t.id);
|
|
241
247
|
return /* @__PURE__ */ n.jsxs(
|
|
242
|
-
|
|
248
|
+
b,
|
|
243
249
|
{
|
|
244
250
|
variant: "secondary",
|
|
245
|
-
onClick: () =>
|
|
251
|
+
onClick: () => B(t.id),
|
|
246
252
|
className: "display-flex items-center gap-2",
|
|
247
253
|
size: "sm",
|
|
248
254
|
children: [
|
|
@@ -255,7 +261,7 @@ const Y = v(
|
|
|
255
261
|
},
|
|
256
262
|
className: "inline-flex items-center justify-center",
|
|
257
263
|
"aria-label": `Remove ${t.label} filter`,
|
|
258
|
-
children: /* @__PURE__ */ n.jsx(
|
|
264
|
+
children: /* @__PURE__ */ n.jsx(j, { name: "X", className: "size-4" })
|
|
259
265
|
}
|
|
260
266
|
)
|
|
261
267
|
]
|
|
@@ -263,13 +269,13 @@ const Y = v(
|
|
|
263
269
|
t.id
|
|
264
270
|
);
|
|
265
271
|
}),
|
|
266
|
-
|
|
272
|
+
I > 0 && /* @__PURE__ */ n.jsxs(b, { children: [
|
|
267
273
|
"+",
|
|
268
|
-
|
|
274
|
+
I,
|
|
269
275
|
" more"
|
|
270
276
|
] }),
|
|
271
|
-
u &&
|
|
272
|
-
|
|
277
|
+
u && H && /* @__PURE__ */ n.jsx(
|
|
278
|
+
b,
|
|
273
279
|
{
|
|
274
280
|
variant: "ghost",
|
|
275
281
|
size: "sm",
|
|
@@ -280,11 +286,11 @@ const Y = v(
|
|
|
280
286
|
)
|
|
281
287
|
] })
|
|
282
288
|
] }) : /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
283
|
-
/* @__PURE__ */ n.jsx(
|
|
289
|
+
/* @__PURE__ */ n.jsx(k, { orientation: "vertical", className: "h-5" }),
|
|
284
290
|
/* @__PURE__ */ n.jsx("span", { className: "text-sm font-normal text-muted-foreground", children: "No filters applied" })
|
|
285
291
|
] })
|
|
286
292
|
] }),
|
|
287
|
-
|
|
293
|
+
x && /* @__PURE__ */ n.jsxs(
|
|
288
294
|
"div",
|
|
289
295
|
{
|
|
290
296
|
className: d(
|
|
@@ -296,14 +302,14 @@ const Y = v(
|
|
|
296
302
|
),
|
|
297
303
|
children: [
|
|
298
304
|
/* @__PURE__ */ n.jsx(
|
|
299
|
-
|
|
305
|
+
V,
|
|
300
306
|
{
|
|
301
|
-
items:
|
|
307
|
+
items: _,
|
|
302
308
|
activeItemId: w,
|
|
303
309
|
onItemClick: N
|
|
304
310
|
}
|
|
305
311
|
),
|
|
306
|
-
/* @__PURE__ */ n.jsx("div", { className: "flex flex-col gap-4 p-6 bg-popover w-[448px] h-full rounded-md overflow-y-auto", children:
|
|
312
|
+
/* @__PURE__ */ n.jsx("div", { className: "flex flex-col gap-4 p-6 bg-popover w-[448px] h-full rounded-md overflow-y-auto", children: K() })
|
|
307
313
|
]
|
|
308
314
|
}
|
|
309
315
|
)
|
|
@@ -312,9 +318,9 @@ const Y = v(
|
|
|
312
318
|
);
|
|
313
319
|
}
|
|
314
320
|
);
|
|
315
|
-
|
|
321
|
+
q.displayName = "FilterDropdown";
|
|
316
322
|
export {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
323
|
+
q as FilterDropdown,
|
|
324
|
+
V as FilterMenu,
|
|
325
|
+
A as FilterMenuItem
|
|
320
326
|
};
|