UNPKG

@dvcol/neo-svelte

Version:

Neomorphic ui library for svelte 5

44 lines (43 loc) 2.07 kB
import type { NeoInputProps } from '../inputs/common/neo-input.model.js'; import type { NeoListContext, NeoListItemOrSection } from './neo-list.model.js'; import type { HTMLNeoBaseElement, HTMLRefProps } from '../utils/html-element.utils.js'; export type NeoListSearchFilter = (item: NeoListItemOrSection, search?: string) => boolean; export type NeoListSearchSort = (a: NeoListItemOrSection, b: NeoListItemOrSection, invert?: boolean) => number; export type NeoListSearchProps<Tag extends keyof HTMLElementTagNameMap = 'div'> = { /** * The HTML tag to use for the container. * @default 'li' */ tag?: Tag; /** * Debounce delay in milliseconds before filtering the list. * * @default 250 */ delay?: number; /** * Whether to invert the sort order of the list. */ invert?: boolean; /** * Custom filter function to apply to the list (overrides default list filter). * Defaults to filtering by label alphabetically based on the list highlight filter. * @see NeoListContext.highlight */ filter?: NeoListSearchFilter; /** * Custom sort function to apply to the list (overrides default list sort). * Defaults unsorted and toggles between ascending and descending alphabetical label order. */ sort?: NeoListSearchSort | false; /** * List context (used to extract the highlight filter). */ context?: NeoListContext; /** * Optional props to pass to the input. */ inputProps?: NeoInputProps; } & HTMLRefProps<HTMLInputElement> & Pick<NeoInputProps, 'value' | 'valid' | 'dirty' | 'touched' | 'hovered' | 'focused' | 'focusin' | 'loading' | 'elevation' | 'hover' | 'blur' | 'pressed' | 'placeholder' | 'rounded' | 'borderless' | 'glass' | 'tinted' | 'color' | 'disabled' | 'skeleton' | 'readonly'> & HTMLNeoBaseElement<HTMLElementTagNameMap[Tag]>; export declare const itemSearchFilter: NeoListSearchFilter; export declare function itemLabelSort(a: NeoListItemOrSection, b: NeoListItemOrSection, reverse?: boolean): number;