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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. package/dist/autocomplete-context.d.mts +0 -1
  2. package/dist/autocomplete-context.d.ts +0 -1
  3. package/dist/autocomplete-context.js.map +1 -1
  4. package/dist/autocomplete-context.mjs +1 -1
  5. package/dist/autocomplete-create.js.map +1 -1
  6. package/dist/autocomplete-create.mjs +4 -4
  7. package/dist/autocomplete-empty.js.map +1 -1
  8. package/dist/autocomplete-empty.mjs +4 -4
  9. package/dist/autocomplete-icon.js.map +1 -1
  10. package/dist/autocomplete-icon.mjs +2 -2
  11. package/dist/autocomplete-list.js +22 -15
  12. package/dist/autocomplete-list.js.map +1 -1
  13. package/dist/autocomplete-list.mjs +3 -3
  14. package/dist/autocomplete-option-group.js.map +1 -1
  15. package/dist/autocomplete-option-group.mjs +3 -3
  16. package/dist/autocomplete-option.js +10 -6
  17. package/dist/autocomplete-option.js.map +1 -1
  18. package/dist/autocomplete-option.mjs +4 -4
  19. package/dist/autocomplete.js +78 -84
  20. package/dist/autocomplete.js.map +1 -1
  21. package/dist/autocomplete.mjs +12 -12
  22. package/dist/{chunk-JYPMXZG4.mjs → chunk-2CVB4NO5.mjs} +7 -7
  23. package/dist/{chunk-3A2HEULI.mjs → chunk-2LP57WVB.mjs} +12 -8
  24. package/dist/chunk-2LP57WVB.mjs.map +1 -0
  25. package/dist/{chunk-PTPJFYGI.mjs → chunk-4GVV3HBE.mjs} +29 -13
  26. package/dist/chunk-4GVV3HBE.mjs.map +1 -0
  27. package/dist/{chunk-6OTUOEYS.mjs → chunk-7QCZ5NGS.mjs} +2 -2
  28. package/dist/{chunk-PU6HFINM.mjs → chunk-ABCTEZN5.mjs} +3 -3
  29. package/dist/{chunk-NOSATNDY.mjs → chunk-IFH3PPSD.mjs} +10 -8
  30. package/dist/chunk-IFH3PPSD.mjs.map +1 -0
  31. package/dist/{chunk-REPBXBG3.mjs → chunk-LIBFONYN.mjs} +7 -10
  32. package/dist/chunk-LIBFONYN.mjs.map +1 -0
  33. package/dist/{chunk-2UKLSSUA.mjs → chunk-PWV7X7G6.mjs} +4 -4
  34. package/dist/{chunk-G6SC44LI.mjs → chunk-RK5E5J5E.mjs} +4 -4
  35. package/dist/{chunk-ZNO5RUVT.mjs → chunk-TP5VZFO3.mjs} +1 -1
  36. package/dist/chunk-TP5VZFO3.mjs.map +1 -0
  37. package/dist/{chunk-CMFJUJJW.mjs → chunk-UX5QECNB.mjs} +2 -2
  38. package/dist/{chunk-6II6KCIJ.mjs → chunk-YPKDYYEV.mjs} +4 -4
  39. package/dist/{chunk-75VF5Q5W.mjs → chunk-ZR77IT3O.mjs} +51 -69
  40. package/dist/chunk-ZR77IT3O.mjs.map +1 -0
  41. package/dist/index.js +81 -85
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +13 -13
  44. package/dist/multi-autocomplete.d.mts +8 -0
  45. package/dist/multi-autocomplete.d.ts +8 -0
  46. package/dist/multi-autocomplete.js +81 -85
  47. package/dist/multi-autocomplete.js.map +1 -1
  48. package/dist/multi-autocomplete.mjs +12 -12
  49. package/dist/use-autocomplete-list.d.mts +2 -1
  50. package/dist/use-autocomplete-list.d.ts +2 -1
  51. package/dist/use-autocomplete-list.js +19 -9
  52. package/dist/use-autocomplete-list.js.map +1 -1
  53. package/dist/use-autocomplete-list.mjs +2 -2
  54. package/dist/use-autocomplete-option-group.js.map +1 -1
  55. package/dist/use-autocomplete-option-group.mjs +2 -2
  56. package/dist/use-autocomplete-option.d.mts +16 -0
  57. package/dist/use-autocomplete-option.d.ts +16 -0
  58. package/dist/use-autocomplete-option.js +10 -6
  59. package/dist/use-autocomplete-option.js.map +1 -1
  60. package/dist/use-autocomplete-option.mjs +2 -2
  61. package/dist/use-autocomplete.d.mts +3 -5
  62. package/dist/use-autocomplete.d.ts +3 -5
  63. package/dist/use-autocomplete.js +56 -69
  64. package/dist/use-autocomplete.js.map +1 -1
  65. package/dist/use-autocomplete.mjs +7 -7
  66. package/package.json +4 -4
  67. package/dist/chunk-3A2HEULI.mjs.map +0 -1
  68. package/dist/chunk-75VF5Q5W.mjs.map +0 -1
  69. package/dist/chunk-NOSATNDY.mjs.map +0 -1
  70. package/dist/chunk-PTPJFYGI.mjs.map +0 -1
  71. package/dist/chunk-REPBXBG3.mjs.map +0 -1
  72. package/dist/chunk-ZNO5RUVT.mjs.map +0 -1
  73. /package/dist/{chunk-JYPMXZG4.mjs.map → chunk-2CVB4NO5.mjs.map} +0 -0
  74. /package/dist/{chunk-6OTUOEYS.mjs.map → chunk-7QCZ5NGS.mjs.map} +0 -0
  75. /package/dist/{chunk-PU6HFINM.mjs.map → chunk-ABCTEZN5.mjs.map} +0 -0
  76. /package/dist/{chunk-2UKLSSUA.mjs.map → chunk-PWV7X7G6.mjs.map} +0 -0
  77. /package/dist/{chunk-G6SC44LI.mjs.map → chunk-RK5E5J5E.mjs.map} +0 -0
  78. /package/dist/{chunk-CMFJUJJW.mjs.map → chunk-UX5QECNB.mjs.map} +0 -0
  79. /package/dist/{chunk-6II6KCIJ.mjs.map → chunk-YPKDYYEV.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/autocomplete-option.tsx","../src/autocomplete-context.ts","../src/autocomplete-icon.tsx","../src/use-autocomplete-option.ts"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { ReactElement } from \"react\"\nimport type { UseAutocompleteOptionProps } from \"./use-autocomplete-option\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\nimport { AutocompleteItemIcon } from \"./autocomplete-icon\"\nimport { useAutocompleteOption } from \"./use-autocomplete-option\"\n\ninterface AutocompleteOptionOptions {\n /**\n * The autocomplete option icon to use.\n */\n icon?: null | ReactElement\n}\n\nexport interface AutocompleteOptionProps\n extends UseAutocompleteOptionProps,\n AutocompleteOptionOptions {}\n\nexport const AutocompleteOption = forwardRef<AutocompleteOptionProps, \"div\">(\n ({ className, icon, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n const { children, customIcon, isSelected, getOptionProps } =\n useAutocompleteOption(rest)\n\n icon ??= customIcon\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n color: \"inherit\",\n display: \"flex\",\n flex: \"0 0 auto\",\n gap: \"0.75rem\",\n outline: 0,\n textAlign: \"start\",\n textDecoration: \"none\",\n userSelect: \"none\",\n width: \"100%\",\n ...styles.item,\n }\n\n return (\n <ui.div\n className={cx(\"ui-autocomplete__item\", className)}\n __css={css}\n {...getOptionProps({}, ref)}\n >\n {icon !== null ? (\n <AutocompleteItemIcon opacity={isSelected ? 1 : 0}>\n {icon || <AutocompleteCheckIcon />}\n </AutocompleteItemIcon>\n ) : null}\n\n <ui.span style={{ flex: 1 }} data-label>\n {children}\n </ui.span>\n </ui.div>\n )\n },\n)\n\nAutocompleteOption.displayName = \"AutocompleteOption\"\nAutocompleteOption.__ui__ = \"AutocompleteOption\"\n\nconst AutocompleteCheckIcon: FC = () => (\n <svg height=\"1em\" viewBox=\"0 0 14 14\" width=\"1em\">\n <polygon\n fill=\"currentColor\"\n points=\"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039\"\n />\n </svg>\n)\n\nAutocompleteCheckIcon.displayName = \"AutocompleteCheckIcon\"\nAutocompleteCheckIcon.__ui__ = \"AutocompleteCheckIcon\"\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","import type { CSSUIObject, FC, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { HTMLAttributes } from \"react\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { ChevronIcon, CloseIcon } from \"@yamada-ui/icon\"\nimport { useClickable } from \"@yamada-ui/use-clickable\"\nimport { cx, getValidChildren, isValidElement } from \"@yamada-ui/utils\"\nimport { cloneElement, useRef } from \"react\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\n\nexport interface AutocompleteIconProps extends HTMLUIProps {}\n\nexport const AutocompleteIcon = forwardRef<AutocompleteIconProps, \"div\">(\n ({ className, children, __css, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n cursor: \"pointer\",\n display: \"inline-flex\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n ...styles.icon,\n ...__css,\n }\n\n const validChildren = getValidChildren(children)\n\n const cloneChildren = validChildren.map((child) =>\n cloneElement(child, {\n style: {\n color: \"currentColor\",\n maxHeight: \"1em\",\n maxWidth: \"1em\",\n },\n \"aria-hidden\": true,\n focusable: false,\n }),\n )\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-autocomplete__icon\", className)}\n __css={css}\n {...rest}\n >\n {isValidElement(children) ? cloneChildren : <ChevronIcon />}\n </ui.div>\n )\n },\n)\n\nAutocompleteIcon.displayName = \"AutocompleteIcon\"\nAutocompleteIcon.__ui__ = \"AutocompleteIcon\"\n\nexport interface AutocompleteClearIconProps extends AutocompleteIconProps {\n disabled?: boolean\n}\n\nexport const AutocompleteClearIcon: FC<AutocompleteClearIconProps> = ({\n className,\n children,\n ...props\n}) => {\n const ref = useRef<HTMLDivElement>(null)\n const { styles } = useAutocompleteContext()\n\n const isDisabled = props.disabled\n\n const rest = useClickable({\n ref,\n isDisabled,\n ...(props as HTMLAttributes<HTMLElement>),\n })\n\n return (\n <AutocompleteIcon\n className={cx(\"ui-autocomplete__icon--clear\", className)}\n aria-label=\"Clear value\"\n __css={styles.clearIcon}\n {...rest}\n >\n {children ?? <CloseIcon h=\"0.5em\" w=\"0.5em\" />}\n </AutocompleteIcon>\n )\n}\n\nAutocompleteClearIcon.displayName = \"AutocompleteClearIcon\"\nAutocompleteClearIcon.__ui__ = \"AutocompleteClearIcon\"\n\nexport interface AutocompleteItemIconProps extends HTMLUIProps<\"span\"> {}\n\nexport const AutocompleteItemIcon = forwardRef<\n AutocompleteItemIconProps,\n \"span\"\n>(({ className, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"inline-flex\",\n flexShrink: 0,\n fontSize: \"0.85em\",\n justifyContent: \"center\",\n ...styles.itemIcon,\n }\n\n return (\n <ui.span\n ref={ref}\n className={cx(\"ui-autocomplete__item__icon\", className)}\n __css={css}\n {...rest}\n />\n )\n})\n\nAutocompleteItemIcon.displayName = \"AutocompleteItemIcon\"\nAutocompleteItemIcon.__ui__ = \"AutocompleteItemIcon\"\n","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 isDisabled?: boolean\n /**\n * If `true`, the autocomplete option will be focusable.\n *\n * @default false\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 icon: customIcon,\n isDisabled,\n isFocusable,\n value: optionValue,\n ...computedProps\n } = { ...optionProps, ...props }\n const trulyDisabled = !!isDisabled && !isFocusable\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 (isDisabled || !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 isDisabled,\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(isDisabled),\n \"aria-hidden\": ariaAttr(isHidden),\n \"aria-selected\": isSelected,\n \"data-disabled\": dataAttr(isDisabled),\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 isDisabled,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,eAA+B;AAC/B,IAAAC,gBAAmB;;;ACDnB,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;;;AC9CH,kBAA+B;AAC/B,kBAAuC;AACvC,2BAA6B;AAC7B,IAAAC,gBAAqD;AACrD,mBAAqC;AA2Ce;AAtC7C,IAAM,uBAAmB;AAAA,EAC9B,CAAC,EAAE,WAAW,UAAU,OAAO,GAAG,KAAK,GAAG,QAAQ;AAChD,UAAM,EAAE,OAAO,IAAI,uBAAuB;AAE1C,UAAM,MAAmB;AAAA,MACvB,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,UAAU;AAAA,MACV,KAAK;AAAA,MACL,WAAW;AAAA,MACX,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,IACL;AAEA,UAAM,oBAAgB,gCAAiB,QAAQ;AAE/C,UAAM,gBAAgB,cAAc;AAAA,MAAI,CAAC,cACvC,2BAAa,OAAO;AAAA,QAClB,OAAO;AAAA,UACL,OAAO;AAAA,UACP,WAAW;AAAA,UACX,UAAU;AAAA,QACZ;AAAA,QACA,eAAe;AAAA,QACf,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAEA,WACE;AAAA,MAAC,eAAG;AAAA,MAAH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A,mBAAmB,cAAc;AACjC,mBAAmB,SAAS;AAE5B,IAAM,wBAA4B,MAChC,6CAAC,SAAI,QAAO,OAAM,SAAQ,aAAY,OAAM,OAC1C;AAAA,EAAC;AAAA;AAAA,IACC,MAAK;AAAA,IACL,QAAO;AAAA;AACT,GACF;AAGF,sBAAsB,cAAc;AACpC,sBAAsB,SAAS;","names":["import_core","import_utils","import_utils","import_utils","import_react","props","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/autocomplete-option.tsx","../src/autocomplete-context.ts","../src/autocomplete-icon.tsx","../src/use-autocomplete-option.ts"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { ReactElement } from \"react\"\nimport type { UseAutocompleteOptionProps } from \"./use-autocomplete-option\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\nimport { AutocompleteItemIcon } from \"./autocomplete-icon\"\nimport { useAutocompleteOption } from \"./use-autocomplete-option\"\n\ninterface AutocompleteOptionOptions {\n /**\n * The autocomplete option icon to use.\n */\n icon?: null | ReactElement\n}\n\nexport interface AutocompleteOptionProps\n extends UseAutocompleteOptionProps,\n AutocompleteOptionOptions {}\n\nexport const AutocompleteOption = forwardRef<AutocompleteOptionProps, \"div\">(\n ({ className, icon, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n const { children, customIcon, isSelected, getOptionProps } =\n useAutocompleteOption(rest)\n\n icon ??= customIcon\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n color: \"inherit\",\n display: \"flex\",\n flex: \"0 0 auto\",\n gap: \"0.75rem\",\n outline: 0,\n textAlign: \"start\",\n textDecoration: \"none\",\n userSelect: \"none\",\n width: \"100%\",\n ...styles.item,\n }\n\n return (\n <ui.div\n className={cx(\"ui-autocomplete__item\", className)}\n __css={css}\n {...getOptionProps({}, ref)}\n >\n {icon !== null ? (\n <AutocompleteItemIcon opacity={isSelected ? 1 : 0}>\n {icon || <AutocompleteCheckIcon />}\n </AutocompleteItemIcon>\n ) : null}\n\n <ui.span style={{ flex: 1 }} data-label>\n {children}\n </ui.span>\n </ui.div>\n )\n },\n)\n\nAutocompleteOption.displayName = \"AutocompleteOption\"\nAutocompleteOption.__ui__ = \"AutocompleteOption\"\n\nconst AutocompleteCheckIcon: FC = () => (\n <svg height=\"1em\" viewBox=\"0 0 14 14\" width=\"1em\">\n <polygon\n fill=\"currentColor\"\n points=\"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039\"\n />\n </svg>\n)\n\nAutocompleteCheckIcon.displayName = \"AutocompleteCheckIcon\"\nAutocompleteCheckIcon.__ui__ = \"AutocompleteCheckIcon\"\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","import type { CSSUIObject, FC, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { HTMLAttributes } from \"react\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { ChevronIcon, CloseIcon } from \"@yamada-ui/icon\"\nimport { useClickable } from \"@yamada-ui/use-clickable\"\nimport { cx, getValidChildren, isValidElement } from \"@yamada-ui/utils\"\nimport { cloneElement, useRef } from \"react\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\n\nexport interface AutocompleteIconProps extends HTMLUIProps {}\n\nexport const AutocompleteIcon = forwardRef<AutocompleteIconProps, \"div\">(\n ({ className, children, __css, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n cursor: \"pointer\",\n display: \"inline-flex\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n ...styles.icon,\n ...__css,\n }\n\n const validChildren = getValidChildren(children)\n\n const cloneChildren = validChildren.map((child) =>\n cloneElement(child, {\n style: {\n color: \"currentColor\",\n maxHeight: \"1em\",\n maxWidth: \"1em\",\n },\n \"aria-hidden\": true,\n focusable: false,\n }),\n )\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-autocomplete__icon\", className)}\n __css={css}\n {...rest}\n >\n {isValidElement(children) ? cloneChildren : <ChevronIcon />}\n </ui.div>\n )\n },\n)\n\nAutocompleteIcon.displayName = \"AutocompleteIcon\"\nAutocompleteIcon.__ui__ = \"AutocompleteIcon\"\n\nexport interface AutocompleteClearIconProps extends AutocompleteIconProps {\n disabled?: boolean\n}\n\nexport const AutocompleteClearIcon: FC<AutocompleteClearIconProps> = ({\n className,\n children,\n ...props\n}) => {\n const ref = useRef<HTMLDivElement>(null)\n const { styles } = useAutocompleteContext()\n\n const isDisabled = props.disabled\n\n const rest = useClickable({\n ref,\n isDisabled,\n ...(props as HTMLAttributes<HTMLElement>),\n })\n\n return (\n <AutocompleteIcon\n className={cx(\"ui-autocomplete__icon--clear\", className)}\n aria-label=\"Clear value\"\n __css={styles.clearIcon}\n {...rest}\n >\n {children ?? <CloseIcon h=\"0.5em\" w=\"0.5em\" />}\n </AutocompleteIcon>\n )\n}\n\nAutocompleteClearIcon.displayName = \"AutocompleteClearIcon\"\nAutocompleteClearIcon.__ui__ = \"AutocompleteClearIcon\"\n\nexport interface AutocompleteItemIconProps extends HTMLUIProps<\"span\"> {}\n\nexport const AutocompleteItemIcon = forwardRef<\n AutocompleteItemIconProps,\n \"span\"\n>(({ className, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"inline-flex\",\n flexShrink: 0,\n fontSize: \"0.85em\",\n justifyContent: \"center\",\n ...styles.itemIcon,\n }\n\n return (\n <ui.span\n ref={ref}\n className={cx(\"ui-autocomplete__item__icon\", className)}\n __css={css}\n {...rest}\n />\n )\n})\n\nAutocompleteItemIcon.displayName = \"AutocompleteItemIcon\"\nAutocompleteItemIcon.__ui__ = \"AutocompleteItemIcon\"\n","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,eAA+B;AAC/B,IAAAC,gBAAmB;;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;","names":["import_core","import_utils","import_utils","import_utils","import_react","props","import_jsx_runtime"]}
@@ -1,10 +1,10 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteOption
4
- } from "./chunk-2UKLSSUA.mjs";
5
- import "./chunk-3A2HEULI.mjs";
6
- import "./chunk-6OTUOEYS.mjs";
7
- import "./chunk-ZNO5RUVT.mjs";
4
+ } from "./chunk-PWV7X7G6.mjs";
5
+ import "./chunk-2LP57WVB.mjs";
6
+ import "./chunk-7QCZ5NGS.mjs";
7
+ import "./chunk-TP5VZFO3.mjs";
8
8
  export {
9
9
  AutocompleteOption
10
10
  };
