import "./sort_header.css"; import type * as React from "react"; import { Button as Base } from "@base-ui/react/button"; import type { useRender } from "@base-ui/react/use-render"; import { type StyleProps } from "./style_props"; export type SortDir = "asc" | "desc"; export interface SortState { key: string; dir: SortDir; } /** none → `first` → the other way → none; the parent holds one `SortState | null`. A register of dates and * amounts starts `"desc"`, since the newest or largest is what a press on its heading is after. */ export declare function cycleSort(current: SortState | null, key: string, first?: SortDir): SortState | null; /** A sorted copy, or `items` unchanged when nothing is sorted. `localeCompare`, since `<` orders by code * point and puts accented letters after the whole alphabet. */ export declare function sortBy(items: T[], sort: SortState | null, getValue: (item: T, key: string) => string | number): T[]; /** Screen-reader fragments; omitted fields keep English. */ export interface SortHeaderLabels { /** Default `(label) => `Sort by ${label}``. */ sortBy?: (label: string) => string; /** Default ", ascending". */ ascending?: string; /** Default ", descending". */ descending?: string; /** `SortMenu`'s words, and what it reads while the rows keep their own order. Default "Sort". */ sort?: string; } export interface SortHeaderProps extends StyleProps { label: string; sortKey: string; sort: SortState | null; onSort: (key: string) => void; /** Numeric columns; the arrow sits left of the label. */ align?: "left" | "right"; labels?: SortHeaderLabels; testID?: string; ref?: React.Ref; render?: Base.Props["render"]; } export interface SortMenuField { key: string; label: string; } export interface SortMenuProps extends StyleProps { /** Every field the rows order by, as their headers would offer them. */ fields: readonly SortMenuField[]; sort: SortState | null; /** `sort` is the rows' own order, none chosen: said in the chip's resting ink, with no ✕, which returns to it. */ resting?: boolean; /** A field pressed — the same press as its header's, so pair it with `cycleSort` the same way. */ onSort: (key: string) => void; /** Back to the rows' own order. */ onClear: () => void; labels?: SortHeaderLabels; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** * THE ROWS' ORDER WHERE NO HEADER OFFERS IT — a chip in the Filters dialog naming the field and its direction, * its list every field the rows order by. A press is its header's press, so the chosen field pressed again turns * the other way and a third time lets go; its ✕ is the rows' own order. For rows with no header row (cards, a * calendar) and a phone, whose header seats two columns. */ export declare function SortMenu(props: SortMenuProps): React.JSX.Element; /** Press cycles via `cycleSort`; the parent orders with `sortBy`. */ export declare function SortHeader(props: SortHeaderProps): React.JSX.Element;