import { type TemplateResult } from 'lit'; import type ApexGridCell from '../components/cell.js'; import type ApexGridRow from '../components/row.js'; import type { ColumnConfiguration } from './types.js'; /** * An option entry for a `'select'` column. May be either a bare value (the * displayed label is `String(value)`) or an explicit `{ value, label }` pair. */ export type SelectOption = V | { value: V; label?: string; }; /** * The flat, non-distributive cell context handed to a column-type renderer's * `display` function. Mirrors {@link ApexCellContext} but uses `unknown` for * `value` so renderers can author against a single shape without * conditional-type narrowing in generic positions. */ export interface ColumnTypeCellContext { parent: ApexGridCell; row: ApexGridRow; column: ColumnConfiguration; value: unknown; /** * Commits a new value for this cell without entering edit mode. Only * present when the column is editable. Used by interactive display * widgets like the boolean checkbox. */ commit?(value: unknown): Promise; } /** * Cell context handed to a column-type renderer's `editor` function. Adds the * `commit` / `cancel` helpers wired through {@link EditingController}. */ export interface ColumnTypeEditorContext extends ColumnTypeCellContext { commit(value: unknown): Promise; cancel(): void; } /** * Built-in column-type renderer contract. A renderer can supply either a * display template, an editor template, or both. Cells fall back to the * column's `cellTemplate` / `editorTemplate` / built-in primitive editor if * the renderer is absent. */ export interface ColumnTypeRenderer { /** * Renders the display (read-only) representation of the cell. * * @remarks * Called when the cell is not in edit mode and the column has no * `cellTemplate`. Return any lit-renderable value. */ display?(ctx: ColumnTypeCellContext): TemplateResult | unknown; /** * Renders the inline editor while the cell is in edit mode. * * @remarks * Called when the cell is in edit mode and the column has no * `editorTemplate`. The returned template SHOULD include `data-apex-editor` * on its focusable element so the cell auto-focuses it. The editor is * responsible for calling `ctx.commit(value)` / `ctx.cancel()`. */ editor?(ctx: ColumnTypeEditorContext): TemplateResult | unknown; } interface NormalizedSelectOption { value: unknown; label: string; } /** * Normalizes a column's `options` configuration into a uniform * `{ value, label }[]` list. Accepts both bare-value entries and explicit * `{ value, label }` pairs. */ export declare function getSelectOptions(column: { options?: SelectOption[]; }): NormalizedSelectOption[]; /** * Parses a stored cell value into a `Date`, or `null` when the value can't be * resolved to a real date. * * @remarks * Accepts `Date` instances, ISO/parseable strings, and millisecond * timestamps. `YYYY-MM-DD` strings are interpreted as **floating dates** * (local midnight) rather than UTC midnight, so they render on the same * calendar day in every timezone. */ export declare function parseDate(value: unknown): Date | null; /** * Returns the built-in renderer for a column `type`, or `undefined` when the * type has no built-in display/editor (the cell falls back to plain text / * the primitive editor in that case). */ export declare function getColumnTypeRenderer(type?: string): ColumnTypeRenderer | undefined; export {};