@ember-lattice/sheet 0.0.0-stage → 1.0.0
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.
- package/CHANGELOG.md +18 -0
- package/LICENSE.md +21 -0
- package/NOTICE +30 -0
- package/README.md +75 -2
- package/addon-main.cjs +4 -0
- package/declarations/format/index.d.ts +41 -0
- package/declarations/format/index.d.ts.map +1 -0
- package/declarations/index.d.ts +6 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/sheet.d.ts +54 -0
- package/declarations/sheet.d.ts.map +1 -0
- package/declarations/surface/index.d.ts +6 -0
- package/declarations/surface/index.d.ts.map +1 -0
- package/declarations/surface/later.d.ts +6 -0
- package/declarations/surface/later.d.ts.map +1 -0
- package/declarations/surface/lattice-sheet.d.ts +89 -0
- package/declarations/surface/lattice-sheet.d.ts.map +1 -0
- package/declarations/surface/model.d.ts +7 -0
- package/declarations/surface/model.d.ts.map +1 -0
- package/declarations/surface/refs.d.ts +22 -0
- package/declarations/surface/refs.d.ts.map +1 -0
- package/declarations/surface/sheet-cell.d.ts +25 -0
- package/declarations/surface/sheet-cell.d.ts.map +1 -0
- package/declarations/surface/sheet-editor.d.ts +19 -0
- package/declarations/surface/sheet-editor.d.ts.map +1 -0
- package/declarations/surface/surface.d.ts +139 -0
- package/declarations/surface/surface.d.ts.map +1 -0
- package/declarations/types.d.ts +144 -0
- package/declarations/types.d.ts.map +1 -0
- package/declarations/workbook.d.ts +67 -0
- package/declarations/workbook.d.ts.map +1 -0
- package/dist/index.js +1135 -0
- package/dist/index.js.map +1 -0
- package/dist/surface/index.js +1214 -0
- package/dist/surface/index.js.map +1 -0
- package/package.json +93 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @ember-lattice/sheet
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 7ce4af2: Lattice 1.0: one grid for every collection in Ember. Lists, feeds, tables, boards and
|
|
8
|
+
spreadsheets come from one headless engine, a port of TanStack Table. It has 80 of the 81
|
|
9
|
+
AG Grid features in the parity matrix; the external filter runs after grouping. The release has the client row models, the Lattice wire protocol with servers for Node,
|
|
10
|
+
Rails and Python, an IronCalc spreadsheet with live collaboration, themes, test harnesses, Jig
|
|
11
|
+
stories and Marquetry catalog entries.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [7ce4af2]
|
|
16
|
+
- @ember-lattice/core@1.0.0
|
|
17
|
+
- @ember-lattice/ember@1.0.0
|
|
18
|
+
- @ember-lattice/formula@1.0.0
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joe Gaudet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Lattice
|
|
2
|
+
Copyright (c) 2026 Joe Gaudet. MIT licensed; see LICENSE.md.
|
|
3
|
+
|
|
4
|
+
Lattice ports code from two MIT-licensed TanStack projects into Ember-native code. Lattice does
|
|
5
|
+
not depend on either package. PORT_MAP.md names each ported file and its source.
|
|
6
|
+
|
|
7
|
+
TanStack Table (@tanstack/table-core 9.3.1)
|
|
8
|
+
https://github.com/TanStack/table
|
|
9
|
+
Copyright (c) 2016 Tanner Linsley
|
|
10
|
+
|
|
11
|
+
TanStack Virtual (@tanstack/virtual-core 3.19.16)
|
|
12
|
+
https://github.com/TanStack/virtual
|
|
13
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
14
|
+
|
|
15
|
+
Both are licensed under the MIT License:
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
18
|
+
and associated documentation files (the "Software"), to deal in the Software without
|
|
19
|
+
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
|
20
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
|
21
|
+
Software is furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
24
|
+
substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
27
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
29
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ember-lattice/sheet
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Lattice spreadsheet model: sparse cells, references by ID, formats, merges, conditional
|
|
4
|
+
formats, data validation, notes and named ranges. The `Sheet` surface is in
|
|
5
|
+
`@ember-lattice/sheet/surface`.
|
|
6
|
+
|
|
7
|
+
Part of [Lattice](https://joegaudet.com/ember-lattice/). Not released yet.
|
|
8
|
+
|
|
9
|
+
## Use
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Workbook } from '@ember-lattice/sheet'
|
|
13
|
+
|
|
14
|
+
const book = new Workbook(engine, { locale: 'en-US' })
|
|
15
|
+
await book.load(doc)
|
|
16
|
+
await book.setInput('s1', 'r1', 'c2', '=A1*2') // stored as '={{c1,r1}}*2'
|
|
17
|
+
book.sheet('s1').cell('r1', 'c2')?.computed // tracked: a change re-renders only this cell
|
|
18
|
+
book.display('s1', 'r1', 'c2') // { text, color } with the cell's number format
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- `apply(ops)` changes the model at once, then sets the computed values from the engine.
|
|
22
|
+
- `setInput` checks data validation. When the value is not valid, the cell keeps its value and
|
|
23
|
+
the result has the note to show.
|
|
24
|
+
- `conditionalFormat` gives the style, the color scale fill and the data bar of a cell.
|
|
25
|
+
Formula rules go through `engine.evaluate`.
|
|
26
|
+
- `find` and `replace` work on the shown text, and with `formulas: true` on the A1 formula text.
|
|
27
|
+
They never touch the stored ID form.
|
|
28
|
+
- `formatValue(value, code, locale)` formats with an Excel format code, for example
|
|
29
|
+
`#,##0.00`, `0%`, `yyyy-mm-dd`, `[Red]` and sections split by `;`.
|
|
30
|
+
|
|
31
|
+
## The Sheet surface
|
|
32
|
+
|
|
33
|
+
`LatticeSheet` shows the active sheet of a `Workbook` with `LatticeGrid` in the `sheet` preset.
|
|
34
|
+
It has A1 column headers, row numbers, a formula bar with function help, sheet tabs, frozen rows
|
|
35
|
+
and columns, merges, notes, data validation and the marks of other users. ADR 0017 has the
|
|
36
|
+
decisions.
|
|
37
|
+
|
|
38
|
+
The surface is not in the package index, because the model must load in Node. Import it from
|
|
39
|
+
`@ember-lattice/sheet/surface`.
|
|
40
|
+
|
|
41
|
+
```gts
|
|
42
|
+
import { Workbook } from '@ember-lattice/sheet'
|
|
43
|
+
import { LatticeSheet, sheetCellEdit } from '@ember-lattice/sheet/surface'
|
|
44
|
+
import { EditController } from '@ember-lattice/editing'
|
|
45
|
+
|
|
46
|
+
const editing = new EditController({ onCellEdit: sheetCellEdit })
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<LatticeSheet @workbook={{book}} @label='Budget' @editing={{editing}} @collab={{session}} />
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- `@editing` is optional. Without it, the sheet is read-only.
|
|
54
|
+
- `@collab` is optional: a `CollabSession` from `@ember-lattice/collab`. With it, cell edits,
|
|
55
|
+
notes and frozen panes go through the session, and Ctrl+Z and Ctrl+Y undo and redo through
|
|
56
|
+
the session. The sheet shows the cursors, selections and soft locks of other users. When
|
|
57
|
+
another user changes the cell in the open editor, an editor with no typed text takes the new
|
|
58
|
+
value. An editor with typed text keeps it, gets `data-conflict` and says so in the live
|
|
59
|
+
region.
|
|
60
|
+
- Frozen rows are pinned rows of the grid, and frozen columns are pinned columns. A merge is one
|
|
61
|
+
grid cell with `aria-rowspan` and `aria-colspan`.
|
|
62
|
+
- The formula bar is a combobox. When the user types a function name after `=`, a list shows
|
|
63
|
+
the matching functions with the signatures from `engine.functions()`. The arrow keys move in
|
|
64
|
+
the list. Enter or Tab puts in the name and `(`. Escape closes the list. In a call, the bar
|
|
65
|
+
shows the signature of that function.
|
|
66
|
+
- Give the sheet a container with a height. The theme (`sheet.css`) styles the surface.
|
|
67
|
+
- The engine must have `watch`. The surface watches the rows and the columns in view, and the
|
|
68
|
+
frozen panes, when the user scrolls.
|
|
69
|
+
|
|
70
|
+
## Tests
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
volta run --node 24.11.1 npx vitest run packages/sheet
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The tests use a fake engine. `@ember-lattice/formula` must be built first.
|
package/addon-main.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CellValue } from '@ember-lattice/formula';
|
|
2
|
+
type DatePart = 'y' | 'M' | 'd' | 'h' | 'm' | 's' | 'ampm' | 'eh' | 'em' | 'es';
|
|
3
|
+
type Token = {
|
|
4
|
+
t: 'lit';
|
|
5
|
+
v: string;
|
|
6
|
+
} | {
|
|
7
|
+
t: 'text';
|
|
8
|
+
} | {
|
|
9
|
+
t: 'general';
|
|
10
|
+
} | {
|
|
11
|
+
t: 'num';
|
|
12
|
+
pattern: string;
|
|
13
|
+
exp?: {
|
|
14
|
+
sign: boolean;
|
|
15
|
+
digits: number;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
t: 'date';
|
|
19
|
+
part: DatePart;
|
|
20
|
+
len: number;
|
|
21
|
+
ampm?: string;
|
|
22
|
+
};
|
|
23
|
+
interface Section {
|
|
24
|
+
tokens: Token[];
|
|
25
|
+
color?: string;
|
|
26
|
+
cond?: {
|
|
27
|
+
op: string;
|
|
28
|
+
value: number;
|
|
29
|
+
};
|
|
30
|
+
percent: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface Formatted {
|
|
33
|
+
text: string;
|
|
34
|
+
color?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Parses a format code into its sections. The result is cached for each code. */
|
|
37
|
+
export declare function parseFormat(code: string): Section[];
|
|
38
|
+
/** Formats a cell value with an Excel format code. */
|
|
39
|
+
export declare function formatValue(value: CellValue | undefined, code?: string, locale?: string): Formatted;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/E,KAAK,KAAK,GACN;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GACb;IAAE,CAAC,EAAE,SAAS,CAAA;CAAE,GAChB;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACtE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7D,UAAU,OAAO;IACf,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAqHD,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAInD;AAgMD,sDAAsD;AACtD,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,IAAI,SAAY,EAChB,MAAM,SAAU,GACf,SAAS,CAuCX"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Workbook } from './workbook.ts';
|
|
2
|
+
export { Sheet } from './sheet.ts';
|
|
3
|
+
export { formatValue, parseFormat } from './format/index.ts';
|
|
4
|
+
export type { Formatted } from './format/index.ts';
|
|
5
|
+
export type * from './types.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,mBAAmB,YAAY,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Area, Cell, ConditionalRule, Validation } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* One sheet of the model: sparse cells `Map<rowId, Map<colId, Cell>>`, the row and column order,
|
|
4
|
+
* frozen panes, merges, conditional formats and data validation. Change it through
|
|
5
|
+
* `Workbook.apply`, so the engine and the op log see each change.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Sheet {
|
|
8
|
+
#private;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
constructor(id: string, name: string, rows: string[], cols: string[]);
|
|
11
|
+
get name(): string;
|
|
12
|
+
set name(value: string);
|
|
13
|
+
get rows(): string[];
|
|
14
|
+
set rows(value: string[]);
|
|
15
|
+
get cols(): string[];
|
|
16
|
+
set cols(value: string[]);
|
|
17
|
+
get frozen(): {
|
|
18
|
+
rows: number;
|
|
19
|
+
cols: number;
|
|
20
|
+
};
|
|
21
|
+
set frozen(value: {
|
|
22
|
+
rows: number;
|
|
23
|
+
cols: number;
|
|
24
|
+
});
|
|
25
|
+
get merges(): Area[];
|
|
26
|
+
set merges(value: Area[]);
|
|
27
|
+
get rules(): ConditionalRule[];
|
|
28
|
+
set rules(value: ConditionalRule[]);
|
|
29
|
+
get validations(): Validation[];
|
|
30
|
+
set validations(value: Validation[]);
|
|
31
|
+
cell(row: string, col: string): Cell | undefined;
|
|
32
|
+
/** Replaces a cell. An empty record clears it. */
|
|
33
|
+
setCell(row: string, col: string, cell: Cell | undefined): void;
|
|
34
|
+
/** Changes some fields of a cell. */
|
|
35
|
+
updateCell(row: string, col: string, change: Partial<Cell>): void;
|
|
36
|
+
/** The cells with content, in no order. */
|
|
37
|
+
entries(): Generator<[string, string, Cell]>;
|
|
38
|
+
get cellCount(): number;
|
|
39
|
+
/** Removes the cells of deleted rows or columns. */
|
|
40
|
+
dropCells(rows: Set<string>, cols: Set<string>): void;
|
|
41
|
+
/** The row and column indices of an area, or undefined when an end is gone. */
|
|
42
|
+
bounds(area: Area): {
|
|
43
|
+
r0: number;
|
|
44
|
+
r1: number;
|
|
45
|
+
c0: number;
|
|
46
|
+
c1: number;
|
|
47
|
+
} | undefined;
|
|
48
|
+
contains(area: Area, row: string, col: string): boolean;
|
|
49
|
+
/** The cells of an area, row by row. */
|
|
50
|
+
cellsOf(area: Area): Generator<[string, string]>;
|
|
51
|
+
/** The merge that holds the cell, if there is one. */
|
|
52
|
+
mergeAt(row: string, col: string): Area | undefined;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../src/sheet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,U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AAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIjE,2CAA2C;IAC1C,OAAO,IAAI,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAM7C,IAAI,SAAS,IAAI,MAAM,CAItB;IAED,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI;IAYrD,+EAA+E;IAC/E,MAAM,CAAC,IAAI,EAAE,IAAI;;;;;;IASjB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAOvD,wCAAwC;IACvC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAQjD,sDAAsD;IACtD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;CAGpD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as LatticeSheet } from './lattice-sheet';
|
|
2
|
+
export type { LatticeSheetSignature } from './lattice-sheet';
|
|
3
|
+
export { ROW_COLUMN, SheetSurface, sheetCellEdit } from './surface.ts';
|
|
4
|
+
export type { SheetCollab, SheetPeer, SheetWireOp } from './surface.ts';
|
|
5
|
+
export { SheetCellValue, SheetRowRef } from './refs.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/surface/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"later.d.ts","sourceRoot":"","sources":["../../src/surface/later.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,qBAAa,KAAK,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;gBACjB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;CAMhC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type { LatticeLocaleTextOverride } from '@ember-lattice/core';
|
|
3
|
+
import type { GridEditing, GridNotes } from '@ember-lattice/ember';
|
|
4
|
+
import type { FunctionInfo } from '@ember-lattice/formula';
|
|
5
|
+
import type { SheetBook, SheetModel } from './model.ts';
|
|
6
|
+
import { SheetSurface } from './surface.ts';
|
|
7
|
+
import type { SheetCollab, SheetPeer } from './surface.ts';
|
|
8
|
+
export interface LatticeSheetSignature {
|
|
9
|
+
Element: HTMLDivElement;
|
|
10
|
+
Args: {
|
|
11
|
+
workbook: SheetBook;
|
|
12
|
+
/** The accessible name of the grid. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** An `EditController` from `@ember-lattice/editing` with `onCellEdit: sheetCellEdit`. */
|
|
15
|
+
editing?: GridEditing;
|
|
16
|
+
/** A `CollabSession` from `@ember-lattice/collab`: ops go through it, and peers show. */
|
|
17
|
+
collab?: SheetCollab;
|
|
18
|
+
/** The row height in px. Default: 28. */
|
|
19
|
+
rowHeight?: number;
|
|
20
|
+
/** Locale text that replaces the owner text for this sheet. */
|
|
21
|
+
localeText?: LatticeLocaleTextOverride;
|
|
22
|
+
/** The locale of the messages. Default: the owner locale. */
|
|
23
|
+
locale?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export default class LatticeSheet extends Component<LatticeSheetSignature> {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly surface: SheetSurface;
|
|
29
|
+
get l(): import("@ember-lattice/core").LatticeLocale;
|
|
30
|
+
/** The formula bar text while the user types, for one cell; null shows the active cell. */
|
|
31
|
+
draft: {
|
|
32
|
+
key: string;
|
|
33
|
+
text: string;
|
|
34
|
+
} | null;
|
|
35
|
+
/** The sheet in a rename, or null. */
|
|
36
|
+
renaming: SheetModel | null;
|
|
37
|
+
/** The caret position in the formula bar. */
|
|
38
|
+
caret: number;
|
|
39
|
+
/** The index of the active option in the function list. */
|
|
40
|
+
helpIndex: number;
|
|
41
|
+
/** The text for which the user closed the list with Escape. */
|
|
42
|
+
helpClosed: string | null;
|
|
43
|
+
willDestroy(): void;
|
|
44
|
+
get panelId(): string;
|
|
45
|
+
get sheets(): readonly SheetModel[];
|
|
46
|
+
get renameId(): string;
|
|
47
|
+
get barId(): string;
|
|
48
|
+
get listId(): string;
|
|
49
|
+
get hintId(): string;
|
|
50
|
+
optionId: (index: number) => string;
|
|
51
|
+
isHelpActive: (index: number) => boolean;
|
|
52
|
+
/** The functions that start with the name at the caret, with their signatures. */
|
|
53
|
+
get help(): FunctionInfo[];
|
|
54
|
+
get helpOpen(): boolean;
|
|
55
|
+
get activeOption(): string | undefined;
|
|
56
|
+
/** The signature of the call at the caret. */
|
|
57
|
+
get hint(): string | undefined;
|
|
58
|
+
get barDescribedBy(): string;
|
|
59
|
+
signatureOf: (fn: FunctionInfo) => string;
|
|
60
|
+
isActive: (sheet: SheetModel) => boolean;
|
|
61
|
+
onSelect: (sheet: SheetModel) => () => void;
|
|
62
|
+
onRename: (sheet: SheetModel) => () => void;
|
|
63
|
+
tabId: (sheet: SheetModel) => string;
|
|
64
|
+
get active(): import("@ember-lattice/ember").GridCellRef | null;
|
|
65
|
+
get address(): string;
|
|
66
|
+
get editable(): boolean;
|
|
67
|
+
get cellKey(): string;
|
|
68
|
+
get barText(): string;
|
|
69
|
+
/** The cell notes for the grid (`@notes`): the grid draws the mark and the note box. */
|
|
70
|
+
notes: GridNotes;
|
|
71
|
+
get peers(): SheetPeer[];
|
|
72
|
+
peerPlace: (peer: SheetPeer) => string;
|
|
73
|
+
onBarInput: (event: Event) => void;
|
|
74
|
+
readCaret: (event: Event) => void;
|
|
75
|
+
/** Puts `NAME(` in place of the typed name, and the caret after it. */
|
|
76
|
+
insertFunction: (fn: FunctionInfo) => void;
|
|
77
|
+
onOptionDown: (fn: FunctionInfo) => (event: MouseEvent) => void;
|
|
78
|
+
/** The list keys: the arrows move, Enter and Tab insert, Escape closes. True when handled. */
|
|
79
|
+
private helpKey;
|
|
80
|
+
onBarKey: (event: KeyboardEvent) => Promise<void>;
|
|
81
|
+
/** The keys of the grid panel: undo and redo with `@collab`. The grid owns Ctrl+D and Ctrl+R. */
|
|
82
|
+
onPanelKey: (event: KeyboardEvent) => void;
|
|
83
|
+
select: (sheet: SheetModel) => void;
|
|
84
|
+
onTabKey: (event: KeyboardEvent) => void;
|
|
85
|
+
startRename: (sheet: SheetModel) => void;
|
|
86
|
+
onRenameKey: (event: KeyboardEvent) => Promise<void>;
|
|
87
|
+
addSheet: () => Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=lattice-sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lattice-sheet.d.ts","sourceRoot":"","sources":["../../src/surface/lattice-sheet.gts"],"names":[],"mappings":"AA8bA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAO1C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAA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sheet.ts';
|
|
2
|
+
import type { Workbook } from '../workbook.ts';
|
|
3
|
+
export type SheetModel = Pick<Sheet, 'id' | 'name' | 'rows' | 'cols' | 'frozen' | 'merges' | 'rules' | 'validations' | 'cell' | 'updateCell'>;
|
|
4
|
+
export interface SheetBook extends Pick<Workbook, 'engine' | 'styles' | 'formulaText' | 'display' | 'setInput' | 'validate' | 'conditionalFormat' | 'apply' | 'refs'> {
|
|
5
|
+
readonly sheets: readonly SheetModel[];
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/surface/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,KAAK,EACH,IAAI,GACJ,MAAM,GACN,MAAM,GACN,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,aAAa,GACb,MAAM,GACN,YAAY,CACf,CAAA;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,QAAQ,EACN,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,SAAS,GACT,UAAU,GACV,UAAU,GACV,mBAAmB,GACnB,OAAO,GACP,MAAM,CACT;IACC,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;CACvC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SheetSurface } from './surface.ts';
|
|
2
|
+
/** The `original` of each table row. */
|
|
3
|
+
export declare class SheetRowRef {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly surface: SheetSurface;
|
|
6
|
+
constructor(id: string, surface: SheetSurface);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The value of a sheet cell in the table: the cell position and the editor text (the A1 formula
|
|
10
|
+
* or the raw value) at the time of the read. The `EditController` keeps it as the value before an
|
|
11
|
+
* edit (for undo), and a fill gives it to the target cells (the formula moves).
|
|
12
|
+
*/
|
|
13
|
+
export declare class SheetCellValue {
|
|
14
|
+
readonly surface: SheetSurface;
|
|
15
|
+
readonly sheet: string;
|
|
16
|
+
readonly row: string;
|
|
17
|
+
readonly col: string;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
constructor(surface: SheetSurface, sheet: string, row: string, col: string, text: string);
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/surface/refs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,wCAAwC;AACxC,qBAAa,WAAW;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;gBAClB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;CAI9C;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBACT,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQxF,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type { LatticeCellSignature } from '@ember-lattice/ember';
|
|
3
|
+
import type { ConditionalResult } from '../types.ts';
|
|
4
|
+
import { Later } from './later.ts';
|
|
5
|
+
import { SheetRowRef } from './refs.ts';
|
|
6
|
+
export default class SheetCell extends Component<LatticeCellSignature> {
|
|
7
|
+
get ref(): SheetRowRef | undefined;
|
|
8
|
+
get surface(): import("./surface.ts").SheetSurface | undefined;
|
|
9
|
+
get book(): import("./model.ts").SheetBook | undefined;
|
|
10
|
+
get row(): string;
|
|
11
|
+
get col(): string;
|
|
12
|
+
get data(): import("../types.ts").Cell | undefined;
|
|
13
|
+
get text(): string;
|
|
14
|
+
get conditional(): Later<ConditionalResult> | undefined;
|
|
15
|
+
get invalid(): boolean;
|
|
16
|
+
get peers(): {
|
|
17
|
+
cursor: import("./surface.ts").SheetPeer | undefined;
|
|
18
|
+
selection: import("./surface.ts").SheetPeer | undefined;
|
|
19
|
+
lock: import("./surface.ts").SheetPeer | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
get peerLabelStyle(): import("@ember/template").TrustedHTML | undefined;
|
|
22
|
+
get style(): import("@ember/template").TrustedHTML;
|
|
23
|
+
get hasConditional(): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=sheet-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet-cell.d.ts","sourceRoot":"","sources":["../../src/surface/sheet-cell.gts"],"names":[],"mappings":"AA8JA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAK1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAqCvC,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,SAAS,CAAC,oBAAoB,CAAC;IACpE,IAAI,GAAG,IAAI,WAAW,GAAG,SAAS,CAGjC;IAED,IAAI,OAAO,oDAEV;IAED,IAAI,IAAI,+CAEP;IAED,IAAI,GAAG,WAEN;IAED,IAAI,GAAG,WAEN;IAED,IAAI,IAAI,2CAEP;IAED,IAAI,IAAI,WAGP;IAED,IAAY,WAAW,IAAI,KAAK,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAM9D;IAED,IAAI,OAAO,YAEV;IAED,IAAI,KAAK;;;;kBAER;IAED,IAAI,cAAc,sDAGjB;IAED,IAAI,KAAK,0CA2BR;IAED,IAAI,cAAc,YAGjB;CAiDF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentLike } from '@glint/template';
|
|
2
|
+
import type { SheetSurface } from './surface.ts';
|
|
3
|
+
export interface SheetEditorSignature {
|
|
4
|
+
Element: HTMLInputElement | HTMLSelectElement;
|
|
5
|
+
Args: {
|
|
6
|
+
id?: string;
|
|
7
|
+
/** The accessible name from the grid: the column header. The editor uses the cell address. */
|
|
8
|
+
label?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
value?: unknown;
|
|
12
|
+
onChange?: (value: unknown) => void;
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
options?: readonly unknown[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** The editor class of one surface: it reads the edited cell and the list options there. */
|
|
18
|
+
export declare function editorFor(surface: SheetSurface): ComponentLike<SheetEditorSignature>;
|
|
19
|
+
//# sourceMappingURL=sheet-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet-editor.d.ts","sourceRoot":"","sources":["../../src/surface/sheet-editor.gts"],"names":[],"mappings":"AA+IA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CAAA;IAC7C,IAAI,EAAE;QACJ,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,8FAA8F;QAC9F,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,OAAO,CAAA;QACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;QACnC,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;KAC7B,CAAA;CACF;AA2ID,4FAA4F;AAC5F,wBAAgB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAcpF"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { LatticeLocale } from '@ember-lattice/core';
|
|
2
|
+
import { GridStateHandle } from '@ember-lattice/ember';
|
|
3
|
+
import type { GridCellRef, GridRow } from '@ember-lattice/ember';
|
|
4
|
+
import type { CellRef, RangeRef } from '@ember-lattice/formula';
|
|
5
|
+
import type { Area, InputResult, WorkbookOp } from '../types.ts';
|
|
6
|
+
import type { SheetBook, SheetModel } from './model.ts';
|
|
7
|
+
import { SheetCellValue, SheetRowRef } from './refs.ts';
|
|
8
|
+
export { SheetCellValue, SheetRowRef };
|
|
9
|
+
/** Another user on the doc: a `Peer` of `@ember-lattice/collab` fits it. */
|
|
10
|
+
export interface SheetPeer {
|
|
11
|
+
clientId: string;
|
|
12
|
+
name: string;
|
|
13
|
+
color: string;
|
|
14
|
+
cursor: CellRef | null;
|
|
15
|
+
selection: RangeRef | null;
|
|
16
|
+
editing: CellRef | null;
|
|
17
|
+
seen: number;
|
|
18
|
+
}
|
|
19
|
+
/** The ops that go over the wire (the `CollabOp` of `@ember-lattice/collab`). */
|
|
20
|
+
export type SheetWireOp = Exclude<WorkbookOp, {
|
|
21
|
+
type: 'addRule' | 'removeRule' | 'addValidation' | 'removeValidation';
|
|
22
|
+
}>;
|
|
23
|
+
/** The part of a `CollabSession` (`@ember-lattice/collab`) that the Sheet uses. */
|
|
24
|
+
export interface SheetCollab {
|
|
25
|
+
readonly peers: SheetPeer[];
|
|
26
|
+
onPresence: ((peers: SheetPeer[]) => void) | undefined;
|
|
27
|
+
/** The ops of another user are in the model now. */
|
|
28
|
+
onRemote: ((ops: SheetWireOp[]) => void) | undefined;
|
|
29
|
+
apply(ops: SheetWireOp[]): Promise<void>;
|
|
30
|
+
undo(): Promise<SheetWireOp[]>;
|
|
31
|
+
redo(): Promise<SheetWireOp[]>;
|
|
32
|
+
setPresence(state: {
|
|
33
|
+
cursor: CellRef | null;
|
|
34
|
+
selection: RangeRef | null;
|
|
35
|
+
}): void;
|
|
36
|
+
setEditing(cell: CellRef | null): void;
|
|
37
|
+
}
|
|
38
|
+
/** The open cell editor: the surface tells it when another user changes its cell. */
|
|
39
|
+
export interface OpenEditor {
|
|
40
|
+
remoteChange(): void;
|
|
41
|
+
}
|
|
42
|
+
/** The row number column. A sheet column ID cannot have a colon. */
|
|
43
|
+
export declare const ROW_COLUMN = ":row";
|
|
44
|
+
export declare class SheetSurface {
|
|
45
|
+
#private;
|
|
46
|
+
readonly workbook: SheetBook;
|
|
47
|
+
readonly collab: SheetCollab | undefined;
|
|
48
|
+
readonly stateHost: GridStateHandle;
|
|
49
|
+
readonly rowHeight: number;
|
|
50
|
+
/** The locale text of the surface: the row header, new sheet names and messages. */
|
|
51
|
+
readonly locale: () => LatticeLocale;
|
|
52
|
+
sheetId: string;
|
|
53
|
+
active: GridCellRef | null;
|
|
54
|
+
peers: SheetPeer[];
|
|
55
|
+
/** The last refused input, for the live region. */
|
|
56
|
+
message: string;
|
|
57
|
+
readonly Editor: import("@glint/template").ComponentLike<import('./sheet-editor').SheetEditorSignature>;
|
|
58
|
+
/** The open cell editor, if there is one. */
|
|
59
|
+
editor: OpenEditor | null;
|
|
60
|
+
constructor(workbook: SheetBook, options: {
|
|
61
|
+
collab?: SheetCollab;
|
|
62
|
+
rowHeight: number;
|
|
63
|
+
locale?: () => LatticeLocale;
|
|
64
|
+
});
|
|
65
|
+
destroy(): void;
|
|
66
|
+
get sheet(): SheetModel;
|
|
67
|
+
select(sheetId: string): void;
|
|
68
|
+
/** The 0-based index of each row ID of the active sheet. */
|
|
69
|
+
get rowIndex(): Map<string, number>;
|
|
70
|
+
get colIndex(): Map<string, number>;
|
|
71
|
+
/** The indices of an area on the active sheet, or undefined when an end is gone. */
|
|
72
|
+
bounds(area: Area): {
|
|
73
|
+
r0: number;
|
|
74
|
+
r1: number;
|
|
75
|
+
c0: number;
|
|
76
|
+
c1: number;
|
|
77
|
+
} | undefined;
|
|
78
|
+
contains(area: Area, row: string, col: string): boolean;
|
|
79
|
+
/** The A1 address of a cell, for example `B3`. */
|
|
80
|
+
address(row: string, col: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* The validation result of the cell value. Undefined while the check runs, and for a cell with
|
|
83
|
+
* no value or no validation. A check runs again when the value, the rules or the locale change.
|
|
84
|
+
*/
|
|
85
|
+
validity(row: string, col: string): InputResult | undefined;
|
|
86
|
+
/** True when the cell value breaks a validation of the cell. */
|
|
87
|
+
cellInvalid(row: string, col: string): boolean;
|
|
88
|
+
/** The text that a reader gets for the cell: the validation message and the marks of others. */
|
|
89
|
+
cellDescription(row: string, col: string): string;
|
|
90
|
+
/** The values of the list validation of a cell, if it has one. */
|
|
91
|
+
listOptions(row: string, col: string): string[] | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The merges by their start column, as indices on the active sheet. A merge is a grid span:
|
|
94
|
+
* the start column spans the merge columns on each merge row, and the rows join one run.
|
|
95
|
+
*/
|
|
96
|
+
get mergesByCol(): Map<string, {
|
|
97
|
+
r0: number;
|
|
98
|
+
r1: number;
|
|
99
|
+
cols: number;
|
|
100
|
+
}[]>;
|
|
101
|
+
/** The table for `LatticeGrid`. A new table when the rows, the columns, the panes or the merges change. */
|
|
102
|
+
get table(): import("@ember-lattice/core").Table<{
|
|
103
|
+
coreReactivityFeature: import("@ember-lattice/core").TableReactivityBindings;
|
|
104
|
+
columnSizingFeature: import("@ember-lattice/core").TableFeature;
|
|
105
|
+
columnPinningFeature: import("@ember-lattice/core").TableFeature;
|
|
106
|
+
rowPinningFeature: import("@ember-lattice/core").TableFeature;
|
|
107
|
+
cellSpanningFeature: import("@ember-lattice/core").TableFeature;
|
|
108
|
+
cellSelectionFeature: import("@ember-lattice/core").TableFeature;
|
|
109
|
+
}, SheetRowRef>;
|
|
110
|
+
columnSize(col: string): number;
|
|
111
|
+
/** The `onCellEdit` path: a text, a moved cell (a fill), an old value (an undo) or a clear. */
|
|
112
|
+
edit(row: GridRow, col: string, value: unknown): Promise<void>;
|
|
113
|
+
/** The editor text of `from`, as Excel fills it into the cell at `row`, `col`. */
|
|
114
|
+
moved(from: SheetCellValue, row: string, col: string): string;
|
|
115
|
+
/** Sets a cell of the active sheet from typed text. Rejects with the validation note. */
|
|
116
|
+
input(row: string, col: string, text: string): Promise<void>;
|
|
117
|
+
/** Applies ops: wire ops through the session; rules and validations on the local model. */
|
|
118
|
+
apply(ops: WorkbookOp[]): Promise<void>;
|
|
119
|
+
/** Undo through the session (with `@collab`): later writes of other users stay. */
|
|
120
|
+
undo(): Promise<void>;
|
|
121
|
+
redo(): Promise<void>;
|
|
122
|
+
/** Adds a sheet with 100 rows and 26 columns, and makes it active. */
|
|
123
|
+
addSheet(): Promise<void>;
|
|
124
|
+
rename(sheetId: string, name: string): Promise<void>;
|
|
125
|
+
/** The other users at a cell: the cursor, a selection that holds it, and the soft lock. */
|
|
126
|
+
peersAt(row: string, col: string): {
|
|
127
|
+
cursor: SheetPeer | undefined;
|
|
128
|
+
selection: SheetPeer | undefined;
|
|
129
|
+
lock: SheetPeer | undefined;
|
|
130
|
+
};
|
|
131
|
+
/** The cell editor opened or closed: the soft lock for the other users. */
|
|
132
|
+
editing(cell: {
|
|
133
|
+
row: string;
|
|
134
|
+
col: string;
|
|
135
|
+
} | null): void;
|
|
136
|
+
}
|
|
137
|
+
/** Give it to the `EditController` of a `LatticeSheet`: `new EditController({ onCellEdit: sheetCellEdit })`. */
|
|
138
|
+
export declare function sheetCellEdit(row: GridRow, columnId: string, value: unknown): Promise<void>;
|
|
139
|
+
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../src/surface/surface.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAa,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,eAAe,EAAmB,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAqB,MAAM,sBAAsB,CAAA;AAEnF,OAAO,KAAK,EAAE,OAAO,EAAa,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAGvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA;AAEtC,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IACtB,SAAS,EAAE,QAAQ,GAAG,IAAI,CAAA;IAC1B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,iFAAiF;AACjF,MAAM,MAAM,WAAW,GAAG,OAAO,CAC/B,UAAU,EACV;IAAE,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,eAAe,GAAG,kBAAkB,C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