@yuno-payments/dashboard-design-system 2.9.0 → 2.9.1-PYORK-145.1

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