@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.
Files changed (79) 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 +10 -6
  17. package/dist/autocomplete-option.js.map +1 -1
  18. package/dist/autocomplete-option.mjs +4 -4
  19. package/dist/autocomplete.js +78 -84
  20. package/dist/autocomplete.js.map +1 -1
  21. package/dist/autocomplete.mjs +12 -12
  22. package/dist/{chunk-JYPMXZG4.mjs → chunk-2CVB4NO5.mjs} +7 -7
  23. package/dist/{chunk-3A2HEULI.mjs → chunk-2LP57WVB.mjs} +12 -8
  24. package/dist/chunk-2LP57WVB.mjs.map +1 -0
  25. package/dist/{chunk-PTPJFYGI.mjs → chunk-4GVV3HBE.mjs} +29 -13
  26. package/dist/chunk-4GVV3HBE.mjs.map +1 -0
  27. package/dist/{chunk-6OTUOEYS.mjs → chunk-7QCZ5NGS.mjs} +2 -2
  28. package/dist/{chunk-PU6HFINM.mjs → chunk-ABCTEZN5.mjs} +3 -3
  29. package/dist/{chunk-NOSATNDY.mjs → chunk-IFH3PPSD.mjs} +10 -8
  30. package/dist/chunk-IFH3PPSD.mjs.map +1 -0
  31. package/dist/{chunk-REPBXBG3.mjs → chunk-LIBFONYN.mjs} +7 -10
  32. package/dist/chunk-LIBFONYN.mjs.map +1 -0
  33. package/dist/{chunk-2UKLSSUA.mjs → chunk-PWV7X7G6.mjs} +4 -4
  34. package/dist/{chunk-G6SC44LI.mjs → chunk-RK5E5J5E.mjs} +4 -4
  35. package/dist/{chunk-ZNO5RUVT.mjs → chunk-TP5VZFO3.mjs} +1 -1
  36. package/dist/chunk-TP5VZFO3.mjs.map +1 -0
  37. package/dist/{chunk-CMFJUJJW.mjs → chunk-UX5QECNB.mjs} +2 -2
  38. package/dist/{chunk-6II6KCIJ.mjs → chunk-YPKDYYEV.mjs} +4 -4
  39. package/dist/{chunk-75VF5Q5W.mjs → chunk-ZR77IT3O.mjs} +51 -69
  40. package/dist/chunk-ZR77IT3O.mjs.map +1 -0
  41. package/dist/index.js +81 -85
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +13 -13
  44. package/dist/multi-autocomplete.d.mts +8 -0
  45. package/dist/multi-autocomplete.d.ts +8 -0
  46. package/dist/multi-autocomplete.js +81 -85
  47. package/dist/multi-autocomplete.js.map +1 -1
  48. package/dist/multi-autocomplete.mjs +12 -12
  49. package/dist/use-autocomplete-list.d.mts +2 -1
  50. package/dist/use-autocomplete-list.d.ts +2 -1
  51. package/dist/use-autocomplete-list.js +19 -9
  52. package/dist/use-autocomplete-list.js.map +1 -1
  53. package/dist/use-autocomplete-list.mjs +2 -2
  54. package/dist/use-autocomplete-option-group.js.map +1 -1
  55. package/dist/use-autocomplete-option-group.mjs +2 -2
  56. package/dist/use-autocomplete-option.d.mts +16 -0
  57. package/dist/use-autocomplete-option.d.ts +16 -0
  58. package/dist/use-autocomplete-option.js +10 -6
  59. package/dist/use-autocomplete-option.js.map +1 -1
  60. package/dist/use-autocomplete-option.mjs +2 -2
  61. package/dist/use-autocomplete.d.mts +3 -5
  62. package/dist/use-autocomplete.d.ts +3 -5
  63. package/dist/use-autocomplete.js +56 -69
  64. package/dist/use-autocomplete.js.map +1 -1
  65. package/dist/use-autocomplete.mjs +7 -7
  66. package/package.json +4 -4
  67. package/dist/chunk-3A2HEULI.mjs.map +0 -1
  68. package/dist/chunk-75VF5Q5W.mjs.map +0 -1
  69. package/dist/chunk-NOSATNDY.mjs.map +0 -1
  70. package/dist/chunk-PTPJFYGI.mjs.map +0 -1
  71. package/dist/chunk-REPBXBG3.mjs.map +0 -1
  72. package/dist/chunk-ZNO5RUVT.mjs.map +0 -1
  73. /package/dist/{chunk-JYPMXZG4.mjs.map → chunk-2CVB4NO5.mjs.map} +0 -0
  74. /package/dist/{chunk-6OTUOEYS.mjs.map → chunk-7QCZ5NGS.mjs.map} +0 -0
  75. /package/dist/{chunk-PU6HFINM.mjs.map → chunk-ABCTEZN5.mjs.map} +0 -0
  76. /package/dist/{chunk-2UKLSSUA.mjs.map → chunk-PWV7X7G6.mjs.map} +0 -0
  77. /package/dist/{chunk-G6SC44LI.mjs.map → chunk-RK5E5J5E.mjs.map} +0 -0
  78. /package/dist/{chunk-CMFJUJJW.mjs.map → chunk-UX5QECNB.mjs.map} +0 -0
  79. /package/dist/{chunk-6II6KCIJ.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-NOSATNDY.mjs";
4
+ } from "./chunk-IFH3PPSD.mjs";
5
5
  import {
6
6
  Autocomplete
7
- } from "./chunk-JYPMXZG4.mjs";
8
- import "./chunk-75VF5Q5W.mjs";
7
+ } from "./chunk-2CVB4NO5.mjs";
8
+ import "./chunk-ZR77IT3O.mjs";
9
9
  import {
10
10
  AutocompleteCreate
11
- } from "./chunk-G6SC44LI.mjs";
11
+ } from "./chunk-RK5E5J5E.mjs";
12
12
  import {
13
13
  AutocompleteEmpty
14
- } from "./chunk-6II6KCIJ.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-2UKLSSUA.mjs";
24
- import "./chunk-3A2HEULI.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,
@@ -18,6 +18,12 @@ import './autocomplete-option-group.mjs';
18
18
  import './use-autocomplete-option-group.mjs';
