import { ColumnDefinition } from './ColumnDefinition'; import { GridLength, type GridLengthInput } from './GridLength'; /** * Describes the object form of a single column definition input. * * The `width` property is required and accepts any `GridLengthInput` * shorthand or a `GridLength` instance. The optional `minWidth` and * `maxWidth` constrain the resolved track width in pixels/DIPs. * * @example * ```ts * const col: IColumnDefinitionInput = { * width: '2*', * minWidth: 80, * maxWidth: 240, * }; * ``` * * @public */ export interface IColumnDefinitionInput { /** * The width specification for this column. * * Accepts a `GridLengthInput` shorthand (`number`, `'auto'`, * `'*'`, `` `${number}*` ``) or a `GridLength` instance. * * @public */ width: GridLengthInput | GridLength; /** * The minimum width of this column in pixels/DIPs. * Must be non-negative. Defaults to `0` when omitted. * * @public */ minWidth?: number; /** * The maximum width of this column in pixels/DIPs. * Must be non-negative and `≥ minWidth`. * Defaults to `Number.MAX_SAFE_INTEGER` when omitted. * * @public */ maxWidth?: number; } /** * Accepted input for a single column track. * * | Form | Example | Meaning | * |-----------------------------|--------------------------------------------------|------------------------------------------| * | `number` | `120` | Fixed width in pixels/DIPs. | * | `'auto'` | `'auto'` | Content-based sizing. | * | `'*'` / `` `${number}*` `` | `'*'`, `'2*'`, `'0.5*'` | Star (proportional) sizing. | * | object | `{ width: '2*', minWidth: 80, maxWidth: 240 }` | Full definition with optional min/max. | * * Bare `string` is **not** accepted - only the exact literal forms listed * above pass compile-time validation. * * @public */ export type ColumnDefinitionInput = GridLengthInput | IColumnDefinitionInput; /** * A space-separated string of `GridLengthInput` tokens that can be * used as an HTML attribute value to define column tracks. * * Each token must be one of: * - A non-negative number (pixels/DIPs), e.g. `"120"` * - `"auto"` for content-based sizing * - `"*"` or `"n*"` for star (proportional) sizing, e.g. `"2*"` * * Tokens are separated by whitespace. * * @example * ```html * * ``` * * @public */ export type ColumnDefinitionsString = string & { readonly __brand?: 'ColumnDefinitionsString'; }; /** * Column track definitions for a grid layout. * * Accepts either an array of `ColumnDefinitionInput` entries (for * programmatic / Lit property binding usage) or a space-separated * `ColumnDefinitionsString` (for plain HTML attribute usage). * * The array length (or number of tokens) determines the number of * columns; each entry defines the sizing of the corresponding column * track. * * @example * Array form (JavaScript / Lit property binding): * ```ts * const columns: ColumnDefinitions = [ * 'auto', // content-sized * '*', // 1 star (proportional) * '2*', // 2 stars (proportional) * 120, // 120 px fixed * { width: '0.5*', minWidth: 80, maxWidth: 240 } * ]; * ``` * * @example * String form (HTML attribute): * ```html * * ``` * * @public */ export type ColumnDefinitions = Array | ColumnDefinitionsString; /** * @public */ export declare namespace ColumnDefinitions { /** * Parses a `ColumnDefinitions` value (array or space-separated * string) into validated `ColumnDefinition` instances. * * When `self` is a `string`, it is first split on whitespace into * individual tokens, each of which must be a valid * `GridLengthInput` literal (`number`, `'auto'`, `'*'`, * `` `${number}*` ``). * * When `self` is an array, each element is validated strictly: * - Numbers must be non-negative (absolute pixel sizing). * - String literals are parsed via `parseGridLength`. * - Object entries must carry a valid `width` and optional * non-negative `minWidth` / `maxWidth` where `minWidth ≤ maxWidth`. * * @public * @param self The raw definitions to parse. * @returns An array of fully validated `ColumnDefinition` instances. * @throws {Error} If any entry is invalid. */ function parse(self: ColumnDefinitions): Array; /** * Parses a space-separated string of grid-length tokens into an * array of `ColumnDefinitionInput` values. * * Each whitespace-delimited token is interpreted as a * `GridLengthInput`: a non-negative number (pixels), `"auto"`, * `"*"`, or `"n*"` (star sizing). * * @example * ```ts * ColumnDefinitions.fromString('* 2* auto 120'); * // → ['*', '2*', 'auto', 120] * ``` * * @public * @param value The space-separated definition string. * @returns An array of parsed `ColumnDefinitionInput` values. * @throws {Error} If the string is empty or any token is invalid. */ function fromString(value: ColumnDefinitionsString): Array; /** * Serializes a `ColumnDefinitions` value into a space-separated * string suitable for use as an HTML attribute value. * * Each entry is converted to its shortest `GridLength` string * representation via `GridLength.toString`. Object entries * (with `minWidth`/`maxWidth`) are serialized using their `width` * component only, as min/max constraints cannot be expressed in the * string format. * * @example * ```ts * ColumnDefinitions.toString(['*', '2*', 'auto', 120]); * // → '* 2* auto 120' * ``` * * @public * @param self The definitions to serialize. * @returns A space-separated string representation. */ function toString(self: ColumnDefinitions): ColumnDefinitionsString; } //# sourceMappingURL=ColumnDefinitions.d.ts.map