@choc-ui/chakra-autocomplete 4.13.0 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"chakra-autocomplete.cjs.production.min.js","sources":["../src/autocomplete-context.ts","../src/helpers/fuzzySearch.ts","../src/helpers/items.ts","../src/helpers/input.ts","../src/helpers/group.ts","../src/use-autocomplete.ts","../src/autocomplete.tsx","../src/autocomplete-item.tsx","../src/autocomplete-creatable.tsx","../src/autocomplete-group.tsx","../src/autocomplete-input.tsx","../src/components/empty-state.tsx","../src/autocomplete-list.tsx","../src/helpers/list.ts","../src/autocomplete-tag.tsx"],"sourcesContent":["import { createContext } from \"@chakra-ui/react-utils\";\nimport { UseAutoCompleteReturn } from \"./types\";\n\nexport const [AutoCompleteProvider, useAutoCompleteContext] = createContext<\n UseAutoCompleteReturn\n>({\n name: \"AutoCompleteContext\",\n errorMessage:\n \"useAutoCompleteContext: `context` is undefined. Seems you forgot to wrap all autoomplete components within `<AutoComplete />`\",\n});\n","/*\n * @param str1 The first string to compare.\n * @param str2 The second string to compare.\n * @param gramSize The size of the grams. Defaults to length 2.\n */\nexport function fuzzyScore(str1: string, str2: string, gramSize: number = 2) {\n function getNGrams(s: string, len: number) {\n s = \" \".repeat(len - 1) + s.toLowerCase() + \" \".repeat(len - 1);\n let v = new Array(s.length - len + 1);\n for (let i = 0; i < v.length; i++) {\n v[i] = s.slice(i, i + len);\n }\n return v;\n }\n\n if (!str1?.length || !str2?.length) {\n return 0.0;\n }\n\n //Order the strings by length so the order they're passed in doesn't matter\n //and so the smaller string's ngrams are always the ones in the set\n let s1 = str1.length < str2.length ? str1 : str2;\n let s2 = str1.length < str2.length ? str2 : str1;\n\n let pairs1 = getNGrams(s1, gramSize);\n let pairs2 = getNGrams(s2, gramSize);\n let set = new Set<string>(pairs1);\n\n let total = pairs2.length;\n let hits = 0;\n for (let item of pairs2) {\n if (set.delete(item)) {\n hits++;\n }\n }\n return hits / total;\n}\n","import { getChildrenDeep } from \"react-nanny\";\nimport { pick, isDefined, isEmpty } from \"@chakra-ui/utils\";\nimport { ReactNode } from \"react\";\nimport { FlexProps } from \"@chakra-ui/react\";\nimport { fuzzyScore } from \"./fuzzySearch\";\nimport { Item } from \"../types\";\nimport { AutoCompleteItemProps } from \"../autocomplete-item\";\n\nexport const getDefItemValue = (item: AutoCompleteItemProps[\"value\"]) =>\n (typeof item === \"string\" ? item : item[Object.keys(item)[0]]).toString();\n\nexport const setEmphasis = (children: any, query: string) => {\n if (typeof children !== \"string\" || isEmpty(query)) {\n return children;\n }\n const newChildren = children\n .toString()\n .replace(\n new RegExp(escapeRegex(query), \"gi\"),\n (match: any) => `<mark>${match}</mark>`\n );\n return newChildren;\n};\n\nexport const getItemList = (children: ReactNode) => {\n const itemChildren = getChildrenDeep(\n children,\n (child: any) => child?.type?.displayName === \"AutoCompleteItem\"\n );\n\n return itemChildren.map(item => {\n const itemObj = pick(item.props, [\"value\", \"label\", \"fixed\", \"disabled\"]);\n const { getValue = getDefItemValue } = item.props;\n const value = getValue(itemObj.value);\n const finObj = isDefined(itemObj.label)\n ? itemObj\n : { ...itemObj, label: value };\n return { ...finObj, value };\n });\n};\n\nexport const getFocusedStyles = (): FlexProps => {\n return {\n bg: \"whiteAlpha.100\",\n _light: {\n bg: \"gray.200\",\n },\n };\n};\n\nexport const defaultFilterMethod = (\n query: string,\n itemValue: Item[\"value\"],\n itemLabel: Item[\"label\"]\n) => {\n return (\n itemValue?.toLowerCase().indexOf(query?.toLowerCase()) >= 0 ||\n itemLabel?.toLowerCase().indexOf(query?.toLowerCase()) >= 0 ||\n fuzzyScore(query, itemValue) >= 0.5 ||\n fuzzyScore(query, itemLabel) >= 0.5\n );\n};\n\nfunction escapeRegex(string: string) {\n return string.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n}\n","export const getMultipleWrapStyles = (themeInput: any, multiple?: boolean) => ({\n ...(multiple && {\n ...themeInput.field,\n _focusWithin: themeInput.field._focus,\n pos: \"relative\",\n minH: 9,\n // px: 3,\n py: 1.5,\n spacing: 3,\n }),\n cursor: \"text\",\n h: \"fit-content\",\n // w: \"full\",\n});\n","import { isDefined } from \"@chakra-ui/utils\";\nimport { getChildDeep } from \"react-nanny\";\nimport { ReactNode } from \"react\";\n\nexport const hasFirstItem = (children: ReactNode, firstItem: any) => {\n const result = getChildDeep(\n children,\n (child: any) =>\n child?.type?.displayName === \"AutoCompleteItem\" &&\n child.props.value === firstItem?.value\n );\n\n return result;\n};\nexport const hasLastItem = (children: ReactNode, lastItem: any) => {\n const result = getChildDeep(\n children,\n (child: any) =>\n child?.type?.displayName === \"AutoCompleteItem\" &&\n child.props.value === lastItem?.value\n );\n return result;\n};\n\nexport const hasChildren = (children: any, filteredList: any[]) => {\n return isDefined(\n getChildDeep(\n children,\n (child: any) =>\n filteredList.findIndex(i => i.value === child.props?.value) >= 0\n )\n );\n};\n","import {\n useDimensions,\n useDisclosure,\n useUpdateEffect,\n useControllableState,\n} from \"@chakra-ui/react\";\nimport {\n callAll,\n getFirstItem,\n getLastItem,\n getNextItem,\n getPrevItem,\n isObject,\n isEmpty,\n isUndefined,\n runIfFn,\n} from \"@chakra-ui/utils\";\nimport { omit } from \"@chakra-ui/utils\";\n\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { AutoCompleteProps } from \"./autocomplete\";\nimport {\n defaultFilterMethod,\n getDefItemValue,\n getFocusedStyles,\n getItemList,\n setEmphasis,\n} from \"./helpers/items\";\nimport { getMultipleWrapStyles } from \"./helpers/input\";\nimport { hasChildren, hasFirstItem, hasLastItem } from \"./helpers/group\";\nimport { Item, UseAutoCompleteReturn } from \"./types\";\n\n/**\n * useAutoComplete that provides all the state and focus management logic\n * for the autocomplete component. It is consumed by the `Autocomplete` component\n *\n */\n\nexport function useAutoComplete(\n autoCompleteProps: AutoCompleteProps\n): UseAutoCompleteReturn {\n let {\n closeOnBlur = true,\n closeOnSelect,\n creatable,\n emphasize,\n emptyState = true,\n freeSolo,\n isReadOnly,\n listAllValuesOnFocus,\n maxSuggestions,\n multiple,\n defaultValue,\n defaultValues = defaultValue ? [defaultValue] : [],\n onReady,\n defaultIsOpen,\n shouldRenderSuggestions = () => true,\n suggestWhenEmpty,\n value,\n values: valuesProp = value\n ? typeof value === \"string\"\n ? [value]\n : [...value]\n : undefined,\n } = autoCompleteProps;\n closeOnSelect = closeOnSelect ? closeOnSelect : multiple ? false : true;\n\n freeSolo = freeSolo ? freeSolo : multiple ? true : autoCompleteProps.freeSolo;\n\n const { isOpen, onClose, onOpen } = useDisclosure({ defaultIsOpen });\n\n const children = runIfFn(autoCompleteProps.children, {\n isOpen,\n onClose,\n onOpen,\n });\n const itemList: Item[] = getItemList(children);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const inputWrapperRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const interactionRef = useRef<\"mouse\" | \"keyboard\" | null>(null);\n\n const [listAll, setListAll] = useState(false);\n\n let defaultQuery = \"\";\n if (multiple) defaultQuery = \"\";\n else if (!isUndefined(defaultValues)) defaultQuery = defaultValues[0];\n else if (!isUndefined(valuesProp)) defaultQuery = valuesProp[0];\n\n const [query, setQuery] = useState<string>(defaultQuery ?? \"\");\n const filteredResults = itemList\n .filter(\n i =>\n i.fixed ||\n runIfFn(\n autoCompleteProps.filter || defaultFilterMethod,\n query,\n i.value,\n i.label\n ) ||\n listAll\n )\n .filter((_, index) => (maxSuggestions ? index < maxSuggestions : true));\n\n // Add Creatable to Filtered List\n const creatableArr: Item[] = creatable\n ? [{ value: query, noFilter: true, creatable: true }]\n : [];\n\n const filteredList = [...filteredResults, ...creatableArr];\n const [values, setValues] = useControllableState({\n defaultValue: defaultValues,\n value: valuesProp,\n onChange: (newValues: any[]) => {\n const item = filteredList.find(opt => opt.value === newValues[0]);\n const items = newValues.map(val =>\n filteredList.find(opt => opt.value === val)\n );\n runIfFn(\n autoCompleteProps.onChange,\n multiple ? newValues : newValues[0],\n multiple ? items : item\n );\n },\n });\n\n const [focusedValue, setFocusedValue] = useState<Item[\"value\"]>(\n itemList[0]?.value\n );\n\n const maxSelections = autoCompleteProps.maxSelections || values.length + 1;\n\n const focusedIndex = filteredList.findIndex(i => i.value === focusedValue);\n const nextItem = getNextItem(\n focusedIndex,\n filteredList,\n !!autoCompleteProps.rollNavigation\n );\n const prevItem = getPrevItem(\n focusedIndex,\n filteredList,\n !!autoCompleteProps.rollNavigation\n );\n const firstItem = getFirstItem(filteredList);\n const lastItem = getLastItem(filteredList);\n\n useUpdateEffect(() => {\n setFocusedValue(firstItem?.value);\n }, [query]);\n\n useEffect(() => {\n const focusedItem = itemList.find(i => i.value === focusedValue);\n runIfFn(autoCompleteProps.onOptionFocus, {\n item: focusedItem!,\n focusMethod: interactionRef.current,\n isNewInput: focusedItem?.creatable,\n });\n }, [focusedValue, autoCompleteProps.onOptionFocus]);\n\n const selectItem = (optionValue: Item[\"value\"]) => {\n if (!values.includes(optionValue) && values.length < maxSelections) {\n setValues(v => (multiple ? [...v, optionValue] : [optionValue]));\n }\n\n const option = filteredList.find(i => i.value === optionValue);\n\n if (multiple) {\n inputRef.current?.focus();\n }\n if (autoCompleteProps.focusInputOnSelect) inputRef.current?.focus();\n runIfFn(autoCompleteProps.onSelectOption, {\n item: option!,\n selectMethod: interactionRef.current,\n isNewInput: option?.creatable,\n });\n if (option?.creatable) {\n runIfFn(autoCompleteProps.onCreateOption, {\n item: omit(option!, [\"noFilter\"]),\n selectMethod: interactionRef.current,\n });\n }\n console.log(option);\n const optionLabel = option?.label || option?.value;\n setQuery(() => (multiple ? \"\" : optionLabel ?? \"\"));\n\n if (closeOnSelect) onClose();\n };\n\n const removeItem = (itemValue: Item[\"value\"]) => {\n setValues(prevValues => {\n const item = itemList.find(opt => opt.value === itemValue);\n runIfFn(autoCompleteProps.onTagRemoved, itemValue, item, prevValues);\n return prevValues.filter(i => i !== itemValue);\n });\n if (query === itemValue) setQuery(\"\");\n };\n\n const resetItems = (focusInput?: boolean) => {\n setValues([]);\n if (focusInput) inputRef.current?.focus();\n };\n\n const tags = multiple\n ? values.map(tag => ({\n label: itemList.find(item => item.value === tag)?.label || tag,\n onRemove: () => removeItem(tag),\n }))\n : [];\n\n useEffect(() => {\n runIfFn(onReady, { tags });\n }, [values]);\n\n const getInputProps: UseAutoCompleteReturn[\"getInputProps\"] = (\n props,\n themeInput\n ) => {\n const { onBlur, onChange, onFocus, onKeyDown, variant, ...rest } = props;\n\n return {\n wrapper: {\n ref: inputWrapperRef,\n onClick: () => {\n inputRef?.current?.focus();\n },\n ...getMultipleWrapStyles(themeInput, multiple),\n ...rest,\n },\n input: {\n isReadOnly,\n onFocus: e => {\n runIfFn(onFocus, e);\n if (autoCompleteProps.openOnFocus && !isReadOnly) onOpen();\n if (autoCompleteProps.selectOnFocus) e.target.select();\n if (listAllValuesOnFocus) setListAll(true);\n },\n onBlur: e => {\n runIfFn(onBlur, e);\n const listIsFocused = e.relatedTarget === listRef?.current;\n const inputWrapperIsFocused = inputWrapperRef.current?.contains(\n e.relatedTarget as any\n );\n if (!listIsFocused && !inputWrapperIsFocused) {\n if (closeOnBlur) onClose();\n if (!values.includes(e.target.value) && !freeSolo)\n setQuery(getLastItem(values) ?? \"\");\n }\n },\n onChange: e => {\n const newValue = e.target.value;\n runIfFn(onChange, e);\n setQuery(newValue);\n const queryIsEmpty = isEmpty(newValue);\n if (\n runIfFn(shouldRenderSuggestions, newValue) &&\n (!queryIsEmpty || suggestWhenEmpty)\n )\n onOpen();\n else onClose();\n setListAll(false);\n },\n onKeyDown: e => {\n runIfFn(onKeyDown, e);\n interactionRef.current = \"keyboard\";\n\n const { key } = e;\n const focusedItem = filteredList[focusedIndex];\n if (key === \"Enter\") {\n if (focusedItem && !focusedItem?.disabled)\n selectItem(focusedItem?.value);\n else inputRef.current?.focus();\n e.preventDefault();\n return;\n }\n\n if (key === \"ArrowDown\") {\n setFocusedValue(nextItem?.value);\n e.preventDefault();\n return;\n }\n\n if (key === \"ArrowUp\") {\n setFocusedValue(prevItem?.value);\n\n e.preventDefault();\n return;\n }\n\n if (key === \"Tab\") {\n setFocusedValue(nextItem?.value);\n\n if (isOpen) e.preventDefault();\n return;\n }\n\n if (key === \"Home\") {\n setFocusedValue(firstItem?.value);\n e.preventDefault();\n return;\n }\n\n if (key === \"End\") {\n setFocusedValue(lastItem?.value);\n e.preventDefault();\n return;\n }\n\n if (key === \"Escape\") {\n callAll(onClose, e.preventDefault);\n }\n },\n value: query,\n variant: multiple ? \"unstyled\" : variant,\n ...rest,\n },\n };\n };\n\n const dim = useDimensions(inputWrapperRef, true);\n const getListProps: UseAutoCompleteReturn[\"getListProps\"] = () => {\n const width = dim?.marginBox.width as number;\n return {\n width,\n };\n };\n\n const getItemProps: UseAutoCompleteReturn[\"getItemProps\"] = (\n props,\n creatable\n ) => {\n const {\n _fixed,\n _focus,\n children: itemChild,\n disabled,\n label,\n value: valueProp,\n fixed,\n getValue = getDefItemValue,\n onClick,\n onMouseOver,\n sx,\n ...rest\n } = props;\n const value = creatable ? valueProp : getValue(valueProp)?.toString();\n const isFocused = value === focusedValue;\n const isValidSuggestion =\n filteredList.findIndex(i => i.value === value) >= 0;\n const itemLabel = itemChild || label || value;\n return {\n item: {\n ...(typeof itemLabel !== \"string\" || !emphasize\n ? { children: itemLabel }\n : {\n dangerouslySetInnerHTML: {\n __html: setEmphasis(itemLabel, query),\n },\n }),\n \"aria-selected\": values.includes(value),\n \"aria-disabled\": disabled,\n _disabled: { opacity: 0.4, cursor: \"not-allowed\", userSelect: \"none\" },\n onClick: e => {\n runIfFn(onClick, e);\n if (!disabled) selectItem(value);\n else inputRef.current?.focus();\n },\n onMouseOver: e => {\n runIfFn(onMouseOver, e);\n setFocusedValue(value);\n interactionRef.current = \"mouse\";\n },\n sx: {\n ...sx,\n mark: {\n color: \"inherit\",\n bg: \"transparent\",\n ...(isObject(emphasize)\n ? emphasize\n : {\n fontWeight: emphasize ? \"extrabold\" : \"inherit\",\n }),\n },\n },\n ...(isFocused && (_focus || getFocusedStyles())),\n ...(fixed && _fixed),\n ...rest,\n },\n root: {\n isValidSuggestion,\n value,\n },\n };\n };\n\n const getGroupProps: UseAutoCompleteReturn[\"getGroupProps\"] = props => {\n const hasItems = hasChildren(props.children, filteredList);\n return {\n divider: {\n hasFirstChild: hasFirstItem(props.children, firstItem),\n hasLastChild: hasLastItem(\n props.children,\n getLastItem(filteredList.filter(i => isUndefined(i?.noFilter)))\n ),\n },\n group: {\n display: hasItems ? \"initial\" : \"none\",\n },\n };\n };\n\n const getEmptyStateProps: UseAutoCompleteReturn[\"getEmptyStateProps\"] = defaultEmptyState => {\n const noSuggestions = filteredList.every(i => i.noFilter);\n if (noSuggestions && emptyState && !creatable) {\n return typeof emptyState === \"boolean\"\n ? defaultEmptyState\n : runIfFn(emptyState, { query });\n }\n };\n\n return {\n autoCompleteProps,\n children,\n filteredList,\n filteredResults,\n focusedValue,\n getEmptyStateProps,\n getGroupProps,\n getInputProps,\n getItemProps,\n getListProps,\n inputRef,\n interactionRef,\n isOpen,\n itemList,\n listRef,\n onClose,\n onOpen,\n query,\n removeItem,\n resetItems,\n setQuery,\n tags,\n values,\n };\n}\n","import React, { useImperativeHandle } from \"react\";\nimport { MaybeRenderProp } from \"@chakra-ui/react-utils\";\n\nimport { AutoCompleteProvider } from \"./autocomplete-context\";\nimport { useAutoComplete } from \"./use-autocomplete\";\nimport { chakra, forwardRef, Popover } from \"@chakra-ui/react\";\nimport { AutoCompleteRefMethods, UseAutoCompleteProps } from \"./types\";\n\nexport type AutoCompleteChildProps = {\n isOpen: boolean;\n onClose: () => void;\n onOpen: () => void;\n};\nexport interface AutoCompleteProps extends UseAutoCompleteProps {\n children: MaybeRenderProp<AutoCompleteChildProps>;\n ref?: React.RefObject<AutoCompleteRefMethods>;\n}\n\nexport const AutoComplete = forwardRef<AutoCompleteProps, \"div\">(\n (props, ref) => {\n const context = useAutoComplete(props);\n const {\n children,\n isOpen,\n onClose,\n onOpen,\n resetItems,\n removeItem,\n } = context;\n\n useImperativeHandle(ref, () => ({\n resetItems,\n removeItem,\n }));\n\n return (\n <AutoCompleteProvider value={context}>\n <Popover\n isLazy\n isOpen={isOpen}\n onClose={onClose}\n onOpen={onOpen}\n autoFocus={false}\n placement=\"bottom\"\n closeOnBlur={true}\n >\n <chakra.div\n sx={{\n \".chakra-popover__popper\": {\n position: \"unset !important\",\n },\n }}\n w=\"full\"\n ref={ref}\n >\n {children}\n </chakra.div>\n </Popover>\n </AutoCompleteProvider>\n );\n }\n);\n\nAutoComplete.displayName = \"AutoComplete\";\n","import {\n CSSObject,\n Flex,\n FlexProps,\n forwardRef,\n useMergeRefs,\n} from \"@chakra-ui/react\";\nimport { isUndefined, omit } from \"@chakra-ui/utils\";\nimport React, { useEffect, useRef } from \"react\";\n\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\n\nexport interface AutoCompleteItemProps extends FlexProps {\n value: any;\n label?: string;\n fixed?: boolean;\n _focus?: CSSObject | any;\n disabled?: boolean;\n _fixed?: CSSObject;\n getValue?: (item: AutoCompleteItemProps[\"value\"]) => any;\n}\n\nexport const AutoCompleteItem = forwardRef<AutoCompleteItemProps, \"div\">(\n (props, forwardedRef) => {\n const {\n focusedValue,\n getItemProps,\n interactionRef,\n } = useAutoCompleteContext();\n const itemRef = useRef<any>();\n const ref = useMergeRefs(forwardedRef, itemRef);\n\n const itemProps = getItemProps(props);\n const { isValidSuggestion, value } = itemProps.root;\n\n const isFocused = focusedValue === value;\n\n useEffect(() => {\n if (isFocused && interactionRef.current === \"keyboard\")\n itemRef?.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n });\n }, [isFocused, interactionRef]);\n\n useEffect(() => {\n if (typeof value !== \"string\") console.warn(\"wow\");\n if (typeof value !== \"string\" && isUndefined(props.getValue))\n console.error(\n \"You must define the `getValue` prop, when an Item's value is not a string\"\n );\n }, []);\n\n const { children, dangerouslySetInnerHTML, ...restProps } = itemProps.item;\n\n const rest = omit(restProps, [\"groupId\"] as any);\n\n return isValidSuggestion ? (\n <Flex ref={ref} {...baseItemStyles} {...rest}>\n {children ? (\n children\n ) : (\n <span dangerouslySetInnerHTML={dangerouslySetInnerHTML} />\n )}\n </Flex>\n ) : null;\n }\n);\n\nAutoCompleteItem.displayName = \"AutoCompleteItem\";\n\nexport const baseItemStyles: FlexProps = {\n mx: \"2\",\n px: \"2\",\n py: \"2\",\n rounded: \"md\",\n cursor: \"pointer\",\n};\n","import { Flex, FlexProps } from \"@chakra-ui/react\";\nimport { MaybeRenderProp } from \"@chakra-ui/react-utils\";\nimport { isEmpty, runIfFn } from \"@chakra-ui/utils\";\n\nimport React from \"react\";\n\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\nimport { baseItemStyles } from \"./autocomplete-item\";\n\ninterface AutoCompleteCreatableProps extends FlexProps {\n children?: MaybeRenderProp<{ value: any }>;\n}\n\nexport function AutoCompleteCreatable(props: AutoCompleteCreatableProps) {\n const { children: childrenProp, ...rest } = props;\n const {\n autoCompleteProps,\n getItemProps,\n query,\n filteredResults,\n } = useAutoCompleteContext();\n\n const queryValue = <mark>{query}</mark>;\n const { children, ...itemProps } = getItemProps(\n {\n ...props,\n value: query,\n children: runIfFn(childrenProp, {\n value: queryValue,\n }),\n },\n true\n ).item;\n\n const queryExistsInList = filteredResults.some(i => i.value === query);\n const showCreatable =\n autoCompleteProps.creatable && !isEmpty(query) && !queryExistsInList;\n\n return showCreatable ? (\n <Flex {...baseItemStyles} {...itemProps} {...rest}>\n {children || `Add ${query}`}\n </Flex>\n ) : null;\n}\n\nAutoCompleteCreatable.displayName = \"AutoCompleteCreatable\";\n","import {\n Box,\n BoxProps,\n Divider,\n DividerProps,\n Flex,\n FlexProps,\n forwardRef,\n} from \"@chakra-ui/react\";\nimport { omit } from \"@chakra-ui/utils\";\nimport React from \"react\";\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\n\nexport interface AutoCompleteGroupProps extends BoxProps {\n children?: React.ReactNode;\n showDivider?: boolean;\n dividerColor?: string;\n}\n\nexport const AutoCompleteGroup = forwardRef<AutoCompleteGroupProps, \"div\">(\n (props, ref) => {\n const { children, showDivider, ...restProps } = props;\n const rest = omit(restProps, [\"groupSibling\"] as any);\n\n const { getGroupProps } = useAutoCompleteContext();\n\n const { group } = getGroupProps(props);\n\n const dividerStyles = useDividerStyles(props);\n\n return (\n <Box ref={ref} {...group} {...rest}>\n <Divider {...dividerStyles.top} />\n {children}\n <Divider {...dividerStyles.bottom} />\n </Box>\n );\n }\n);\n\nexport const AutoCompleteGroupTitle = forwardRef<FlexProps, \"div\">(\n (props, ref) => {\n return <Flex {...baseTitleStyles} {...props} ref={ref} />;\n }\n);\n\nAutoCompleteGroup.displayName = \"AutoCompleteGroup\";\nAutoCompleteGroupTitle.displayName = \"AutoCompleteGroupTitle\";\n\nconst baseTitleStyles: FlexProps = {\n ml: 5,\n my: 1,\n fontSize: \"xs\",\n letterSpacing: \"wider\",\n fontWeight: \"extrabold\",\n textTransform: \"uppercase\",\n};\n\nconst useDividerStyles = (\n props: AutoCompleteGroupProps & { groupSibling?: boolean }\n) => {\n const { getGroupProps } = useAutoCompleteContext();\n\n const hasGroupSibling: unknown = props.groupSibling;\n\n const {\n divider: { hasFirstChild, hasLastChild },\n } = getGroupProps(props as AutoCompleteGroupProps);\n\n const baseStyles: DividerProps = {\n my: 2,\n borderColor: props.dividerColor,\n };\n\n const top = {\n ...baseStyles,\n mb: 4,\n display: !props.showDivider || hasFirstChild ? \"none\" : \"\",\n };\n const bottom = {\n ...baseStyles,\n display:\n !props.showDivider || hasLastChild || hasGroupSibling ? \"none\" : \"\",\n };\n\n return { top, bottom };\n};\n","import {\n CSSObject,\n forwardRef,\n Input,\n InputProps,\n useMergeRefs,\n useMultiStyleConfig,\n Wrap,\n WrapItem,\n} from \"@chakra-ui/react\";\nimport { runIfFn } from \"@chakra-ui/utils\";\nimport { MaybeRenderProp } from \"@chakra-ui/react-utils\";\nimport React from \"react\";\n\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\nimport { UseAutoCompleteReturn } from \"./types\";\n\nexport interface AutoCompleteInputProps extends InputProps {\n children?: MaybeRenderProp<{ tags: UseAutoCompleteReturn[\"tags\"] }>;\n wrapStyles?: CSSObject;\n}\n\nexport const AutoCompleteInput = forwardRef<AutoCompleteInputProps, \"input\">(\n (props, forwardedRef) => {\n const { inputRef, getInputProps, tags } = useAutoCompleteContext();\n\n // const ref = useMergeRefs(forwardedRef, inputRef);\n\n const { children: childrenProp, ...rest } = props;\n\n const themeInput: any = useMultiStyleConfig(\"Input\", props);\n\n const { wrapper, input: inputProps } = getInputProps(rest, themeInput);\n const { ref: wrapperRef, ...wrapperProps } = wrapper;\n const ref = useMergeRefs(forwardedRef, wrapperRef);\n\n const children = runIfFn(childrenProp, { tags });\n\n return (\n <Wrap {...wrapperProps} ref={ref}>\n {children}\n <WrapItem as={Input} {...(inputProps as any)} ref={inputRef} />\n </Wrap>\n );\n }\n);\n\nAutoCompleteInput.displayName = \"Input\";\n\nAutoCompleteInput.id = \"Input\";\n","import { Box, BoxProps, Flex, FlexProps } from \"@chakra-ui/layout\";\nimport React from \"react\";\nimport { useAutoCompleteContext } from \"../autocomplete-context\";\n\nexport const EmptyState = (props: BoxProps) => {\n const { getEmptyStateProps } = useAutoCompleteContext();\n\n const emptyState = getEmptyStateProps(\n <Flex {...emptyStyles}>No options found!</Flex>\n );\n\n return <Box {...props}>{emptyState}</Box>;\n};\n\nconst emptyStyles: FlexProps = {\n fontSize: \"sm\",\n align: \"center\",\n justify: \"center\",\n fontWeight: \"bold\",\n fontStyle: \"italic\",\n};\n","import {\n forwardRef,\n PopoverContent,\n PopoverContentProps,\n useMergeRefs,\n} from \"@chakra-ui/react\";\nimport React from \"react\";\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\nimport { EmptyState } from \"./components/empty-state\";\nimport { siblingInfo } from \"./helpers/list\";\n\nexport type AutoCompleteListProps = PopoverContentProps;\n\nexport const AutoCompleteList = forwardRef<AutoCompleteListProps, \"div\">(\n (props, forwardedRef) => {\n const { children, ...rest } = props;\n const { listRef, getListProps } = useAutoCompleteContext();\n const ref = useMergeRefs(forwardedRef, listRef);\n const listProps = getListProps();\n\n return (\n <PopoverContent ref={ref} {...baseStyles} {...listProps} {...rest}>\n {siblingInfo(children)}\n <EmptyState />\n </PopoverContent>\n );\n }\n);\n\nAutoCompleteList.displayName = \"AutoCompleteList\";\n\nconst baseStyles: PopoverContentProps = {\n mt: \"4\",\n py: \"4\",\n opacity: \"0\",\n bg: \"#232934\",\n rounded: \"md\",\n maxH: \"350px\",\n border: \"none\",\n shadow: \"base\",\n pos: \"absolute\",\n zIndex: \"popover\",\n overflowY: \"auto\",\n\n _light: {\n bg: \"#ffffff\",\n },\n\n _focus: {\n boxShadow: \"none\",\n },\n};\n","import React from \"react\";\n\nexport const siblingInfo = (children: React.ReactNode) => {\n return React.Children.map(children, (child: any, i) => {\n if (child.type.displayName === \"AutoCompleteGroup\") {\n const sibling: any = React.Children.toArray(children)[i + 1];\n return React.cloneElement(child, {\n groupSibling: sibling\n ? sibling.type.displayName === \"AutoCompleteGroup\"\n : false,\n });\n }\n return child;\n });\n};\n","import { WrapItem } from \"@chakra-ui/layout\";\nimport { Tag, TagCloseButton, TagLabel, TagProps } from \"@chakra-ui/tag\";\nimport { runIfFn } from \"@chakra-ui/utils\";\nimport React, { memo } from \"react\";\n\ntype AutoCompleteTagProps = {\n disabled?: boolean;\n label: string;\n onRemove?: () => void;\n} & TagProps;\n\nexport const AutoCompleteTag = memo((props: AutoCompleteTagProps) => {\n const { label, onRemove, disabled, ...rest } = props;\n\n return (\n <WrapItem>\n <Tag\n borderRadius=\"md\"\n fontWeight=\"normal\"\n {...(disabled && disabledStyles)}\n {...rest}\n >\n <TagLabel>{label}</TagLabel>\n <TagCloseButton\n onClick={() => !disabled && runIfFn(onRemove)}\n cursor=\"pointer\"\n {...(disabled && disabledStyles)}\n />\n </Tag>\n </WrapItem>\n );\n});\n\nconst disabledStyles: TagProps = {\n cursor: \"text\",\n userSelect: \"none\",\n opacity: 0.4,\n _focus: { boxShadow: \"none\" },\n};\n"],"names":["createContext","name","errorMessage","AutoCompleteProvider","useAutoCompleteContext","fuzzyScore","str1","str2","gramSize","getNGrams","s","len","repeat","toLowerCase","v","Array","length","i","slice","s2","pairs1","pairs2","set","Set","total","hits","getDefItemValue","item","Object","keys","toString","setEmphasis","children","query","isEmpty","replace","RegExp","match","defaultFilterMethod","itemValue","itemLabel","indexOf","getMultipleWrapStyles","themeInput","multiple","field","_focusWithin","_focus","pos","minH","py","spacing","cursor","h","hasFirstItem","firstItem","getChildDeep","child","type","displayName","props","value","hasLastItem","lastItem","useAutoComplete","autoCompleteProps","closeOnBlur","closeOnSelect","creatable","emphasize","emptyState","freeSolo","isReadOnly","listAllValuesOnFocus","maxSuggestions","defaultValue","defaultValues","onReady","defaultIsOpen","shouldRenderSuggestions","suggestWhenEmpty","values","valuesProp","undefined","useDisclosure","isOpen","onClose","onOpen","runIfFn","itemList","getChildrenDeep","map","itemObj","pick","getValue","finObj","isDefined","label","getItemList","inputRef","useRef","inputWrapperRef","listRef","interactionRef","useState","listAll","setListAll","defaultQuery","isUndefined","setQuery","filteredResults","filter","fixed","_","index","filteredList","noFilter","useControllableState","onChange","newValues","find","opt","items","val","setValues","_itemList$","focusedValue","setFocusedValue","maxSelections","focusedIndex","findIndex","nextItem","getNextItem","rollNavigation","prevItem","getPrevItem","getFirstItem","getLastItem","useUpdateEffect","useEffect","focusedItem","onOptionFocus","focusMethod","current","isNewInput","selectItem","optionValue","includes","option","focus","focusInputOnSelect","onSelectOption","selectMethod","onCreateOption","omit","console","log","optionLabel","removeItem","prevValues","onTagRemoved","tags","tag","onRemove","dim","useDimensions","getEmptyStateProps","defaultEmptyState","every","getGroupProps","hasItems","_child$props","hasChildren","divider","hasFirstChild","hasLastChild","group","display","getInputProps","onBlur","onFocus","onKeyDown","variant","rest","wrapper","ref","onClick","input","e","openOnFocus","selectOnFocus","target","select","listIsFocused","relatedTarget","inputWrapperIsFocused","_inputWrapperRef$curr","contains","newValue","queryIsEmpty","key","disabled","preventDefault","callAll","getItemProps","_fixed","itemChild","valueProp","onMouseOver","sx","_getValue","isFocused","isValidSuggestion","dangerouslySetInnerHTML","__html","_disabled","opacity","userSelect","mark","color","bg","isObject","fontWeight","_light","root","getListProps","width","marginBox","resetItems","focusInput","AutoComplete","forwardRef","context","useImperativeHandle","React","Popover","isLazy","autoFocus","placement","chakra","div","position","w","AutoCompleteItem","forwardedRef","itemRef","useMergeRefs","itemProps","scrollIntoView","behavior","block","warn","error","restProps","Flex","baseItemStyles","mx","px","rounded","AutoCompleteCreatable","childrenProp","queryValue","queryExistsInList","some","AutoCompleteGroup","dividerStyles","useDividerStyles","Box","Divider","top","bottom","AutoCompleteGroupTitle","baseTitleStyles","ml","my","fontSize","letterSpacing","textTransform","hasGroupSibling","groupSibling","baseStyles","borderColor","dividerColor","mb","showDivider","AutoCompleteInput","useMultiStyleConfig","inputProps","wrapperRef","wrapperProps","Wrap","WrapItem","as","Input","id","EmptyState","emptyStyles","align","justify","fontStyle","AutoCompleteList","listProps","PopoverContent","Children","sibling","toArray","cloneElement","siblingInfo","mt","maxH","border","shadow","zIndex","overflowY","boxShadow","AutoCompleteTag","memo","Tag","borderRadius","disabledStyles","TagLabel","TagCloseButton"],"mappings":"0UAG8DA,gBAE5D,CACAC,KAAM,sBACNC,aACE,kIALUC,OAAsBC,ocCEpC,SAAgBC,EAAWC,EAAcC,EAAcC,YAC5CC,EAAUC,EAAWC,GAC5BD,EAAI,IAAIE,OAAOD,EAAM,GAAKD,EAAEG,cAAgB,IAAID,OAAOD,EAAM,WACzDG,EAAI,IAAIC,MAAML,EAAEM,OAASL,EAAM,GAC1BM,EAAI,EAAGA,EAAIH,EAAEE,OAAQC,IAC5BH,EAAEG,GAAKP,EAAEQ,MAAMD,EAAGA,EAAIN,UAEjBG,cAP4CN,IAAAA,EAAmB,SAU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BA,EAAQtP,KAAKC,qBAIdF,KDUF0P,CAAYnR,GACb0M,gBAAC6D,YAMTK,EAAiBjP,YAAc,mBAE/B,IAAM6N,EAAkC,CACtC4B,GAAI,IACJlQ,GAAI,IACJsK,QAAS,IACTI,GAAI,UACJsC,QAAS,KACTmD,KAAM,QACNC,OAAQ,OACRC,OAAQ,OACRvQ,IAAK,WACLwQ,OAAQ,UACRC,UAAW,OAEX1F,OAAQ,CACNH,GAAI,WAGN7K,OAAQ,CACN2Q,UAAW,2CEtCFC,EAAkBC,QAAK,SAAChQ,OAC3BqC,EAAuCrC,EAAvCqC,MAAOkE,EAAgCvG,EAAhCuG,SAAUsC,EAAsB7I,EAAtB6I,SAAalB,IAAS3H,YAG7C8K,gBAACyD,gBACCzD,gBAACmF,qBACCC,aAAa,KACbhG,WAAW,UACNrB,GAAYsH,EACbxI,GAEJmD,gBAACsF,gBAAU/N,GACXyI,gBAACuF,gCACCvI,QAAS,kBAAOe,GAAYjH,UAAQ2E,IACpC/G,OAAO,WACFqJ,GAAYsH,SAOrBA,EAA2B,CAC/B3Q,OAAQ,OACRqK,WAAY,OACZD,QAAS,GACTzK,OAAQ,CAAE2Q,UAAW"}
1
+ {"version":3,"file":"chakra-autocomplete.cjs.production.min.js","sources":["../src/autocomplete-context.ts","../src/helpers/fuzzySearch.ts","../src/helpers/items.ts","../src/helpers/input.ts","../src/helpers/group.ts","../src/use-autocomplete.ts","../src/autocomplete.tsx","../src/autocomplete-item.tsx","../src/autocomplete-creatable.tsx","../src/autocomplete-group.tsx","../src/autocomplete-input.tsx","../src/components/empty-state.tsx","../src/autocomplete-list.tsx","../src/helpers/list.ts","../src/autocomplete-tag.tsx"],"sourcesContent":["import { createContext } from \"@chakra-ui/react-utils\";\nimport { UseAutoCompleteReturn } from \"./types\";\n\nexport const [AutoCompleteProvider, useAutoCompleteContext] = createContext<\n UseAutoCompleteReturn\n>({\n name: \"AutoCompleteContext\",\n errorMessage:\n \"useAutoCompleteContext: `context` is undefined. Seems you forgot to wrap all autoomplete components within `<AutoComplete />`\",\n});\n","/*\n * @param str1 The first string to compare.\n * @param str2 The second string to compare.\n * @param gramSize The size of the grams. Defaults to length 2.\n */\nexport function fuzzyScore(str1: string, str2: string, gramSize: number = 2) {\n function getNGrams(s: string, len: number) {\n s = \" \".repeat(len - 1) + s.toLowerCase() + \" \".repeat(len - 1);\n let v = new Array(s.length - len + 1);\n for (let i = 0; i < v.length; i++) {\n v[i] = s.slice(i, i + len);\n }\n return v;\n }\n\n if (!str1?.length || !str2?.length) {\n return 0.0;\n }\n\n //Order the strings by length so the order they're passed in doesn't matter\n //and so the smaller string's ngrams are always the ones in the set\n let s1 = str1.length < str2.length ? str1 : str2;\n let s2 = str1.length < str2.length ? str2 : str1;\n\n let pairs1 = getNGrams(s1, gramSize);\n let pairs2 = getNGrams(s2, gramSize);\n let set = new Set<string>(pairs1);\n\n let total = pairs2.length;\n let hits = 0;\n for (let item of pairs2) {\n if (set.delete(item)) {\n hits++;\n }\n }\n return hits / total;\n}\n","import { getChildrenDeep } from \"react-nanny\";\nimport { pick, isDefined, isEmpty } from \"@chakra-ui/utils\";\nimport { ReactNode } from \"react\";\nimport { FlexProps } from \"@chakra-ui/react\";\nimport { fuzzyScore } from \"./fuzzySearch\";\nimport { Item } from \"../types\";\nimport { AutoCompleteItemProps } from \"../autocomplete-item\";\n\nexport const getDefItemValue = (item: AutoCompleteItemProps[\"value\"]) =>\n (typeof item === \"string\" ? item : item[Object.keys(item)[0]]).toString();\n\nexport const setEmphasis = (children: any, query: string) => {\n if (typeof children !== \"string\" || isEmpty(query)) {\n return children;\n }\n const newChildren = children\n .toString()\n .replace(\n new RegExp(escapeRegex(query), \"gi\"),\n (match: any) => `<mark>${match}</mark>`\n );\n return newChildren;\n};\n\nexport const getItemList = (children: ReactNode) => {\n const itemChildren = getChildrenDeep(\n children,\n (child: any) => child?.type?.displayName === \"AutoCompleteItem\"\n );\n\n return itemChildren.map(item => {\n const itemObj = pick(item.props, [\"value\", \"label\", \"fixed\", \"disabled\"]);\n const { getValue = getDefItemValue } = item.props;\n const value = getValue(itemObj.value);\n const finObj = isDefined(itemObj.label)\n ? itemObj\n : { ...itemObj, label: value };\n return { ...finObj, value };\n });\n};\n\nexport const getFocusedStyles = (): FlexProps => {\n return {\n bg: \"whiteAlpha.100\",\n _light: {\n bg: \"gray.200\",\n },\n };\n};\n\nexport const defaultFilterMethod = (\n query: string,\n itemValue: Item[\"value\"],\n itemLabel: Item[\"label\"]\n) => {\n return (\n itemValue?.toLowerCase().indexOf(query?.toLowerCase()) >= 0 ||\n itemLabel?.toLowerCase().indexOf(query?.toLowerCase()) >= 0 ||\n fuzzyScore(query, itemValue) >= 0.5 ||\n fuzzyScore(query, itemLabel) >= 0.5\n );\n};\n\nfunction escapeRegex(string: string) {\n return string.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n}\n","export const getMultipleWrapStyles = (themeInput: any, multiple?: boolean) => ({\n ...(multiple && {\n ...themeInput.field,\n _focusWithin: themeInput.field._focus,\n pos: \"relative\",\n minH: 9,\n // px: 3,\n py: 1.5,\n spacing: 3,\n }),\n cursor: \"text\",\n h: \"fit-content\",\n // w: \"full\",\n});\n","import { isDefined } from \"@chakra-ui/utils\";\nimport { getChildDeep } from \"react-nanny\";\nimport { ReactNode } from \"react\";\n\nexport const hasFirstItem = (children: ReactNode, firstItem: any) => {\n const result = getChildDeep(\n children,\n (child: any) =>\n child?.type?.displayName === \"AutoCompleteItem\" &&\n child.props.value === firstItem?.value\n );\n\n return result;\n};\nexport const hasLastItem = (children: ReactNode, lastItem: any) => {\n const result = getChildDeep(\n children,\n (child: any) =>\n child?.type?.displayName === \"AutoCompleteItem\" &&\n child.props.value === lastItem?.value\n );\n return result;\n};\n\nexport const hasChildren = (children: any, filteredList: any[]) => {\n return isDefined(\n getChildDeep(\n children,\n (child: any) =>\n filteredList.findIndex(i => i.value === child.props?.value) >= 0\n )\n );\n};\n","import {\n useDimensions,\n useDisclosure,\n useUpdateEffect,\n useControllableState,\n} from \"@chakra-ui/react\";\nimport {\n callAll,\n getFirstItem,\n getLastItem,\n getNextItem,\n getPrevItem,\n isObject,\n isEmpty,\n isUndefined,\n runIfFn,\n} from \"@chakra-ui/utils\";\nimport { omit } from \"@chakra-ui/utils\";\n\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { AutoCompleteProps } from \"./autocomplete\";\nimport {\n defaultFilterMethod,\n getDefItemValue,\n getFocusedStyles,\n getItemList,\n setEmphasis,\n} from \"./helpers/items\";\nimport { getMultipleWrapStyles } from \"./helpers/input\";\nimport { hasChildren, hasFirstItem, hasLastItem } from \"./helpers/group\";\nimport { Item, UseAutoCompleteReturn } from \"./types\";\n\n/**\n * useAutoComplete that provides all the state and focus management logic\n * for the autocomplete component. It is consumed by the `Autocomplete` component\n *\n */\n\nexport function useAutoComplete(\n autoCompleteProps: AutoCompleteProps\n): UseAutoCompleteReturn {\n let {\n closeOnBlur = true,\n closeOnSelect,\n creatable,\n emphasize,\n emptyState = true,\n freeSolo,\n isReadOnly,\n listAllValuesOnFocus,\n maxSuggestions,\n multiple,\n defaultValue,\n defaultValues = defaultValue ? [defaultValue] : [],\n onReady,\n defaultIsOpen,\n restoreOnBlurIfEmpty = true,\n shouldRenderSuggestions = () => true,\n submitKeys = [],\n suggestWhenEmpty,\n value,\n values: valuesProp = value\n ? typeof value === \"string\"\n ? [value]\n : [...value]\n : undefined,\n } = autoCompleteProps;\n closeOnSelect = closeOnSelect ? closeOnSelect : multiple ? false : true;\n\n freeSolo = freeSolo ? freeSolo : multiple ? true : autoCompleteProps.freeSolo;\n\n const { isOpen, onClose, onOpen } = useDisclosure({ defaultIsOpen });\n\n const children = runIfFn(autoCompleteProps.children, {\n isOpen,\n onClose,\n onOpen,\n });\n const itemList: Item[] = getItemList(children);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const inputWrapperRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const interactionRef = useRef<\"mouse\" | \"keyboard\" | null>(null);\n\n const [listAll, setListAll] = useState(false);\n\n let defaultQuery = \"\";\n if (multiple) defaultQuery = \"\";\n else if (!isUndefined(defaultValues)) defaultQuery = defaultValues[0];\n else if (!isUndefined(valuesProp)) defaultQuery = valuesProp[0];\n\n const [query, setQuery] = useState<string>(defaultQuery ?? \"\");\n const filteredResults = itemList\n .filter(\n i =>\n i.fixed ||\n runIfFn(\n autoCompleteProps.filter || defaultFilterMethod,\n query,\n i.value,\n i.label\n ) ||\n listAll\n )\n .filter((_, index) => (maxSuggestions ? index < maxSuggestions : true));\n\n // Add Creatable to Filtered List\n const creatableArr: Item[] = creatable\n ? [{ value: query, noFilter: true, creatable: true }]\n : [];\n\n const filteredList = [...filteredResults, ...creatableArr];\n const [values, setValues] = useControllableState({\n defaultValue: defaultValues,\n value: valuesProp,\n onChange: (newValues: any[]) => {\n const item = filteredList.find(opt => opt.value === newValues[0]);\n const items = newValues.map(val =>\n filteredList.find(opt => opt.value === val)\n );\n runIfFn(\n autoCompleteProps.onChange,\n multiple ? newValues : newValues[0],\n multiple ? items : item\n );\n },\n });\n\n const [focusedValue, setFocusedValue] = useState<Item[\"value\"]>(\n itemList[0]?.value\n );\n\n const maxSelections = autoCompleteProps.maxSelections || values.length + 1;\n\n const focusedIndex = filteredList.findIndex(i => i.value === focusedValue);\n const nextItem = getNextItem(\n focusedIndex,\n filteredList,\n !!autoCompleteProps.rollNavigation\n );\n const prevItem = getPrevItem(\n focusedIndex,\n filteredList,\n !!autoCompleteProps.rollNavigation\n );\n const firstItem = getFirstItem(filteredList);\n const lastItem = getLastItem(filteredList);\n\n useUpdateEffect(() => {\n setFocusedValue(firstItem?.value);\n }, [query]);\n\n useEffect(() => {\n const focusedItem = itemList.find(i => i.value === focusedValue);\n runIfFn(autoCompleteProps.onOptionFocus, {\n item: focusedItem!,\n focusMethod: interactionRef.current,\n isNewInput: focusedItem?.creatable,\n });\n }, [focusedValue, autoCompleteProps.onOptionFocus]);\n\n const selectItem = (optionValue: Item[\"value\"]) => {\n if (!values.includes(optionValue) && values.length < maxSelections) {\n setValues(v => (multiple ? [...v, optionValue] : [optionValue]));\n }\n\n const option = filteredList.find(i => i.value === optionValue);\n\n if (multiple) {\n inputRef.current?.focus();\n }\n if (autoCompleteProps.focusInputOnSelect) inputRef.current?.focus();\n runIfFn(autoCompleteProps.onSelectOption, {\n item: option!,\n selectMethod: interactionRef.current,\n isNewInput: option?.creatable,\n });\n if (option?.creatable) {\n runIfFn(autoCompleteProps.onCreateOption, {\n item: omit(option!, [\"noFilter\"]),\n selectMethod: interactionRef.current,\n });\n }\n\n const optionLabel = option?.label || option?.value;\n setQuery(() => (multiple ? \"\" : optionLabel ?? \"\"));\n\n if (closeOnSelect) onClose();\n };\n\n const removeItem: UseAutoCompleteReturn[\"removeItem\"] = (\n itemValue,\n focusInput\n ) => {\n setValues(prevValues => {\n const item = itemList.find(opt => opt.value === itemValue);\n runIfFn(autoCompleteProps.onTagRemoved, itemValue, item, prevValues);\n return prevValues.filter(i => i !== itemValue);\n });\n if (query === itemValue) setQuery(\"\");\n if (focusInput) inputRef.current?.focus();\n };\n\n const resetItems = (focusInput?: boolean) => {\n setValues([]);\n if (focusInput) inputRef.current?.focus();\n };\n\n const tags = multiple\n ? values.map(tag => ({\n label: itemList.find(item => item.value === tag)?.label || tag,\n onRemove: () => removeItem(tag),\n }))\n : [];\n\n useEffect(() => {\n runIfFn(onReady, { tags });\n }, [values]);\n\n const getInputProps: UseAutoCompleteReturn[\"getInputProps\"] = (\n props,\n themeInput\n ) => {\n const { onBlur, onChange, onFocus, onKeyDown, variant, ...rest } = props;\n\n return {\n wrapper: {\n ref: inputWrapperRef,\n onClick: () => {\n inputRef?.current?.focus();\n },\n ...getMultipleWrapStyles(themeInput, multiple),\n ...rest,\n },\n input: {\n isReadOnly,\n onFocus: e => {\n runIfFn(onFocus, e);\n if (autoCompleteProps.openOnFocus && !isReadOnly) onOpen();\n if (autoCompleteProps.selectOnFocus) e.target.select();\n if (listAllValuesOnFocus) setListAll(true);\n },\n onBlur: e => {\n runIfFn(onBlur, e);\n const listIsFocused = e.relatedTarget === listRef?.current;\n const inputWrapperIsFocused = inputWrapperRef.current?.contains(\n e.relatedTarget as any\n );\n if (!listIsFocused && !inputWrapperIsFocused) {\n if (closeOnBlur) onClose();\n if (\n !values.includes(e.target.value) &&\n !freeSolo &&\n restoreOnBlurIfEmpty\n ) {\n const latestValue = getLastItem(values);\n const latestValueItem = itemList.find(\n i => i.value === latestValue\n );\n const latestValueLabel =\n latestValueItem?.label || latestValueItem?.value || \"\";\n setQuery(latestValueLabel);\n }\n }\n },\n onChange: e => {\n const newValue = e.target.value;\n runIfFn(onChange, e);\n setQuery(newValue);\n const queryIsEmpty = isEmpty(newValue);\n if (\n runIfFn(shouldRenderSuggestions, newValue) &&\n (!queryIsEmpty || suggestWhenEmpty)\n )\n onOpen();\n else onClose();\n setListAll(false);\n },\n onKeyDown: e => {\n runIfFn(onKeyDown, e);\n interactionRef.current = \"keyboard\";\n\n const { key } = e;\n const focusedItem = filteredList[focusedIndex];\n if ([\"Enter\", ...submitKeys].includes(key)) {\n if (focusedItem && !focusedItem?.disabled)\n selectItem(focusedItem?.value);\n else inputRef.current?.focus();\n e.preventDefault();\n return;\n }\n\n if (key === \"ArrowDown\") {\n setFocusedValue(nextItem?.value);\n e.preventDefault();\n return;\n }\n\n if (key === \"ArrowUp\") {\n setFocusedValue(prevItem?.value);\n\n e.preventDefault();\n return;\n }\n\n if (key === \"Tab\") {\n setFocusedValue(nextItem?.value);\n\n if (isOpen) e.preventDefault();\n return;\n }\n\n if (key === \"Home\") {\n setFocusedValue(firstItem?.value);\n e.preventDefault();\n return;\n }\n\n if (key === \"End\") {\n setFocusedValue(lastItem?.value);\n e.preventDefault();\n return;\n }\n\n if (key === \"Escape\") {\n callAll(onClose, e.preventDefault);\n }\n },\n value: query,\n variant: multiple ? \"unstyled\" : variant,\n ...rest,\n },\n };\n };\n\n const dim = useDimensions(inputWrapperRef, true);\n const getListProps: UseAutoCompleteReturn[\"getListProps\"] = () => {\n const width = dim?.marginBox.width as number;\n return {\n width,\n };\n };\n\n const getItemProps: UseAutoCompleteReturn[\"getItemProps\"] = (\n props,\n creatable\n ) => {\n const {\n _fixed,\n _focus,\n children: itemChild,\n disabled,\n label,\n value: valueProp,\n fixed,\n getValue = getDefItemValue,\n onClick,\n onMouseOver,\n sx,\n ...rest\n } = props;\n const value = creatable ? valueProp : getValue(valueProp)?.toString();\n const isFocused = value === focusedValue;\n const isValidSuggestion =\n filteredList.findIndex(i => i.value === value) >= 0;\n const itemLabel = itemChild || label || value;\n return {\n item: {\n ...(typeof itemLabel !== \"string\" || !emphasize\n ? { children: itemLabel }\n : {\n dangerouslySetInnerHTML: {\n __html: setEmphasis(itemLabel, query),\n },\n }),\n \"aria-selected\": values.includes(value),\n \"aria-disabled\": disabled,\n _disabled: { opacity: 0.4, cursor: \"not-allowed\", userSelect: \"none\" },\n onClick: e => {\n runIfFn(onClick, e);\n if (!disabled) selectItem(value);\n else inputRef.current?.focus();\n },\n onMouseOver: e => {\n runIfFn(onMouseOver, e);\n setFocusedValue(value);\n interactionRef.current = \"mouse\";\n },\n sx: {\n ...sx,\n mark: {\n color: \"inherit\",\n bg: \"transparent\",\n ...(isObject(emphasize)\n ? emphasize\n : {\n fontWeight: emphasize ? \"extrabold\" : \"inherit\",\n }),\n },\n },\n ...(isFocused && (_focus || getFocusedStyles())),\n ...(fixed && _fixed),\n ...rest,\n },\n root: {\n isValidSuggestion,\n value,\n },\n };\n };\n\n const getGroupProps: UseAutoCompleteReturn[\"getGroupProps\"] = props => {\n const hasItems = hasChildren(props.children, filteredList);\n return {\n divider: {\n hasFirstChild: hasFirstItem(props.children, firstItem),\n hasLastChild: hasLastItem(\n props.children,\n getLastItem(filteredList.filter(i => isUndefined(i?.noFilter)))\n ),\n },\n group: {\n display: hasItems ? \"initial\" : \"none\",\n },\n };\n };\n\n const getEmptyStateProps: UseAutoCompleteReturn[\"getEmptyStateProps\"] = defaultEmptyState => {\n const noSuggestions = filteredList.every(i => i.noFilter);\n if (noSuggestions && emptyState && !creatable) {\n return typeof emptyState === \"boolean\"\n ? defaultEmptyState\n : runIfFn(emptyState, { query });\n }\n };\n\n return {\n autoCompleteProps,\n children,\n filteredList,\n filteredResults,\n focusedValue,\n getEmptyStateProps,\n getGroupProps,\n getInputProps,\n getItemProps,\n getListProps,\n inputRef,\n interactionRef,\n isOpen,\n itemList,\n listRef,\n onClose,\n onOpen,\n query,\n removeItem,\n resetItems,\n setQuery,\n tags,\n values,\n };\n}\n","import React, { useImperativeHandle } from \"react\";\nimport { MaybeRenderProp } from \"@chakra-ui/react-utils\";\n\nimport { AutoCompleteProvider } from \"./autocomplete-context\";\nimport { useAutoComplete } from \"./use-autocomplete\";\nimport { chakra, forwardRef, Popover } from \"@chakra-ui/react\";\nimport { AutoCompleteRefMethods, UseAutoCompleteProps } from \"./types\";\n\nexport type AutoCompleteChildProps = {\n isOpen: boolean;\n onClose: () => void;\n onOpen: () => void;\n};\nexport interface AutoCompleteProps extends UseAutoCompleteProps {\n children: MaybeRenderProp<AutoCompleteChildProps>;\n ref?: React.RefObject<AutoCompleteRefMethods>;\n}\n\nexport const AutoComplete = forwardRef<AutoCompleteProps, \"div\">(\n (props, ref) => {\n const context = useAutoComplete(props);\n const {\n children,\n isOpen,\n onClose,\n onOpen,\n resetItems,\n removeItem,\n } = context;\n\n useImperativeHandle(ref, () => ({\n resetItems,\n removeItem,\n }));\n\n return (\n <AutoCompleteProvider value={context}>\n <Popover\n isLazy\n isOpen={isOpen}\n onClose={onClose}\n onOpen={onOpen}\n autoFocus={false}\n placement=\"bottom\"\n closeOnBlur={true}\n >\n <chakra.div\n sx={{\n \".chakra-popover__popper\": {\n position: \"unset !important\",\n },\n }}\n w=\"full\"\n ref={ref}\n >\n {children}\n </chakra.div>\n </Popover>\n </AutoCompleteProvider>\n );\n }\n);\n\nAutoComplete.displayName = \"AutoComplete\";\n","import {\n CSSObject,\n Flex,\n FlexProps,\n forwardRef,\n useMergeRefs,\n} from \"@chakra-ui/react\";\nimport { isUndefined, omit } from \"@chakra-ui/utils\";\nimport React, { useEffect, useRef } from \"react\";\n\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\n\nexport interface AutoCompleteItemProps extends FlexProps {\n value: any;\n label?: string;\n fixed?: boolean;\n _focus?: CSSObject | any;\n disabled?: boolean;\n _fixed?: CSSObject;\n getValue?: (item: AutoCompleteItemProps[\"value\"]) => any;\n}\n\nexport const AutoCompleteItem = forwardRef<AutoCompleteItemProps, \"div\">(\n (props, forwardedRef) => {\n const {\n focusedValue,\n getItemProps,\n interactionRef,\n } = useAutoCompleteContext();\n const itemRef = useRef<any>();\n const ref = useMergeRefs(forwardedRef, itemRef);\n\n const itemProps = getItemProps(props);\n const { isValidSuggestion, value } = itemProps.root;\n\n const isFocused = focusedValue === value;\n\n useEffect(() => {\n if (isFocused && interactionRef.current === \"keyboard\")\n itemRef?.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n });\n }, [isFocused, interactionRef]);\n\n useEffect(() => {\n if (typeof value !== \"string\") console.warn(\"wow\");\n if (typeof value !== \"string\" && isUndefined(props.getValue))\n console.error(\n \"You must define the `getValue` prop, when an Item's value is not a string\"\n );\n }, []);\n\n const { children, dangerouslySetInnerHTML, ...restProps } = itemProps.item;\n\n const rest = omit(restProps, [\"groupId\"] as any);\n\n return isValidSuggestion ? (\n <Flex ref={ref} {...baseItemStyles} {...rest}>\n {children ? (\n children\n ) : (\n <span dangerouslySetInnerHTML={dangerouslySetInnerHTML} />\n )}\n </Flex>\n ) : null;\n }\n);\n\nAutoCompleteItem.displayName = \"AutoCompleteItem\";\n\nexport const baseItemStyles: FlexProps = {\n mx: \"2\",\n px: \"2\",\n py: \"2\",\n rounded: \"md\",\n cursor: \"pointer\",\n};\n","import { Flex, FlexProps } from \"@chakra-ui/react\";\nimport { MaybeRenderProp } from \"@chakra-ui/react-utils\";\nimport { isEmpty, runIfFn } from \"@chakra-ui/utils\";\n\nimport React from \"react\";\n\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\nimport { baseItemStyles } from \"./autocomplete-item\";\n\ninterface AutoCompleteCreatableProps extends FlexProps {\n children?: MaybeRenderProp<{ value: any }>;\n}\n\nexport function AutoCompleteCreatable(props: AutoCompleteCreatableProps) {\n const { children: childrenProp, ...rest } = props;\n const {\n autoCompleteProps,\n getItemProps,\n query,\n filteredResults,\n } = useAutoCompleteContext();\n\n const queryValue = <mark>{query}</mark>;\n const { children, ...itemProps } = getItemProps(\n {\n ...props,\n value: query,\n children: runIfFn(childrenProp, {\n value: queryValue,\n }),\n },\n true\n ).item;\n\n const queryExistsInList = filteredResults.some(i => i.value === query);\n const showCreatable =\n autoCompleteProps.creatable && !isEmpty(query) && !queryExistsInList;\n\n return showCreatable ? (\n <Flex {...baseItemStyles} {...itemProps} {...rest}>\n {children || `Add ${query}`}\n </Flex>\n ) : null;\n}\n\nAutoCompleteCreatable.displayName = \"AutoCompleteCreatable\";\n","import {\n Box,\n BoxProps,\n Divider,\n DividerProps,\n Flex,\n FlexProps,\n forwardRef,\n} from \"@chakra-ui/react\";\nimport { omit } from \"@chakra-ui/utils\";\nimport React from \"react\";\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\n\nexport interface AutoCompleteGroupProps extends BoxProps {\n children?: React.ReactNode;\n showDivider?: boolean;\n dividerColor?: string;\n}\n\nexport const AutoCompleteGroup = forwardRef<AutoCompleteGroupProps, \"div\">(\n (props, ref) => {\n const { children, showDivider, ...restProps } = props;\n const rest = omit(restProps, [\"groupSibling\"] as any);\n\n const { getGroupProps } = useAutoCompleteContext();\n\n const { group } = getGroupProps(props);\n\n const dividerStyles = useDividerStyles(props);\n\n return (\n <Box ref={ref} {...group} {...rest}>\n <Divider {...dividerStyles.top} />\n {children}\n <Divider {...dividerStyles.bottom} />\n </Box>\n );\n }\n);\n\nexport const AutoCompleteGroupTitle = forwardRef<FlexProps, \"div\">(\n (props, ref) => {\n return <Flex {...baseTitleStyles} {...props} ref={ref} />;\n }\n);\n\nAutoCompleteGroup.displayName = \"AutoCompleteGroup\";\nAutoCompleteGroupTitle.displayName = \"AutoCompleteGroupTitle\";\n\nconst baseTitleStyles: FlexProps = {\n ml: 5,\n my: 1,\n fontSize: \"xs\",\n letterSpacing: \"wider\",\n fontWeight: \"extrabold\",\n textTransform: \"uppercase\",\n};\n\nconst useDividerStyles = (\n props: AutoCompleteGroupProps & { groupSibling?: boolean }\n) => {\n const { getGroupProps } = useAutoCompleteContext();\n\n const hasGroupSibling: unknown = props.groupSibling;\n\n const {\n divider: { hasFirstChild, hasLastChild },\n } = getGroupProps(props as AutoCompleteGroupProps);\n\n const baseStyles: DividerProps = {\n my: 2,\n borderColor: props.dividerColor,\n };\n\n const top = {\n ...baseStyles,\n mb: 4,\n display: !props.showDivider || hasFirstChild ? \"none\" : \"\",\n };\n const bottom = {\n ...baseStyles,\n display:\n !props.showDivider || hasLastChild || hasGroupSibling ? \"none\" : \"\",\n };\n\n return { top, bottom };\n};\n","import {\n CSSObject,\n forwardRef,\n Input,\n InputProps,\n useMergeRefs,\n useMultiStyleConfig,\n Wrap,\n WrapItem,\n} from \"@chakra-ui/react\";\nimport { runIfFn } from \"@chakra-ui/utils\";\nimport { MaybeRenderProp } from \"@chakra-ui/react-utils\";\nimport React from \"react\";\n\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\nimport { UseAutoCompleteReturn } from \"./types\";\n\nexport interface AutoCompleteInputProps extends InputProps {\n children?: MaybeRenderProp<{ tags: UseAutoCompleteReturn[\"tags\"] }>;\n wrapStyles?: CSSObject;\n}\n\nexport const AutoCompleteInput = forwardRef<AutoCompleteInputProps, \"input\">(\n (props, forwardedRef) => {\n const { inputRef, getInputProps, tags } = useAutoCompleteContext();\n\n // const ref = useMergeRefs(forwardedRef, inputRef);\n\n const { children: childrenProp, ...rest } = props;\n\n const themeInput: any = useMultiStyleConfig(\"Input\", props);\n\n const { wrapper, input: inputProps } = getInputProps(rest, themeInput);\n const { ref: wrapperRef, ...wrapperProps } = wrapper;\n const ref = useMergeRefs(forwardedRef, inputRef);\n\n const children = runIfFn(childrenProp, { tags });\n\n return (\n <Wrap {...wrapperProps} ref={wrapperRef}>\n {children}\n <WrapItem as={Input} {...(inputProps as any)} ref={ref} />\n </Wrap>\n );\n }\n);\n\nAutoCompleteInput.displayName = \"Input\";\n\nAutoCompleteInput.id = \"Input\";\n","import { Box, BoxProps, Flex, FlexProps } from \"@chakra-ui/layout\";\nimport React from \"react\";\nimport { useAutoCompleteContext } from \"../autocomplete-context\";\n\nexport const EmptyState = (props: BoxProps) => {\n const { getEmptyStateProps } = useAutoCompleteContext();\n\n const emptyState = getEmptyStateProps(\n <Flex {...emptyStyles}>No options found!</Flex>\n );\n\n return <Box {...props}>{emptyState}</Box>;\n};\n\nconst emptyStyles: FlexProps = {\n fontSize: \"sm\",\n align: \"center\",\n justify: \"center\",\n fontWeight: \"bold\",\n fontStyle: \"italic\",\n};\n","import {\n forwardRef,\n PopoverContent,\n PopoverContentProps,\n useMergeRefs,\n} from \"@chakra-ui/react\";\nimport React from \"react\";\nimport { useAutoCompleteContext } from \"./autocomplete-context\";\nimport { EmptyState } from \"./components/empty-state\";\nimport { siblingInfo } from \"./helpers/list\";\n\nexport type AutoCompleteListProps = PopoverContentProps;\n\nexport const AutoCompleteList = forwardRef<AutoCompleteListProps, \"div\">(\n (props, forwardedRef) => {\n const { children, ...rest } = props;\n const { listRef, getListProps } = useAutoCompleteContext();\n const ref = useMergeRefs(forwardedRef, listRef);\n const listProps = getListProps();\n\n return (\n <PopoverContent ref={ref} {...baseStyles} {...listProps} {...rest}>\n {siblingInfo(children)}\n <EmptyState />\n </PopoverContent>\n );\n }\n);\n\nAutoCompleteList.displayName = \"AutoCompleteList\";\n\nconst baseStyles: PopoverContentProps = {\n mt: \"4\",\n py: \"4\",\n opacity: \"0\",\n bg: \"#232934\",\n rounded: \"md\",\n maxH: \"350px\",\n border: \"none\",\n shadow: \"base\",\n pos: \"absolute\",\n zIndex: \"popover\",\n overflowY: \"auto\",\n\n _light: {\n bg: \"#ffffff\",\n },\n\n _focus: {\n boxShadow: \"none\",\n },\n};\n","import React from \"react\";\n\nexport const siblingInfo = (children: React.ReactNode) => {\n return React.Children.map(children, (child: any, i) => {\n if (child.type.displayName === \"AutoCompleteGroup\") {\n const sibling: any = React.Children.toArray(children)[i + 1];\n return React.cloneElement(child, {\n groupSibling: sibling\n ? sibling.type.displayName === \"AutoCompleteGroup\"\n : false,\n });\n }\n return child;\n });\n};\n","import { WrapItem } from \"@chakra-ui/layout\";\nimport { Tag, TagCloseButton, TagLabel, TagProps } from \"@chakra-ui/tag\";\nimport { runIfFn } from \"@chakra-ui/utils\";\nimport React, { memo } from \"react\";\n\ntype AutoCompleteTagProps = {\n disabled?: boolean;\n label: string;\n onRemove?: () => void;\n} & TagProps;\n\nexport const AutoCompleteTag = memo((props: AutoCompleteTagProps) => {\n const { label, onRemove, disabled, ...rest } = props;\n\n return (\n <WrapItem>\n <Tag\n borderRadius=\"md\"\n fontWeight=\"normal\"\n {...(disabled && disabledStyles)}\n {...rest}\n >\n <TagLabel>{label}</TagLabel>\n <TagCloseButton\n onClick={() => !disabled && runIfFn(onRemove)}\n cursor=\"pointer\"\n {...(disabled && disabledStyles)}\n />\n </Tag>\n </WrapItem>\n );\n});\n\nconst disabledStyles: TagProps = {\n cursor: \"text\",\n userSelect: \"none\",\n opacity: 0.4,\n _focus: { boxShadow: \"none\" },\n};\n"],"names":["createContext","name","errorMessage","AutoCompleteProvider","useAutoCompleteContext","fuzzyScore","str1","str2","gramSize","getNGrams","s","len","repeat","toLowerCase","v","Array","length","i","slice","s2","pairs1","pairs2","set","Set","total","hits","getDefItemValue","item","Object","keys","toString","setEmphasis","children","query","isEmpty","replace","RegExp","match","defaultFilterMethod","itemValue","itemLabel","indexOf","getMultipleWrapStyles","themeInput","multiple","field","_focusWithin","_focus","pos","minH","py","spacing","cursor","h","hasFirstItem","firstItem","getChildDeep","child","type","displayName","props","value","hasLastItem","lastItem","useAutoComplete","autoCompleteProps","closeOnBlur","closeOnSelect","creatable","emphasize","emptyState","freeSolo","isReadOnly","listAllValuesOnFocus","maxSuggestions","defaultValue","defaultValues","onReady","defaultIsOpen","restoreOnBlurIfEmpty","shouldRenderSuggestions","submitKeys","suggestWhenEmpty","values","valuesProp","undefined","useDisclosure","isOpen","onClose","onOpen","runIfFn","itemList","getChildrenDeep","map","itemObj","pick","getValue","finObj","isDefined","label","getItemList","inputRef","useRef","inputWrapperRef","listRef","interactionRef","useState","listAll","setListAll","defaultQuery","isUndefined","setQuery","filteredResults","filter","fixed","_","index","filteredList","noFilter","useControllableState","onChange","newValues","find","opt","items","val","setValues","_itemList$","focusedValue","setFocusedValue","maxSelections","focusedIndex","findIndex","nextItem","getNextItem","rollNavigation","prevItem","getPrevItem","getFirstItem","getLastItem","useUpdateEffect","useEffect","focusedItem","onOptionFocus","focusMethod","current","isNewInput","selectItem","optionValue","includes","option","focus","focusInputOnSelect","onSelectOption","selectMethod","onCreateOption","omit","optionLabel","removeItem","focusInput","prevValues","onTagRemoved","tags","tag","onRemove","dim","useDimensions","getEmptyStateProps","defaultEmptyState","every","getGroupProps","hasItems","_child$props","hasChildren","divider","hasFirstChild","hasLastChild","group","display","getInputProps","onBlur","onFocus","onKeyDown","variant","rest","wrapper","ref","onClick","input","e","openOnFocus","selectOnFocus","target","select","listIsFocused","relatedTarget","inputWrapperIsFocused","_inputWrapperRef$curr","contains","latestValue","latestValueItem","newValue","queryIsEmpty","key","disabled","preventDefault","callAll","getItemProps","_fixed","itemChild","valueProp","onMouseOver","sx","_getValue","isFocused","isValidSuggestion","dangerouslySetInnerHTML","__html","_disabled","opacity","userSelect","mark","color","bg","isObject","fontWeight","_light","root","getListProps","width","marginBox","resetItems","AutoComplete","forwardRef","context","useImperativeHandle","React","Popover","isLazy","autoFocus","placement","chakra","div","position","w","AutoCompleteItem","forwardedRef","itemRef","useMergeRefs","itemProps","scrollIntoView","behavior","block","console","warn","error","restProps","Flex","baseItemStyles","mx","px","rounded","AutoCompleteCreatable","childrenProp","queryValue","queryExistsInList","some","AutoCompleteGroup","dividerStyles","useDividerStyles","Box","Divider","top","bottom","AutoCompleteGroupTitle","baseTitleStyles","ml","my","fontSize","letterSpacing","textTransform","hasGroupSibling","groupSibling","baseStyles","borderColor","dividerColor","mb","showDivider","AutoCompleteInput","useMultiStyleConfig","inputProps","wrapperRef","wrapperProps","Wrap","WrapItem","as","Input","id","EmptyState","emptyStyles","align","justify","fontStyle","AutoCompleteList","listProps","PopoverContent","Children","sibling","toArray","cloneElement","siblingInfo","mt","maxH","border","shadow","zIndex","overflowY","boxShadow","AutoCompleteTag","memo","Tag","borderRadius","disabledStyles","TagLabel","TagCloseButton"],"mappings":"0UAG8DA,gBAE5D,CACAC,KAAM,sBACNC,aACE,kIALUC,OAAsBC,ocCEpC,SAAgBC,EAAWC,EAAcC,EAAcC,YAC5CC,EAAUC,EAAWC,GAC5BD,EAAI,IAAIE,OAAOD,EAAM,GAAKD,EAAEG,cAAgB,IAAID,OAAOD,EAAM,WACzDG,EAAI,IAAIC,MAAML,EAAEM,OAASL,EAAM,GAC1BM,EAAI,EAAGA,EAAIH,EAAEE,OAAQC,IAC5BH,EAAEG,GAAKP,EAAEQ,MAAMD,EAAGA,EAAIN,UAEjBG,cAP4CN,IAAAA,EAAmB,SAUnEF,IAAAA,EAAMU,cAAWT,IAAAA,EAAMS,cACnB,YAMLG,EAAKb,EAAKU,OAAST,EAAKS,OAAST,EAAOD,EAExCc,EAASX,EAHJH,EAAKU,OAAST,EAAKS,OAASV,EAAOC,EAGjBC,GACvBa,EAASZ,EAAUU,EAAIX,GACvBc,EAAM,IAAIC,IAAYH,GAEtBI,EAAQH,EAAOL,OACfS,EAAO,wrBACMJ,kBACXC,mBACFG,WAGGA,EAAOD,EC3BT,IAAME,EAAkB,SAACC,UACb,iBAATA,EAAoBA,EAAOA,EAAKC,OAAOC,KAAKF,G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CACtC4B,GAAI,IACJrQ,GAAI,IACJyK,QAAS,IACTI,GAAI,UACJsC,QAAS,KACTmD,KAAM,QACNC,OAAQ,OACRC,OAAQ,OACR1Q,IAAK,WACL2Q,OAAQ,UACRC,UAAW,OAEX1F,OAAQ,CACNH,GAAI,WAGNhL,OAAQ,CACN8Q,UAAW,2CEtCFC,EAAkBC,QAAK,SAACnQ,OAC3BuC,EAAuCvC,EAAvCuC,MAAOiE,EAAgCxG,EAAhCwG,SAAUwC,EAAsBhJ,EAAtBgJ,SAAapB,IAAS5H,YAG7CgL,gBAAC0D,gBACC1D,gBAACoF,qBACCC,aAAa,KACbhG,WAAW,UACNrB,GAAYsH,EACb1I,GAEJoD,gBAACuF,gBAAUhO,GACXyI,gBAACwF,gCACCzI,QAAS,kBAAOiB,GAAYlH,UAAQ0E,IACpChH,OAAO,WACFwJ,GAAYsH,SAOrBA,EAA2B,CAC/B9Q,OAAQ,OACRwK,WAAY,OACZD,QAAS,GACT5K,OAAQ,CAAE8Q,UAAW"}
@@ -246,10 +246,14 @@ function useAutoComplete(autoCompleteProps) {
246
246
  defaultValues = _autoCompleteProps$de === void 0 ? defaultValue ? [defaultValue] : [] : _autoCompleteProps$de,
247
247
  onReady = autoCompleteProps.onReady,
248
248
  defaultIsOpen = autoCompleteProps.defaultIsOpen,
249
+ _autoCompleteProps$re = autoCompleteProps.restoreOnBlurIfEmpty,
250
+ restoreOnBlurIfEmpty = _autoCompleteProps$re === void 0 ? true : _autoCompleteProps$re,
249
251
  _autoCompleteProps$sh = autoCompleteProps.shouldRenderSuggestions,
250
252
  shouldRenderSuggestions = _autoCompleteProps$sh === void 0 ? function () {
251
253
  return true;
252
254
  } : _autoCompleteProps$sh,
255
+ _autoCompleteProps$su = autoCompleteProps.submitKeys,
256
+ submitKeys = _autoCompleteProps$su === void 0 ? [] : _autoCompleteProps$su,
253
257
  suggestWhenEmpty = autoCompleteProps.suggestWhenEmpty,
254
258
  value = autoCompleteProps.value,
255
259
  _autoCompleteProps$va = autoCompleteProps.values,
@@ -376,7 +380,6 @@ function useAutoComplete(autoCompleteProps) {
376
380
  });