19
19
 
20
20
  interface MultiAutocompleteOptions {
21
+ /**
22
+ * If `true`, display the select clear icon.
23
+ *
24
+ * @default true
25
+ */
26
+ clearable?: boolean;
21
27
  /**
22
28
  * If `true`, the list element will be closed when value is selected.
23
29
  *
@@ -59,6 +65,8 @@ interface MultiAutocompleteOptions {
59
65
  * If `true`, display the select clear icon.
60
66
  *
61
67
  * @default true
68
+ *
69
+ * @deprecated Use `clearable` instead.
62
70
  */
63
71
  isClearable?: boolean;
64
72
  /**
@@ -18,6 +18,12 @@ import './autocomplete-option-group.js';
18
18
  import './use-autocomplete-option-group.js';
19
19
 
20
20
  interface MultiAutocompleteOptions {
21
+ /**
22
+ * If `true`, display the select clear icon.
23
+ *
24
+ * @default true
25
+ */
26
+ clearable?: boolean;
21
27
  /**
22
28
  * If `true`, the list element will be closed when value is selected.
23
29
  *
@@ -59,6 +65,8 @@ interface MultiAutocompleteOptions {
59
65
  * If `true`, display the select clear icon.
60
66
  *
61
67
  * @default true
68
+ *
69
+ * @deprecated Use `clearable` instead.
62
70
  */
63
71
  isClearable?: boolean;
64
72
  /**
@@ -172,13 +172,17 @@ var useAutocompleteOption = (props) => {
172
172
  id,
173
173
  children,
174
174
  closeOnSelect: customCloseOnSelect,
175
+ disabled,
176
+ focusable,
175
177
  icon: customIcon,
176
178
  isDisabled,
177
179
  isFocusable,
178
180
  value: optionValue,
179
181
  ...computedProps
180
182
  } = { ...optionProps, ...props };
181
- const trulyDisabled = !!isDisabled && !isFocusable;
183
+ disabled != null ? disabled : disabled = isDisabled;
184
+ focusable != null ? focusable : focusable = isFocusable;
185
+ const trulyDisabled = !!disabled && !focusable;
182
186
  const { descendants, index, register } = useAutocompleteDescendant({
183
187
  disabled: trulyDisabled
184
188
  });
@@ -204,7 +208,7 @@ var useAutocompleteOption = (props) => {
204
208
  const onClick = (0, import_react2.useCallback)(
205
209
  (ev) => {
206
210
  ev.stopPropagation();
207
- if (isDisabled || !isTargetOption(ev.currentTarget)) {
211
+ if (disabled || !isTargetOption(ev.currentTarget)) {
208
212
  if (inputRef.current) inputRef.current.focus();
209
213
  return;
210
214
  }
@@ -218,7 +222,7 @@ var useAutocompleteOption = (props) => {
218
222
  isDuplicated,
219
223
  onFocusNext,
220
224
  omitSelectedValues,
221
- isDisabled,
225
+ disabled,
222
226
  optionValue,
223
227
  setFocusedIndex,
224
228
  index,
@@ -250,10 +254,10 @@ var useAutocompleteOption = (props) => {
250
254
  ...props2,
251
255
  id,
252
256
  style: isHidden ? style : void 0,
253
- "aria-disabled": (0, import_utils3.ariaAttr)(isDisabled),
257
+ "aria-disabled": (0, import_utils3.ariaAttr)(disabled),
254
258
  "aria-hidden": (0, import_utils3.ariaAttr)(isHidden),
255
259
  "aria-selected": isSelected,
256
- "data-disabled": (0, import_utils3.dataAttr)(isDisabled),
260
+ "data-disabled": (0, import_utils3.dataAttr)(disabled),
257
261
  "data-duplicated": (0, import_utils3.dataAttr)(isDuplicated),
258
262
  "data-focus": (0, import_utils3.dataAttr)(isFocused),
259
263
  "data-target": (0, import_utils3.dataAttr)(true),
@@ -267,7 +271,7 @@ var useAutocompleteOption = (props) => {
267
271
  isDuplicated,
268
272
  optionValue,
269
273
  computedProps,
270
- isDisabled,
274
+ disabled,
271
275
  isFocused,
272
276
  isSelected,
273
277
  isTarget,
@@ -450,9 +454,9 @@ var import_utils7 = require("@yamada-ui/utils");
450
454
  var import_utils6 = require("@yamada-ui/utils");
451
455
  var import_react3 = require("react");
452
456
  var useAutocompleteList = () => {
453
- const { focusedIndex, isOpen, listRef, rebirthOptions, value } = useAutocompleteContext();
457
+ const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
454
458
  const descendants = useAutocompleteDescendantsContext();
455
- const uuid = (0, import_react3.useId)();
459
+ const listRef = (0, import_react3.useRef)(null);
456
460
  const beforeFocusedIndex = (0, import_react3.useRef)(-1);
457
461
  const selectedValue = descendants.value(focusedIndex);
458
462
  const isMulti = (0, import_utils6.isArray)(value);
@@ -488,21 +492,31 @@ var useAutocompleteList = () => {
488
492
  (0, import_utils6.useUpdateEffect)(() => {
489
493
  if (!isOpen) beforeFocusedIndex.current = -1;
490
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
+ );
491
508
  const getListProps = (0, import_react3.useCallback)(
492
- ({ id, ...props } = {}, ref = null) => ({
493
- id: id != null ? id : uuid,
509
+ (props = {}, ref = null) => ({
494
510
  ref: (0, import_utils6.mergeRefs)(listRef, ref),
495
- "aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
496
511
  position: "relative",
497
- role: "listbox",
498
512
  tabIndex: -1,
499
513
  ...props
500
514
  }),
501
- [listRef, uuid, isMulti]
515
+ [listRef]
502
516
  );
503
517
  return {
504
- getListProps,
505
- onAnimationComplete
518
+ getContainerProps,
519
+ getListProps
506
520
  };
507
521
  };
508
522
 
@@ -525,7 +539,7 @@ var AutocompleteList = (0, import_core4.forwardRef)(
525
539
  }, ref) => {
526
540
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
527
541
  const { styles } = useAutocompleteContext();
528
- const { getListProps, onAnimationComplete } = useAutocompleteList();
542
+ const { getContainerProps, getListProps } = useAutocompleteList();
529
543
  width != null ? width : width = w;
530
544
  width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
531
545
  minWidth != null ? minWidth : minWidth = minW;
@@ -535,16 +549,13 @@ var AutocompleteList = (0, import_core4.forwardRef)(
535
549
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
536
550
  import_popover.PopoverContent,
537
551
  {
552
+ as: "div",
538
553
  className: "ui-autocomplete__popover",
539
554
  maxWidth,
540
555
  minWidth,
541
556
  width,
542
557
  __css: { ...styles.content, maxWidth, minWidth, width },
543
- ...contentProps,
544
- onAnimationComplete: (0, import_utils7.handlerAll)(
545
- contentProps == null ? void 0 : contentProps.onAnimationComplete,
546
- onAnimationComplete
547
- ),
558
+ ...getContainerProps(contentProps),
548
559
  children: [
549
560
  header ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
550
561
  import_core4.ui.header,
@@ -884,8 +895,8 @@ var defaultFormat = (value) => {
884
895
  var flattenItems = (items) => {
885
896
  const filterItems = (items2) => items2.map((item) => {
886
897
  var _a;
887
- const { isDisabled, isFocusable } = item;
888
- const trulyDisabled = !!isDisabled && !isFocusable;
898
+ const { disabled, focusable } = item;
899
+ const trulyDisabled = !!disabled && !focusable;
889
900
  if (trulyDisabled) return;
890
901
  if ("items" in item) {
891
902
  return filterItems((_a = item.items) != null ? _a : []);
@@ -896,6 +907,7 @@ var flattenItems = (items) => {
896
907
  return filterItems(items).flat(Infinity);
897
908
  };
898
909
  var useAutocomplete = (props) => {
910
+ var _a;
899
911
  const {
900
912
  allowCreate = false,
901
913
  allowFree = false,
@@ -939,16 +951,8 @@ var useAutocomplete = (props) => {
939
951
  onSearch: onSearchProp,
940
952
  ...rest
941
953
  } = (0, import_form_control.useFormControlProps)(props);
942
- const {
943
- "aria-readonly": _ariaReadonly,
944
- onFocus: onFocusProp,
945
- ...formControlProps
946
- } = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
947
- const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
948
- const { id } = rest;
949
954
  const descendants = useAutocompleteDescendants();
950
955
  const containerRef = (0, import_react5.useRef)(null);
951
- const listRef = (0, import_react5.useRef)(null);
952
956
  const inputRef = (0, import_react5.useRef)(null);
953
957
  const timeoutIds = (0, import_react5.useRef)(/* @__PURE__ */ new Set([]));
