@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.
- package/dist/autocomplete-context.d.mts +0 -1
- package/dist/autocomplete-context.d.ts +0 -1
- package/dist/autocomplete-context.js.map +1 -1
- package/dist/autocomplete-context.mjs +1 -1
- package/dist/autocomplete-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +4 -4
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +4 -4
- package/dist/autocomplete-icon.js.map +1 -1
- package/dist/autocomplete-icon.mjs +2 -2
- package/dist/autocomplete-list.js +22 -15
- package/dist/autocomplete-list.js.map +1 -1
- package/dist/autocomplete-list.mjs +3 -3
- package/dist/autocomplete-option-group.js.map +1 -1
- package/dist/autocomplete-option-group.mjs +3 -3
- package/dist/autocomplete-option.js +10 -6
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +4 -4
- package/dist/autocomplete.js +78 -84
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +12 -12
- package/dist/{chunk-JYPMXZG4.mjs → chunk-2CVB4NO5.mjs} +7 -7
- package/dist/{chunk-3A2HEULI.mjs → chunk-2LP57WVB.mjs} +12 -8
- package/dist/chunk-2LP57WVB.mjs.map +1 -0
- package/dist/{chunk-PTPJFYGI.mjs → chunk-4GVV3HBE.mjs} +29 -13
- package/dist/chunk-4GVV3HBE.mjs.map +1 -0
- package/dist/{chunk-6OTUOEYS.mjs → chunk-7QCZ5NGS.mjs} +2 -2
- package/dist/{chunk-PU6HFINM.mjs → chunk-ABCTEZN5.mjs} +3 -3
- package/dist/{chunk-NOSATNDY.mjs → chunk-IFH3PPSD.mjs} +10 -8
- package/dist/chunk-IFH3PPSD.mjs.map +1 -0
- package/dist/{chunk-REPBXBG3.mjs → chunk-LIBFONYN.mjs} +7 -10
- package/dist/chunk-LIBFONYN.mjs.map +1 -0
- package/dist/{chunk-2UKLSSUA.mjs → chunk-PWV7X7G6.mjs} +4 -4
- package/dist/{chunk-G6SC44LI.mjs → chunk-RK5E5J5E.mjs} +4 -4
- package/dist/{chunk-ZNO5RUVT.mjs → chunk-TP5VZFO3.mjs} +1 -1
- package/dist/chunk-TP5VZFO3.mjs.map +1 -0
- package/dist/{chunk-CMFJUJJW.mjs → chunk-UX5QECNB.mjs} +2 -2
- package/dist/{chunk-6II6KCIJ.mjs → chunk-YPKDYYEV.mjs} +4 -4
- package/dist/{chunk-75VF5Q5W.mjs → chunk-ZR77IT3O.mjs} +51 -69
- package/dist/chunk-ZR77IT3O.mjs.map +1 -0
- package/dist/index.js +81 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/multi-autocomplete.d.mts +8 -0
- package/dist/multi-autocomplete.d.ts +8 -0
- package/dist/multi-autocomplete.js +81 -85
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +12 -12
- package/dist/use-autocomplete-list.d.mts +2 -1
- package/dist/use-autocomplete-list.d.ts +2 -1
- package/dist/use-autocomplete-list.js +19 -9
- package/dist/use-autocomplete-list.js.map +1 -1
- package/dist/use-autocomplete-list.mjs +2 -2
- package/dist/use-autocomplete-option-group.js.map +1 -1
- package/dist/use-autocomplete-option-group.mjs +2 -2
- package/dist/use-autocomplete-option.d.mts +16 -0
- package/dist/use-autocomplete-option.d.ts +16 -0
- package/dist/use-autocomplete-option.js +10 -6
- package/dist/use-autocomplete-option.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +2 -2
- package/dist/use-autocomplete.d.mts +3 -5
- package/dist/use-autocomplete.d.ts +3 -5
- package/dist/use-autocomplete.js +56 -69
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +7 -7
- package/package.json +4 -4
- package/dist/chunk-3A2HEULI.mjs.map +0 -1
- package/dist/chunk-75VF5Q5W.mjs.map +0 -1
- package/dist/chunk-NOSATNDY.mjs.map +0 -1
- package/dist/chunk-PTPJFYGI.mjs.map +0 -1
- package/dist/chunk-REPBXBG3.mjs.map +0 -1
- package/dist/chunk-ZNO5RUVT.mjs.map +0 -1
- /package/dist/{chunk-JYPMXZG4.mjs.map → chunk-2CVB4NO5.mjs.map} +0 -0
- /package/dist/{chunk-6OTUOEYS.mjs.map → chunk-7QCZ5NGS.mjs.map} +0 -0
- /package/dist/{chunk-PU6HFINM.mjs.map → chunk-ABCTEZN5.mjs.map} +0 -0
- /package/dist/{chunk-2UKLSSUA.mjs.map → chunk-PWV7X7G6.mjs.map} +0 -0
- /package/dist/{chunk-G6SC44LI.mjs.map → chunk-RK5E5J5E.mjs.map} +0 -0
- /package/dist/{chunk-CMFJUJJW.mjs.map → chunk-UX5QECNB.mjs.map} +0 -0
- /package/dist/{chunk-6II6KCIJ.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,
|
46
|
+
const { focusedIndex, isOpen, rebirthOptions, value } = useAutocompleteContext();
|
47
47
|
const descendants = useAutocompleteDescendantsContext();
|
48
|
-
const
|
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
|
-
(
|
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
|
104
|
+
[listRef]
|
95
105
|
);
|
96
106
|
return {
|
97
|
-
|
98
|
-
|
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
|
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,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;;;ADhCI,IAAM,sBAAsB,MAAM;AACvC,QAAM,EAAE,cAAc,QAAQ,gBAAgB,MAAM,IAClD,uBAAuB;AACzB,QAAM,cAAc,kCAAkC;AACtD,QAAM,cAAU,qBAAuB,IAAI;AAC3C,QAAM,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,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 +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
|
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'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AQ,CAAC,GAAG,MAAM,SAAS;AA7ChC;AA8CM,YAAM,QAAuB;AAAA,QAC3B,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,QAAQ;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,oBAAmB,cAAS,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"]}
|
@@ -17,11 +17,27 @@ interface UseAutocompleteOptionProps extends Omit<HTMLUIProps, "children" | "val
|
|
17
17
|
*
|
18
18
|
* @default false
|
19
19
|
*/
|
20
|
+
disabled?: boolean;
|
21
|
+
/**
|
22
|
+
* If `true`, the autocomplete option will be focusable.
|
23
|
+
*
|
24
|
+
* @default false
|
25
|
+
*/
|
26
|
+
focusable?: boolean;
|
27
|
+
/**
|
28
|
+
* If `true`, the autocomplete option will be disabled.
|
29
|
+
*
|
30
|
+
* @default false
|
31
|
+
*
|
32
|
+
* @deprecated Use `disabled` instead.
|
33
|
+
*/
|
20
34
|
isDisabled?: boolean;
|
21
35
|
/**
|
22
36
|
* If `true`, the autocomplete option will be focusable.
|
23
37
|
*
|
24
38
|
* @default false
|
39
|
+
*
|
40
|
+
* @deprecated Use `focusable` instead.
|
25
41
|
*/
|
26
42
|
isFocusable?: boolean;
|
27
43
|
/**
|
@@ -17,11 +17,27 @@ interface UseAutocompleteOptionProps extends Omit<HTMLUIProps, "children" | "val
|
|
17
17
|
*
|
18
18
|
* @default false
|
19
19
|
*/
|
20
|
+
disabled?: boolean;
|
21
|
+
/**
|
22
|
+
* If `true`, the autocomplete option will be focusable.
|
23
|
+
*
|
24
|
+
* @default false
|
25
|
+
*/
|
26
|
+
focusable?: boolean;
|
27
|
+
/**
|
28
|
+
* If `true`, the autocomplete option will be disabled.
|
29
|
+
*
|
30
|
+
* @default false
|
31
|
+
*
|
32
|
+
* @deprecated Use `disabled` instead.
|
33
|
+
*/
|
20
34
|
isDisabled?: boolean;
|
21
35
|
/**
|
22
36
|
* If `true`, the autocomplete option will be focusable.
|
23
37
|
*
|
24
38
|
* @default false
|
39
|
+
*
|
40
|
+
* @deprecated Use `focusable` instead.
|
25
41
|
*/
|
26
42
|
isFocusable?: boolean;
|
27
43
|
/**
|
@@ -68,13 +68,17 @@ var useAutocompleteOption = (props) => {
|
|
68
68
|
id,
|
69
69
|
children,
|
70
70
|
closeOnSelect: customCloseOnSelect,
|
71
|
+
disabled,
|
72
|
+
focusable,
|
71
73
|
icon: customIcon,
|
72
74
|
isDisabled,
|
73
75
|
isFocusable,
|
74
76
|
value: optionValue,
|
75
77
|
...computedProps
|
76
78
|
} = { ...optionProps, ...props };
|
77
|
-
|
79
|
+
disabled != null ? disabled : disabled = isDisabled;
|
80
|
+
focusable != null ? focusable : focusable = isFocusable;
|
81
|
+
const trulyDisabled = !!disabled && !focusable;
|
78
82
|
const { descendants, index, register } = useAutocompleteDescendant({
|
79
83
|
disabled: trulyDisabled
|
80
84
|
});
|
@@ -100,7 +104,7 @@ var useAutocompleteOption = (props) => {
|
|
100
104
|
const onClick = (0, import_react.useCallback)(
|
101
105
|
(ev) => {
|
102
106
|
ev.stopPropagation();
|
103
|
-
if (
|
107
|
+
if (disabled || !isTargetOption(ev.currentTarget)) {
|
104
108
|
if (inputRef.current) inputRef.current.focus();
|
105
109
|
return;
|
106
110
|
}
|
@@ -114,7 +118,7 @@ var useAutocompleteOption = (props) => {
|
|
114
118
|
isDuplicated,
|
115
119
|
onFocusNext,
|
116
120
|
omitSelectedValues,
|
117
|
-
|
121
|
+
disabled,
|
118
122
|
optionValue,
|
119
123
|
setFocusedIndex,
|
120
124
|
index,
|
@@ -146,10 +150,10 @@ var useAutocompleteOption = (props) => {
|
|
146
150
|
...props2,
|
147
151
|
id,
|
148
152
|
style: isHidden ? style : void 0,
|
149
|
-
"aria-disabled": (0, import_utils2.ariaAttr)(
|
153
|
+
"aria-disabled": (0, import_utils2.ariaAttr)(disabled),
|
150
154
|
"aria-hidden": (0, import_utils2.ariaAttr)(isHidden),
|
151
155
|
"aria-selected": isSelected,
|
152
|
-
"data-disabled": (0, import_utils2.dataAttr)(
|
156
|
+
"data-disabled": (0, import_utils2.dataAttr)(disabled),
|
153
157
|
"data-duplicated": (0, import_utils2.dataAttr)(isDuplicated),
|
154
158
|
"data-focus": (0, import_utils2.dataAttr)(isFocused),
|
155
159
|
"data-target": (0, import_utils2.dataAttr)(true),
|
@@ -163,7 +167,7 @@ var useAutocompleteOption = (props) => {
|
|
163
167
|
isDuplicated,
|
164
168
|
optionValue,
|
165
169
|
computedProps,
|
166
|
-
|
170
|
+
disabled,
|
167
171
|
isFocused,
|
168
172
|
isSelected,
|
169
173
|
isTarget,
|
@@ -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 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","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,E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O,IAAM,uBAAuB,MAAM;AACxC,QAAM,EAAE,SAAS,MAAM,IAAI,uBAAuB;AAElD,QAAM,oBAA4B;AAAA,IAChC,CAAC,QAAQ,CAAC,GAAG,MAAM,SAAS;AAC1B,YAAM,WAAW,SAAS,CAAC;AAE3B,YAAM,QAAuB;AAAA,QAC3B,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,QAAQ;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,I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Y;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"]}
|
@@ -3,8 +3,8 @@ import {
|
|
3
3
|
useAutocompleteCreate,
|
4
4
|
useAutocompleteEmpty,
|
5
5
|
useAutocompleteOption
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
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
|
5
|
+
import { ChangeEvent, ReactElement, FocusEvent, DOMAttributes, MouseEvent } from 'react';
|
6
6
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
7
|
-
import {
|
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';
|
@@ -15,7 +15,7 @@ interface AutocompleteItemWithValue extends AutocompleteOptionProps {
|
|
15
15
|
label?: string;
|
16
16
|
value?: string;
|
17
17
|
}
|
18
|
-
interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "isDisabled" | "isFocusable"> {
|
18
|
+
interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "disabled" | "focusable" | "isDisabled" | "isFocusable"> {
|
19
19
|
items?: AutocompleteItemWithValue[];
|
20
20
|
}
|
21
21
|
type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue;
|
@@ -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
|
5
|
+
import { ChangeEvent, ReactElement, FocusEvent, DOMAttributes, MouseEvent } from 'react';
|
6
6
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
7
|
-
import {
|
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';
|
@@ -15,7 +15,7 @@ interface AutocompleteItemWithValue extends AutocompleteOptionProps {
|
|
15
15
|
label?: string;
|
16
16
|
value?: string;
|
17
17
|
}
|
18
|
-
interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "isDisabled" | "isFocusable"> {
|
18
|
+
interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "disabled" | "focusable" | "isDisabled" | "isFocusable"> {
|
19
19
|
items?: AutocompleteItemWithValue[];
|
20
20
|
}
|
21
21
|
type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue;
|
@@ -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;
|