@konstructio/ui 0.1.2-alpha.44 → 0.1.2-alpha.46
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/dist/components/AlertDialog/AlertDialog.js +39 -37
- package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
- package/dist/components/AlertDialog/components/index.js +1 -1
- package/dist/components/Badge/Badge.js +23 -26
- package/dist/components/Badge/Badge.variants.js +1 -1
- package/dist/components/Button/Button.variants.js +108 -98
- package/dist/components/Checkbox/Checkbox.js +104 -100
- package/dist/components/Checkbox/Checkbox.variants.js +30 -7
- package/dist/components/Filter/Filter.js +1 -1
- package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +9 -10
- package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +76 -43
- package/dist/components/Filter/components/ResetButton/ResetButton.js +21 -32
- package/dist/components/Filter/events/index.js +3 -3
- package/dist/components/ImageUpload/ImageUpload.js +221 -0
- package/dist/components/ImageUpload/ImageUpload.variants.js +109 -0
- package/dist/components/Input/Input.variants.js +10 -2
- package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +4 -4
- package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +16 -7
- package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +92 -74
- package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +53 -29
- package/dist/components/PhoneNumberInput/components/Wrapper.js +139 -120
- package/dist/components/Select/Select.js +48 -0
- package/dist/components/{Dropdown/Dropdown.variants.js → Select/Select.variants.js} +3 -3
- package/dist/components/{Dropdown → Select}/components/List/List.js +48 -43
- package/dist/components/{Dropdown → Select}/components/List/List.variants.js +8 -5
- package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.js +20 -20
- package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.variants.js +3 -2
- package/dist/components/{Dropdown → Select}/components/Wrapper.js +70 -70
- package/dist/components/Select/contexts/index.js +6 -0
- package/dist/components/{Dropdown/contexts/dropdown.context.js → Select/contexts/select.context.js} +2 -2
- package/dist/components/Select/contexts/select.hook.js +11 -0
- package/dist/components/Select/contexts/select.provider.js +58 -0
- package/dist/components/{Dropdown → Select}/hooks/useNavigationList.js +3 -3
- package/dist/components/{Dropdown/hooks/useDropdown.js → Select/hooks/useSelect.js} +33 -33
- package/dist/components/Switch/Switch.js +153 -125
- package/dist/components/Switch/Switch.variants.js +15 -6
- package/dist/components/Typography/Typography.js +25 -27
- package/dist/components/Typography/Typography.variants.js +2 -2
- package/dist/components/VirtualizedTable/components/Actions/Actions.js +14 -14
- package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +10 -10
- package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/index.js +77 -74
- package/dist/{index-CPU02rhe.js → index-D6KzX_ef.js} +13 -12
- package/dist/index.d.ts +106 -60
- package/dist/index.js +109 -106
- package/dist/package.json +4 -4
- package/dist/styles.css +1 -1
- package/dist/ui/civo-theme.css +6 -5
- package/dist/ui/theme.css +27 -0
- package/dist/x-BXShoIAM.js +8 -0
- package/package.json +4 -4
- package/dist/components/Dropdown/Dropdown.js +0 -48
- package/dist/components/Dropdown/contexts/dropdown.hook.js +0 -13
- package/dist/components/Dropdown/contexts/dropdown.provider.js +0 -58
- package/dist/components/Dropdown/contexts/index.js +0 -6
- /package/dist/components/{Dropdown → Select}/components/EmptyList.js +0 -0
- /package/dist/components/{Dropdown → Select}/components/index.js +0 -0
- /package/dist/components/{Dropdown → Select}/constants/index.js +0 -0
- /package/dist/components/{Dropdown → Select}/constants/pagination.js +0 -0
|
@@ -52,7 +52,7 @@ const a = e(
|
|
|
52
52
|
"bg-transparent",
|
|
53
53
|
"border-none",
|
|
54
54
|
"outline-none",
|
|
55
|
-
"text-
|
|
55
|
+
"text-metal-700",
|
|
56
56
|
"text-sm",
|
|
57
57
|
"capitalize",
|
|
58
58
|
"placeholder:text-sm",
|
|
@@ -69,7 +69,7 @@ const a = e(
|
|
|
69
69
|
"dark:text-metal-50"
|
|
70
70
|
]);
|
|
71
71
|
export {
|
|
72
|
-
a as dropdownVariants,
|
|
73
72
|
t as inputVariants,
|
|
74
|
-
d as labelVariants
|
|
73
|
+
d as labelVariants,
|
|
74
|
+
a as selectVariants
|
|
75
75
|
};
|
|
@@ -3,75 +3,75 @@ import { S as Z } from "../../../../index-BvoZGpli.js";
|
|
|
3
3
|
import { d as B } from "../../../../debounce-BFejQm9P.js";
|
|
4
4
|
import { forwardRef as G, useRef as C, useState as J, useImperativeHandle as K, useMemo as M, useEffect as Q } from "react";
|
|
5
5
|
import { Loading as R } from "../../../Loading/Loading.js";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as o } from "../../../../utils/index.js";
|
|
7
7
|
import { useNavigationUlList as W } from "../../hooks/useNavigationList.js";
|
|
8
8
|
import { ListItem as b } from "../ListItem/ListItem.js";
|
|
9
9
|
import { listVariants as X } from "./List.variants.js";
|
|
10
10
|
import { DEFAULT_LIST_SIZE as Y } from "../../constants/pagination.js";
|
|
11
|
-
import {
|
|
11
|
+
import { useSelectContext as $ } from "../../contexts/select.hook.js";
|
|
12
12
|
const fe = G(
|
|
13
13
|
({
|
|
14
14
|
additionalOptions: F,
|
|
15
15
|
className: N,
|
|
16
|
-
inputRef:
|
|
16
|
+
inputRef: l,
|
|
17
17
|
isLoading: E,
|
|
18
|
-
itemClassName:
|
|
18
|
+
itemClassName: i,
|
|
19
19
|
name: I,
|
|
20
|
-
searchable:
|
|
20
|
+
searchable: x = !1,
|
|
21
21
|
listItemSecondRowClassName: c,
|
|
22
|
-
wrapperInputRef:
|
|
22
|
+
wrapperInputRef: S,
|
|
23
23
|
isInfiniteScrollEnabled: u,
|
|
24
24
|
onFetchMoreOptions: f,
|
|
25
|
-
noOptionsText:
|
|
26
|
-
},
|
|
27
|
-
const n = C(null), m = C(null), [p,
|
|
28
|
-
isOpen:
|
|
25
|
+
noOptionsText: y
|
|
26
|
+
}, j) => {
|
|
27
|
+
const n = C(null), m = C(null), [p, L] = J(!1), {
|
|
28
|
+
isOpen: O,
|
|
29
29
|
searchTerm: g,
|
|
30
|
-
canFilter:
|
|
30
|
+
canFilter: P,
|
|
31
31
|
canContinueFetching: a,
|
|
32
32
|
page: d,
|
|
33
|
-
options:
|
|
33
|
+
options: w,
|
|
34
34
|
isTyping: k,
|
|
35
35
|
setOptions: T,
|
|
36
|
-
setPage:
|
|
37
|
-
setCanContinueFetching:
|
|
36
|
+
setPage: U,
|
|
37
|
+
setCanContinueFetching: _
|
|
38
38
|
} = $();
|
|
39
|
-
K(
|
|
40
|
-
const h =
|
|
39
|
+
K(j, () => n.current, [n]);
|
|
40
|
+
const h = x && P ? w.filter((e) => {
|
|
41
41
|
const t = g.toLowerCase();
|
|
42
42
|
return (typeof e.label == "string" ? e.label.toLowerCase() : "").includes(t);
|
|
43
|
-
}) :
|
|
43
|
+
}) : w;
|
|
44
44
|
W({
|
|
45
45
|
ulRef: n,
|
|
46
|
-
wrapperInputRef:
|
|
47
|
-
searchable:
|
|
46
|
+
wrapperInputRef: S,
|
|
47
|
+
searchable: x,
|
|
48
48
|
filteredOptions: h
|
|
49
49
|
});
|
|
50
|
-
const
|
|
51
|
-
(e, t,
|
|
52
|
-
),
|
|
50
|
+
const q = h.filter(
|
|
51
|
+
(e, t, s) => t === s.findIndex((v) => v.value === e.value)
|
|
52
|
+
), z = h.length === 0, A = M(
|
|
53
53
|
() => B(async (e) => {
|
|
54
54
|
const [t] = e;
|
|
55
55
|
if (t.isIntersecting && !p && f && a)
|
|
56
56
|
try {
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
page:
|
|
57
|
+
L(!0);
|
|
58
|
+
const s = d + 1, { data: v, hasMore: D } = await f({
|
|
59
|
+
page: s,
|
|
60
60
|
pageSize: Y,
|
|
61
61
|
termOfSearch: g
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
U(s), _(D), T((H) => [...H, ...v]);
|
|
64
64
|
} catch {
|
|
65
65
|
console.error("Error fetching more options");
|
|
66
66
|
} finally {
|
|
67
|
-
|
|
67
|
+
L(!1);
|
|
68
68
|
}
|
|
69
69
|
}, 100),
|
|
70
70
|
[p, f, g, d]
|
|
71
71
|
);
|
|
72
72
|
return Q(() => {
|
|
73
73
|
if (u && a && m.current && !k) {
|
|
74
|
-
const e = new IntersectionObserver(
|
|
74
|
+
const e = new IntersectionObserver(A, {
|
|
75
75
|
threshold: 0.1
|
|
76
76
|
});
|
|
77
77
|
return e.observe(m.current), () => e.disconnect();
|
|
@@ -88,36 +88,36 @@ const fe = G(
|
|
|
88
88
|
ref: n,
|
|
89
89
|
title: I,
|
|
90
90
|
role: "listbox",
|
|
91
|
-
className:
|
|
92
|
-
"data-state":
|
|
91
|
+
className: o(X({ className: N })),
|
|
92
|
+
"data-state": O ? "open" : "closed",
|
|
93
93
|
children: [
|
|
94
94
|
E ? /* @__PURE__ */ r(
|
|
95
95
|
b,
|
|
96
96
|
{
|
|
97
|
-
className:
|
|
97
|
+
className: o("select-none", i),
|
|
98
98
|
isClickable: !1,
|
|
99
|
-
inputRef:
|
|
99
|
+
inputRef: l,
|
|
100
100
|
value: "Loading...",
|
|
101
101
|
label: "Loading...",
|
|
102
102
|
listItemSecondRowClassName: c
|
|
103
103
|
}
|
|
104
|
-
) :
|
|
104
|
+
) : z ? /* @__PURE__ */ r(
|
|
105
105
|
b,
|
|
106
106
|
{
|
|
107
107
|
isEmpty: !0,
|
|
108
|
-
className:
|
|
108
|
+
className: o("select-none", i),
|
|
109
109
|
isClickable: !1,
|
|
110
|
-
inputRef:
|
|
111
|
-
value:
|
|
112
|
-
label:
|
|
110
|
+
inputRef: l,
|
|
111
|
+
value: y ?? "",
|
|
112
|
+
label: y ?? "No options",
|
|
113
113
|
listItemSecondRowClassName: c
|
|
114
114
|
}
|
|
115
|
-
) :
|
|
115
|
+
) : q.map((e) => /* @__PURE__ */ r(
|
|
116
116
|
b,
|
|
117
117
|
{
|
|
118
|
-
className:
|
|
118
|
+
className: o("select-none", i),
|
|
119
119
|
isClickable: !0,
|
|
120
|
-
inputRef:
|
|
120
|
+
inputRef: l,
|
|
121
121
|
listItemSecondRowClassName: c,
|
|
122
122
|
...e
|
|
123
123
|
},
|
|
@@ -137,14 +137,17 @@ const fe = G(
|
|
|
137
137
|
F?.map((e, t) => /* @__PURE__ */ r("li", { role: "option", "data-action": "true", children: /* @__PURE__ */ r(
|
|
138
138
|
Z,
|
|
139
139
|
{
|
|
140
|
-
className:
|
|
140
|
+
className: o(
|
|
141
141
|
"flex",
|
|
142
|
-
"
|
|
142
|
+
"min-h-10",
|
|
143
|
+
"py-2",
|
|
144
|
+
"px-6",
|
|
143
145
|
"w-full",
|
|
144
146
|
"h-full",
|
|
145
147
|
"gap-1",
|
|
146
148
|
"items-center",
|
|
147
149
|
"text-sm",
|
|
150
|
+
"[&>svg]:-ml-1",
|
|
148
151
|
"[&>svg]:w-3.5",
|
|
149
152
|
"[&>svg]:h-3.5",
|
|
150
153
|
"[&>svg]:shrink-0",
|
|
@@ -152,7 +155,9 @@ const fe = G(
|
|
|
152
155
|
"select-none",
|
|
153
156
|
"hover:bg-gray-50",
|
|
154
157
|
"hover:dark:bg-metal-700",
|
|
155
|
-
"focus:outline-0"
|
|
158
|
+
"focus:outline-0",
|
|
159
|
+
"text-blue-600",
|
|
160
|
+
"dark:text-aurora-500"
|
|
156
161
|
),
|
|
157
162
|
children: e
|
|
158
163
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
const
|
|
1
|
+
import { c as t } from "../../../../index-D29mdTf5.js";
|
|
2
|
+
const o = t([
|
|
3
|
+
"scrollbar",
|
|
3
4
|
"absolute",
|
|
4
5
|
"bg-white",
|
|
5
6
|
"border",
|
|
@@ -11,7 +12,7 @@ const t = o([
|
|
|
11
12
|
"top-full",
|
|
12
13
|
"w-full",
|
|
13
14
|
"z-10",
|
|
14
|
-
"max-h-
|
|
15
|
+
"max-h-44",
|
|
15
16
|
"overflow-y-auto",
|
|
16
17
|
"border-gray-200",
|
|
17
18
|
"text-zinc-700",
|
|
@@ -21,8 +22,10 @@ const t = o([
|
|
|
21
22
|
"duration-200",
|
|
22
23
|
"dark:bg-metal-800",
|
|
23
24
|
"dark:border-metal-700",
|
|
24
|
-
"dark:text-metal-50"
|
|
25
|
+
"dark:text-metal-50",
|
|
26
|
+
"[&>li:first-child]:mt-2",
|
|
27
|
+
"[&>li:last-child]:mb-2"
|
|
25
28
|
]);
|
|
26
29
|
export {
|
|
27
|
-
|
|
30
|
+
o as listVariants
|
|
28
31
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as n, jsxs as d } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as I, useCallback as u } from "react";
|
|
3
|
-
import { cn as
|
|
3
|
+
import { cn as s } from "../../../../utils/index.js";
|
|
4
4
|
import { Typography as y } from "../../../Typography/Typography.js";
|
|
5
5
|
import { listItemVariants as L } from "./ListItem.variants.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useSelectContext as V } from "../../contexts/select.hook.js";
|
|
7
7
|
function j(c, r) {
|
|
8
8
|
const i = r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp(`(${i})`, "gi");
|
|
9
9
|
return c.split(o).map((a, t) => a.toLowerCase() === r.toLowerCase() ? /* @__PURE__ */ n(
|
|
@@ -23,18 +23,18 @@ const K = ({
|
|
|
23
23
|
listItemSecondRowClassName: a,
|
|
24
24
|
...t
|
|
25
25
|
}) => {
|
|
26
|
-
const { searchTerm: m, highlightSearchEnabled: h, setValue:
|
|
26
|
+
const { searchTerm: m, highlightSearchEnabled: h, setValue: x, toggleOpen: g } = V(), b = I(null), f = u(
|
|
27
27
|
(e) => {
|
|
28
|
-
|
|
28
|
+
x(e.value, o), g(!1);
|
|
29
29
|
},
|
|
30
|
-
[
|
|
31
|
-
),
|
|
32
|
-
(e,
|
|
33
|
-
e.key === "Enter" && (e.stopPropagation(), f(
|
|
30
|
+
[x, g]
|
|
31
|
+
), N = u(
|
|
32
|
+
(e, l) => {
|
|
33
|
+
e.key === "Enter" && (e.stopPropagation(), f(l));
|
|
34
34
|
},
|
|
35
35
|
[f]
|
|
36
|
-
),
|
|
37
|
-
({ label: e, rightComponent:
|
|
36
|
+
), w = u(
|
|
37
|
+
({ label: e, rightComponent: l, subLabel: p, rightComponentClassName: C }) => {
|
|
38
38
|
if (c)
|
|
39
39
|
return /* @__PURE__ */ n(
|
|
40
40
|
y,
|
|
@@ -53,25 +53,25 @@ const K = ({
|
|
|
53
53
|
variant: "body2",
|
|
54
54
|
className: "text-zinc-700 dark:text-metal-50 font-medium",
|
|
55
55
|
children: [
|
|
56
|
-
|
|
56
|
+
l ? /* @__PURE__ */ d(
|
|
57
57
|
"span",
|
|
58
58
|
{
|
|
59
|
-
className:
|
|
59
|
+
className: s("flex gap-2 items-center", C),
|
|
60
60
|
children: [
|
|
61
61
|
k,
|
|
62
62
|
" ",
|
|
63
|
-
|
|
63
|
+
l
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
) : k,
|
|
67
|
-
|
|
67
|
+
p ? /* @__PURE__ */ n(
|
|
68
68
|
"span",
|
|
69
69
|
{
|
|
70
|
-
className:
|
|
70
|
+
className: s(
|
|
71
71
|
"block font-normal text-sm text-metal-800 dark:text-metal-50",
|
|
72
72
|
a
|
|
73
73
|
),
|
|
74
|
-
children:
|
|
74
|
+
children: p
|
|
75
75
|
}
|
|
76
76
|
) : null
|
|
77
77
|
]
|
|
@@ -86,17 +86,17 @@ const K = ({
|
|
|
86
86
|
ref: b,
|
|
87
87
|
role: "option",
|
|
88
88
|
"data-action": "false",
|
|
89
|
-
className:
|
|
89
|
+
className: s(L({ className: i })),
|
|
90
90
|
tabIndex: 0,
|
|
91
91
|
onClick: (e) => {
|
|
92
92
|
r && (f(t), e.stopPropagation());
|
|
93
93
|
},
|
|
94
|
-
onKeyDown: (e) =>
|
|
94
|
+
onKeyDown: (e) => N(e, t),
|
|
95
95
|
children: [
|
|
96
96
|
t.leftIcon ? /* @__PURE__ */ n(
|
|
97
97
|
"span",
|
|
98
98
|
{
|
|
99
|
-
className:
|
|
99
|
+
className: s(
|
|
100
100
|
"w-4 h-4 flex justify-center",
|
|
101
101
|
{
|
|
102
102
|
"items-center": !t.subLabel,
|
|
@@ -107,7 +107,7 @@ const K = ({
|
|
|
107
107
|
children: t.leftIcon
|
|
108
108
|
}
|
|
109
109
|
) : null,
|
|
110
|
-
|
|
110
|
+
w(t)
|
|
111
111
|
]
|
|
112
112
|
}
|
|
113
113
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as r } from "../../../../index-D29mdTf5.js";
|
|
2
2
|
const t = r([
|
|
3
3
|
"cursor-pointer",
|
|
4
|
-
"py-
|
|
5
|
-
"px-
|
|
4
|
+
"py-1.5",
|
|
5
|
+
"px-6",
|
|
6
6
|
"h-full",
|
|
7
7
|
"focus-visible:outline-none",
|
|
8
8
|
"m-0",
|
|
@@ -12,6 +12,7 @@ const t = r([
|
|
|
12
12
|
"gap-3",
|
|
13
13
|
"transition-bg",
|
|
14
14
|
"duration-250",
|
|
15
|
+
"min-h-10",
|
|
15
16
|
"hover:bg-gray-50",
|
|
16
17
|
"focus:bg-gray-50",
|
|
17
18
|
"dark:hover:bg-metal-700",
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Z, useId as ee, useRef as
|
|
3
|
-
import { S as
|
|
4
|
-
import { Typography as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { labelVariants as
|
|
7
|
-
import {
|
|
2
|
+
import { forwardRef as Z, useId as ee, useRef as w, useMemo as te, useImperativeHandle as ae, useEffect as re } from "react";
|
|
3
|
+
import { S as le } from "../../../loader-juvMSJ9L.js";
|
|
4
|
+
import { Typography as ne } from "../../Typography/Typography.js";
|
|
5
|
+
import { cn as n } from "../../../utils/index.js";
|
|
6
|
+
import { labelVariants as oe, inputVariants as se, selectVariants as ce } from "../Select.variants.js";
|
|
7
|
+
import { useSelect as ie } from "../hooks/useSelect.js";
|
|
8
8
|
import { List as me } from "./List/List.js";
|
|
9
9
|
import { c as pe } from "../../../createLucideIcon-D4r5Phnh.js";
|
|
10
10
|
import { C as ue } from "../../../chevron-up-DrQr2Fwd.js";
|
|
11
|
-
import {
|
|
11
|
+
import { useSelectContext as fe } from "../contexts/select.hook.js";
|
|
12
12
|
const de = [
|
|
13
13
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
14
14
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
@@ -20,69 +20,69 @@ const de = [
|
|
|
20
20
|
disabled: t = !1,
|
|
21
21
|
error: f,
|
|
22
22
|
iconClassName: R,
|
|
23
|
-
inputClassName:
|
|
23
|
+
inputClassName: S,
|
|
24
|
+
isInfiniteScrollEnabled: F = !1,
|
|
24
25
|
isLoading: g,
|
|
25
26
|
isRequired: h,
|
|
26
27
|
label: v,
|
|
27
|
-
labelClassName:
|
|
28
|
-
listClassName:
|
|
29
|
-
listItemClassName:
|
|
30
|
-
listItemSecondRowClassName:
|
|
28
|
+
labelClassName: T,
|
|
29
|
+
listClassName: E,
|
|
30
|
+
listItemClassName: M,
|
|
31
|
+
listItemSecondRowClassName: W,
|
|
31
32
|
name: d,
|
|
32
|
-
|
|
33
|
+
noOptionsText: _,
|
|
34
|
+
placeholder: N,
|
|
33
35
|
searchable: k = !1,
|
|
34
|
-
showSearchIcon:
|
|
35
|
-
theme:
|
|
36
|
-
wrapperClassName:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
onSearchChange: P,
|
|
41
|
-
noOptionsText: U,
|
|
36
|
+
showSearchIcon: C,
|
|
37
|
+
theme: $,
|
|
38
|
+
wrapperClassName: H,
|
|
39
|
+
onFetchMoreOptions: P,
|
|
40
|
+
onBlur: U,
|
|
41
|
+
onSearchChange: q,
|
|
42
42
|
...y
|
|
43
|
-
},
|
|
44
|
-
const I = ee(), s =
|
|
45
|
-
isOpen:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setSearchTerm:
|
|
51
|
-
|
|
43
|
+
}, A) => {
|
|
44
|
+
const I = ee(), s = w(null), L = w(null), B = w(0), {
|
|
45
|
+
isOpen: c,
|
|
46
|
+
options: l,
|
|
47
|
+
searchTerm: D,
|
|
48
|
+
value: o,
|
|
49
|
+
setCanFilter: G,
|
|
50
|
+
setSearchTerm: J,
|
|
51
|
+
setValue: i,
|
|
52
52
|
toggleOpen: K
|
|
53
|
-
} = fe(), e = te(() =>
|
|
53
|
+
} = fe(), e = te(() => l.find(({ value: a }) => a === o), [l, o]), { wrapperRef: Q, wrapperInputRef: V, handleOpen: j } = ie({
|
|
54
54
|
ulRef: L,
|
|
55
55
|
inputRef: s,
|
|
56
56
|
disabled: t,
|
|
57
57
|
internalValue: e,
|
|
58
|
-
onBlur:
|
|
58
|
+
onBlur: U
|
|
59
59
|
}), m = d ? `${I}-${d}` : I;
|
|
60
|
-
ae(
|
|
61
|
-
if (x && !
|
|
62
|
-
const a =
|
|
63
|
-
a &&
|
|
60
|
+
ae(A, () => s.current, [s]), re(() => {
|
|
61
|
+
if (x && !o) {
|
|
62
|
+
const a = l && l.find((p) => p.value === x);
|
|
63
|
+
a && i(a.value);
|
|
64
64
|
}
|
|
65
|
-
}, [x,
|
|
65
|
+
}, [x, l, i, o]);
|
|
66
66
|
const X = (a) => {
|
|
67
67
|
const p = a.target.value;
|
|
68
|
-
|
|
69
|
-
const O =
|
|
68
|
+
G(!0), i(""), J(p ?? ""), q?.(p);
|
|
69
|
+
const O = l.find(
|
|
70
70
|
(Y) => Y.value.toLocaleLowerCase() === p.toLocaleLowerCase()
|
|
71
71
|
);
|
|
72
|
-
|
|
72
|
+
i(O ? O.value : e?.value ?? "");
|
|
73
73
|
};
|
|
74
74
|
return /* @__PURE__ */ u(
|
|
75
75
|
"div",
|
|
76
76
|
{
|
|
77
77
|
ref: Q,
|
|
78
|
-
className:
|
|
79
|
-
"data-theme":
|
|
78
|
+
className: n("flex flex-col w-full relative", H),
|
|
79
|
+
"data-theme": $,
|
|
80
80
|
children: [
|
|
81
81
|
v ? /* @__PURE__ */ u(
|
|
82
82
|
"label",
|
|
83
83
|
{
|
|
84
84
|
id: m,
|
|
85
|
-
className:
|
|
85
|
+
className: n(oe({ className: T })),
|
|
86
86
|
htmlFor: m,
|
|
87
87
|
onClick: () => !t && j(),
|
|
88
88
|
children: [
|
|
@@ -96,21 +96,21 @@ const de = [
|
|
|
96
96
|
{
|
|
97
97
|
ref: V,
|
|
98
98
|
id: m,
|
|
99
|
-
className:
|
|
100
|
-
|
|
99
|
+
className: n(
|
|
100
|
+
ce({ className: z, hasError: !!f, disabled: t })
|
|
101
101
|
),
|
|
102
102
|
role: "combobox",
|
|
103
|
-
onClick: () => !t && K(!
|
|
104
|
-
"aria-expanded":
|
|
105
|
-
tabIndex:
|
|
103
|
+
onClick: () => !t && K(!c),
|
|
104
|
+
"aria-expanded": c,
|
|
105
|
+
tabIndex: B.current,
|
|
106
106
|
"aria-labelledby": m,
|
|
107
107
|
children: [
|
|
108
108
|
/* @__PURE__ */ u("div", { className: "flex gap-2.5 items-center flex-1", children: [
|
|
109
|
-
e?.leftIcon && !
|
|
110
|
-
|
|
109
|
+
e?.leftIcon && !C && /* @__PURE__ */ r("span", { className: "w-4 h-4 flex justify-center items-center dark:text-metal-50", children: e.leftIcon }),
|
|
110
|
+
C && /* @__PURE__ */ r(
|
|
111
111
|
xe,
|
|
112
112
|
{
|
|
113
|
-
className:
|
|
113
|
+
className: n(
|
|
114
114
|
"w-4",
|
|
115
115
|
"h-4",
|
|
116
116
|
"text-zinc-500",
|
|
@@ -126,16 +126,16 @@ const de = [
|
|
|
126
126
|
"input",
|
|
127
127
|
{
|
|
128
128
|
type: "text",
|
|
129
|
-
value:
|
|
129
|
+
value: c ? D : e?.label ?? o ?? "",
|
|
130
130
|
onChange: X,
|
|
131
|
-
placeholder:
|
|
132
|
-
className:
|
|
131
|
+
placeholder: N,
|
|
132
|
+
className: n(se({ className: S }), {
|
|
133
133
|
"text-red-700 placeholder:text-red-700": !!f
|
|
134
134
|
}),
|
|
135
135
|
onClick: (a) => {
|
|
136
136
|
a.stopPropagation(), t || j();
|
|
137
137
|
},
|
|
138
|
-
"aria-label": v ||
|
|
138
|
+
"aria-label": v || N,
|
|
139
139
|
"aria-labelledby": m,
|
|
140
140
|
required: h,
|
|
141
141
|
autoComplete: "off",
|
|
@@ -145,10 +145,10 @@ const de = [
|
|
|
145
145
|
...y
|
|
146
146
|
}
|
|
147
147
|
) : /* @__PURE__ */ u(
|
|
148
|
-
|
|
148
|
+
ne,
|
|
149
149
|
{
|
|
150
150
|
variant: "body2",
|
|
151
|
-
className:
|
|
151
|
+
className: n(
|
|
152
152
|
"flex-1 text-zinc-400 text-sm dark:text-metal-400 flex gap-2 items-center",
|
|
153
153
|
{
|
|
154
154
|
"text-red-700": !!f,
|
|
@@ -159,18 +159,18 @@ const de = [
|
|
|
159
159
|
e?.wrapperClassNameOnSelectedValue
|
|
160
160
|
),
|
|
161
161
|
children: [
|
|
162
|
-
e?.label ||
|
|
162
|
+
e?.label || N,
|
|
163
163
|
" ",
|
|
164
164
|
e?.showRightComponentOnselectedValue ? e?.rightComponent : null
|
|
165
165
|
]
|
|
166
166
|
}
|
|
167
167
|
)
|
|
168
168
|
] }),
|
|
169
|
-
g ? /* @__PURE__ */ r(
|
|
169
|
+
g ? /* @__PURE__ */ r(le, { className: "w-4 h-4 text-metal-400 animate-spin select-none" }) : !C && /* @__PURE__ */ r(
|
|
170
170
|
ue,
|
|
171
171
|
{
|
|
172
|
-
"data-state":
|
|
173
|
-
className:
|
|
172
|
+
"data-state": c ? "open" : "closed",
|
|
173
|
+
className: n(
|
|
174
174
|
"w-4 h-4 text-zinc-500 transition-all duration-100 data-[state=open]:rotate-0 data-[state=closed]:rotate-180 select-none dark:group-focus-within:text-metal-50",
|
|
175
175
|
R,
|
|
176
176
|
{
|
|
@@ -193,27 +193,27 @@ const de = [
|
|
|
193
193
|
"aria-hidden": "true",
|
|
194
194
|
required: h,
|
|
195
195
|
inert: !0,
|
|
196
|
-
defaultValue: e?.value ??
|
|
196
|
+
defaultValue: e?.value ?? o ?? void 0,
|
|
197
197
|
...y
|
|
198
198
|
}
|
|
199
199
|
),
|
|
200
|
-
|
|
200
|
+
c && /* @__PURE__ */ r(
|
|
201
201
|
me,
|
|
202
202
|
{
|
|
203
203
|
ref: L,
|
|
204
204
|
additionalOptions: b,
|
|
205
|
-
className:
|
|
206
|
-
itemClassName:
|
|
205
|
+
className: E,
|
|
206
|
+
itemClassName: M,
|
|
207
207
|
name: d,
|
|
208
208
|
wrapperInputRef: V,
|
|
209
209
|
inputRef: s,
|
|
210
|
-
options:
|
|
210
|
+
options: l,
|
|
211
211
|
isLoading: !!g,
|
|
212
212
|
searchable: k,
|
|
213
|
-
listItemSecondRowClassName:
|
|
214
|
-
isInfiniteScrollEnabled:
|
|
215
|
-
onFetchMoreOptions:
|
|
216
|
-
noOptionsText:
|
|
213
|
+
listItemSecondRowClassName: W,
|
|
214
|
+
isInfiniteScrollEnabled: F,
|
|
215
|
+
onFetchMoreOptions: P,
|
|
216
|
+
noOptionsText: _
|
|
217
217
|
}
|
|
218
218
|
)
|
|
219
219
|
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as e } from "react";
|
|
2
|
+
import { SelectContext as o } from "./select.context.js";
|
|
3
|
+
const c = () => {
|
|
4
|
+
const t = e(o);
|
|
5
|
+
if (!t)
|
|
6
|
+
throw new Error("useSelectContext must be used within a SelectProvider");
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
c as useSelectContext
|
|
11
|
+
};
|