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