@yamada-ui/autocomplete 1.6.5-dev-20241119122307 → 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
@@ -1,15 +1,14 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteOptionGroup
4
- } from "./chunk-PU6HFINM.mjs";
4
+ } from "./chunk-ABCTEZN5.mjs";
5
5
  import {
6
6
  AutocompleteOption
7
- } from "./chunk-7GVG5MVF.mjs";
7
+ } from "./chunk-PWV7X7G6.mjs";
8
8
  import {
9
9
  useAutocompleteContext,
10
- useAutocompleteDescendants,
11
- useAutocompleteDescendantsContext
12
- } from "./chunk-ZNO5RUVT.mjs";
10
+ useAutocompleteDescendants
11
+ } from "./chunk-TP5VZFO3.mjs";
13
12
 
14
13
  // src/use-autocomplete.tsx
15
14
  import { layoutStyleProperties } from "@yamada-ui/core";
@@ -154,6 +153,7 @@ var flattenItems = (items) => {
154
153
  return filterItems(items).flat(Infinity);
155
154
  };
156
155
  var useAutocomplete = (props) => {
156
+ var _a;
157
157
  const {
158
158
  allowCreate = false,
159
159
  allowFree = false,
@@ -197,16 +197,8 @@ var useAutocomplete = (props) => {
197
197
  onSearch: onSearchProp,
198
198
  ...rest
199
199
  } = useFormControlProps(props);
200
- const {
201
- "aria-readonly": _ariaReadonly,
202
- onFocus: onFocusProp,
203
- ...formControlProps
204
- } = pickObject(rest, formControlProperties);
205
- const [containerProps, inputProps] = splitObject(rest, layoutStyleProperties);
206
- const { id } = rest;
207
200
  const descendants = useAutocompleteDescendants();
208
201
  const containerRef = useRef(null);
209
- const listRef = useRef(null);
210
202
  const inputRef = useRef(null);
211
203
  const timeoutIds = useRef(/* @__PURE__ */ new Set([]));
212
204
  const isComposition = useRef(false);
@@ -232,6 +224,12 @@ var useAutocomplete = (props) => {
232
224
  onClose: onCloseProp,
233
225
  onOpen: onOpenProp
234
226
  });
227
+ const {
228
+ "aria-readonly": _ariaReadonly,
229
+ onFocus: onFocusProp,
230
+ ...formControlProps
231
+ } = pickObject(rest, formControlProperties);
232
+ const [containerProps, inputProps] = splitObject(rest, layoutStyleProperties);
235
233
  const isFocused = focusedIndex > -1;
236
234
  const isCreate = focusedIndex === -2 && allowCreate;
237
235
  const isMulti = isArray(value);
@@ -250,14 +248,15 @@ var useAutocomplete = (props) => {
250
248
  }
251
249
  const selectedValues = descendants.enabledValues(
252
250
  ({ node }) => {
253
- var _a;
254
- return isMulti && value.includes((_a = node.dataset.value) != null ? _a : "");
251
+ var _a2;
252
+ return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
255
253
  }
256
254
  );
257
255
  const selectedIndexes = selectedValues.map(({ index }) => index);
258
256
  const enabledValues = descendants.enabledValues(
259
257
  ({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
260
258
  );
259
+ const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
261
260
  const validChildren = getValidChildren(children);
262
261
  const computedChildren = useMemo(
263
262
  () => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
@@ -287,8 +286,8 @@ var useAutocomplete = (props) => {
287
286
  if (inputRef.current) inputRef.current.focus();
288
287
  }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
289
288
  const onFocusFirst = useCallback(() => {
290
- const id2 = setTimeout(() => {
291
- var _a;
289
+ const id = setTimeout(() => {
290
+ var _a2;
292
291
  if (isEmpty || isAllSelected) return;
293
292
  const first = descendants.enabledFirstValue(
294
293
  ({ node }) => "target" in node.dataset
@@ -299,13 +298,13 @@ var useAutocomplete = (props) => {
299
298
  } else {
300
299
  if (selectedIndexes.includes(first.index)) {
301
300
  const enabledFirst = enabledValues[0];
302
- setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
301
+ setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
303
302
  } else {
304
303
  setFocusedIndex(first.index);
305
304
  }
306
305
  }
307
306
  });
308
- timeoutIds.current.add(id2);
307
+ timeoutIds.current.add(id);
309
308
  }, [
310
309
  descendants,
311
310
  enabledValues,
@@ -316,8 +315,8 @@ var useAutocomplete = (props) => {
316
315
  selectedIndexes
317
316
  ]);
318
317
  const onFocusLast = useCallback(() => {
319
- const id2 = setTimeout(() => {
320
- var _a;
318
+ const id = setTimeout(() => {
319
+ var _a2;
321
320
  if (isEmpty || isAllSelected) return;
322
321
  const last = descendants.enabledLastValue(
323
322
  ({ node }) => "target" in node.dataset
@@ -328,13 +327,13 @@ var useAutocomplete = (props) => {
328
327
  } else {
329
328
  if (selectedIndexes.includes(last.index)) {
330
329
  const enabledLast = enabledValues.reverse()[0];
331
- setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
330
+ setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
332
331
  } else {
333
332
  setFocusedIndex(last.index);
334
333
  }
335
334
  }
336
335
  });
337
- timeoutIds.current.add(id2);
336
+ timeoutIds.current.add(id);
338
337
  }, [
339
338
  descendants,
340
339
  enabledValues,
@@ -345,22 +344,22 @@ var useAutocomplete = (props) => {
345
344
  selectedIndexes
346
345
  ]);
347
346
  const onFocusSelected = useCallback(() => {
348
- const id2 = setTimeout(() => {
347
+ const id = setTimeout(() => {
349
348
  const values = descendants.enabledValues();
350
349
  const selected = values.find(
351
350
  ({ node }) => {
352
- var _a;
353
- return !isMulti ? node.dataset.value === value : value.includes((_a = node.dataset.value) != null ? _a : "");
351
+ var _a2;
352
+ return !isMulti ? node.dataset.value === value : value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
354
353
  }
355
354
  );
356
355
  if (selected) setFocusedIndex(selected.index);
357
356
  });
358
- timeoutIds.current.add(id2);
357
+ timeoutIds.current.add(id);
359
358
  }, [descendants, isMulti, value]);
360
359
  const onFocusNext = useCallback(
361
360
  (index = focusedIndex) => {
362
- const id2 = setTimeout(() => {
363
- var _a, _b;
361
+ const id = setTimeout(() => {
362
+ var _a2, _b;
364
363
  const next = descendants.enabledNextValue(
365
364
  index,
366
365
  ({ node }) => "target" in node.dataset
@@ -370,14 +369,14 @@ var useAutocomplete = (props) => {
370
369
  setFocusedIndex(next.index);
371
370
  } else {
372
371
  if (selectedIndexes.includes(next.index)) {
373
- const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
372
+ const enabledNext = (_a2 = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a2 : enabledValues[0];
374
373
  setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
375
374
  } else {
376
375
  setFocusedIndex(next.index);
377
376
  }
378
377
  }
379
378
  });
380
- timeoutIds.current.add(id2);
379
+ timeoutIds.current.add(id);
381
380
  },
382
381
  [
383
382
  descendants,
@@ -390,8 +389,8 @@ var useAutocomplete = (props) => {
390
389
  );
391
390
  const onFocusPrev = useCallback(
392
391
  (index = focusedIndex) => {
393
- const id2 = setTimeout(() => {
394
- var _a, _b;
392
+ const id = setTimeout(() => {
393
+ var _a2, _b;
395
394
  const prev = descendants.enabledPrevValue(
396
395
  index,
397
396
  ({ node }) => "target" in node.dataset
@@ -401,14 +400,14 @@ var useAutocomplete = (props) => {
401
400
  setFocusedIndex(prev.index);
402
401
  } else {
403
402
  if (selectedIndexes.includes(prev.index)) {
404
- const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
403
+ const enabledPrev = (_a2 = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a2 : enabledValues[0];
405
404
  setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
406
405
  } else {
407
406
  setFocusedIndex(prev.index);
408
407
  }
409
408
  }
410
409
  });
411
- timeoutIds.current.add(id2);
410
+ timeoutIds.current.add(id);
412
411
  },
413
412
  [
414
413
  descendants,
@@ -427,8 +426,8 @@ var useAutocomplete = (props) => {
427
426
  let isHit2 = false;
428
427
  let isFocused2 = false;
429
428
  values.forEach(({ index, node }) => {
430
- var _a;
431
- if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
429
+ var _a2;
430
+ if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
432
431
  isHit2 = true;
433
432
  const isDisabled = "disabled" in node.dataset;
434
433
  node.dataset.target = "";
@@ -461,8 +460,8 @@ var useAutocomplete = (props) => {
461
460
  if (!values.length) return;
462
461
  const resolvedValues = isArray(newValue) ? newValue : [newValue];
463
462
  const selectedLabel = resolvedValues.map((value2) => {
464
- var _a, _b;
465
- const { node } = (_a = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a : {};
463
+ var _a2, _b;
464
+ const { node } = (_a2 = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a2 : {};
466
465
  if (node) {
467
466
  const { textContent } = (_b = Array.from(node.children).find(
468
467
  (child) => child.getAttribute("data-label") !== null
@@ -499,9 +498,9 @@ var useAutocomplete = (props) => {
499
498
  [isMulti, rebirthOptions, setValue]
500
499
  );
501
500
  const onSelect = useCallback(() => {
502
- var _a, _b;
501
+ var _a2, _b;
503
502
  let enabledValue = descendants.value(focusedIndex);
504
- if ("disabled" in ((_a = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a : {}))
503
+ if ("disabled" in ((_a2 = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a2 : {}))
505
504
  enabledValue = void 0;
506
505
  if (!enabledValue) return;
507
506
  const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
@@ -539,8 +538,7 @@ var useAutocomplete = (props) => {
539
538
  isComposition.current = false;
540
539
  }, []);
541
540
  const onCreate = useCallback(() => {
542
- var _a, _b;
543
- if (!listRef.current) return;
541
+ var _a2, _b;
544
542
  const newItem = { label: inputValue, value: inputValue };
545
543
  let newItems = [];
546
544
  if (resolvedItems) newItems = [...resolvedItems];
@@ -555,7 +553,7 @@ var useAutocomplete = (props) => {
555
553
  const targetItem = newItems[i];
556
554
  if (i !== -1 && targetItem && "items" in targetItem) {
557
555
  if (secondInsertPositionItem === "first") {
558
- targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
556
+ targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
559
557
  } else {
560
558
  targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
561
559
  }
@@ -712,7 +710,7 @@ var useAutocomplete = (props) => {
712
710
  setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
713
711
  }, [items]);
714
712
  useUnmountEffect(() => {
715
- timeoutIds.current.forEach((id2) => clearTimeout(id2));
713
+ timeoutIds.current.forEach((id) => clearTimeout(id));
716
714
  timeoutIds.current.clear();
717
715
  });
718
716
  useOutsideClick({
@@ -783,6 +781,10 @@ var useAutocomplete = (props) => {
783
781
  const getFieldProps = useCallback(
784
782
  (props2 = {}, ref = null) => ({
785
783
  ref,
784
+ "aria-activedescendant": activedescendantId,
785
+ "aria-autocomplete": "list",
786
+ "aria-haspopup": "listbox",
787
+ role: "combobox",
786
788
  tabIndex: -1,
787
789
  ...props2,
788
790
  ...formControlProps,
@@ -792,6 +794,7 @@ var useAutocomplete = (props) => {
792
794
  onKeyDown: handlerAll(props2.onKeyDown, onKeyDownProp, onKeyDown)
793
795
  }),
794
796
  [
797
+ activedescendantId,
795
798
  formControlProps,
796
799
  placeholder,
797
800
  isOpen,
@@ -802,7 +805,6 @@ var useAutocomplete = (props) => {
802
805
  ]
803
806
  );
804
807
  return {
805
- id,
806
808
  allowCreate,
807
809
  allowFree,
808
810
  children: children != null ? children : computedChildren,
@@ -817,7 +819,6 @@ var useAutocomplete = (props) => {
817
819
  isHit,
818
820
  isOpen,
819
821
  label,
820
- listRef,
821
822
  omitSelectedValues,
822
823
  pickOptions,
823
824
  rebirthOptions,
@@ -845,23 +846,15 @@ var useAutocomplete = (props) => {
845
846
  };
846
847
  };
847
848
  var useAutocompleteInput = () => {
848
- var _a, _b;
849
849
  const {
850
- id,
851
- focusedIndex,
852
850
  inputRef,
853
851
  isAllSelected,
854
- isOpen,
855
- listRef,
856
852
  formControlProps,
857
853
  inputProps,
858
854
  onCompositionEnd,
859
855
  onCompositionStart,
860
856
  onSearch
861
857
  } = useAutocompleteContext();
862
- const descendants = useAutocompleteDescendantsContext();
863
- const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
864
- const listId = (_b = listRef.current) == null ? void 0 : _b.id;
865
858
  useUpdateEffect(() => {
866
859
  if (isAllSelected && inputRef.current) inputRef.current.blur();
867
860
  }, [isAllSelected]);
@@ -870,19 +863,12 @@ var useAutocompleteInput = () => {
870
863
  return {
871
864
  ref: mergeRefs(inputRef, ref),
872
865
  ...formControlProps,
873
- "aria-activedescendant": activedescendantId,
874
- "aria-autocomplete": "list",
875
- "aria-controls": listId,
876
- "aria-expanded": isOpen,
877
- "aria-haspopup": "listbox",
878
866
  autoCapitalize: "none",
879
867
  autoComplete: "off",
880
- role: "combobox",
881
868
  spellCheck: "false",
882
869
  tabIndex: isAllSelected ? -1 : 0,
883
870
  ...inputProps,
884
871
  ...props,
885
- id,
886
872
  cursor: formControlProps.readOnly ? "default" : "text",
887
873
  pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
888
874
  onChange: handlerAll(props.onChange, onSearch),
@@ -899,13 +885,9 @@ var useAutocompleteInput = () => {
899
885
  };
900
886
  },
901
887
  [
902
- listId,
903
- activedescendantId,
904
- isOpen,
905
888
  inputProps,
906
889
  inputRef,
907
890
  formControlProps,
908
- id,
909
891
  isAllSelected,
910
892
  onSearch,
911
893
  onCompositionStart,
@@ -921,4 +903,4 @@ export {
921
903
  useAutocomplete,
922
904
  useAutocompleteInput
923
905
  };
924
- //# sourceMappingURL=chunk-YWUT56L3.mjs.map
906
+ //# sourceMappingURL=chunk-ZR77IT3O.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-autocomplete.tsx"],"sourcesContent":["import type { HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { ComboBoxProps, PopoverProps } from \"@yamada-ui/popover\"\nimport type { Union } from \"@yamada-ui/utils\"\nimport type {\n ChangeEvent,\n DOMAttributes,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactElement,\n} from \"react\"\nimport type { AutocompleteOptionProps } from \"./autocomplete-option\"\nimport type { AutocompleteOptionGroupProps } from \"./autocomplete-option-group\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useDisclosure } from \"@yamada-ui/use-disclosure\"\nimport { useOutsideClick } from \"@yamada-ui/use-outside-click\"\nimport {\n dataAttr,\n funcAll,\n getEventRelatedTarget,\n getValidChildren,\n handlerAll,\n isArray,\n isContains,\n isUndefined,\n mergeRefs,\n pickObject,\n splitObject,\n useSafeLayoutEffect,\n useUnmountEffect,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendants,\n} from \"./autocomplete-context\"\nimport { AutocompleteOption } from \"./autocomplete-option\"\nimport { AutocompleteOptionGroup } from \"./autocomplete-option-group\"\n\ninterface AutocompleteItemWithValue extends AutocompleteOptionProps {\n label?: string\n value?: string\n}\n\ninterface AutocompleteItemWithItems\n extends AutocompleteOptionGroupProps,\n Pick<\n AutocompleteOptionProps,\n \"disabled\" | \"focusable\" | \"isDisabled\" | \"isFocusable\"\n > {\n items?: AutocompleteItemWithValue[]\n}\n\nexport type AutocompleteItem =\n | AutocompleteItemWithItems\n | AutocompleteItemWithValue\n\ntype MaybeValue = string | string[]\n\nconst kanaMap: { [key: string]: string } = {\n \"。\": \"。\",\n \"「\": \"「\",\n \"」\": \"」\",\n \"、\": \"、\",\n \"・\": \"・\",\n ヲ: \"ヲ\",\n ヺ: \"ヺ\",\n ァ: \"ァ\",\n ィ: \"ィ\",\n ゥ: \"ゥ\",\n ェ: \"ェ\",\n ォ: \"ォ\",\n ャ: \"ャ\",\n ュ: \"ュ\",\n ョ: \"ョ\",\n ッ: \"ッ\",\n ー: \"ー\",\n ア: \"ア\",\n イ: \"イ\",\n ウ: \"ウ\",\n ヴ: \"ヴ\",\n エ: \"エ\",\n オ: \"オ\",\n カ: \"カ\",\n ガ: \"ガ\",\n キ: \"キ\",\n ギ: \"ギ\",\n ク: \"ク\",\n グ: \"グ\",\n ケ: \"ケ\",\n ゲ: \"ゲ\",\n コ: \"コ\",\n ゴ: \"ゴ\",\n サ: \"サ\",\n ザ: \"ザ\",\n シ: \"シ\",\n ジ: \"ジ\",\n ス: \"ス\",\n ズ: \"ズ\",\n セ: \"セ\",\n ゼ: \"ゼ\",\n ソ: \"ソ\",\n ゾ: \"ゾ\",\n タ: \"タ\",\n ダ: \"ダ\",\n チ: \"チ\",\n ヂ: \"ヂ\",\n ツ: \"ツ\",\n ヅ: \"ヅ\",\n テ: \"テ\",\n デ: \"デ\",\n ト: \"ト\",\n ド: \"ド\",\n ナ: \"ナ\",\n ニ: \"ニ\",\n ヌ: \"ヌ\",\n ネ: \"ネ\",\n ノ: \"ノ\",\n ハ: \"ハ\",\n バ: \"バ\",\n パ: \"パ\",\n ヒ: \"ヒ\",\n ビ: \"ビ\",\n ピ: \"ピ\",\n フ: \"フ\",\n ブ: \"ブ\",\n プ: \"プ\",\n ヘ: \"ヘ\",\n ベ: \"ベ\",\n ペ: \"ペ\",\n ホ: \"ホ\",\n ボ: \"ボ\",\n ポ: \"ポ\",\n マ: \"マ\",\n ミ: \"ミ\",\n ム: \"ム\",\n メ: \"メ\",\n モ: \"モ\",\n ヤ: \"ヤ\",\n ユ: \"ユ\",\n ヨ: \"ヨ\",\n ラ: \"ラ\",\n リ: \"リ\",\n ル: \"ル\",\n レ: \"レ\",\n ロ: \"ロ\",\n ワ: \"ワ\",\n ヷ: \"ヷ\",\n ン: \"ン\",\n}\n\nconst defaultFormat = (value: string) => {\n value = value.replace(/[!-~]/g, (v) =>\n String.fromCharCode(v.charCodeAt(0) - 0xfee0),\n )\n\n const reg = new RegExp(\"(\" + Object.keys(kanaMap).join(\"|\") + \")\", \"g\")\n\n value = value\n .replace(reg, (v) => kanaMap[v]!)\n .replace(/゙/g, \"゛\")\n .replace(/゚/g, \"゜\")\n\n value = value.toUpperCase()\n\n return value\n}\n\nconst flattenItems = (\n items: AutocompleteItem[],\n): AutocompleteItemWithValue[] => {\n const filterItems = (\n items: AutocompleteItem[] | AutocompleteItemWithValue[],\n ): (AutocompleteItemWithValue | AutocompleteItemWithValue[])[] =>\n items\n .map((item) => {\n const { disabled, focusable } = item\n const trulyDisabled = !!disabled && !focusable\n\n if (trulyDisabled) return\n\n if (\"items\" in item) {\n return filterItems(item.items ?? [])\n } else {\n return item as AutocompleteItemWithValue\n }\n })\n .filter(Boolean) as (\n | AutocompleteItemWithValue\n | AutocompleteItemWithValue[]\n )[]\n\n return filterItems(items).flat(Infinity) as AutocompleteItemWithValue[]\n}\n\ninterface UseAutocompleteBaseProps<T extends MaybeValue = string>\n extends ComboBoxProps,\n FormControlOptions {\n /**\n * If `true`, enables the creation of autocomplete option.\n *\n * @default false\n */\n allowCreate?: boolean\n /**\n * If `true`, enables the free input.\n */\n allowFree?: boolean\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: T\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: string\n /**\n * Function to format text when search input.\n */\n format?: (value: string) => string\n /**\n * The position to be inserted when the autocomplete option is created.\n *\n * @default 'first'\n */\n insertPositionItem?: [string, \"first\" | \"last\"] | Union<\"first\" | \"last\">\n /**\n * If provided, generate options based on items.\n */\n items?: AutocompleteItem[]\n /**\n * The maximum selectable value.\n */\n maxSelectValues?: number\n /**\n * If `true`, the selected item(s) will be excluded from the list.\n *\n * @default false\n */\n omitSelectedValues?: boolean\n /**\n * The value of the autocomplete.\n */\n value?: T\n /**\n * Props for select option element.\n */\n optionProps?: Omit<AutocompleteOptionProps, \"children\" | \"value\">\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: T) => void\n /**\n * The callback invoked when autocomplete option created.\n */\n onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void\n /**\n * The callback invoked when search input.\n */\n onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void\n}\n\nexport interface UseAutocompleteProps<T extends MaybeValue = string>\n extends Omit<\n HTMLUIProps<\"input\">,\n | \"disabled\"\n | \"list\"\n | \"readOnly\"\n | \"required\"\n | \"size\"\n | keyof UseAutocompleteBaseProps\n >,\n UseAutocompleteBaseProps<T> {}\n\nexport const useAutocomplete = <T extends MaybeValue = string>(\n props: UseAutocompleteProps<T>,\n) => {\n const {\n allowCreate = false,\n allowFree = false,\n animation,\n boundary,\n children,\n closeDelay,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnSelect = true,\n defaultIsOpen,\n defaultValue,\n duration = 0.2,\n emptyMessage = \"No results found\",\n eventListeners,\n flip,\n format = defaultFormat,\n gutter,\n insertPositionItem = \"first\",\n isLazy,\n isOpen: isOpenProp,\n items,\n lazyBehavior,\n matchWidth = true,\n maxSelectValues,\n modifiers,\n offset,\n omitSelectedValues = false,\n openDelay,\n placeholder,\n placement = \"bottom-start\",\n preventOverflow,\n strategy,\n value: valueProp,\n optionProps,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onCreate: onCreateProp,\n onKeyDown: onKeyDownProp,\n onOpen: onOpenProp,\n onSearch: onSearchProp,\n ...rest\n } = useFormControlProps(props)\n const descendants = useAutocompleteDescendants()\n const containerRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const timeoutIds = useRef<Set<any>>(new Set([]))\n const isComposition = useRef<boolean>(false)\n const prevValue = useRef<T | undefined>(undefined)\n const [resolvedItems, setResolvedItems] = useState<\n AutocompleteItem[] | undefined\n >(items ? JSON.parse(JSON.stringify(items)) : undefined)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [label, setLabel] = useState<T | undefined>(undefined)\n const [inputValue, setInputValue] = useState<string>(\"\")\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [isAllSelected, setIsAllSelected] = useState<boolean>(false)\n const [isHit, setIsHit] = useState<boolean>(true)\n const {\n isOpen,\n onClose,\n onOpen: onInternalOpen,\n } = useDisclosure({\n defaultIsOpen,\n isOpen: isOpenProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const {\n \"aria-readonly\": _ariaReadonly,\n onFocus: onFocusProp,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const [containerProps, inputProps] = splitObject(rest, layoutStyleProperties)\n\n const isFocused = focusedIndex > -1\n const isCreate = focusedIndex === -2 && allowCreate\n const isMulti = isArray(value)\n const isEmptyValue = !isMulti ? !value : !value.length\n\n const [firstInsertPositionItem, secondInsertPositionItem] = useMemo(() => {\n if (isArray(insertPositionItem)) {\n return insertPositionItem\n } else {\n return [insertPositionItem, \"first\"]\n }\n }, [insertPositionItem])\n\n if (allowCreate && !isUndefined(children)) {\n console.warn(\n `${!isMulti ? \"Autocomplete\" : \"MultiAutocomplete\"}: ${\n !isMulti ? \"Autocomplete\" : \"MultiAutocomplete\"\n } internally prefers 'children'. If 'allowCreate' is true, it will not be reflected correctly. If want to reflect, please set 'items' in props.`,\n )\n }\n\n const selectedValues = descendants.enabledValues(\n ({ node }) => isMulti && value.includes(node.dataset.value ?? \"\"),\n )\n const selectedIndexes = selectedValues.map(({ index }) => index)\n const enabledValues = descendants.enabledValues(\n ({ index, node }) =>\n \"target\" in node.dataset && !selectedIndexes.includes(index),\n )\n const activedescendantId = descendants.value(focusedIndex)?.node.id\n const validChildren = getValidChildren(children)\n\n const computedChildren = useMemo(\n () =>\n resolvedItems\n ?.map((item, index) => {\n if (\"value\" in item) {\n const { label, value, ...props } = item\n\n return (\n <AutocompleteOption key={index} value={value} {...props}>\n {label}\n </AutocompleteOption>\n )\n } else if (\"items\" in item) {\n const { items = [], label, ...props } = item\n\n return (\n <AutocompleteOptionGroup\n key={index}\n label={label as string}\n {...props}\n >\n {items.map(({ label, value, ...props }, index) => (\n <AutocompleteOption key={index} value={value} {...props}>\n {label}\n </AutocompleteOption>\n ))}\n </AutocompleteOptionGroup>\n )\n }\n })\n .filter(Boolean) as ReactElement[] | undefined,\n [resolvedItems],\n )\n\n const isEmpty = !validChildren.length && !computedChildren?.length\n\n const onOpen = useCallback(() => {\n if (formControlProps.disabled || formControlProps.readOnly) return\n\n if (!allowCreate && (isEmpty || isAllSelected)) return\n\n onInternalOpen()\n\n if (inputRef.current) inputRef.current.focus()\n }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen])\n\n const onFocusFirst = useCallback(() => {\n const id = setTimeout(() => {\n if (isEmpty || isAllSelected) return\n\n const first = descendants.enabledFirstValue(\n ({ node }) => \"target\" in node.dataset,\n )\n\n if (!first) return\n\n if (!isMulti || !omitSelectedValues) {\n setFocusedIndex(first.index)\n } else {\n if (selectedIndexes.includes(first.index)) {\n const enabledFirst = enabledValues[0]\n\n setFocusedIndex(enabledFirst?.index ?? -1)\n } else {\n setFocusedIndex(first.index)\n }\n }\n })\n\n timeoutIds.current.add(id)\n }, [\n descendants,\n enabledValues,\n isAllSelected,\n isEmpty,\n isMulti,\n omitSelectedValues,\n selectedIndexes,\n ])\n\n const onFocusLast = useCallback(() => {\n const id = setTimeout(() => {\n if (isEmpty || isAllSelected) return\n\n const last = descendants.enabledLastValue(\n ({ node }) => \"target\" in node.dataset,\n )\n\n if (!last) return\n\n if (!isMulti || !omitSelectedValues) {\n setFocusedIndex(last.index)\n } else {\n if (selectedIndexes.includes(last.index)) {\n const enabledLast = enabledValues.reverse()[0]\n\n setFocusedIndex(enabledLast?.index ?? -1)\n } else {\n setFocusedIndex(last.index)\n }\n }\n })\n\n timeoutIds.current.add(id)\n }, [\n descendants,\n enabledValues,\n isAllSelected,\n isEmpty,\n isMulti,\n omitSelectedValues,\n selectedIndexes,\n ])\n\n const onFocusSelected = useCallback(() => {\n const id = setTimeout(() => {\n const values = descendants.enabledValues()\n\n const selected = values.find(({ node }) =>\n !isMulti\n ? node.dataset.value === value\n : value.includes(node.dataset.value ?? \"\"),\n )\n\n if (selected) setFocusedIndex(selected.index)\n })\n\n timeoutIds.current.add(id)\n }, [descendants, isMulti, value])\n\n const onFocusNext = useCallback(\n (index: number = focusedIndex) => {\n const id = setTimeout(() => {\n const next = descendants.enabledNextValue(\n index,\n ({ node }) => \"target\" in node.dataset,\n )\n\n if (!next) return\n\n if (!isMulti || !omitSelectedValues) {\n setFocusedIndex(next.index)\n } else {\n if (selectedIndexes.includes(next.index)) {\n const enabledNext =\n enabledValues.find(({ index }) => next.index < index) ??\n enabledValues[0]\n\n setFocusedIndex(enabledNext?.index ?? -1)\n } else {\n setFocusedIndex(next.index)\n }\n }\n })\n\n timeoutIds.current.add(id)\n },\n [\n descendants,\n enabledValues,\n focusedIndex,\n isMulti,\n omitSelectedValues,\n selectedIndexes,\n ],\n )\n\n const onFocusPrev = useCallback(\n (index: number = focusedIndex) => {\n const id = setTimeout(() => {\n const prev = descendants.enabledPrevValue(\n index,\n ({ node }) => \"target\" in node.dataset,\n )\n\n if (!prev) return\n\n if (!isMulti || !omitSelectedValues) {\n setFocusedIndex(prev.index)\n } else {\n if (selectedIndexes.includes(prev.index)) {\n const enabledPrev =\n enabledValues.reverse().find(({ index }) => index < prev.index) ??\n enabledValues[0]\n\n setFocusedIndex(enabledPrev?.index ?? -1)\n } else {\n setFocusedIndex(prev.index)\n }\n }\n })\n\n timeoutIds.current.add(id)\n },\n [\n descendants,\n enabledValues,\n focusedIndex,\n isMulti,\n omitSelectedValues,\n selectedIndexes,\n ],\n )\n\n const onFocusFirstOrSelected =\n isEmptyValue || omitSelectedValues ? onFocusFirst : onFocusSelected\n const onFocusLastOrSelected =\n isEmptyValue || omitSelectedValues ? onFocusLast : onFocusSelected\n\n const pickOptions = useCallback(\n (value: string) => {\n const values = descendants.values()\n\n let isHit = false\n let isFocused = false\n\n values.forEach(({ index, node }) => {\n if (format(node.textContent ?? \"\").includes(value)) {\n isHit = true\n\n const isDisabled = \"disabled\" in node.dataset\n\n node.dataset.target = \"\"\n\n if (!isFocused && !isDisabled) {\n isFocused = true\n\n setFocusedIndex(index)\n }\n } else {\n delete node.dataset.target\n }\n })\n\n setIsHit(isHit)\n },\n [descendants, format],\n )\n\n const rebirthOptions = useCallback(\n (runFocus = true) => {\n const values = descendants.values()\n\n values.forEach(({ node }) => {\n node.dataset.target = \"\"\n })\n\n if (runFocus) onFocusFirst()\n\n setIsHit(true)\n },\n [descendants, onFocusFirst],\n )\n\n const onChangeLabel = useCallback(\n (newValue: MaybeValue) => {\n const values = descendants.values()\n\n if (!values.length) return\n\n const resolvedValues = isArray(newValue) ? newValue : [newValue]\n\n const selectedLabel = resolvedValues\n .map((value) => {\n const { node } =\n values.find(({ node }) => node.dataset.value === value) ?? {}\n\n if (node) {\n const { textContent } =\n Array.from(node.children).find(\n (child) => child.getAttribute(\"data-label\") !== null,\n ) ?? {}\n\n return textContent\n } else {\n return allowFree ? value : undefined\n }\n })\n .filter((label) => !isUndefined(label))\n\n setLabel((!isMulti ? selectedLabel[0] : selectedLabel) as T)\n },\n [allowFree, descendants, isMulti],\n )\n\n const onChange = useCallback(\n (newValue: string, runRebirth = true) => {\n setValue((prev) => {\n let next: T\n\n if (!isArray(prev)) {\n next = newValue as T\n } else {\n const isSelected = prev.includes(newValue)\n\n if (!isSelected) {\n next = [...prev, newValue] as T\n } else {\n next = prev.filter((value) => value !== newValue) as T\n }\n }\n\n prevValue.current = next\n\n return next\n })\n\n setInputValue(\"\")\n\n if (isMulti && runRebirth) rebirthOptions(false)\n },\n [isMulti, rebirthOptions, setValue],\n )\n\n const onSelect = useCallback(() => {\n let enabledValue = descendants.value(focusedIndex)\n\n if (\"disabled\" in (enabledValue?.node.dataset ?? {}))\n enabledValue = undefined\n\n if (!enabledValue) return\n\n const value = enabledValue.node.dataset.value ?? \"\"\n\n onChange(value)\n\n if (closeOnSelect) onClose()\n\n if (omitSelectedValues) onFocusNext()\n }, [\n closeOnSelect,\n descendants,\n focusedIndex,\n omitSelectedValues,\n onChange,\n onClose,\n onFocusNext,\n ])\n\n const onSearch = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!isOpen) onOpen()\n\n onSearchProp?.(ev)\n\n const value = ev.target.value\n const computedValue = format(value)\n\n if (computedValue) {\n pickOptions(computedValue)\n } else {\n rebirthOptions()\n }\n\n setInputValue(value)\n },\n [isOpen, onOpen, format, onSearchProp, pickOptions, rebirthOptions],\n )\n\n const onCompositionStart = useCallback(() => {\n isComposition.current = true\n }, [])\n\n const onCompositionEnd = useCallback(() => {\n isComposition.current = false\n }, [])\n\n const onCreate = useCallback(() => {\n const newItem: AutocompleteItem = { label: inputValue, value: inputValue }\n\n let newItems: AutocompleteItem[] = []\n\n if (resolvedItems) newItems = [...resolvedItems]\n\n if (firstInsertPositionItem === \"first\") {\n newItems = [newItem, ...newItems]\n } else if (firstInsertPositionItem === \"last\") {\n newItems = [...newItems, newItem]\n } else {\n const i = newItems.findIndex(\n ({ label }) => label === firstInsertPositionItem,\n )\n\n const targetItem = newItems[i]\n\n if (i !== -1 && targetItem && \"items\" in targetItem) {\n if (secondInsertPositionItem === \"first\") {\n targetItem.items = [newItem, ...(targetItem.items ?? [])]\n } else {\n targetItem.items = [...(targetItem.items ?? []), newItem]\n }\n\n newItems[i] = targetItem\n } else {\n console.warn(\n `${\n !isMulti ? \"Autocomplete\" : \"MultiAutocomplete\"\n }: '${firstInsertPositionItem}' specified in insertPositionItem does not exist in the option group.`,\n )\n }\n }\n\n setResolvedItems(newItems)\n onChange(inputValue)\n rebirthOptions(false)\n\n const index = flattenItems(newItems).findIndex(\n ({ value }) => value === inputValue,\n )\n\n setFocusedIndex(index)\n\n onCreateProp?.(newItem, newItems)\n }, [\n inputValue,\n resolvedItems,\n firstInsertPositionItem,\n onChange,\n rebirthOptions,\n onCreateProp,\n secondInsertPositionItem,\n isMulti,\n ])\n\n const onClick = useCallback(() => {\n if (isOpen) {\n if (inputRef.current) inputRef.current.focus()\n } else {\n onOpen()\n\n onFocusFirstOrSelected()\n }\n }, [isOpen, onFocusFirstOrSelected, onOpen])\n\n const onFocus = useCallback(() => {\n if (isOpen) return\n\n onOpen()\n\n onFocusFirstOrSelected()\n }, [isOpen, onFocusFirstOrSelected, onOpen])\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n\n if (isContains(containerRef.current, relatedTarget)) return\n\n if (!closeOnBlur && isHit) return\n\n if (allowFree && !!inputValue) onChange(inputValue, false)\n\n setInputValue(\"\")\n\n if (isOpen) onClose()\n },\n [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange],\n )\n\n const onDelete = useCallback(() => {\n if (!isMulti) {\n onChange(\"\")\n } else {\n onChange(value[value.length - 1]!)\n }\n\n if (!isOpen) onFocus()\n }, [isMulti, isOpen, onChange, onFocus, value])\n\n const onClear = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.stopPropagation()\n\n prevValue.current = [] as unknown as T\n setValue([] as unknown as T)\n setLabel(undefined)\n setInputValue(\"\")\n rebirthOptions()\n\n if (isOpen && inputRef.current) inputRef.current.focus()\n },\n [isOpen, setLabel, setInputValue, setValue, rebirthOptions],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (ev.key === \" \") ev.key = ev.code\n\n if (formControlProps.disabled || formControlProps.readOnly) return\n if (isComposition.current) return\n\n const enabledDelete = label === inputValue || !inputValue.length\n\n const actions: { [key: string]: Function | undefined } = {\n ArrowDown: isFocused\n ? () => onFocusNext()\n : !isOpen\n ? funcAll(onOpen, onFocusFirstOrSelected)\n : undefined,\n ArrowUp: isFocused\n ? () => onFocusPrev()\n : !isOpen\n ? funcAll(onOpen, onFocusLastOrSelected)\n : undefined,\n Backspace: !isEmptyValue && enabledDelete ? onDelete : undefined,\n End: isOpen ? onFocusLast : undefined,\n Enter: isCreate\n ? onCreate\n : isFocused\n ? onSelect\n : !isOpen\n ? funcAll(onOpen, onFocusFirstOrSelected)\n : allowFree && isMulti\n ? () => {\n if (inputValue) onChange(inputValue)\n\n setFocusedIndex(0)\n }\n : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n Home: isOpen ? onFocusFirst : undefined,\n Space: isCreate\n ? onCreate\n : isFocused\n ? onSelect\n : !isOpen\n ? funcAll(onOpen, onFocusFirstOrSelected)\n : undefined,\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n },\n [\n allowFree,\n formControlProps,\n label,\n inputValue,\n onOpen,\n isFocused,\n isMulti,\n onFocusFirstOrSelected,\n onFocusNext,\n onFocusLastOrSelected,\n onFocusPrev,\n isCreate,\n onCreate,\n onSelect,\n isOpen,\n onFocusFirst,\n onFocusLast,\n closeOnEsc,\n onClose,\n isEmptyValue,\n onDelete,\n onChange,\n ],\n )\n\n useEffect(() => {\n if (!isMulti) return\n\n if (!omitSelectedValues && isUndefined(maxSelectValues)) return\n\n const isAll = value.length > 0 && value.length === descendants.count()\n const isMax = value.length === maxSelectValues\n\n if (isAll || isMax) {\n onClose()\n setIsAllSelected(true)\n } else {\n setIsAllSelected(false)\n }\n }, [\n omitSelectedValues,\n value,\n descendants,\n isMulti,\n onClose,\n maxSelectValues,\n ])\n\n useSafeLayoutEffect(() => {\n onChangeLabel(value)\n }, [value])\n\n useUpdateEffect(() => {\n if (isOpen || allowFree) return\n\n setFocusedIndex(-1)\n setInputValue(\"\")\n }, [isOpen])\n\n useUpdateEffect(() => {\n if (!isHit) setFocusedIndex(-2)\n }, [isHit])\n\n useUpdateEffect(() => {\n setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : undefined)\n }, [items])\n\n useUnmountEffect(() => {\n timeoutIds.current.forEach((id) => clearTimeout(id))\n timeoutIds.current.clear()\n })\n\n useOutsideClick({\n ref: containerRef,\n enabled: isOpen && (closeOnBlur || !isHit),\n handler: onClose,\n })\n\n const getPopoverProps = useCallback(\n (props?: PopoverProps): PopoverProps => ({\n animation,\n boundary,\n closeDelay,\n closeOnBlur,\n duration,\n eventListeners,\n flip,\n gutter,\n isLazy,\n lazyBehavior,\n matchWidth,\n modifiers,\n offset,\n openDelay,\n placement,\n preventOverflow,\n strategy,\n ...props,\n closeOnButton: false,\n isOpen,\n trigger: \"never\",\n onClose,\n onOpen,\n }),\n [\n closeOnBlur,\n openDelay,\n closeDelay,\n isLazy,\n lazyBehavior,\n animation,\n duration,\n offset,\n gutter,\n preventOverflow,\n flip,\n matchWidth,\n boundary,\n eventListeners,\n strategy,\n placement,\n modifiers,\n isOpen,\n onOpen,\n onClose,\n ],\n )\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onBlur: handlerAll(props.onBlur, rest.onBlur, onBlur),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n }),\n\n [containerProps, formControlProps, onBlur, onClick, rest],\n )\n\n const getFieldProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref,\n \"aria-activedescendant\": activedescendantId,\n \"aria-autocomplete\": \"list\",\n \"aria-haspopup\": \"listbox\",\n role: \"combobox\",\n tabIndex: -1,\n ...props,\n ...formControlProps,\n \"data-active\": dataAttr(isOpen),\n placeholder,\n onFocus: handlerAll(props.onFocus, onFocusProp, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDownProp, onKeyDown),\n }),\n [\n activedescendantId,\n formControlProps,\n placeholder,\n isOpen,\n onFocusProp,\n onFocus,\n onKeyDownProp,\n onKeyDown,\n ],\n )\n\n return {\n allowCreate,\n allowFree,\n children: children ?? computedChildren,\n closeOnSelect,\n descendants,\n emptyMessage,\n focusedIndex,\n inputRef,\n inputValue,\n isAllSelected,\n isEmpty,\n isHit,\n isOpen,\n label,\n omitSelectedValues,\n pickOptions,\n rebirthOptions,\n setFocusedIndex,\n value,\n formControlProps,\n getContainerProps,\n getFieldProps,\n getPopoverProps,\n inputProps: inputProps as DOMAttributes<HTMLInputElement>,\n optionProps,\n onChange,\n onClear,\n onClose,\n onCompositionEnd,\n onCompositionStart,\n onCreate,\n onFocusFirst,\n onFocusLast,\n onFocusNext,\n onFocusPrev,\n onFocusSelected,\n onOpen,\n onSearch,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport const useAutocompleteInput = () => {\n const {\n inputRef,\n isAllSelected,\n formControlProps,\n inputProps,\n onCompositionEnd,\n onCompositionStart,\n onSearch,\n } = useAutocompleteContext()\n\n useUpdateEffect(() => {\n if (isAllSelected && inputRef.current) inputRef.current.blur()\n }, [isAllSelected])\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => {\n return {\n ref: mergeRefs(inputRef, ref),\n ...formControlProps,\n autoCapitalize: \"none\",\n autoComplete: \"off\",\n spellCheck: \"false\",\n tabIndex: isAllSelected ? -1 : 0,\n ...inputProps,\n ...props,\n cursor: formControlProps.readOnly ? \"default\" : \"text\",\n pointerEvents:\n formControlProps.disabled || isAllSelected ? \"none\" : \"auto\",\n onChange: handlerAll(props.onChange, onSearch),\n onCompositionEnd: handlerAll(\n props.onCompositionEnd,\n inputProps.onCompositionEnd,\n onCompositionEnd,\n ),\n onCompositionStart: handlerAll(\n props.onCompositionStart,\n inputProps.onCompositionStart,\n onCompositionStart,\n ),\n }\n },\n [\n inputProps,\n inputRef,\n formControlProps,\n isAllSelected,\n onSearch,\n onCompositionStart,\n onCompositionEnd,\n ],\n )\n\n return {\n getInputProps,\n }\n}\n\nexport type UseAutocompleteInputReturn = ReturnType<typeof useAutocompleteInput>\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAqXpD;AAzVd,IAAM,UAAqC;AAAA,EACzC,UAAK;AAAA,EACL,UAAK;AAAA,EACL,UAAK;AAAA,EACL,UAAK;AAAA,EACL,UAAK;AAAA,EACL,QAAG;AAAA,EACH,cAAI;AAAA,EACJ,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,cAAI;AAAA,EACJ,QAAG;AAAA,EACH,QAAG;AAAA,EACH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AAA,IACA;AAAA,EACF,IAAI,uBAAuB;AAE3B,kBAAgB,MAAM;AACpB,QAAI,iBAAiB,SAAS,QAAS,UAAS,QAAQ,KAAK;AAAA,EAC/D,GAAG,CAAC,aAAa,CAAC;AAElB,QAAM,gBAAqC;AAAA,IACzC,CAAC,QAAQ,CAAC,GAAG,MAAM,SAAS;AAC1B,aAAO;AAAA,QACL,KAAK,UAAU,UAAU,GAAG;AAAA,QAC5B,GAAG;AAAA,QACH,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,YAAY;AAAA,QACZ,UAAU,gBAAgB,KAAK;AAAA,QAC/B,GAAG;AAAA,QACH,GAAG;AAAA,QACH,QAAQ,iBAAiB,WAAW,YAAY;AAAA,QAChD,eACE,iBAAiB,YAAY,gBAAgB,SAAS;AAAA,QACxD,UAAU,WAAW,MAAM,UAAU,QAAQ;AAAA,QAC7C,kBAAkB;AAAA,UAChB,MAAM;AAAA,UACN,WAAW;AAAA,UACX;AAAA,QACF;AAAA,QACA,oBAAoB;AAAA,UAClB,MAAM;AAAA,UACN,WAAW;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["items","_a","label","value","props","index","isHit","isFocused","node"]}