@choc-ui/chakra-autocomplete 4.12.0 → 4.15.2
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.
- package/README.md +14 -1
- package/dist/chakra-autocomplete.cjs.development.js +36 -25
- package/dist/chakra-autocomplete.cjs.development.js.map +1 -1
- package/dist/chakra-autocomplete.cjs.production.min.js +1 -1
- package/dist/chakra-autocomplete.cjs.production.min.js.map +1 -1
- package/dist/chakra-autocomplete.esm.js +36 -25
- package/dist/chakra-autocomplete.esm.js.map +1 -1
- package/dist/types.d.ts +13 -7
- package/package.json +1 -1
|
@@ -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 { 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 }]\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 selectMethod: interactionRef.current,\n isNewInput: false,\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: false,\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\n const item = filteredList.find(opt => opt.value === values[0]);\n const optionLabel = item?.label || item?.value;\n setQuery(() => (multiple ? \"\" : optionLabel ?? \"\"));\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(e.target.value);\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","selectMethod","current","isNewInput","selectItem","optionValue","includes","option","focus","focusInputOnSelect","onSelectOption","removeItem","prevValues","onTagRemoved","tags","tag","onRemove","optionLabel","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","console","warn","error","restProps","omit","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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AAQnP,KAAKC,qBAIdF,KDUFuP,CAAYhR,GACbqM,gBAAC+D,YAMTK,EAAiB9O,YAAc,mBAE/B,IAAM0N,EAAkC,CACtC4B,GAAI,IACJ/P,GAAI,IACJiK,QAAS,IACTI,GAAI,UACJwC,QAAS,KACTmD,KAAM,QACNC,OAAQ,OACRC,OAAQ,OACRpQ,IAAK,WACLqQ,OAAQ,UACRC,UAAW,OAEX5F,OAAQ,CACNH,GAAI,WAGNxK,OAAQ,CACNwQ,UAAW,2CEtCFC,EAAkBC,QAAK,SAAC7P,OAC3BqC,EAAuCrC,EAAvCqC,MAAO4D,EAAgCjG,EAAhCiG,SAAUuC,EAAsBxI,EAAtBwI,SAAalB,IAAStH,YAG7CyK,gBAAC2D,gBACC3D,gBAACqF,qBACCC,aAAa,KACblG,WAAW,UACNrB,GAAYwH,EACb1I,GAEJmD,gBAACwF,gBAAU5N,GACXoI,gBAACyF,gCACCzI,QAAS,kBAAOe,GAAY5G,UAAQqE,IACpCzG,OAAO,WACFgJ,GAAYwH,SAOrBA,EAA2B,CAC/BxQ,OAAQ,OACRgK,WAAY,OACZD,QAAS,GACTpK,OAAQ,CAAEwQ,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 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 (!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 ([\"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","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","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,GAAM,KAAKG,YAEpDC,EAAc,SAACC,EAAeC,SACjB,iBAAbD,GAAyBE,UAAQD,GACnCD,EAEWA,EACjBF,WACAK,QACC,IAAIC,OAAmBH,EA8CbE,QAAQ,yBAA0B,QA9Cb,OAC/B,SAACE,kBAAwBA,gBA+BlBC,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ACC1D,gBAACoF,qBACCC,aAAa,KACbhG,WAAW,UACNrB,GAAYsH,EACbxI,GAEJkD,gBAACuF,gBAAU9N,GACXuI,gBAACwF,gCACCvI,QAAS,kBAAOe,GAAYhH,UAAQ0E,IACpC/G,OAAO,WACFqJ,GAAYsH,SAOrBA,EAA2B,CAC/B3Q,OAAQ,OACRqK,WAAY,OACZD,QAAS,GACTzK,OAAQ,CAAE2Q,UAAW"}
|
|
@@ -250,6 +250,8 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
250
250
|
shouldRenderSuggestions = _autoCompleteProps$sh === void 0 ? function () {
|
|
251
251
|
return true;
|
|
252
252
|
} : _autoCompleteProps$sh,
|
|
253
|
+
_autoCompleteProps$su = autoCompleteProps.submitKeys,
|
|
254
|
+
submitKeys = _autoCompleteProps$su === void 0 ? [] : _autoCompleteProps$su,
|
|
253
255
|
suggestWhenEmpty = autoCompleteProps.suggestWhenEmpty,
|
|
254
256
|
value = autoCompleteProps.value,
|
|
255
257
|
_autoCompleteProps$va = autoCompleteProps.values,
|
|
@@ -294,7 +296,8 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
294
296
|
|
|
295
297
|
var creatableArr = creatable ? [{
|
|
296
298
|
value: query,
|
|
297
|
-
noFilter: true
|
|
299
|
+
noFilter: true,
|
|
300
|
+
creatable: true
|
|
298
301
|
}] : [];
|
|
299
302
|
var filteredList = [].concat(filteredResults, creatableArr);
|
|
300
303
|
|
|
@@ -337,8 +340,8 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
337
340
|
});
|
|
338
341
|
runIfFn(autoCompleteProps.onOptionFocus, {
|
|
339
342
|
item: focusedItem,
|
|
340
|
-
|
|
341
|
-
isNewInput:
|
|
343
|
+
focusMethod: interactionRef.current,
|
|
344
|
+
isNewInput: focusedItem == null ? void 0 : focusedItem.creatable
|
|
342
345
|
});
|
|
343
346
|
}, [focusedValue, autoCompleteProps.onOptionFocus]);
|
|
344
347
|
|
|
@@ -365,12 +368,26 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
365
368
|
runIfFn(autoCompleteProps.onSelectOption, {
|
|
366
369
|
item: option,
|
|
367
370
|
selectMethod: interactionRef.current,
|
|
368
|
-
isNewInput:
|
|
371
|
+
isNewInput: option == null ? void 0 : option.creatable
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
if (option != null && option.creatable) {
|
|
375
|
+
runIfFn(autoCompleteProps.onCreateOption, {
|
|
376
|
+
item: omit(option, ["noFilter"]),
|
|
377
|
+
selectMethod: interactionRef.current
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
var optionLabel = (option == null ? void 0 : option.label) || (option == null ? void 0 : option.value);
|
|
382
|
+
setQuery(function () {
|
|
383
|
+
return multiple ? "" : optionLabel != null ? optionLabel : "";
|
|
369
384
|
});
|
|
370
385
|
if (closeOnSelect) onClose();
|
|
371
386
|
};
|
|
372
387
|
|
|
373
|
-
var removeItem = function removeItem(itemValue) {
|
|
388
|
+
var removeItem = function removeItem(itemValue, focusInput) {
|
|
389
|
+
var _inputRef$current3;
|
|
390
|
+
|
|
374
391
|
setValues(function (prevValues) {
|
|
375
392
|
var item = itemList.find(function (opt) {
|
|
376
393
|
return opt.value === itemValue;
|
|
@@ -381,13 +398,14 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
381
398
|
});
|
|
382
399
|
});
|
|
383
400
|
if (query === itemValue) setQuery("");
|
|
401
|
+
if (focusInput) (_inputRef$current3 = inputRef.current) == null ? void 0 : _inputRef$current3.focus();
|
|
384
402
|
};
|
|
385
403
|
|
|
386
404
|
var resetItems = function resetItems(focusInput) {
|
|
387
|
-
var _inputRef$
|
|
405
|
+
var _inputRef$current4;
|
|
388
406
|
|
|
389
407
|
setValues([]);
|
|
390
|
-
if (focusInput) (_inputRef$
|
|
408
|
+
if (focusInput) (_inputRef$current4 = inputRef.current) == null ? void 0 : _inputRef$current4.focus();
|
|
391
409
|
};
|
|
392
410
|
|
|
393
411
|
var tags = multiple ? values.map(function (tag) {
|
|
@@ -406,13 +424,6 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
406
424
|
runIfFn(onReady, {
|
|
407
425
|
tags: tags
|
|
408
426
|
});
|
|
409
|
-
var item = filteredList.find(function (opt) {
|
|
410
|
-
return opt.value === values[0];
|
|
411
|
-
});
|
|
412
|
-
var optionLabel = (item == null ? void 0 : item.label) || (item == null ? void 0 : item.value);
|
|
413
|
-
setQuery(function () {
|
|
414
|
-
return multiple ? "" : optionLabel != null ? optionLabel : "";
|
|
415
|
-
});
|
|
416
427
|
}, [values]);
|
|
417
428
|
|
|
418
429
|
var getInputProps = function getInputProps(props, themeInput) {
|
|
@@ -427,9 +438,9 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
427
438
|
wrapper: _extends({
|
|
428
439
|
ref: inputWrapperRef,
|
|
429
440
|
onClick: function onClick() {
|
|
430
|
-
var _inputRef$
|
|
441
|
+
var _inputRef$current5;
|
|
431
442
|
|
|
432
|
-
inputRef == null ? void 0 : (_inputRef$
|
|
443
|
+
inputRef == null ? void 0 : (_inputRef$current5 = inputRef.current) == null ? void 0 : _inputRef$current5.focus();
|
|
433
444
|
}
|
|
434
445
|
}, getMultipleWrapStyles(themeInput, multiple), rest),
|
|
435
446
|
input: _extends({
|
|
@@ -457,7 +468,7 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
457
468
|
onChange: function onChange(e) {
|
|
458
469
|
var newValue = e.target.value;
|
|
459
470
|
runIfFn(_onChange, e);
|
|
460
|
-
setQuery(
|
|
471
|
+
setQuery(newValue);
|
|
461
472
|
var queryIsEmpty = isEmpty(newValue);
|
|
462
473
|
if (runIfFn(shouldRenderSuggestions, newValue) && (!queryIsEmpty || suggestWhenEmpty)) onOpen();else onClose();
|
|
463
474
|
setListAll(false);
|
|
@@ -468,10 +479,10 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
468
479
|
var key = e.key;
|
|
469
480
|
var focusedItem = filteredList[focusedIndex];
|
|
470
481
|
|
|
471
|
-
if (
|
|
472
|
-
var _inputRef$
|
|
482
|
+
if (["Enter"].concat(submitKeys).includes(key)) {
|
|
483
|
+
var _inputRef$current6;
|
|
473
484
|
|
|
474
|
-
if (focusedItem && !(focusedItem != null && focusedItem.disabled)) selectItem(focusedItem == null ? void 0 : focusedItem.value);else (_inputRef$
|
|
485
|
+
if (focusedItem && !(focusedItem != null && focusedItem.disabled)) selectItem(focusedItem == null ? void 0 : focusedItem.value);else (_inputRef$current6 = inputRef.current) == null ? void 0 : _inputRef$current6.focus();
|
|
475
486
|
e.preventDefault();
|
|
476
487
|
return;
|
|
477
488
|
}
|
|
@@ -564,10 +575,10 @@ function useAutoComplete(autoCompleteProps) {
|
|
|
564
575
|
userSelect: "none"
|
|
565
576
|
},
|
|
566
577
|
onClick: function onClick(e) {
|
|
567
|
-
var _inputRef$
|
|
578
|
+
var _inputRef$current7;
|
|
568
579
|
|
|
569
580
|
runIfFn(_onClick, e);
|
|
570
|
-
if (!disabled) selectItem(value);else (_inputRef$
|
|
581
|
+
if (!disabled) selectItem(value);else (_inputRef$current7 = inputRef.current) == null ? void 0 : _inputRef$current7.focus();
|
|
571
582
|
},
|
|
572
583
|
onMouseOver: function onMouseOver(e) {
|
|
573
584
|
runIfFn(_onMouseOver, e);
|
|
@@ -845,16 +856,16 @@ var AutoCompleteInput = /*#__PURE__*/forwardRef(function (props, forwardedRef) {
|
|
|
845
856
|
var wrapperRef = wrapper.ref,
|
|
846
857
|
wrapperProps = _objectWithoutPropertiesLoose(wrapper, _excluded2$2);
|
|
847
858
|
|
|
848
|
-
var ref = useMergeRefs(forwardedRef,
|
|
859
|
+
var ref = useMergeRefs(forwardedRef, inputRef);
|
|
849
860
|
var children = runIfFn(childrenProp, {
|
|
850
861
|
tags: tags
|
|
851
862
|
});
|
|
852
863
|
return React.createElement(Wrap, Object.assign({}, wrapperProps, {
|
|
853
|
-
ref:
|
|
864
|
+
ref: wrapperRef
|
|
854
865
|
}), children, React.createElement(WrapItem, Object.assign({
|
|
855
866
|
as: Input
|
|
856
867
|
}, inputProps, {
|
|
857
|
-
ref:
|
|
868
|
+
ref: ref
|
|
858
869
|
})));
|
|
859
870
|
});
|
|
860
871
|
AutoCompleteInput.displayName = "Input";
|