@yamada-ui/autocomplete 1.6.5-next-20241118225020 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/autocomplete-context.d.mts +0 -1
- package/dist/autocomplete-context.d.ts +0 -1
- package/dist/autocomplete-context.js.map +1 -1
- package/dist/autocomplete-context.mjs +1 -1
- package/dist/autocomplete-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +4 -4
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +4 -4
- package/dist/autocomplete-icon.js.map +1 -1
- package/dist/autocomplete-icon.mjs +2 -2
- package/dist/autocomplete-list.js +22 -15
- package/dist/autocomplete-list.js.map +1 -1
- package/dist/autocomplete-list.mjs +3 -3
- package/dist/autocomplete-option-group.js.map +1 -1
- package/dist/autocomplete-option-group.mjs +3 -3
- package/dist/autocomplete-option.js +10 -6
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +4 -4
- package/dist/autocomplete.js +78 -84
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +12 -12
- package/dist/{chunk-JYPMXZG4.mjs → chunk-2CVB4NO5.mjs} +7 -7
- package/dist/{chunk-3A2HEULI.mjs → chunk-2LP57WVB.mjs} +12 -8
- package/dist/chunk-2LP57WVB.mjs.map +1 -0
- package/dist/{chunk-PTPJFYGI.mjs → chunk-4GVV3HBE.mjs} +29 -13
- package/dist/chunk-4GVV3HBE.mjs.map +1 -0
- package/dist/{chunk-6OTUOEYS.mjs → chunk-7QCZ5NGS.mjs} +2 -2
- package/dist/{chunk-PU6HFINM.mjs → chunk-ABCTEZN5.mjs} +3 -3
- package/dist/{chunk-NOSATNDY.mjs → chunk-IFH3PPSD.mjs} +10 -8
- package/dist/chunk-IFH3PPSD.mjs.map +1 -0
- package/dist/{chunk-REPBXBG3.mjs → chunk-LIBFONYN.mjs} +7 -10
- package/dist/chunk-LIBFONYN.mjs.map +1 -0
- package/dist/{chunk-2UKLSSUA.mjs → chunk-PWV7X7G6.mjs} +4 -4
- package/dist/{chunk-G6SC44LI.mjs → chunk-RK5E5J5E.mjs} +4 -4
- package/dist/{chunk-ZNO5RUVT.mjs → chunk-TP5VZFO3.mjs} +1 -1
- package/dist/chunk-TP5VZFO3.mjs.map +1 -0
- package/dist/{chunk-CMFJUJJW.mjs → chunk-UX5QECNB.mjs} +2 -2
- package/dist/{chunk-6II6KCIJ.mjs → chunk-YPKDYYEV.mjs} +4 -4
- package/dist/{chunk-75VF5Q5W.mjs → chunk-ZR77IT3O.mjs} +51 -69
- package/dist/chunk-ZR77IT3O.mjs.map +1 -0
- package/dist/index.js +81 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/multi-autocomplete.d.mts +8 -0
- package/dist/multi-autocomplete.d.ts +8 -0
- package/dist/multi-autocomplete.js +81 -85
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +12 -12
- package/dist/use-autocomplete-list.d.mts +2 -1
- package/dist/use-autocomplete-list.d.ts +2 -1
- package/dist/use-autocomplete-list.js +19 -9
- package/dist/use-autocomplete-list.js.map +1 -1
- package/dist/use-autocomplete-list.mjs +2 -2
- 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 +16 -0
- package/dist/use-autocomplete-option.d.ts +16 -0
- package/dist/use-autocomplete-option.js +10 -6
- package/dist/use-autocomplete-option.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +2 -2
- package/dist/use-autocomplete.d.mts +3 -5
- package/dist/use-autocomplete.d.ts +3 -5
- package/dist/use-autocomplete.js +56 -69
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +7 -7
- package/package.json +4 -4
- package/dist/chunk-3A2HEULI.mjs.map +0 -1
- package/dist/chunk-75VF5Q5W.mjs.map +0 -1
- package/dist/chunk-NOSATNDY.mjs.map +0 -1
- package/dist/chunk-PTPJFYGI.mjs.map +0 -1
- package/dist/chunk-REPBXBG3.mjs.map +0 -1
- package/dist/chunk-ZNO5RUVT.mjs.map +0 -1
- /package/dist/{chunk-JYPMXZG4.mjs.map → chunk-2CVB4NO5.mjs.map} +0 -0
- /package/dist/{chunk-6OTUOEYS.mjs.map → chunk-7QCZ5NGS.mjs.map} +0 -0
- /package/dist/{chunk-PU6HFINM.mjs.map → chunk-ABCTEZN5.mjs.map} +0 -0
- /package/dist/{chunk-2UKLSSUA.mjs.map → chunk-PWV7X7G6.mjs.map} +0 -0
- /package/dist/{chunk-G6SC44LI.mjs.map → chunk-RK5E5J5E.mjs.map} +0 -0
- /package/dist/{chunk-CMFJUJJW.mjs.map → chunk-UX5QECNB.mjs.map} +0 -0
- /package/dist/{chunk-6II6KCIJ.mjs.map → chunk-YPKDYYEV.mjs.map} +0 -0
package/dist/index.js
CHANGED
@@ -178,13 +178,17 @@ var useAutocompleteOption = (props) => {
|
|
178
178
|
id,
|
179
179
|
children,
|
180
180
|
closeOnSelect: customCloseOnSelect,
|
181
|
+
disabled,
|
182
|
+
focusable,
|
181
183
|
icon: customIcon,
|
182
184
|
isDisabled,
|
183
185
|
isFocusable,
|
184
186
|
value: optionValue,
|
185
187
|
...computedProps
|
186
188
|
} = { ...optionProps, ...props };
|
187
|
-
|
189
|
+
disabled != null ? disabled : disabled = isDisabled;
|
190
|
+
focusable != null ? focusable : focusable = isFocusable;
|
191
|
+
const trulyDisabled = !!disabled && !focusable;
|
188
192
|
const { descendants, index, register } = useAutocompleteDescendant({
|
189
193
|
disabled: trulyDisabled
|
190
194
|
});
|
@@ -210,7 +214,7 @@ var useAutocompleteOption = (props) => {
|
|
210
214
|
const onClick = (0, import_react2.useCallback)(
|
211
215
|
(ev) => {
|
212
216
|
ev.stopPropagation();
|
213
|
-
if (
|
217
|
+
if (disabled || !isTargetOption(ev.currentTarget)) {
|
214
218
|
if (inputRef.current) inputRef.current.focus();
|
215
219
|
return;
|
216
220
|
}
|
@@ -224,7 +228,7 @@ var useAutocompleteOption = (props) => {
|
|
224
228
|
isDuplicated,
|
225
229
|
onFocusNext,
|
226
230
|
omitSelectedValues,
|
227
|
-
|
231
|
+
disabled,
|
228
232
|
optionValue,
|
229
233
|
setFocusedIndex,
|
230
234
|
index,
|
@@ -256,10 +260,10 @@ var useAutocompleteOption = (props) => {
|
|
256
260
|
...props2,
|
257
261
|
id,
|
258
262
|
style: isHidden ? style : void 0,
|
259
|
-
"aria-disabled": (0, import_utils3.ariaAttr)(
|
263
|
+
"aria-disabled": (0, import_utils3.ariaAttr)(disabled),
|
260
264
|
"aria-hidden": (0, import_utils3.ariaAttr)(isHidden),
|
261
265
|
"aria-selected": isSelected,
|
262
|
-
"data-disabled": (0, import_utils3.dataAttr)(
|
266
|
+
"data-disabled": (0, import_utils3.dataAttr)(disabled),
|
263
267
|
"data-duplicated": (0, import_utils3.dataAttr)(isDuplicated),
|
264
268
|
"data-focus": (0, import_utils3.dataAttr)(isFocused),
|
265
269
|
"data-target": (0, import_utils3.dataAttr)(true),
|
@@ -273,7 +277,7 @@ var useAutocompleteOption = (props) => {
|
|
273
277
|
isDuplicated,
|
274
278
|
optionValue,
|
275
279
|
computedProps,
|
276
|
-
|
280
|
+
disabled,
|
277
281
|
isFocused,
|
278
282
|
isSelected,
|
279
283
|
isTarget,
|
@@ -456,9 +460,9 @@ var import_utils7 = require("@yamada-ui/utils");
|
|
456
460
|
var import_utils6 = require("@yamada-ui/utils");
|
457
461
|
var import_react3 = require("react");
|
458
462
|
var useAutocompleteList = () => {
|
459
|
-
const { focusedIndex, isOpen,
|
463
|
+
const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
|
460
464
|
const descendants = useAutocompleteDescendantsContext();
|
461
|
-
const
|
465
|
+
const listRef = (0, import_react3.useRef)(null);
|
462
466
|
const beforeFocusedIndex = (0, import_react3.useRef)(-1);
|
463
467
|
const selectedValue = descendants.value(focusedIndex);
|
464
468
|
const isMulti = (0, import_utils6.isArray)(value);
|
@@ -494,21 +498,31 @@ var useAutocompleteList = () => {
|
|
494
498
|
(0, import_utils6.useUpdateEffect)(() => {
|
495
499
|
if (!isOpen) beforeFocusedIndex.current = -1;
|
496
500
|
}, [isOpen]);
|
501
|
+
const getContainerProps = (0, import_react3.useCallback)(
|
502
|
+
(props = {}, ref = null) => ({
|
503
|
+
ref,
|
504
|
+
"aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
|
505
|
+
role: "listbox",
|
506
|
+
...props,
|
507
|
+
onAnimationComplete: (0, import_utils6.handlerAll)(
|
508
|
+
props.onAnimationComplete,
|
509
|
+
onAnimationComplete
|
510
|
+
)
|
511
|
+
}),
|
512
|
+
[isMulti, onAnimationComplete]
|
513
|
+
);
|
497
514
|
const getListProps = (0, import_react3.useCallback)(
|
498
|
-
(
|
499
|
-
id: id != null ? id : uuid,
|
515
|
+
(props = {}, ref = null) => ({
|
500
516
|
ref: (0, import_utils6.mergeRefs)(listRef, ref),
|
501
|
-
"aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
|
502
517
|
position: "relative",
|
503
|
-
role: "listbox",
|
504
518
|
tabIndex: -1,
|
505
519
|
...props
|
506
520
|
}),
|
507
|
-
[listRef
|
521
|
+
[listRef]
|
508
522
|
);
|
509
523
|
return {
|
510
|
-
|
511
|
-
|
524
|
+
getContainerProps,
|
525
|
+
getListProps
|
512
526
|
};
|
513
527
|
};
|
514
528
|
|
@@ -531,7 +545,7 @@ var AutocompleteList = (0, import_core4.forwardRef)(
|
|
531
545
|
}, ref) => {
|
532
546
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
533
547
|
const { styles } = useAutocompleteContext();
|
534
|
-
const {
|
548
|
+
const { getContainerProps, getListProps } = useAutocompleteList();
|
535
549
|
width != null ? width : width = w;
|
536
550
|
width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
|
537
551
|
minWidth != null ? minWidth : minWidth = minW;
|
@@ -541,16 +555,13 @@ var AutocompleteList = (0, import_core4.forwardRef)(
|
|
541
555
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
542
556
|
import_popover.PopoverContent,
|
543
557
|
{
|
558
|
+
as: "div",
|
544
559
|
className: "ui-autocomplete__popover",
|
545
560
|
maxWidth,
|
546
561
|
minWidth,
|
547
562
|
width,
|
548
563
|
__css: { ...styles.content, maxWidth, minWidth, width },
|
549
|
-
...contentProps,
|
550
|
-
onAnimationComplete: (0, import_utils7.handlerAll)(
|
551
|
-
contentProps == null ? void 0 : contentProps.onAnimationComplete,
|
552
|
-
onAnimationComplete
|
553
|
-
),
|
564
|
+
...getContainerProps(contentProps),
|
554
565
|
children: [
|
555
566
|
header ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
556
567
|
import_core4.ui.header,
|
@@ -890,8 +901,8 @@ var defaultFormat = (value) => {
|
|
890
901
|
var flattenItems = (items) => {
|
891
902
|
const filterItems = (items2) => items2.map((item) => {
|
892
903
|
var _a;
|
893
|
-
const {
|
894
|
-
const trulyDisabled = !!
|
904
|
+
const { disabled, focusable } = item;
|
905
|
+
const trulyDisabled = !!disabled && !focusable;
|
895
906
|
if (trulyDisabled) return;
|
896
907
|
if ("items" in item) {
|
897
908
|
return filterItems((_a = item.items) != null ? _a : []);
|
@@ -902,6 +913,7 @@ var flattenItems = (items) => {
|
|
902
913
|
return filterItems(items).flat(Infinity);
|
903
914
|
};
|
904
915
|
var useAutocomplete = (props) => {
|
916
|
+
var _a;
|
905
917
|
const {
|
906
918
|
allowCreate = false,
|
907
919
|
allowFree = false,
|
@@ -945,16 +957,8 @@ var useAutocomplete = (props) => {
|
|
945
957
|
onSearch: onSearchProp,
|
946
958
|
...rest
|
947
959
|
} = (0, import_form_control.useFormControlProps)(props);
|
948
|
-
const {
|
949
|
-
"aria-readonly": _ariaReadonly,
|
950
|
-
onFocus: onFocusProp,
|
951
|
-
...formControlProps
|
952
|
-
} = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
|
953
|
-
const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
|
954
|
-
const { id } = rest;
|
955
960
|
const descendants = useAutocompleteDescendants();
|
956
961
|
const containerRef = (0, import_react5.useRef)(null);
|
957
|
-
const listRef = (0, import_react5.useRef)(null);
|
958
962
|
const inputRef = (0, import_react5.useRef)(null);
|
959
963
|
const timeoutIds = (0, import_react5.useRef)(/* @__PURE__ */ new Set([]));
|
960
964
|
const isComposition = (0, import_react5.useRef)(false);
|
@@ -980,6 +984,12 @@ var useAutocomplete = (props) => {
|
|
980
984
|
onClose: onCloseProp,
|
981
985
|
onOpen: onOpenProp
|
982
986
|
});
|
987
|
+
const {
|
988
|
+
"aria-readonly": _ariaReadonly,
|
989
|
+
onFocus: onFocusProp,
|
990
|
+
...formControlProps
|
991
|
+
} = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
|
992
|
+
const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
|
983
993
|
const isFocused = focusedIndex > -1;
|
984
994
|
const isCreate = focusedIndex === -2 && allowCreate;
|
985
995
|
const isMulti = (0, import_utils11.isArray)(value);
|
@@ -998,14 +1008,15 @@ var useAutocomplete = (props) => {
|
|
998
1008
|
}
|
999
1009
|
const selectedValues = descendants.enabledValues(
|
1000
1010
|
({ node }) => {
|
1001
|
-
var
|
1002
|
-
return isMulti && value.includes((
|
1011
|
+
var _a2;
|
1012
|
+
return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
|
1003
1013
|
}
|
1004
1014
|
);
|
1005
1015
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
1006
1016
|
const enabledValues = descendants.enabledValues(
|
1007
1017
|
({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
|
1008
1018
|
);
|
1019
|
+
const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
|
1009
1020
|
const validChildren = (0, import_utils11.getValidChildren)(children);
|
1010
1021
|
const computedChildren = (0, import_react5.useMemo)(
|
1011
1022
|
() => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
|
@@ -1035,8 +1046,8 @@ var useAutocomplete = (props) => {
|
|
1035
1046
|
if (inputRef.current) inputRef.current.focus();
|
1036
1047
|
}, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
|
1037
1048
|
const onFocusFirst = (0, import_react5.useCallback)(() => {
|
1038
|
-
const
|
1039
|
-
var
|
1049
|
+
const id = setTimeout(() => {
|
1050
|
+
var _a2;
|
1040
1051
|
if (isEmpty || isAllSelected) return;
|
1041
1052
|
const first = descendants.enabledFirstValue(
|
1042
1053
|
({ node }) => "target" in node.dataset
|
@@ -1047,13 +1058,13 @@ var useAutocomplete = (props) => {
|
|
1047
1058
|
} else {
|
1048
1059
|
if (selectedIndexes.includes(first.index)) {
|
1049
1060
|
const enabledFirst = enabledValues[0];
|
1050
|
-
setFocusedIndex((
|
1061
|
+
setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
|
1051
1062
|
} else {
|
1052
1063
|
setFocusedIndex(first.index);
|
1053
1064
|
}
|
1054
1065
|
}
|
1055
1066
|
});
|
1056
|
-
timeoutIds.current.add(
|
1067
|
+
timeoutIds.current.add(id);
|
1057
1068
|
}, [
|
1058
1069
|
descendants,
|
1059
1070
|
enabledValues,
|
@@ -1064,8 +1075,8 @@ var useAutocomplete = (props) => {
|
|
1064
1075
|
selectedIndexes
|
1065
1076
|
]);
|
1066
1077
|
const onFocusLast = (0, import_react5.useCallback)(() => {
|
1067
|
-
const
|
1068
|
-
var
|
1078
|
+
const id = setTimeout(() => {
|
1079
|
+
var _a2;
|
1069
1080
|
if (isEmpty || isAllSelected) return;
|
1070
1081
|
const last = descendants.enabledLastValue(
|
1071
1082
|
({ node }) => "target" in node.dataset
|
@@ -1076,13 +1087,13 @@ var useAutocomplete = (props) => {
|
|
1076
1087
|
} else {
|
1077
1088
|
if (selectedIndexes.includes(last.index)) {
|
1078
1089
|
const enabledLast = enabledValues.reverse()[0];
|
1079
|
-
setFocusedIndex((
|
1090
|
+
setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
|
1080
1091
|
} else {
|
1081
1092
|
setFocusedIndex(last.index);
|
1082
1093
|
}
|
1083
1094
|
}
|
1084
1095
|
});
|
1085
|
-
timeoutIds.current.add(
|
1096
|
+
timeoutIds.current.add(id);
|
1086
1097
|
}, [
|
1087
1098
|
descendants,
|
1088
1099
|
enabledValues,
|
@@ -1093,22 +1104,22 @@ var useAutocomplete = (props) => {
|
|
1093
1104
|
selectedIndexes
|
1094
1105
|
]);
|
1095
1106
|
const onFocusSelected = (0, import_react5.useCallback)(() => {
|
1096
|
-
const
|
1107
|
+
const id = setTimeout(() => {
|
1097
1108
|
const values = descendants.enabledValues();
|
1098
1109
|
const selected = values.find(
|
1099
1110
|
({ node }) => {
|
1100
|
-
var
|
1101
|
-
return !isMulti ? node.dataset.value === value : value.includes((
|
1111
|
+
var _a2;
|
1112
|
+
return !isMulti ? node.dataset.value === value : value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
|
1102
1113
|
}
|
1103
1114
|
);
|
1104
1115
|
if (selected) setFocusedIndex(selected.index);
|
1105
1116
|
});
|
1106
|
-
timeoutIds.current.add(
|
1117
|
+
timeoutIds.current.add(id);
|
1107
1118
|
}, [descendants, isMulti, value]);
|
1108
1119
|
const onFocusNext = (0, import_react5.useCallback)(
|
1109
1120
|
(index = focusedIndex) => {
|
1110
|
-
const
|
1111
|
-
var
|
1121
|
+
const id = setTimeout(() => {
|
1122
|
+
var _a2, _b;
|
1112
1123
|
const next = descendants.enabledNextValue(
|
1113
1124
|
index,
|
1114
1125
|
({ node }) => "target" in node.dataset
|
@@ -1118,14 +1129,14 @@ var useAutocomplete = (props) => {
|
|
1118
1129
|
setFocusedIndex(next.index);
|
1119
1130
|
} else {
|
1120
1131
|
if (selectedIndexes.includes(next.index)) {
|
1121
|
-
const enabledNext = (
|
1132
|
+
const enabledNext = (_a2 = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a2 : enabledValues[0];
|
1122
1133
|
setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
|
1123
1134
|
} else {
|
1124
1135
|
setFocusedIndex(next.index);
|
1125
1136
|
}
|
1126
1137
|
}
|
1127
1138
|
});
|
1128
|
-
timeoutIds.current.add(
|
1139
|
+
timeoutIds.current.add(id);
|
1129
1140
|
},
|
1130
1141
|
[
|
1131
1142
|
descendants,
|
@@ -1138,8 +1149,8 @@ var useAutocomplete = (props) => {
|
|
1138
1149
|
);
|
1139
1150
|
const onFocusPrev = (0, import_react5.useCallback)(
|
1140
1151
|
(index = focusedIndex) => {
|
1141
|
-
const
|
1142
|
-
var
|
1152
|
+
const id = setTimeout(() => {
|
1153
|
+
var _a2, _b;
|
1143
1154
|
const prev = descendants.enabledPrevValue(
|
1144
1155
|
index,
|
1145
1156
|
({ node }) => "target" in node.dataset
|
@@ -1149,14 +1160,14 @@ var useAutocomplete = (props) => {
|
|
1149
1160
|
setFocusedIndex(prev.index);
|
1150
1161
|
} else {
|
1151
1162
|
if (selectedIndexes.includes(prev.index)) {
|
1152
|
-
const enabledPrev = (
|
1163
|
+
const enabledPrev = (_a2 = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a2 : enabledValues[0];
|
1153
1164
|
setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
|
1154
1165
|
} else {
|
1155
1166
|
setFocusedIndex(prev.index);
|
1156
1167
|
}
|
1157
1168
|
}
|
1158
1169
|
});
|
1159
|
-
timeoutIds.current.add(
|
1170
|
+
timeoutIds.current.add(id);
|
1160
1171
|
},
|
1161
1172
|
[
|
1162
1173
|
descendants,
|
@@ -1175,8 +1186,8 @@ var useAutocomplete = (props) => {
|
|
1175
1186
|
let isHit2 = false;
|
1176
1187
|
let isFocused2 = false;
|
1177
1188
|
values.forEach(({ index, node }) => {
|
1178
|
-
var
|
1179
|
-
if (format((
|
1189
|
+
var _a2;
|
1190
|
+
if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
|
1180
1191
|
isHit2 = true;
|
1181
1192
|
const isDisabled = "disabled" in node.dataset;
|
1182
1193
|
node.dataset.target = "";
|
@@ -1209,8 +1220,8 @@ var useAutocomplete = (props) => {
|
|
1209
1220
|
if (!values.length) return;
|
1210
1221
|
const resolvedValues = (0, import_utils11.isArray)(newValue) ? newValue : [newValue];
|
1211
1222
|
const selectedLabel = resolvedValues.map((value2) => {
|
1212
|
-
var
|
1213
|
-
const { node } = (
|
1223
|
+
var _a2, _b;
|
1224
|
+
const { node } = (_a2 = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a2 : {};
|
1214
1225
|
if (node) {
|
1215
1226
|
const { textContent } = (_b = Array.from(node.children).find(
|
1216
1227
|
(child) => child.getAttribute("data-label") !== null
|
@@ -1247,9 +1258,9 @@ var useAutocomplete = (props) => {
|
|
1247
1258
|
[isMulti, rebirthOptions, setValue]
|
1248
1259
|
);
|
1249
1260
|
const onSelect = (0, import_react5.useCallback)(() => {
|
1250
|
-
var
|
1261
|
+
var _a2, _b;
|
1251
1262
|
let enabledValue = descendants.value(focusedIndex);
|
1252
|
-
if ("disabled" in ((
|
1263
|
+
if ("disabled" in ((_a2 = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a2 : {}))
|
1253
1264
|
enabledValue = void 0;
|
1254
1265
|
if (!enabledValue) return;
|
1255
1266
|
const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
|
@@ -1287,8 +1298,7 @@ var useAutocomplete = (props) => {
|
|
1287
1298
|
isComposition.current = false;
|
1288
1299
|
}, []);
|
1289
1300
|
const onCreate = (0, import_react5.useCallback)(() => {
|
1290
|
-
var
|
1291
|
-
if (!listRef.current) return;
|
1301
|
+
var _a2, _b;
|
1292
1302
|
const newItem = { label: inputValue, value: inputValue };
|
1293
1303
|
let newItems = [];
|
1294
1304
|
if (resolvedItems) newItems = [...resolvedItems];
|
@@ -1303,7 +1313,7 @@ var useAutocomplete = (props) => {
|
|
1303
1313
|
const targetItem = newItems[i];
|
1304
1314
|
if (i !== -1 && targetItem && "items" in targetItem) {
|
1305
1315
|
if (secondInsertPositionItem === "first") {
|
1306
|
-
targetItem.items = [newItem, ...(
|
1316
|
+
targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
|
1307
1317
|
} else {
|
1308
1318
|
targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
|
1309
1319
|
}
|
@@ -1460,7 +1470,7 @@ var useAutocomplete = (props) => {
|
|
1460
1470
|
setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
|
1461
1471
|
}, [items]);
|
1462
1472
|
(0, import_utils11.useUnmountEffect)(() => {
|
1463
|
-
timeoutIds.current.forEach((
|
1473
|
+
timeoutIds.current.forEach((id) => clearTimeout(id));
|
1464
1474
|
timeoutIds.current.clear();
|
1465
1475
|
});
|
1466
1476
|
(0, import_use_outside_click.useOutsideClick)({
|
@@ -1531,6 +1541,10 @@ var useAutocomplete = (props) => {
|
|
1531
1541
|
const getFieldProps = (0, import_react5.useCallback)(
|
1532
1542
|
(props2 = {}, ref = null) => ({
|
1533
1543
|
ref,
|
1544
|
+
"aria-activedescendant": activedescendantId,
|
1545
|
+
"aria-autocomplete": "list",
|
1546
|
+
"aria-haspopup": "listbox",
|
1547
|
+
role: "combobox",
|
1534
1548
|
tabIndex: -1,
|
1535
1549
|
...props2,
|
1536
1550
|
...formControlProps,
|
@@ -1540,6 +1554,7 @@ var useAutocomplete = (props) => {
|
|
1540
1554
|
onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
|
1541
1555
|
}),
|
1542
1556
|
[
|
1557
|
+
activedescendantId,
|
1543
1558
|
formControlProps,
|
1544
1559
|
placeholder,
|
1545
1560
|
isOpen,
|
@@ -1550,7 +1565,6 @@ var useAutocomplete = (props) => {
|
|
1550
1565
|
]
|
1551
1566
|
);
|
1552
1567
|
return {
|
1553
|
-
id,
|
1554
1568
|
allowCreate,
|
1555
1569
|
allowFree,
|
1556
1570
|
children: children != null ? children : computedChildren,
|
@@ -1565,7 +1579,6 @@ var useAutocomplete = (props) => {
|
|
1565
1579
|
isHit,
|
1566
1580
|
isOpen,
|
1567
1581
|
label,
|
1568
|
-
listRef,
|
1569
1582
|
omitSelectedValues,
|
1570
1583
|
pickOptions,
|
1571
1584
|
rebirthOptions,
|
@@ -1593,23 +1606,15 @@ var useAutocomplete = (props) => {
|
|
1593
1606
|
};
|
1594
1607
|
};
|
1595
1608
|
var useAutocompleteInput = () => {
|
1596
|
-
var _a, _b;
|
1597
1609
|
const {
|
1598
|
-
id,
|
1599
|
-
focusedIndex,
|
1600
1610
|
inputRef,
|
1601
1611
|
isAllSelected,
|
1602
|
-
isOpen,
|
1603
|
-
listRef,
|
1604
1612
|
formControlProps,
|
1605
1613
|
inputProps,
|
1606
1614
|
onCompositionEnd,
|
1607
1615
|
onCompositionStart,
|
1608
1616
|
onSearch
|
1609
1617
|
} = useAutocompleteContext();
|
1610
|
-
const descendants = useAutocompleteDescendantsContext();
|
1611
|
-
const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
|
1612
|
-
const listId = (_b = listRef.current) == null ? void 0 : _b.id;
|
1613
1618
|
(0, import_utils11.useUpdateEffect)(() => {
|
1614
1619
|
if (isAllSelected && inputRef.current) inputRef.current.blur();
|
1615
1620
|
}, [isAllSelected]);
|
@@ -1618,19 +1623,12 @@ var useAutocompleteInput = () => {
|
|
1618
1623
|
return {
|
1619
1624
|
ref: (0, import_utils11.mergeRefs)(inputRef, ref),
|
1620
1625
|
...formControlProps,
|
1621
|
-
"aria-activedescendant": activedescendantId,
|
1622
|
-
"aria-autocomplete": "list",
|
1623
|
-
"aria-controls": listId,
|
1624
|
-
"aria-expanded": isOpen,
|
1625
|
-
"aria-haspopup": "listbox",
|
1626
1626
|
autoCapitalize: "none",
|
1627
1627
|
autoComplete: "off",
|
1628
|
-
role: "combobox",
|
1629
1628
|
spellCheck: "false",
|
1630
1629
|
tabIndex: isAllSelected ? -1 : 0,
|
1631
1630
|
...inputProps,
|
1632
1631
|
...props,
|
1633
|
-
id,
|
1634
1632
|
cursor: formControlProps.readOnly ? "default" : "text",
|
1635
1633
|
pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
|
1636
1634
|
onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
|
@@ -1647,13 +1645,9 @@ var useAutocompleteInput = () => {
|
|
1647
1645
|
};
|
1648
1646
|
},
|
1649
1647
|
[
|
1650
|
-
listId,
|
1651
|
-
activedescendantId,
|
1652
|
-
isOpen,
|
1653
1648
|
inputProps,
|
1654
1649
|
inputRef,
|
1655
1650
|
formControlProps,
|
1656
|
-
id,
|
1657
1651
|
isAllSelected,
|
1658
1652
|
onSearch,
|
1659
1653
|
onCompositionStart,
|
@@ -1828,6 +1822,7 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1828
1822
|
);
|
1829
1823
|
let {
|
1830
1824
|
className,
|
1825
|
+
clearable,
|
1831
1826
|
closeOnSelect = false,
|
1832
1827
|
color,
|
1833
1828
|
component,
|
@@ -1874,6 +1869,7 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1874
1869
|
});
|
1875
1870
|
h != null ? h : h = height;
|
1876
1871
|
minH != null ? minH : minH = minHeight;
|
1872
|
+
clearable != null ? clearable : clearable = isClearable;
|
1877
1873
|
const css = {
|
1878
1874
|
color,
|
1879
1875
|
h: "fit-content",
|
@@ -1918,7 +1914,7 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1918
1914
|
...getFieldProps(fieldProps, ref)
|
1919
1915
|
}
|
1920
1916
|
),
|
1921
|
-
|
1917
|
+
clearable && value.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1922
1918
|
AutocompleteClearIcon,
|
1923
1919
|
{
|
1924
1920
|
...clearIconProps,
|