@yuno-payments/dashboard-design-system 1.1.7 → 1.2.0

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,98 +1,100 @@
1
- import { j as t } from "../../../_virtual/jsx-runtime.js";
2
- import { forwardRef as Y, useState as y, useRef as Z, useEffect as I } from "react";
1
+ import { j as s } from "../../../_virtual/jsx-runtime.js";
2
+ import { forwardRef as _, useState as y, useRef as W, useEffect as z } from "react";
3
3
  import { cn as f } from "../../../lib/utils.js";
4
- import { Combobox as _, ComboboxTrigger as W, ComboboxContent as A } from "../../../vendor/shadcn/combobox.js";
5
- import { Icon as $ } from "../icon/icon.js";
6
- import { Label as P } from "../label/label.js";
4
+ import { Combobox as A, ComboboxTrigger as P, ComboboxContent as ee } from "../../../vendor/shadcn/combobox.js";
5
+ import { Icon as B } from "../icon/icon.js";
6
+ import { Label as se } from "../label/label.js";
7
7
  import { Typography as C } from "../typography/typography.js";
8
8
  import { Badge as N } from "../badge/badge.js";
9
- import { Checkbox as ee } from "../checkbox/checkbox.js";
10
- const te = ({ message: n = "No results" }) => /* @__PURE__ */ t.jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ t.jsx(C, { variant: "sm", className: "text-muted-foreground", children: n }) }), se = Y(
9
+ import { Checkbox as te } from "../checkbox/checkbox.js";
10
+ const ne = ({ message: n = "No results" }) => /* @__PURE__ */ s.jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ s.jsx(C, { variant: "sm", className: "text-muted-foreground", children: n }) }), re = _(
11
11
  ({
12
12
  value: n,
13
- options: a,
14
- selectPlaceholder: z = "Select options...",
15
- searchPlaceholder: w = "Search...",
13
+ options: o,
14
+ selectPlaceholder: K = "Select",
15
+ searchPlaceholder: w = "Search",
16
16
  onChange: k,
17
17
  onCloseChip: x,
18
18
  valueProp: r = "value",
19
- fullWidth: v = !1,
20
- disabled: o = !1,
19
+ fullWidth: D = !1,
20
+ disabled: a = !1,
21
21
  withSearch: d = !0,
22
- limitTags: D = 10,
23
- maxHeightList: p = 320,
24
- emptyState: B = /* @__PURE__ */ t.jsx(te, {}),
25
- label: O,
26
- description: E,
22
+ limitTags: v = 10,
23
+ maxHeightList: g = 320,
24
+ emptyState: G = /* @__PURE__ */ s.jsx(ne, {}),
25
+ label: E,
26
+ description: O,
27
27
  error: u,
28
28
  deleteAll: l,
29
- className: K,
30
- id: i
31
- }, G) => {
32
- const [c, R] = y(!1), [L, M] = y(""), [S, g] = y(a), h = Z(null);
33
- I(() => {
34
- g(a);
35
- }, [a]), I(() => {
29
+ className: L,
30
+ id: i,
31
+ renderOption: R,
32
+ renderChip: F
33
+ }, M) => {
34
+ const [c, S] = y(!1), [U, V] = y(""), [T, p] = y(o), h = W(null);
35
+ z(() => {
36
+ p(o);
37
+ }, [o]), z(() => {
36
38
  c && h.current && d && setTimeout(() => {
37
39
  h.current?.focus();
38
40
  }, 0);
39
41
  }, [c, d]);
40
42
  const b = (e) => {
41
- const s = e.label || e[r];
42
- return String(s);
43
- }, U = (e) => {
44
- const s = e.target.value;
45
- if (M(s), s === "")
46
- g(a);
43
+ const t = e.label || e[r];
44
+ return String(t);
45
+ }, X = (e) => {
46
+ const t = e.target.value;
47
+ if (V(t), t === "")
48
+ p(o);
47
49
  else {
48
- const m = a.filter(
49
- (Q) => b(Q).toLowerCase().includes(s.toLowerCase())
50
+ const m = o.filter(
51
+ (Z) => b(Z).toLowerCase().includes(t.toLowerCase())
50
52
  );
51
- g(m);
53
+ p(m);
52
54
  }
53
55
  }, j = (e) => {
54
- if (o) return;
55
- const s = n.includes(e) ? n.filter((m) => m !== e) : [...n, e];
56
- k(s);
57
- }, V = (e) => {
58
- if (!o)
56
+ if (a) return;
57
+ const t = n.includes(e) ? n.filter((m) => m !== e) : [...n, e];
58
+ k(t);
59
+ }, q = (e) => {
60
+ if (!a)
59
61
  if (x)
60
62
  x(e);
61
63
  else {
62
- const s = n.filter((m) => m !== e);
63
- k(s);
64
+ const t = n.filter((m) => m !== e);
65
+ k(t);
64
66
  }
65
- }, X = () => {
66
- o || !l?.onClick || l.onClick();
67
- }, q = (e, s) => e?.length <= s ? e : e?.substring(0, s) + "...", T = n.map((e) => a.find((s) => s[r] === e)).filter(Boolean), H = l && !o && n.length >= l.length, J = T.slice(0, D), F = T.length - D;
68
- return /* @__PURE__ */ t.jsxs("div", { className: f("w-full", v && "w-full", K), children: [
69
- O && /* @__PURE__ */ t.jsx(
70
- P,
67
+ }, H = () => {
68
+ a || !l?.onClick || l.onClick();
69
+ }, J = (e, t) => e?.length <= t ? e : e?.substring(0, t) + "...", I = n.map((e) => o.find((t) => t[r] === e)).filter(Boolean), Q = l && !a && n.length >= l.length, Y = I.slice(0, v), $ = I.length - v;
70
+ return /* @__PURE__ */ s.jsxs("div", { className: f("w-full", D && "w-full", L), children: [
71
+ E && /* @__PURE__ */ s.jsx(
72
+ se,
71
73
  {
72
74
  htmlFor: i,
73
- className: f("mb-2 block", o && "opacity-50"),
74
- children: O
75
+ className: f("mb-2 block", a && "opacity-50"),
76
+ children: E
75
77
  }
76
78
  ),
77
- E && !u && /* @__PURE__ */ t.jsx(
79
+ O && !u && /* @__PURE__ */ s.jsx(
78
80
  C,
79
81
  {
80
82
  variant: "sm",
81
83
  className: f(
82
84
  "text-muted-foreground mb-2",
83
- o && "opacity-50"
85
+ a && "opacity-50"
84
86
  ),
85
- children: E
87
+ children: O
86
88
  }
87
89
  ),
88
- /* @__PURE__ */ t.jsxs(_, { open: c, onOpenChange: R, children: [
89
- /* @__PURE__ */ t.jsx(W, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
90
+ /* @__PURE__ */ s.jsxs(A, { open: c, onOpenChange: S, children: [
91
+ /* @__PURE__ */ s.jsx(P, { asChild: !0, children: /* @__PURE__ */ s.jsxs(
90
92
  "button",
91
93
  {
92
- ref: G,
94
+ ref: M,
93
95
  id: i,
94
96
  type: "button",
95
- disabled: o,
97
+ disabled: a,
96
98
  role: "combobox",
97
99
  "aria-expanded": c,
98
100
  "aria-haspopup": "listbox",
@@ -100,17 +102,17 @@ const te = ({ message: n = "No results" }) => /* @__PURE__ */ t.jsx("div", { cla
100
102
  className: f(
101
103
  "flex h-auto min-h-[38px] w-full items-center justify-between gap-2 rounded-md border border-input bg-input px-3 py-1.5 text-sm shadow-xs ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
102
104
  u && "border-destructive",
103
- v && "w-full"
105
+ D && "w-full"
104
106
  ),
105
107
  children: [
106
- /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-1 flex-1 items-center", children: n.length === 0 ? /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: z }) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
107
- H && /* @__PURE__ */ t.jsx(
108
+ /* @__PURE__ */ s.jsx("div", { className: "flex flex-wrap gap-1 flex-1 items-center", children: n.length === 0 ? /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground", children: K }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
109
+ Q && /* @__PURE__ */ s.jsx(
108
110
  "div",
109
111
  {
110
112
  onClick: (e) => {
111
- e.preventDefault(), e.stopPropagation(), X();
113
+ e.preventDefault(), e.stopPropagation(), H();
112
114
  },
113
- children: /* @__PURE__ */ t.jsx(
115
+ children: /* @__PURE__ */ s.jsx(
114
116
  N,
115
117
  {
116
118
  variant: "secondary",
@@ -120,28 +122,28 @@ const te = ({ message: n = "No results" }) => /* @__PURE__ */ t.jsx("div", { cla
120
122
  )
121
123
  }
122
124
  ),
123
- J.map((e) => /* @__PURE__ */ t.jsx(
125
+ Y.map((e) => /* @__PURE__ */ s.jsx(
124
126
  "div",
125
127
  {
126
- onClick: (s) => {
127
- x && !o && (s.preventDefault(), s.stopPropagation(), V(e[r]));
128
+ onClick: (t) => {
129
+ x && !a && (t.preventDefault(), t.stopPropagation(), q(e[r]));
128
130
  },
129
- children: /* @__PURE__ */ t.jsx(
131
+ children: F ? F(e) : /* @__PURE__ */ s.jsx(
130
132
  N,
131
133
  {
132
134
  variant: "outline",
133
135
  className: "gap-1 flex items-center",
134
- endIcon: x && !o ? "X" : void 0,
135
- children: q(b(e), 8)
136
+ endIcon: x && !a ? "X" : void 0,
137
+ children: J(b(e), 8)
136
138
  }
137
139
  )
138
140
  },
139
141
  e[r]
140
142
  )),
141
- F > 0 && /* @__PURE__ */ t.jsx(N, { variant: "outline", className: "flex items-center", children: `+${F}` })
143
+ $ > 0 && /* @__PURE__ */ s.jsx(N, { variant: "outline", className: "flex items-center", children: `+${$}` })
142
144
  ] }) }),
143
- /* @__PURE__ */ t.jsx(
144
- $,
145
+ /* @__PURE__ */ s.jsx(
146
+ B,
145
147
  {
146
148
  name: "CaretUpDown",
147
149
  size: "sm",
@@ -154,82 +156,85 @@ const te = ({ message: n = "No results" }) => /* @__PURE__ */ t.jsx("div", { cla
154
156
  ]
155
157
  }
156
158
  ) }),
157
- /* @__PURE__ */ t.jsx(
158
- A,
159
+ /* @__PURE__ */ s.jsx(
160
+ ee,
159
161
  {
160
162
  className: "p-0",
161
163
  align: "start",
162
- style: { maxHeight: p },
164
+ style: { maxHeight: g },
163
165
  id: i ? `${i}-listbox` : void 0,
164
166
  role: "listbox",
165
- children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col", children: [
166
- d && a.length > 0 && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b", children: [
167
- /* @__PURE__ */ t.jsx(
168
- $,
167
+ children: /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col", children: [
168
+ d && o.length > 0 && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b", children: [
169
+ /* @__PURE__ */ s.jsx(
170
+ B,
169
171
  {
170
172
  name: "MagnifyingGlass",
171
173
  size: "sm",
172
174
  className: "text-muted-foreground"
173
175
  }
174
176
  ),
175
- /* @__PURE__ */ t.jsx(
177
+ /* @__PURE__ */ s.jsx(
176
178
  "input",
177
179
  {
178
180
  ref: h,
179
181
  type: "text",
180
182
  placeholder: w,
181
- value: L,
182
- onChange: U,
183
+ value: U,
184
+ onChange: X,
183
185
  onKeyDown: (e) => {
184
- e.stopPropagation(), e.key === "Escape" && R(!1);
186
+ e.stopPropagation(), e.key === "Escape" && S(!1);
185
187
  },
186
188
  className: "flex-1 outline-none bg-transparent text-sm placeholder:text-muted-foreground",
187
189
  "aria-label": w
188
190
  }
189
191
  )
190
192
  ] }),
191
- /* @__PURE__ */ t.jsx(
193
+ /* @__PURE__ */ s.jsx(
192
194
  "div",
193
195
  {
194
196
  className: "overflow-y-auto",
195
197
  style: {
196
- maxHeight: d ? p - 48 : p
198
+ maxHeight: d ? g - 48 : g
197
199
  },
198
- children: S.length > 0 ? S.map((e) => /* @__PURE__ */ t.jsxs(
200
+ children: T.length > 0 ? T.map((e) => /* @__PURE__ */ s.jsx(
199
201
  "div",
200
202
  {
201
203
  role: "option",
202
204
  "aria-selected": n.includes(e[r]),
203
205
  className: "flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-accent transition-colors",
204
206
  onClick: () => j(e[r]),
205
- onKeyDown: (s) => {
206
- (s.key === "Enter" || s.key === " ") && (s.preventDefault(), j(e[r]));
207
+ onKeyDown: (t) => {
208
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), j(e[r]));
207
209
  },
208
- children: [
209
- /* @__PURE__ */ t.jsx(
210
- ee,
210
+ children: R ? R(
211
+ e,
212
+ n.includes(e[r])
213
+ ) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
214
+ /* @__PURE__ */ s.jsx(
215
+ te,
211
216
  {
212
217
  checked: n.includes(e[r]),
213
218
  onChange: () => j(e[r]),
214
- onClick: (s) => s.stopPropagation()
219
+ onClick: (t) => t.stopPropagation()
215
220
  }
216
221
  ),
217
- /* @__PURE__ */ t.jsx("span", { className: "text-sm flex-1", children: b(e) })
218
- ]
222
+ /* @__PURE__ */ s.jsx("span", { className: "text-sm flex-1", children: b(e) })
223
+ ] })
219
224
  },
220
225
  e[r]
221
- )) : B
226
+ )) : G
222
227
  }
223
228
  )
224
229
  ] })
225
230
  }
226
231
  )
227
232
  ] }),
228
- u && /* @__PURE__ */ t.jsx(C, { variant: "sm", className: "text-destructive mt-2", children: u })
233
+ u && /* @__PURE__ */ s.jsx(C, { variant: "sm", className: "text-destructive mt-2", children: u })
229
234
  ] });
230
235
  }
231
236
  );
232
- se.displayName = "Combobox";
237
+ re.displayName = "Combobox";
233
238
  export {
234
- se as Combobox
239
+ re as Combobox
235
240
  };
@@ -30,12 +30,12 @@ export interface ComboboxProps {
30
30
  options: ComboboxOption[];
31
31
  /**
32
32
  * Placeholder text when no options are selected
33
- * @default "Select options..."
33
+ * @default "Select"
34
34
  */
35
35
  selectPlaceholder?: string;
36
36
  /**
37
37
  * Placeholder text for the search input
38
- * @default "Search..."
38
+ * @default "Search"
39
39
  */
40
40
  searchPlaceholder?: string;
41
41
  /**
@@ -117,4 +117,16 @@ export interface ComboboxProps {
117
117
  * HTML id attribute
118
118
  */
119
119
  id?: string;
120
+ /**
121
+ * Custom render function for each option in the dropdown list.
122
+ * Replaces inner content only — the wrapper with role="option",
123
+ * click handlers, and hover styles is always provided by the Combobox.
124
+ */
125
+ renderOption?: (option: ComboboxOption, isSelected: boolean) => ReactNode;
126
+ /**
127
+ * Custom render function for each selected chip in the trigger area.
128
+ * Replaces the default truncated Badge — the wrapper div with
129
+ * remove-on-click behavior is always provided by the Combobox.
130
+ */
131
+ renderChip?: (option: ComboboxOption) => ReactNode;
120
132
  }
@@ -101,7 +101,7 @@ const q = g(
101
101
  items: t,
102
102
  className: c,
103
103
  searchable: m = !1,
104
- searchPlaceholder: u = "Search...",
104
+ searchPlaceholder: u = "Search",
105
105
  showActions: d = !1,
106
106
  enableSelectAll: b = !0,
107
107
  enableInverse: v = !0,
@@ -260,7 +260,7 @@ const D = g(
260
260
  ({
261
261
  children: s,
262
262
  showSearch: l = !1,
263
- searchPlaceholder: n = "Search...",
263
+ searchPlaceholder: n = "Search",
264
264
  searchValue: t,
265
265
  onSearchChange: c,
266
266
  className: m
@@ -12,7 +12,7 @@ const D = c.forwardRef(
12
12
  value: s = [],
13
13
  onChange: l,
14
14
  placeholder: b = "Select items...",
15
- searchPlaceholder: w = "Search...",
15
+ searchPlaceholder: w = "Search",
16
16
  emptyMessage: N = "No results found.",
17
17
  disabled: v = !1,
18
18
  label: i,
@@ -27,7 +27,7 @@ const P = D("flex gap-2 w-full", {
27
27
  }
28
28
  }), te = U(
29
29
  ({
30
- placeholder: F = "Search...",
30
+ placeholder: F = "Search",
31
31
  onSearch: l,
32
32
  limitSearch: y = 10,
33
33
  persistKey: c = "",
@@ -22,7 +22,7 @@ export interface SearchValue {
22
22
  export interface SearchFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "className"> {
23
23
  /**
24
24
  * Placeholder text for the input
25
- * @default "Search..."
25
+ * @default "Search"
26
26
  */
27
27
  placeholder?: string;
28
28
  /**
@@ -21,7 +21,7 @@ const W = r.forwardRef(
21
21
  groups: o = [],
22
22
  className: E,
23
23
  id: g,
24
- searchPlaceholder: z = "Search...",
24
+ searchPlaceholder: z = "Search",
25
25
  maxHeight: F = 300
26
26
  }, I) => {
27
27
  const [i, C] = r.useState(!1), [v, S] = r.useState(""), d = o.length > 0, w = c.length > 0, R = r.useCallback(() => {