@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.
Files changed (71) hide show
  1. package/dist/autocomplete-context.d.mts +0 -1
  2. package/dist/autocomplete-context.d.ts +0 -1
  3. package/dist/autocomplete-context.js.map +1 -1
  4. package/dist/autocomplete-context.mjs +1 -1
  5. package/dist/autocomplete-create.js.map +1 -1
  6. package/dist/autocomplete-create.mjs +4 -4
  7. package/dist/autocomplete-empty.js.map +1 -1
  8. package/dist/autocomplete-empty.mjs +4 -4
  9. package/dist/autocomplete-icon.js.map +1 -1
  10. package/dist/autocomplete-icon.mjs +2 -2
  11. package/dist/autocomplete-list.js +22 -15
  12. package/dist/autocomplete-list.js.map +1 -1
  13. package/dist/autocomplete-list.mjs +3 -3
  14. package/dist/autocomplete-option-group.js.map +1 -1
  15. package/dist/autocomplete-option-group.mjs +3 -3
  16. package/dist/autocomplete-option.js.map +1 -1
  17. package/dist/autocomplete-option.mjs +4 -4
  18. package/dist/autocomplete.js +66 -76
  19. package/dist/autocomplete.js.map +1 -1
  20. package/dist/autocomplete.mjs +12 -12
  21. package/dist/{chunk-7YDPBPBY.mjs → chunk-2CVB4NO5.mjs} +7 -7
  22. package/dist/{chunk-LCC3VNZV.mjs → chunk-2LP57WVB.mjs} +2 -2
  23. package/dist/{chunk-PTPJFYGI.mjs → chunk-4GVV3HBE.mjs} +29 -13
  24. package/dist/chunk-4GVV3HBE.mjs.map +1 -0
  25. package/dist/{chunk-6OTUOEYS.mjs → chunk-7QCZ5NGS.mjs} +2 -2
  26. package/dist/{chunk-PU6HFINM.mjs → chunk-ABCTEZN5.mjs} +3 -3
  27. package/dist/{chunk-J3GHHVSC.mjs → chunk-IFH3PPSD.mjs} +7 -7
  28. package/dist/{chunk-REPBXBG3.mjs → chunk-LIBFONYN.mjs} +7 -10
  29. package/dist/chunk-LIBFONYN.mjs.map +1 -0
  30. package/dist/{chunk-7GVG5MVF.mjs → chunk-PWV7X7G6.mjs} +4 -4
  31. package/dist/{chunk-ZFWB5LCD.mjs → chunk-RK5E5J5E.mjs} +4 -4
  32. package/dist/{chunk-ZNO5RUVT.mjs → chunk-TP5VZFO3.mjs} +1 -1
  33. package/dist/chunk-TP5VZFO3.mjs.map +1 -0
  34. package/dist/{chunk-CMFJUJJW.mjs → chunk-UX5QECNB.mjs} +2 -2
  35. package/dist/{chunk-6QAH2ARG.mjs → chunk-YPKDYYEV.mjs} +4 -4
  36. package/dist/{chunk-YWUT56L3.mjs → chunk-ZR77IT3O.mjs} +49 -67
  37. package/dist/chunk-ZR77IT3O.mjs.map +1 -0
  38. package/dist/index.js +66 -76
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +13 -13
  41. package/dist/multi-autocomplete.js +66 -76
  42. package/dist/multi-autocomplete.js.map +1 -1
  43. package/dist/multi-autocomplete.mjs +12 -12
  44. package/dist/use-autocomplete-list.d.mts +2 -1
  45. package/dist/use-autocomplete-list.d.ts +2 -1
  46. package/dist/use-autocomplete-list.js +19 -9
  47. package/dist/use-autocomplete-list.js.map +1 -1
  48. package/dist/use-autocomplete-list.mjs +2 -2
  49. package/dist/use-autocomplete-option-group.js.map +1 -1
  50. package/dist/use-autocomplete-option-group.mjs +2 -2
  51. package/dist/use-autocomplete-option.js.map +1 -1
  52. package/dist/use-autocomplete-option.mjs +2 -2
  53. package/dist/use-autocomplete.d.mts +0 -2
  54. package/dist/use-autocomplete.d.ts +0 -2
  55. package/dist/use-autocomplete.js +44 -61
  56. package/dist/use-autocomplete.js.map +1 -1
  57. package/dist/use-autocomplete.mjs +7 -7
  58. package/package.json +4 -4
  59. package/dist/chunk-PTPJFYGI.mjs.map +0 -1
  60. package/dist/chunk-REPBXBG3.mjs.map +0 -1
  61. package/dist/chunk-YWUT56L3.mjs.map +0 -1
  62. package/dist/chunk-ZNO5RUVT.mjs.map +0 -1
  63. /package/dist/{chunk-7YDPBPBY.mjs.map → chunk-2CVB4NO5.mjs.map} +0 -0
  64. /package/dist/{chunk-LCC3VNZV.mjs.map → chunk-2LP57WVB.mjs.map} +0 -0
  65. /package/dist/{chunk-6OTUOEYS.mjs.map → chunk-7QCZ5NGS.mjs.map} +0 -0
  66. /package/dist/{chunk-PU6HFINM.mjs.map → chunk-ABCTEZN5.mjs.map} +0 -0
  67. /package/dist/{chunk-J3GHHVSC.mjs.map → chunk-IFH3PPSD.mjs.map} +0 -0
  68. /package/dist/{chunk-7GVG5MVF.mjs.map → chunk-PWV7X7G6.mjs.map} +0 -0
  69. /package/dist/{chunk-ZFWB5LCD.mjs.map → chunk-RK5E5J5E.mjs.map} +0 -0
  70. /package/dist/{chunk-CMFJUJJW.mjs.map → chunk-UX5QECNB.mjs.map} +0 -0
  71. /package/dist/{chunk-6QAH2ARG.mjs.map → chunk-YPKDYYEV.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,29 +1,29 @@
1
1
  "use client"
2
2
  import {
3
3
  MultiAutocomplete
4
- } from "./chunk-J3GHHVSC.mjs";
4
+ } from "./chunk-IFH3PPSD.mjs";
5
5
  import {
6
6
  Autocomplete
7
- } from "./chunk-7YDPBPBY.mjs";
8
- import "./chunk-YWUT56L3.mjs";
7
+ } from "./chunk-2CVB4NO5.mjs";
8
+ import "./chunk-ZR77IT3O.mjs";
9
9
  import {
10
10
  AutocompleteCreate
11
- } from "./chunk-ZFWB5LCD.mjs";
11
+ } from "./chunk-RK5E5J5E.mjs";
12
12
  import {
13
13
  AutocompleteEmpty
14
- } from "./chunk-6QAH2ARG.mjs";
15
- import "./chunk-REPBXBG3.mjs";
16
- import "./chunk-PTPJFYGI.mjs";
14
+ } from "./chunk-YPKDYYEV.mjs";
15
+ import "./chunk-LIBFONYN.mjs";
16
+ import "./chunk-4GVV3HBE.mjs";
17
17
  import {
18
18
  AutocompleteOptionGroup
19
- } from "./chunk-PU6HFINM.mjs";
20
- import "./chunk-CMFJUJJW.mjs";
19
+ } from "./chunk-ABCTEZN5.mjs";
20
+ import "./chunk-UX5QECNB.mjs";
21
21
  import {
22
22
  AutocompleteOption
23
- } from "./chunk-7GVG5MVF.mjs";
24
- import "./chunk-LCC3VNZV.mjs";
25
- import "./chunk-6OTUOEYS.mjs";
26
- import "./chunk-ZNO5RUVT.mjs";
23
+ } from "./chunk-PWV7X7G6.mjs";
24
+ import "./chunk-2LP57WVB.mjs";
25
+ import "./chunk-7QCZ5NGS.mjs";
26
+ import "./chunk-TP5VZFO3.mjs";
27
27
  export {
28
28
  Autocomplete,
29
29
  AutocompleteCreate,
@@ -454,9 +454,9 @@ var import_utils7 = require("@yamada-ui/utils");
454
454
  var import_utils6 = require("@yamada-ui/utils");
455
455
  var import_react3 = require("react");
456
456
  var useAutocompleteList = () => {
457
- const { focusedIndex, isOpen, listRef, rebirthOptions, value } = useAutocompleteContext();
457
+ const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
458
458
  const descendants = useAutocompleteDescendantsContext();
459
- const uuid = (0, import_react3.useId)();
459
+ const listRef = (0, import_react3.useRef)(null);
460
460
  const beforeFocusedIndex = (0, import_react3.useRef)(-1);
461
461
  const selectedValue = descendants.value(focusedIndex);
462
462
  const isMulti = (0, import_utils6.isArray)(value);
@@ -492,21 +492,31 @@ var useAutocompleteList = () => {
492
492
  (0, import_utils6.useUpdateEffect)(() => {
493
493
  if (!isOpen) beforeFocusedIndex.current = -1;
494
494
  }, [isOpen]);
495
+ const getContainerProps = (0, import_react3.useCallback)(
496
+ (props = {}, ref = null) => ({
497
+ ref,
498
+ "aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
499
+ role: "listbox",
500
+ ...props,
501
+ onAnimationComplete: (0, import_utils6.handlerAll)(
502
+ props.onAnimationComplete,
503
+ onAnimationComplete
504
+ )
505
+ }),
506
+ [isMulti, onAnimationComplete]
507
+ );
495
508
  const getListProps = (0, import_react3.useCallback)(
496
- ({ id, ...props } = {}, ref = null) => ({
497
- id: id != null ? id : uuid,
509
+ (props = {}, ref = null) => ({
498
510
  ref: (0, import_utils6.mergeRefs)(listRef, ref),
499
- "aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
500
511
  position: "relative",
501
- role: "listbox",
502
512
  tabIndex: -1,
503
513
  ...props
504
514
  }),
505
- [listRef, uuid, isMulti]
515
+ [listRef]
506
516
  );
507
517
  return {
508
- getListProps,
509
- onAnimationComplete
518
+ getContainerProps,
519
+ getListProps
510
520
  };
511
521
  };
512
522
 
@@ -529,7 +539,7 @@ var AutocompleteList = (0, import_core4.forwardRef)(
529
539
  }, ref) => {
530
540
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
531
541
  const { styles } = useAutocompleteContext();
532
- const { getListProps, onAnimationComplete } = useAutocompleteList();
542
+ const { getContainerProps, getListProps } = useAutocompleteList();
533
543
  width != null ? width : width = w;
534
544
  width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
535
545
  minWidth != null ? minWidth : minWidth = minW;
@@ -539,16 +549,13 @@ var AutocompleteList = (0, import_core4.forwardRef)(
539
549
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
540
550
  import_popover.PopoverContent,
541
551
  {
552
+ as: "div",
542
553
  className: "ui-autocomplete__popover",
543
554
  maxWidth,
544
555
  minWidth,
545
556
  width,
546
557
  __css: { ...styles.content, maxWidth, minWidth, width },
547
- ...contentProps,
548
- onAnimationComplete: (0, import_utils7.handlerAll)(
549
- contentProps == null ? void 0 : contentProps.onAnimationComplete,
550
- onAnimationComplete
551
- ),
558
+ ...getContainerProps(contentProps),
552
559
  children: [
553
560
  header ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
554
561
  import_core4.ui.header,
@@ -900,6 +907,7 @@ var flattenItems = (items) => {
900
907
  return filterItems(items).flat(Infinity);
901
908
  };
902
909
  var useAutocomplete = (props) => {
910
+ var _a;
903
911
  const {
904
912
  allowCreate = false,
905
913
  allowFree = false,
@@ -943,16 +951,8 @@ var useAutocomplete = (props) => {
943
951
  onSearch: onSearchProp,
944
952
  ...rest
945
953
  } = (0, import_form_control.useFormControlProps)(props);
946
- const {
947
- "aria-readonly": _ariaReadonly,
948
- onFocus: onFocusProp,
949
- ...formControlProps
950
- } = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
951
- const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
952
- const { id } = rest;
953
954
  const descendants = useAutocompleteDescendants();
954
955
  const containerRef = (0, import_react5.useRef)(null);
955
- const listRef = (0, import_react5.useRef)(null);
956
956
  const inputRef = (0, import_react5.useRef)(null);
957
957
  const timeoutIds = (0, import_react5.useRef)(/* @__PURE__ */ new Set([]));
958
958
  const isComposition = (0, import_react5.useRef)(false);
@@ -978,6 +978,12 @@ var useAutocomplete = (props) => {
978
978
  onClose: onCloseProp,
979
979
  onOpen: onOpenProp
980
980
  });
981
+ const {
982
+ "aria-readonly": _ariaReadonly,
983
+ onFocus: onFocusProp,
984
+ ...formControlProps
985
+ } = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
986
+ const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
981
987
  const isFocused = focusedIndex > -1;
982
988
  const isCreate = focusedIndex === -2 && allowCreate;
983
989
  const isMulti = (0, import_utils11.isArray)(value);
@@ -996,14 +1002,15 @@ var useAutocomplete = (props) => {
996
1002
  }
997
1003
  const selectedValues = descendants.enabledValues(
998
1004
  ({ node }) => {
999
- var _a;
1000
- return isMulti && value.includes((_a = node.dataset.value) != null ? _a : "");
1005
+ var _a2;
1006
+ return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
1001
1007
  }
1002
1008
  );
1003
1009
  const selectedIndexes = selectedValues.map(({ index }) => index);
1004
1010
  const enabledValues = descendants.enabledValues(
1005
1011
  ({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
1006
1012
  );
1013
+ const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1007
1014
  const validChildren = (0, import_utils11.getValidChildren)(children);
1008
1015
  const computedChildren = (0, import_react5.useMemo)(
1009
1016
  () => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
@@ -1033,8 +1040,8 @@ var useAutocomplete = (props) => {
1033
1040
  if (inputRef.current) inputRef.current.focus();
1034
1041
  }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
1035
1042
  const onFocusFirst = (0, import_react5.useCallback)(() => {
1036
- const id2 = setTimeout(() => {
1037
- var _a;
1043
+ const id = setTimeout(() => {
1044
+ var _a2;
1038
1045
  if (isEmpty || isAllSelected) return;
1039
1046
  const first = descendants.enabledFirstValue(
1040
1047
  ({ node }) => "target" in node.dataset
@@ -1045,13 +1052,13 @@ var useAutocomplete = (props) => {
1045
1052
  } else {
1046
1053
  if (selectedIndexes.includes(first.index)) {
1047
1054
  const enabledFirst = enabledValues[0];
1048
- setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
1055
+ setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
1049
1056
  } else {
1050
1057
  setFocusedIndex(first.index);
1051
1058
  }
1052
1059
  }
1053
1060
  });
1054
- timeoutIds.current.add(id2);
1061
+ timeoutIds.current.add(id);
1055
1062
  }, [
1056
1063
  descendants,
1057
1064
  enabledValues,
@@ -1062,8 +1069,8 @@ var useAutocomplete = (props) => {
1062
1069
  selectedIndexes
1063
1070
  ]);
1064
1071
  const onFocusLast = (0, import_react5.useCallback)(() => {
1065
- const id2 = setTimeout(() => {
1066
- var _a;
1072
+ const id = setTimeout(() => {
1073
+ var _a2;
1067
1074
  if (isEmpty || isAllSelected) return;
1068
1075
  const last = descendants.enabledLastValue(
1069
1076
  ({ node }) => "target" in node.dataset
@@ -1074,13 +1081,13 @@ var useAutocomplete = (props) => {
1074
1081
  } else {
1075
1082
  if (selectedIndexes.includes(last.index)) {
1076
1083
  const enabledLast = enabledValues.reverse()[0];
1077
- setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
1084
+ setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
1078
1085
  } else {
1079
1086
  setFocusedIndex(last.index);
1080
1087
  }
1081
1088
  }
1082
1089
  });
1083
- timeoutIds.current.add(id2);
1090
+ timeoutIds.current.add(id);
1084
1091
  }, [
1085
1092
  descendants,
1086
1093
  enabledValues,
@@ -1091,22 +1098,22 @@ var useAutocomplete = (props) => {
1091
1098
  selectedIndexes
1092
1099
  ]);
1093
1100
  const onFocusSelected = (0, import_react5.useCallback)(() => {
1094
- const id2 = setTimeout(() => {
1101
+ const id = setTimeout(() => {
1095
1102
  const values = descendants.enabledValues();
1096
1103
  const selected = values.find(
1097
1104
  ({ node }) => {
1098
- var _a;
1099
- return !isMulti ? node.dataset.value === value : value.includes((_a = node.dataset.value) != null ? _a : "");
1105
+ var _a2;
1106
+ return !isMulti ? node.dataset.value === value : value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
1100
1107
  }
1101
1108
  );
1102
1109
  if (selected) setFocusedIndex(selected.index);
1103
1110
  });
1104
- timeoutIds.current.add(id2);
1111
+ timeoutIds.current.add(id);
1105
1112
  }, [descendants, isMulti, value]);
1106
1113
  const onFocusNext = (0, import_react5.useCallback)(
1107
1114
  (index = focusedIndex) => {
1108
- const id2 = setTimeout(() => {
1109
- var _a, _b;
1115
+ const id = setTimeout(() => {
1116
+ var _a2, _b;
1110
1117
  const next = descendants.enabledNextValue(
1111
1118
  index,
1112
1119
  ({ node }) => "target" in node.dataset
@@ -1116,14 +1123,14 @@ var useAutocomplete = (props) => {
1116
1123
  setFocusedIndex(next.index);
1117
1124
  } else {
1118
1125
  if (selectedIndexes.includes(next.index)) {
1119
- const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
1126
+ const enabledNext = (_a2 = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a2 : enabledValues[0];
1120
1127
  setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
1121
1128
  } else {
1122
1129
  setFocusedIndex(next.index);
1123
1130
  }
1124
1131
  }
1125
1132
  });
1126
- timeoutIds.current.add(id2);
1133
+ timeoutIds.current.add(id);
1127
1134
  },
1128
1135
  [
1129
1136
  descendants,
@@ -1136,8 +1143,8 @@ var useAutocomplete = (props) => {
1136
1143
  );
1137
1144
  const onFocusPrev = (0, import_react5.useCallback)(
1138
1145
  (index = focusedIndex) => {
1139
- const id2 = setTimeout(() => {
1140
- var _a, _b;
1146
+ const id = setTimeout(() => {
1147
+ var _a2, _b;
1141
1148
  const prev = descendants.enabledPrevValue(
1142
1149
  index,
1143
1150
  ({ node }) => "target" in node.dataset
@@ -1147,14 +1154,14 @@ var useAutocomplete = (props) => {
1147
1154
  setFocusedIndex(prev.index);
1148
1155
  } else {
1149
1156
  if (selectedIndexes.includes(prev.index)) {
1150
- const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
1157
+ const enabledPrev = (_a2 = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a2 : enabledValues[0];
1151
1158
  setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
1152
1159
  } else {
1153
1160
  setFocusedIndex(prev.index);
1154
1161
  }
1155
1162
  }
1156
1163
  });
1157
- timeoutIds.current.add(id2);
1164
+ timeoutIds.current.add(id);
1158
1165
  },
1159
1166
  [
1160
1167
  descendants,
@@ -1173,8 +1180,8 @@ var useAutocomplete = (props) => {
1173
1180
  let isHit2 = false;
1174
1181
  let isFocused2 = false;
1175
1182
  values.forEach(({ index, node }) => {
1176
- var _a;
1177
- if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
1183
+ var _a2;
1184
+ if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
1178
1185
  isHit2 = true;
1179
1186
  const isDisabled = "disabled" in node.dataset;
1180
1187
  node.dataset.target = "";
@@ -1207,8 +1214,8 @@ var useAutocomplete = (props) => {
1207
1214
  if (!values.length) return;
1208
1215
  const resolvedValues = (0, import_utils11.isArray)(newValue) ? newValue : [newValue];
1209
1216
  const selectedLabel = resolvedValues.map((value2) => {
1210
- var _a, _b;
1211
- const { node } = (_a = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a : {};
1217
+ var _a2, _b;
1218
+ const { node } = (_a2 = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a2 : {};
1212
1219
  if (node) {
1213
1220
  const { textContent } = (_b = Array.from(node.children).find(
1214
1221
  (child) => child.getAttribute("data-label") !== null
@@ -1245,9 +1252,9 @@ var useAutocomplete = (props) => {
1245
1252
  [isMulti, rebirthOptions, setValue]
1246
1253
  );
1247
1254
  const onSelect = (0, import_react5.useCallback)(() => {
1248
- var _a, _b;
1255
+ var _a2, _b;
1249
1256
  let enabledValue = descendants.value(focusedIndex);
1250
- if ("disabled" in ((_a = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a : {}))
1257
+ if ("disabled" in ((_a2 = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a2 : {}))
1251
1258
  enabledValue = void 0;
1252
1259
  if (!enabledValue) return;
1253
1260
  const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
@@ -1285,8 +1292,7 @@ var useAutocomplete = (props) => {
1285
1292
  isComposition.current = false;
1286
1293
  }, []);
1287
1294
  const onCreate = (0, import_react5.useCallback)(() => {
1288
- var _a, _b;
1289
- if (!listRef.current) return;
1295
+ var _a2, _b;
1290
1296
  const newItem = { label: inputValue, value: inputValue };
1291
1297
  let newItems = [];
1292
1298
  if (resolvedItems) newItems = [...resolvedItems];
@@ -1301,7 +1307,7 @@ var useAutocomplete = (props) => {
1301
1307
  const targetItem = newItems[i];
1302
1308
  if (i !== -1 && targetItem && "items" in targetItem) {
1303
1309
  if (secondInsertPositionItem === "first") {
1304
- targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
1310
+ targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
1305
1311
  } else {
1306
1312
  targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
1307
1313
  }
@@ -1458,7 +1464,7 @@ var useAutocomplete = (props) => {
1458
1464
  setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
1459
1465
  }, [items]);
1460
1466
  (0, import_utils11.useUnmountEffect)(() => {
1461
- timeoutIds.current.forEach((id2) => clearTimeout(id2));
1467
+ timeoutIds.current.forEach((id) => clearTimeout(id));
1462
1468
  timeoutIds.current.clear();
1463
1469
  });
1464
1470
  (0, import_use_outside_click.useOutsideClick)({
@@ -1529,6 +1535,10 @@ var useAutocomplete = (props) => {
1529
1535
  const getFieldProps = (0, import_react5.useCallback)(
1530
1536
  (props2 = {}, ref = null) => ({
1531
1537
  ref,
1538
+ "aria-activedescendant": activedescendantId,
1539
+ "aria-autocomplete": "list",
1540
+ "aria-haspopup": "listbox",
1541
+ role: "combobox",
1532
1542
  tabIndex: -1,
1533
1543
  ...props2,
1534
1544
  ...formControlProps,
@@ -1538,6 +1548,7 @@ var useAutocomplete = (props) => {
1538
1548
  onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
1539
1549
  }),
1540
1550
  [
1551
+ activedescendantId,
1541
1552
  formControlProps,
1542
1553
  placeholder,
1543
1554
  isOpen,
@@ -1548,7 +1559,6 @@ var useAutocomplete = (props) => {
1548
1559
  ]
1549
1560
  );
1550
1561
  return {
1551
- id,
1552
1562
  allowCreate,
1553
1563
  allowFree,
1554
1564
  children: children != null ? children : computedChildren,
@@ -1563,7 +1573,6 @@ var useAutocomplete = (props) => {
1563
1573
  isHit,
1564
1574
  isOpen,
1565
1575
  label,
1566
- listRef,
1567
1576
  omitSelectedValues,
1568
1577
  pickOptions,
1569
1578
  rebirthOptions,
@@ -1591,23 +1600,15 @@ var useAutocomplete = (props) => {
1591
1600
  };
1592
1601
  };
1593
1602
  var useAutocompleteInput = () => {
1594
- var _a, _b;
1595
1603
  const {
1596
- id,
1597
- focusedIndex,
1598
1604
  inputRef,
1599
1605
  isAllSelected,
1600
- isOpen,
1601
- listRef,
1602
1606
  formControlProps,
1603
1607
  inputProps,
1604
1608
  onCompositionEnd,
1605
1609
  onCompositionStart,
1606
1610
  onSearch
1607
1611
  } = useAutocompleteContext();
1608
- const descendants = useAutocompleteDescendantsContext();
1609
- const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1610
- const listId = (_b = listRef.current) == null ? void 0 : _b.id;
1611
1612
  (0, import_utils11.useUpdateEffect)(() => {
1612
1613
  if (isAllSelected && inputRef.current) inputRef.current.blur();
1613
1614
  }, [isAllSelected]);
@@ -1616,19 +1617,12 @@ var useAutocompleteInput = () => {
1616
1617
  return {
1617
1618
  ref: (0, import_utils11.mergeRefs)(inputRef, ref),
1618
1619
  ...formControlProps,
1619
- "aria-activedescendant": activedescendantId,
1620
- "aria-autocomplete": "list",
1621
- "aria-controls": listId,
1622
- "aria-expanded": isOpen,
1623
- "aria-haspopup": "listbox",
1624
1620
  autoCapitalize: "none",
1625
1621
  autoComplete: "off",
1626
- role: "combobox",
1627
1622
  spellCheck: "false",
1628
1623
  tabIndex: isAllSelected ? -1 : 0,
1629
1624
  ...inputProps,
1630
1625
  ...props,
1631
- id,
1632
1626
  cursor: formControlProps.readOnly ? "default" : "text",
1633
1627
  pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1634
1628
  onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
@@ -1645,13 +1639,9 @@ var useAutocompleteInput = () => {
1645
1639
  };
1646
1640
  },
1647
1641
  [
1648
- listId,
1649
- activedescendantId,
1650
- isOpen,
1651
1642
  inputProps,
1652
1643
  inputRef,
1653
1644
  formControlProps,
1654
- id,
1655
1645
  isAllSelected,
1656
1646
  onSearch,
1657
1647
  onCompositionStart,