{"version":3,"file":"Combobox.mjs","sources":["../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import {\n  autoUpdate,\n  flip,\n  FloatingPortal,\n  offset,\n  size,\n  useFloating,\n  useMergeRefs,\n} from '@floating-ui/react';\nimport {\n  Combobox as HeadlessCombobox,\n  type ComboboxProps as HeadlessComboboxProps,\n  ComboboxButton,\n  type ComboboxButtonProps as HeadlessComboboxButtonProps,\n  ComboboxInput,\n  type ComboboxInputProps as HeadlessComboboxInputProps,\n  ComboboxOption,\n  type ComboboxOptionProps as HeadlessComboboxOptionProps,\n  ComboboxOptions,\n  type ComboboxOptionsProps as HeadlessComboboxOptionsProps,\n  Label,\n} from '@headlessui/react';\nimport clsx from 'clsx';\n\nimport React, {\n  useContext,\n  useEffect,\n  useRef,\n  useState,\n  type ChangeEventHandler,\n  type CSSProperties,\n  type ElementType,\n  type KeyboardEventHandler,\n  type ReactNode,\n} from 'react';\n\nimport {\n  EDS_AUDIT_PREFIX,\n  assertNoRemovedIconProp,\n  type WithRemovedIconProps,\n} from '../../util/logging';\nimport type { ExtractProps, IconOrContent } from '../../util/utility-types';\nimport type { Status } from '../../util/variant-types';\n\nimport Checkbox from '../Checkbox';\nimport FieldLabel from '../FieldLabel';\nimport FieldNote from '../FieldNote';\nimport { hasSlotContent, IconSlot, useSemanticIcon } from '../Icon';\nimport InputChip from '../InputChip';\nimport PopoverContainer from '../PopoverContainer';\nimport PopoverListItem from '../PopoverListItem';\nimport type { PopoverListItemProps } from '../PopoverListItem/PopoverListItem';\nimport Radio from '../Radio';\nimport Text from '../Text';\n\nimport styles from './Combobox.module.css';\n\ntype ComboboxValue = string | { [k: string]: unknown };\n\n/**\n * The field holds one value normally, and a list of them when `multiple` is set.\n */\ntype ComboboxSelection = ComboboxValue | ComboboxValue[];\n\nexport type ComboboxProps = Omit<\n  HeadlessComboboxProps<ComboboxValue, boolean | undefined, ElementType>,\n  // HeadlessUI derives these from a `multiple` type parameter, which we can't supply at the\n  // component boundary. We restate them in terms of `ComboboxSelection` instead, which keeps\n  // both single and multiple usage readable.\n  'by' | 'defaultValue' | 'onChange' | 'value'\n> & {\n  // Component API\n  /**\n   * Compare option values by a named key, or by a comparison function, instead of by reference.\n   * Useful when the selected value and the option come from different places.\n   *\n   * See: https://headlessui.com/react/combobox#binding-objects-as-values\n   */\n  by?: string | ((a: ComboboxValue, z: ComboboxValue) => boolean);\n  /**\n   * The default value of the combobox field (when uncontrolled)\n   */\n  defaultValue?: ComboboxSelection;\n  /**\n   * Fires when a value is selected. Passes the selected value, or the list of selected values\n   * when `multiple` is set.\n   */\n  onChange?: (value: ComboboxSelection | null) => void;\n  /**\n   * The value of the combobox field (when controlled)\n   */\n  value?: ComboboxSelection;\n  /**\n   * Screen-reader text for the combobox's label.\n   *\n   * When possible, use a visible label by passing a <Combobox.Label> into `children`.\n   * In rare cases where there's no visible label, you must provide an `aria-label` for screen readers.\n   */\n  'aria-label'?: string;\n  /**\n   * Optional className for additional styling.\n   */\n  className?: string;\n  /**\n   * Name of the form element, which triggers the generation of hidden key/value form fields (e.g. `name=$name[$key]`).\n   *\n   * See: https://headlessui.com/react/combobox#using-with-html-forms\n   */\n  name?: string;\n  /**\n   * Optional className for additional options menu styling.\n   *\n   * If optionsClassName is provided please include the width property to define\n   * the options menu width.\n   */\n  optionsClassName?: string;\n  /**\n   * Indicates that field is required for form to be successfully submitted\n   */\n  required?: boolean;\n  // Design API\n  /**\n   * Text under the field used to provide validation hints or error message to describe the input error.\n   */\n  fieldNote?: ReactNode;\n  /**\n   * Visible text label for the component.\n   */\n  label?: string;\n  /**\n   * Whether the label is adjacent to the field (horizontal) or above the field (vertical)\n   *\n   * **Default is `\"vertical\"`**.\n   */\n  labelLayout?: 'vertical' | 'horizontal';\n  /**\n   * Whether it should show the field hint or not\n   *\n   * **Default is `\"false\"`**.\n   */\n  showHint?: boolean;\n  /**\n   * Status for the field state\n   *\n   * **Default is `\"default\"`**.\n   */\n  status?: 'default' | Extract<Status, 'warning' | 'critical'>;\n  /**\n   * Add additional descriptive text for the field name\n   */\n  subLabel?: ReactNode;\n};\n\ntype ComboboxLabelProps = ExtractProps<typeof Label> & {\n  disabled?: boolean;\n  required?: boolean;\n  showHint?: boolean;\n  /**\n   * Add additional descriptive text for the field name\n   */\n  subLabel?: ReactNode;\n};\n\ntype ComboboxOptionsProps = HeadlessComboboxOptionsProps<'div'> & {\n  // Component API\n  /**\n   * Where the option list sits relative to the field. When left unset, the list lines up with\n   * the field's bottom left edge and is at least as wide as the field, however many chips it\n   * holds. A width class on the list can make it wider.\n   *\n   * Setting it hands positioning back to HeadlessUI, which measures from the text field itself\n   * rather than the field's border.\n   *\n   * See: https://headlessui.com/react/combobox#positioning-the-options\n   */\n  anchor?: HeadlessComboboxOptionsProps<'div'>['anchor'];\n  // Design API\n  /**\n   * Text shown in place of the options when none are passed in, such as when a query matches\n   * nothing.\n   *\n   * **Default is `\"No matches found\"`**.\n   */\n  noMatchesText?: ReactNode;\n  /**\n   * The list element. Merged with the ref used to position the list against the field.\n   */\n  ref?: React.Ref<HTMLDivElement>;\n};\n\ntype ComboboxOptionProps = HeadlessComboboxOptionProps<'div', ComboboxValue> &\n  Pick<PopoverListItemProps, 'subLabel'> & {\n    optionClassName?: string;\n  };\n\ntype ComboboxButtonProps = HeadlessComboboxButtonProps<'button'> & {\n  // Component API\n  /**\n   * Screen-reader text for the toggle, used when the field has no visible label. When there\n   * is one, HeadlessUI names the toggle from that label and this is ignored.\n   *\n   * **Default is `\"Show options\"`**.\n   */\n  'aria-label'?: string;\n  // Design API\n};\n\ntype ComboboxInputProps = Omit<\n  HeadlessComboboxInputProps<'input', ComboboxValue>,\n  'displayValue' | 'onChange'\n> & {\n  // Component API\n  /**\n   * Screen-reader text for the field. Prefer a visible label on `<Combobox>` (or a\n   * `<Combobox.Label>`); this is the escape hatch when there's no visible label.\n   *\n   * Inherited from `<Combobox aria-label=\"...\">` when not set here.\n   */\n  'aria-label'?: string;\n  /**\n   * Optional className for additional styling of the field wrapper.\n   */\n  className?: string;\n  /**\n   * Maps the currently selected value to the text shown in the text field. Receives `null`\n   * when nothing is selected.\n   *\n   * See: https://headlessui.com/react/combobox#binding-objects-as-values\n   */\n  displayValue?: (item: ComboboxValue | null) => string;\n  /**\n   * Optional className for additional styling of the inner `<input>` element.\n   */\n  inputClassName?: string;\n  /**\n   * Fires on every keystroke in the text field. Use it to filter the options passed\n   * to `Combobox.Options`.\n   */\n  onChange?: ChangeEventHandler<HTMLInputElement>;\n  /**\n   * Fires on key down in the text field. Runs before the component's own handling, so calling\n   * `preventDefault()` here opts out of backspace-to-remove.\n   */\n  onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n  // Design API\n  /**\n   * Maps a selected value to the text shown on its chip, when `multiple` is set.\n   *\n   * **Defaults to the value's `label`**, or the value itself when it's a string.\n   */\n  chipLabel?: (item: ComboboxValue) => string;\n  /**\n   * Leading glyph (icon) or content for a selected value's chip, when `multiple` is set.\n   */\n  chipLeadingComponent?: (item: ComboboxValue) => IconOrContent;\n  /**\n   * Whether we should truncate the text displayed in the combobox field\n   */\n  shouldTruncate?: boolean;\n  /**\n   * Whether selected values appear as removable chips inside the field, when `multiple` is set.\n   * Turn it off to surface the selection yourself. Also governs whether backspace on an empty\n   * field removes the last chip, and whether adding a chip selects the query text.\n   *\n   * **Default is `\"true\"`**.\n   */\n  showChips?: boolean;\n};\n\ntype ComboboxInputWrapperProps = {\n  // Component API\n  /**\n   * The text field (and any other content) placed inside the field's border.\n   */\n  children?: ReactNode;\n  /**\n   * Optional className for additional styling.\n   */\n  className?: string;\n  // Design API\n  /**\n   * Whether the field is holding selection chips, which lets its contents wrap onto more\n   * than one line.\n   */\n  hasChips?: boolean;\n  /**\n   * Status for the field state\n   *\n   * **Default is `\"default\"`**.\n   */\n  status?: 'default' | Extract<Status, 'warning' | 'critical'>;\n};\n\ntype ComboboxContextType = {\n  ariaLabel?: string;\n  disabled?: boolean;\n  /**\n   * The bordered field, which the option list lines up with.\n   */\n  fieldElement?: HTMLDivElement | null;\n  /**\n   * Whether the consumer passed `virtual` with an empty `options` list, so the option list\n   * shows its empty state instead of calling the render prop.\n   */\n  hasNoVirtualOptions?: boolean;\n  optionsClassName?: string;\n  /**\n   * Drops one value from the selection. Backs the remove button on each chip.\n   */\n  removeValue?: (value: ComboboxValue) => void;\n  required?: boolean;\n  /**\n   * Registers the bordered field. Backs the ref on `Combobox.InputWrapper`.\n   */\n  setFieldElement?: (element: HTMLDivElement | null) => void;\n  /**\n   * The current selection, always as a list. Empty unless `multiple` is set.\n   */\n  selectedValues?: ComboboxValue[];\n  status?: ComboboxProps['status'];\n  multiple?: boolean; // pulls from HeadlessUI\n};\n\n/**\n * Maps a selected value to chip text. Combobox values are either strings or objects carrying a\n * `label`, which matches what `Select` documents for its own option values.\n */\nconst defaultChipLabel = (value: ComboboxValue) =>\n  typeof value === 'string' ? value : String(value.label ?? '');\n\nlet showNameWarning = true;\n\nconst ComboboxContext = React.createContext<ComboboxContextType>({});\n\n/**\n * Space between the field and the option list\n */\nconst OPTIONS_GAP = 10;\n\n/**\n * HeadlessUI infers its value type from a `multiple` type parameter, which we can't supply from\n * a plain props object. Our own `ComboboxProps` already describes the same shape, so we render\n * through it directly. Behavior is unchanged; only the inference is pinned down.\n */\nconst ComboboxRoot = HeadlessCombobox as React.ComponentType<ComboboxProps>;\n\n/**\n * ## Usage\n *\n * A text field paired with a list of options. Typing filters the list, so use it where a\n * `Select` would be unwieldy. Supports controlled and uncontrolled behavior.\n *\n * | Type/Use | Description | Example |\n * |----------|-------------|---------|\n * | Standard | Type to filter a list of options; one can be selected. | Country selector. Assignee picker. |\n * | Multi-select | Type to filter, and select more than one option from the list. | Filter panels. Role or permission assignments. |\n * | Disabled | Non-interactive; used to show unavailable or inactive states. | Feature-gated selections. Incomplete forms. |\n * | Preselected | Default selection appears in the field before user interacts. | Recommended settings. \"Most common\" default. |\n *\n * Filtering is left to the consumer, since only the consumer knows how the option data is\n * shaped and where it comes from. Use `onChange` on `Combobox.Input` to capture the query,\n * then pass the filtered list to `Combobox.Options`.\n *\n * ### Best Practices\n *\n * * Use `Combobox` for long lists where typing is faster than scrolling. For 3-10 options, use `Select`.\n * * Order the menu options logically to make it easier for users to find the option they want. Default to alphabetical order.\n * * Keep the option list the same width as the field that triggered it. This is the default.\n * * When the filtered list is empty, `Combobox.Options` says \"No matches found\" so the field doesn't look broken. Use `noMatchesText` to change the wording.\n * * When only so many values may be selected, say so in the `subLabel` (e.g., \"Choose up to 3\"). If the user selects more than that, set `status` to `\"critical\"` and explain in the `fieldNote`. Don't disable the remaining options: it hides the choices without telling the user why.\n *\n * ## Interaction\n *\n * The field is always editable, so users can either type to narrow the list or open the full\n * list with the toggle button. In single-select mode, only one selection can be made. In\n * multi-select mode, one or more selections can be made from the list, and each one shows in\n * the field as a chip. Adding a chip selects the query text that found it, so the next keystroke\n * begins a new search. A chip goes away either through its own close button or by pressing\n * backspace in an empty field.\n *\n * ## Content & Accessibility\n *\n * ### Do's\n *\n * * Use short, precise labels whenever possible.\n * * Avoid truncated items.\n * * In short lists, order from most common to least common choices.\n * * In longer lists use alphabetical order, but if there are 2 or 3 very common selections, consider repeating them at the top of the list.\n * * Use sentence case.\n *\n * ### Don'ts\n *\n * * Use periods at the end of labels.\n * * Place placeholder text within the field; it can cause accessibility issues with color contrast, inconsistent screen-reader behavior, and text disappearing as users type.\n *\n * ## Resources\n *\n * * https://headlessui.com/react/combobox\n */\nexport function Combobox({\n  'aria-label': ariaLabel,\n  by,\n  children,\n  className,\n  disabled,\n  fieldNote,\n  label,\n  labelLayout = 'vertical',\n  name,\n  optionsClassName,\n  required,\n  showHint,\n  status,\n  onChange: theirOnChange,\n  subLabel,\n  ...other\n}: ComboboxProps) {\n  // TODO: convert this to use assertEdsUsage? (issue as warning)\n  if (process.env.NODE_ENV !== 'production') {\n    if (!name && showNameWarning) {\n      console.warn(\n        EDS_AUDIT_PREFIX +\n          \"%c`Combobox` won't render a form field unless you include a `name` prop.\\n\\n See https://headlessui.com/react/combobox#using-with-html-forms for more information\",\n        'font-weight: bold',\n      );\n      showNameWarning = false;\n    }\n  }\n\n  // Create a new value to track the internal state of Combobox. Added to work around\n  // behavior inherited from HeadlessUI where it will fire onChange even if there is no change\n  // Adding to support behavior synced to how <select> tags work\n  const [selectedValue, setSelectedValue] = useState<\n    ComboboxSelection | null | undefined\n  >(other.value !== undefined ? other.value : other.defaultValue);\n\n  // Held in state, not a ref, so the option list re-renders to anchor itself once the field mounts\n  const [fieldElement, setFieldElement] = useState<HTMLDivElement | null>(null);\n\n  const componentClassName = clsx(\n    styles['combobox'],\n    fieldNote && styles['combobox--has-fieldNote'],\n    labelLayout && styles[`combobox--label-layout-${labelLayout}`],\n    className,\n  );\n\n  const { defaultValue: theirDefaultValue, ...restProps } = other;\n\n  // In virtual mode HeadlessUI renders the list by calling the render prop once per option, so\n  // with no options there's nothing to call and the empty state can't show. With nothing to\n  // virtualize, we turn virtualization off and let `Combobox.Options` show the empty state.\n  const hasNoVirtualOptions = other.virtual?.options.length === 0;\n\n  // Removing a chip has to change what HeadlessUI treats as selected, and it offers no\n  // imperative way in. So for multi-select we drive its value from the copy we already track,\n  // seeded from `defaultValue`. The consumer's uncontrolled API is unchanged.\n  const shouldControlValue =\n    Boolean(other.multiple) && other.value === undefined;\n\n  const handleChange = (changedValue: ComboboxSelection | null) => {\n    if (selectedValue !== changedValue) {\n      setSelectedValue(changedValue);\n      // Use the value from the event because updates to `useState` are queued\n      theirOnChange && theirOnChange(changedValue);\n    }\n  };\n\n  const sharedProps: ComboboxProps = {\n    className: componentClassName,\n    // Provide a wrapping <div> element for the combobox. This is needed so that any props\n    // passed directly to this component have a corresponding DOM element to receive them.\n    // Otherwise we get an error.\n    as: 'div' as const,\n    by,\n    disabled,\n    // HeadlessUI uses `invalid` to mark the field (and its descendants) as invalid for\n    // assistive tech. Derive it from `status` unless the consumer sets it themselves.\n    invalid: other.invalid ?? status === 'critical',\n    name,\n    ...restProps,\n    ...(hasNoVirtualOptions && { virtual: null }),\n    ...(shouldControlValue\n      ? { value: selectedValue ?? [] }\n      : { defaultValue: theirDefaultValue }),\n    onChange: handleChange,\n  };\n\n  // The chips in the field need to know what's selected. When controlled, the consumer's value\n  // is the source of truth; otherwise we read the copy tracked above.\n  const currentValue = other.value !== undefined ? other.value : selectedValue;\n  const selectedValues =\n    other.multiple && Array.isArray(currentValue) ? currentValue : [];\n\n  /**\n   * Compares two option values the same way HeadlessUI does, honoring `by` so that values\n   * loaded separately from the option list still match.\n   */\n  const isSameValue = (a: ComboboxValue, z: ComboboxValue) => {\n    if (typeof by === 'function') {\n      return by(a, z);\n    }\n\n    if (\n      typeof by === 'string' &&\n      typeof a === 'object' &&\n      typeof z === 'object'\n    ) {\n      return a[by] === z[by];\n    }\n\n    return a === z;\n  };\n\n  const context: ComboboxContextType = {\n    // The accessible name has to land on the `<input>`, not on the wrapping element, so we\n    // hand it down to `Combobox.Input` rather than putting it on the root.\n    ariaLabel,\n    disabled,\n    fieldElement,\n    hasNoVirtualOptions,\n    optionsClassName,\n    removeValue: (valueToRemove) => {\n      const remaining = selectedValues.filter(\n        (value) => !isSameValue(value, valueToRemove),\n      );\n\n      setSelectedValue(remaining);\n      theirOnChange && theirOnChange(remaining);\n    },\n    required,\n    selectedValues,\n    setFieldElement,\n    status,\n    multiple: other.multiple,\n  };\n\n  if (typeof children === 'function') {\n    return (\n      <ComboboxContext.Provider value={context}>\n        <ComboboxRoot {...sharedProps}>{children}</ComboboxRoot>\n      </ComboboxContext.Provider>\n    );\n  }\n\n  return (\n    <ComboboxContext.Provider value={context}>\n      <ComboboxRoot {...sharedProps}>\n        {(label || required) && (\n          <Combobox.Label\n            disabled={disabled}\n            required={required}\n            showHint={showHint}\n            subLabel={subLabel}\n          >\n            {label}\n          </Combobox.Label>\n        )}\n        {children}\n      </ComboboxRoot>\n      {fieldNote && (\n        <div className={styles['combobox__footer']}>\n          <FieldNote disabled={disabled} status={status}>\n            {fieldNote}\n          </FieldNote>\n        </div>\n      )}\n    </ComboboxContext.Provider>\n  );\n}\n\nconst ComboboxLabelComponent = ({\n  children: label,\n  required,\n  className,\n  disabled,\n  showHint,\n  subLabel,\n}: ComboboxLabelProps) => {\n  const componentClassName = clsx(\n    styles['combobox__label'],\n    disabled && clsx(styles['combobox__label--disabled']),\n    className,\n  );\n\n  const requiredTextClassName = clsx(\n    styles['combobox__required-text'],\n    disabled && styles['combobox__required-text--disabled'],\n  );\n\n  const overlineClassName = clsx(\n    styles['combobox__overline'],\n    !label && styles['combobox__overline--no-label'],\n  );\n\n  const subLabelClassName = clsx(\n    styles['combobox__subLabel'],\n    disabled && styles['combobox__label--disabled'],\n  );\n\n  return (\n    <div className={overlineClassName}>\n      <Label\n        as={FieldLabel}\n        className={componentClassName}\n        disabled={disabled}\n        size=\"md\"\n      >\n        {label}\n      </Label>\n      {required && showHint && (\n        <Text\n          aria-disabled={disabled ?? undefined}\n          as=\"span\"\n          className={requiredTextClassName}\n          preset=\"body-sm\"\n        >\n          (Required)\n        </Text>\n      )}\n      {!required && showHint && (\n        <Text\n          aria-disabled={disabled ?? undefined}\n          as=\"span\"\n          className={requiredTextClassName}\n          preset=\"body-sm\"\n        >\n          (Optional)\n        </Text>\n      )}\n      {label && subLabel && (\n        <div className={subLabelClassName}>\n          {/* TODO: is there a way to coerce HeadlessUI into using aria-describedby like InputField/TextareaField */}\n          <Text as=\"span\" preset=\"body-sm\">\n            {subLabel}\n          </Text>\n        </div>\n      )}\n    </div>\n  );\n};\n\n/**\n * The toggle for the option list. Unlike `Select`, this is not the primary way into the\n * component: the text field is. It sits at the end of the field and reveals the full,\n * unfiltered list.\n */\nconst ComboboxButtonComponent = function (props: ComboboxButtonProps) {\n  const {\n    'aria-label': ariaLabel = 'Show options',\n    children,\n    className,\n    // TODO(next-major): remove, with the assert below.\n    icon: removedIcon,\n    ...other\n  } = props as WithRemovedIconProps<ComboboxButtonProps, 'icon'>;\n\n  // TODO(next-major): remove.\n  assertNoRemovedIconProp('Combobox.Button', 'icon', 'expand', removedIcon);\n\n  const componentClassName = clsx(styles['combobox-input__button'], className);\n\n  // The indicator marks the button as the thing that reveals the options, so it is the\n  // same semantic `expand` icon a `Menu.Button` or a `Select` carries. The CSS flips it\n  // when the list is open rather than swapping to `collapse`.\n  const expandIcon = useSemanticIcon('expand');\n\n  return (\n    <ComboboxButton\n      // The icon is decorative and the field's label belongs to the text input, so without\n      // this the toggle reaches assistive tech as an unnamed button.\n      aria-label={ariaLabel}\n      className={componentClassName}\n      {...other}\n    >\n      {(renderProps) => {\n        if (typeof children === 'function') {\n          return children(renderProps);\n        }\n\n        // HeadlessUI's render prop has to hand back a single element, so arbitrary children\n        // get wrapped rather than returned as-is. The icon branch is wrapped for the same\n        // reason: its guard can leave it with nothing to hand back.\n        return children ? (\n          <>{children}</>\n        ) : (\n          <>\n            {hasSlotContent(expandIcon) && (\n              <IconSlot\n                className={clsx(\n                  styles['combobox-input__icon'],\n                  renderProps.open && styles['combobox-input__icon--reversed'],\n                )}\n                content={expandIcon}\n                purpose=\"decorative\"\n                size=\"24px\"\n              />\n            )}\n          </>\n        );\n      }}\n    </ComboboxButton>\n  );\n};\n\n/**\n * The editable text field for the component, wrapped in the bordered field styling along\n * with the toggle button for the option list.\n *\n * When `multiple` is set, the values picked so far appear ahead of the text field as chips,\n * each one removable. The text field then holds only the query, which is why `displayValue`\n * has no effect in that mode.\n */\nconst ComboboxInputComponent = function (props: ComboboxInputProps) {\n  const {\n    'aria-label': ariaLabel,\n    chipLabel = defaultChipLabel,\n    chipLeadingComponent,\n    className,\n    inputClassName,\n    onKeyDown: theirOnKeyDown,\n    shouldTruncate = false,\n    showChips = true,\n    // TODO(next-major): remove, with the assert below.\n    icon: removedIcon,\n    ...other\n  } = props as WithRemovedIconProps<ComboboxInputProps, 'icon'>;\n\n  // TODO(next-major): remove.\n  assertNoRemovedIconProp('Combobox.Input', 'icon', 'expand', removedIcon);\n  const {\n    ariaLabel: contextAriaLabel,\n    disabled,\n    multiple,\n    removeValue,\n    required,\n    selectedValues = [],\n    status,\n  } = useContext(ComboboxContext);\n\n  const fieldClassName = clsx(\n    styles['combobox-input__field'],\n    shouldTruncate && styles['combobox-input__field--truncated'],\n    inputClassName,\n  );\n\n  const inputRef = useRef<HTMLInputElement>(null);\n  const hasChips = Boolean(showChips && multiple && selectedValues.length > 0);\n\n  /**\n   * Picking an option leaves the query that found it sitting in the field, since HeadlessUI only\n   * rewrites the text for a single-select value. Select that text once the chip appears, so the\n   * next keystroke starts a fresh search instead of appending to a query that's already been\n   * spent. The caret lands at the end for anyone who'd rather keep typing on it.\n   */\n  const chipCountRef = useRef(selectedValues.length);\n\n  useEffect(() => {\n    const previousChipCount = chipCountRef.current;\n    chipCountRef.current = selectedValues.length;\n\n    // Only on a chip being added. Removals (close button, backspace) leave the query alone.\n    if (!showChips || !multiple || selectedValues.length <= previousChipCount) {\n      return;\n    }\n\n    const input = inputRef.current;\n\n    // A selection can also change from outside the field. Reaching for the text then would pull\n    // the caret away from wherever the person actually is, so leave it be.\n    if (!input || input.ownerDocument.activeElement !== input) {\n      return;\n    }\n\n    input.select();\n  }, [multiple, selectedValues.length, showChips]);\n\n  /**\n   * Backspace on an empty field drops the last chip, which is what people expect from a field\n   * full of chips. HeadlessUI doesn't bind Backspace on the combobox input as of v2.2, so\n   * there's nothing to fight with; we still mark the event handled in case that changes.\n   */\n  const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (event) => {\n    theirOnKeyDown && theirOnKeyDown(event);\n\n    if (\n      !hasChips ||\n      event.key !== 'Backspace' ||\n      event.defaultPrevented ||\n      // Only once the query is gone, so backspace still edits text first\n      event.currentTarget.value !== ''\n    ) {\n      return;\n    }\n\n    event.preventDefault();\n    removeValue && removeValue(selectedValues[selectedValues.length - 1]);\n  };\n\n  return (\n    <ComboboxInputWrapper\n      className={className}\n      hasChips={hasChips}\n      status={status}\n    >\n      {hasChips && (\n        // A list, so screen readers announce how many values are currently selected\n        <ul className={styles['combobox-input__chips']}>\n          {selectedValues.map((value, index) => (\n            // The selection is an ordered list and position is what removal acts on, so the\n            // index is the stable identity here\n            // eslint-disable-next-line react/no-array-index-key\n            <li key={`${index}-${chipLabel(value)}`}>\n              <InputChip\n                isDisabled={disabled}\n                label={chipLabel(value)}\n                leadingComponent={chipLeadingComponent?.(value)}\n                onClick={(event) => {\n                  // Without this the click reaches the field and reopens the option list\n                  event.preventDefault();\n                  event.stopPropagation();\n                  removeValue?.(value);\n                }}\n              />\n            </li>\n          ))}\n        </ul>\n      )}\n      <ComboboxInput\n        aria-label={ariaLabel ?? contextAriaLabel}\n        className={fieldClassName}\n        onKeyDown={handleKeyDown}\n        ref={inputRef}\n        required={required}\n        style={\n          {\n            '--combobox__input-width': `calc(${inputRef.current?.value.length || 0} * 1ch)`,\n          } as CSSProperties\n        }\n        {...other}\n      />\n    </ComboboxInputWrapper>\n  );\n};\n\n/**\n * The content container showing the available options. Pass in the options that match the\n * current query; `Combobox` does no filtering of its own. With none passed in, it shows\n * `noMatchesText` instead.\n *\n * The list lines up with the field, not the text field inside it. HeadlessUI can only anchor to\n * the text field, which moves and narrows as chips fill the field, so we position the list with\n * Floating UI instead.\n */\nconst ComboboxOptionsComponent = function (props: ComboboxOptionsProps) {\n  const {\n    anchor,\n    children,\n    className,\n    noMatchesText = 'No matches found',\n    ref,\n    style,\n    ...other\n  } = props;\n  const { fieldElement, hasNoVirtualOptions, optionsClassName } =\n    useContext(ComboboxContext);\n\n  // Without a field to line up with (e.g., a custom input outside `Combobox.InputWrapper`), fall\n  // back to HeadlessUI's anchoring from the text field\n  const shouldAnchorToField = anchor === undefined && Boolean(fieldElement);\n\n  const { floatingStyles, refs } = useFloating({\n    elements: { reference: shouldAnchorToField ? fieldElement : null },\n    placement: 'bottom-start',\n    // Position with top/left, since the container's entry animation holds `transform`\n    transform: false,\n    whileElementsMounted: autoUpdate,\n    middleware: [\n      offset(OPTIONS_GAP),\n      flip(),\n      size({\n        // At least as wide as the field. A width class from the consumer can still widen it.\n        apply({ elements: { floating }, rects }) {\n          floating.style.minWidth = `${rects.reference.width}px`;\n        },\n      }),\n    ],\n  });\n\n  // The consumer's ref still gets the list when Floating UI needs it too\n  const floatingRef = useMergeRefs([refs.setFloating, ref]);\n\n  const componentClassName = clsx(\n    styles['combobox__options'],\n    className,\n    optionsClassName,\n  );\n\n  // A disabled option rather than loose text, since a listbox may only hold options. It's not a\n  // HeadlessUI option: those need a value, which HeadlessUI runs through the consumer's `by`\n  // comparator, and there's no value here that every comparator can read.\n  const noMatches = (\n    <div\n      aria-disabled=\"true\"\n      aria-selected=\"false\"\n      className={styles['combobox__no-matches']}\n      role=\"option\"\n    >\n      <Text as=\"div\" preset=\"body-sm\">\n        {noMatchesText}\n      </Text>\n    </div>\n  );\n\n  // `hasSlotContent` looks inside fragments and arrays and skips null, undefined, and booleans,\n  // so options that are wrapped in a fragment or rendered conditionally still count as none\n  // when nothing renders. A render prop is checked on what it returns. In virtual mode\n  // HeadlessUI calls it once per option (passing that option), so its result is left alone,\n  // and with no virtual options it isn't called at all.\n  const content = hasNoVirtualOptions\n    ? noMatches\n    : typeof children === 'function'\n      ? (slot: Parameters<typeof children>[0]) => {\n          const result = children(slot);\n          return slot.option !== undefined || hasSlotContent(result)\n            ? result\n            : noMatches;\n        }\n      : hasSlotContent(children)\n        ? children\n        : noMatches;\n\n  const options = (\n    <ComboboxOptions\n      anchor={\n        shouldAnchorToField\n          ? undefined\n          : (anchor ?? { to: 'bottom start', gap: 24, offset: -12 })\n      }\n      as={PopoverContainer}\n      className={componentClassName}\n      modal={false}\n      ref={shouldAnchorToField ? floatingRef : ref}\n      style={shouldAnchorToField ? { ...floatingStyles, ...style } : style}\n      {...other}\n    >\n      {content}\n    </ComboboxOptions>\n  );\n\n  // HeadlessUI portals the list itself when it anchors. We do the same so the list isn't clipped\n  // by a scrolling or overflow-hidden ancestor.\n  return shouldAnchorToField ? (\n    <FloatingPortal>{options}</FloatingPortal>\n  ) : (\n    options\n  );\n};\n\n/**\n * Represents one of the available options for selection\n */\nconst ComboboxOptionComponent = function (props: ComboboxOptionProps) {\n  const {\n    children,\n    className,\n    optionClassName,\n    subLabel: optionSubLabel,\n    ...other\n  } = props;\n\n  const optionItemClassName = clsx(\n    className,\n    optionClassName,\n    styles['combobox__option'],\n  );\n  const { multiple } = useContext(ComboboxContext);\n\n  return (\n    <ComboboxOption\n      // Render as a fragment instead of the default <div>. We're rendering our own element in\n      // the render prop to control active/selected styling, and we don't want to end up with\n      // duplicate elements.\n      as={React.Fragment}\n      {...other}\n    >\n      {typeof children === 'function'\n        ? children\n        : ({ focus, disabled, selected }) => {\n            return (\n              <PopoverListItem\n                __type=\"selectitem\"\n                className={optionItemClassName}\n                isDisabled={disabled}\n                isFocused={focus}\n                leadingContent={\n                  multiple ? (\n                    <Checkbox\n                      aria-hidden=\"true\"\n                      aria-label=\"checkbox\"\n                      checked={selected}\n                      inert\n                      readOnly\n                    />\n                  ) : (\n                    <Radio\n                      aria-hidden=\"true\"\n                      aria-label=\"radio\"\n                      checked={selected}\n                      inert\n                      readOnly\n                    />\n                  )\n                }\n                subLabel={optionSubLabel}\n              >\n                <span className={styles['combobox__option-text']}>\n                  {children}\n                </span>\n              </PopoverListItem>\n            );\n          }}\n    </ComboboxOption>\n  );\n};\n\n/**\n * The component providing the field border, background, and the toggle button, with space\n * for the text field. Use it directly when you need to render your own `ComboboxInput` but\n * want to keep the EDS field appearance.\n */\nexport const ComboboxInputWrapper = React.forwardRef<\n  HTMLDivElement,\n  ComboboxInputWrapperProps\n>((props, ref) => {\n  const {\n    children,\n    className,\n    hasChips,\n    status: theirStatus,\n    // TODO(next-major): remove, with the assert below.\n    icon: removedIcon,\n    ...other\n  } = props as WithRemovedIconProps<typeof props, 'icon'>;\n\n  // TODO(next-major): remove.\n  assertNoRemovedIconProp(\n    'Combobox.InputWrapper',\n    'icon',\n    'expand',\n    removedIcon,\n  );\n\n  const { setFieldElement, status: contextStatus } =\n    useContext(ComboboxContext);\n  const status = theirStatus ?? contextStatus;\n  const mergedRef = useMergeRefs([ref, setFieldElement]);\n\n  const componentClassName = clsx(\n    styles['combobox-input'],\n    hasChips && styles['combobox-input--has-chips'],\n    status === 'warning' && styles['combobox-input--warning'],\n    status === 'critical' && styles['combobox-input--error'],\n    className,\n  );\n\n  return (\n    <div className={componentClassName} ref={mergedRef} {...other}>\n      {children}\n      <ComboboxButtonComponent />\n    </div>\n  );\n});\n\nCombobox.displayName = 'Combobox';\nComboboxButtonComponent.displayName = 'Combobox.Button';\nComboboxInputComponent.displayName = 'Combobox.Input';\nComboboxInputWrapper.displayName = 'Combobox.InputWrapper';\nComboboxLabelComponent.displayName = 'Combobox.Label';\nComboboxOptionComponent.displayName = 'Combobox.Option';\nComboboxOptionsComponent.displayName = 'Combobox.Options';\n\nCombobox.Button = ComboboxButtonComponent;\nCombobox.Input = ComboboxInputComponent;\nCombobox.InputWrapper = ComboboxInputWrapper;\nCombobox.Label = ComboboxLabelComponent;\nCombobox.Option = ComboboxOptionComponent;\nCombobox.Options = ComboboxOptionsComponent;\n"],"names":["React","HeadlessCombobox"],"mappings":";;;;;;;;;;;;;;;;;;AAmUA;;;AAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,KAAoB,KAAI,EAAA,IAAA,EAAA,CAAA,CAChD,OAAA,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC,CAAA,EAAA,GAAA,KAAK,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,EAAE,CAAC,CAAA,EAAA;AAE/D,IAAI,eAAe,GAAG,IAAI;AAE1B,MAAM,eAAe,GAAGA,cAAK,CAAC,aAAa,CAAsB,EAAE,CAAC;AAEpE;;AAEG;AACH,MAAM,WAAW,GAAG,EAAE;AAEtB;;;;AAIG;AACH,MAAM,YAAY,GAAGC,UAAsD;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDG;SACa,QAAQ,CAAC,EACvB,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