@yuno-payments/dashboard-design-system 2.9.3 → 2.9.4

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,125 +1,135 @@
1
- import { j as e } from "../../../_virtual/jsx-runtime.js";
1
+ import { j as t } from "../../../_virtual/jsx-runtime.js";
2
2
  import * as l from "react";
3
- import { cn as a, getDirection as A } from "../../../lib/utils.js";
4
- import { FieldLabel as B } from "../../../vendor/shadcn/field.js";
3
+ import { cn as c, getDirection as A } from "../../../lib/utils.js";
4
+ import { FieldLabel as J } from "../../../vendor/shadcn/field.js";
5
5
  import { Icon as b } from "../../atoms/icon/icon.js";
6
- import { Combobox as H, ComboboxTrigger as J, ComboboxContent as K } from "../../../vendor/shadcn/combobox.js";
7
- import { Command as M, CommandInput as P, CommandList as Q, CommandEmpty as U, CommandGroup as W, CommandItem as G } from "../../../vendor/shadcn/command.js";
6
+ import { Combobox as M, ComboboxTrigger as P, ComboboxContent as Q } from "../../../vendor/shadcn/combobox.js";
7
+ import { Command as U, CommandInput as W, CommandList as X, CommandEmpty as Y, CommandGroup as Z, CommandItem as _ } from "../../../vendor/shadcn/command.js";
8
8
  import { Typography as x } from "../../atoms/typography/typography.js";
