@yuno-payments/dashboard-design-system 0.0.206 → 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.
@@ -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, useRef as H, useCallback as _, useEffect as K } from "react";
3
- import { Button as g } from "../../../vendor/shadcn/button.js";
4
- import { Separator as S } from "../../../vendor/shadcn/separator.js";
5
- import { Icon as C } from "../icon/icon.js";
6
- import { FilterSection as k } from "../filter/filter.js";
7
- import { FilterDateRange as X, FilterDateRangeValue as b } from "../filter/filter-date-range.js";
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 M = v(
10
- ({ icon: r, label: h, isActive: l = !1, showChevron: m = !1, className: u, ...o }, j) => /* @__PURE__ */ n.jsxs(
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: j,
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
- C,
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
- C,
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
- M.displayName = "FilterMenuItem";
56
- const A = v(
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
- M,
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
- A.displayName = "FilterMenu";
80
- const Y = v(
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
- maxVisibleTags: o = 4,
88
- className: j,
89
- disabled: V = !1
87
+ onOpenChange: o,
88
+ maxVisibleTags: p = 4,
89
+ className: z,
90
+ disabled: O = !1
90
91
  }, f) => {
91
- const [p, x] = E(!1), [w, N] = E(
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 = H(null), z = _(
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
- K(() => {
100
- if (!p) return;
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
- ) || x(!1);
113
+ ) || g(!1);
108
114
  }, a = (s) => {
109
- s.key === "Escape" && x(!1);
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
- }, [p]);
117
- const O = l.length > 0, R = l.slice(0, o), T = l.length - o, D = (t) => {
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((I) => I.id === s)) return s;
128
+ if (r.find((F) => F.id === s)) return s;
123
129
  }
124
130
  return t;
125
- }, F = (t) => {
126
- const a = D(t);
131
+ }, D = (t) => {
132
+ const a = T(t);
127
133
  return r.find((s) => s.id === a)?.clearable !== !1;
128
- }, L = (t) => {
129
- const a = D(t);
130
- N(a), x(!0);
131
- }, P = l.some(
132
- (t) => F(t.id)
133
- ), U = r.map((t) => ({
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), B = () => {
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
- k,
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
- k,
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 === b.CUSTOM && !e.dateInit && !e.dateEnd) {
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
- X,
193
+ $,
188
194
  {
189
- value: e.dateValue || b.LAST_7_DAYS,
195
+ value: e.dateValue || C.LAST_7_DAYS,
190
196
  onValueChange: t,
191
- showCustomFields: e.dateValue === b.CUSTOM,
197
+ showCustomFields: e.dateValue === C.CUSTOM,
192
198
  onCustomFieldsChange: (a) => {
193
- a && t(b.CUSTOM);
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: z,
219
- className: d("flex flex-col gap-1 relative", j),
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
- g,
229
+ b,
224
230
  {
225
231
  variant: "outline",
226
232
  size: "sm",
227
233
  className: "gap-2",
228
- onClick: () => x(!p),
229
- disabled: V,
234
+ onClick: () => g(!x),
235
+ disabled: O,
230
236
  children: [
231
- /* @__PURE__ */ n.jsx(C, { name: "FunnelSimple", className: "size-4" }),
237
+ /* @__PURE__ */ n.jsx(j, { name: "FunnelSimple", className: "size-4" }),
232
238
  h
233
239
  ]
234
240
  }
235
241
  ),
236
- O ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
237
- /* @__PURE__ */ n.jsx(S, { orientation: "vertical", className: "h-5" }),
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
- R.map((t) => {
240
- const a = F(t.id);
245
+ U.map((t) => {
246
+ const a = D(t.id);
241
247
  return /* @__PURE__ */ n.jsxs(
242
- g,
248
+ b,
243
249
  {
244
250
  variant: "secondary",
245
- onClick: () => L(t.id),
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(C, { name: "X", className: "size-4" })
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
- T > 0 && /* @__PURE__ */ n.jsxs(g, { children: [
272
+ I > 0 && /* @__PURE__ */ n.jsxs(b, { children: [
267
273
  "+",
268
- T,
274
+ I,
269
275
  " more"
270
276
  ] }),
271
- u && P && /* @__PURE__ */ n.jsx(
272
- g,
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(S, { orientation: "vertical", className: "h-5" }),
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
- p && /* @__PURE__ */ n.jsxs(
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
- A,
305
+ V,
300
306
  {
301
- items: U,
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: B() })
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
- Y.displayName = "FilterDropdown";
321
+ q.displayName = "FilterDropdown";
316
322
  export {
317
- Y as FilterDropdown,
318
- A as FilterMenu,
319
- M as FilterMenuItem
323
+ q as FilterDropdown,
324
+ V as FilterMenu,
325
+ A as FilterMenuItem
320
326
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuno-payments/dashboard-design-system",
3
- "version": "0.0.206",
3
+ "version": "0.0.207",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",