import type { ReactNode } from 'react'; import type { ActiveFilter, FilterField, QuickFilter } from './filterModel.js'; import { type FilterStore, type ListFilters } from './useListFilters.js'; /** A toggleable column. Rendering stays in the page's row component, gated by * {@link ListView.isVisible}; this is just the header metadata + visibility. */ export interface ColumnDef { key: string; label: string; headerClassName?: string; /** Pinned on — never offered in the column picker — and the list's name * column, which keeps a minimum width so it can't be crushed. */ alwaysVisible?: boolean; /** Always shown and never offered in the column picker, at its own width: * for a column such as a delete button's, which `alwaysVisible` would widen * to a name's minimum. */ locked?: boolean; /** Hidden until the user turns it on in the Display menu. */ defaultHidden?: boolean; /** NOT a table column (no header) — appears in picker and isVisible, but excluded from visibleColumns. */ inline?: boolean; /** Drops below a container width instead of stacking (see `stack`). */ priority?: ColumnPriority; /** Below the `medium` width, a column without a `priority` gives up its cell * and its content shows under the first column's instead, so a phone gets a * row it can read rather than one running off the side. `false` keeps it a * column there: for something short that compares best lined up, like a * total. The first column never stacks; it is what the others stack under. */ stack?: boolean; /** Where a stacked column's value sits on the lines under the name. By default the stacked * values share a line, flowing and wrapping between them. `own` starts a line of its own, for * a value read first, such as a status; `join` stays on the line before it after a "·", for * one that belongs with that value, such as a job's nodes after its partition. */ stackLine?: StackLine | undefined; /** The `value` of the {@link OrderByOption} this column sorts by. Its header * then sorts the list: it shows, and sets, the same order as Display * options' Ordering. */ orderBy?: string; /** The column's width, such as `'12%'` or `128`, set on its header. In a * fixed-layout list (`listTableFixedProps`), where every column without one * takes an equal share, give the other columns a width each and leave the * name without one, so it takes what they leave. A percentage is a share of * the list: when narrower widths drop columns, the shares they held go to * the columns left, each in proportion to its own, the name's among them. */ width?: string | number; /** `end` sets the header and the cells against the column's far edge, for * figures, sizes and times that compare best lined up on their last digit. */ align?: 'start' | 'end'; } /** Column responsive importance; `low` drops before `medium`. See {@link ColumnDef.priority}. */ type ColumnPriority = 'low' | 'medium'; /** How a stacked column's value lines up with the others under the name; see * {@link ColumnDef.stackLine}. */ export type StackLine = 'own' | 'join'; /** Whether a column is always shown and kept out of the column picker. */ export declare function isLocked(col: ColumnDef): boolean; interface GroupByOption { value: string; label: string; } /** compare is the ascending comparator; the view negates it for descending. */ export interface OrderByOption { value: string; label: string; compare: (a: T, b: T) => number; } type OrderDir = 'asc' | 'desc'; /** A multi-choice filter: shorthand for an `enum` {@link FilterField} offering "is" and "is not". * `matches` decides whether a row passes given the values chosen ("is not" passes the rows it * turns away). */ export interface FilterFacet { key: string; label: string; options: { value: string; label: string; icon?: ReactNode; }[]; matches: (row: T, selected: string[]) => boolean; shared?: boolean; searchable?: boolean; } /** A page's own on-or-off choice in Display options, such as how amounts are written, remembered * and reset with the rest of the view. */ export interface DisplaySwitch { key: string; label: string; defaultOn?: boolean; } /** Picker metadata + default pinned state only — per-row icons and handlers live in the row component. */ export interface ActionDef { key: string; label: string; defaultPinned?: boolean; } export interface ListViewConfig { /** Persistence namespace for this page's grouping/columns/filters. */ storageKey: string; sharedFiltersKey?: string; columns: ColumnDef[]; groupBys?: GroupByOption[]; defaultGroupBy?: string; orderBys?: OrderByOption[]; defaultOrderBy?: string; facets?: FilterFacet[]; /** Filters beyond facets: people, dates, text, yes-or-no, with conditions. They follow the * facets in the Filter menu. */ filterFields?: FilterField[] | undefined; /** What the page shows before the reader changes anything; Reset returns to them. */ defaultFilters?: ActiveFilter[] | undefined; /** Filters held outside the list too, such as the URL: its filters win while it has any, and * changes go to both. See `decodeFilters` and `encodeFilters`. */ filterStore?: FilterStore | undefined; /** False leaves remembering the filters to `filterStore` alone. */ rememberFilters?: boolean | undefined; /** Fields whose values also show as toggles above the chips, such as a job's state with how * many jobs are in each. */ quickFilters?: readonly QuickFilter[] | undefined; actions?: ActionDef[]; /** Explicit pinned-button count when not using actions+isPinned; sizes the actions column. */ actionCount?: number; /** Whether the column-header row shows before the user changes Display * options (default true). */ defaultShowColumnHeaders?: boolean; /** Whether row action affordances show before the user changes Display options. */ defaultShowActions?: boolean; switches?: DisplaySwitch[]; /** Adds built-in "Default" and "Favorites" sort modes; "Default" wins until the user picks a sort. */ isFavorite?: (row: T) => boolean; /** Whether a row is powered on/running; "Default" sort keeps on-rows above off-rows. */ isOn?: (row: T) => boolean; /** Creation time (ms) for a row; "Default" sort falls back to newest-first. */ createdAt?: (row: T) => number | null | undefined; } export declare const DEFAULT_ORDER = "__default"; export declare const FAVORITE_ORDER = "__favorite"; /** Generic-free so pages can pass view to ListPage regardless of row type. */ export interface ListViewChrome { /** Whether rows render their action affordances at all (the `⋯` + pinned * buttons). Usually on by default; pages can opt out via defaultShowActions. */ showActions: boolean; /** Whether those actions show at rest rather than only on hover/focus. */ alwaysShowActions: boolean; /** Responsive show/hide class per visible column (aligned to * {@link visibleColumns}); `ListColumns` and `ListRow` apply entry `i`. */ columnClasses: string[]; /** Per visible column, whether it stacks under the first on a narrow * container ({@link ColumnDef.stack}); `ListRow` reads entry `i`. */ columnStacks: boolean[]; /** Per visible column, the line its stacked value takes ({@link ColumnDef.stackLine}). */ columnStackLines?: (StackLine | undefined)[] | undefined; /** Whether the last column is a locked one, such as a delete button's: the * row's `⋯` then keeps a lane of its own after it rather than floating over * it on hover. */ lastColumnLocked?: boolean | undefined; /** Whether the row's `⋯` keeps a lane of its own after the last column * rather than floating over its end on hover: the last column is locked, or * it is end-aligned, such as a runtime or a count, whose value sits right * where the `⋯` would and would be hidden while the row is hovered. A text * column's end is usually blank, so the `⋯` floats there and the list keeps * its width. */ reservesActionLane?: boolean | undefined; /** The list's filters, which `ListPage` shows as a row of chips under its toolbar. */ filterState?: ListFilters | undefined; /** Which of the list's groups are collapsed, remembered with the view: a `ListGroup` with a * `groupKey` inside the `ListPage` reads and sets it. */ groupState?: ListGroupState | undefined; } /** The collapsed state of a list's groups, kept by its view under its `storageKey`. */ export interface ListGroupState { /** Whether the group is collapsed: as the reader last left it, or else `defaultCollapsed`. */ isCollapsed: (key: string, defaultCollapsed?: boolean) => boolean; setCollapsed: (key: string, collapsed: boolean) => void; /** A shown group's place in Collapse all and Expand all, until the returned function drops it. */ register: (key: string, defaultCollapsed: boolean) => () => void; } export interface ListView extends ListViewChrome { columns: ColumnDef[]; /** Columns rendered as table columns right now (user-enabled, not inline). * Headers and group-row colspans read this so they always match the cells. */ visibleColumns: ColumnDef[]; /** Whether a column is turned on (drives both cells and the Display picker). */ isVisible: (key: string) => boolean; /** Number of always-visible pinned buttons a row shows (drives column width). */ pinnedCount: number; /** Pixel width the trailing actions column reserves for its buttons. */ actionsWidth: number; toggleColumn: (key: string) => void; groupBys: GroupByOption[]; groupBy: string; setGroupBy: (value: string) => void; orderBys: OrderByOption[]; orderBy: string; setOrderBy: (value: string) => void; orderDir: OrderDir; toggleOrderDir: () => void; /** Orders by `value` ascending, or flips the direction when the list * already orders by it: a sortable column header's click. */ sortBy: (value: string) => void; applyOrder: (rows: T[]) => T[]; facets: FilterFacet[]; filterState: ListFilters; /** The values of each filter that reads "is"; `filterState.active` has every filter. */ filters: Record; setFacetValues: (key: string, values: string[]) => void; /** Empties every filter but the required ones. */ clearFilters: () => void; activeFilterCount: number; applyFilters: (rows: T[]) => T[]; actions: ActionDef[]; isPinned: (key: string) => boolean; togglePinned: (key: string) => void; /** Whether the table renders its column-header row (default on). */ showColumnHeaders: boolean; toggleColumnHeaders: () => void; /** Toggle whether rows expose action affordances. */ toggleShowActions: () => void; toggleAlwaysShowActions: () => void; switches: DisplaySwitch[]; isSwitchOn: (key: string) => boolean; toggleSwitch: (key: string) => void; /** True when grouping, columns, header row, and pinned actions are all at * their defaults. */ isDisplayDefault: boolean; /** Restore grouping, columns, header row, and pinned actions to their * defaults (does not touch field filters — those have their own Clear). */ resetDisplay: () => void; groupState: ListGroupState; /** The keys of the collapsible groups the list shows now. */ groupKeys: string[]; /** Whether every group the list shows is collapsed. */ allGroupsCollapsed: boolean; collapseAllGroups: () => void; expandAllGroups: () => void; } /** Persisted grouping + column-visibility + field-filter state for a list page, * driving the shared Display/Filter menus. */ export declare function useListView({ storageKey, sharedFiltersKey, columns, groupBys, defaultGroupBy, orderBys, defaultOrderBy, facets, filterFields, defaultFilters, filterStore, rememberFilters, quickFilters, actions, actionCount, defaultShowColumnHeaders, defaultShowActions, switches, isFavorite, isOn, createdAt, }: ListViewConfig): ListView; export {};