@yamada-ui/autocomplete 1.6.5-dev-20241118224412 → 1.6.5-dev-20241119150031
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.map +1 -1
- package/dist/autocomplete-option.mjs +4 -4
- package/dist/autocomplete.js +66 -76
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +12 -12
- package/dist/{chunk-7YDPBPBY.mjs → chunk-2CVB4NO5.mjs} +7 -7
- package/dist/{chunk-LCC3VNZV.mjs → chunk-2LP57WVB.mjs} +2 -2
- 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-J3GHHVSC.mjs → chunk-IFH3PPSD.mjs} +7 -7
- package/dist/{chunk-REPBXBG3.mjs → chunk-LIBFONYN.mjs} +7 -10
- package/dist/chunk-LIBFONYN.mjs.map +1 -0
- package/dist/{chunk-7GVG5MVF.mjs → chunk-PWV7X7G6.mjs} +4 -4
- package/dist/{chunk-ZFWB5LCD.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-6QAH2ARG.mjs → chunk-YPKDYYEV.mjs} +4 -4
- package/dist/{chunk-YWUT56L3.mjs → chunk-ZR77IT3O.mjs} +49 -67
- package/dist/chunk-ZR77IT3O.mjs.map +1 -0
- package/dist/index.js +66 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/multi-autocomplete.js +66 -76
- 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.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +2 -2
- package/dist/use-autocomplete.d.mts +0 -2
- package/dist/use-autocomplete.d.ts +0 -2
- package/dist/use-autocomplete.js +44 -61
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +7 -7
- package/package.json +4 -4
- package/dist/chunk-PTPJFYGI.mjs.map +0 -1
- package/dist/chunk-REPBXBG3.mjs.map +0 -1
- package/dist/chunk-YWUT56L3.mjs.map +0 -1
- package/dist/chunk-ZNO5RUVT.mjs.map +0 -1
- /package/dist/{chunk-7YDPBPBY.mjs.map → chunk-2CVB4NO5.mjs.map} +0 -0
- /package/dist/{chunk-LCC3VNZV.mjs.map → chunk-2LP57WVB.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-J3GHHVSC.mjs.map → chunk-IFH3PPSD.mjs.map} +0 -0
- /package/dist/{chunk-7GVG5MVF.mjs.map → chunk-PWV7X7G6.mjs.map} +0 -0
- /package/dist/{chunk-ZFWB5LCD.mjs.map → chunk-RK5E5J5E.mjs.map} +0 -0
- /package/dist/{chunk-CMFJUJJW.mjs.map → chunk-UX5QECNB.mjs.map} +0 -0
- /package/dist/{chunk-6QAH2ARG.mjs.map → chunk-YPKDYYEV.mjs.map} +0 -0
package/dist/index.js
CHANGED
@@ -460,9 +460,9 @@ var import_utils7 = require("@yamada-ui/utils");
|
|
460
460
|
var import_utils6 = require("@yamada-ui/utils");
|
461
461
|
var import_react3 = require("react");
|
462
462
|
var useAutocompleteList = () => {
|
463
|
-
const { focusedIndex, isOpen,
|
463
|
+
const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
|
464
464
|
const descendants = useAutocompleteDescendantsContext();
|
465
|
-
const
|
465
|
+
const listRef = (0, import_react3.useRef)(null);
|
466
466
|
const beforeFocusedIndex = (0, import_react3.useRef)(-1);
|
467
467
|
const selectedValue = descendants.value(focusedIndex);
|
468
468
|
const isMulti = (0, import_utils6.isArray)(value);
|
@@ -498,21 +498,31 @@ var useAutocompleteList = () => {
|
|
498
498
|
(0, import_utils6.useUpdateEffect)(() => {
|
499
499
|
if (!isOpen) beforeFocusedIndex.current = -1;
|
500
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
|
+
);
|
501
514
|
const getListProps = (0, import_react3.useCallback)(
|
502
|
-
(
|
503
|
-
id: id != null ? id : uuid,
|
515
|
+
(props = {}, ref = null) => ({
|
504
516
|
ref: (0, import_utils6.mergeRefs)(listRef, ref),
|
505
|
-
"aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
|
506
517
|
position: "relative",
|
507
|
-
role: "listbox",
|
508
518
|
tabIndex: -1,
|
509
519
|
...props
|
510
520
|
}),
|
511
|
-
[listRef
|
521
|
+
[listRef]
|
512
522
|
);
|
513
523
|
return {
|
514
|
-
|
515
|
-
|
524
|
+
getContainerProps,
|
525
|
+
getListProps
|
516
526
|
};
|
517
527
|
};
|
518
528
|
|
@@ -535,7 +545,7 @@ var AutocompleteList = (0, import_core4.forwardRef)(
|
|
535
545
|
}, ref) => {
|
536
546
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
537
547
|
const { styles } = useAutocompleteContext();
|
538
|
-
const {
|
548
|
+
const { getContainerProps, getListProps } = useAutocompleteList();
|
539
549
|
width != null ? width : width = w;
|
540
550
|
width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
|
541
551
|
minWidth != null ? minWidth : minWidth = minW;
|
@@ -545,16 +555,13 @@ var AutocompleteList = (0, import_core4.forwardRef)(
|
|
545
555
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
546
556
|
import_popover.PopoverContent,
|
547
557
|
{
|
558
|
+
as: "div",
|
548
559
|
className: "ui-autocomplete__popover",
|
549
560
|
maxWidth,
|
550
561
|
minWidth,
|
551
562
|
width,
|
552
563
|
__css: { ...styles.content, maxWidth, minWidth, width },
|
553
|
-
...contentProps,
|
554
|
-
onAnimationComplete: (0, import_utils7.handlerAll)(
|
555
|
-
contentProps == null ? void 0 : contentProps.onAnimationComplete,
|
556
|
-
onAnimationComplete
|
557
|
-
),
|
564
|
+
...getContainerProps(contentProps),
|
558
565
|
children: [
|
559
566
|
header ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
560
567
|
import_core4.ui.header,
|
@@ -906,6 +913,7 @@ var flattenItems = (items) => {
|
|
906
913
|
return filterItems(items).flat(Infinity);
|
907
914
|
};
|
908
915
|
var useAutocomplete = (props) => {
|
916
|
+
var _a;
|
909
917
|
const {
|
910
918
|
allowCreate = false,
|
911
919
|
allowFree = false,
|
@@ -949,16 +957,8 @@ var useAutocomplete = (props) => {
|
|
949
957
|
onSearch: onSearchProp,
|
950
958
|
...rest
|
951
959
|
} = (0, import_form_control.useFormControlProps)(props);
|
952
|
-
const {
|
953
|
-
"aria-readonly": _ariaReadonly,
|
954
|
-
onFocus: onFocusProp,
|
955
|
-
...formControlProps
|
956
|
-
} = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
|
957
|
-
const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
|
958
|
-
const { id } = rest;
|
959
960
|
const descendants = useAutocompleteDescendants();
|
960
961
|
const containerRef = (0, import_react5.useRef)(null);
|
961
|
-
const listRef = (0, import_react5.useRef)(null);
|
962
962
|
const inputRef = (0, import_react5.useRef)(null);
|
963
963
|
const timeoutIds = (0, import_react5.useRef)(/* @__PURE__ */ new Set([]));
|
964
964
|
const isComposition = (0, import_react5.useRef)(false);
|
@@ -984,6 +984,12 @@ var useAutocomplete = (props) => {
|
|
984
984
|
onClose: onCloseProp,
|
985
985
|
onOpen: onOpenProp
|
986
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);
|
987
993
|
const isFocused = focusedIndex > -1;
|
988
994
|
const isCreate = focusedIndex === -2 && allowCreate;
|
989
995
|
const isMulti = (0, import_utils11.isArray)(value);
|
@@ -1002,14 +1008,15 @@ var useAutocomplete = (props) => {
|
|
1002
1008
|
}
|
1003
1009
|
const selectedValues = descendants.enabledValues(
|
1004
1010
|
({ node }) => {
|
1005
|
-
var
|
1006
|
-
return isMulti && value.includes((
|
1011
|
+
var _a2;
|
1012
|
+
return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
|
1007
1013
|
}
|
1008
1014
|
);
|
1009
1015
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
1010
1016
|
const enabledValues = descendants.enabledValues(
|
1011
1017
|
({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
|
1012
1018
|
);
|
1019
|
+
const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
|
1013
1020
|
const validChildren = (0, import_utils11.getValidChildren)(children);
|
1014
1021
|
const computedChildren = (0, import_react5.useMemo)(
|
1015
1022
|
() => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
|
@@ -1039,8 +1046,8 @@ var useAutocomplete = (props) => {
|
|
1039
1046
|
if (inputRef.current) inputRef.current.focus();
|
1040
1047
|
}, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
|
1041
1048
|
const onFocusFirst = (0, import_react5.useCallback)(() => {
|
1042
|
-
const
|
1043
|
-
var
|
1049
|
+
const id = setTimeout(() => {
|
1050
|
+
var _a2;
|
1044
1051
|
if (isEmpty || isAllSelected) return;
|
1045
1052
|
const first = descendants.enabledFirstValue(
|
1046
1053
|
({ node }) => "target" in node.dataset
|
@@ -1051,13 +1058,13 @@ var useAutocomplete = (props) => {
|
|
1051
1058
|
} else {
|
1052
1059
|
if (selectedIndexes.includes(first.index)) {
|
1053
1060
|
const enabledFirst = enabledValues[0];
|
1054
|
-
setFocusedIndex((
|
1061
|
+
setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
|
1055
1062
|
} else {
|
1056
1063
|
setFocusedIndex(first.index);
|
1057
1064
|
}
|
1058
1065
|
}
|
1059
1066
|
});
|
1060
|
-
timeoutIds.current.add(
|
1067
|
+
timeoutIds.current.add(id);
|
1061
1068
|
}, [
|
1062
1069
|
descendants,
|
1063
1070
|
enabledValues,
|
@@ -1068,8 +1075,8 @@ var useAutocomplete = (props) => {
|
|
1068
1075
|
selectedIndexes
|
1069
1076
|
]);
|
1070
1077
|
const onFocusLast = (0, import_react5.useCallback)(() => {
|
1071
|
-
const
|
1072
|
-
var
|
1078
|
+
const id = setTimeout(() => {
|
1079
|
+
var _a2;
|
1073
1080
|
if (isEmpty || isAllSelected) return;
|
1074
1081
|
const last = descendants.enabledLastValue(
|
1075
1082
|
({ node }) => "target" in node.dataset
|
@@ -1080,13 +1087,13 @@ var useAutocomplete = (props) => {
|
|
1080
1087
|
} else {
|
1081
1088
|
if (selectedIndexes.includes(last.index)) {
|
1082
1089
|
const enabledLast = enabledValues.reverse()[0];
|
1083
|
-
setFocusedIndex((
|
1090
|
+
setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
|
1084
1091
|
} else {
|
1085
1092
|
setFocusedIndex(last.index);
|
1086
1093
|
}
|
1087
1094
|
}
|
1088
1095
|
});
|
1089
|
-
timeoutIds.current.add(
|
1096
|
+
timeoutIds.current.add(id);
|
1090
1097
|
}, [
|
1091
1098
|
descendants,
|
1092
1099
|
enabledValues,
|
@@ -1097,22 +1104,22 @@ var useAutocomplete = (props) => {
|
|
1097
1104
|
selectedIndexes
|
1098
1105
|
]);
|
1099
1106
|
const onFocusSelected = (0, import_react5.useCallback)(() => {
|
1100
|
-
const
|
1107
|
+
const id = setTimeout(() => {
|
1101
1108
|
const values = descendants.enabledValues();
|
1102
1109
|
const selected = values.find(
|
1103
1110
|
({ node }) => {
|
1104
|
-
var
|
1105
|
-
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 : "");
|
1106
1113
|
}
|
1107
1114
|
);
|
1108
1115
|
if (selected) setFocusedIndex(selected.index);
|
1109
1116
|
});
|
1110
|
-
timeoutIds.current.add(
|
1117
|
+
timeoutIds.current.add(id);
|
1111
1118
|
}, [descendants, isMulti, value]);
|
1112
1119
|
const onFocusNext = (0, import_react5.useCallback)(
|
1113
1120
|
(index = focusedIndex) => {
|
1114
|
-
const
|
1115
|
-
var
|
1121
|
+
const id = setTimeout(() => {
|
1122
|
+
var _a2, _b;
|
1116
1123
|
const next = descendants.enabledNextValue(
|
1117
1124
|
index,
|
1118
1125
|
({ node }) => "target" in node.dataset
|
@@ -1122,14 +1129,14 @@ var useAutocomplete = (props) => {
|
|
1122
1129
|
setFocusedIndex(next.index);
|
1123
1130
|
} else {
|
1124
1131
|
if (selectedIndexes.includes(next.index)) {
|
1125
|
-
const enabledNext = (
|
1132
|
+
const enabledNext = (_a2 = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a2 : enabledValues[0];
|
1126
1133
|
setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
|
1127
1134
|
} else {
|
1128
1135
|
setFocusedIndex(next.index);
|
1129
1136
|
}
|
1130
1137
|
}
|
1131
1138
|
});
|
1132
|
-
timeoutIds.current.add(
|
1139
|
+
timeoutIds.current.add(id);
|
1133
1140
|
},
|
1134
1141
|
[
|
1135
1142
|
descendants,
|
@@ -1142,8 +1149,8 @@ var useAutocomplete = (props) => {
|
|
1142
1149
|
);
|
1143
1150
|
const onFocusPrev = (0, import_react5.useCallback)(
|
1144
1151
|
(index = focusedIndex) => {
|
1145
|
-
const
|
1146
|
-
var
|
1152
|
+
const id = setTimeout(() => {
|
1153
|
+
var _a2, _b;
|
1147
1154
|
const prev = descendants.enabledPrevValue(
|
1148
1155
|
index,
|
1149
1156
|
({ node }) => "target" in node.dataset
|
@@ -1153,14 +1160,14 @@ var useAutocomplete = (props) => {
|
|
1153
1160
|
setFocusedIndex(prev.index);
|
1154
1161
|
} else {
|
1155
1162
|
if (selectedIndexes.includes(prev.index)) {
|
1156
|
-
const enabledPrev = (
|
1163
|
+
const enabledPrev = (_a2 = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a2 : enabledValues[0];
|
1157
1164
|
setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
|
1158
1165
|
} else {
|
1159
1166
|
setFocusedIndex(prev.index);
|
1160
1167
|
}
|
1161
1168
|
}
|
1162
1169
|
});
|
1163
|
-
timeoutIds.current.add(
|
1170
|
+
timeoutIds.current.add(id);
|
1164
1171
|
},
|
1165
1172
|
[
|
1166
1173
|
descendants,
|
@@ -1179,8 +1186,8 @@ var useAutocomplete = (props) => {
|
|
1179
1186
|
let isHit2 = false;
|
1180
1187
|
let isFocused2 = false;
|
1181
1188
|
values.forEach(({ index, node }) => {
|
1182
|
-
var
|
1183
|
-
if (format((
|
1189
|
+
var _a2;
|
1190
|
+
if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
|
1184
1191
|
isHit2 = true;
|
1185
1192
|
const isDisabled = "disabled" in node.dataset;
|
1186
1193
|
node.dataset.target = "";
|
@@ -1213,8 +1220,8 @@ var useAutocomplete = (props) => {
|
|
1213
1220
|
if (!values.length) return;
|
1214
1221
|
const resolvedValues = (0, import_utils11.isArray)(newValue) ? newValue : [newValue];
|
1215
1222
|
const selectedLabel = resolvedValues.map((value2) => {
|
1216
|
-
var
|
1217
|
-
const { node } = (
|
1223
|
+
var _a2, _b;
|
1224
|
+
const { node } = (_a2 = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a2 : {};
|
1218
1225
|
if (node) {
|
1219
1226
|
const { textContent } = (_b = Array.from(node.children).find(
|
1220
1227
|
(child) => child.getAttribute("data-label") !== null
|
@@ -1251,9 +1258,9 @@ var useAutocomplete = (props) => {
|
|
1251
1258
|
[isMulti, rebirthOptions, setValue]
|
1252
1259
|
);
|
1253
1260
|
const onSelect = (0, import_react5.useCallback)(() => {
|
1254
|
-
var
|
1261
|
+
var _a2, _b;
|
1255
1262
|
let enabledValue = descendants.value(focusedIndex);
|
1256
|
-
if ("disabled" in ((
|
1263
|
+
if ("disabled" in ((_a2 = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a2 : {}))
|
1257
1264
|
enabledValue = void 0;
|
1258
1265
|
if (!enabledValue) return;
|
1259
1266
|
const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
|
@@ -1291,8 +1298,7 @@ var useAutocomplete = (props) => {
|
|
1291
1298
|
isComposition.current = false;
|
1292
1299
|
}, []);
|
1293
1300
|
const onCreate = (0, import_react5.useCallback)(() => {
|
1294
|
-
var
|
1295
|
-
if (!listRef.current) return;
|
1301
|
+
var _a2, _b;
|
1296
1302
|
const newItem = { label: inputValue, value: inputValue };
|
1297
1303
|
let newItems = [];
|
1298
1304
|
if (resolvedItems) newItems = [...resolvedItems];
|
@@ -1307,7 +1313,7 @@ var useAutocomplete = (props) => {
|
|
1307
1313
|
const targetItem = newItems[i];
|
1308
1314
|
if (i !== -1 && targetItem && "items" in targetItem) {
|
1309
1315
|
if (secondInsertPositionItem === "first") {
|
1310
|
-
targetItem.items = [newItem, ...(
|
1316
|
+
targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
|
1311
1317
|
} else {
|
1312
1318
|
targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
|
1313
1319
|
}
|
@@ -1464,7 +1470,7 @@ var useAutocomplete = (props) => {
|
|
1464
1470
|
setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
|
1465
1471
|
}, [items]);
|
1466
1472
|
(0, import_utils11.useUnmountEffect)(() => {
|
1467
|
-
timeoutIds.current.forEach((
|
1473
|
+
timeoutIds.current.forEach((id) => clearTimeout(id));
|
1468
1474
|
timeoutIds.current.clear();
|
1469
1475
|
});
|
1470
1476
|
(0, import_use_outside_click.useOutsideClick)({
|
@@ -1535,6 +1541,10 @@ var useAutocomplete = (props) => {
|
|
1535
1541
|
const getFieldProps = (0, import_react5.useCallback)(
|
1536
1542
|
(props2 = {}, ref = null) => ({
|
1537
1543
|
ref,
|
1544
|
+
"aria-activedescendant": activedescendantId,
|
1545
|
+
"aria-autocomplete": "list",
|
1546
|
+
"aria-haspopup": "listbox",
|
1547
|
+
role: "combobox",
|
1538
1548
|
tabIndex: -1,
|
1539
1549
|
...props2,
|
1540
1550
|
...formControlProps,
|
@@ -1544,6 +1554,7 @@ var useAutocomplete = (props) => {
|
|
1544
1554
|
onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
|
1545
1555
|
}),
|
1546
1556
|
[
|
1557
|
+
activedescendantId,
|
1547
1558
|
formControlProps,
|
1548
1559
|
placeholder,
|
1549
1560
|
isOpen,
|
@@ -1554,7 +1565,6 @@ var useAutocomplete = (props) => {
|
|
1554
1565
|
]
|
1555
1566
|
);
|
1556
1567
|
return {
|
1557
|
-
id,
|
1558
1568
|
allowCreate,
|
1559
1569
|
allowFree,
|
1560
1570
|
children: children != null ? children : computedChildren,
|
@@ -1569,7 +1579,6 @@ var useAutocomplete = (props) => {
|
|
1569
1579
|
isHit,
|
1570
1580
|
isOpen,
|
1571
1581
|
label,
|
1572
|
-
listRef,
|
1573
1582
|
omitSelectedValues,
|
1574
1583
|
pickOptions,
|
1575
1584
|
rebirthOptions,
|
@@ -1597,23 +1606,15 @@ var useAutocomplete = (props) => {
|
|
1597
1606
|
};
|
1598
1607
|
};
|
1599
1608
|
var useAutocompleteInput = () => {
|
1600
|
-
var _a, _b;
|
1601
1609
|
const {
|
1602
|
-
id,
|
1603
|
-
focusedIndex,
|
1604
1610
|
inputRef,
|
1605
1611
|
isAllSelected,
|
1606
|
-
isOpen,
|
1607
|
-
listRef,
|
1608
1612
|
formControlProps,
|
1609
1613
|
inputProps,
|
1610
1614
|
onCompositionEnd,
|
1611
1615
|
onCompositionStart,
|
1612
1616
|
onSearch
|
1613
1617
|
} = useAutocompleteContext();
|
1614
|
-
const descendants = useAutocompleteDescendantsContext();
|
1615
|
-
const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
|
1616
|
-
const listId = (_b = listRef.current) == null ? void 0 : _b.id;
|
1617
1618
|
(0, import_utils11.useUpdateEffect)(() => {
|
1618
1619
|
if (isAllSelected && inputRef.current) inputRef.current.blur();
|
1619
1620
|
}, [isAllSelected]);
|
@@ -1622,19 +1623,12 @@ var useAutocompleteInput = () => {
|
|
1622
1623
|
return {
|
1623
1624
|
ref: (0, import_utils11.mergeRefs)(inputRef, ref),
|
1624
1625
|
...formControlProps,
|
1625
|
-
"aria-activedescendant": activedescendantId,
|
1626
|
-
"aria-autocomplete": "list",
|
1627
|
-
"aria-controls": listId,
|
1628
|
-
"aria-expanded": isOpen,
|
1629
|
-
"aria-haspopup": "listbox",
|
1630
1626
|
autoCapitalize: "none",
|
1631
1627
|
autoComplete: "off",
|
1632
|
-
role: "combobox",
|
1633
1628
|
spellCheck: "false",
|
1634
1629
|
tabIndex: isAllSelected ? -1 : 0,
|
1635
1630
|
...inputProps,
|
1636
1631
|
...props,
|
1637
|
-
id,
|
1638
1632
|
cursor: formControlProps.readOnly ? "default" : "text",
|
1639
1633
|
pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
|
1640
1634
|
onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
|
@@ -1651,13 +1645,9 @@ var useAutocompleteInput = () => {
|
|
1651
1645
|
};
|
1652
1646
|
},
|
1653
1647
|
[
|
1654
|
-
listId,
|
1655
|
-
activedescendantId,
|
1656
|
-
isOpen,
|
1657
1648
|
inputProps,
|
1658
1649
|
inputRef,
|
1659
1650
|
formControlProps,
|
1660
|
-
id,
|
1661
1651
|
isAllSelected,
|
1662
1652
|
onSearch,
|
1663
1653
|
onCompositionStart,
|