/** * The **Workbook Mapper** — the pipeline stage that turns a validated * {@link WorkbookSheet} into grid-ready artifacts: inferred column definitions * and typed row-data objects. * * Responsibilities: * - resolve the header row (or synthesize `Column N` headers); * - synthesize a safe, unique `field` per column ({@link ColumnMapper}); * - infer each column's {@link ColumnDataType} ({@link TypeDetector}); * - coerce every literal cell to its column's type once, up front, so the grid * never re-parses on render; * - **preserve formulas verbatim** — a `=`-prefixed cell keeps its raw source * string as the field value and flips the column's `allowFormula`, so the * grid's existing `setData → FormulaInitializer` path registers and computes * it through the one Formula Engine (the importer never evaluates anything). * * The mapper is pure and has no grid/DOM dependency. * * @packageDocumentation */ import type { ColumnDefInput } from '../../../types/column.types'; import type { WorkbookSheet } from '../model/workbook'; /** Options for {@link WorkbookMapper.mapSheet}. */ export interface WorkbookMapOptions { /** Whether the first row is a header row. */ readonly hasHeaderRow: boolean; /** Max cells sampled per column for type detection. */ readonly sampleSize?: number; } /** The grid-ready product of mapping one sheet. */ export interface MappedWorkbook { /** Inferred column definitions (type-sniffed; `allowFormula` set where formulas exist). */ readonly columns: ColumnDefInput[]; /** Row-data objects keyed by column `field`. Formula cells keep their raw `=…` source. */ readonly rows: Record[]; /** Resolved headers in column order. */ readonly headers: string[]; /** Synthesized fields, parallel to {@link headers}. */ readonly fields: string[]; /** Count of cells carrying a `=`-prefixed formula. */ readonly formulaCount: number; } /** Stateless Workbook → grid transformation. */ export declare class WorkbookMapper { /** * Maps a single sheet into columns + typed rows. * * @param sheet - The validated sheet to map. * @param options - Mapping options. * @returns The grid-ready artifacts. */ static mapSheet(sheet: WorkbookSheet, options: WorkbookMapOptions): MappedWorkbook; /** Resolves the header row, padding/synthesizing to `width` columns. */ private static resolveHeaders; /** * Coerces a raw literal cell value to its column's type. Currency/percentage/ * number strings are stripped of symbols, separators and `%` before parsing; * dates become ISO strings; booleans accept `true/false/yes/no/1/0`. * * @param raw - The raw cell value. * @param type - The inferred column type. * @returns The typed value (or `null` for blanks / unparseable numerics). */ private static coerce; } //# sourceMappingURL=workbook-mapper.d.ts.map