import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["input"]; type $Props = { /** * Specify the value of the search input. * @default "" */ value?: number | string; /** * Set to `true` to expand the search bar. * @default false */ expanded?: boolean; /** * Set to `true` to keep the search bar expanded * @default false */ persistent?: boolean; /** * Specify the label text. It is visually hidden and names the search * field for assistive technology. * @default "Search" */ labelText?: string; /** * Set to `true` to disable the search bar * @default false */ disabled?: boolean; /** * Set to `true` to filter table rows using the search value. * * If `true`, the default search excludes `id`, `cells` fields and * only does a basic comparison on string and number type cell values. * * To implement your own client-side filtering, pass a function * that accepts a row and value and returns a boolean. * @default false */ shouldFilterRows?: boolean | ((row: Row, value: number | string) => boolean); /** * The filtered row ids. * @default [] */ filteredRowIds?: ReadonlyArray; /** * Specify the tabindex * @default "0" */ tabindex?: number | string | undefined; /** * Milliseconds of quiet time before rows are filtered. Filtering waits * until typing pauses; `value` still updates immediately; clearing * applies at once. `0` filters synchronously on every keystroke. A * starting `value` filters on mount without waiting. * * Unrelated to the `search` event, which fires on Enter * regardless of this delay. * @default 0 */ debounce?: number; /** * Set to `true` to yield to the browser before rows are filtered, so the * input and the clear button paint before a large table re-renders. * `value` still updates immediately. * * Filtering becomes asynchronous: `filteredRowIds` and the table rows * update shortly after `value`, and clearing no longer applies at once. * Rapid changes coalesce, so only the latest value is filtered. Combined * with `debounce`, the debounce delay elapses first, then the filter yields. * The first filter on mount and server rendering stay synchronous. * @default false */ deferFilter?: boolean; /** * 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; [key: `data-${string}`]: unknown; }; export type ToolbarSearchProps = Omit<$RestProps, keyof $Props> & $Props; export default class ToolbarSearch extends SvelteComponentTyped< ToolbarSearchProps, { blur: WindowEventMap["blur"]; change: WindowEventMap["change"]; clear: CustomEvent; focus: WindowEventMap["focus"]; input: WindowEventMap["input"]; keydown: WindowEventMap["keydown"]; keyup: WindowEventMap["keyup"]; paste: WindowEventMap["paste"]; search: CustomEvent; }, Record > { /** * Programmatically clear the search input. * Resets `value` and collapses the search bar (unless `persistent`). * @example * ```svelte * * * ``` */ clear: () => void; }