@yamada-ui/autocomplete 1.6.5-next-20241119123334 → 1.6.5

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 +2 -4
  54. package/dist/use-autocomplete.d.ts +2 -4
  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
@@ -43,9 +43,9 @@ var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createCont
43
43
 
44
44
  // src/use-autocomplete-list.ts
45
45
  var useAutocompleteList = () => {
46
- const { focusedIndex, isOpen, listRef, rebirthOptions, value } = useAutocompleteContext();
46
+ const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
47
47
  const descendants = useAutocompleteDescendantsContext();
48
- const uuid = (0, import_react.useId)();
48
+ const listRef = (0, import_react.useRef)(null);
49
49
  const beforeFocusedIndex = (0, import_react.useRef)(-1);
50
50
  const selectedValue = descendants.value(focusedIndex);
51
51
  const isMulti = (0, import_utils2.isArray)(value);
@@ -81,21 +81,31 @@ var useAutocompleteList = () => {
81
81
  (0, import_utils2.useUpdateEffect)(() => {
82
82
  if (!isOpen) beforeFocusedIndex.current = -1;
83
83
  }, [isOpen]);
84
+ const getContainerProps = (0, import_react.useCallback)(
85
+ (props = {}, ref = null) => ({
86
+ ref,
87
+ "aria-multiselectable": (0, import_utils2.ariaAttr)(isMulti),
88
+ role: "listbox",
89
+ ...props,
90
+ onAnimationComplete: (0, import_utils2.handlerAll)(
91
+ props.onAnimationComplete,
92
+ onAnimationComplete
93
+ )
94
+ }),
95
+ [isMulti, onAnimationComplete]
96
+ );
84
97
  const getListProps = (0, import_react.useCallback)(
85
- ({ id, ...props } = {}, ref = null) => ({
86
- id: id != null ? id : uuid,
98
+ (props = {}, ref = null) => ({
87
99
  ref: (0, import_utils2.mergeRefs)(listRef, ref),
88
- "aria-multiselectable": (0, import_utils2.ariaAttr)(isMulti),
89
100
  position: "relative",
90
- role: "listbox",
91
101
  tabIndex: -1,
92
102
  ...props
93
103
  }),
94
- [listRef, uuid, isMulti]
104
+ [listRef]
95
105
  );
96
106
  return {
97
- getListProps,
98
- onAnimationComplete
107
+ getContainerProps,
108
+ getListProps
99
109
  };
100
110
  };
101
111
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-autocomplete-list.ts","../src/autocomplete-context.ts"],"sourcesContent":["import type { PropGetter } from \"@yamada-ui/core\"\nimport { ariaAttr, isArray, mergeRefs, useUpdateEffect } from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendantsContext,\n} from \"./autocomplete-context\"\n\nexport const useAutocompleteList = () => {\n const { focusedIndex, isOpen, listRef, rebirthOptions, value } =\n useAutocompleteContext()\n const descendants = useAutocompleteDescendantsContext()\n const uuid = useId()\n const beforeFocusedIndex = useRef<number>(-1)\n const selectedValue = descendants.value(focusedIndex)\n const isMulti = isArray(value)\n\n const onAnimationComplete = useCallback(() => {\n if (!isOpen) rebirthOptions(false)\n }, [isOpen, rebirthOptions])\n\n useEffect(() => {\n if (!listRef.current || !selectedValue) return\n\n if (beforeFocusedIndex.current === selectedValue.index) return\n\n const parent = listRef.current\n const child = selectedValue.node\n\n const parentHeight = parent.clientHeight\n const viewTop = parent.scrollTop\n const viewBottom = viewTop + parentHeight\n\n const childHeight = child.clientHeight\n const childTop = child.offsetTop\n const childBottom = childTop + childHeight\n\n const isInView = viewTop <= childTop && childBottom <= viewBottom\n\n const isScrollBottom = beforeFocusedIndex.current < selectedValue.index\n\n if (!isInView) {\n if (childBottom <= parentHeight) {\n listRef.current.scrollTo({ top: 0 })\n } else {\n if (!isScrollBottom) {\n listRef.current.scrollTo({ top: childTop + 1 })\n } else {\n listRef.current.scrollTo({ top: childBottom - parentHeight })\n }\n }\n }\n\n beforeFocusedIndex.current = selectedValue.index\n }, [listRef, selectedValue])\n\n useUpdateEffect(() => {\n if (!isOpen) beforeFocusedIndex.current = -1\n }, [isOpen])\n\n const getListProps: PropGetter = useCallback(\n ({ id, ...props } = {}, ref = null) => ({\n id: id ?? uuid,\n ref: mergeRefs(listRef, ref),\n \"aria-multiselectable\": ariaAttr(isMulti),\n position: \"relative\",\n role: \"listbox\",\n tabIndex: -1,\n ...props,\n }),\n [listRef, uuid, isMulti],\n )\n\n return {\n getListProps,\n onAnimationComplete,\n }\n}\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n listRef: RefObject<HTMLUListElement>\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, runRebirth?: boolean) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAA8D;AAC9D,mBAAsD;;;ACCtD,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,uBAAuB;AACzB,QAAI,wCAAiB;AAiCd,IAAM,CAAC,sBAAsB,sBAAsB,QACxD,4BAAmC;AAAA,EACjC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADxCI,IAAM,sBAAsB,MAAM;AACvC,QAAM,EAAE,cAAc,QAAQ,SAAS,gBAAgB,MAAM,IAC3D,uBAAuB;AACzB,QAAM,cAAc,kCAAkC;AACtD,QAAM,WAAO,oBAAM;AACnB,QAAM,yBAAqB,qBAAe,EAAE;AAC5C,QAAM,gBAAgB,YAAY,MAAM,YAAY;AACpD,QAAM,cAAU,uBAAQ,KAAK;AAE7B,QAAM,0BAAsB,0BAAY,MAAM;AAC5C,QAAI,CAAC,OAAQ,gBAAe,KAAK;AAAA,EACnC,GAAG,CAAC,QAAQ,cAAc,CAAC;AAE3B,8BAAU,MAAM;AACd,QAAI,CAAC,QAAQ,WAAW,CAAC,cAAe;AAExC,QAAI,mBAAmB,YAAY,cAAc,MAAO;AAExD,UAAM,SAAS,QAAQ;AACvB,UAAM,QAAQ,cAAc;AAE5B,UAAM,eAAe,OAAO;AAC5B,UAAM,UAAU,OAAO;AACvB,UAAM,aAAa,UAAU;AAE7B,UAAM,cAAc,MAAM;AAC1B,UAAM,WAAW,MAAM;AACvB,UAAM,cAAc,WAAW;AAE/B,UAAM,WAAW,WAAW,YAAY,eAAe;AAEvD,UAAM,iBAAiB,mBAAmB,UAAU,cAAc;AAElE,QAAI,CAAC,UAAU;AACb,UAAI,eAAe,cAAc;AAC/B,gBAAQ,QAAQ,SAAS,EAAE,KAAK,EAAE,CAAC;AAAA,MACrC,OAAO;AACL,YAAI,CAAC,gBAAgB;AACnB,kBAAQ,QAAQ,SAAS,EAAE,KAAK,WAAW,EAAE,CAAC;AAAA,QAChD,OAAO;AACL,kBAAQ,QAAQ,SAAS,EAAE,KAAK,cAAc,aAAa,CAAC;AAAA,QAC9D;AAAA,MACF;AAAA,IACF;AAEA,uBAAmB,UAAU,cAAc;AAAA,EAC7C,GAAG,CAAC,SAAS,aAAa,CAAC;AAE3B,qCAAgB,MAAM;AACpB,QAAI,CAAC,OAAQ,oBAAmB,UAAU;AAAA,EAC5C,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,mBAA2B;AAAA,IAC/B,CAAC,EAAE,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MACtC,IAAI,kBAAM;AAAA,MACV,SAAK,yBAAU,SAAS,GAAG;AAAA,MAC3B,4BAAwB,wBAAS,OAAO;AAAA,MACxC,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,GAAG;AAAA,IACL;AAAA,IACA,CAAC,SAAS,MAAM,OAAO;AAAA,EACzB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["import_utils"]}
1
+ {"version":3,"sources":["../src/use-autocomplete-list.ts","../src/autocomplete-context.ts"],"sourcesContent":["import type { PropGetter } from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport {\n ariaAttr,\n handlerAll,\n isArray,\n mergeRefs,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendantsContext,\n} from \"./autocomplete-context\"\n\nexport const useAutocompleteList = () => {\n const { focusedIndex, isOpen, rebirthOptions, value } =\n useAutocompleteContext()\n const descendants = useAutocompleteDescendantsContext()\n const listRef = useRef<HTMLDivElement>(null)\n const beforeFocusedIndex = useRef<number>(-1)\n const selectedValue = descendants.value(focusedIndex)\n const isMulti = isArray(value)\n\n const onAnimationComplete = useCallback(() => {\n if (!isOpen) rebirthOptions(false)\n }, [isOpen, rebirthOptions])\n\n useEffect(() => {\n if (!listRef.current || !selectedValue) return\n\n if (beforeFocusedIndex.current === selectedValue.index) return\n\n const parent = listRef.current\n const child = selectedValue.node\n\n const parentHeight = parent.clientHeight\n const viewTop = parent.scrollTop\n const viewBottom = viewTop + parentHeight\n\n const childHeight = child.clientHeight\n const childTop = child.offsetTop\n const childBottom = childTop + childHeight\n\n const isInView = viewTop <= childTop && childBottom <= viewBottom\n\n const isScrollBottom = beforeFocusedIndex.current < selectedValue.index\n\n if (!isInView) {\n if (childBottom <= parentHeight) {\n listRef.current.scrollTo({ top: 0 })\n } else {\n if (!isScrollBottom) {\n listRef.current.scrollTo({ top: childTop + 1 })\n } else {\n listRef.current.scrollTo({ top: childBottom - parentHeight })\n }\n }\n }\n\n beforeFocusedIndex.current = selectedValue.index\n }, [listRef, selectedValue])\n\n useUpdateEffect(() => {\n if (!isOpen) beforeFocusedIndex.current = -1\n }, [isOpen])\n\n const getContainerProps: PropGetter<MotionProps, MotionProps> = useCallback(\n (props = {}, ref = null) => ({\n ref,\n \"aria-multiselectable\": ariaAttr(isMulti),\n role: \"listbox\",\n ...props,\n onAnimationComplete: handlerAll(\n props.onAnimationComplete,\n onAnimationComplete,\n ),\n }),\n [isMulti, onAnimationComplete],\n )\n\n const getListProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(listRef, ref),\n position: \"relative\",\n tabIndex: -1,\n ...props,\n }),\n [listRef],\n )\n\n return {\n getContainerProps,\n getListProps,\n }\n}\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, runRebirth?: boolean) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAMO;AACP,mBAA+C;;;ACN/C,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5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AEA,uBAAmB,UAAU,cAAc;AAAA,EAC7C,GAAG,CAAC,SAAS,aAAa,CAAC;AAE3B,qCAAgB,MAAM;AACpB,QAAI,CAAC,OAAQ,oBAAmB,UAAU;AAAA,EAC5C,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,wBAA0D;AAAA,IAC9D,CAAC,QAAQ,CAAC,GAAG,MAAM,UAAU;AAAA,MAC3B;AAAA,MACA,4BAAwB,wBAAS,OAAO;AAAA,MACxC,MAAM;AAAA,MACN,GAAG;AAAA,MACH,yBAAqB;AAAA,QACnB,MAAM;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,mBAAmB;AAAA,EAC/B;AAEA,QAAM,mBAA2B;AAAA,IAC/B,CAAC,QAAQ,CAAC,GAAG,MAAM,UAAU;AAAA,MAC3B,SAAK,yBAAU,SAAS,GAAG;AAAA,MAC3B,UAAU;AAAA,MACV,UAAU;AAAA,MACV,GAAG;AAAA,IACL;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["import_utils"]}
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import {
3
3
  useAutocompleteList
4
- } from "./chunk-PTPJFYGI.mjs";
5
- import "./chunk-ZNO5RUVT.mjs";
4
+ } from "./chunk-4GVV3HBE.mjs";
5
+ import "./chunk-TP5VZFO3.mjs";
6
6
  export {
7
7
  useAutocompleteList
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-autocomplete-option-group.ts","../src/autocomplete-context.ts"],"sourcesContent":["import type { HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { CSSProperties } from \"react\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport { isArray, mergeRefs, splitObject } from \"@yamada-ui/utils\"\nimport { useCallback, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendantsContext,\n} from \"./autocomplete-context\"\n\nexport interface UseAutocompleteOptionGroupProps extends HTMLUIProps {\n /**\n * The label of the autocomplete option group.\n */\n label: string\n}\n\nexport const useAutocompleteOptionGroup = ({\n label,\n ...rest\n}: UseAutocompleteOptionGroupProps) => {\n const { omitSelectedValues, value } = useAutocompleteContext()\n const descendants = useAutocompleteDescendantsContext()\n const labelRef = useRef<HTMLDivElement>(null)\n const labelId = useId()\n const values = descendants.values()\n const isMulti = isArray(value)\n const selectedValues =\n isMulti && omitSelectedValues\n ? descendants.values(({ node }) =>\n value.includes(node.dataset.value ?? \"\"),\n )\n : []\n const selectedIndexes = selectedValues.map(({ index }) => index)\n const childValues = values.filter(\n ({ index, node }) =>\n node.parentElement?.dataset.label === label &&\n !selectedIndexes.includes(index) &&\n \"target\" in node.dataset,\n )\n const isEmpty = !childValues.length\n\n const [containerProps, groupProps] = splitObject(rest, layoutStyleProperties)\n\n const getContainerProps: PropGetter<\"li\"> = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref,\n \"aria-labelledby\": labelRef.current?.id,\n role: \"group\",\n ...props,\n ...containerProps,\n style: isEmpty ? style : undefined,\n }\n },\n [containerProps, isEmpty],\n )\n\n const getLabelProps: PropGetter = useCallback(\n ({ id, ...props } = {}, ref = null) => {\n return {\n id: id ?? labelId,\n ref: mergeRefs(ref, labelRef),\n role: \"presentation\",\n ...props,\n }\n },\n [labelId],\n )\n\n const getGroupProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref,\n ...props,\n ...groupProps,\n \"data-label\": label,\n }),\n [groupProps, label],\n )\n\n return {\n label,\n getContainerProps,\n getGroupProps,\n getLabelProps,\n }\n}\n\nexport type UseAutocompleteOptionGroupReturn = ReturnType<\n typeof useAutocompleteOptionGroup\n>\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n listRef: RefObject<HTMLUListElement>\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, runRebirth?: boolean) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAsC;AACtC,IAAAA,gBAAgD;AAChD,mBAA2C;;;ACD3C,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,gBA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S,YAAT,mBAAkB;AAAA,QACrC,MAAM;AAAA,QACN,GAAG;AAAA,QACH,GAAG;AAAA,QACH,OAAO,UAAU,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,QAAM,oBAA4B;AAAA,IAChC,CAAC,EAAE,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,SAAS;AACrC,aAAO;AAAA,QACL,IAAI,kBAAM;AAAA,QACV,SAAK,yBAAU,KAAK,QAAQ;AAAA,QAC5B,MAAM;AAAA,QACN,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,oBAA4B;AAAA,IAChC,CAAC,QAAQ,CAAC,GAAG,MAAM,UAAU;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc;AAAA,IAChB;AAAA,IACA,CAAC,YAAY,KAAK;AAAA,EACpB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_utils"]}
1
+ {"version":3,"sources":["../src/use-autocomplete-option-group.ts","../src/autocomplete-context.ts"],"sourcesContent":["import type { HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { CSSProperties } from \"react\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport { isArray, mergeRefs, splitObject } from \"@yamada-ui/utils\"\nimport { useCallback, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendantsContext,\n} from \"./autocomplete-context\"\n\nexport interface UseAutocompleteOptionGroupProps extends HTMLUIProps {\n /**\n * The label of the autocomplete option group.\n */\n label: string\n}\n\nexport const useAutocompleteOptionGroup = ({\n label,\n ...rest\n}: UseAutocompleteOptionGroupProps) => {\n const { omitSelectedValues, value } = useAutocompleteContext()\n const descendants = useAutocompleteDescendantsContext()\n const labelRef = useRef<HTMLDivElement>(null)\n const labelId = useId()\n const values = descendants.values()\n const isMulti = isArray(value)\n const selectedValues =\n isMulti && omitSelectedValues\n ? descendants.values(({ node }) =>\n value.includes(node.dataset.value ?? \"\"),\n )\n : []\n const selectedIndexes = selectedValues.map(({ index }) => index)\n const childValues = values.filter(\n ({ index, node }) =>\n node.parentElement?.dataset.label === label &&\n !selectedIndexes.includes(index) &&\n \"target\" in node.dataset,\n )\n const isEmpty = !childValues.length\n\n const [containerProps, groupProps] = splitObject(rest, layoutStyleProperties)\n\n const getContainerProps: PropGetter<\"li\"> = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref,\n \"aria-labelledby\": labelRef.current?.id,\n role: \"group\",\n ...props,\n ...containerProps,\n style: isEmpty ? style : undefined,\n }\n },\n [containerProps, isEmpty],\n )\n\n const getLabelProps: PropGetter = useCallback(\n ({ id, ...props } = {}, ref = null) => {\n return {\n id: id ?? labelId,\n ref: mergeRefs(ref, labelRef),\n role: \"presentation\",\n ...props,\n }\n },\n [labelId],\n )\n\n const getGroupProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref,\n ...props,\n ...groupProps,\n \"data-label\": label,\n }),\n [groupProps, label],\n )\n\n return {\n label,\n getContainerProps,\n getGroupProps,\n getLabelProps,\n }\n}\n\nexport type UseAutocompleteOptionGroupReturn = ReturnType<\n typeof useAutocompleteOptionGroup\n>\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, runRebirth?: boolean) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAsC;AACtC,IAAAA,gBAAgD;AAChD,mBAA2C;;;ACD3C,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,uBAAuB;AACzB,QAAI,wCAAiB;AAgCd,IAAM,CAAC,sBAAsB,sBAAsB,QACxD,4BAAmC;AAAA,EACjC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;AD9BI,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA,GAAG;AACL,MAAuC;AACrC,QAAM,EAAE,oBAAoB,MAAM,IAAI,uBAAu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;AACrC,aAAO;AAAA,QACL,IAAI,kBAAM;AAAA,QACV,SAAK,yBAAU,KAAK,QAAQ;AAAA,QAC5B,MAAM;AAAA,QACN,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,oBAA4B;AAAA,IAChC,CAAC,QAAQ,CAAC,GAAG,MAAM,UAAU;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc;AAAA,IAChB;AAAA,IACA,CAAC,YAAY,KAAK;AAAA,EACpB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_utils"]}
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import {
3
3
  useAutocompleteOptionGroup
4
- } from "./chunk-CMFJUJJW.mjs";
5
- import "./chunk-ZNO5RUVT.mjs";
4
+ } from "./chunk-UX5QECNB.mjs";
5
+ import "./chunk-TP5VZFO3.mjs";
6
6
  export {
7
7
  useAutocompleteOptionGroup
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-autocomplete-option.ts","../src/autocomplete-context.ts"],"sourcesContent":["import type { HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { CSSProperties, MouseEvent } from \"react\"\nimport {\n ariaAttr,\n dataAttr,\n handlerAll,\n isArray,\n isHTMLElement,\n isNumber,\n isString,\n isUndefined,\n mergeRefs,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendant,\n} from \"./autocomplete-context\"\n\nconst isTargetOption = (target: EventTarget | null): boolean =>\n isHTMLElement(target) && !!target.getAttribute(\"role\")?.startsWith(\"option\")\n\nexport interface UseAutocompleteOptionProps\n extends Omit<HTMLUIProps, \"children\" | \"value\"> {\n /**\n * The label of the autocomplete option.\n */\n children?: string\n /**\n * If `true`, the list element will be closed when selected.\n *\n * @default false\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the autocomplete option will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the autocomplete option will be focusable.\n *\n * @default false\n */\n focusable?: boolean\n /**\n * If `true`, the autocomplete option will be disabled.\n *\n * @default false\n *\n * @deprecated Use `disabled` instead.\n */\n isDisabled?: boolean\n /**\n * If `true`, the autocomplete option will be focusable.\n *\n * @default false\n *\n * @deprecated Use `focusable` instead.\n */\n isFocusable?: boolean\n /**\n * The value of the autocomplete option.\n */\n value?: string\n}\n\nexport const useAutocompleteOption = (props: UseAutocompleteOptionProps) => {\n const {\n closeOnSelect,\n focusedIndex,\n inputRef,\n omitSelectedValues,\n setFocusedIndex,\n value,\n optionProps,\n onChange,\n onClose,\n onFocusNext,\n } = useAutocompleteContext()\n const uuid = useId()\n const itemRef = useRef<HTMLLIElement>(null)\n let {\n id,\n children,\n closeOnSelect: customCloseOnSelect,\n disabled,\n focusable,\n icon: customIcon,\n isDisabled,\n isFocusable,\n value: optionValue,\n ...computedProps\n } = { ...optionProps, ...props }\n disabled ??= isDisabled\n focusable ??= isFocusable\n const trulyDisabled = !!disabled && !focusable\n const { descendants, index, register } = useAutocompleteDescendant({\n disabled: trulyDisabled,\n })\n const values = descendants.values()\n const frontValues = values.slice(0, index)\n const isMulti = isArray(value)\n const isDuplicated = frontValues.some(\n ({ node }) => node.dataset.value === (optionValue ?? \"\"),\n )\n const isSelected =\n !isDuplicated &&\n (!isMulti\n ? (optionValue ?? \"\") === value\n : value.includes(optionValue ?? \"\"))\n const isTarget = \"target\" in (itemRef.current?.dataset ?? {})\n const isFocused = index === focusedIndex\n\n id ??= uuid\n\n if (isUndefined(optionValue)) {\n if (isString(children) || isNumber(children)) {\n optionValue = children.toString()\n } else {\n console.warn(\n `${\n !isMulti ? \"Autocomplete\" : \"MultiAutocomplete\"\n }: Cannot infer the option value of complex children. Pass a \\`value\\` prop or use a plain string as children to <Option>.`,\n )\n }\n }\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.stopPropagation()\n\n if (disabled || !isTargetOption(ev.currentTarget)) {\n if (inputRef.current) inputRef.current.focus()\n\n return\n }\n\n if (!isDuplicated) setFocusedIndex(index)\n\n onChange(optionValue ?? \"\")\n\n if (inputRef.current) inputRef.current.focus()\n\n if (customCloseOnSelect ?? closeOnSelect) onClose()\n\n if (omitSelectedValues) onFocusNext(index)\n },\n [\n isDuplicated,\n onFocusNext,\n omitSelectedValues,\n disabled,\n optionValue,\n setFocusedIndex,\n index,\n onChange,\n customCloseOnSelect,\n closeOnSelect,\n onClose,\n inputRef,\n ],\n )\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const isHidden = !isTarget || (omitSelectedValues && isSelected)\n\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref: mergeRefs(itemRef, ref, register),\n role: \"option\",\n ...computedProps,\n ...props,\n id,\n style: isHidden ? style : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-hidden\": ariaAttr(isHidden),\n \"aria-selected\": isSelected,\n \"data-disabled\": dataAttr(disabled),\n \"data-duplicated\": dataAttr(isDuplicated),\n \"data-focus\": dataAttr(isFocused),\n \"data-target\": dataAttr(true),\n \"data-value\": optionValue ?? \"\",\n tabIndex: -1,\n onClick: handlerAll(computedProps.onClick, props.onClick, onClick),\n }\n },\n [\n id,\n isDuplicated,\n optionValue,\n computedProps,\n disabled,\n isFocused,\n isSelected,\n isTarget,\n omitSelectedValues,\n onClick,\n register,\n ],\n )\n\n return {\n children,\n customIcon,\n isFocused,\n isSelected,\n isTarget,\n omitSelectedValues,\n getOptionProps,\n }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n\nexport const useAutocompleteCreate = () => {\n const { isHit, onCreate } = useAutocompleteContext()\n\n const getCreateProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref,\n role: \"option\",\n ...props,\n style: isHit ? style : undefined,\n \"aria-hidden\": ariaAttr(isHit),\n \"data-focus\": dataAttr(!isHit),\n tabIndex: -1,\n onClick: handlerAll(props.onClick, onCreate),\n }\n },\n [isHit, onCreate],\n )\n\n return { getCreateProps }\n}\n\nexport type UseAutocompleteCreateReturn = ReturnType<\n typeof useAutocompleteCreate\n>\n\nexport const useAutocompleteEmpty = () => {\n const { isEmpty, isHit } = useAutocompleteContext()\n\n const getEmptyProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const isHidden = isHit && !isEmpty\n\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref,\n role: \"presentation\",\n ...props,\n style: isHidden ? style : undefined,\n \"aria-hidden\": ariaAttr(isHidden),\n tabIndex: -1,\n }\n },\n [isHit, isEmpty],\n )\n\n return { getEmptyProps }\n}\n\nexport type UseAutocompleteEmptyReturn = ReturnType<typeof useAutocompleteEmpty>\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n listRef: RefObject<HTMLUListElement>\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, runRebirth?: boolean) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAUO;AACP,mBAA2C;;;ACV3C,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,uBAAuB;AACzB,QAAI,wCAAiB;AAiCd,IAAM,CAAC,sBAAsB,sBAAsB,QACxD,4BAAmC;AAAA,EACjC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;AD7BH,IAAM,iBAAiB,CAAC,WAAqC;AAnB7D;AAoBE,0CAAc,MAAM,KAAK,CAAC,GAAC,YAAO,aAAa,MAAM,MAA1B,mBAA6B,W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Q;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,SAAS;AAAA,QACT,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,OAAO;AAAA,MACT;AAEA,aAAO;AAAA,QACL;AAAA,QACA,MAAM;AAAA,QACN,GAAG;AAAA,QACH,OAAO,WAAW,QAAQ;AAAA,QAC1B,mBAAe,wBAAS,QAAQ;AAAA,QAChC,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,CAAC,OAAO,OAAO;AAAA,EACjB;AAEA,SAAO,EAAE,cAAc;AACzB;","names":["import_utils","props"]}
1
+ {"version":3,"sources":["../src/use-autocomplete-option.ts","../src/autocomplete-context.ts"],"sourcesContent":["import type { HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { CSSProperties, MouseEvent } from \"react\"\nimport {\n ariaAttr,\n dataAttr,\n handlerAll,\n isArray,\n isHTMLElement,\n isNumber,\n isString,\n isUndefined,\n mergeRefs,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendant,\n} from \"./autocomplete-context\"\n\nconst isTargetOption = (target: EventTarget | null): boolean =>\n isHTMLElement(target) && !!target.getAttribute(\"role\")?.startsWith(\"option\")\n\nexport interface UseAutocompleteOptionProps\n extends Omit<HTMLUIProps, \"children\" | \"value\"> {\n /**\n * The label of the autocomplete option.\n */\n children?: string\n /**\n * If `true`, the list element will be closed when selected.\n *\n * @default false\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the autocomplete option will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the autocomplete option will be focusable.\n *\n * @default false\n */\n focusable?: boolean\n /**\n * If `true`, the autocomplete option will be disabled.\n *\n * @default false\n *\n * @deprecated Use `disabled` instead.\n */\n isDisabled?: boolean\n /**\n * If `true`, the autocomplete option will be focusable.\n *\n * @default false\n *\n * @deprecated Use `focusable` instead.\n */\n isFocusable?: boolean\n /**\n * The value of the autocomplete option.\n */\n value?: string\n}\n\nexport const useAutocompleteOption = (props: UseAutocompleteOptionProps) => {\n const {\n closeOnSelect,\n focusedIndex,\n inputRef,\n omitSelectedValues,\n setFocusedIndex,\n value,\n optionProps,\n onChange,\n onClose,\n onFocusNext,\n } = useAutocompleteContext()\n const uuid = useId()\n const itemRef = useRef<HTMLLIElement>(null)\n let {\n id,\n children,\n closeOnSelect: customCloseOnSelect,\n disabled,\n focusable,\n icon: customIcon,\n isDisabled,\n isFocusable,\n value: optionValue,\n ...computedProps\n } = { ...optionProps, ...props }\n disabled ??= isDisabled\n focusable ??= isFocusable\n const trulyDisabled = !!disabled && !focusable\n const { descendants, index, register } = useAutocompleteDescendant({\n disabled: trulyDisabled,\n })\n const values = descendants.values()\n const frontValues = values.slice(0, index)\n const isMulti = isArray(value)\n const isDuplicated = frontValues.some(\n ({ node }) => node.dataset.value === (optionValue ?? \"\"),\n )\n const isSelected =\n !isDuplicated &&\n (!isMulti\n ? (optionValue ?? \"\") === value\n : value.includes(optionValue ?? \"\"))\n const isTarget = \"target\" in (itemRef.current?.dataset ?? {})\n const isFocused = index === focusedIndex\n\n id ??= uuid\n\n if (isUndefined(optionValue)) {\n if (isString(children) || isNumber(children)) {\n optionValue = children.toString()\n } else {\n console.warn(\n `${\n !isMulti ? \"Autocomplete\" : \"MultiAutocomplete\"\n }: Cannot infer the option value of complex children. Pass a \\`value\\` prop or use a plain string as children to <Option>.`,\n )\n }\n }\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.stopPropagation()\n\n if (disabled || !isTargetOption(ev.currentTarget)) {\n if (inputRef.current) inputRef.current.focus()\n\n return\n }\n\n if (!isDuplicated) setFocusedIndex(index)\n\n onChange(optionValue ?? \"\")\n\n if (inputRef.current) inputRef.current.focus()\n\n if (customCloseOnSelect ?? closeOnSelect) onClose()\n\n if (omitSelectedValues) onFocusNext(index)\n },\n [\n isDuplicated,\n onFocusNext,\n omitSelectedValues,\n disabled,\n optionValue,\n setFocusedIndex,\n index,\n onChange,\n customCloseOnSelect,\n closeOnSelect,\n onClose,\n inputRef,\n ],\n )\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const isHidden = !isTarget || (omitSelectedValues && isSelected)\n\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref: mergeRefs(itemRef, ref, register),\n role: \"option\",\n ...computedProps,\n ...props,\n id,\n style: isHidden ? style : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-hidden\": ariaAttr(isHidden),\n \"aria-selected\": isSelected,\n \"data-disabled\": dataAttr(disabled),\n \"data-duplicated\": dataAttr(isDuplicated),\n \"data-focus\": dataAttr(isFocused),\n \"data-target\": dataAttr(true),\n \"data-value\": optionValue ?? \"\",\n tabIndex: -1,\n onClick: handlerAll(computedProps.onClick, props.onClick, onClick),\n }\n },\n [\n id,\n isDuplicated,\n optionValue,\n computedProps,\n disabled,\n isFocused,\n isSelected,\n isTarget,\n omitSelectedValues,\n onClick,\n register,\n ],\n )\n\n return {\n children,\n customIcon,\n isFocused,\n isSelected,\n isTarget,\n omitSelectedValues,\n getOptionProps,\n }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n\nexport const useAutocompleteCreate = () => {\n const { isHit, onCreate } = useAutocompleteContext()\n\n const getCreateProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref,\n role: \"option\",\n ...props,\n style: isHit ? style : undefined,\n \"aria-hidden\": ariaAttr(isHit),\n \"data-focus\": dataAttr(!isHit),\n tabIndex: -1,\n onClick: handlerAll(props.onClick, onCreate),\n }\n },\n [isHit, onCreate],\n )\n\n return { getCreateProps }\n}\n\nexport type UseAutocompleteCreateReturn = ReturnType<\n typeof useAutocompleteCreate\n>\n\nexport const useAutocompleteEmpty = () => {\n const { isEmpty, isHit } = useAutocompleteContext()\n\n const getEmptyProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const isHidden = isHit && !isEmpty\n\n const style: CSSProperties = {\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }\n\n return {\n ref,\n role: \"presentation\",\n ...props,\n style: isHidden ? style : undefined,\n \"aria-hidden\": ariaAttr(isHidden),\n tabIndex: -1,\n }\n },\n [isHit, isEmpty],\n )\n\n return { getEmptyProps }\n}\n\nexport type UseAutocompleteEmptyReturn = ReturnType<typeof useAutocompleteEmpty>\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, runRebirth?: boolean) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAUO;AACP,mBAA2C;;;ACV3C,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,uBAAuB;AACzB,QAAI,wCAAiB;AAgCd,IAAM,CAAC,sBAAsB,sBAAsB,QACxD,4BAAmC;AAAA,EACjC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;AD5BH,IAAM,iBAAiB,CAAC,WAAqC;AAnB7D;AAoBE,0CAAc,MAAM,KAAK,CAAC,GAAC,YAAO,aAAa,MAAM,MAA1B,mBAA6B,WAAW;AAAA;AAgD9D,IAAM,wBAAwB,CAAC,UAAsC;AApE5E;AAqEE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,uBAAuB;AAC3B,QAAM,WAAO,oBAAM;AACnB,QAAM,cAAU,qBAAsB,IAAI;AAC1C,MAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IAC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,EAAE,cAAc;AACzB;","names":["import_utils","props"]}
@@ -3,8 +3,8 @@ import {
3
3
  useAutocompleteCreate,
4
4
  useAutocompleteEmpty,
5
5
  useAutocompleteOption
6
- } from "./chunk-LCC3VNZV.mjs";
7
- import "./chunk-ZNO5RUVT.mjs";
6
+ } from "./chunk-2LP57WVB.mjs";
7
+ import "./chunk-TP5VZFO3.mjs";
8
8
  export {
9
9
  useAutocompleteCreate,
10
10
  useAutocompleteEmpty,
@@ -2,9 +2,9 @@ import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps, PropGetter } from '@yamada-ui/core';
3
3
  import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant';
4
4
  import * as react from 'react';
5
- import { ReactElement, FocusEvent, DOMAttributes, MouseEvent, ChangeEvent } from 'react';
5
+ import { ChangeEvent, ReactElement, FocusEvent, DOMAttributes, MouseEvent } from 'react';
6
6
  import { FormControlOptions } from '@yamada-ui/form-control';
7
- import { PopoverProps, ComboBoxProps } from '@yamada-ui/popover';
7
+ import { ComboBoxProps, PopoverProps } from '@yamada-ui/popover';
8
8
  import { Union } from '@yamada-ui/utils';
9
9
  import { AutocompleteOptionProps } from './autocomplete-option.mjs';
10
10
  import { AutocompleteOptionGroupProps } from './autocomplete-option-group.mjs';
@@ -95,7 +95,6 @@ interface UseAutocompleteBaseProps<T extends MaybeValue = string> extends ComboB
95
95
  interface UseAutocompleteProps<T extends MaybeValue = string> extends Omit<HTMLUIProps<"input">, "disabled" | "list" | "readOnly" | "required" | "size" | keyof UseAutocompleteBaseProps>, UseAutocompleteBaseProps<T> {
96
96
  }
97
97
  declare const useAutocomplete: <T extends MaybeValue = string>(props: UseAutocompleteProps<T>) => {
98
- id: string | undefined;
99
98
  allowCreate: boolean;
100
99
  allowFree: boolean;
101
100
  children: string | number | boolean | ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | undefined;
@@ -134,7 +133,6 @@ declare const useAutocomplete: <T extends MaybeValue = string>(props: UseAutocom
134
133
  isHit: boolean;
135
134
  isOpen: boolean;
136
135
  label: T | undefined;
137
- listRef: react.RefObject<HTMLUListElement>;
138
136
  omitSelectedValues: boolean;
139
137
  pickOptions: (value: string) => void;
140
138
  rebirthOptions: (runFocus?: boolean) => void;
@@ -2,9 +2,9 @@ import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps, PropGetter } from '@yamada-ui/core';
3
3
  import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant';
4
4
  import * as react from 'react';
5
- import { ReactElement, FocusEvent, DOMAttributes, MouseEvent, ChangeEvent } from 'react';
5
+ import { ChangeEvent, ReactElement, FocusEvent, DOMAttributes, MouseEvent } from 'react';
6
6
  import { FormControlOptions } from '@yamada-ui/form-control';
7
- import { PopoverProps, ComboBoxProps } from '@yamada-ui/popover';
7
+ import { ComboBoxProps, PopoverProps } from '@yamada-ui/popover';
8
8
  import { Union } from '@yamada-ui/utils';
9
9
  import { AutocompleteOptionProps } from './autocomplete-option.js';
10
10
  import { AutocompleteOptionGroupProps } from './autocomplete-option-group.js';
@@ -95,7 +95,6 @@ interface UseAutocompleteBaseProps<T extends MaybeValue = string> extends ComboB
95
95
  interface UseAutocompleteProps<T extends MaybeValue = string> extends Omit<HTMLUIProps<"input">, "disabled" | "list" | "readOnly" | "required" | "size" | keyof UseAutocompleteBaseProps>, UseAutocompleteBaseProps<T> {
96
96
  }
97
97
  declare const useAutocomplete: <T extends MaybeValue = string>(props: UseAutocompleteProps<T>) => {
98
- id: string | undefined;
99
98
  allowCreate: boolean;
100
99
  allowFree: boolean;
101
100
  children: string | number | boolean | ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | undefined;
@@ -134,7 +133,6 @@ declare const useAutocomplete: <T extends MaybeValue = string>(props: UseAutocom
134
133
  isHit: boolean;
135
134
  isOpen: boolean;
136
135
  label: T | undefined;
137
- listRef: react.RefObject<HTMLUListElement>;
138
136
  omitSelectedValues: boolean;
139
137
  pickOptions: (value: string) => void;
140
138
  rebirthOptions: (runFocus?: boolean) => void;
@@ -600,6 +600,7 @@ var flattenItems = (items) => {
600
600
  return filterItems(items).flat(Infinity);
601
601
  };
602
602
  var useAutocomplete = (props) => {
603
+ var _a;
603
604
  const {
604
605
  allowCreate = false,
605
606
  allowFree = false,
@@ -643,16 +644,8 @@ var useAutocomplete = (props) => {
643
644
  onSearch: onSearchProp,
644
645
  ...rest
645
646
  } = (0, import_form_control.useFormControlProps)(props);
646
- const {
647
- "aria-readonly": _ariaReadonly,
648
- onFocus: onFocusProp,
649
- ...formControlProps
650
- } = (0, import_utils7.pickObject)(rest, import_form_control.formControlProperties);
651
- const [containerProps, inputProps] = (0, import_utils7.splitObject)(rest, import_core5.layoutStyleProperties);
652
- const { id } = rest;
653
647
  const descendants = useAutocompleteDescendants();
654
648
  const containerRef = (0, import_react4.useRef)(null);
655
- const listRef = (0, import_react4.useRef)(null);
656
649
  const inputRef = (0, import_react4.useRef)(null);
657
650
  const timeoutIds = (0, import_react4.useRef)(/* @__PURE__ */ new Set([]));
658
651
  const isComposition = (0, import_react4.useRef)(false);
@@ -678,6 +671,12 @@ var useAutocomplete = (props) => {
678
671
  onClose: onCloseProp,
679
672
  onOpen: onOpenProp
680
673
  });
674
+ const {
675
+ "aria-readonly": _ariaReadonly,
676
+ onFocus: onFocusProp,
677
+ ...formControlProps
678
+ } = (0, import_utils7.pickObject)(rest, import_form_control.formControlProperties);
679
+ const [containerProps, inputProps] = (0, import_utils7.splitObject)(rest, import_core5.layoutStyleProperties);
681
680
  const isFocused = focusedIndex > -1;
682
681
  const isCreate = focusedIndex === -2 && allowCreate;
683
682
  const isMulti = (0, import_utils7.isArray)(value);
@@ -696,14 +695,15 @@ var useAutocomplete = (props) => {
696
695
  }
697
696
  const selectedValues = descendants.enabledValues(
698
697
  ({ node }) => {
699
- var _a;
700
- return isMulti && value.includes((_a = node.dataset.value) != null ? _a : "");
698
+ var _a2;
699
+ return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
701
700
  }
702
701
  );
703
702
  const selectedIndexes = selectedValues.map(({ index }) => index);
704
703
  const enabledValues = descendants.enabledValues(
705
704
  ({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
706
705
  );
706
+ const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
707
707
  const validChildren = (0, import_utils7.getValidChildren)(children);
708
708
  const computedChildren = (0, import_react4.useMemo)(
709
709
  () => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
@@ -733,8 +733,8 @@ var useAutocomplete = (props) => {
733
733
  if (inputRef.current) inputRef.current.focus();
734
734
  }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
735
735
  const onFocusFirst = (0, import_react4.useCallback)(() => {
736
- const id2 = setTimeout(() => {
737
- var _a;
736
+ const id = setTimeout(() => {
737
+ var _a2;
738
738
  if (isEmpty || isAllSelected) return;
739
739
  const first = descendants.enabledFirstValue(
740
740
  ({ node }) => "target" in node.dataset
@@ -745,13 +745,13 @@ var useAutocomplete = (props) => {
745
745
  } else {
746
746
  if (selectedIndexes.includes(first.index)) {
747
747
  const enabledFirst = enabledValues[0];
748
- setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
748
+ setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
749
749
  } else {
750
750
  setFocusedIndex(first.index);
751
751
  }
752
752
  }
753
753
  });
754
- timeoutIds.current.add(id2);
754
+ timeoutIds.current.add(id);
755
755
  }, [
756
756
  descendants,
757
757
  enabledValues,
@@ -762,8 +762,8 @@ var useAutocomplete = (props) => {
762
762
  selectedIndexes
763
763
  ]);
764
764
  const onFocusLast = (0, import_react4.useCallback)(() => {
765
- const id2 = setTimeout(() => {
766
- var _a;
765
+ const id = setTimeout(() => {
766
+ var _a2;
767
767
  if (isEmpty || isAllSelected) return;
768
768
  const last = descendants.enabledLastValue(
769
769
  ({ node }) => "target" in node.dataset
@@ -774,13 +774,13 @@ var useAutocomplete = (props) => {
774
774
  } else {
775
775
  if (selectedIndexes.includes(last.index)) {
776
776
  const enabledLast = enabledValues.reverse()[0];
777
- setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
777
+ setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
778
778
  } else {
779
779
  setFocusedIndex(last.index);
780
780
  }
781
781
  }
782
782
  });
783
- timeoutIds.current.add(id2);
783
+ timeoutIds.current.add(id);
784
784
  }, [
785
785
  descendants,
786
786
  enabledValues,
@@ -791,22 +791,22 @@ var useAutocomplete = (props) => {
791
791
  selectedIndexes
792
792
  ]);
793
793
  const onFocusSelected = (0, import_react4.useCallback)(() => {
794
- const id2 = setTimeout(() => {
794
+ const id = setTimeout(() => {
795
795
  const values = descendants.enabledValues();
796
796
  const selected = values.find(
797
797
  ({ node }) => {
798
- var _a;
799
- return !isMulti ? node.dataset.value === value : value.includes((_a = node.dataset.value) != null ? _a : "");
798
+ var _a2;
799
+ return !isMulti ? node.dataset.value === value : value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
800
800
  }
801
801
  );
802
802
  if (selected) setFocusedIndex(selected.index);
803
803
  });
804
- timeoutIds.current.add(id2);
804
+ timeoutIds.current.add(id);
805
805
  }, [descendants, isMulti, value]);
806
806
  const onFocusNext = (0, import_react4.useCallback)(
807
807
  (index = focusedIndex) => {
808
- const id2 = setTimeout(() => {
809
- var _a, _b;
808
+ const id = setTimeout(() => {
809
+ var _a2, _b;
810
810
  const next = descendants.enabledNextValue(
811
811
  index,
812
812
  ({ node }) => "target" in node.dataset
@@ -816,14 +816,14 @@ var useAutocomplete = (props) => {
816
816
  setFocusedIndex(next.index);
817
817
  } else {
818
818
  if (selectedIndexes.includes(next.index)) {
819
- const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
819
+ const enabledNext = (_a2 = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a2 : enabledValues[0];
820
820
  setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
821
821
  } else {
822
822
  setFocusedIndex(next.index);
823
823
  }
824
824
  }
825
825
  });
826
- timeoutIds.current.add(id2);
826
+ timeoutIds.current.add(id);
827
827
  },
828
828
  [
829
829
  descendants,
@@ -836,8 +836,8 @@ var useAutocomplete = (props) => {
836
836
  );
837
837
  const onFocusPrev = (0, import_react4.useCallback)(
838
838
  (index = focusedIndex) => {
839
- const id2 = setTimeout(() => {
840
- var _a, _b;
839
+ const id = setTimeout(() => {
840
+ var _a2, _b;
841
841
  const prev = descendants.enabledPrevValue(
842
842
  index,
843
843
  ({ node }) => "target" in node.dataset
@@ -847,14 +847,14 @@ var useAutocomplete = (props) => {
847
847
  setFocusedIndex(prev.index);
848
848
  } else {
849
849
  if (selectedIndexes.includes(prev.index)) {
850
- const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
850
+ const enabledPrev = (_a2 = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a2 : enabledValues[0];
851
851
  setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
852
852
  } else {
853
853
  setFocusedIndex(prev.index);
854
854
  }
855
855
  }
856
856
  });
857
- timeoutIds.current.add(id2);
857
+ timeoutIds.current.add(id);
858
858
  },
859
859
  [
860
860
  descendants,
@@ -873,8 +873,8 @@ var useAutocomplete = (props) => {
873
873
  let isHit2 = false;
874
874
  let isFocused2 = false;
875
875
  values.forEach(({ index, node }) => {
876
- var _a;
877
- if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
876
+ var _a2;
877
+ if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
878
878
  isHit2 = true;
879
879
  const isDisabled = "disabled" in node.dataset;
880
880
  node.dataset.target = "";
@@ -907,8 +907,8 @@ var useAutocomplete = (props) => {
907
907
  if (!values.length) return;
908
908
  const resolvedValues = (0, import_utils7.isArray)(newValue) ? newValue : [newValue];
909
909
  const selectedLabel = resolvedValues.map((value2) => {
910
- var _a, _b;
911
- const { node } = (_a = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a : {};
910
+ var _a2, _b;
911
+ const { node } = (_a2 = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a2 : {};
912
912
  if (node) {
913
913
  const { textContent } = (_b = Array.from(node.children).find(
914
914
  (child) => child.getAttribute("data-label") !== null
@@ -945,9 +945,9 @@ var useAutocomplete = (props) => {
945
945
  [isMulti, rebirthOptions, setValue]
946
946
  );
947
947
  const onSelect = (0, import_react4.useCallback)(() => {
948
- var _a, _b;
948
+ var _a2, _b;
949
949
  let enabledValue = descendants.value(focusedIndex);
950
- if ("disabled" in ((_a = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a : {}))
950
+ if ("disabled" in ((_a2 = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a2 : {}))
951
951
  enabledValue = void 0;
952
952
  if (!enabledValue) return;
953
953
  const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
@@ -985,8 +985,7 @@ var useAutocomplete = (props) => {
985
985
  isComposition.current = false;
986
986
  }, []);
987
987
  const onCreate = (0, import_react4.useCallback)(() => {
988
- var _a, _b;
989
- if (!listRef.current) return;
988
+ var _a2, _b;
990
989
  const newItem = { label: inputValue, value: inputValue };
991
990
  let newItems = [];
992
991
  if (resolvedItems) newItems = [...resolvedItems];
@@ -1001,7 +1000,7 @@ var useAutocomplete = (props) => {
1001
1000
  const targetItem = newItems[i];
1002
1001
  if (i !== -1 && targetItem && "items" in targetItem) {
1003
1002
  if (secondInsertPositionItem === "first") {
1004
- targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
1003
+ targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
1005
1004
  } else {
1006
1005
  targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
1007
1006
  }
@@ -1158,7 +1157,7 @@ var useAutocomplete = (props) => {
1158
1157
  setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
1159
1158
  }, [items]);
1160
1159
  (0, import_utils7.useUnmountEffect)(() => {
1161
- timeoutIds.current.forEach((id2) => clearTimeout(id2));
1160
+ timeoutIds.current.forEach((id) => clearTimeout(id));
1162
1161
  timeoutIds.current.clear();
1163
1162
  });
1164
1163
  (0, import_use_outside_click.useOutsideClick)({
@@ -1229,6 +1228,10 @@ var useAutocomplete = (props) => {
1229
1228
  const getFieldProps = (0, import_react4.useCallback)(
1230
1229
  (props2 = {}, ref = null) => ({
1231
1230
  ref,
1231
+ "aria-activedescendant": activedescendantId,
1232
+ "aria-autocomplete": "list",
1233
+ "aria-haspopup": "listbox",
1234
+ role: "combobox",
1232
1235
  tabIndex: -1,
1233
1236
  ...props2,
1234
1237
  ...formControlProps,
@@ -1238,6 +1241,7 @@ var useAutocomplete = (props) => {
1238
1241
  onKeyDown: (0, import_utils7.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
1239
1242
  }),
1240
1243
  [
1244
+ activedescendantId,
1241
1245
  formControlProps,
1242
1246
  placeholder,
1243
1247
  isOpen,
@@ -1248,7 +1252,6 @@ var useAutocomplete = (props) => {
1248
1252
  ]
1249
1253
  );
1250
1254
  return {
1251
- id,
1252
1255
  allowCreate,
1253
1256
  allowFree,
1254
1257
  children: children != null ? children : computedChildren,
@@ -1263,7 +1266,6 @@ var useAutocomplete = (props) => {
1263
1266
  isHit,
1264
1267
  isOpen,
1265
1268
  label,
1266
- listRef,
1267
1269
  omitSelectedValues,
1268
1270
  pickOptions,
1269
1271
  rebirthOptions,
@@ -1291,23 +1293,15 @@ var useAutocomplete = (props) => {
1291
1293
  };
1292
1294
  };
1293
1295
  var useAutocompleteInput = () => {
1294
- var _a, _b;
1295
1296
  const {
1296
- id,
1297
- focusedIndex,
1298
1297
  inputRef,
1299
1298
  isAllSelected,
1300
- isOpen,
1301
- listRef,
1302
1299
  formControlProps,
1303
1300
  inputProps,
1304
1301
  onCompositionEnd,
1305
1302
  onCompositionStart,
1306
1303
  onSearch
1307
1304
  } = useAutocompleteContext();
1308
- const descendants = useAutocompleteDescendantsContext();
1309
- const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1310
- const listId = (_b = listRef.current) == null ? void 0 : _b.id;
1311
1305
  (0, import_utils7.useUpdateEffect)(() => {
1312
1306
  if (isAllSelected && inputRef.current) inputRef.current.blur();
1313
1307
  }, [isAllSelected]);
@@ -1316,19 +1310,12 @@ var useAutocompleteInput = () => {
1316
1310
  return {
1317
1311
  ref: (0, import_utils7.mergeRefs)(inputRef, ref),
1318
1312
  ...formControlProps,
1319
- "aria-activedescendant": activedescendantId,
1320
- "aria-autocomplete": "list",
1321
- "aria-controls": listId,
1322
- "aria-expanded": isOpen,
1323
- "aria-haspopup": "listbox",
1324
1313
  autoCapitalize: "none",
1325
1314
  autoComplete: "off",
1326
- role: "combobox",
1327
1315
  spellCheck: "false",
1328
1316
  tabIndex: isAllSelected ? -1 : 0,
1329
1317
  ...inputProps,
1330
1318
  ...props,
1331
- id,
1332
1319
  cursor: formControlProps.readOnly ? "default" : "text",
1333
1320
  pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1334
1321
  onChange: (0, import_utils7.handlerAll)(props.onChange, onSearch),
@@ -1345,13 +1332,9 @@ var useAutocompleteInput = () => {
1345
1332
  };
1346
1333
  },
1347
1334
  [
1348
- listId,
1349
- activedescendantId,
1350
- isOpen,
1351
1335
  inputProps,
1352
1336
  inputRef,
1353
1337
  formControlProps,
1354
- id,
1355
1338
  isAllSelected,
1356
1339
  onSearch,
1357
1340
  onCompositionStart,