9
- const X = l.forwardRef(
9
+ const E = "__yuno_search_select_no_highlight__", $ = "end", ee = l.forwardRef(
10
10
  ({
11
11
  label: j,
12
- description: N,
12
+ description: C,
13
13
  error: u,
14
- optional: L = !1,
14
+ optional: G = !1,
15
15
  placeholder: k = "Select an option",
16
- value: r,
17
- defaultValue: p,
18
- onChange: h,
16
+ value: s,
17
+ defaultValue: h,
18
+ onChange: p,
19
19
  disabled: f = !1,
20
- options: c = [],
20
+ options: o = [],
21
21
  groups: i = [],
22
- className: E,
22
+ className: I,
23
23
  id: g,
24
- searchPlaceholder: z = "Search",
25
- maxHeight: F = 300
26
- }, I) => {
27
- const [o, C] = l.useState(!1), [v, S] = l.useState(""), d = i.length > 0, w = c.length > 0, D = l.useCallback(() => {
28
- if (!r) return null;
24
+ searchPlaceholder: T = "Search",
25
+ maxHeight: V = 300
26
+ }, z) => {
27
+ const [r, N] = l.useState(!1), [S, v] = l.useState(""), [D, O] = l.useState(E), F = l.useCallback((e) => {
28
+ O(E), N(e);
29
+ }, []), d = i.length > 0, w = o.length > 0, H = l.useCallback(() => {
30
+ if (!s) return null;
29
31
  if (d)
30
- for (const s of i) {
31
- const n = s.options.find((t) => t.value === r);
32
- if (n) return n.label;
32
+ for (const e of i) {
33
+ const a = e.options.find((n) => n.value === s);
34
+ if (a) return a.label;
33
35
  }
34
36
  else if (w) {
35
- const s = c.find((n) => n.value === r);
36
- if (s) return s.label;
37
+ const e = o.find((a) => a.value === s);
38
+ if (e) return e.label;
37
39
  }
38
40
  return null;
39
- }, [r, i, c, d, w]), R = l.useCallback(
40
- (s) => {
41
- if (!s)
42
- return { filteredOptions: c, filteredGroups: i };
43
- const n = s.toLowerCase();
41
+ }, [s, i, o, d, w]), R = l.useCallback(
42
+ (e) => {
43
+ if (!e)
44
+ return { filteredOptions: o, filteredGroups: i };
45
+ const a = e.toLowerCase();
44
46
  if (d) {
45
- const t = i.map((m) => ({
47
+ const n = i.map((m) => ({
46
48
  ...m,
47
49
  options: m.options.filter(
48
- (V) => V.label.toLowerCase().includes(n)
50
+ (K) => K.label.toLowerCase().includes(a)
49
51
  )
50
52
  })).filter((m) => m.options.length > 0);
51
- return { filteredOptions: [], filteredGroups: t };
53
+ return { filteredOptions: [], filteredGroups: n };
52
54
  } else
53
- return { filteredOptions: c.filter(
54
- (m) => m.label.toLowerCase().includes(n)
55
+ return { filteredOptions: o.filter(
56
+ (m) => m.label.toLowerCase().includes(a)
55
57
  ), filteredGroups: [] };
56
58
  },
57
- [c, i, d]
58
- ), { filteredOptions: T, filteredGroups: q } = R(v);
59
+ [o, i, d]
60
+ ), { filteredOptions: q, filteredGroups: B } = R(S);
59
61
  l.useEffect(() => {
60
- o && setTimeout(() => {
62
+ r && setTimeout(() => {
61
63
  document.querySelector(
62
64
  '[data-slot="command-input"]'
63
65
  )?.focus();
64
66
  }, 0);
65
- }, [o]), l.useEffect(() => {
66
- o || S("");
67
- }, [o]), l.useEffect(() => {
68
- p && !r && h?.(p);
69
- }, [p, r, h]);
70
- const y = (s) => {
71
- f || (h?.(s), C(!1));
72
- }, O = D();
73
- return /* @__PURE__ */ e.jsxs("div", { dir: A(), className: a("w-full", E), children: [
74
- j && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 mb-2", children: [
75
- /* @__PURE__ */ e.jsx(
76
- B,
67
+ }, [r]), l.useEffect(() => {
68
+ if (!r || !s) return;
69
+ const e = setTimeout(() => {
70
+ document.querySelector(
71
+ '[data-slot="command-list"] [data-selected-option="true"]'
72
+ )?.scrollIntoView({ block: $ });
73
+ }, 0);
74
+ return () => clearTimeout(e);
75
+ }, [r, s]), l.useEffect(() => {
76
+ r || v("");
77
+ }, [r]), l.useEffect(() => {
78
+ h && !s && p?.(h);
79
+ }, [h, s, p]);
80
+ const y = (e) => {
81
+ f || (p?.(e), N(!1));
82
+ }, L = H();
83
+ return /* @__PURE__ */ t.jsxs("div", { dir: A(), className: c("w-full", I), children: [
84
+ j && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-1 mb-2", children: [
85
+ /* @__PURE__ */ t.jsx(
86
+ J,
77
87
  {
78
88
  htmlFor: g,
79
- className: a(f && "text-muted-foreground"),
89
+ className: c(f && "text-muted-foreground"),
80
90
  children: j
81
91
  }
82
92
  ),
83
- L && /* @__PURE__ */ e.jsx(x, { variant: "sm", className: "text-muted-foreground", children: "(Optional)" })
93
+ G && /* @__PURE__ */ t.jsx(x, { variant: "sm", className: "text-muted-foreground", children: "(Optional)" })
84
94
  ] }),
85
- N && !u && /* @__PURE__ */ e.jsx(
95
+ C && !u && /* @__PURE__ */ t.jsx(
86
96
  x,
87
97
  {
88
98
  variant: "sm",
89
- className: a(
99
+ className: c(
90
100
  "text-muted-foreground mb-2",
91
101
  f && "text-muted-"
92
102
  ),
93
- children: N
103
+ children: C
94
104
  }
95
105
  ),
96
- /* @__PURE__ */ e.jsxs(H, { open: o, onOpenChange: C, children: [
97
- /* @__PURE__ */ e.jsx(J, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
106
+ /* @__PURE__ */ t.jsxs(M, { open: r, onOpenChange: F, children: [
107
+ /* @__PURE__ */ t.jsx(P, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
98
108
  "button",
99
109
  {
100
- ref: I,
110
+ ref: z,
101
111
  id: g,
102
112
  type: "button",
103
113
  disabled: f,
104
114
  role: "combobox",
105
- "aria-expanded": o,
115
+ "aria-expanded": r,
106
116
  "aria-haspopup": "listbox",
107
- className: a(
117
+ className: c(
108
118
  "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-input px-3 py-2 text-sm 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:text-muted- shadow-xs [&>span]:min-w-0 [&>span]:truncate",
109
119
  u && "border-destructive"
110
120
  ),
111
121
  children: [
112
- /* @__PURE__ */ e.jsx(
122
+ /* @__PURE__ */ t.jsx(
113
123
  "span",
114
124
  {
115
- className: a(
125
+ className: c(
116
126
  "truncate",
117
- !O && "text-muted-foreground"
127
+ !L && "text-muted-foreground"
118
128
  ),
119
- children: O || k
129
+ children: L || k
120
130
  }
121
131
  ),
122
- /* @__PURE__ */ e.jsx(
132
+ /* @__PURE__ */ t.jsx(
123
133
  b,
124
134
  {
125
135
  name: "CaretDown",
@@ -130,79 +140,89 @@ const X = l.forwardRef(
130
140
  ]
131
141
  }
132
142
  ) }),
133
- /* @__PURE__ */ e.jsx(K, { className: "p-0", align: "start", children: /* @__PURE__ */ e.jsxs(M, { shouldFilter: !1, children: [
134
- /* @__PURE__ */ e.jsx(
135
- P,
136
- {
137
- placeholder: z,
138
- value: v,
139
- onValueChange: S
140
- }
141
- ),
142
- /* @__PURE__ */ e.jsxs(Q, { style: { maxHeight: F }, children: [
143
- /* @__PURE__ */ e.jsx(U, { children: /* @__PURE__ */ e.jsx(
144
- x,
145
- {
146
- variant: "sm",
147
- className: "text-muted-foreground py-6 text-center",
148
- children: "No results found."
149
- }
150
- ) }),
151
- d ? q.map((s, n) => /* @__PURE__ */ e.jsxs(W, { children: [
152
- s.label && /* @__PURE__ */ e.jsx("div", { className: "px-2 py-1.5 text-xs font-medium text-muted-foreground", children: s.label }),
153
- s.options.map((t) => /* @__PURE__ */ e.jsxs(
154
- G,
143
+ /* @__PURE__ */ t.jsx(Q, { className: "p-0", align: "start", children: /* @__PURE__ */ t.jsxs(
144
+ U,
145
+ {
146
+ shouldFilter: !1,
147
+ value: D,
148
+ onValueChange: O,
149
+ children: [
150
+ /* @__PURE__ */ t.jsx(
151
+ W,
155
152
  {
156
- value: t.value,
157
- onSelect: () => y(t.value),
158
- className: a(
159
- "cursor-pointer",
160
- r === t.value && "bg-accent"
161
- ),
162
- children: [
163
- /* @__PURE__ */ e.jsxs("span", { className: "flex items-center", children: [
164
- t.icon && /* @__PURE__ */ e.jsx("span", { className: "mr-2 inline-flex items-center", children: t.icon }),
165
- t.label
166
- ] }),
167
- r === t.value && /* @__PURE__ */ e.jsx(
168
- b,
169
- {
170
- name: "Check",
171
- size: "sm",
172
- className: "ml-auto"
173
- }
174
- )
175
- ]
176
- },
177
- t.value
178
- ))
179
- ] }, n)) : T.map((s) => /* @__PURE__ */ e.jsxs(
180
- G,
181
- {
182
- value: s.value,
183
- onSelect: () => y(s.value),
184
- className: a(
185
- "cursor-pointer",
186
- r === s.value && "bg-accent"
187
- ),
188
- children: [
189
- /* @__PURE__ */ e.jsxs("span", { className: "flex items-center", children: [
190
- s.icon && /* @__PURE__ */ e.jsx("span", { className: "mr-2 inline-flex items-center", children: s.icon }),
191
- s.label
192
- ] }),
193
- r === s.value && /* @__PURE__ */ e.jsx(b, { name: "Check", size: "sm", className: "ml-auto" })
194
- ]
195
- },
196
- s.value
197
- ))
198
- ] })
199
- ] }) })
153
+ placeholder: T,
154
+ value: S,
155
+ onValueChange: v
156
+ }
157
+ ),
158
+ /* @__PURE__ */ t.jsxs(X, { style: { maxHeight: V }, children: [
159
+ /* @__PURE__ */ t.jsx(Y, { children: /* @__PURE__ */ t.jsx(
160
+ x,
161
+ {
162
+ variant: "sm",
163
+ className: "text-muted-foreground py-6 text-center",
164
+ children: "No results found."
165
+ }
166
+ ) }),
167
+ d ? B.map((e, a) => /* @__PURE__ */ t.jsxs(Z, { children: [
168
+ e.label && /* @__PURE__ */ t.jsx("div", { className: "px-2 py-1.5 text-xs font-medium text-muted-foreground", children: e.label }),
169
+ e.options.map((n) => /* @__PURE__ */ t.jsxs(
170
+ _,
171
+ {
172
+ value: n.value,
173
+ onSelect: () => y(n.value),
174
+ "data-selected-option": s === n.value ? !0 : void 0,
175
+ className: c(
176
+ "cursor-pointer",
177
+ s === n.value && "bg-accent"
178
+ ),
179
+ children: [
180
+ /* @__PURE__ */ t.jsxs("span", { className: "flex items-center", children: [
181
+ n.icon && /* @__PURE__ */ t.jsx("span", { className: "mr-2 inline-flex items-center", children: n.icon }),
182
+ n.label
183
+ ] }),
184
+ s === n.value && /* @__PURE__ */ t.jsx(
185
+ b,
186
+ {
187
+ name: "Check",
188
+ size: "sm",
189
+ className: "ml-auto"
190
+ }
191
+ )
192
+ ]
193
+ },
194
+ n.value
195
+ ))
196
+ ] }, a)) : q.map((e) => /* @__PURE__ */ t.jsxs(
197
+ _,
198
+ {
199
+ value: e.value,
200
+ onSelect: () => y(e.value),
201
+ "data-selected-option": s === e.value ? !0 : void 0,
202
+ className: c(
203
+ "cursor-pointer",
204
+ s === e.value && "bg-accent"
205
+ ),
206
+ children: [
207
+ /* @__PURE__ */ t.jsxs("span", { className: "flex items-center", children: [
208
+ e.icon && /* @__PURE__ */ t.jsx("span", { className: "mr-2 inline-flex items-center", children: e.icon }),
209
+ e.label
210
+ ] }),
211
+ s === e.value && /* @__PURE__ */ t.jsx(b, { name: "Check", size: "sm", className: "ml-auto" })
212
+ ]
213
+ },
214
+ e.value
215
+ ))
216
+ ] })
217
+ ]
218
+ }
219
+ ) })
200
220
  ] }),
201
- u && /* @__PURE__ */ e.jsx(x, { variant: "sm", className: "text-destructive mt-2", children: u })
221
+ u && /* @__PURE__ */ t.jsx(x, { variant: "sm", className: "text-destructive mt-2", children: u })
202
222
  ] });
203
223
  }
204
224
  );
205
- X.displayName = "SearchSelect";
225
+ ee.displayName = "SearchSelect";
206
226
  export {
207
- X as SearchSelect
227
+ ee as SearchSelect
208
228
  };