@oneplatformdev/ui 0.0.1-beta.19 → 0.0.1-beta.20
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.
- package/Combobox/Combobox.mjs +49 -51
- package/package.json +1 -1
package/Combobox/Combobox.mjs
CHANGED
@@ -1,50 +1,48 @@
|
|
1
|
-
import { jsx as a, jsxs as
|
2
|
-
import n, { useRef as
|
3
|
-
import { LoadingMask as
|
4
|
-
import { Popover as
|
5
|
-
import { Button as
|
1
|
+
import { jsx as a, jsxs as t } from "react/jsx-runtime";
|
2
|
+
import n, { useRef as U, useEffect as w, useCallback as x } from "react";
|
3
|
+
import { LoadingMask as _ } from "../LoadingMask/LoadingMask.mjs";
|
4
|
+
import { Popover as B, PopoverTrigger as F, PopoverContent as V } from "../Popover/Popover.mjs";
|
5
|
+
import { Button as X } from "../Button/Button.mjs";
|
6
6
|
import "../Button/buttonVariants.mjs";
|
7
|
-
import { Command as
|
7
|
+
import { Command as q, CommandInput as z, CommandList as A, CommandEmpty as H, CommandGroup as J, CommandItem as K } from "../Command/Command.mjs";
|
8
8
|
import { cn as N } from "@oneplatformdev/utils";
|
9
|
-
import { useDebounceCallback as
|
10
|
-
import { X as
|
11
|
-
const
|
9
|
+
import { useDebounceCallback as Q } from "@oneplatformdev/hooks";
|
10
|
+
import { X as W, ChevronsUpDown as Y, Check as Z } from "lucide-react";
|
11
|
+
const ie = (S) => {
|
12
12
|
var y;
|
13
13
|
const {
|
14
14
|
value: o,
|
15
15
|
onChange: k,
|
16
|
-
placeholder:
|
17
|
-
disabled:
|
18
|
-
searchLabel:
|
19
|
-
fetchOptions:
|
20
|
-
options:
|
21
|
-
emptyLabel:
|
16
|
+
placeholder: L,
|
17
|
+
disabled: O,
|
18
|
+
searchLabel: P,
|
19
|
+
fetchOptions: j,
|
20
|
+
options: r,
|
21
|
+
emptyLabel: D = "No options",
|
22
22
|
onMount: u
|
23
|
-
} = S, s =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}, [t]);
|
29
|
-
const E = async () => {
|
23
|
+
} = S, s = U(!1), [l, p] = n.useState(!1), [M, h] = n.useState(""), [f, c] = n.useState([]), [i, b] = n.useState(), [v, C] = n.useState(!1);
|
24
|
+
w(() => {
|
25
|
+
r != null && r.length && c(r);
|
26
|
+
}, [r]);
|
27
|
+
const T = async () => {
|
30
28
|
l || (g(), h(""));
|
31
|
-
}, g = async (e) => {
|
29
|
+
}, g = x(async (e) => {
|
32
30
|
C(!0);
|
33
31
|
try {
|
34
|
-
const m = await
|
32
|
+
const m = await j(e);
|
35
33
|
c(m);
|
36
34
|
} catch (m) {
|
37
35
|
console.error("Unexpected error while get option:", m);
|
38
36
|
} finally {
|
39
37
|
C(!1);
|
40
38
|
}
|
41
|
-
},
|
42
|
-
h(e),
|
39
|
+
}, []), E = Q(g, 1e3, { leading: !1, trailing: !0 }), G = (e) => {
|
40
|
+
h(e), E(e);
|
43
41
|
}, d = (e) => {
|
44
42
|
k(e.value), b(e);
|
45
|
-
},
|
43
|
+
}, I = () => {
|
46
44
|
d({ value: "", label: "" }), b(void 0);
|
47
|
-
},
|
45
|
+
}, R = x(() => {
|
48
46
|
if (!u) {
|
49
47
|
s.current = !0;
|
50
48
|
return;
|
@@ -53,18 +51,18 @@ const de = (S) => {
|
|
53
51
|
s.current = !0;
|
54
52
|
});
|
55
53
|
}, []);
|
56
|
-
return
|
54
|
+
return w(() => (R(), () => {
|
57
55
|
s.current = !1;
|
58
|
-
}), []), /* @__PURE__ */ a("div", { className: "w-full", children: /* @__PURE__ */
|
59
|
-
|
56
|
+
}), []), /* @__PURE__ */ a("div", { className: "w-full", children: /* @__PURE__ */ t(
|
57
|
+
B,
|
60
58
|
{
|
61
59
|
open: l,
|
62
60
|
onOpenChange: (e) => {
|
63
|
-
p(e), e &&
|
61
|
+
p(e), e && T();
|
64
62
|
},
|
65
63
|
children: [
|
66
|
-
/* @__PURE__ */ a(
|
67
|
-
|
64
|
+
/* @__PURE__ */ a(F, { asChild: !0, className: "border-border", children: /* @__PURE__ */ t(
|
65
|
+
X,
|
68
66
|
{
|
69
67
|
variant: "outline",
|
70
68
|
role: "combobox",
|
@@ -73,39 +71,39 @@ const de = (S) => {
|
|
73
71
|
"w-full justify-between font-normal text-sm border bg-input",
|
74
72
|
l ? "border-2 border-sidebar-accent" : "border-border"
|
75
73
|
),
|
76
|
-
disabled:
|
74
|
+
disabled: O,
|
77
75
|
children: [
|
78
|
-
/* @__PURE__ */ a("span", { className: "truncate max-w-[calc(100%-1.5rem)] overflow-hidden whitespace-nowrap", children: o ? ((y = f.find((e) => e.value === o)) == null ? void 0 : y.label) || (i == null ? void 0 : i.label) : /* @__PURE__ */ a("span", { className: "text-gray-400", children:
|
76
|
+
/* @__PURE__ */ a("span", { className: "truncate max-w-[calc(100%-1.5rem)] overflow-hidden whitespace-nowrap", children: o ? ((y = f.find((e) => e.value === o)) == null ? void 0 : y.label) || (i == null ? void 0 : i.label) : /* @__PURE__ */ a("span", { className: "text-gray-400", children: L }) }),
|
79
77
|
o ? /* @__PURE__ */ a(
|
80
|
-
|
78
|
+
W,
|
81
79
|
{
|
82
80
|
className: "opacity-50 w-4 h-4 cursor-pointer hover:opacity-100",
|
83
81
|
onClick: (e) => {
|
84
|
-
e.stopPropagation(),
|
82
|
+
e.stopPropagation(), I();
|
85
83
|
}
|
86
84
|
}
|
87
|
-
) : /* @__PURE__ */ a(
|
85
|
+
) : /* @__PURE__ */ a(Y, { className: "opacity-50 w-4 h-4" })
|
88
86
|
]
|
89
87
|
}
|
90
88
|
) }),
|
91
89
|
/* @__PURE__ */ a(
|
92
|
-
|
90
|
+
V,
|
93
91
|
{
|
94
92
|
className: "w-[var(--radix-popper-anchor-width)] max-w-none p-0",
|
95
93
|
align: "start",
|
96
|
-
children: /* @__PURE__ */
|
94
|
+
children: /* @__PURE__ */ t(q, { shouldFilter: !1, children: [
|
97
95
|
/* @__PURE__ */ a(
|
98
|
-
|
96
|
+
z,
|
99
97
|
{
|
100
|
-
placeholder:
|
101
|
-
value:
|
102
|
-
onValueChange:
|
98
|
+
placeholder: P,
|
99
|
+
value: M,
|
100
|
+
onValueChange: G
|
103
101
|
}
|
104
102
|
),
|
105
|
-
/* @__PURE__ */
|
106
|
-
!v && /* @__PURE__ */ a(
|
107
|
-
/* @__PURE__ */ a(
|
108
|
-
|
103
|
+
/* @__PURE__ */ t(A, { children: [
|
104
|
+
!v && /* @__PURE__ */ a(H, { children: D }),
|
105
|
+
/* @__PURE__ */ a(J, { children: v ? /* @__PURE__ */ a("div", { className: "flex justify-center", children: /* @__PURE__ */ a(_, {}) }) : f.map((e) => /* @__PURE__ */ t(
|
106
|
+
K,
|
109
107
|
{
|
110
108
|
value: e.value,
|
111
109
|
onSelect: () => {
|
@@ -114,7 +112,7 @@ const de = (S) => {
|
|
114
112
|
children: [
|
115
113
|
e.label,
|
116
114
|
/* @__PURE__ */ a(
|
117
|
-
|
115
|
+
Z,
|
118
116
|
{
|
119
117
|
className: N(
|
120
118
|
"ml-auto",
|
@@ -135,5 +133,5 @@ const de = (S) => {
|
|
135
133
|
) });
|
136
134
|
};
|
137
135
|
export {
|
138
|
-
|
136
|
+
ie as Combobox
|
139
137
|
};
|