377
381
  }
378
382
 
379
- console.log(option);
380
383
  var optionLabel = (option == null ? void 0 : option.label) || (option == null ? void 0 : option.value);
381
384
  setQuery(function () {
382
385
  return multiple ? "" : optionLabel != null ? optionLabel : "";
@@ -384,7 +387,9 @@ function useAutoComplete(autoCompleteProps) {
384
387
  if (closeOnSelect) onClose();
385
388
  };
386
389
 
387
- var removeItem = function removeItem(itemValue) {
390
+ var removeItem = function removeItem(itemValue, focusInput) {
391
+ var _inputRef$current3;
392
+
388
393
  setValues(function (prevValues) {
389
394
  var item = itemList.find(function (opt) {
390
395
  return opt.value === itemValue;
@@ -395,13 +400,14 @@ function useAutoComplete(autoCompleteProps) {
395
400
  });
396
401
  });
397
402
  if (query === itemValue) setQuery("");
403
+ if (focusInput) (_inputRef$current3 = inputRef.current) == null ? void 0 : _inputRef$current3.focus();
398
404
  };
399
405
 
400
406
  var resetItems = function resetItems(focusInput) {
401
- var _inputRef$current3;
407
+ var _inputRef$current4;
402
408
 
403
409
  setValues([]);
404
- if (focusInput) (_inputRef$current3 = inputRef.current) == null ? void 0 : _inputRef$current3.focus();
410
+ if (focusInput) (_inputRef$current4 = inputRef.current) == null ? void 0 : _inputRef$current4.focus();
405
411
  };
406
412
 
407
413
  var tags = multiple ? values.map(function (tag) {
@@ -434,9 +440,9 @@ function useAutoComplete(autoCompleteProps) {
434
440
  wrapper: _extends({
435
441
  ref: inputWrapperRef,
436
442
  onClick: function onClick() {
437
- var _inputRef$current4;
443
+ var _inputRef$current5;
438
444
 
439
- inputRef == null ? void 0 : (_inputRef$current4 = inputRef.current) == null ? void 0 : _inputRef$current4.focus();
445
+ inputRef == null ? void 0 : (_inputRef$current5 = inputRef.current) == null ? void 0 : _inputRef$current5.focus();
440
446
  }
441
447
  }, getMultipleWrapStyles(themeInput, multiple), rest),
442
448
  input: _extends({
@@ -455,10 +461,16 @@ function useAutoComplete(autoCompleteProps) {
455
461
  var inputWrapperIsFocused = (_inputWrapperRef$curr = inputWrapperRef.current) == null ? void 0 : _inputWrapperRef$curr.contains(e.relatedTarget);
456
462
 
457
463
  if (!listIsFocused && !inputWrapperIsFocused) {
458
- var _getLastItem;
459
-
460
464
  if (closeOnBlur) onClose();
461
- if (!values.includes(e.target.value) && !freeSolo) setQuery((_getLastItem = getLastItem(values)) != null ? _getLastItem : "");
465
+
466
+ if (!values.includes(e.target.value) && !freeSolo && restoreOnBlurIfEmpty) {
467
+ var latestValue = getLastItem(values);
468
+ var latestValueItem = itemList.find(function (i) {
469
+ return i.value === latestValue;
470
+ });
471
+ var latestValueLabel = (latestValueItem == null ? void 0 : latestValueItem.label) || (latestValueItem == null ? void 0 : latestValueItem.value) || "";
472
+ setQuery(latestValueLabel);
473
+ }
462
474
  }
463
475
  },
464
476
  onChange: function onChange(e) {
@@ -475,10 +487,10 @@ function useAutoComplete(autoCompleteProps) {
475
487
  var key = e.key;
476
488
  var focusedItem = filteredList[focusedIndex];
477
489
 
478
- if (key === "Enter") {
479
- var _inputRef$current5;
490
+ if (["Enter"].concat(submitKeys).includes(key)) {
491
+ var _inputRef$current6;
480
492
 
481
- if (focusedItem && !(focusedItem != null && focusedItem.disabled)) selectItem(focusedItem == null ? void 0 : focusedItem.value);else (_inputRef$current5 = inputRef.current) == null ? void 0 : _inputRef$current5.focus();
493
+ if (focusedItem && !(focusedItem != null && focusedItem.disabled)) selectItem(focusedItem == null ? void 0 : focusedItem.value);else (_inputRef$current6 = inputRef.current) == null ? void 0 : _inputRef$current6.focus();
482
494
  e.preventDefault();
483
495
  return;
484
496
  }
@@ -571,10 +583,10 @@ function useAutoComplete(autoCompleteProps) {
571
583
  userSelect: "none"
572
584
  },
573
585
  onClick: function onClick(e) {
574
- var _inputRef$current6;
586
+ var _inputRef$current7;
575
587
 
576
588
  runIfFn(_onClick, e);
577
- if (!disabled) selectItem(value);else (_inputRef$current6 = inputRef.current) == null ? void 0 : _inputRef$current6.focus();
589
+ if (!disabled) selectItem(value);else (_inputRef$current7 = inputRef.current) == null ? void 0 : _inputRef$current7.focus();
578
590
  },
579
591
  onMouseOver: function onMouseOver(e) {
580
592
  runIfFn(_onMouseOver, e);
@@ -852,16 +864,16 @@ var AutoCompleteInput = /*#__PURE__*/forwardRef(function (props, forwardedRef) {
852
864
  var wrapperRef = wrapper.ref,
853
865
  wrapperProps = _objectWithoutPropertiesLoose(wrapper, _excluded2$2);
854
866
 
855
- var ref = useMergeRefs(forwardedRef, wrapperRef);
867
+ var ref = useMergeRefs(forwardedRef, inputRef);
856
868
  var children = runIfFn(childrenProp, {
857
869
  tags: tags
858
870
  });
859
871
  return React.createElement(Wrap, Object.assign({}, wrapperProps, {
860
- ref: ref
872
+ ref: wrapperRef
861
873
  }), children, React.createElement(WrapItem, Object.assign({
862
874
  as: Input
863
875
  }, inputProps, {
864
- ref: inputRef
876
+ ref: ref
865
877
  })));
866
878
  });
867
879
  AutoCompleteInput.displayName = "Input";