954
958
  const isComposition = (0, import_react5.useRef)(false);
@@ -974,6 +978,12 @@ var useAutocomplete = (props) => {
974
978
  onClose: onCloseProp,
975
979
  onOpen: onOpenProp
976
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);
977
987
  const isFocused = focusedIndex > -1;
978
988
  const isCreate = focusedIndex === -2 && allowCreate;
979
989
  const isMulti = (0, import_utils11.isArray)(value);
@@ -992,14 +1002,15 @@ var useAutocomplete = (props) => {
992
1002
  }
993
1003
  const selectedValues = descendants.enabledValues(
994
1004
  ({ node }) => {
995
- var _a;
996
- return isMulti && value.includes((_a = node.dataset.value) != null ? _a : "");
1005
+ var _a2;
1006
+ return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
997
1007
  }
998
1008
  );
999
1009
  const selectedIndexes = selectedValues.map(({ index }) => index);
1000
1010
  const enabledValues = descendants.enabledValues(
1001
1011
  ({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
1002
1012
  );
1013
+ const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1003
1014
  const validChildren = (0, import_utils11.getValidChildren)(children);
1004
1015
  const computedChildren = (0, import_react5.useMemo)(
1005
1016
  () => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
@@ -1029,8 +1040,8 @@ var useAutocomplete = (props) => {
1029
1040
  if (inputRef.current) inputRef.current.focus();
1030
1041
  }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
1031
1042
  const onFocusFirst = (0, import_react5.useCallback)(() => {
1032
- const id2 = setTimeout(() => {
1033
- var _a;
1043
+ const id = setTimeout(() => {
1044
+ var _a2;
1034
1045
  if (isEmpty || isAllSelected) return;
1035
1046
  const first = descendants.enabledFirstValue(
1036
1047
  ({ node }) => "target" in node.dataset
@@ -1041,13 +1052,13 @@ var useAutocomplete = (props) => {
1041
1052
  } else {
1042
1053
  if (selectedIndexes.includes(first.index)) {
1043
1054
  const enabledFirst = enabledValues[0];
1044
- setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
1055
+ setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
1045
1056
  } else {
1046
1057
  setFocusedIndex(first.index);
1047
1058
  }
1048
1059
  }
1049
1060
  });
1050
- timeoutIds.current.add(id2);
1061
+ timeoutIds.current.add(id);
1051
1062
  }, [
1052
1063
  descendants,
1053
1064
  enabledValues,
@@ -1058,8 +1069,8 @@ var useAutocomplete = (props) => {
1058
1069
  selectedIndexes
1059
1070
  ]);
1060
1071
  const onFocusLast = (0, import_react5.useCallback)(() => {
1061
- const id2 = setTimeout(() => {
1062
- var _a;
1072
+ const id = setTimeout(() => {
1073
+ var _a2;
1063
1074
  if (isEmpty || isAllSelected) return;
1064
1075
  const last = descendants.enabledLastValue(
1065
1076
  ({ node }) => "target" in node.dataset
@@ -1070,13 +1081,13 @@ var useAutocomplete = (props) => {
1070
1081
  } else {
1071
1082
  if (selectedIndexes.includes(last.index)) {
1072
1083
  const enabledLast = enabledValues.reverse()[0];
1073
- setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
1084
+ setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
1074
1085
  } else {
1075
1086
  setFocusedIndex(last.index);
1076
1087
  }
1077
1088
  }
1078
1089
  });
1079
- timeoutIds.current.add(id2);
1090
+ timeoutIds.current.add(id);
1080
1091
  }, [
1081
1092
  descendants,
1082
1093
  enabledValues,
@@ -1087,22 +1098,22 @@ var useAutocomplete = (props) => {
1087
1098
  selectedIndexes
1088
1099
  ]);
1089
1100
  const onFocusSelected = (0, import_react5.useCallback)(() => {
1090
- const id2 = setTimeout(() => {
1101
+ const id = setTimeout(() => {
1091
1102
  const values = descendants.enabledValues();
1092
1103
  const selected = values.find(
1093
1104
  ({ node }) => {
1094
- var _a;
1095
- 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 : "");
1096
1107
  }
1097
1108
  );
1098
1109
  if (selected) setFocusedIndex(selected.index);
1099
1110
  });
1100
- timeoutIds.current.add(id2);
1111
+ timeoutIds.current.add(id);
1101
1112
  }, [descendants, isMulti, value]);
1102
1113
  const onFocusNext = (0, import_react5.useCallback)(
1103
1114
  (index = focusedIndex) => {
1104
- const id2 = setTimeout(() => {
1105
- var _a, _b;
1115
+ const id = setTimeout(() => {
1116
+ var _a2, _b;
1106
1117
  const next = descendants.enabledNextValue(
1107
1118
  index,
1108
1119
  ({ node }) => "target" in node.dataset
@@ -1112,14 +1123,14 @@ var useAutocomplete = (props) => {
1112
1123
  setFocusedIndex(next.index);
1113
1124
  } else {
1114
1125
  if (selectedIndexes.includes(next.index)) {
1115
- 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];
1116
1127
  setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
1117
1128
  } else {
1118
1129
  setFocusedIndex(next.index);
1119
1130
  }
1120
1131
  }
1121
1132
  });
1122
- timeoutIds.current.add(id2);
1133
+ timeoutIds.current.add(id);
1123
1134
  },
1124
1135
  [
1125
1136
  descendants,
@@ -1132,8 +1143,8 @@ var useAutocomplete = (props) => {
1132
1143
  );
1133
1144
  const onFocusPrev = (0, import_react5.useCallback)(
1134
1145
  (index = focusedIndex) => {
1135
- const id2 = setTimeout(() => {
1136
- var _a, _b;
1146
+ const id = setTimeout(() => {
1147
+ var _a2, _b;
1137
1148
  const prev = descendants.enabledPrevValue(
1138
1149
  index,
1139
1150
  ({ node }) => "target" in node.dataset
@@ -1143,14 +1154,14 @@ var useAutocomplete = (props) => {
1143
1154
  setFocusedIndex(prev.index);
1144
1155
  } else {
1145
1156
  if (selectedIndexes.includes(prev.index)) {
1146
- 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];
1147
1158
  setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
1148
1159
  } else {
1149
1160
  setFocusedIndex(prev.index);
1150
1161
  }
1151
1162
  }
1152
1163
  });
1153
- timeoutIds.current.add(id2);
1164
+ timeoutIds.current.add(id);
1154
1165
  },
1155
1166
  [
1156
1167
  descendants,
@@ -1169,8 +1180,8 @@ var useAutocomplete = (props) => {
1169
1180
  let isHit2 = false;
1170
1181
  let isFocused2 = false;
1171
1182
  values.forEach(({ index, node }) => {
1172
- var _a;
1173
- if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
1183
+ var _a2;
1184
+ if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
1174
1185
  isHit2 = true;
1175
1186
  const isDisabled = "disabled" in node.dataset;
1176
1187
  node.dataset.target = "";
@@ -1203,8 +1214,8 @@ var useAutocomplete = (props) => {
1203
1214
  if (!values.length) return;
1204
1215
  const resolvedValues = (0, import_utils11.isArray)(newValue) ? newValue : [newValue];
1205
1216
  const selectedLabel = resolvedValues.map((value2) => {
1206
- var _a, _b;
1207
- 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 : {};
1208
1219
  if (node) {
1209
1220
  const { textContent } = (_b = Array.from(node.children).find(
1210
1221
  (child) => child.getAttribute("data-label") !== null
@@ -1241,9 +1252,9 @@ var useAutocomplete = (props) => {
1241
1252
  [isMulti, rebirthOptions, setValue]
1242
1253
  );
1243
1254
  const onSelect = (0, import_react5.useCallback)(() => {
1244
- var _a, _b;
1255
+ var _a2, _b;
1245
1256
  let enabledValue = descendants.value(focusedIndex);
1246
- 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 : {}))
1247
1258
  enabledValue = void 0;
1248
1259
  if (!enabledValue) return;
1249
1260
  const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
@@ -1281,8 +1292,7 @@ var useAutocomplete = (props) => {
1281
1292
  isComposition.current = false;
1282
1293
  }, []);
1283
1294
  const onCreate = (0, import_react5.useCallback)(() => {
1284
- var _a, _b;
1285
- if (!listRef.current) return;
1295
+ var _a2, _b;
1286
1296
  const newItem = { label: inputValue, value: inputValue };
1287
1297
  let newItems = [];
1288
1298
  if (resolvedItems) newItems = [...resolvedItems];
@@ -1297,7 +1307,7 @@ var useAutocomplete = (props) => {
1297
1307
  const targetItem = newItems[i];
1298
1308
  if (i !== -1 && targetItem && "items" in targetItem) {
1299
1309
  if (secondInsertPositionItem === "first") {
1300
- targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
1310
+ targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
1301
1311
  } else {
1302
1312
  targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
1303
1313
  }
@@ -1454,7 +1464,7 @@ var useAutocomplete = (props) => {
1454
1464
  setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
1455
1465
  }, [items]);
1456
1466
  (0, import_utils11.useUnmountEffect)(() => {
1457
- timeoutIds.current.forEach((id2) => clearTimeout(id2));
1467
+ timeoutIds.current.forEach((id) => clearTimeout(id));
1458
1468
  timeoutIds.current.clear();
1459
1469
  });
1460
1470
  (0, import_use_outside_click.useOutsideClick)({
@@ -1525,6 +1535,10 @@ var useAutocomplete = (props) => {
1525
1535
  const getFieldProps = (0, import_react5.useCallback)(
1526
1536
  (props2 = {}, ref = null) => ({
1527
1537
  ref,
1538
+ "aria-activedescendant": activedescendantId,
1539
+ "aria-autocomplete": "list",
1540
+ "aria-haspopup": "listbox",
1541
+ role: "combobox",
1528
1542
  tabIndex: -1,
1529
1543
  ...props2,
1530
1544
  ...formControlProps,
@@ -1534,6 +1548,7 @@ var useAutocomplete = (props) => {
1534
1548
  onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
1535
1549
  }),
1536
1550
  [
1551
+ activedescendantId,
1537
1552
  formControlProps,
1538
1553
  placeholder,
1539
1554
  isOpen,
@@ -1544,7 +1559,6 @@ var useAutocomplete = (props) => {
1544
1559
  ]
1545
1560
  );
1546
1561
  return {
1547
- id,
1548
1562
  allowCreate,
1549
1563
  allowFree,
1550
1564
  children: children != null ? children : computedChildren,
@@ -1559,7 +1573,6 @@ var useAutocomplete = (props) => {
1559
1573
  isHit,
1560
1574
  isOpen,
1561
1575
  label,
1562
- listRef,
1563
1576
  omitSelectedValues,
1564
1577
  pickOptions,
1565
1578
  rebirthOptions,
@@ -1587,23 +1600,15 @@ var useAutocomplete = (props) => {
1587
1600
  };
1588
1601
  };
1589
1602
  var useAutocompleteInput = () => {
1590
- var _a, _b;
1591
1603
  const {
1592
- id,
1593
- focusedIndex,
1594
1604
  inputRef,
1595
1605
  isAllSelected,
1596
- isOpen,
1597
- listRef,
1598
1606
  formControlProps,
1599
1607
  inputProps,
1600
1608
  onCompositionEnd,
1601
1609
  onCompositionStart,
1602
1610
  onSearch
1603
1611
  } = useAutocompleteContext();
1604
- const descendants = useAutocompleteDescendantsContext();
1605
- const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1606
- const listId = (_b = listRef.current) == null ? void 0 : _b.id;
1607
1612
  (0, import_utils11.useUpdateEffect)(() => {
1608
1613
  if (isAllSelected && inputRef.current) inputRef.current.blur();
1609
1614
  }, [isAllSelected]);
@@ -1612,19 +1617,12 @@ var useAutocompleteInput = () => {
1612
1617
  return {
1613
1618
  ref: (0, import_utils11.mergeRefs)(inputRef, ref),
1614
1619
  ...formControlProps,
1615
- "aria-activedescendant": activedescendantId,
1616
- "aria-autocomplete": "list",
1617
- "aria-controls": listId,
1618
- "aria-expanded": isOpen,
1619
- "aria-haspopup": "listbox",
1620
1620
  autoCapitalize: "none",
1621
1621
  autoComplete: "off",
1622
- role: "combobox",
1623
1622
  spellCheck: "false",
1624
1623
  tabIndex: isAllSelected ? -1 : 0,
1625
1624
  ...inputProps,
1626
1625
  ...props,
1627
- id,
1628
1626
  cursor: formControlProps.readOnly ? "default" : "text",
1629
1627
  pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1630
1628
  onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
@@ -1641,13 +1639,9 @@ var useAutocompleteInput = () => {
1641
1639
  };
1642
1640
  },
1643
1641
  [
1644
- listId,
1645
- activedescendantId,
1646
- isOpen,
1647
1642
  inputProps,
1648
1643
  inputRef,
1649
1644
  formControlProps,
1650
- id,
1651
1645
  isAllSelected,
1652
1646
  onSearch,
1653
1647
  onCompositionStart,
@@ -1669,6 +1663,7 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
1669
1663
  );
1670
1664
  let {
1671
1665
  className,
1666
+ clearable,
1672
1667
  closeOnSelect = false,
1673
1668
  color,
1674
1669
  component,
@@ -1715,6 +1710,7 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
1715
1710
  });
1716
1711
  h != null ? h : h = height;
1717
1712
  minH != null ? minH : minH = minHeight;
1713
+ clearable != null ? clearable : clearable = isClearable;
1718
1714
  const css = {
1719
1715
  color,
1720
1716
  h: "fit-content",
@@ -1759,7 +1755,7 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
1759
1755
  ...getFieldProps(fieldProps, ref)
1760
1756
  }
1761
1757
  ),
1762
- isClearable && value.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1758
+ clearable && value.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1763
1759
  AutocompleteClearIcon,
1764
1760
  {
1765
1761
  ...clearIconProps,