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.

38 lines (37 loc) • 1.89 kB
/** * Value handling for `type: 'select'` data-table columns. A select cell holds either one * value or an array of values (multi-value / tag columns); both facet, filter and render * through the same helpers so the Funnel works the same for either shape. */ /** * Filter value standing for "no value". It is `null`, not a string, so it can never * collide with a real option — a cell whose value is the string `'null'` stays a regular * option. Every other selected option is the `String()` of the cell value. */ export declare const EMPTY_SELECT_VALUE: null; export type SelectFilterValue = string | typeof EMPTY_SELECT_VALUE; /** * The values a select cell contributes to facets and filters: each distinct item of an * array, or the scalar itself. Items are distinct by their filter value (`String()`), so a * row counts once per option even when its array repeats an item. A missing cell (null, * undefined, '' or an empty array) is one `EMPTY_SELECT_VALUE`, so it facets and filters * as a single "empty" option. */ export declare function selectCellValues(value: unknown): unknown[]; /** One-of filter: the cell matches when any of its values is among the selected options. */ export declare function matchesSelectFilter(value: unknown, filterValue: SelectFilterValue[]): boolean; export type SelectFilterOption = { value: SelectFilterValue; label: string; count: number; }; /** * Filter options from a column's faceted unique values: sorted by label, with the empty * option (labelled `emptyLabel`) last. */ export declare function selectFilterOptions(facets: Map<unknown, number>, emptyLabel?: string): SelectFilterOption[]; /** * Cell text for a select value: the same distinct items the Funnel lists, joined with `, `; * undefined when empty. */ export declare function formatSelectValue(value: unknown): string | number | boolean | undefined;