@konstructio/ui 0.1.2-alpha.43 → 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} +8 -8
- package/dist/components/{Dropdown → Select}/components/List/List.js +73 -46
- package/dist/components/{Dropdown → Select}/components/List/List.variants.js +11 -8
- package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.js +34 -34
- package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.variants.js +5 -4
- package/dist/components/{Dropdown → Select}/components/Wrapper.js +88 -88
- 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
|
@@ -1,18 +1,18 @@
|
|
|
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 oe, inputVariants as
|
|
7
|
-
import {
|
|
8
|
-
import { List as
|
|
9
|
-
import { c as
|
|
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
|
+
import { List as me } from "./List/List.js";
|
|
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" }]
|
|
15
|
-
], xe =
|
|
15
|
+
], xe = pe("search", de), je = Z(
|
|
16
16
|
({
|
|
17
17
|
additionalOptions: b,
|
|
18
18
|
className: z,
|
|
@@ -20,70 +20,70 @@ 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(),
|
|
45
|
-
isOpen:
|
|
46
|
-
|
|
43
|
+
}, A) => {
|
|
44
|
+
const I = ee(), s = w(null), L = w(null), B = w(0), {
|
|
45
|
+
isOpen: c,
|
|
46
|
+
options: l,
|
|
47
|
+
searchTerm: D,
|
|
47
48
|
value: o,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setCanFilter: J,
|
|
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
|
-
inputRef:
|
|
55
|
+
inputRef: s,
|
|
56
56
|
disabled: t,
|
|
57
57
|
internalValue: e,
|
|
58
|
-
onBlur:
|
|
59
|
-
}),
|
|
60
|
-
ae(
|
|
58
|
+
onBlur: U
|
|
59
|
+
}), m = d ? `${I}-${d}` : I;
|
|
60
|
+
ae(A, () => s.current, [s]), re(() => {
|
|
61
61
|
if (x && !o) {
|
|
62
|
-
const a =
|
|
63
|
-
a &&
|
|
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
|
-
const
|
|
68
|
-
|
|
69
|
-
const O =
|
|
70
|
-
(Y) => Y.value.toLocaleLowerCase() ===
|
|
67
|
+
const p = a.target.value;
|
|
68
|
+
G(!0), i(""), J(p ?? ""), q?.(p);
|
|
69
|
+
const O = l.find(
|
|
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
|
-
id:
|
|
85
|
-
className:
|
|
86
|
-
htmlFor:
|
|
84
|
+
id: m,
|
|
85
|
+
className: n(oe({ className: T })),
|
|
86
|
+
htmlFor: m,
|
|
87
87
|
onClick: () => !t && j(),
|
|
88
88
|
children: [
|
|
89
89
|
v,
|
|
@@ -95,22 +95,22 @@ const de = [
|
|
|
95
95
|
"div",
|
|
96
96
|
{
|
|
97
97
|
ref: V,
|
|
98
|
-
id:
|
|
99
|
-
className:
|
|
100
|
-
|
|
98
|
+
id: m,
|
|
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:
|
|
106
|
-
"aria-labelledby":
|
|
103
|
+
onClick: () => !t && K(!c),
|
|
104
|
+
"aria-expanded": c,
|
|
105
|
+
tabIndex: B.current,
|
|
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",
|
|
@@ -118,7 +118,7 @@ const de = [
|
|
|
118
118
|
"transition-colors",
|
|
119
119
|
"duration-300",
|
|
120
120
|
"dark:text-metal-300",
|
|
121
|
-
"dark:group-focus-within:text-
|
|
121
|
+
"dark:group-focus-within:text-metal-50"
|
|
122
122
|
)
|
|
123
123
|
}
|
|
124
124
|
),
|
|
@@ -126,17 +126,17 @@ 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 ||
|
|
139
|
-
"aria-labelledby":
|
|
138
|
+
"aria-label": v || N,
|
|
139
|
+
"aria-labelledby": m,
|
|
140
140
|
required: h,
|
|
141
141
|
autoComplete: "off",
|
|
142
142
|
autoCapitalize: "words",
|
|
@@ -145,37 +145,37 @@ const de = [
|
|
|
145
145
|
...y
|
|
146
146
|
}
|
|
147
147
|
) : /* @__PURE__ */ u(
|
|
148
|
-
|
|
148
|
+
ne,
|
|
149
149
|
{
|
|
150
150
|
variant: "body2",
|
|
151
|
-
className:
|
|
152
|
-
"flex-1 text-zinc-400 text-sm dark:text-
|
|
151
|
+
className: n(
|
|
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,
|
|
155
155
|
"select-none": !e,
|
|
156
|
-
"text-
|
|
157
|
-
"text-
|
|
156
|
+
"text-metal-800 dark:text-metal-50": e,
|
|
157
|
+
"text-metal-400/50 dark:text-metal-50/50": t
|
|
158
158
|
},
|
|
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:
|
|
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-
|
|
172
|
+
"data-state": c ? "open" : "closed",
|
|
173
|
+
className: n(
|
|
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
|
{
|
|
177
177
|
"text-red-700": !!f,
|
|
178
|
-
"text-
|
|
178
|
+
"text-metal-400/50 dark:group-focus-within:text-zinc-500": t
|
|
179
179
|
}
|
|
180
180
|
)
|
|
181
181
|
}
|
|
@@ -186,7 +186,7 @@ const de = [
|
|
|
186
186
|
/* @__PURE__ */ r(
|
|
187
187
|
"input",
|
|
188
188
|
{
|
|
189
|
-
ref:
|
|
189
|
+
ref: s,
|
|
190
190
|
type: "text",
|
|
191
191
|
name: d,
|
|
192
192
|
className: "hidden",
|
|
@@ -197,23 +197,23 @@ const de = [
|
|
|
197
197
|
...y
|
|
198
198
|
}
|
|
199
199
|
),
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
c && /* @__PURE__ */ r(
|
|
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
|
-
inputRef:
|
|
210
|
-
options:
|
|
209
|
+
inputRef: s,
|
|
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
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as L } from "react/jsx-runtime";
|
|
2
|
+
import { useState as e, useRef as f, useCallback as T, useEffect as p } from "react";
|
|
3
|
+
import { SelectContext as N } from "./select.context.js";
|
|
4
|
+
import { useToggle as O } from "../../../hooks/useToggle.js";
|
|
5
|
+
const c = 1, R = 300, V = ({
|
|
6
|
+
children: C,
|
|
7
|
+
value: E,
|
|
8
|
+
name: i,
|
|
9
|
+
highlightSearch: S = !1,
|
|
10
|
+
options: n,
|
|
11
|
+
onChange: a,
|
|
12
|
+
onBlur: u
|
|
13
|
+
}) => {
|
|
14
|
+
const [d, l] = e(n), v = f(S), [F, g] = O(!1), [P, I] = e(""), [b, x] = e(!0), [A, o] = e(!0), [_, s] = e(c), [y, h] = e(!1), t = f(void 0), D = T(
|
|
15
|
+
(r, m) => {
|
|
16
|
+
m?.current && (m.current.value = r), t.current && clearTimeout(t.current), h(!0), o(!0), s(c), a?.({ target: { value: r, name: i ?? "" } }), u?.(), t.current = setTimeout(() => {
|
|
17
|
+
h(!1);
|
|
18
|
+
}, R);
|
|
19
|
+
},
|
|
20
|
+
[a, i, u]
|
|
21
|
+
), G = T(
|
|
22
|
+
(r) => {
|
|
23
|
+
g(r), o(!0), s(c);
|
|
24
|
+
},
|
|
25
|
+
[g]
|
|
26
|
+
);
|
|
27
|
+
return p(() => {
|
|
28
|
+
l(n);
|
|
29
|
+
}, [n.length]), p(() => () => {
|
|
30
|
+
t.current && clearTimeout(t.current);
|
|
31
|
+
}, []), /* @__PURE__ */ L(
|
|
32
|
+
N.Provider,
|
|
33
|
+
{
|
|
34
|
+
value: {
|
|
35
|
+
highlightSearchEnabled: v.current,
|
|
36
|
+
isOpen: F,
|
|
37
|
+
searchTerm: P,
|
|
38
|
+
value: E,
|
|
39
|
+
canFilter: b,
|
|
40
|
+
canContinueFetching: A,
|
|
41
|
+
page: _,
|
|
42
|
+
options: d,
|
|
43
|
+
isTyping: y,
|
|
44
|
+
setOptions: l,
|
|
45
|
+
setPage: s,
|
|
46
|
+
setCanContinueFetching: o,
|
|
47
|
+
setCanFilter: x,
|
|
48
|
+
setSearchTerm: I,
|
|
49
|
+
setValue: D,
|
|
50
|
+
toggleOpen: G
|
|
51
|
+
},
|
|
52
|
+
children: C
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
V as SelectProvider
|
|
58
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRef as g, useEffect as a } from "react";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
2
|
+
import { useSelectContext as k } from "../contexts/select.hook.js";
|
|
3
|
+
const d = ({
|
|
4
4
|
searchable: o,
|
|
5
5
|
ulRef: n,
|
|
6
6
|
wrapperInputRef: e,
|
|
@@ -46,5 +46,5 @@ const A = ({
|
|
|
46
46
|
}, [s]);
|
|
47
47
|
};
|
|
48
48
|
export {
|
|
49
|
-
|
|
49
|
+
d as useNavigationUlList
|
|
50
50
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { useRef as m, useEffect as c, useCallback as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
1
|
+
import { useRef as m, useEffect as c, useCallback as w } from "react";
|
|
2
|
+
import { useSelectContext as L } from "../contexts/select.hook.js";
|
|
3
|
+
const y = ({
|
|
4
4
|
ulRef: f,
|
|
5
|
-
inputRef:
|
|
6
|
-
disabled:
|
|
5
|
+
inputRef: r,
|
|
6
|
+
disabled: E,
|
|
7
7
|
internalValue: u,
|
|
8
8
|
onBlur: g
|
|
9
9
|
}) => {
|
|
10
|
-
const
|
|
10
|
+
const t = m(null), a = m(null), { value: i, setSearchTerm: v, setCanFilter: d, toggleOpen: n } = L();
|
|
11
11
|
c(() => {
|
|
12
|
-
const e = new AbortController(),
|
|
12
|
+
const e = new AbortController(), s = (l) => {
|
|
13
13
|
l.key === "Escape" && n(!1);
|
|
14
|
-
},
|
|
15
|
-
|
|
14
|
+
}, o = (l) => {
|
|
15
|
+
t.current?.contains(l.target) || n(!1);
|
|
16
16
|
};
|
|
17
|
-
return document.addEventListener("keydown",
|
|
17
|
+
return document.addEventListener("keydown", s, {
|
|
18
18
|
signal: e.signal
|
|
19
|
-
}), document.addEventListener("mousedown",
|
|
19
|
+
}), document.addEventListener("mousedown", o, {
|
|
20
20
|
signal: e.signal
|
|
21
21
|
}), document.addEventListener(
|
|
22
22
|
"visibilitychange",
|
|
@@ -29,20 +29,20 @@ const p = ({
|
|
|
29
29
|
), a.current?.addEventListener(
|
|
30
30
|
"focusin",
|
|
31
31
|
(l) => {
|
|
32
|
-
!
|
|
32
|
+
!E && l.target?.matches(":focus-visible") && n(!0);
|
|
33
33
|
},
|
|
34
34
|
{ signal: e.signal }
|
|
35
35
|
), () => {
|
|
36
36
|
e.abort();
|
|
37
37
|
};
|
|
38
|
-
}, [n,
|
|
38
|
+
}, [n, t]), c(() => {
|
|
39
39
|
const e = new AbortController();
|
|
40
40
|
return a.current?.addEventListener(
|
|
41
41
|
"keydown",
|
|
42
|
-
(
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
|
|
42
|
+
(s) => {
|
|
43
|
+
if (s.key === "ArrowDown") {
|
|
44
|
+
const o = f.current?.querySelector("li");
|
|
45
|
+
o && o.focus();
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
{ signal: e.signal }
|
|
@@ -51,13 +51,13 @@ const p = ({
|
|
|
51
51
|
};
|
|
52
52
|
}, [a, f]), c(() => {
|
|
53
53
|
const e = new AbortController();
|
|
54
|
-
return
|
|
54
|
+
return r?.current?.addEventListener(
|
|
55
55
|
"focusin",
|
|
56
56
|
() => {
|
|
57
57
|
v(u?.value ?? ""), d(!1);
|
|
58
58
|
},
|
|
59
59
|
{ signal: e.signal }
|
|
60
|
-
),
|
|
60
|
+
), r?.current?.addEventListener(
|
|
61
61
|
"focusout",
|
|
62
62
|
() => {
|
|
63
63
|
d(!0);
|
|
@@ -69,35 +69,35 @@ const p = ({
|
|
|
69
69
|
d(!1);
|
|
70
70
|
},
|
|
71
71
|
{ signal: e.signal }
|
|
72
|
-
),
|
|
72
|
+
), t.current?.addEventListener(
|
|
73
73
|
"focusout",
|
|
74
|
-
(
|
|
75
|
-
|
|
74
|
+
(s) => {
|
|
75
|
+
t.current?.contains(s.relatedTarget) || n(!1);
|
|
76
76
|
},
|
|
77
77
|
{ signal: e.signal }
|
|
78
78
|
), () => {
|
|
79
79
|
e.abort();
|
|
80
80
|
};
|
|
81
81
|
}, [i]), c(() => {
|
|
82
|
-
|
|
82
|
+
r?.current && (r.current.value = i && u?.value || "");
|
|
83
83
|
}, [u, i]), c(() => {
|
|
84
84
|
const e = new AbortController();
|
|
85
|
-
return
|
|
86
|
-
const
|
|
87
|
-
(!
|
|
85
|
+
return t.current?.addEventListener("focusout", (s) => {
|
|
86
|
+
const o = s.relatedTarget;
|
|
87
|
+
(!o || !t.current?.contains(o)) && (r?.current?.value || g?.());
|
|
88
88
|
}), () => {
|
|
89
89
|
e.abort();
|
|
90
90
|
};
|
|
91
|
-
}, [n,
|
|
92
|
-
const
|
|
93
|
-
n(!0), requestAnimationFrame(() =>
|
|
94
|
-
}, [
|
|
91
|
+
}, [n, t, v, g, i]);
|
|
92
|
+
const b = w(() => {
|
|
93
|
+
n(!0), requestAnimationFrame(() => r?.current?.focus());
|
|
94
|
+
}, [r, n]);
|
|
95
95
|
return {
|
|
96
|
-
wrapperRef:
|
|
96
|
+
wrapperRef: t,
|
|
97
97
|
wrapperInputRef: a,
|
|
98
|
-
handleOpen:
|
|
98
|
+
handleOpen: b
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
101
|
export {
|
|
102
|
-
|
|
102
|
+
y as useSelect
|
|
103
103
|
};
|