import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["input"]; type $Props = { /** * Specify the value of the search input. * Follows the field when the owning form resets. * @default "" */ value?: T; /** * Specify the size of the search input. * Inherits the parent `Form` size when unset, otherwise `"lg"` (40px), * as in Carbon v11. Also accepts Carbon v11's `"md"` (`"lg"`, 40px). * Carbon v11's 48px `lg` is `"xl"` here. * @default "lg" */ size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined; /** * Specify the class name passed to the outer div element * @default "" */ searchClass?: string; /** * Set to `true` to display the skeleton state * @default false */ skeleton?: boolean; /** * Set to `true` to disable the search input * @default false */ disabled?: boolean; /** * Specify the helper text * @default "" */ helperText?: string; /** * Set to `true` to use the read-only variant. * The value cannot be edited or cleared, and still submits with the form. * @default false */ readonly?: boolean; /** * Set to `true` to enable the expandable variant * @default false */ expandable?: boolean; /** * Set to `true to expand the search input. * @default false */ expanded?: boolean; /** * Set to `true` to use the fluid variant. * Inherited from the parent `FluidForm` context, * so it does not need to be set when used inside `FluidForm`. * Cannot be combined with the expandable variant. * @default false */ fluid?: boolean; /** * Specify the `placeholder` attribute of the search input * @default "Search..." */ placeholder?: string; /** * Specify the `autocomplete` attribute. * @default "off" */ autocomplete?: "on" | "off"; /** * Set to `true` to auto focus the search element * @default false */ autofocus?: boolean; /** * Specify the close button label text * @default "Clear search input" */ closeButtonLabelText?: string; /** * Specify a keyboard shortcut that focuses the field, such as `"/"` or * `"mod+k"`. `mod` is Command on Apple platforms and Ctrl elsewhere. The * keys show at the end of the empty field until it's focused, and the * input gets `aria-keyshortcuts`. A shortcut without a modifier, such as * `"/"`, doesn't fire while typing in another field. * @default "" */ shortcut?: string; /** * Specify the label text * @default "" */ labelText?: string; /** * Set to `true` to visually hide the label text * @default false */ hideLabel?: boolean; /** * Set to `true` to indicate an invalid state * @default false */ invalid?: boolean; /** * Specify the invalid state text * @default "" */ invalidText?: string; /** * Set to `true` to indicate a warning state * @default false */ warn?: boolean; /** * Specify the warning state text * @default "" */ warnText?: string; /** * Specify the icon to render. * @default IconSearch */ icon?: Icon; /** * Set an id for the input element * @default uniqueId() */ id?: string; /** * Obtain a reference to the input HTML element. * @default null */ ref?: null | HTMLInputElement; /** * Set to `true` to select the input's text when it receives focus * @default false */ selectTextOnFocus?: boolean; /** * Set to `true` while results are loading. Shows a small spinner in place * of the search icon and sets `aria-busy` on the input. The field stays * editable. * @default false */ loading?: boolean; /** * Specify the assistive text for the spinner shown while `loading` * @default "Searching" */ loadingDescription?: string; /** * Wait this many milliseconds after `loading` turns `true` before showing * the spinner. Once shown, it stays for at least 500 ms, so fast work shows * nothing and slow work never flashes. The input sets `aria-busy` as soon as * `loading` is `true`. * Set to `0` to show it at once. * @default 0 */ loadingDelay?: number; /** * Milliseconds to wait after the last input before dispatching `search`. * 0 (default) does not dispatch on input; Enter still dispatches * immediately. When greater than 0, `search` also fires after the pause. * `value` updates immediately either way. * @default 0 */ debounce?: number; labelChildren?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type SearchProps = Omit<$RestProps, keyof $Props> & $Props; export default class Search extends SvelteComponentTyped< SearchProps, { blur: WindowEventMap["blur"]; change: WindowEventMap["change"]; clear: CustomEvent; click: WindowEventMap["click"]; collapse: CustomEvent; expand: CustomEvent; focus: WindowEventMap["focus"]; input: WindowEventMap["input"]; keydown: WindowEventMap["keydown"]; keyup: WindowEventMap["keyup"]; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; mouseover: WindowEventMap["mouseover"]; paste: WindowEventMap["paste"]; search: CustomEvent; /** Dispatched when `shortcut` is pressed, before the field is focused. Call `preventDefault()` to skip the focus. */ shortcut: CustomEvent; }, { labelChildren: Record } > { /** * Focus the input without selecting text, even when `selectTextOnFocus` is set. */ focusWithoutSelect: () => void; }