{"version":3,"file":"index.mjs","names":["useInteractions","createContext","useContext","OptionLike","AutocompleteContext","activeIndex","selection","getItemProps","ReturnType","handleSelect","index","useAutocomplete","context","Error","OptionLike","getOptionLabel","option","type","properties","label","getOptionValue","id","value","memo","useId","OptionLike","useListItem","useAutocomplete","clsx","getOptionLabel","getOptionValue","AutocompleteOptionProps","O","AutocompleteOption","props","$","_c","t0","label","id","activeIndex","selection","getItemProps","handleSelect","t1","ref","index","isActive","isSelected","t2","t3","t4","t5","onClick","t6","ChangeEvent","KeyboardEvent","useCallback","useMemo","useRef","useState","ReactNode","ComponentProps","CSSProperties","RefObject","OptionLike","Option","AutocompleteOption","AutocompleteOptionProps","FloatingFocusManager","FloatingList","FloatingPortal","Placement","autoUpdate","flip","offset","size","useDismiss","useFloating","useInteractions","useListNavigation","useRole","AutocompleteContext","clsx","getOptionLabel","getOptionValue","Button","Dialog","Loader","inputConfig","sizeVariant","ThemeColor","AutocompleteProps","icon","color","noSearchSuffix","suffix","placement","searchValue","onChangeSearchValue","value","selectionLabel","selection","O","onChangeSelection","option","options","autocompleteOptionComponent","props","loading","clearSearchButton","selectOnFocus","ref","HTMLInputElement","Autocomplete","className","autoFocus","placeholder","readOnly","rest","isOpen","setIsOpen","activeIndex","setActiveIndex","OptionComponent","listRef","Array","HTMLElement","refs","floatingStyles","context","open","onOpenChange","whileElementsMounted","middleware","padding","apply","rects","elements","availableHeight","Object","assign","floating","style","width","Math","max","reference","firstChild","firstElementChild","maxHeight","min","role","dismiss","listNav","onNavigate","virtual","loop","getReferenceProps","getFloatingProps","getItemProps","handleChangeSearchValue","e","target","current","handleSelect","index","newSelection","autocompleteContext","showClearSearchButton","trim","container","medium","setReference","input","onClick","document","activeElement","select","onChange","onMouseDown","length","onKeyDown","key","setFloating","map","useRef","useState","Autocomplete","AutocompleteProps","Option","OptionLike","useIsomorphicLayoutEffect","getOptionLabel","Props","Omit","O","SimpleAutocomplete","options","selection","onChangeSelection","rest","searchValue","setSearchValue","searchValueRef","current","inputRef","HTMLInputElement","document","activeElement","selectionLabel","filteredOptions","filter","option","optionLabel","toLowerCase","startsWith","useCallback","useEffect","useRef","useState","Autocomplete","AutocompleteProps","OptionLike","Option","getOptionLabel","useStateDebounce","useIsomorphicLayoutEffect","Props","Omit","O","onChangeSearchValueCallback","searchValue","Promise","debounce","LazyAutocomplete","selection","onChangeSelection","rest","searchValueDebounced","setSearchValue","searchValueRef","current","inputRef","HTMLInputElement","loading","setLoading","options","setOptions","handleChangeSelection","document","activeElement","selectionLabel","abort","trim","then","newOptions","catch","newValue","immediate"],"sources":["../../../src/components/autocomplete/useAutocompleteContext.ts","../../../src/components/autocomplete/util.ts","../../../src/components/autocomplete/AutocompleteOption.tsx","../../../src/components/autocomplete/Autocomplete.tsx","../../../src/components/autocomplete/SimpleAutocomplete.tsx","../../../src/components/autocomplete/LazyAutocomplete.tsx"],"sourcesContent":["import { useInteractions } from \"@floating-ui/react\";\nimport { createContext, useContext } from \"react\";\nimport { OptionLike } from \"../select-legacy\";\n\ninterface AutocompleteContext {\n  activeIndex: number | null;\n  selection: OptionLike | null;\n  getItemProps: ReturnType<typeof useInteractions>[\"getItemProps\"];\n  handleSelect: (index: number | null) => void;\n}\n\nexport const AutocompleteContext = createContext<AutocompleteContext | null>(null);\n\nexport function useAutocomplete() {\n  const context = useContext(AutocompleteContext);\n  if (context === null) {\n    throw new Error(\"Autocomplete components must be wrapped in <Autocomplete>\");\n  }\n  return context;\n}\n","import { OptionLike } from \"../select-legacy\";\n\nexport function getOptionLabel(option: OptionLike) {\n  switch (option.type) {\n    case \"Feature\":\n      return option.properties.label;\n    default:\n      return option.label;\n  }\n}\n\nexport function getOptionValue(option: OptionLike) {\n  switch (option.type) {\n    case \"Feature\":\n      return option.properties.id;\n    default:\n      return option.value;\n  }\n}\n","import { memo, useId } from \"react\";\nimport { OptionLike } from \"../select-legacy\";\nimport { useListItem } from \"@floating-ui/react\";\nimport { useAutocomplete } from \"./useAutocompleteContext\";\nimport clsx from \"clsx\";\nimport { getOptionLabel, getOptionValue } from \"./util\";\n\nexport type AutocompleteOptionProps<O extends OptionLike> = O;\n\nexport const AutocompleteOption = memo(function AutocompleteOption<O extends OptionLike>(\n  props: AutocompleteOptionProps<O>,\n) {\n  const label = getOptionLabel(props);\n\n  const id = useId();\n  const { activeIndex, selection, getItemProps, handleSelect } = useAutocomplete();\n  const { ref, index } = useListItem({ label });\n  const isActive = activeIndex === index;\n  const isSelected = selection ? getOptionValue(selection) === getOptionValue(props) : false;\n\n  return (\n    <div\n      className={clsx(\"option\", isSelected ? \"bg-gray-2\" : isActive && \"bg-gray-1\")}\n      ref={ref}\n      role=\"option\"\n      id={id}\n      data-presentation=\"compact\"\n      aria-selected={isActive}\n      {...getItemProps({\n        onClick: () => handleSelect(index),\n      })}\n    >\n      {label}\n    </div>\n  );\n});\n","import {\n  ChangeEvent,\n  KeyboardEvent,\n  useCallback,\n  useMemo,\n  useRef,\n  useState,\n  ReactNode,\n  ComponentProps,\n  CSSProperties,\n  RefObject,\n} from \"react\";\nimport type { OptionLike, Option } from \"../select-legacy\";\nimport { AutocompleteOption, AutocompleteOptionProps } from \"./AutocompleteOption\";\nimport {\n  FloatingFocusManager,\n  FloatingList,\n  FloatingPortal,\n  Placement,\n  autoUpdate,\n  flip,\n  offset,\n  size,\n  useDismiss,\n  useFloating,\n  useInteractions,\n  useListNavigation,\n  useRole,\n} from \"@floating-ui/react\";\nimport { AutocompleteContext } from \"./useAutocompleteContext\";\nimport clsx from \"clsx\";\n\nimport { getOptionLabel, getOptionValue } from \"./util\";\nimport { Button } from \"../button\";\nimport { Dialog } from \"../dialog\";\nimport { Loader } from \"../loader\";\nimport { inputConfig, sizeVariant } from \"../fields/text/Input\";\nimport { ThemeColor } from \"../../types\";\n\nexport interface AutocompleteProps<O extends OptionLike = Option> extends ComponentProps<\"input\"> {\n  icon?: boolean | ReactNode;\n\n  color?: ThemeColor;\n\n  /**\n   * render suffix only if selection and searchValue is empty\n   */\n  noSearchSuffix?: ReactNode;\n\n  suffix?: ReactNode;\n\n  placement?: Placement;\n  /**\n   * search string used as value for <input>\n   */\n  searchValue: string;\n  /**\n   * change handler when typing in the input\n   * or when clicking on an option (the label value is passed)\n   */\n  onChangeSearchValue: (value: string, selectionLabel: boolean) => void;\n\n  selection?: O | null;\n  /**\n   * select handler for a selection from the autocomplete's dropdown\n   * the option object is passed when clicking on an option\n   * null value is passed when typing a new character in the input search.\n   */\n  onChangeSelection: (option: O | null) => void;\n  options: O[];\n\n  autocompleteOptionComponent?: (props: AutocompleteOptionProps<O>) => ReactNode;\n\n  loading?: boolean;\n\n  clearSearchButton?: boolean;\n\n  selectOnFocus?: boolean;\n\n  ref?: RefObject<HTMLInputElement>;\n}\n\nexport function Autocomplete<O extends OptionLike = Option>({\n  className,\n  autoFocus = false,\n  icon = true,\n  color = \"yellow\",\n  noSearchSuffix,\n  suffix,\n  placement = \"bottom\",\n  placeholder = \"Search...\",\n  selection = null,\n  onChangeSelection,\n  autocompleteOptionComponent,\n  loading = false,\n  clearSearchButton = false,\n  searchValue,\n  onChangeSearchValue,\n  options,\n  selectOnFocus = true,\n  readOnly = false,\n  ref,\n  ...rest\n}: AutocompleteProps<O>) {\n  const [isOpen, setIsOpen] = useState(false);\n  const [activeIndex, setActiveIndex] = useState<number | null>(null);\n\n  const OptionComponent = autocompleteOptionComponent ?? AutocompleteOption;\n\n  const listRef = useRef<Array<HTMLElement | null>>([]);\n\n  const { refs, floatingStyles, context } = useFloating({\n    placement,\n    open: isOpen,\n    onOpenChange: setIsOpen,\n    whileElementsMounted: autoUpdate,\n    middleware: [\n      offset(5),\n      flip({ padding: 10 }),\n      size({\n        apply({ rects, elements, availableHeight }) {\n          Object.assign(elements.floating.style, {\n            width: `${Math.max(130, rects.reference.width)}px`,\n          });\n          const firstChild = elements.floating.firstElementChild as HTMLElement;\n          if (firstChild) {\n            firstChild.style.maxHeight = `${Math.min(availableHeight, 288)}px`;\n          }\n        },\n        padding: 10,\n      }),\n    ],\n  });\n\n  const role = useRole(context, { role: \"listbox\" });\n  const dismiss = useDismiss(context);\n  const listNav = useListNavigation(context, {\n    listRef,\n    activeIndex,\n    onNavigate: setActiveIndex,\n    /* we want the real focus to stay on the input, so focus associated to active items is simulated */\n    virtual: true,\n    loop: true,\n  });\n\n  const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([\n    role,\n    dismiss,\n    listNav,\n  ]);\n\n  function handleChangeSearchValue(e: ChangeEvent<HTMLInputElement>) {\n    const value = e.target.value;\n\n    onChangeSearchValue(value, false);\n\n    if (value !== searchValue && selection !== null) {\n      onChangeSelection(null);\n      setActiveIndex(null);\n      return;\n    }\n\n    if (value) {\n      setIsOpen(true);\n      /**\n       * bug whith LazyAutocomplete activeIndex is set to 0 but the options array has immediately 0 elements\n       * so focus can't be set to the first Dom element.\n       */\n      setActiveIndex(listRef.current[0] ? 0 : null);\n    } else {\n      setIsOpen(false);\n      setActiveIndex(null);\n    }\n  }\n\n  const handleSelect = useCallback(\n    (index: number | null) => {\n      if (index === null) {\n        onChangeSelection(null);\n      } else if (options[index]) {\n        const newSelection = options[index];\n        onChangeSelection(newSelection);\n\n        onChangeSearchValue(getOptionLabel(newSelection), true);\n      }\n      setActiveIndex(null);\n      setIsOpen(false);\n    },\n\n    [options, onChangeSelection, onChangeSearchValue],\n  );\n\n  const autocompleteContext = useMemo(\n    () => ({\n      activeIndex,\n      selection,\n      getItemProps,\n      handleSelect,\n    }),\n    [activeIndex, selection, getItemProps, handleSelect],\n  );\n\n  const showClearSearchButton =\n    clearSearchButton && (searchValue.trim() !== \"\" || selection !== null);\n\n  return (\n    <div className={className} role=\"combobox\">\n      <div\n        className={clsx(inputConfig.container, sizeVariant.medium, readOnly && \"readonly\")}\n        ref={refs.setReference}\n        data-color={color}\n      >\n        {icon !== false && (\n          <div className=\"flex-center relative\">\n            <Loader loading={loading} size=\"input\" color=\"gray\" className=\"mr-2\">\n              {icon === true ? <i className=\"fe-search text-body-md\"></i> : icon}\n            </Loader>\n          </div>\n        )}\n        <input\n          autoComplete=\"off\"\n          autoFocus={autoFocus}\n          spellCheck=\"false\"\n          className={clsx(inputConfig.input, icon === false && \"pl-4\")}\n          ref={ref}\n          type=\"search\"\n          readOnly={readOnly}\n          value={searchValue}\n          placeholder={placeholder}\n          aria-autocomplete=\"list\"\n          {...getReferenceProps({\n            onClick() {\n              if (selectOnFocus) {\n                // it's better to listen onClick instead of onFocus. the event is triggered later and there\n                // was an issue if we listen on onFocus and user click on the text of the textarea with Firefox\n                (document.activeElement as HTMLInputElement)?.select();\n              }\n            },\n            onChange: handleChangeSearchValue,\n            onMouseDown() {\n              if (options.length === 0) {\n                return;\n              }\n              /**\n               * There is a already selection\n               * and the only element available is the selection,\n               * no need to display the dropdown.\n               */\n              // if (options.length === 1 && options[0].value === selection?.value) {\n              //   return;\n              // }\n              setIsOpen((isOpen) => !isOpen);\n            },\n            onKeyDown(e: KeyboardEvent<HTMLInputElement>) {\n              if (e.key === \"Enter\" && activeIndex != null) {\n                handleSelect(activeIndex);\n              }\n            },\n          })}\n          {...rest}\n        />\n        <div className=\"flex-center relative\">\n          {suffix}\n          {showClearSearchButton && (\n            <Button\n              size=\"input\"\n              type=\"button\"\n              withRipple={false}\n              icon\n              color=\"gray\"\n              variant=\"text\"\n              onClick={() => {\n                setIsOpen(false);\n                onChangeSelection(null);\n                setActiveIndex(null);\n                onChangeSearchValue(\"\", true);\n              }}\n            >\n              <i className=\"fe-cancel\"></i>\n            </Button>\n          )}\n          {icon === false && loading && <Loader size=\"medium\" color=\"gray\" />}\n          {!selection && searchValue === \"\" && noSearchSuffix}\n        </div>\n      </div>\n      <FloatingPortal>\n        <AutocompleteContext.Provider value={autocompleteContext}>\n          {isOpen && (\n            <FloatingFocusManager\n              disabled={selectOnFocus}\n              context={context}\n              initialFocus={-1}\n              visuallyHiddenDismiss\n            >\n              <div\n                className=\"z-dialog outline-hidden\"\n                ref={refs.setFloating}\n                style={floatingStyles as CSSProperties}\n                {...getFloatingProps()}\n              >\n                <Dialog\n                  placement={context.placement}\n                  className=\"motion-safe:animate-fade-in-list overflow-auto\"\n                >\n                  <FloatingList elementsRef={listRef}>\n                    {options.map((option) => {\n                      return <OptionComponent {...option} key={getOptionValue(option)} />;\n                    })}\n                  </FloatingList>\n                </Dialog>\n              </div>\n            </FloatingFocusManager>\n          )}\n        </AutocompleteContext.Provider>\n      </FloatingPortal>\n    </div>\n  );\n}\n","import { useRef, useState } from \"react\";\nimport { Autocomplete, AutocompleteProps } from \"./Autocomplete\";\nimport { Option, OptionLike } from \"../select-legacy\";\nimport { useIsomorphicLayoutEffect } from \"../../hooks\";\nimport { getOptionLabel } from \"./util\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ninterface Props<O extends OptionLike = Option> extends Omit<\n  AutocompleteProps<O>,\n  \"searchValue\" | \"onChangeSearchValue\" | \"loading\" | \"clearSearchButton\" | \"selectOnFocus\"\n> {}\n\nexport function SimpleAutocomplete<O extends OptionLike = Option>({\n  options,\n  selection = null,\n  onChangeSelection,\n  ...rest\n}: Props<O>) {\n  const [searchValue, setSearchValue] = useState(selection ? getOptionLabel(selection) : \"\");\n\n  const searchValueRef = useRef(searchValue);\n  searchValueRef.current = searchValue;\n\n  const inputRef = useRef<HTMLInputElement>(null!);\n\n  // side effect, update the searchValue <input /> value when\n  // selection come from outside\n  useIsomorphicLayoutEffect(() => {\n    if (selection === null) {\n      if (document.activeElement !== inputRef.current) {\n        setSearchValue(\"\");\n      }\n      return;\n    }\n\n    // we need the fresh value of searchValue but we don't\n    // want searchValue as useEffect dependency\n    const selectionLabel = getOptionLabel(selection);\n    if (searchValueRef.current !== getOptionLabel(selection)) {\n      setSearchValue(selectionLabel);\n    }\n  }, [selection, setSearchValue]);\n\n  const filteredOptions =\n    selection !== null\n      ? []\n      : options.filter((option) => {\n          const optionLabel = getOptionLabel(option);\n          return optionLabel.toLowerCase().startsWith(searchValue.toLowerCase());\n        });\n\n  return (\n    <Autocomplete\n      ref={inputRef}\n      searchValue={searchValue}\n      onChangeSearchValue={setSearchValue}\n      selection={selection}\n      onChangeSelection={onChangeSelection}\n      options={filteredOptions}\n      {...rest}\n    />\n  );\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Autocomplete, AutocompleteProps } from \"./Autocomplete\";\nimport { OptionLike, Option } from \"../select-legacy\";\nimport { getOptionLabel } from \"./util\";\nimport { useStateDebounce, useIsomorphicLayoutEffect } from \"../../hooks\";\n\ninterface Props<O extends OptionLike = Option>\n  // Omit \"searchValue\" | \"onChangeSearchValue\" | \"options\"\n  extends Omit<\n    AutocompleteProps<O>,\n    \"searchValue\" | \"onChangeSearchValue\" | \"options\" | \"selectOnFocus\"\n  > {\n  onChangeSearchValueCallback: (searchValue: string) => Promise<O[]>;\n  debounce?: number;\n}\n\nexport function LazyAutocomplete<O extends OptionLike = Option>({\n  onChangeSearchValueCallback,\n  debounce = 5000,\n  selection = null,\n  onChangeSelection,\n  ...rest\n}: Props<O>) {\n  const [searchValue, searchValueDebounced, setSearchValue] = useStateDebounce(\n    selection ? getOptionLabel(selection) : \"\",\n    debounce,\n  );\n\n  const searchValueRef = useRef(searchValue);\n  searchValueRef.current = searchValue;\n\n  const inputRef = useRef<HTMLInputElement>(null!);\n\n  const [loading, setLoading] = useState(false);\n\n  const [options, setOptions] = useState<O[]>([]);\n\n  const handleChangeSelection = useCallback(\n    (selection: O | null) => {\n      onChangeSelection(selection);\n      if (selection) {\n        setOptions([]);\n      }\n    },\n    [onChangeSelection],\n  );\n\n  // side effect, update the searchValue <input /> value when\n  // selection come from outside\n  useIsomorphicLayoutEffect(() => {\n    if (selection === null) {\n      if (document.activeElement !== inputRef.current) {\n        setSearchValue(\"\", true);\n      }\n      return;\n    }\n\n    // we need the fresh value of searchValue but we don't\n    // want searchValue as useEffect dependency\n    const selectionLabel = getOptionLabel(selection);\n    if (searchValueRef.current !== selectionLabel) {\n      setSearchValue(selectionLabel, true);\n    }\n  }, [selection, setSearchValue]);\n\n  /**\n   * set new options when searchValueDebounced change\n   */\n  useEffect(() => {\n    let abort = false;\n\n    // when we're selecting option we change searchValue to be the complete label\n    // value but we don't want to fetch new research\n    if (selection) {\n      return;\n    }\n\n    if (searchValueDebounced.trim() === \"\") {\n      setOptions([]);\n      return;\n    }\n\n    setLoading(true);\n\n    onChangeSearchValueCallback(searchValueDebounced)\n      ?.then((newOptions) => {\n        setLoading(false);\n\n        if (!abort) {\n          setOptions(newOptions);\n        }\n      })\n      .catch(() => {\n        setLoading(false);\n      });\n\n    return () => {\n      setLoading(false);\n      abort = true;\n    };\n  }, [selection, searchValueDebounced, onChangeSearchValueCallback]);\n\n  return (\n    <Autocomplete\n      ref={inputRef}\n      searchValue={searchValue}\n      onChangeSearchValue={(newValue, immediate) => {\n        setSearchValue(newValue, immediate || newValue === \"\" ? true : false);\n      }}\n      selection={selection}\n      onChangeSelection={handleChangeSelection}\n      options={options}\n      loading={loading}\n      {...rest}\n    />\n  );\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAaI,sBAAsBH,cAA0C,IAAI;AAEjF,SAAOU,kBAAA;CACL,MAAAC,UAAgBV,WAAWE,mBAAmB;CAC9C,IAAIQ,YAAY,MACd,MAAM,IAAIC,MAAM,2DAA2D;CAC5E,OACMD;AAAO;;;AChBhB,SAAgBG,eAAeC,QAAoB;CACjD,QAAQA,OAAOC,MAAf;EACE,KAAK,WACH,OAAOD,OAAOE,WAAWC;EAC3B,SACE,OAAOH,OAAOG;CAClB;AACF;AAEA,SAAgBC,eAAeJ,QAAoB;CACjD,QAAQA,OAAOC,MAAf;EACE,KAAK,WACH,OAAOD,OAAOE,WAAWG;EAC3B,SACE,OAAOL,OAAOM;CAClB;AACF;;;ACTA,MAAaW,qBAAqBV,KAAK,SAAAU,mBAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,OAAA;EAGvBG,KAAAR,eAAeK,KAAK;EAACC,EAAA,KAAAD;EAAAC,E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