UNPKG

compote-ui

Version:

An opinionated UI component library for Svelte, built on top of [Ark UI](https://ark-ui.com) with additional components and features not available in the core Ark UI library.

42 lines (41 loc) • 2.1 kB
/** The slice of a TanStack column the filter editors read and write. */ export type FilterableColumn = { id: string; getFilterValue(): unknown; setFilterValue(value: unknown): void; }; export type ColumnFilterEditingOptions = { /** The table the edited columns belong to; read on every access so it may change. */ table: () => object; /** * Whether `columnId` still has an editor. An editor torn down by an outside change can * still emit — Ark's NumberInput commits the typed number on the blur its unmount * triggers — and that must not write back a filter the app just cleared. */ isActive?: (columnId: string) => boolean; }; /** Drops every pending filter edit on `table` without committing, whichever host made it. */ export declare function cancelPendingFilterEdits(table: object): void; /** * One host's access to a table's pending filter edits (see PendingFilterEdits). The edits * live with the table, not with the host or its editors, so an edit still commits after its * editor unmounts with a closing popover. * * A control shows its pending edit if there is one, otherwise the column's live filter * value — so a filter changed from outside (the app calling setFilterValue / * setColumnFilters / resetColumnFilters) never leaves a stale value in the inputs, an edit * pending during that change is dropped rather than re-applied, and committing one range * bound never restores the other's old value. */ export declare class ColumnFilterEditing { #private; constructor(options: ColumnFilterEditingOptions); textValue(column: FilterableColumn): string; editText(column: FilterableColumn, value: string): void; rangeBound(column: FilterableColumn, which: 'min' | 'max'): number | null; editRange(column: FilterableColumn, which: 'min' | 'max', value: number | null): void; /** Drops the pending edits for one column without committing them. */ cancel(columnId: string): void; /** Drops every pending edit on the table without committing — including other hosts'. */ cancelAll(): void; }