@molecule/app-spreadsheet-grid-solid 0.0.0-stage → 0.0.1-stage

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * High-performance virtualized spreadsheet cell grid for Solid.
3
+ *
4
+ * Exports:
5
+ * - `<SpreadsheetGrid>` — the grid component (virtualized cells, frozen
6
+ * rows/columns, range selection, copy/paste as TSV, in-cell editing).
7
+ * - Types: `SpreadsheetGridProps`, `SpreadsheetSelection`, `CellMap`,
8
+ * `CellRef`, `CellValue`.
9
+ * - Helpers: `cellRef()`, `columnLetter()`, `normalizeSelection()`,
10
+ * `isInSelection()`, `formatCellValue()`, `parseClipboardTsv()`,
11
+ * `serializeSelectionTsv()`, `computeVisibleRange()`.
12
+ *
13
+ * Pairs with `@molecule/api-formula-engine` for formula evaluation —
14
+ * pass evaluated `cells` plus an optional `renderCell` to display
15
+ * formula results.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import { createSignal } from 'solid-js'
20
+ *
21
+ * import { SpreadsheetGrid, type CellMap, type SpreadsheetSelection } from '@molecule/app-spreadsheet-grid-solid'
22
+ *
23
+ * export function Sheet() {
24
+ * const [cells, setCells] = createSignal<CellMap>(new Map())
25
+ * const [selection, setSelection] = createSignal<SpreadsheetSelection>({
26
+ * r1: 0,
27
+ * c1: 0,
28
+ * r2: 0,
29
+ * c2: 0,
30
+ * })
31
+ * return (
32
+ * <SpreadsheetGrid
33
+ * rows={1000}
34
+ * columns={26}
35
+ * cells={cells()}
36
+ * selection={selection()}
37
+ * frozenRows={1}
38
+ * frozenCols={1}
39
+ * onCellChange={(ref, value) => {
40
+ * const next = new Map(cells())
41
+ * if (value === null) next.delete(ref)
42
+ * else next.set(ref, value)
43
+ * setCells(next)
44
+ * }}
45
+ * onSelectionChange={(next) => setSelection(next)}
46
+ * />
47
+ * )
48
+ * }
49
+ * ```
50
+ *
51
+ * @remarks
52
+ * - Must render with a ClassMap bond wired (`getClassMap()` throws
53
+ * otherwise), and inside the app's i18n provider (or with the bonded one).
54
+ * - The viewport is FIXED-PIXEL: `viewportWidth`/`viewportHeight`
55
+ * (defaults 720×360) — the grid does not auto-size to its container.
56
+ * Measure the container and pass px if you need it to fill.
57
+ * - Copy (Ctrl/Cmd+C) writes TSV through `copyTextWithFallback()` from
58
+ * `@molecule/app-clipboard`, which uses the bonded clipboard provider with
59
+ * a selection-and-copy fallback and never throws. Paste is handled through
60
+ * the native paste event, so the grid container must have focus (click a
61
+ * cell first). Keyboard support is Enter/F2 (edit) + copy/paste only; there
62
+ * is NO arrow-key cell navigation.
63
+ * - Committed edits and pasted cells auto-coerce number-like strings to
64
+ * numbers (`'42'` → `42`); empty string clears the cell (`null`).
65
+ * - Gridlines/selection/header styling uses Material-3 design-token
66
+ * utilities (`bg-surface`, `border-outline-variant`, …). Apps whose
67
+ * Tailwind theme does not define those tokens (the minimal scaffold
68
+ * theme does not) get a functional but unstyled grid.
69
+ *
70
+ * @module
71
+ */
72
+ export * from './SpreadsheetGrid.jsx';
73
+ export * from './types.js';
74
+ export * from './utilities.js';
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,75 @@
1
+ /**
2
+ * High-performance virtualized spreadsheet cell grid for Solid.
3
+ *
4
+ * Exports:
5
+ * - `<SpreadsheetGrid>` — the grid component (virtualized cells, frozen
6
+ * rows/columns, range selection, copy/paste as TSV, in-cell editing).
7
+ * - Types: `SpreadsheetGridProps`, `SpreadsheetSelection`, `CellMap`,
8
+ * `CellRef`, `CellValue`.
9
+ * - Helpers: `cellRef()`, `columnLetter()`, `normalizeSelection()`,
10
+ * `isInSelection()`, `formatCellValue()`, `parseClipboardTsv()`,
11
+ * `serializeSelectionTsv()`, `computeVisibleRange()`.
12
+ *
13
+ * Pairs with `@molecule/api-formula-engine` for formula evaluation —
14
+ * pass evaluated `cells` plus an optional `renderCell` to display
15
+ * formula results.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import { createSignal } from 'solid-js'
20
+ *
21
+ * import { SpreadsheetGrid, type CellMap, type SpreadsheetSelection } from '@molecule/app-spreadsheet-grid-solid'
22
+ *
23
+ * export function Sheet() {
24
+ * const [cells, setCells] = createSignal<CellMap>(new Map())
25
+ * const [selection, setSelection] = createSignal<SpreadsheetSelection>({
26
+ * r1: 0,
27
+ * c1: 0,
28
+ * r2: 0,
29
+ * c2: 0,
30
+ * })
31
+ * return (
32
+ * <SpreadsheetGrid
33
+ * rows={1000}
34
+ * columns={26}
35
+ * cells={cells()}
36
+ * selection={selection()}
37
+ * frozenRows={1}
38
+ * frozenCols={1}
39
+ * onCellChange={(ref, value) => {
40
+ * const next = new Map(cells())
41
+ * if (value === null) next.delete(ref)
42
+ * else next.set(ref, value)
43
+ * setCells(next)
44
+ * }}
45
+ * onSelectionChange={(next) => setSelection(next)}
46
+ * />
47
+ * )
48
+ * }
49
+ * ```
50
+ *
51
+ * @remarks
52
+ * - Must render with a ClassMap bond wired (`getClassMap()` throws
53
+ * otherwise), and inside the app's i18n provider (or with the bonded one).
54
+ * - The viewport is FIXED-PIXEL: `viewportWidth`/`viewportHeight`
55
+ * (defaults 720×360) — the grid does not auto-size to its container.
56
+ * Measure the container and pass px if you need it to fill.
57
+ * - Copy (Ctrl/Cmd+C) writes TSV through `copyTextWithFallback()` from
58
+ * `@molecule/app-clipboard`, which uses the bonded clipboard provider with
59
+ * a selection-and-copy fallback and never throws. Paste is handled through
60
+ * the native paste event, so the grid container must have focus (click a
61
+ * cell first). Keyboard support is Enter/F2 (edit) + copy/paste only; there
62
+ * is NO arrow-key cell navigation.
63
+ * - Committed edits and pasted cells auto-coerce number-like strings to
64
+ * numbers (`'42'` → `42`); empty string clears the cell (`null`).
65
+ * - Gridlines/selection/header styling uses Material-3 design-token
66
+ * utilities (`bg-surface`, `border-outline-variant`, …). Apps whose
67
+ * Tailwind theme does not define those tokens (the minimal scaffold
68
+ * theme does not) get a functional but unstyled grid.
69
+ *
70
+ * @module
71
+ */
72
+ export * from './SpreadsheetGrid.jsx';
73
+ export * from './types.js';
74
+ export * from './utilities.js';
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Geometry, ClassMap classes and inline-style strings for `<SpreadsheetGrid>`.
3
+ *
4
+ * The plan is framework-neutral: every framework's port computes the same one
5
+ * from the same props and state, so the rendered DOM (positions, classes,
6
+ * indices, text) cannot drift between frameworks.
7
+ *
8
+ * @module
9
+ */
10
+ import type { UIClassMap } from '@molecule/app-ui';
11
+ import type { CellMap, CellRef, CellValue, SpreadsheetSelection } from './types.js';
12
+ /** The open in-cell editor. */
13
+ export interface GridEditing {
14
+ /** 0-indexed row of the edited cell. */
15
+ row: number;
16
+ /** 0-indexed column of the edited cell. */
17
+ col: number;
18
+ /** The draft text the editor shows. */
19
+ draft: string;
20
+ }
21
+ /** Everything the plan is computed from. */
22
+ export interface GridGeometry {
23
+ /** Total number of rows. */
24
+ rows: number;
25
+ /** Total number of columns. */
26
+ columns: number;
27
+ /** Sparse cell data. */
28
+ cells: CellMap;
29
+ /** Current selection. */
30
+ selection: SpreadsheetSelection;
31
+ /** Rows frozen at the top. */
32
+ frozenRows: number;
33
+ /** Columns frozen on the left. */
34
+ frozenCols: number;
35
+ /** Per-cell width in pixels. */
36
+ cellWidth: number;
37
+ /** Per-cell height in pixels. */
38
+ cellHeight: number;
39
+ /** Width of the row-number gutter. */
40
+ gutterWidth: number;
41
+ /** Height of the column-letter header. */
42
+ headerHeight: number;
43
+ /** Visible viewport width. */
44
+ viewportWidth: number;
45
+ /** Visible viewport height. */
46
+ viewportHeight: number;
47
+ /** Horizontal scroll offset of the scrollable region. */
48
+ scrollLeft: number;
49
+ /** Vertical scroll offset of the scrollable region. */
50
+ scrollTop: number;
51
+ /** The open editor, or `null`. */
52
+ editing: GridEditing | null;
53
+ }
54
+ /** One column-letter or row-number label. */
55
+ export interface GridHeaderCell {
56
+ /** A stable key for the label. */
57
+ key: string;
58
+ /** The 0-indexed column (headers) or row (gutter). */
59
+ index: number;
60
+ /** The label text (`A`, `12`). */
61
+ text: string;
62
+ /** Its inline style. */
63
+ style: string;
64
+ /** Its ClassMap classes. */
65
+ classes: string;
66
+ }
67
+ /** One rendered cell, positioned for the region it renders in. */
68
+ export interface GridCell {
69
+ /** 0-indexed row. */
70
+ row: number;
71
+ /** 0-indexed column. */
72
+ col: number;
73
+ /** A1 reference. */
74
+ ref: CellRef;
75
+ /** The raw cell value. */
76
+ value: CellValue | undefined;
77
+ /** The value's display string (React's `formatCellValue`). */
78
+ text: string;
79
+ /** Its inline style for its region. */
80
+ style: string;
81
+ /** Its ClassMap classes. */
82
+ classes: string;
83
+ /** Whether the cell lies inside the selection. */
84
+ selected: boolean;
85
+ /** Whether it is the selection anchor (the cell in the tab order). */
86
+ anchor: boolean;
87
+ }
88
+ /** The plan one render of the grid is built from. */
89
+ export interface GridLayout {
90
+ /** The root `<div role="grid">`. */
91
+ rootClasses: string;
92
+ /** Its inline style. */
93
+ rootStyle: string;
94
+ /** The top-left corner. */
95
+ cornerClasses: string;
96
+ /** Its inline style. */
97
+ cornerStyle: string;
98
+ /** The column-letter header lane. */
99
+ headerLaneClasses: string;
100
+ /** Its inline style. */
101
+ headerLaneStyle: string;
102
+ /** The scrolling column-letter container's inline style. */
103
+ headerScrollerStyle: string;
104
+ /** The letters of the frozen columns. */
105
+ frozenHeaderCells: GridHeaderCell[];
106
+ /** The letters of the scrolling columns. */
107
+ scrollingHeaderCells: GridHeaderCell[];
108
+ /** The row-number gutter lane. */
109
+ gutterLaneClasses: string;
110
+ /** Its inline style. */
111
+ gutterLaneStyle: string;
112
+ /** The scrolling row-number container's inline style. */
113
+ gutterScrollerStyle: string;
114
+ /** The numbers of the frozen rows. */
115
+ frozenGutterCells: GridHeaderCell[];
116
+ /** The numbers of the scrolling rows. */
117
+ scrollingGutterCells: GridHeaderCell[];
118
+ /** Whether the frozen-rows region renders. */
119
+ showFrozenRows: boolean;
120
+ /** Whether the frozen-cols region renders. */
121
+ showFrozenCols: boolean;
122
+ /** Whether the frozen-rows × frozen-cols corner renders. */
123
+ showFrozenCorner: boolean;
124
+ /** The frozen-rows region's inline style. */
125
+ frozenRowsRegionStyle: string;
126
+ /** Its inner (scrolling) container's inline style. */
127
+ frozenRowsInnerStyle: string;
128
+ /** The frozen-cols region's inline style. */
129
+ frozenColsRegionStyle: string;
130
+ /** Its inner (scrolling) container's inline style. */
131
+ frozenColsInnerStyle: string;
132
+ /** The frozen corner's inline style. */
133
+ frozenCornerStyle: string;
134
+ /** Cells of the frozen-rows × scrolling-cols region. */
135
+ frozenRowsCells: GridCell[];
136
+ /** Cells of the frozen-cols × scrolling-rows region. */
137
+ frozenColsCells: GridCell[];
138
+ /** Cells of the frozen-rows × frozen-cols corner. */
139
+ frozenCornerCells: GridCell[];
140
+ /** Cells of the main scrollable region. */
141
+ mainCells: GridCell[];
142
+ /** Every rendered cell, by A1 reference (a region's cells are disjoint from the others'). */
143
+ byRef: Map<string, GridCell>;
144
+ /** The scroll region's inline style. */
145
+ scrollRegionStyle: string;
146
+ /** The scroll spacer's inline style. */
147
+ scrollSpacerStyle: string;
148
+ /** The hidden total-size hint's classes. */
149
+ totalClasses: string;
150
+ /** Its inline style. */
151
+ totalStyle: string;
152
+ /** Its text (`720×360`). */
153
+ totalText: string;
154
+ /** The in-cell editor input's classes. */
155
+ editorClasses: string;
156
+ /** The cell content wrapper's classes. */
157
+ contentClasses: string;
158
+ }
159
+ /**
160
+ * Computes one render's plan from the grid's geometry and state.
161
+ *
162
+ * @param geometry - The grid geometry.
163
+ * @param cm - The bonded ClassMap.
164
+ * @returns The layout plan.
165
+ */
166
+ export declare function computeLayout(geometry: GridGeometry, cm: UIClassMap): GridLayout;
167
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AASnF,+BAA+B;AAC/B,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,yBAAyB;IACzB,SAAS,EAAE,oBAAoB,CAAA;IAC/B,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAA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iBAAiB,EAAE,MAAM,CAAA;IACzB,wCAAwC;IACxC,iBAAiB,EAAE,MAAM,CAAA;IACzB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAA;IACpB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAA;IACrB,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAA;CACvB;AA0ED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU,CAgMhF"}
package/dist/layout.js ADDED
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Geometry, ClassMap classes and inline-style strings for `<SpreadsheetGrid>`.
3
+ *
4
+ * The plan is framework-neutral: every framework's port computes the same one
5
+ * from the same props and state, so the rendered DOM (positions, classes,
6
+ * indices, text) cannot drift between frameworks.
7
+ *
8
+ * @module
9
+ */
10
+ import { cellRef, columnLetter, computeVisibleRange, formatCellValue, isInSelection, } from './utilities.js';
11
+ /**
12
+ * A pixel length, as React writes one.
13
+ *
14
+ * @param value - A length in pixels.
15
+ * @returns The CSS length (`28px`).
16
+ */
17
+ const px = (value) => `${value}px`;
18
+ /**
19
+ * Whether a cell is the selection anchor.
20
+ *
21
+ * @param selection - The selection.
22
+ * @param row - The cell's 0-indexed row.
23
+ * @param col - The cell's 0-indexed column.
24
+ * @returns `true` when the cell is the anchor.
25
+ */
26
+ const isAnchor = (selection, row, col) => selection.r1 === row && selection.c1 === col;
27
+ /**
28
+ * Builds the cell box style of one region.
29
+ *
30
+ * @param geometry - The grid geometry.
31
+ * @param left - The cell's left offset in pixels.
32
+ * @param top - The cell's top offset in pixels.
33
+ * @returns The inline style.
34
+ */
35
+ const cellBoxStyle = (geometry, left, top) => `position: absolute; left: ${px(left)}; top: ${px(top)}; width: ${px(geometry.cellWidth)}; height: ${px(geometry.cellHeight)}; box-sizing: border-box;`;
36
+ /**
37
+ * Describes one rendered cell.
38
+ *
39
+ * @param geometry - The grid geometry.
40
+ * @param cm - The ClassMap.
41
+ * @param row - The cell's 0-indexed row.
42
+ * @param col - The cell's 0-indexed column.
43
+ * @param left - Its left offset in pixels.
44
+ * @param top - Its top offset in pixels.
45
+ * @returns The cell.
46
+ */
47
+ const cellAt = (geometry, cm, row, col, left, top) => {
48
+ const ref = cellRef(row, col);
49
+ const selected = isInSelection(geometry.selection, row, col);
50
+ const anchor = isAnchor(geometry.selection, row, col);
51
+ const value = geometry.cells.get(ref);
52
+ return {
53
+ row,
54
+ col,
55
+ ref,
56
+ value,
57
+ text: formatCellValue(value),
58
+ style: cellBoxStyle(geometry, left, top),
59
+ classes: cm.cn(cm.spreadsheetGridCellBorder, selected ? cm.spreadsheetGridCellSelected : cm.surface, anchor ? cm.spreadsheetGridCellAnchor : ''),
60
+ selected,
61
+ anchor,
62
+ };
63
+ };
64
+ /**
65
+ * Computes one render's plan from the grid's geometry and state.
66
+ *
67
+ * @param geometry - The grid geometry.
68
+ * @param cm - The bonded ClassMap.
69
+ * @returns The layout plan.
70
+ */
71
+ export function computeLayout(geometry, cm) {
72
+ const { cellHeight, cellWidth, columns, frozenCols, frozenRows, gutterWidth, headerHeight } = geometry;
73
+ const frozenRowsHeight = frozenRows * cellHeight;
74
+ const frozenColsWidth = frozenCols * cellWidth;
75
+ const scrollableWidth = Math.max(0, geometry.viewportWidth - gutterWidth - frozenColsWidth);
76
+ const scrollableHeight = Math.max(0, geometry.viewportHeight - headerHeight - frozenRowsHeight);
77
+ const [colStart, colEnd] = computeVisibleRange(geometry.scrollLeft, scrollableWidth, cellWidth, Math.max(0, columns - frozenCols));
78
+ const [rowStart, rowEnd] = computeVisibleRange(geometry.scrollTop, scrollableHeight, cellHeight, Math.max(0, geometry.rows - frozenRows));
79
+ const visibleCols = [];
80
+ for (let c = frozenCols + colStart; c <= frozenCols + colEnd; c += 1) {
81
+ if (c >= columns)
82
+ break;
83
+ visibleCols.push(c);
84
+ }
85
+ const visibleRows = [];
86
+ for (let r = frozenRows + rowStart; r <= frozenRows + rowEnd; r += 1) {
87
+ if (r >= geometry.rows)
88
+ break;
89
+ visibleRows.push(r);
90
+ }
91
+ const frozenColumns = Array.from({ length: Math.min(frozenCols, columns) }, (_v, i) => i);
92
+ const frozenRowIndices = Array.from({ length: Math.min(frozenRows, geometry.rows) }, (_v, i) => i);
93
+ const totalScrollWidth = Math.max(0, columns - frozenCols) * cellWidth;
94
+ const totalScrollHeight = Math.max(0, geometry.rows - frozenRows) * cellHeight;
95
+ const totalGridWidth = gutterWidth + columns * cellWidth;
96
+ const totalGridHeight = headerHeight + geometry.rows * cellHeight;
97
+ const headerCellClasses = cm.cn(cm.spreadsheetGridHeaderCell, cm.textCenter, cm.textSize('xs'), cm.fontWeight('semibold'));
98
+ const headerCellStyle = (left) => `position: absolute; left: ${px(left)}; top: ${px(0)}; width: ${px(cellWidth)}; height: ${px(headerHeight)}; line-height: ${px(headerHeight)};`;
99
+ const gutterCellStyle = (top, width, height) => `position: absolute; left: ${px(0)}; top: ${px(top)}; width: ${px(width)}; height: ${px(height)}; line-height: ${px(height)};`;
100
+ const frozenRowsCells = [];
101
+ const frozenColsCells = [];
102
+ const frozenCornerCells = [];
103
+ const mainCells = [];
104
+ if (frozenRows > 0)
105
+ for (const row of frozenRowIndices)
106
+ for (const col of visibleCols)
107
+ frozenRowsCells.push(cellAt(geometry, cm, row, col, (col - frozenCols) * cellWidth, row * cellHeight));
108
+ if (frozenCols > 0)
109
+ for (const col of frozenColumns)
110
+ for (const row of visibleRows)
111
+ frozenColsCells.push(cellAt(geometry, cm, row, col, col * cellWidth, (row - frozenRows) * cellHeight));
112
+ if (frozenRows > 0 && frozenCols > 0)
113
+ for (const row of frozenRowIndices)
114
+ for (const col of frozenColumns)
115
+ frozenCornerCells.push(cellAt(geometry, cm, row, col, col * cellWidth, row * cellHeight));
116
+ for (const row of visibleRows)
117
+ for (const col of visibleCols)
118
+ mainCells.push(cellAt(geometry, cm, row, col, (col - frozenCols) * cellWidth, (row - frozenRows) * cellHeight));
119
+ return {
120
+ rootClasses: cm.cn(cm.spreadsheetGridRoot, cm.spreadsheetGridRootBorder),
121
+ rootStyle: `width: ${px(geometry.viewportWidth)}; height: ${px(geometry.viewportHeight)}; position: relative; overflow: hidden; outline: none;`,
122
+ cornerClasses: cm.spreadsheetGridCorner,
123
+ cornerStyle: `position: absolute; left: ${px(0)}; top: ${px(0)}; width: ${px(gutterWidth)}; height: ${px(headerHeight)};`,
124
+ headerLaneClasses: cm.spreadsheetGridLane,
125
+ headerLaneStyle: `position: absolute; left: ${px(gutterWidth)}; top: ${px(0)}; width: ${px(geometry.viewportWidth - gutterWidth)}; height: ${px(headerHeight)}; overflow: hidden;`,
126
+ headerScrollerStyle: `position: absolute; left: ${px(frozenColsWidth - geometry.scrollLeft)}; top: ${px(0)}; width: ${px(totalScrollWidth)}; height: ${px(headerHeight)};`,
127
+ frozenHeaderCells: frozenColumns.map((col) => ({
128
+ key: `hdr-frozen-${col}`,
129
+ index: col,
130
+ text: columnLetter(col),
131
+ style: headerCellStyle(col * cellWidth),
132
+ classes: headerCellClasses,
133
+ })),
134
+ scrollingHeaderCells: visibleCols.map((col) => ({
135
+ key: `hdr-${col}`,
136
+ index: col,
137
+ text: columnLetter(col),
138
+ style: headerCellStyle((col - frozenCols) * cellWidth),
139
+ classes: headerCellClasses,
140
+ })),
141
+ gutterLaneClasses: cm.spreadsheetGridLane,
142
+ gutterLaneStyle: `position: absolute; left: ${px(0)}; top: ${px(headerHeight)}; width: ${px(gutterWidth)}; height: ${px(geometry.viewportHeight - headerHeight)}; overflow: hidden;`,
143
+ gutterScrollerStyle: `position: absolute; left: ${px(0)}; top: ${px(frozenRowsHeight - geometry.scrollTop)}; width: ${px(gutterWidth)}; height: ${px(totalScrollHeight)};`,
144
+ frozenGutterCells: frozenRowIndices.map((row) => ({
145
+ key: `gutter-frozen-${row}`,
146
+ index: row,
147
+ text: String(row + 1),
148
+ style: gutterCellStyle(row * cellHeight, gutterWidth, cellHeight),
149
+ classes: headerCellClasses,
150
+ })),
151
+ scrollingGutterCells: visibleRows.map((row) => ({
152
+ key: `gutter-${row}`,
153
+ index: row,
154
+ text: String(row + 1),
155
+ style: gutterCellStyle((row - frozenRows) * cellHeight, gutterWidth, cellHeight),
156
+ classes: headerCellClasses,
157
+ })),
158
+ showFrozenRows: frozenRows > 0,
159
+ showFrozenCols: frozenCols > 0,
160
+ showFrozenCorner: frozenRows > 0 && frozenCols > 0,
161
+ frozenRowsRegionStyle: `position: absolute; left: ${px(gutterWidth + frozenColsWidth)}; top: ${px(headerHeight)}; width: ${px(scrollableWidth)}; height: ${px(frozenRowsHeight)}; overflow: hidden;`,
162
+ frozenRowsInnerStyle: `position: absolute; left: ${px(-geometry.scrollLeft)}; top: ${px(0)}; width: ${px(totalScrollWidth)}; height: ${px(frozenRowsHeight)};`,
163
+ frozenColsRegionStyle: `position: absolute; left: ${px(gutterWidth)}; top: ${px(headerHeight + frozenRowsHeight)}; width: ${px(frozenColsWidth)}; height: ${px(scrollableHeight)}; overflow: hidden;`,
164
+ frozenColsInnerStyle: `position: absolute; left: ${px(0)}; top: ${px(-geometry.scrollTop)}; width: ${px(frozenColsWidth)}; height: ${px(totalScrollHeight)};`,
165
+ frozenCornerStyle: `position: absolute; left: ${px(gutterWidth)}; top: ${px(headerHeight)}; width: ${px(frozenColsWidth)}; height: ${px(frozenRowsHeight)}; overflow: hidden;`,
166
+ frozenRowsCells,
167
+ frozenColsCells,
168
+ frozenCornerCells,
169
+ mainCells,
170
+ byRef: new Map([...frozenRowsCells, ...frozenColsCells, ...frozenCornerCells, ...mainCells].map((cell) => [
171
+ cell.ref,
172
+ cell,
173
+ ])),
174
+ scrollRegionStyle: `position: absolute; left: ${px(gutterWidth + frozenColsWidth)}; top: ${px(headerHeight + frozenRowsHeight)}; width: ${px(scrollableWidth)}; height: ${px(scrollableHeight)}; overflow: auto;`,
175
+ scrollSpacerStyle: `width: ${px(totalScrollWidth)}; height: ${px(totalScrollHeight)}; position: relative;`,
176
+ totalClasses: cm.cn(cm.displayBlock),
177
+ totalStyle: `position: absolute; left: ${px(-10000)}; top: ${px(-10000)};`,
178
+ totalText: `${totalGridWidth}×${totalGridHeight}`,
179
+ editorClasses: cm.cn(cm.w('full'), cm.h('full'), cm.spreadsheetGridCellEditor),
180
+ contentClasses: cm.cn(cm.w('full'), cm.h('full'), cm.spreadsheetGridCellContent, cm.textSize('sm')),
181
+ };
182
+ }
183
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EACL,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,aAAa,GACd,MAAM,gBAAgB,CAAA;AA0JvB;;;;;GAKG;AACH,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,GAAG,KAAK,IAAI,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,QAAQ,GAAG,CAAC,SAA+B,EAAE,GAAW,EAAE,GAAW,EAAW,EAAE,CACtF,SAAS,CAAC,EAAE,KAAK,GAAG,IAAI,SAAS,CAAC,EAAE,KAAK,GAAG,CAAA;AAE9C;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,CAAC,QAAsB,EAAE,IAAY,EAAE,GAAW,EAAU,EAAE,CACjF,6BAA6B,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,CAClE,QAAQ,CAAC,SAAS,CACnB,aAAa,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAA;AAElE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,GAAG,CACb,QAAsB,EACtB,EAAc,EACd,GAAW,EACX,GAAW,EACX,IAAY,EACZ,GAAW,EACD,EAAE;IACZ,MAAM,GAA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U,EAAE,CAAC,YAAY,GAAG,gBAAgB,CAAC,YAAY,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,CAC1F,gBAAgB,CACjB,mBAAmB;QACpB,iBAAiB,EAAE,UAAU,EAAE,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAC9D,iBAAiB,CAClB,uBAAuB;QACxB,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC;QACpC,UAAU,EAAE,6BAA6B,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG;QAC1E,SAAS,EAAE,GAAG,cAAc,IAAI,eAAe,EAAE;QACjD,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC;QAC9E,cAAc,EAAE,EAAE,CAAC,EAAE,CACnB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EACZ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EACZ,EAAE,CAAC,0BAA0B,EAC7B,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAClB;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Types for the Solid spreadsheet grid, the same props
3
+ * `@molecule/app-spreadsheet-grid-react` accepts.
4
+ *
5
+ * @module
6
+ */
7
+ import type { JSX } from 'solid-js';
8
+ /**
9
+ * Cell reference in A1 notation (e.g. `'A1'`, `'AB17'`). Column letters are
10
+ * uppercase; row numbers are 1-indexed.
11
+ */
12
+ export type CellRef = string;
13
+ /**
14
+ * Primitive value stored in a cell. Formula strings start with `'='` —
15
+ * evaluation is the host application's responsibility (typically wired
16
+ * through `@molecule/api-formula-engine`).
17
+ */
18
+ export type CellValue = string | number | boolean | null;
19
+ /**
20
+ * Sparse map from `CellRef` to value. Cells not present in the map render
21
+ * as empty. Using a `Map` keeps update cost O(1) regardless of grid size.
22
+ */
23
+ export type CellMap = Map<CellRef, CellValue>;
24
+ /**
25
+ * Inclusive rectangular selection — `r1`/`c1` is the anchor (where the
26
+ * drag started) and `r2`/`c2` is the focus (where it ended). Both are
27
+ * 0-indexed. A single-cell selection has `r1 === r2 && c1 === c2`.
28
+ */
29
+ export interface SpreadsheetSelection {
30
+ r1: number;
31
+ c1: number;
32
+ r2: number;
33
+ c2: number;
34
+ }
35
+ /**
36
+ * Props accepted by the {@link SpreadsheetGrid} component.
37
+ */
38
+ export interface SpreadsheetGridProps {
39
+ /** Total number of rows in the grid. */
40
+ rows: number;
41
+ /** Total number of columns in the grid. */
42
+ columns: number;
43
+ /** Sparse cell-data map. Cells not present render as empty. */
44
+ cells: CellMap;
45
+ /** Called when the user commits an edit (Enter, Tab, or focus loss). */
46
+ onCellChange: (ref: CellRef, value: CellValue) => void;
47
+ /** Current selection. */
48
+ selection: SpreadsheetSelection;
49
+ /** Called when the user changes the selection (click, drag, Shift+click). */
50
+ onSelectionChange: (selection: SpreadsheetSelection) => void;
51
+ /** Number of rows frozen at the top (default `0`). */
52
+ frozenRows?: number;
53
+ /** Number of columns frozen on the left (default `0`). */
54
+ frozenCols?: number;
55
+ /** Per-cell width in pixels (default `96`). */
56
+ cellWidth?: number;
57
+ /** Per-cell height in pixels (default `28`). */
58
+ cellHeight?: number;
59
+ /** Width of the row-number gutter on the left (default `48`). */
60
+ gutterWidth?: number;
61
+ /** Height of the column-letter header (default `28`). */
62
+ headerHeight?: number;
63
+ /** Visible viewport width in pixels (default `720`). */
64
+ viewportWidth?: number;
65
+ /** Visible viewport height in pixels (default `360`). */
66
+ viewportHeight?: number;
67
+ /** `data-mol-id` for AI-agent selectors. */
68
+ dataMolId?: string;
69
+ /**
70
+ * Optional cell renderer. Receives the cached display string plus the
71
+ * raw value. Defaults to plain text. Use to render formula results
72
+ * (`'=A1+B1'` → evaluated number) or custom formatting.
73
+ */
74
+ renderCell?: (value: CellValue | undefined, ref: CellRef) => JSX.Element;
75
+ }
76
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAExD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAE7C;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,KAAK,EAAE,OAAO,CAAA;IACd,wEAAwE;IACxE,YAAY,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAA;IACtD,yBAAyB;IACzB,SAAS,EAAE,oBAAoB,CAAA;IAC/B,6EAA6E;IAC7E,iBAAiB,EAAE,CAAC,SAAS,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAC5D,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO,CAAA;CACzE"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types for the Solid spreadsheet grid, the same props
3
+ * `@molecule/app-spreadsheet-grid-react` accepts.
4
+ *
5
+ * @module
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}