@@ -171,13 +171,17 @@ var useAutocompleteOption = (props) => {
171
171
  id,
172
172
  children,
173
173
  closeOnSelect: customCloseOnSelect,
174
+ disabled,
175
+ focusable,
174
176
  icon: customIcon,
175
177
  isDisabled,
176
178
  isFocusable,
177
179
  value: optionValue,
178
180
  ...computedProps
179
181
  } = { ...optionProps, ...props };
180
- const trulyDisabled = !!isDisabled && !isFocusable;
182
+ disabled != null ? disabled : disabled = isDisabled;
183
+ focusable != null ? focusable : focusable = isFocusable;
184
+ const trulyDisabled = !!disabled && !focusable;
181
185
  const { descendants, index, register } = useAutocompleteDescendant({
182
186
  disabled: trulyDisabled
183
187
  });
@@ -203,7 +207,7 @@ var useAutocompleteOption = (props) => {
203
207
  const onClick = (0, import_react2.useCallback)(
204
208
  (ev) => {
205
209
  ev.stopPropagation();
206
- if (isDisabled || !isTargetOption(ev.currentTarget)) {
210
+ if (disabled || !isTargetOption(ev.currentTarget)) {
207
211
  if (inputRef.current) inputRef.current.focus();
208
212
  return;
209
213
  }
@@ -217,7 +221,7 @@ var useAutocompleteOption = (props) => {
217
221
  isDuplicated,
218
222
  onFocusNext,
219
223
  omitSelectedValues,
220
- isDisabled,
224
+ disabled,
221
225
  optionValue,
222
226
  setFocusedIndex,
223
227
  index,
@@ -249,10 +253,10 @@ var useAutocompleteOption = (props) => {
249
253
  ...props2,
250
254
  id,
251
255
  style: isHidden ? style : void 0,
252
- "aria-disabled": (0, import_utils3.ariaAttr)(isDisabled),
256
+ "aria-disabled": (0, import_utils3.ariaAttr)(disabled),
253
257
  "aria-hidden": (0, import_utils3.ariaAttr)(isHidden),
254
258
  "aria-selected": isSelected,
255
- "data-disabled": (0, import_utils3.dataAttr)(isDisabled),
259
+ "data-disabled": (0, import_utils3.dataAttr)(disabled),
256
260
  "data-duplicated": (0, import_utils3.dataAttr)(isDuplicated),
257
261
  "data-focus": (0, import_utils3.dataAttr)(isFocused),
258
262
  "data-target": (0, import_utils3.dataAttr)(true),
@@ -266,7 +270,7 @@ var useAutocompleteOption = (props) => {
266
270
  isDuplicated,
267
271
  optionValue,
268
272
  computedProps,
269
- isDisabled,
273
+ disabled,
270
274
  isFocused,
271
275
  isSelected,
272
276
  isTarget,
@@ -449,9 +453,9 @@ var import_utils7 = require("@yamada-ui/utils");
449
453
  var import_utils6 = require("@yamada-ui/utils");
450
454
  var import_react3 = require("react");
451
455
  var useAutocompleteList = () => {
452
- const { focusedIndex, isOpen, listRef, rebirthOptions, value } = useAutocompleteContext();
456
+ const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
453
457
  const descendants = useAutocompleteDescendantsContext();
454
- const uuid = (0, import_react3.useId)();
458
+ const listRef = (0, import_react3.useRef)(null);
455
459
  const beforeFocusedIndex = (0, import_react3.useRef)(-1);
456
460
  const selectedValue = descendants.value(focusedIndex);
457
461
  const isMulti = (0, import_utils6.isArray)(value);
@@ -487,21 +491,31 @@ var useAutocompleteList = () => {
487
491
  (0, import_utils6.useUpdateEffect)(() => {
488
492
  if (!isOpen) beforeFocusedIndex.current = -1;
489
493
  }, [isOpen]);
494
+ const getContainerProps = (0, import_react3.useCallback)(
495
+ (props = {}, ref = null) => ({
496
+ ref,
497
+ "aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
498
+ role: "listbox",
499
+ ...props,
500
+ onAnimationComplete: (0, import_utils6.handlerAll)(
501
+ props.onAnimationComplete,
502
+ onAnimationComplete
503
+ )
504
+ }),
505
+ [isMulti, onAnimationComplete]
506
+ );
490
507
  const getListProps = (0, import_react3.useCallback)(
491
- ({ id, ...props } = {}, ref = null) => ({
492
- id: id != null ? id : uuid,
508
+ (props = {}, ref = null) => ({
493
509
  ref: (0, import_utils6.mergeRefs)(listRef, ref),
494
- "aria-multiselectable": (0, import_utils6.ariaAttr)(isMulti),
495
510
  position: "relative",
496
- role: "listbox",
497
511
  tabIndex: -1,
498
512
  ...props
499
513
  }),
500
- [listRef, uuid, isMulti]
514
+ [listRef]
501
515
  );
502
516
  return {
503
- getListProps,
504
- onAnimationComplete
517
+ getContainerProps,
518
+ getListProps
505
519
  };
506
520
  };
507
521
 
@@ -524,7 +538,7 @@ var AutocompleteList = (0, import_core4.forwardRef)(
524
538
  }, ref) => {
525
539
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
526
540
  const { styles } = useAutocompleteContext();
527
- const { getListProps, onAnimationComplete } = useAutocompleteList();
541
+ const { getContainerProps, getListProps } = useAutocompleteList();
528
542
  width != null ? width : width = w;
529
543
  width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
530
544
  minWidth != null ? minWidth : minWidth = minW;
@@ -534,16 +548,13 @@ var AutocompleteList = (0, import_core4.forwardRef)(
534
548
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
535
549
  import_popover.PopoverContent,
536
550
  {
551
+ as: "div",
537
552
  className: "ui-autocomplete__popover",
538
553
  maxWidth,
539
554
  minWidth,
540
555
  width,
541
556
  __css: { ...styles.content, maxWidth, minWidth, width },
542
- ...contentProps,
543
- onAnimationComplete: (0, import_utils7.handlerAll)(
544
- contentProps == null ? void 0 : contentProps.onAnimationComplete,
545
- onAnimationComplete
546
- ),
557
+ ...getContainerProps(contentProps),
547
558
  children: [
548
559
  header ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
549
560
  import_core4.ui.header,
@@ -883,8 +894,8 @@ var defaultFormat = (value) => {
883
894
  var flattenItems = (items) => {
884
895
  const filterItems = (items2) => items2.map((item) => {
885
896
  var _a;
886
- const { isDisabled, isFocusable } = item;
887
- const trulyDisabled = !!isDisabled && !isFocusable;
897
+ const { disabled, focusable } = item;
898
+ const trulyDisabled = !!disabled && !focusable;
888
899
  if (trulyDisabled) return;
889
900
  if ("items" in item) {
890
901
  return filterItems((_a = item.items) != null ? _a : []);
@@ -895,6 +906,7 @@ var flattenItems = (items) => {
895
906
  return filterItems(items).flat(Infinity);
896
907
  };
897
908
  var useAutocomplete = (props) => {
909
+ var _a;
898
910
  const {
899
911
  allowCreate = false,
900
912
  allowFree = false,
@@ -938,16 +950,8 @@ var useAutocomplete = (props) => {
938
950
  onSearch: onSearchProp,
939
951
  ...rest
940
952
  } = (0, import_form_control.useFormControlProps)(props);
941
- const {
942
- "aria-readonly": _ariaReadonly,
943
- onFocus: onFocusProp,
944
- ...formControlProps
945
- } = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
946
- const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
947
- const { id } = rest;
948
953
  const descendants = useAutocompleteDescendants();
949
954
  const containerRef = (0, import_react5.useRef)(null);
950
- const listRef = (0, import_react5.useRef)(null);
951
955
  const inputRef = (0, import_react5.useRef)(null);
952
956
  const timeoutIds = (0, import_react5.useRef)(/* @__PURE__ */ new Set([]));
953
957
  const isComposition = (0, import_react5.useRef)(false);
@@ -973,6 +977,12 @@ var useAutocomplete = (props) => {
973
977
  onClose: onCloseProp,
974
978
  onOpen: onOpenProp
975
979
  });
980
+ const {
981
+ "aria-readonly": _ariaReadonly,
982
+ onFocus: onFocusProp,
983
+ ...formControlProps
984
+ } = (0, import_utils11.pickObject)(rest, import_form_control.formControlProperties);
985
+ const [containerProps, inputProps] = (0, import_utils11.splitObject)(rest, import_core8.layoutStyleProperties);
976
986
  const isFocused = focusedIndex > -1;
977
987
  const isCreate = focusedIndex === -2 && allowCreate;
978
988
  const isMulti = (0, import_utils11.isArray)(value);
@@ -991,14 +1001,15 @@ var useAutocomplete = (props) => {
991
1001
  }
992
1002
  const selectedValues = descendants.enabledValues(
993
1003
  ({ node }) => {
994
- var _a;
995
- return isMulti && value.includes((_a = node.dataset.value) != null ? _a : "");
1004
+ var _a2;
1005
+ return isMulti && value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
996
1006
  }
997
1007
  );
998
1008
  const selectedIndexes = selectedValues.map(({ index }) => index);
999
1009
  const enabledValues = descendants.enabledValues(
1000
1010
  ({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
1001
1011
  );
1012
+ const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1002
1013
  const validChildren = (0, import_utils11.getValidChildren)(children);
1003
1014
  const computedChildren = (0, import_react5.useMemo)(
1004
1015
  () => resolvedItems == null ? void 0 : resolvedItems.map((item, index) => {
@@ -1028,8 +1039,8 @@ var useAutocomplete = (props) => {
1028
1039
  if (inputRef.current) inputRef.current.focus();
1029
1040
  }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
1030
1041
  const onFocusFirst = (0, import_react5.useCallback)(() => {
1031
- const id2 = setTimeout(() => {
1032
- var _a;
1042
+ const id = setTimeout(() => {
1043
+ var _a2;
1033
1044
  if (isEmpty || isAllSelected) return;
1034
1045
  const first = descendants.enabledFirstValue(
1035
1046
  ({ node }) => "target" in node.dataset
@@ -1040,13 +1051,13 @@ var useAutocomplete = (props) => {
1040
1051
  } else {
1041
1052
  if (selectedIndexes.includes(first.index)) {
1042
1053
  const enabledFirst = enabledValues[0];
1043
- setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
1054
+ setFocusedIndex((_a2 = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a2 : -1);
1044
1055
  } else {
1045
1056
  setFocusedIndex(first.index);
1046
1057
  }
1047
1058
  }
1048
1059
  });
1049
- timeoutIds.current.add(id2);
1060
+ timeoutIds.current.add(id);
1050
1061
  }, [
1051
1062
  descendants,
1052
1063
  enabledValues,
@@ -1057,8 +1068,8 @@ var useAutocomplete = (props) => {
1057
1068
  selectedIndexes
1058
1069
  ]);
1059
1070
  const onFocusLast = (0, import_react5.useCallback)(() => {
1060
- const id2 = setTimeout(() => {
1061
- var _a;
1071
+ const id = setTimeout(() => {
1072
+ var _a2;
1062
1073
  if (isEmpty || isAllSelected) return;
1063
1074
  const last = descendants.enabledLastValue(
1064
1075
  ({ node }) => "target" in node.dataset
@@ -1069,13 +1080,13 @@ var useAutocomplete = (props) => {
1069
1080
  } else {
1070
1081
  if (selectedIndexes.includes(last.index)) {
1071
1082
  const enabledLast = enabledValues.reverse()[0];
1072
- setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
1083
+ setFocusedIndex((_a2 = enabledLast == null ? void 0 : enabledLast.index) != null ? _a2 : -1);
1073
1084
  } else {
1074
1085
  setFocusedIndex(last.index);
1075
1086
  }
1076
1087
  }
1077
1088
  });
1078
- timeoutIds.current.add(id2);
1089
+ timeoutIds.current.add(id);
1079
1090
  }, [
1080
1091
  descendants,
1081
1092
  enabledValues,
@@ -1086,22 +1097,22 @@ var useAutocomplete = (props) => {
1086
1097
  selectedIndexes
1087
1098
  ]);
1088
1099
  const onFocusSelected = (0, import_react5.useCallback)(() => {
1089
- const id2 = setTimeout(() => {
1100
+ const id = setTimeout(() => {
1090
1101
  const values = descendants.enabledValues();
1091
1102
  const selected = values.find(
1092
1103
  ({ node }) => {
1093
- var _a;
1094
- return !isMulti ? node.dataset.value === value : value.includes((_a = node.dataset.value) != null ? _a : "");
1104
+ var _a2;
1105
+ return !isMulti ? node.dataset.value === value : value.includes((_a2 = node.dataset.value) != null ? _a2 : "");
1095
1106
  }
1096
1107
  );
1097
1108
  if (selected) setFocusedIndex(selected.index);
1098
1109
  });
1099
- timeoutIds.current.add(id2);
1110
+ timeoutIds.current.add(id);
1100
1111
  }, [descendants, isMulti, value]);
1101
1112
  const onFocusNext = (0, import_react5.useCallback)(
1102
1113
  (index = focusedIndex) => {
1103
- const id2 = setTimeout(() => {
1104
- var _a, _b;
1114
+ const id = setTimeout(() => {
1115
+ var _a2, _b;
1105
1116
  const next = descendants.enabledNextValue(
1106
1117
  index,
1107
1118
  ({ node }) => "target" in node.dataset
@@ -1111,14 +1122,14 @@ var useAutocomplete = (props) => {
1111
1122
  setFocusedIndex(next.index);
1112
1123
  } else {
1113
1124
  if (selectedIndexes.includes(next.index)) {
1114
- const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
1125
+ const enabledNext = (_a2 = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a2 : enabledValues[0];
1115
1126
  setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
1116
1127
  } else {
1117
1128
  setFocusedIndex(next.index);
1118
1129
  }
1119
1130
  }
1120
1131
  });
1121
- timeoutIds.current.add(id2);
1132
+ timeoutIds.current.add(id);
1122
1133
  },
1123
1134
  [
1124
1135
  descendants,
@@ -1131,8 +1142,8 @@ var useAutocomplete = (props) => {
1131
1142
  );
1132
1143
  const onFocusPrev = (0, import_react5.useCallback)(
1133
1144
  (index = focusedIndex) => {
1134
- const id2 = setTimeout(() => {
1135
- var _a, _b;
1145
+ const id = setTimeout(() => {
1146
+ var _a2, _b;
1136
1147
  const prev = descendants.enabledPrevValue(
1137
1148
  index,
1138
1149
  ({ node }) => "target" in node.dataset
@@ -1142,14 +1153,14 @@ var useAutocomplete = (props) => {
1142
1153
  setFocusedIndex(prev.index);
1143
1154
  } else {
1144
1155
  if (selectedIndexes.includes(prev.index)) {
1145
- const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
1156
+ const enabledPrev = (_a2 = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a2 : enabledValues[0];
1146
1157
  setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
1147
1158
  } else {
1148
1159
  setFocusedIndex(prev.index);
1149
1160
  }
1150
1161
  }
1151
1162
  });
1152
- timeoutIds.current.add(id2);
1163
+ timeoutIds.current.add(id);
1153
1164
  },
1154
1165
  [
1155
1166
  descendants,
@@ -1168,8 +1179,8 @@ var useAutocomplete = (props) => {
1168
1179
  let isHit2 = false;
1169
1180
  let isFocused2 = false;
1170
1181
  values.forEach(({ index, node }) => {
1171
- var _a;
1172
- if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
1182
+ var _a2;
1183
+ if (format((_a2 = node.textContent) != null ? _a2 : "").includes(value2)) {
1173
1184
  isHit2 = true;
1174
1185
  const isDisabled = "disabled" in node.dataset;
1175
1186
  node.dataset.target = "";
@@ -1202,8 +1213,8 @@ var useAutocomplete = (props) => {
1202
1213
  if (!values.length) return;
1203
1214
  const resolvedValues = (0, import_utils11.isArray)(newValue) ? newValue : [newValue];
1204
1215
  const selectedLabel = resolvedValues.map((value2) => {
1205
- var _a, _b;
1206
- const { node } = (_a = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a : {};
1216
+ var _a2, _b;
1217
+ const { node } = (_a2 = values.find(({ node: node2 }) => node2.dataset.value === value2)) != null ? _a2 : {};
1207
1218
  if (node) {
1208
1219
  const { textContent } = (_b = Array.from(node.children).find(
1209
1220
  (child) => child.getAttribute("data-label") !== null
@@ -1240,9 +1251,9 @@ var useAutocomplete = (props) => {
1240
1251
  [isMulti, rebirthOptions, setValue]
1241
1252
  );
1242
1253
  const onSelect = (0, import_react5.useCallback)(() => {
1243
- var _a, _b;
1254
+ var _a2, _b;
1244
1255
  let enabledValue = descendants.value(focusedIndex);
1245
- if ("disabled" in ((_a = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a : {}))
1256
+ if ("disabled" in ((_a2 = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a2 : {}))
1246
1257
  enabledValue = void 0;
1247
1258
  if (!enabledValue) return;
1248
1259
  const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
@@ -1280,8 +1291,7 @@ var useAutocomplete = (props) => {
1280
1291
  isComposition.current = false;
1281
1292
  }, []);
1282
1293
  const onCreate = (0, import_react5.useCallback)(() => {
1283
- var _a, _b;
1284
- if (!listRef.current) return;
1294
+ var _a2, _b;
1285
1295
  const newItem = { label: inputValue, value: inputValue };
1286
1296
  let newItems = [];
1287
1297
  if (resolvedItems) newItems = [...resolvedItems];
@@ -1296,7 +1306,7 @@ var useAutocomplete = (props) => {
1296
1306
  const targetItem = newItems[i];
1297
1307
  if (i !== -1 && targetItem && "items" in targetItem) {
1298
1308
  if (secondInsertPositionItem === "first") {
1299
- targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
1309
+ targetItem.items = [newItem, ...(_a2 = targetItem.items) != null ? _a2 : []];
1300
1310
  } else {
1301
1311
  targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
1302
1312
  }
@@ -1453,7 +1463,7 @@ var useAutocomplete = (props) => {
1453
1463
  setResolvedItems(items ? JSON.parse(JSON.stringify(items)) : void 0);
1454
1464
  }, [items]);
1455
1465
  (0, import_utils11.useUnmountEffect)(() => {
1456
- timeoutIds.current.forEach((id2) => clearTimeout(id2));
1466
+ timeoutIds.current.forEach((id) => clearTimeout(id));
1457
1467
  timeoutIds.current.clear();
1458
1468
  });
1459
1469
  (0, import_use_outside_click.useOutsideClick)({
@@ -1524,6 +1534,10 @@ var useAutocomplete = (props) => {
1524
1534
  const getFieldProps = (0, import_react5.useCallback)(
1525
1535
  (props2 = {}, ref = null) => ({
1526
1536
  ref,
1537
+ "aria-activedescendant": activedescendantId,
1538
+ "aria-autocomplete": "list",
1539
+ "aria-haspopup": "listbox",
1540
+ role: "combobox",
1527
1541
  tabIndex: -1,
1528
1542
  ...props2,
1529
1543
  ...formControlProps,
@@ -1533,6 +1547,7 @@ var useAutocomplete = (props) => {
1533
1547
  onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
1534
1548
  }),
1535
1549
  [
1550
+ activedescendantId,
1536
1551
  formControlProps,
1537
1552
  placeholder,
1538
1553
  isOpen,
@@ -1543,7 +1558,6 @@ var useAutocomplete = (props) => {
1543
1558
  ]
1544
1559
  );
1545
1560
  return {
1546
- id,
1547
1561
  allowCreate,
1548
1562
  allowFree,
1549
1563
  children: children != null ? children : computedChildren,
@@ -1558,7 +1572,6 @@ var useAutocomplete = (props) => {
1558
1572
  isHit,
1559
1573
  isOpen,
1560
1574
  label,
1561
- listRef,
1562
1575
  omitSelectedValues,
1563
1576
  pickOptions,
1564
1577
  rebirthOptions,
@@ -1586,23 +1599,15 @@ var useAutocomplete = (props) => {
1586
1599
  };
1587
1600
  };
1588
1601
  var useAutocompleteInput = () => {
1589
- var _a, _b;
1590
1602
  const {
1591
- id,
1592
- focusedIndex,
1593
1603
  inputRef,
1594
1604
  isAllSelected,
1595
- isOpen,
1596
- listRef,
1597
1605
  formControlProps,
1598
1606
  inputProps,
1599
1607
  onCompositionEnd,
1600
1608
  onCompositionStart,
1601
1609
  onSearch
1602
1610
  } = useAutocompleteContext();
1603
- const descendants = useAutocompleteDescendantsContext();
1604
- const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
1605
- const listId = (_b = listRef.current) == null ? void 0 : _b.id;
1606
1611
  (0, import_utils11.useUpdateEffect)(() => {
1607
1612
  if (isAllSelected && inputRef.current) inputRef.current.blur();
1608
1613
  }, [isAllSelected]);
@@ -1611,19 +1616,12 @@ var useAutocompleteInput = () => {
1611
1616
  return {
1612
1617
  ref: (0, import_utils11.mergeRefs)(inputRef, ref),
1613
1618
  ...formControlProps,
1614
- "aria-activedescendant": activedescendantId,
1615
- "aria-autocomplete": "list",
1616
- "aria-controls": listId,
1617
- "aria-expanded": isOpen,
1618
- "aria-haspopup": "listbox",
1619
1619
  autoCapitalize: "none",
1620
1620
  autoComplete: "off",
1621
- role: "combobox",
1622
1621
  spellCheck: "false",
1623
1622
  tabIndex: isAllSelected ? -1 : 0,
1624
1623
  ...inputProps,
1625
1624
  ...props,
1626
- id,
1627
1625
  cursor: formControlProps.readOnly ? "default" : "text",
1628
1626
  pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1629
1627
  onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
@@ -1640,13 +1638,9 @@ var useAutocompleteInput = () => {
1640
1638
  };
1641
1639
  },
1642
1640
  [
1643
- listId,
1644
- activedescendantId,
1645
- isOpen,
1646
1641
  inputProps,
1647
1642
  inputRef,
1648
1643
  formControlProps,
1649
- id,
1650
1644
  isAllSelected,
1651
1645
  onSearch,
1652
1646
  onCompositionStart,