import { FunctionalComponent, VNode } from '../../stencil-public-runtime'; /** * The lookup table: the design language's table (§ 15 strip, § 18 rows, § 22 layouts) taken out of * `vehicle-ssc` and made reusable. A pure functional component with no state, no timers and no * memory; the panel that owns it runs the choreography (retainedBody, the leave, the reshape) and * hands it flags. * * It is a function and not an element because the strip's headings and the body's rows must be * `subgrid`s of one grid, inside the panel's own shadow root, between the panel's head and its * body. The stylesheet is `lookup-table.css`, a fragment that the panel `@import`s. * * What it never does: decide a verdict, pick a notice, or read meaning off an empty list. The panel * says what the strip shows (`lead`, `notice`) and what the body holds (`body`, `open`). */ /** Built kinds. 'chip' | 'action' are specified and deferred to a named consumer. `date` and `number` show `value()` as given: the table never formats. */ export type CellKind = 'text' | 'code' | 'media' | 'date' | 'number'; export type NoticeTone = 'positive' | 'negative' | 'neutral' | 'attention' | 'idle'; /** * What the strip shows. The column headings are a fixed structure (they depend on `hiddenFields` * only, never on the data), so they are there before the answer is known; only an outcome that has * no rows to head replaces them with its notice. There is no skeleton: a skeleton would stand for a * shape that is not in doubt (owner, F1, 2026-10-18). */ export type LeadKind = 'columns' | 'notice'; export type LookupColumn = { /** The hiddenFields name and the column's stable key: 'partNumber', 'description', ... */ field: string; /** Heading in the strip and caption on the narrow card (data-label). Already localised. */ label: string; kind: CellKind; /** The cell's value; for 'media' the image URL. null, undefined, '' or whitespace is blank. */ value: (row: Row) => string | number | null | undefined; /** The row's name: Code type, uncaptioned on a card, first in the stacked layout. At most one. */ identity?: boolean; /** The one column that absorbs the slack (§ 18). At most one, and only on a 'text' column. */ grow?: boolean; /** A small grey chip after the value, e.g. "Centre". Only beside a value, never in place of one. */ note?: (row: Row) => string | null | undefined; }; export type LookupTableStrings = { /** The strip's one word at 720px and under, e.g. "Accessory list". */ columnsLabel: string; /** Media cell, no URL on record. */ noImage: string; /** Media cell, the URL did not load. */ imageFailed: string; /** The media button's label, followed by the row's identity value. */ openImage: string; }; export type PlaceholderKind = 'idle' | 'empty' | 'error' | 'unauthorized'; export type IconComponent = FunctionalComponent<{ class?: string; }>; export type PlaceholderContent = { icon: IconComponent; text: string; }; /** The body's own words for an outcome with no rows, under the headings, instead of the strip's notice. */ export type TablePlaceholder = { kind: PlaceholderKind | null; retained?: PlaceholderKind | null; content: Record; }; export type LookupTableProps = { /** Already filtered: pass `visibleColumns(all, hidden)`. */ columns: LookupColumn[]; rows: Row[]; rowKey: (row: Row, index: number) => string; /** The panel's own lead (`tableLead(...)`, or a wrapper of it for a panel with more states). */ lead: LeadKind; notice: { tone: NoticeTone; text: string; } | null; /** `data-phase="busy"`: a lookup is in flight. The strip does not change for it (the headings stay); the attribute is a state hook for the panel's own rules. */ busy: boolean; /** What the body shows: 'rows', or the panel's own kind (rendered from `children`). */ body: string; /** The body's `data-open`. */ open: boolean; /** A live column change is in progress: headings fade, roles go (§ 5.3). */ reshaping?: boolean; strings: LookupTableStrings; /** The owner's `openImageViewer`; the table only reports which image was asked for. */ onOpenMedia?: (image: HTMLImageElement, src: string) => void; /** * One entry per row in `rows`: whether the row's slot is open and how its values are veiled. * Omitted, every row is open and unveiled. A panel that keeps its rows on screen through a lookup * (owner, 2026-10-25) passes `tableSlots(...)` and keys its rows by slot, so a row is a place that * stays while its values change under a cover, and only the rows that come or go slide. */ slots?: RowSlot[]; /** A drawer under each row, one open at a time; the panel owns which and its timers. */ drawer?: LookupDrawer; placeholder?: TablePlaceholder; }; export type LookupDrawer = { /** The one open row, keyed like `rowKey`. */ openKey: string | null; /** The row whose drawer is shutting: its content stays rendered until the panel drops it. */ retainedKey?: string | null; /** The drawer's content, the panel's own. */ render: (row: Row, key: string) => VNode | VNode[]; /** The toggle's `.sr-only` column heading. Already localised. */ label: string; /** The toggle's aria-label and title. Already localised. */ toggleLabel: (row: Row, open: boolean) => string; onToggle: (key: string) => void; /** Rows that have a drawer; the others get no toggle and no row click. Omitted, every row has one. */ has?: (row: Row) => boolean; /** The toggle as a labelled button (the icon, `text` and a chevron) under a visible heading, in place of the 30px round one; a row with no drawer shows `text` plain. */ labelled?: { text: (row: Row) => string; icon: IconComponent; }; /** The toggle opens a dialog elsewhere (a sheet on a phone) and not the drawer: the row whose dialog is open. */ dialog?: { openKey: string | null; }; /** Names the drawer's panel as a region. Already localised. */ regionLabel?: (row: Row) => string; /** For a panel that keeps a drawer open through a lookup: its content goes under the row's skeleton, and the drawer, its toggle and the row click are inert while covered. */ cover?: boolean; }; /** * How a row's values are veiled. `cover`: the skeleton is over them (a lookup is in flight, or the * row is leaving after one); `fade`: they are faded out (a page is changing, nothing is fetched); * `none`: they are read. */ export type RowVeil = 'none' | 'cover' | 'fade'; export type RowSlot = { open: boolean; veil: RowVeil; }; /** * The slots for `current` rows followed by `outgoing` ones (rows the body held before and no longer * does, rendered after the current ones so they can leave where they stood). * * - The current rows' first `opened` slots are open; the rest are new and start shut, and the owner * raises `opened` a frame later so they slide open rather than appear. * - Outgoing rows shut on their own while the body stays open. When the body itself shuts (the * outcome has no rows), they stay open inside it, so the region leaves as one movement and not * one inside another. */ export declare const tableSlots: ({ current, outgoing, opened, bodyOpen, currentVeil, outgoingVeil, }: { current: number; outgoing: number; opened: number; bodyOpen: boolean; currentVeil: RowVeil; outgoingVeil: RowVeil; }) => RowSlot[]; /** Comma-separated field names, trimmed, empty names dropped. Moved here from the sale panel. */ export declare const parseHiddenFields: (raw?: string) => Set; /** Definition order kept; a hidden field removes its column entirely; unknown names are ignored. */ export declare const visibleColumns: (columns: LookupColumn[], hidden: ReadonlySet) => LookupColumn[]; /** * The `grid-template-columns` strings. `stacked` is the 720–960 layout, where the description sits * under its code: it exists only when the first visible column is the identity and a different, * growing column is visible. Otherwise it is null and the wide layout simply continues. */ export declare const tableTracks: (columns: LookupColumn[], drawer?: boolean | "labelled") => { wide: string; stacked: string | null; }; /** null for null, undefined, '' or whitespace, else `String(value)`. **0 is a value**: a "no value" zero is mapped to null upstream, never guessed here. */ export declare const cellText: (column: LookupColumn, row: Row) => string | null; /** The table roles exist only while there is a table to land in: the body is rows, open, and not reshaping (§ 8). */ export declare const tableRoles: (body: string, open: boolean, reshaping: boolean) => boolean; /** * The strip shows the headings whenever there is something to head: idle, in flight, and above rows * (they depend on the configuration alone, so the answer cannot change them). It shows a notice * only for an outcome that has no rows (authorized and empty, unauthorized, a failed lookup, a * panel's own body) and when every column is hidden, where there are no headings to show. A panel * whose body says that outcome in words (`placeholder: true`) keeps its headings. § 20's * `panelLead`, generalised, with the skeleton leg removed. */ export declare const tableLead: ({ busy, idle, body, columns, placeholder }: { busy: boolean; idle: boolean; body: string; columns: number; placeholder?: boolean; }) => LeadKind; /** What the body renders: it keeps its outgoing kind while it shuts, so the content slides away instead of blinking out. */ export declare const shownBody: (body: string, retained: string) => string; export declare const placeholderKind: ({ columns, loaded, failed, authorized, records, leaving, }: { columns: number; loaded: boolean; failed: boolean; authorized?: boolean; records: number; leaving?: boolean; }) => PlaceholderKind | null; export declare function LookupTable(props: LookupTableProps, children?: VNode[]): VNode;