import type React from 'react'; import type { FocusDetail, InputDetail, KeyboardDetail, OptionGroup, SelectDetail, SelectOption } from './types.js'; export interface AutocompleteRef extends HTMLElement { /** Opens the suggestion dropdown. */ open(): void; /** Closes the suggestion dropdown. */ close(): void; /** Clears all selections (multi-mode) or the input (single-mode). */ clear(): void; /** Focuses the search input. */ focus(): void; /** Returns the current selection. A single string in single mode, a string array in `mode="multiple"` — matching the shape of `cx-change`'s `detail.value`. */ getValue(): string | string[]; /** Sets the selection programmatically. Accepts an array in `mode="multiple"`. */ setValue(value: string | string[]): void; } /** * Like Select, options come from the `items` prop (not children). * Filtering is client-side by default. For server-side search, update `items` in your `onInput` handler. * Multi-select mode uses `mode="multiple"` with chip display. * * In React, reach the imperative methods through a ref: * `const api = useRef(null)`, pass `ref={api}`, then `api.current?.open()`. * Available: open(), close(), clear(), +3 more. * * @csspart base */ export interface AutocompleteOwnProps { /** * Unique identifier for the element. * @example 'example-id' */ id?: string; /** * Visible label text. * @example 'Example label' */ label: string; /** * Visual style variant. Allowed values: `outline`, `filled`, `ghost`. * @example 'outline' */ variant?: 'outline' | 'filled' | 'ghost'; /** * Corner radius style. Allowed values: `sharp`, `rounded`, `pill`. * @example 'sharp' */ shape?: 'sharp' | 'rounded' | 'pill'; /** * Component size. Allowed values: `xs`, `sm`, `md`, `lg`, `xl`. * @example 'xs' */ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'; /** * 'single' for single select, 'multiple' for multi-select with chips. Allowed values: `single`, `multiple`. * @example 'single' */ mode?: 'single' | 'multiple'; /** * Currently selected item ID(s). * @example ['item-1'] */ selected?: string[]; /** * Current search query text. Controlled by onInput events. * @example 'example' */ query?: string; /** * Placeholder text shown when empty. * @example 'Enter a value' */ placeholder?: string; /** * Helper text displayed below the input. * @example 'example' */ helperText?: string; /** * Error message text. When set, shows validation error styling. * @example 'This field is invalid' */ error?: string; /** * Disables the component, preventing interaction. * @defaultValue false * @example true */ disabled?: boolean; /** * Marks the field as required for form validation. * @defaultValue false * @example true */ required?: boolean; /** * Makes the component read-only. * @defaultValue false * @example true */ readonly?: boolean; /** * Form field name for submission. * @example 'fieldName' */ name?: string; /** * When true, user can submit values not in the items list. * @defaultValue false * @example true */ allowCustom?: boolean; /** * Whether a clear button appears when the field has a value. * @defaultValue false * @example true */ clearable?: boolean; /** * Options to filter from. Filtering is client-side (fuzzy substring match). For server-side search, update this array in your onInput handler. * @example [{ value: 'a', label: 'Option A' }] */ items?: SelectOption[]; /** * Typed array of grouped item data. Bind as a property; do not stringify it or use children for groups. * @example [{ label: 'Group', options: [{ value: 'a', label: 'Option A' }] }] */ groups?: OptionGroup[]; /** * Fires on each user edit before the value is committed. Detail: `InputDetail`. * @example (event) => console.log(event.detail.value) */ onInput?: (event: CustomEvent) => void; /** * Fires when the committed component value or state changes. Detail: `SelectDetail`. * @example (event) => console.log(event.detail.value) */ onChange?: (event: CustomEvent) => void; /** * Fires when focus enters the component. Detail: `FocusDetail`. * @example (event) => console.log(event.detail.relatedTarget) */ onFocus?: (event: CustomEvent) => void; /** * Fires when focus leaves the component. Detail: `FocusDetail`. * @example (event) => console.log(event.detail.relatedTarget) */ onBlur?: (event: CustomEvent) => void; /** * Fires when a key is pressed inside the component. Detail: `KeyboardDetail`. * @example (event) => console.log(event.detail.key) */ onKeydown?: (event: CustomEvent) => void; /** * Fires when a key is released inside the component. Detail: `KeyboardDetail`. * @example (event) => console.log(event.detail.key) */ onKeyup?: (event: CustomEvent) => void; /** CSS class applied to the Custom Element host. * @example 'my-component' */ className?: string; /** Inline styles applied to the Custom Element host. * @example { marginTop: 8 } */ style?: React.CSSProperties; } /** * Props for ``: the component's own API plus every standard DOM * attribute and native React event handler, forwarded verbatim to the * `` host — `id`, `data-*`, `aria-*`, `title`, `tabIndex`, * `slot`, `onMouseEnter`, and the rest. Own props always win over a * same-named DOM attribute. */ export type AutocompleteProps = AutocompleteOwnProps & Omit, keyof AutocompleteOwnProps | 'children' | 'dangerouslySetInnerHTML'>; export declare const Autocomplete: React.ForwardRefExoticComponent, "children" | "dangerouslySetInnerHTML" | keyof AutocompleteOwnProps> & React.RefAttributes>;