@yamada-ui/autocomplete 1.5.4-dev-20241005224505 → 1.5.4-dev-20241006032009
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/autocomplete-context.d.mts +115 -115
- package/dist/autocomplete-context.d.ts +115 -115
- package/dist/autocomplete-context.js +2 -2
- package/dist/autocomplete-context.js.map +1 -1
- package/dist/autocomplete-context.mjs +1 -1
- package/dist/autocomplete-create.d.mts +4 -4
- package/dist/autocomplete-create.d.ts +4 -4
- package/dist/autocomplete-create.js +32 -32
- package/dist/autocomplete-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +4 -4
- package/dist/autocomplete-empty.d.mts +4 -4
- package/dist/autocomplete-empty.d.ts +4 -4
- package/dist/autocomplete-empty.js +34 -34
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +4 -4
- package/dist/autocomplete-icon.js +17 -17
- package/dist/autocomplete-icon.js.map +1 -1
- package/dist/autocomplete-icon.mjs +2 -2
- package/dist/autocomplete-list.d.mts +2 -2
- package/dist/autocomplete-list.d.ts +2 -2
- package/dist/autocomplete-list.js +18 -18
- package/dist/autocomplete-list.js.map +1 -1
- package/dist/autocomplete-list.mjs +3 -3
- package/dist/autocomplete-option-group.js +14 -14
- package/dist/autocomplete-option-group.js.map +1 -1
- package/dist/autocomplete-option-group.mjs +3 -3
- package/dist/autocomplete-option.d.mts +1 -1
- package/dist/autocomplete-option.d.ts +1 -1
- package/dist/autocomplete-option.js +47 -47
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +4 -4
- package/dist/autocomplete.d.mts +31 -31
- package/dist/autocomplete.d.ts +31 -31
- package/dist/autocomplete.js +299 -297
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +12 -12
- package/dist/{chunk-5GKGL6BL.mjs → chunk-2MVSDK7L.mjs} +16 -16
- package/dist/chunk-2MVSDK7L.mjs.map +1 -0
- package/dist/{chunk-JMX72TSD.mjs → chunk-2SISETLV.mjs} +11 -11
- package/dist/{chunk-JMX72TSD.mjs.map → chunk-2SISETLV.mjs.map} +1 -1
- package/dist/{chunk-OLOU5HFC.mjs → chunk-4APEPTYJ.mjs} +169 -167
- package/dist/chunk-4APEPTYJ.mjs.map +1 -0
- package/dist/{chunk-6F3LT7J6.mjs → chunk-EWV3Q3S4.mjs} +7 -7
- package/dist/{chunk-6F3LT7J6.mjs.map → chunk-EWV3Q3S4.mjs.map} +1 -1
- package/dist/{chunk-Q2HZVVOI.mjs → chunk-I4IW2CW7.mjs} +16 -16
- package/dist/chunk-I4IW2CW7.mjs.map +1 -0
- package/dist/{chunk-7SWSKLSA.mjs → chunk-I5X4WSCX.mjs} +18 -18
- package/dist/chunk-I5X4WSCX.mjs.map +1 -0
- package/dist/{chunk-HZECQUHV.mjs → chunk-PXQD7AV2.mjs} +40 -40
- package/dist/{chunk-HZECQUHV.mjs.map → chunk-PXQD7AV2.mjs.map} +1 -1
- package/dist/{chunk-QPIWG4ZF.mjs → chunk-TJGVRIGK.mjs} +62 -60
- package/dist/chunk-TJGVRIGK.mjs.map +1 -0
- package/dist/{chunk-R76HPAN4.mjs → chunk-TR4X4EEG.mjs} +7 -7
- package/dist/{chunk-R76HPAN4.mjs.map → chunk-TR4X4EEG.mjs.map} +1 -1
- package/dist/{chunk-S53LMDD7.mjs → chunk-VTBUO5SK.mjs} +15 -15
- package/dist/chunk-VTBUO5SK.mjs.map +1 -0
- package/dist/{chunk-JPUKYLBW.mjs → chunk-WDQYM4FP.mjs} +5 -5
- package/dist/chunk-WDQYM4FP.mjs.map +1 -0
- package/dist/{chunk-S2HFYJVI.mjs → chunk-ZEGANG5C.mjs} +13 -13
- package/dist/chunk-ZEGANG5C.mjs.map +1 -0
- package/dist/{chunk-5LPWFWE6.mjs → chunk-ZJFWWXQM.mjs} +34 -34
- package/dist/chunk-ZJFWWXQM.mjs.map +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +351 -347
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/multi-autocomplete.d.mts +51 -51
- package/dist/multi-autocomplete.d.ts +51 -51
- package/dist/multi-autocomplete.js +321 -317
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +12 -12
- package/dist/use-autocomplete-list.d.mts +1 -1
- package/dist/use-autocomplete-list.d.ts +1 -1
- package/dist/use-autocomplete-list.js +7 -7
- package/dist/use-autocomplete-list.js.map +1 -1
- package/dist/use-autocomplete-list.mjs +2 -2
- package/dist/use-autocomplete-option-group.js +11 -11
- package/dist/use-autocomplete-option-group.js.map +1 -1
- package/dist/use-autocomplete-option-group.mjs +2 -2
- package/dist/use-autocomplete-option.d.mts +12 -12
- package/dist/use-autocomplete-option.d.ts +12 -12
- package/dist/use-autocomplete-option.js +34 -34
- package/dist/use-autocomplete-option.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +2 -2
- package/dist/use-autocomplete.d.mts +86 -86
- package/dist/use-autocomplete.d.ts +86 -86
- package/dist/use-autocomplete.js +221 -219
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +7 -7
- package/package.json +13 -13
- package/dist/chunk-5GKGL6BL.mjs.map +0 -1
- package/dist/chunk-5LPWFWE6.mjs.map +0 -1
- package/dist/chunk-7SWSKLSA.mjs.map +0 -1
- package/dist/chunk-JPUKYLBW.mjs.map +0 -1
- package/dist/chunk-OLOU5HFC.mjs.map +0 -1
- package/dist/chunk-Q2HZVVOI.mjs.map +0 -1
- package/dist/chunk-QPIWG4ZF.mjs.map +0 -1
- package/dist/chunk-S2HFYJVI.mjs.map +0 -1
- package/dist/chunk-S53LMDD7.mjs.map +0 -1
@@ -1,15 +1,15 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
AutocompleteOptionGroup
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-EWV3Q3S4.mjs";
|
5
5
|
import {
|
6
6
|
AutocompleteOption
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-ZEGANG5C.mjs";
|
8
8
|
import {
|
9
9
|
useAutocompleteContext,
|
10
10
|
useAutocompleteDescendants,
|
11
11
|
useAutocompleteDescendantsContext
|
12
|
-
} from "./chunk-
|
12
|
+
} from "./chunk-WDQYM4FP.mjs";
|
13
13
|
|
14
14
|
// src/use-autocomplete.tsx
|
15
15
|
import { layoutStyleProperties } from "@yamada-ui/core";
|
@@ -24,78 +24,93 @@ import {
|
|
24
24
|
dataAttr,
|
25
25
|
funcAll,
|
26
26
|
getEventRelatedTarget,
|
27
|
+
getValidChildren,
|
27
28
|
handlerAll,
|
28
29
|
isArray,
|
29
30
|
isContains,
|
31
|
+
isUndefined,
|
30
32
|
mergeRefs,
|
31
33
|
pickObject,
|
32
34
|
splitObject,
|
33
35
|
useUnmountEffect,
|
34
|
-
useUpdateEffect
|
35
|
-
getValidChildren,
|
36
|
-
isUndefined
|
36
|
+
useUpdateEffect
|
37
37
|
} from "@yamada-ui/utils";
|
38
38
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
39
39
|
import { jsx } from "react/jsx-runtime";
|
40
40
|
var kanaMap = {
|
41
|
-
\
|
42
|
-
\
|
43
|
-
\
|
44
|
-
\
|
45
|
-
\
|
46
|
-
\
|
47
|
-
\uFF7C\uFF9E: "\u30B8",
|
48
|
-
\uFF7D\uFF9E: "\u30BA",
|
49
|
-
\uFF7E\uFF9E: "\u30BC",
|
50
|
-
\uFF7F\uFF9E: "\u30BE",
|
51
|
-
\uFF80\uFF9E: "\u30C0",
|
52
|
-
\uFF81\uFF9E: "\u30C2",
|
53
|
-
\uFF82\uFF9E: "\u30C5",
|
54
|
-
\uFF83\uFF9E: "\u30C7",
|
55
|
-
\uFF84\uFF9E: "\u30C9",
|
56
|
-
\uFF8A\uFF9E: "\u30D0",
|
57
|
-
\uFF8B\uFF9E: "\u30D3",
|
58
|
-
\uFF8C\uFF9E: "\u30D6",
|
59
|
-
\uFF8D\uFF9E: "\u30D9",
|
60
|
-
\uFF8E\uFF9E: "\u30DC",
|
61
|
-
\uFF8A\uFF9F: "\u30D1",
|
62
|
-
\uFF8B\uFF9F: "\u30D4",
|
63
|
-
\uFF8C\uFF9F: "\u30D7",
|
64
|
-
\uFF8D\uFF9F: "\u30DA",
|
65
|
-
\uFF8E\uFF9F: "\u30DD",
|
66
|
-
\uFF73\uFF9E: "\u30F4",
|
67
|
-
\uFF9C\uFF9E: "\u30F7",
|
41
|
+
"\uFF61": "\u3002",
|
42
|
+
"\uFF62": "\u300C",
|
43
|
+
"\uFF63": "\u300D",
|
44
|
+
"\uFF64": "\u3001",
|
45
|
+
"\uFF65": "\u30FB",
|
46
|
+
\uFF66: "\u30F2",
|
68
47
|
\uFF66\uFF9E: "\u30FA",
|
48
|
+
\uFF67: "\u30A1",
|
49
|
+
\uFF68: "\u30A3",
|
50
|
+
\uFF69: "\u30A5",
|
51
|
+
\uFF6A: "\u30A7",
|
52
|
+
\uFF6B: "\u30A9",
|
53
|
+
\uFF6C: "\u30E3",
|
54
|
+
\uFF6D: "\u30E5",
|
55
|
+
\uFF6E: "\u30E7",
|
56
|
+
\uFF6F: "\u30C3",
|
57
|
+
\uFF70: "\u30FC",
|
69
58
|
\uFF71: "\u30A2",
|
70
59
|
\uFF72: "\u30A4",
|
71
60
|
\uFF73: "\u30A6",
|
61
|
+
\uFF73\uFF9E: "\u30F4",
|
72
62
|
\uFF74: "\u30A8",
|
73
63
|
\uFF75: "\u30AA",
|
74
64
|
\uFF76: "\u30AB",
|
65
|
+
\uFF76\uFF9E: "\u30AC",
|
75
66
|
\uFF77: "\u30AD",
|
67
|
+
\uFF77\uFF9E: "\u30AE",
|
76
68
|
\uFF78: "\u30AF",
|
69
|
+
\uFF78\uFF9E: "\u30B0",
|
77
70
|
\uFF79: "\u30B1",
|
71
|
+
\uFF79\uFF9E: "\u30B2",
|
78
72
|
\uFF7A: "\u30B3",
|
73
|
+
\uFF7A\uFF9E: "\u30B4",
|
79
74
|
\uFF7B: "\u30B5",
|
75
|
+
\uFF7B\uFF9E: "\u30B6",
|
80
76
|
\uFF7C: "\u30B7",
|
77
|
+
\uFF7C\uFF9E: "\u30B8",
|
81
78
|
\uFF7D: "\u30B9",
|
79
|
+
\uFF7D\uFF9E: "\u30BA",
|
82
80
|
\uFF7E: "\u30BB",
|
81
|
+
\uFF7E\uFF9E: "\u30BC",
|
83
82
|
\uFF7F: "\u30BD",
|
83
|
+
\uFF7F\uFF9E: "\u30BE",
|
84
84
|
\uFF80: "\u30BF",
|
85
|
+
\uFF80\uFF9E: "\u30C0",
|
85
86
|
\uFF81: "\u30C1",
|
87
|
+
\uFF81\uFF9E: "\u30C2",
|
86
88
|
\uFF82: "\u30C4",
|
89
|
+
\uFF82\uFF9E: "\u30C5",
|
87
90
|
\uFF83: "\u30C6",
|
91
|
+
\uFF83\uFF9E: "\u30C7",
|
88
92
|
\uFF84: "\u30C8",
|
93
|
+
\uFF84\uFF9E: "\u30C9",
|
89
94
|
\uFF85: "\u30CA",
|
90
95
|
\uFF86: "\u30CB",
|
91
96
|
\uFF87: "\u30CC",
|
92
97
|
\uFF88: "\u30CD",
|
93
98
|
\uFF89: "\u30CE",
|
94
99
|
\uFF8A: "\u30CF",
|
100
|
+
\uFF8A\uFF9E: "\u30D0",
|
101
|
+
\uFF8A\uFF9F: "\u30D1",
|
95
102
|
\uFF8B: "\u30D2",
|
103
|
+
\uFF8B\uFF9E: "\u30D3",
|
104
|
+
\uFF8B\uFF9F: "\u30D4",
|
96
105
|
\uFF8C: "\u30D5",
|
106
|
+
\uFF8C\uFF9E: "\u30D6",
|
107
|
+
\uFF8C\uFF9F: "\u30D7",
|
97
108
|
\uFF8D: "\u30D8",
|
109
|
+
\uFF8D\uFF9E: "\u30D9",
|
110
|
+
\uFF8D\uFF9F: "\u30DA",
|
98
111
|
\uFF8E: "\u30DB",
|
112
|
+
\uFF8E\uFF9E: "\u30DC",
|
113
|
+
\uFF8E\uFF9F: "\u30DD",
|
99
114
|
\uFF8F: "\u30DE",
|
100
115
|
\uFF90: "\u30DF",
|
101
116
|
\uFF91: "\u30E0",
|
@@ -110,23 +125,8 @@ var kanaMap = {
|
|
110
125
|
\uFF9A: "\u30EC",
|
111
126
|
\uFF9B: "\u30ED",
|
112
127
|
\uFF9C: "\u30EF",
|
113
|
-
\
|
114
|
-
\uFF9D: "\u30F3"
|
115
|
-
\uFF67: "\u30A1",
|
116
|
-
\uFF68: "\u30A3",
|
117
|
-
\uFF69: "\u30A5",
|
118
|
-
\uFF6A: "\u30A7",
|
119
|
-
\uFF6B: "\u30A9",
|
120
|
-
\uFF6F: "\u30C3",
|
121
|
-
\uFF6C: "\u30E3",
|
122
|
-
\uFF6D: "\u30E5",
|
123
|
-
\uFF6E: "\u30E7",
|
124
|
-
"\uFF61": "\u3002",
|
125
|
-
"\uFF64": "\u3001",
|
126
|
-
\uFF70: "\u30FC",
|
127
|
-
"\uFF62": "\u300C",
|
128
|
-
"\uFF63": "\u300D",
|
129
|
-
"\uFF65": "\u30FB"
|
128
|
+
\uFF9C\uFF9E: "\u30F7",
|
129
|
+
\uFF9D: "\u30F3"
|
130
130
|
};
|
131
131
|
var defaultFormat = (value) => {
|
132
132
|
value = value.replace(
|
@@ -154,46 +154,46 @@ var flattenItems = (items) => {
|
|
154
154
|
};
|
155
155
|
var useAutocomplete = (props) => {
|
156
156
|
const {
|
157
|
-
value: valueProp,
|
158
|
-
defaultValue,
|
159
|
-
onChange: onChangeProp,
|
160
|
-
onCreate: onCreateProp,
|
161
|
-
onSearch: onSearchProp,
|
162
|
-
closeOnSelect = true,
|
163
|
-
omitSelectedValues = false,
|
164
|
-
maxSelectValues,
|
165
157
|
allowCreate = false,
|
166
158
|
allowFree = false,
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
placeholder,
|
172
|
-
onKeyDown: onKeyDownProp,
|
173
|
-
isOpen: isOpenProp,
|
174
|
-
defaultIsOpen,
|
175
|
-
onOpen: onOpenProp,
|
176
|
-
onClose: onCloseProp,
|
159
|
+
animation,
|
160
|
+
boundary,
|
161
|
+
children,
|
162
|
+
closeDelay,
|
177
163
|
closeOnBlur = true,
|
178
164
|
closeOnEsc = true,
|
179
|
-
|
180
|
-
|
165
|
+
closeOnSelect = true,
|
166
|
+
defaultIsOpen,
|
167
|
+
defaultValue,
|
168
|
+
duration = 0.2,
|
169
|
+
emptyMessage = "No results found",
|
170
|
+
eventListeners,
|
171
|
+
flip,
|
172
|
+
format = defaultFormat,
|
173
|
+
gutter,
|
174
|
+
insertPositionItem = "first",
|
181
175
|
isLazy,
|
176
|
+
isOpen: isOpenProp,
|
177
|
+
items,
|
182
178
|
lazyBehavior,
|
183
|
-
|
184
|
-
|
179
|
+
matchWidth = true,
|
180
|
+
maxSelectValues,
|
181
|
+
modifiers,
|
185
182
|
offset,
|
186
|
-
|
183
|
+
omitSelectedValues = false,
|
184
|
+
openDelay,
|
185
|
+
placeholder,
|
186
|
+
placement = "bottom-start",
|
187
187
|
preventOverflow,
|
188
|
-
flip,
|
189
|
-
matchWidth = true,
|
190
|
-
boundary,
|
191
|
-
eventListeners,
|
192
188
|
strategy,
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
189
|
+
value: valueProp,
|
190
|
+
optionProps,
|
191
|
+
onChange: onChangeProp,
|
192
|
+
onClose: onCloseProp,
|
193
|
+
onCreate: onCreateProp,
|
194
|
+
onKeyDown: onKeyDownProp,
|
195
|
+
onOpen: onOpenProp,
|
196
|
+
onSearch: onSearchProp,
|
197
197
|
...rest
|
198
198
|
} = useFormControlProps(props);
|
199
199
|
const {
|
@@ -212,8 +212,8 @@ var useAutocomplete = (props) => {
|
|
212
212
|
const prevValue = useRef(void 0);
|
213
213
|
const [resolvedItems, setResolvedItems] = useState(items ? JSON.parse(JSON.stringify(items)) : void 0);
|
214
214
|
const [value, setValue] = useControllableState({
|
215
|
-
value: valueProp,
|
216
215
|
defaultValue,
|
216
|
+
value: valueProp,
|
217
217
|
onChange: onChangeProp
|
218
218
|
});
|
219
219
|
const [label, setLabel] = useState(void 0);
|
@@ -223,13 +223,13 @@ var useAutocomplete = (props) => {
|
|
223
223
|
const [isHit, setIsHit] = useState(true);
|
224
224
|
const {
|
225
225
|
isOpen,
|
226
|
-
|
227
|
-
|
226
|
+
onClose,
|
227
|
+
onOpen: onInternalOpen
|
228
228
|
} = useDisclosure({
|
229
|
-
isOpen: isOpenProp,
|
230
229
|
defaultIsOpen,
|
231
|
-
|
232
|
-
onClose: onCloseProp
|
230
|
+
isOpen: isOpenProp,
|
231
|
+
onClose: onCloseProp,
|
232
|
+
onOpen: onOpenProp
|
233
233
|
});
|
234
234
|
const isFocused = focusedIndex > -1;
|
235
235
|
const isCreate = focusedIndex === -2 && allowCreate;
|
@@ -255,7 +255,7 @@ var useAutocomplete = (props) => {
|
|
255
255
|
);
|
256
256
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
257
257
|
const enabledValues = descendants.enabledValues(
|
258
|
-
({
|
258
|
+
({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
|
259
259
|
);
|
260
260
|
const validChildren = getValidChildren(children);
|
261
261
|
const computedChildren = useMemo(
|
@@ -264,7 +264,7 @@ var useAutocomplete = (props) => {
|
|
264
264
|
const { label: label2, value: value2, ...props2 } = item;
|
265
265
|
return /* @__PURE__ */ jsx(AutocompleteOption, { value: value2, ...props2, children: label2 }, i);
|
266
266
|
} else if ("items" in item) {
|
267
|
-
const {
|
267
|
+
const { items: items2 = [], label: label2, ...props2 } = item;
|
268
268
|
return /* @__PURE__ */ jsx(AutocompleteOptionGroup, { label: label2, ...props2, children: items2.map(({ label: label3, value: value2, ...props3 }, i2) => /* @__PURE__ */ jsx(AutocompleteOption, { value: value2, ...props3, children: label3 }, i2)) }, i);
|
269
269
|
}
|
270
270
|
}),
|
@@ -279,6 +279,7 @@ var useAutocomplete = (props) => {
|
|
279
279
|
}, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
|
280
280
|
const onFocusFirst = useCallback(() => {
|
281
281
|
const id2 = setTimeout(() => {
|
282
|
+
var _a;
|
282
283
|
if (isEmpty || isAllSelected) return;
|
283
284
|
const first = descendants.enabledFirstValue(
|
284
285
|
({ node }) => "target" in node.dataset
|
@@ -289,7 +290,7 @@ var useAutocomplete = (props) => {
|
|
289
290
|
} else {
|
290
291
|
if (selectedIndexes.includes(first.index)) {
|
291
292
|
const enabledFirst = enabledValues[0];
|
292
|
-
setFocusedIndex(enabledFirst.index);
|
293
|
+
setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
|
293
294
|
} else {
|
294
295
|
setFocusedIndex(first.index);
|
295
296
|
}
|
@@ -307,6 +308,7 @@ var useAutocomplete = (props) => {
|
|
307
308
|
]);
|
308
309
|
const onFocusLast = useCallback(() => {
|
309
310
|
const id2 = setTimeout(() => {
|
311
|
+
var _a;
|
310
312
|
if (isEmpty || isAllSelected) return;
|
311
313
|
const last = descendants.enabledLastValue(
|
312
314
|
({ node }) => "target" in node.dataset
|
@@ -317,7 +319,7 @@ var useAutocomplete = (props) => {
|
|
317
319
|
} else {
|
318
320
|
if (selectedIndexes.includes(last.index)) {
|
319
321
|
const enabledLast = enabledValues.reverse()[0];
|
320
|
-
setFocusedIndex(enabledLast.index);
|
322
|
+
setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
|
321
323
|
} else {
|
322
324
|
setFocusedIndex(last.index);
|
323
325
|
}
|
@@ -349,7 +351,7 @@ var useAutocomplete = (props) => {
|
|
349
351
|
const onFocusNext = useCallback(
|
350
352
|
(index = focusedIndex) => {
|
351
353
|
const id2 = setTimeout(() => {
|
352
|
-
var _a;
|
354
|
+
var _a, _b;
|
353
355
|
const next = descendants.enabledNextValue(
|
354
356
|
index,
|
355
357
|
({ node }) => "target" in node.dataset
|
@@ -360,7 +362,7 @@ var useAutocomplete = (props) => {
|
|
360
362
|
} else {
|
361
363
|
if (selectedIndexes.includes(next.index)) {
|
362
364
|
const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
|
363
|
-
setFocusedIndex(enabledNext.index);
|
365
|
+
setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
|
364
366
|
} else {
|
365
367
|
setFocusedIndex(next.index);
|
366
368
|
}
|
@@ -380,7 +382,7 @@ var useAutocomplete = (props) => {
|
|
380
382
|
const onFocusPrev = useCallback(
|
381
383
|
(index = focusedIndex) => {
|
382
384
|
const id2 = setTimeout(() => {
|
383
|
-
var _a;
|
385
|
+
var _a, _b;
|
384
386
|
const prev = descendants.enabledPrevValue(
|
385
387
|
index,
|
386
388
|
({ node }) => "target" in node.dataset
|
@@ -391,7 +393,7 @@ var useAutocomplete = (props) => {
|
|
391
393
|
} else {
|
392
394
|
if (selectedIndexes.includes(prev.index)) {
|
393
395
|
const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
|
394
|
-
setFocusedIndex(enabledPrev.index);
|
396
|
+
setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
|
395
397
|
} else {
|
396
398
|
setFocusedIndex(prev.index);
|
397
399
|
}
|
@@ -415,7 +417,7 @@ var useAutocomplete = (props) => {
|
|
415
417
|
const values = descendants.values();
|
416
418
|
let isHit2 = false;
|
417
419
|
let isFocused2 = false;
|
418
|
-
values.forEach(({
|
420
|
+
values.forEach(({ index, node }) => {
|
419
421
|
var _a;
|
420
422
|
if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
|
421
423
|
isHit2 = true;
|
@@ -473,7 +475,7 @@ var useAutocomplete = (props) => {
|
|
473
475
|
return selectedValues2[0];
|
474
476
|
} else {
|
475
477
|
selectedValues2.forEach((selectedValue) => {
|
476
|
-
const isSelected = isArray(prev) && prev.includes(selectedValue
|
478
|
+
const isSelected = isArray(prev) && prev.includes(selectedValue);
|
477
479
|
if (!isSelected) {
|
478
480
|
prev = [...isArray(prev) ? prev : [], selectedValue];
|
479
481
|
} else if (runOmit) {
|
@@ -578,7 +580,7 @@ var useAutocomplete = (props) => {
|
|
578
580
|
({ label: label2 }) => label2 === firstInsertPositionItem
|
579
581
|
);
|
580
582
|
const targetItem = newItems[i];
|
581
|
-
if (i !== -1 && "items" in targetItem) {
|
583
|
+
if (i !== -1 && targetItem && "items" in targetItem) {
|
582
584
|
if (secondInsertPositionItem === "first") {
|
583
585
|
targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
|
584
586
|
} else {
|
@@ -662,15 +664,15 @@ var useAutocomplete = (props) => {
|
|
662
664
|
const actions = {
|
663
665
|
ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0,
|
664
666
|
ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? funcAll(onOpen, onFocusLastOrSelected) : void 0,
|
665
|
-
|
667
|
+
Backspace: !isEmptyValue && enabledDelete ? onDelete : void 0,
|
668
|
+
End: isOpen ? onFocusLast : void 0,
|
666
669
|
Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
|
667
670
|
if (inputValue) onChange(inputValue);
|
668
671
|
setFocusedIndex(0);
|
669
672
|
} : void 0,
|
670
|
-
Home: isOpen ? onFocusFirst : void 0,
|
671
|
-
End: isOpen ? onFocusLast : void 0,
|
672
673
|
Escape: closeOnEsc ? onClose : void 0,
|
673
|
-
|
674
|
+
Home: isOpen ? onFocusFirst : void 0,
|
675
|
+
Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0
|
674
676
|
};
|
675
677
|
const action = actions[ev.key];
|
676
678
|
if (!action) return;
|
@@ -725,7 +727,7 @@ var useAutocomplete = (props) => {
|
|
725
727
|
useEffect(() => {
|
726
728
|
var _a;
|
727
729
|
if (isMulti) {
|
728
|
-
if (JSON.stringify((_a = prevValue.current) != null ? _a : []) === JSON.stringify(value
|
730
|
+
if (JSON.stringify((_a = prevValue.current) != null ? _a : []) === JSON.stringify(value))
|
729
731
|
return;
|
730
732
|
const label2 = getSelectedValues(value);
|
731
733
|
setLabel(label2);
|
@@ -751,34 +753,34 @@ var useAutocomplete = (props) => {
|
|
751
753
|
});
|
752
754
|
useOutsideClick({
|
753
755
|
ref: containerRef,
|
754
|
-
|
755
|
-
|
756
|
+
enabled: isOpen && (closeOnBlur || !isHit),
|
757
|
+
handler: onClose
|
756
758
|
});
|
757
759
|
const getPopoverProps = useCallback(
|
758
760
|
(props2) => ({
|
759
|
-
|
760
|
-
|
761
|
+
animation,
|
762
|
+
boundary,
|
761
763
|
closeDelay,
|
764
|
+
closeOnBlur,
|
765
|
+
duration,
|
766
|
+
eventListeners,
|
767
|
+
flip,
|
768
|
+
gutter,
|
762
769
|
isLazy,
|
763
770
|
lazyBehavior,
|
764
|
-
|
765
|
-
|
771
|
+
matchWidth,
|
772
|
+
modifiers,
|
766
773
|
offset,
|
767
|
-
|
774
|
+
openDelay,
|
775
|
+
placement,
|
768
776
|
preventOverflow,
|
769
|
-
flip,
|
770
|
-
matchWidth,
|
771
|
-
boundary,
|
772
|
-
eventListeners,
|
773
777
|
strategy,
|
774
|
-
placement,
|
775
|
-
modifiers,
|
776
778
|
...props2,
|
777
|
-
trigger: "never",
|
778
779
|
closeOnButton: false,
|
779
780
|
isOpen,
|
780
|
-
|
781
|
-
onClose
|
781
|
+
trigger: "never",
|
782
|
+
onClose,
|
783
|
+
onOpen
|
782
784
|
}),
|
783
785
|
[
|
784
786
|
closeOnBlur,
|
@@ -809,8 +811,8 @@ var useAutocomplete = (props) => {
|
|
809
811
|
...containerProps,
|
810
812
|
...props2,
|
811
813
|
...formControlProps,
|
812
|
-
|
813
|
-
|
814
|
+
onBlur: handlerAll(props2.onBlur, rest.onBlur, onBlur),
|
815
|
+
onClick: handlerAll(props2.onClick, rest.onClick, onClick)
|
814
816
|
}),
|
815
817
|
[containerProps, formControlProps, onBlur, onClick, rest]
|
816
818
|
);
|
@@ -821,8 +823,8 @@ var useAutocomplete = (props) => {
|
|
821
823
|
...props2,
|
822
824
|
...formControlProps,
|
823
825
|
placeholder,
|
824
|
-
"data-active": dataAttr(isOpen),
|
825
826
|
"aria-expanded": dataAttr(isOpen),
|
827
|
+
"data-active": dataAttr(isOpen),
|
826
828
|
onFocus: handlerAll(props2.onFocus, onFocusProp, onFocus),
|
827
829
|
onKeyDown: handlerAll(props2.onKeyDown, onKeyDownProp, onKeyDown)
|
828
830
|
}),
|
@@ -838,61 +840,61 @@ var useAutocomplete = (props) => {
|
|
838
840
|
);
|
839
841
|
return {
|
840
842
|
id,
|
841
|
-
descendants,
|
842
|
-
value,
|
843
|
-
label,
|
844
|
-
inputValue,
|
845
|
-
isHit,
|
846
|
-
isEmpty,
|
847
|
-
computedChildren,
|
848
|
-
focusedIndex,
|
849
|
-
omitSelectedValues,
|
850
|
-
closeOnSelect,
|
851
843
|
allowCreate,
|
852
844
|
allowFree,
|
845
|
+
closeOnSelect,
|
846
|
+
computedChildren,
|
847
|
+
descendants,
|
853
848
|
emptyMessage,
|
854
|
-
|
849
|
+
focusedIndex,
|
850
|
+
inputRef,
|
851
|
+
inputValue,
|
855
852
|
isAllSelected,
|
853
|
+
isEmpty,
|
854
|
+
isHit,
|
855
|
+
isOpen,
|
856
|
+
label,
|
856
857
|
listRef,
|
857
|
-
|
858
|
-
|
859
|
-
|
858
|
+
omitSelectedValues,
|
859
|
+
pickOptions,
|
860
|
+
rebirthOptions,
|
860
861
|
setFocusedIndex,
|
861
|
-
|
862
|
+
value,
|
863
|
+
formControlProps,
|
864
|
+
getContainerProps,
|
865
|
+
getFieldProps,
|
866
|
+
getPopoverProps,
|
867
|
+
inputProps,
|
868
|
+
optionProps,
|
862
869
|
onChange,
|
863
|
-
|
864
|
-
onCreate,
|
870
|
+
onChangeLabel,
|
865
871
|
onClear,
|
866
|
-
onCompositionStart,
|
867
|
-
onCompositionEnd,
|
868
|
-
pickOptions,
|
869
|
-
rebirthOptions,
|
870
|
-
onOpen,
|
871
872
|
onClose,
|
873
|
+
onCompositionEnd,
|
874
|
+
onCompositionStart,
|
875
|
+
onCreate,
|
872
876
|
onFocusFirst,
|
873
877
|
onFocusLast,
|
874
|
-
onFocusSelected,
|
875
878
|
onFocusNext,
|
876
879
|
onFocusPrev,
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
inputProps
|
880
|
+
onFocusSelected,
|
881
|
+
onOpen,
|
882
|
+
onSearch
|
881
883
|
};
|
882
884
|
};
|
883
885
|
var useAutocompleteInput = () => {
|
884
886
|
const {
|
885
887
|
id,
|
888
|
+
focusedIndex,
|
886
889
|
inputRef,
|
887
|
-
onSearch,
|
888
|
-
onCompositionStart,
|
889
|
-
onCompositionEnd,
|
890
890
|
isAllSelected,
|
891
|
+
isOpen,
|
892
|
+
listRef,
|
891
893
|
formControlProps,
|
892
894
|
inputProps,
|
893
|
-
|
894
|
-
|
895
|
-
|
895
|
+
onCompositionEnd,
|
896
|
+
onCompositionStart,
|
897
|
+
onSearch
|
896
898
|
} = useAutocompleteContext();
|
897
899
|
const { value } = useAutocompleteDescendantsContext();
|
898
900
|
useUpdateEffect(() => {
|
@@ -904,15 +906,15 @@ var useAutocompleteInput = () => {
|
|
904
906
|
return {
|
905
907
|
ref: mergeRefs(inputRef, ref),
|
906
908
|
...formControlProps,
|
907
|
-
role: "combobox",
|
908
|
-
"aria-haspopup": "listbox",
|
909
|
-
"aria-autocomplete": "list",
|
910
|
-
"aria-expanded": isOpen,
|
911
|
-
"aria-activedescendant": (_a = value(focusedIndex)) == null ? void 0 : _a.node.id,
|
912
|
-
"aria-controls": (_b = listRef.current) == null ? void 0 : _b.id,
|
913
909
|
autoCapitalize: "none",
|
914
910
|
autoComplete: "off",
|
911
|
+
role: "combobox",
|
915
912
|
spellCheck: "false",
|
913
|
+
"aria-activedescendant": (_a = value(focusedIndex)) == null ? void 0 : _a.node.id,
|
914
|
+
"aria-autocomplete": "list",
|
915
|
+
"aria-controls": (_b = listRef.current) == null ? void 0 : _b.id,
|
916
|
+
"aria-expanded": isOpen,
|
917
|
+
"aria-haspopup": "listbox",
|
916
918
|
...inputProps,
|
917
919
|
...props,
|
918
920
|
id,
|
@@ -920,15 +922,15 @@ var useAutocompleteInput = () => {
|
|
920
922
|
pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
|
921
923
|
tabIndex: isAllSelected ? -1 : 0,
|
922
924
|
onChange: handlerAll(props.onChange, onSearch),
|
923
|
-
onCompositionStart: handlerAll(
|
924
|
-
props.onCompositionStart,
|
925
|
-
inputProps.onCompositionStart,
|
926
|
-
onCompositionStart
|
927
|
-
),
|
928
925
|
onCompositionEnd: handlerAll(
|
929
926
|
props.onCompositionEnd,
|
930
927
|
inputProps.onCompositionEnd,
|
931
928
|
onCompositionEnd
|
929
|
+
),
|
930
|
+
onCompositionStart: handlerAll(
|
931
|
+
props.onCompositionStart,
|
932
|
+
inputProps.onCompositionStart,
|
933
|
+
onCompositionStart
|
932
934
|
)
|
933
935
|
};
|
934
936
|
},
|
@@ -956,4 +958,4 @@ export {
|
|
956
958
|
useAutocomplete,
|
957
959
|
useAutocompleteInput
|
958
960
|
};
|
959
|
-
//# sourceMappingURL=chunk-
|
961
|
+
//# sourceMappingURL=chunk-4APEPTYJ.mjs.map
|