@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
|
@@ -0,0 +1,1214 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked, cached } from '@glimmer/tracking';
|
|
3
|
+
import { on } from '@ember/modifier';
|
|
4
|
+
import { guidFor } from '@ember/object/internals';
|
|
5
|
+
import { renderSettled } from '@ember/renderer';
|
|
6
|
+
import { getOwner } from '@ember/owner';
|
|
7
|
+
import { tableFeatures, cellSelectionFeature, cellSpanningFeature, rowPinningFeature, columnPinningFeature, columnSizingFeature, emberReactivityBindings, latticeLocale, constructTable } from '@ember-lattice/core';
|
|
8
|
+
import { GridStateHandle, rowNumberColumn, LatticeGrid } from '@ember-lattice/ember';
|
|
9
|
+
import is from '@sindresorhus/is';
|
|
10
|
+
import { columnLabel, fromR1C1, toR1C1, toStored } from '@ember-lattice/formula';
|
|
11
|
+
import { htmlSafe } from '@ember/template';
|
|
12
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
13
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
14
|
+
import { setComponentTemplate } from '@ember/component';
|
|
15
|
+
|
|
16
|
+
// A promise result as tracked state, for the async parts of a sheet cell.
|
|
17
|
+
class Later {
|
|
18
|
+
static {
|
|
19
|
+
g(this.prototype, "value", [tracked]);
|
|
20
|
+
}
|
|
21
|
+
#value = (i(this, "value"), void 0);
|
|
22
|
+
constructor(promise) {
|
|
23
|
+
promise.then(v => this.value = v, () => {});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The objects in the table of a `LatticeSheet`: the row `original` and the cell value.
|
|
28
|
+
|
|
29
|
+
/** The `original` of each table row. */
|
|
30
|
+
class SheetRowRef {
|
|
31
|
+
id;
|
|
32
|
+
surface;
|
|
33
|
+
constructor(id, surface) {
|
|
34
|
+
this.id = id;
|
|
35
|
+
this.surface = surface;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The value of a sheet cell in the table: the cell position and the editor text (the A1 formula
|
|
41
|
+
* or the raw value) at the time of the read. The `EditController` keeps it as the value before an
|
|
42
|
+
* edit (for undo), and a fill gives it to the target cells (the formula moves).
|
|
43
|
+
*/
|
|
44
|
+
class SheetCellValue {
|
|
45
|
+
surface;
|
|
46
|
+
sheet;
|
|
47
|
+
row;
|
|
48
|
+
col;
|
|
49
|
+
text;
|
|
50
|
+
constructor(surface, sheet, row, col, text) {
|
|
51
|
+
this.surface = surface;
|
|
52
|
+
this.sheet = sheet;
|
|
53
|
+
this.row = row;
|
|
54
|
+
this.col = col;
|
|
55
|
+
this.text = text;
|
|
56
|
+
}
|
|
57
|
+
toString() {
|
|
58
|
+
return this.text;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// The cell of a `LatticeSheet`: the formatted value, the cell style, conditional formats, the
|
|
63
|
+
// invalid marker, and the marks of other users (ADR 0017). A merge is a grid span; the grid draws
|
|
64
|
+
// notes. The grid also puts `aria-invalid` and the description on the gridcell, through the
|
|
65
|
+
// `cellInvalid` and `cellDescription` hooks of the surface columns.
|
|
66
|
+
const COLOR = /^(#[0-9a-f]{3,8}|[a-z]+|var\(--[a-z0-9-]+(,\s*(#[0-9a-f]{3,8}|[a-z]+))?\))$/i;
|
|
67
|
+
const safeColor = value => value && COLOR.test(value) ? value : undefined;
|
|
68
|
+
/** Black or white, whichever has more contrast on the color. */
|
|
69
|
+
function textOn(color) {
|
|
70
|
+
const hex = /^#([0-9a-f]{6})$/i.exec(color)?.[1];
|
|
71
|
+
if (!hex) return '#fff';
|
|
72
|
+
const lin = i => {
|
|
73
|
+
const c = parseInt(hex.slice(i, i + 2), 16) / 255;
|
|
74
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
75
|
+
};
|
|
76
|
+
const l = 0.2126 * lin(0) + 0.7152 * lin(2) + 0.0722 * lin(4);
|
|
77
|
+
return (l + 0.05) / 0.05 > 1.05 / (l + 0.05) ? '#000' : '#fff';
|
|
78
|
+
}
|
|
79
|
+
function css(style) {
|
|
80
|
+
if (!style) return [];
|
|
81
|
+
const out = [];
|
|
82
|
+
if (style.bold) out.push('font-weight: 700');
|
|
83
|
+
if (style.italic) out.push('font-style: italic');
|
|
84
|
+
const lines = [style.underline && 'underline', style.strike && 'line-through'].filter(Boolean);
|
|
85
|
+
if (lines.length) out.push(`text-decoration: ${lines.join(' ')}`);
|
|
86
|
+
const color = safeColor(style.color);
|
|
87
|
+
if (color) out.push(`color: ${color}`);
|
|
88
|
+
const fill = safeColor(style.fill);
|
|
89
|
+
if (fill) out.push(`background-color: ${fill}`);
|
|
90
|
+
if (style.align) out.push(`text-align: ${style.align}`);
|
|
91
|
+
if (style.wrap) out.push('white-space: normal');
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
class SheetCell extends Component {
|
|
95
|
+
get ref() {
|
|
96
|
+
const ref = this.args.row.original;
|
|
97
|
+
return ref instanceof SheetRowRef ? ref : undefined;
|
|
98
|
+
}
|
|
99
|
+
get surface() {
|
|
100
|
+
return this.ref?.surface;
|
|
101
|
+
}
|
|
102
|
+
get book() {
|
|
103
|
+
return this.surface?.workbook;
|
|
104
|
+
}
|
|
105
|
+
get row() {
|
|
106
|
+
return this.args.row.id;
|
|
107
|
+
}
|
|
108
|
+
get col() {
|
|
109
|
+
return this.args.column.id;
|
|
110
|
+
}
|
|
111
|
+
get data() {
|
|
112
|
+
return this.surface?.sheet.cell(this.row, this.col);
|
|
113
|
+
}
|
|
114
|
+
get text() {
|
|
115
|
+
const s = this.surface;
|
|
116
|
+
return s ? s.workbook.display(s.sheetId, this.row, this.col).text : '';
|
|
117
|
+
}
|
|
118
|
+
get conditional() {
|
|
119
|
+
const s = this.surface;
|
|
120
|
+
if (!s || !s.sheet.rules.some(r => s.contains(r.range, this.row, this.col))) return undefined;
|
|
121
|
+
// The read makes the cache depend on the value.
|
|
122
|
+
void this.data?.computed;
|
|
123
|
+
return new Later(s.workbook.conditionalFormat(s.sheetId, this.row, this.col));
|
|
124
|
+
}
|
|
125
|
+
static {
|
|
126
|
+
n(this.prototype, "conditional", [cached]);
|
|
127
|
+
}
|
|
128
|
+
get invalid() {
|
|
129
|
+
return this.surface?.cellInvalid(this.row, this.col) ?? false;
|
|
130
|
+
}
|
|
131
|
+
get peers() {
|
|
132
|
+
return this.surface?.peersAt(this.row, this.col);
|
|
133
|
+
}
|
|
134
|
+
get peerLabelStyle() {
|
|
135
|
+
const color = safeColor(this.peers?.cursor?.color);
|
|
136
|
+
return color ? htmlSafe(`background-color: ${color}; color: ${textOn(color)}`) : undefined;
|
|
137
|
+
}
|
|
138
|
+
get style() {
|
|
139
|
+
const data = this.data;
|
|
140
|
+
const book = this.book;
|
|
141
|
+
const rules = [];
|
|
142
|
+
if (is.number(data?.computed)) rules.push('text-align: end');
|
|
143
|
+
rules.push(...css(data?.style ? book?.styles.get(data.style) : undefined));
|
|
144
|
+
const s = this.surface;
|
|
145
|
+
const formatted = s ? s.workbook.display(s.sheetId, this.row, this.col).color : undefined;
|
|
146
|
+
const formatColor = safeColor(formatted);
|
|
147
|
+
if (formatColor) rules.push(`color: ${formatColor}`);
|
|
148
|
+
const cf = this.conditional?.value;
|
|
149
|
+
if (cf) {
|
|
150
|
+
rules.push(...css(cf.style));
|
|
151
|
+
const fill = safeColor(cf.fill);
|
|
152
|
+
if (fill) rules.push(`background-color: ${fill}`);
|
|
153
|
+
const bar = cf.bar && safeColor(cf.bar.color);
|
|
154
|
+
if (cf.bar && bar) {
|
|
155
|
+
const pct = Math.round(cf.bar.length * 100);
|
|
156
|
+
rules.push(`background-image: linear-gradient(to right, ${bar} ${pct}%, transparent ${pct}%)`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const peers = this.peers;
|
|
160
|
+
const ring = safeColor(peers?.cursor?.color ?? peers?.selection?.color);
|
|
161
|
+
if (ring) rules.push(`--lt-sheet-peer: ${ring}`);
|
|
162
|
+
return htmlSafe(rules.join('; '));
|
|
163
|
+
}
|
|
164
|
+
get hasConditional() {
|
|
165
|
+
const cf = this.conditional?.value;
|
|
166
|
+
return !!cf && (!!cf.style || !!cf.fill || !!cf.bar);
|
|
167
|
+
}
|
|
168
|
+
static {
|
|
169
|
+
setComponentTemplate(precompileTemplate("<span class=\"lt-sheet-cell\" style={{this.style}} data-cf={{if this.hasConditional \"true\"}} data-invalid={{if this.invalid \"true\"}} data-peer-cursor={{if this.peers.cursor \"true\"}} data-peer-selection={{if this.peers.selection \"true\"}} data-locked={{if this.peers.lock \"true\"}}>\n {{this.text}}\n {{#if this.peers.cursor}}\n <span class=\"lt-sheet-peer-label\" aria-hidden=\"true\" style={{this.peerLabelStyle}}>\n {{this.peers.cursor.name}}\n </span>\n {{/if}}\n</span>", {
|
|
170
|
+
strictMode: true
|
|
171
|
+
}), this);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// The cell editor of a `LatticeSheet`, in `meta.lattice.editor`: a text input for a value or a
|
|
176
|
+
// `=formula`, or a select for a cell with a list validation. It has the Formwright control args.
|
|
177
|
+
// When another user changes the cell, an untouched editor takes the new text; an editor with
|
|
178
|
+
// typed text keeps it and gets `data-conflict`.
|
|
179
|
+
const textOf = value => is.string(value) ? value : is.nullOrUndefined(value) ? '' : String(value);
|
|
180
|
+
const isSelected = (option, value) => option === textOf(value);
|
|
181
|
+
class SheetEditor extends Component {
|
|
182
|
+
/** The edited cell: the active cell when the edit opened. The subclass sets it. */cell = null;
|
|
183
|
+
/** The cell text in the model that the editor started from. */
|
|
184
|
+
base = '';
|
|
185
|
+
/** Another user changed the cell after the user typed. */
|
|
186
|
+
static {
|
|
187
|
+
g(this.prototype, "conflict", [tracked], function () {
|
|
188
|
+
return false;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
#conflict = (i(this, "conflict"), void 0);
|
|
192
|
+
get options() {
|
|
193
|
+
const cell = this.cell;
|
|
194
|
+
return cell ? this.surface.listOptions(cell.row, cell.col) : undefined;
|
|
195
|
+
}
|
|
196
|
+
willDestroy() {
|
|
197
|
+
super.willDestroy();
|
|
198
|
+
if (this.surface.editor === this) this.surface.editor = null;
|
|
199
|
+
this.surface.editing(null);
|
|
200
|
+
}
|
|
201
|
+
/** The surface calls this after the ops of another user. */
|
|
202
|
+
remoteChange() {
|
|
203
|
+
const cell = this.cell;
|
|
204
|
+
if (!cell) return;
|
|
205
|
+
const now = this.surface.workbook.formulaText(this.surface.sheetId, cell.row, cell.col);
|
|
206
|
+
if (now === this.base) return;
|
|
207
|
+
const untouched = this.text === this.base;
|
|
208
|
+
this.base = now;
|
|
209
|
+
if (untouched) {
|
|
210
|
+
this.args.onChange?.(now);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this.conflict = true;
|
|
214
|
+
this.surface.message = this.surface.locale().t('sheet.remoteChange', {
|
|
215
|
+
cell: this.surface.address(cell.row, cell.col)
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
get text() {
|
|
219
|
+
return textOf(this.args.value);
|
|
220
|
+
}
|
|
221
|
+
/** The accessible name: the A1 address of the edited cell, for example `B3`. */
|
|
222
|
+
get label() {
|
|
223
|
+
const cell = this.cell;
|
|
224
|
+
return cell ? this.surface.address(cell.row, cell.col) : this.args.label;
|
|
225
|
+
}
|
|
226
|
+
change = event => {
|
|
227
|
+
const target = event.target;
|
|
228
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLSelectElement) {
|
|
229
|
+
this.args.onChange?.(target.value);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
static {
|
|
233
|
+
setComponentTemplate(precompileTemplate("{{#if this.options}}\n <select class=\"lt-sheet-input\" id={{@id}} aria-invalid={{if @invalid \"true\"}} ...attributes aria-label={{this.label}} {{on \"change\" this.change}}>\n {{#each this.options as |choice|}}\n <option value={{choice}} selected={{isSelected choice @value}}>{{choice}}</option>\n {{/each}}\n </select>\n{{else}}\n <input class=\"lt-sheet-input\" id={{@id}} value={{this.text}} spellcheck=\"false\" autocomplete=\"off\" aria-invalid={{if @invalid \"true\"}} data-conflict={{if this.conflict \"true\"}} ...attributes aria-label={{this.label}} {{on \"input\" this.change}} />\n{{/if}}", {
|
|
234
|
+
strictMode: true,
|
|
235
|
+
scope: () => ({
|
|
236
|
+
on,
|
|
237
|
+
isSelected
|
|
238
|
+
})
|
|
239
|
+
}), this);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** The editor class of one surface: it reads the edited cell and the list options there. */
|
|
243
|
+
function editorFor(surface) {
|
|
244
|
+
return class extends SheetEditor {
|
|
245
|
+
surface = surface;
|
|
246
|
+
constructor(owner, args) {
|
|
247
|
+
super(owner, args);
|
|
248
|
+
const a = surface.active;
|
|
249
|
+
this.cell = a && {
|
|
250
|
+
row: a.rowId,
|
|
251
|
+
col: a.columnId
|
|
252
|
+
};
|
|
253
|
+
if (this.cell) {
|
|
254
|
+
this.base = surface.workbook.formulaText(surface.sheetId, this.cell.row, this.cell.col);
|
|
255
|
+
}
|
|
256
|
+
surface.editor = this;
|
|
257
|
+
surface.editing(this.cell);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// The state of one `LatticeSheet`: the active sheet, the table for `LatticeGrid`, the input path
|
|
263
|
+
// (to the `Workbook` or to a `CollabSession`), the viewport watch and the peers (ADR 0017).
|
|
264
|
+
|
|
265
|
+
/** Another user on the doc: a `Peer` of `@ember-lattice/collab` fits it. */
|
|
266
|
+
|
|
267
|
+
/** The ops that go over the wire (the `CollabOp` of `@ember-lattice/collab`). */
|
|
268
|
+
|
|
269
|
+
/** The part of a `CollabSession` (`@ember-lattice/collab`) that the Sheet uses. */
|
|
270
|
+
|
|
271
|
+
/** The open cell editor: the surface tells it when another user changes its cell. */
|
|
272
|
+
|
|
273
|
+
/** The row number column. A sheet column ID cannot have a colon. */
|
|
274
|
+
const ROW_COLUMN = ':row';
|
|
275
|
+
const features = tableFeatures({
|
|
276
|
+
coreReactivityFeature: emberReactivityBindings(),
|
|
277
|
+
columnSizingFeature,
|
|
278
|
+
columnPinningFeature,
|
|
279
|
+
rowPinningFeature,
|
|
280
|
+
cellSpanningFeature,
|
|
281
|
+
cellSelectionFeature
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
/** The model ops that stay local with `@collab`: the wire has no op for them yet. */
|
|
285
|
+
const LOCAL_OPS = new Set(['addRule', 'removeRule', 'addValidation', 'removeValidation']);
|
|
286
|
+
const COLUMN_SIZE = 100;
|
|
287
|
+
/** The rows before and after the first row in view that the engine watches. */
|
|
288
|
+
const WATCH_BEFORE = 40;
|
|
289
|
+
const WATCH_AFTER = 120;
|
|
290
|
+
/** The px before and after the first column in view that the engine watches. */
|
|
291
|
+
const WATCH_LEFT = 1000;
|
|
292
|
+
const WATCH_RIGHT = 4000;
|
|
293
|
+
|
|
294
|
+
/** Reads typed text, as `Workbook.setInput` does: a formula, a number, a boolean or text. */
|
|
295
|
+
function parseInput(text) {
|
|
296
|
+
if (text === '') return {};
|
|
297
|
+
if (text.startsWith('=') && text.length > 1) return {
|
|
298
|
+
formula: text
|
|
299
|
+
};
|
|
300
|
+
const n = Number(text.trim());
|
|
301
|
+
if (text.trim() !== '' && Number.isFinite(n)) return {
|
|
302
|
+
value: n
|
|
303
|
+
};
|
|
304
|
+
const upper = text.toUpperCase();
|
|
305
|
+
if (upper === 'TRUE' || upper === 'FALSE') return {
|
|
306
|
+
value: upper === 'TRUE'
|
|
307
|
+
};
|
|
308
|
+
return {
|
|
309
|
+
value: text
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Removes the cached table value of a cell, so the next read gets the new editor text. */
|
|
314
|
+
function forget(row, col) {
|
|
315
|
+
if (is.object(row) && '_valuesCache' in row && is.object(row._valuesCache)) {
|
|
316
|
+
Reflect.deleteProperty(row._valuesCache, col);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** The ops of the inputs in flight together. The last input to finish sends them in one apply. */
|
|
321
|
+
class InputBatch {
|
|
322
|
+
open = 0;
|
|
323
|
+
ops = [];
|
|
324
|
+
#resolve;
|
|
325
|
+
#reject;
|
|
326
|
+
sent = new Promise((resolve, reject) => {
|
|
327
|
+
this.#resolve = resolve;
|
|
328
|
+
this.#reject = reject;
|
|
329
|
+
});
|
|
330
|
+
send(collab) {
|
|
331
|
+
if (this.ops.length === 0) this.#resolve();else collab.apply(this.ops).then(this.#resolve, this.#reject);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
class SheetSurface {
|
|
335
|
+
workbook;
|
|
336
|
+
collab;
|
|
337
|
+
stateHost = new GridStateHandle();
|
|
338
|
+
rowHeight;
|
|
339
|
+
/** The locale text of the surface: the row header, new sheet names and messages. */
|
|
340
|
+
locale;
|
|
341
|
+
static {
|
|
342
|
+
g(this.prototype, "sheetId", [tracked]);
|
|
343
|
+
}
|
|
344
|
+
#sheetId = (i(this, "sheetId"), void 0);
|
|
345
|
+
static {
|
|
346
|
+
g(this.prototype, "active", [tracked], function () {
|
|
347
|
+
return null;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
#active = (i(this, "active"), void 0);
|
|
351
|
+
static {
|
|
352
|
+
g(this.prototype, "peers", [tracked], function () {
|
|
353
|
+
return [];
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
#peers = (i(this, "peers"), void 0);
|
|
357
|
+
static {
|
|
358
|
+
g(this.prototype, "message", [tracked], function () {
|
|
359
|
+
return '';
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
#message = (i(this, "message"), void 0);
|
|
363
|
+
/** The last refused input, for the live region. */
|
|
364
|
+
Editor = editorFor(this);
|
|
365
|
+
/** The open cell editor, if there is one. */
|
|
366
|
+
editor = null;
|
|
367
|
+
/** The inputs in flight that go to the session together. */
|
|
368
|
+
#batch = null;
|
|
369
|
+
#unsubscribe;
|
|
370
|
+
#presence;
|
|
371
|
+
#remote;
|
|
372
|
+
#watching = false;
|
|
373
|
+
#again = false;
|
|
374
|
+
#watchKey = '';
|
|
375
|
+
#destroyed = false;
|
|
376
|
+
constructor(workbook, options) {
|
|
377
|
+
this.workbook = workbook;
|
|
378
|
+
this.locale = options.locale ?? (() => latticeLocale(undefined));
|
|
379
|
+
this.collab = options.collab;
|
|
380
|
+
this.rowHeight = options.rowHeight;
|
|
381
|
+
this.sheetId = workbook.sheets[0]?.id ?? '';
|
|
382
|
+
// The grid notifies during its own updates: read its state after them.
|
|
383
|
+
this.#unsubscribe = this.stateHost.subscribe(() => queueMicrotask(this.#sync));
|
|
384
|
+
const collab = this.collab;
|
|
385
|
+
if (collab) {
|
|
386
|
+
this.peers = collab.peers;
|
|
387
|
+
this.#presence = collab.onPresence;
|
|
388
|
+
collab.onPresence = peers => {
|
|
389
|
+
this.#presence?.(peers);
|
|
390
|
+
if (!this.#destroyed) this.peers = peers;
|
|
391
|
+
};
|
|
392
|
+
this.#remote = collab.onRemote;
|
|
393
|
+
collab.onRemote = ops => {
|
|
394
|
+
this.#remote?.(ops);
|
|
395
|
+
if (this.#destroyed) return;
|
|
396
|
+
this.#forgetOps(ops);
|
|
397
|
+
this.editor?.remoteChange();
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
queueMicrotask(this.#sync);
|
|
401
|
+
}
|
|
402
|
+
destroy() {
|
|
403
|
+
this.#destroyed = true;
|
|
404
|
+
this.#unsubscribe();
|
|
405
|
+
if (this.collab) {
|
|
406
|
+
this.collab.onPresence = this.#presence;
|
|
407
|
+
this.collab.onRemote = this.#remote;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
get sheet() {
|
|
411
|
+
return this.workbook.sheets.find(s => s.id === this.sheetId) ?? this.workbook.sheets[0];
|
|
412
|
+
}
|
|
413
|
+
select(sheetId) {
|
|
414
|
+
if (sheetId === this.sheetId) return;
|
|
415
|
+
this.sheetId = sheetId;
|
|
416
|
+
this.active = null;
|
|
417
|
+
this.#watchKey = '';
|
|
418
|
+
queueMicrotask(this.#sync);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** The 0-based index of each row ID of the active sheet. */
|
|
422
|
+
get rowIndex() {
|
|
423
|
+
return new Map(this.sheet.rows.map((id, i) => [id, i]));
|
|
424
|
+
}
|
|
425
|
+
static {
|
|
426
|
+
n(this.prototype, "rowIndex", [cached]);
|
|
427
|
+
}
|
|
428
|
+
get colIndex() {
|
|
429
|
+
return new Map(this.sheet.cols.map((id, i) => [id, i]));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** The indices of an area on the active sheet, or undefined when an end is gone. */
|
|
433
|
+
static {
|
|
434
|
+
n(this.prototype, "colIndex", [cached]);
|
|
435
|
+
}
|
|
436
|
+
bounds(area) {
|
|
437
|
+
const r0 = this.rowIndex.get(area.start.row);
|
|
438
|
+
const r1 = this.rowIndex.get(area.end.row);
|
|
439
|
+
const c0 = this.colIndex.get(area.start.col);
|
|
440
|
+
const c1 = this.colIndex.get(area.end.col);
|
|
441
|
+
if (r0 === undefined || r1 === undefined || c0 === undefined || c1 === undefined) return;
|
|
442
|
+
return {
|
|
443
|
+
r0,
|
|
444
|
+
r1,
|
|
445
|
+
c0,
|
|
446
|
+
c1
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
contains(area, row, col) {
|
|
450
|
+
const b = this.bounds(area);
|
|
451
|
+
const r = this.rowIndex.get(row) ?? -1;
|
|
452
|
+
const c = this.colIndex.get(col) ?? -1;
|
|
453
|
+
return !!b && r >= b.r0 && r <= b.r1 && c >= b.c0 && c <= b.c1;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** The A1 address of a cell, for example `B3`. */
|
|
457
|
+
address(row, col) {
|
|
458
|
+
return `${columnLabel(this.colIndex.get(col) ?? 0)}${(this.rowIndex.get(row) ?? 0) + 1}`;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** The validation of each cell, with the value, the rules and the locale that it checked. */
|
|
462
|
+
#validity = new Map();
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* The validation result of the cell value. Undefined while the check runs, and for a cell with
|
|
466
|
+
* no value or no validation. A check runs again when the value, the rules or the locale change.
|
|
467
|
+
*/
|
|
468
|
+
validity(row, col) {
|
|
469
|
+
const sheet = this.sheet;
|
|
470
|
+
const data = sheet.cell(row, col);
|
|
471
|
+
const value = data?.computed ?? data?.value;
|
|
472
|
+
if (is.nullOrUndefined(value)) return undefined;
|
|
473
|
+
if (!sheet.validations.some(v => this.contains(v.range, row, col))) return undefined;
|
|
474
|
+
const l = this.locale();
|
|
475
|
+
const locale = [l.locale, l.t('sheet.validation.oneOf'), l.t('sheet.validation.range'), l.t('sheet.validation.invalid')].join('\n');
|
|
476
|
+
const key = `${sheet.id}\n${row}\n${col}`;
|
|
477
|
+
let entry = this.#validity.get(key);
|
|
478
|
+
if (!entry || entry.value !== value || entry.rules !== sheet.validations || entry.locale !== locale) {
|
|
479
|
+
const result = new Later(this.workbook.validate(sheet.id, row, col, value, l));
|
|
480
|
+
entry = {
|
|
481
|
+
value,
|
|
482
|
+
rules: sheet.validations,
|
|
483
|
+
locale,
|
|
484
|
+
result
|
|
485
|
+
};
|
|
486
|
+
this.#validity.set(key, entry);
|
|
487
|
+
}
|
|
488
|
+
return entry.result.value;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/** True when the cell value breaks a validation of the cell. */
|
|
492
|
+
cellInvalid(row, col) {
|
|
493
|
+
return this.validity(row, col)?.ok === false;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** The text that a reader gets for the cell: the validation message and the marks of others. */
|
|
497
|
+
cellDescription(row, col) {
|
|
498
|
+
const parts = [];
|
|
499
|
+
const result = this.validity(row, col);
|
|
500
|
+
if (result && !result.ok) parts.push(result.message);
|
|
501
|
+
const peers = this.peersAt(row, col);
|
|
502
|
+
const l = this.locale();
|
|
503
|
+
if (peers.lock) parts.push(l.t('sheet.peerLock', {
|
|
504
|
+
name: peers.lock.name
|
|
505
|
+
}));else if (peers.cursor) parts.push(l.t('sheet.peerCursor', {
|
|
506
|
+
name: peers.cursor.name
|
|
507
|
+
}));else if (peers.selection) parts.push(l.t('sheet.peerSelection', {
|
|
508
|
+
name: peers.selection.name
|
|
509
|
+
}));
|
|
510
|
+
return parts.join(' ');
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** The values of the list validation of a cell, if it has one. */
|
|
514
|
+
listOptions(row, col) {
|
|
515
|
+
for (const v of this.sheet.validations) {
|
|
516
|
+
if (v.rule.kind === 'list' && this.contains(v.range, row, col)) return v.rule.values;
|
|
517
|
+
}
|
|
518
|
+
return undefined;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* The merges by their start column, as indices on the active sheet. A merge is a grid span:
|
|
523
|
+
* the start column spans the merge columns on each merge row, and the rows join one run.
|
|
524
|
+
*/
|
|
525
|
+
get mergesByCol() {
|
|
526
|
+
const out = new Map();
|
|
527
|
+
for (const m of this.sheet.merges) {
|
|
528
|
+
const b = this.bounds(m);
|
|
529
|
+
if (!b) continue;
|
|
530
|
+
const list = out.get(m.start.col) ?? [];
|
|
531
|
+
list.push({
|
|
532
|
+
r0: b.r0,
|
|
533
|
+
r1: b.r1,
|
|
534
|
+
cols: b.c1 - b.c0 + 1
|
|
535
|
+
});
|
|
536
|
+
out.set(m.start.col, list);
|
|
537
|
+
}
|
|
538
|
+
return out;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** The table for `LatticeGrid`. A new table when the rows, the columns, the panes or the merges change. */
|
|
542
|
+
static {
|
|
543
|
+
n(this.prototype, "mergesByCol", [cached]);
|
|
544
|
+
}
|
|
545
|
+
get table() {
|
|
546
|
+
const sheet = this.sheet;
|
|
547
|
+
const frozen = sheet.frozen.cols;
|
|
548
|
+
const merges = this.mergesByCol;
|
|
549
|
+
const mergeAt = (col, rowId) => {
|
|
550
|
+
const r = this.rowIndex.get(rowId) ?? -1;
|
|
551
|
+
return merges.get(col)?.find(m => r >= m.r0 && r <= m.r1);
|
|
552
|
+
};
|
|
553
|
+
// A non-literal meta: `editor` is a key that `@ember-lattice/editing` adds to the type.
|
|
554
|
+
const dataMeta = {
|
|
555
|
+
cell: SheetCell,
|
|
556
|
+
cellKind: 'full',
|
|
557
|
+
editor: this.Editor,
|
|
558
|
+
cellDescription: (row, column) => this.cellDescription(row.id, column.id),
|
|
559
|
+
cellInvalid: (row, column) => this.cellInvalid(row.id, column.id),
|
|
560
|
+
format: value => value instanceof SheetCellValue ? this.workbook.display(value.sheet, value.row, value.col).text : String(value ?? '')
|
|
561
|
+
};
|
|
562
|
+
const meta = dataMeta;
|
|
563
|
+
const columns = [
|
|
564
|
+
// The grid shows the display position; frozen rows come first, so it is the sheet row.
|
|
565
|
+
{
|
|
566
|
+
...rowNumberColumn({
|
|
567
|
+
header: this.locale().t('sheet.rowHeader'),
|
|
568
|
+
size: 48
|
|
569
|
+
}),
|
|
570
|
+
id: ROW_COLUMN
|
|
571
|
+
}, ...sheet.cols.map((col, i) => ({
|
|
572
|
+
id: col,
|
|
573
|
+
header: columnLabel(i),
|
|
574
|
+
size: COLUMN_SIZE,
|
|
575
|
+
accessorFn: ref => new SheetCellValue(this, sheet.id, ref.id, col, this.workbook.formulaText(sheet.id, ref.id, col)),
|
|
576
|
+
meta: {
|
|
577
|
+
lattice: meta
|
|
578
|
+
},
|
|
579
|
+
...(merges.has(col) && {
|
|
580
|
+
spanColumns: ({
|
|
581
|
+
row
|
|
582
|
+
}) => mergeAt(col, row.id)?.cols ?? 1,
|
|
583
|
+
spanRows: ({
|
|
584
|
+
anchorRow,
|
|
585
|
+
row
|
|
586
|
+
}) => {
|
|
587
|
+
const m = mergeAt(col, anchorRow.id);
|
|
588
|
+
return !!m && m === mergeAt(col, row.id);
|
|
589
|
+
}
|
|
590
|
+
})
|
|
591
|
+
}))];
|
|
592
|
+
return constructTable({
|
|
593
|
+
features,
|
|
594
|
+
columns,
|
|
595
|
+
data: sheet.rows.map(id => new SheetRowRef(id, this)),
|
|
596
|
+
getRowId: ref => ref.id,
|
|
597
|
+
autoResetCellSelection: false,
|
|
598
|
+
// No span index for a sheet without merges (the 100k row gate has none).
|
|
599
|
+
enableCellSpanning: merges.size > 0,
|
|
600
|
+
initialState: {
|
|
601
|
+
columnPinning: {
|
|
602
|
+
start: [ROW_COLUMN, ...sheet.cols.slice(0, frozen)],
|
|
603
|
+
end: []
|
|
604
|
+
},
|
|
605
|
+
rowPinning: {
|
|
606
|
+
top: sheet.rows.slice(0, sheet.frozen.rows),
|
|
607
|
+
bottom: []
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
static {
|
|
613
|
+
n(this.prototype, "table", [cached]);
|
|
614
|
+
}
|
|
615
|
+
columnSize(col) {
|
|
616
|
+
return this.table.getColumn(col)?.getSize() ?? COLUMN_SIZE;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** The `onCellEdit` path: a text, a moved cell (a fill), an old value (an undo) or a clear. */
|
|
620
|
+
async edit(row, col, value) {
|
|
621
|
+
forget(row, col);
|
|
622
|
+
const sheet = this.sheetId;
|
|
623
|
+
if (value instanceof SheetCellValue) {
|
|
624
|
+
const same = value.sheet === sheet && value.row === row.id && value.col === col;
|
|
625
|
+
return this.input(row.id, col, same ? value.text : this.moved(value, row.id, col));
|
|
626
|
+
}
|
|
627
|
+
if (is.string(value)) return this.input(row.id, col, value);
|
|
628
|
+
return this.input(row.id, col, is.nullOrUndefined(value) ? '' : String(value));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** The editor text of `from`, as Excel fills it into the cell at `row`, `col`. */
|
|
632
|
+
moved(from, row, col) {
|
|
633
|
+
if (!from.text.startsWith('=')) return from.text;
|
|
634
|
+
const at = (r, c) => ({
|
|
635
|
+
row: this.rowIndex.get(r) ?? 0,
|
|
636
|
+
col: this.colIndex.get(c) ?? 0
|
|
637
|
+
});
|
|
638
|
+
return fromR1C1(toR1C1(from.text, at(from.row, from.col)), at(row, col));
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** Sets a cell of the active sheet from typed text. Rejects with the validation note. */
|
|
642
|
+
async input(row, col, text) {
|
|
643
|
+
const sheet = this.sheetId;
|
|
644
|
+
forget(this.table.getRow(row, true), col);
|
|
645
|
+
if (!this.collab) {
|
|
646
|
+
const result = await this.workbook.setInput(sheet, row, col, text, this.locale());
|
|
647
|
+
if (!result.ok) {
|
|
648
|
+
this.message = result.message;
|
|
649
|
+
throw new Error(result.message);
|
|
650
|
+
}
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
// The inputs that start before the batch is sent (a paste, a fill) are one session change:
|
|
654
|
+
// one undo step.
|
|
655
|
+
const batch = this.#batch ??= new InputBatch();
|
|
656
|
+
batch.open++;
|
|
657
|
+
try {
|
|
658
|
+
batch.ops.push(await this.#opOf(sheet, row, col, text));
|
|
659
|
+
} finally {
|
|
660
|
+
if (--batch.open === 0) {
|
|
661
|
+
if (this.#batch === batch) this.#batch = null;
|
|
662
|
+
batch.send(this.collab);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
await batch.sent;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** The `setCell` op of typed text. Rejects with the validation note. */
|
|
669
|
+
async #opOf(sheet, row, col, text) {
|
|
670
|
+
const input = parseInput(text);
|
|
671
|
+
if (!input.formula && input.value !== undefined) {
|
|
672
|
+
const check = await this.workbook.validate(sheet, row, col, input.value, this.locale());
|
|
673
|
+
if (!check.ok) {
|
|
674
|
+
this.message = check.message;
|
|
675
|
+
throw new Error(check.message);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
const formula = input.formula && toStored(input.formula, sheet, this.workbook.refs());
|
|
679
|
+
return formula ? {
|
|
680
|
+
type: 'setCell',
|
|
681
|
+
sheet,
|
|
682
|
+
row,
|
|
683
|
+
col,
|
|
684
|
+
formula
|
|
685
|
+
} : {
|
|
686
|
+
type: 'setCell',
|
|
687
|
+
sheet,
|
|
688
|
+
row,
|
|
689
|
+
col,
|
|
690
|
+
value: input.value ?? null
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** Applies ops: wire ops through the session; rules and validations on the local model. */
|
|
695
|
+
async apply(ops) {
|
|
696
|
+
if (!this.collab) {
|
|
697
|
+
await this.workbook.apply(ops);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
const local = ops.filter(op => LOCAL_OPS.has(op.type));
|
|
701
|
+
const remote = ops.filter(op => !LOCAL_OPS.has(op.type));
|
|
702
|
+
if (local.length) await this.workbook.apply(local);
|
|
703
|
+
if (remote.length) await this.collab.apply(remote);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** Undo through the session (with `@collab`): later writes of other users stay. */
|
|
707
|
+
async undo() {
|
|
708
|
+
if (this.collab) this.#forgetOps(await this.collab.undo());
|
|
709
|
+
}
|
|
710
|
+
async redo() {
|
|
711
|
+
if (this.collab) this.#forgetOps(await this.collab.redo());
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** Removes the cached table values of the cells that ops wrote. */
|
|
715
|
+
#forgetOps(ops) {
|
|
716
|
+
for (const op of ops) {
|
|
717
|
+
if (op.type === 'setCell' && op.sheet === this.sheetId) {
|
|
718
|
+
forget(this.table.getRow(op.row, true), op.col);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/** Adds a sheet with 100 rows and 26 columns, and makes it active. */
|
|
724
|
+
async addSheet() {
|
|
725
|
+
const sheets = this.workbook.sheets;
|
|
726
|
+
const nameOf = n => this.locale().t('sheet.newSheetName', {
|
|
727
|
+
number: String(n)
|
|
728
|
+
});
|
|
729
|
+
let n = sheets.length + 1;
|
|
730
|
+
while (sheets.some(s => s.id === `s${n}` || s.name === nameOf(n))) n++;
|
|
731
|
+
const id = `s${n}`;
|
|
732
|
+
const ids = (p, count) => Array.from({
|
|
733
|
+
length: count
|
|
734
|
+
}, (_, i) => `${p}${i + 1}`);
|
|
735
|
+
await this.apply([{
|
|
736
|
+
type: 'addSheet',
|
|
737
|
+
id,
|
|
738
|
+
name: nameOf(n),
|
|
739
|
+
rows: ids(`${id}r`, 100),
|
|
740
|
+
cols: ids(`${id}c`, 26)
|
|
741
|
+
}]);
|
|
742
|
+
this.select(id);
|
|
743
|
+
}
|
|
744
|
+
async rename(sheetId, name) {
|
|
745
|
+
const trimmed = name.trim();
|
|
746
|
+
if (trimmed === '' || this.workbook.sheets.some(s => s.id !== sheetId && s.name === trimmed)) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
await this.apply([{
|
|
750
|
+
type: 'renameSheet',
|
|
751
|
+
id: sheetId,
|
|
752
|
+
name: trimmed
|
|
753
|
+
}]);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/** The other users at a cell: the cursor, a selection that holds it, and the soft lock. */
|
|
757
|
+
peersAt(row, col) {
|
|
758
|
+
let cursor;
|
|
759
|
+
let selection;
|
|
760
|
+
let lock;
|
|
761
|
+
const sheet = this.sheetId;
|
|
762
|
+
for (const peer of this.peers) {
|
|
763
|
+
const c = peer.cursor;
|
|
764
|
+
if (c && c.sheet === sheet && c.row === row && c.col === col) cursor = peer;
|
|
765
|
+
const s = peer.selection;
|
|
766
|
+
if (s && s.sheet === sheet && this.contains(s, row, col)) selection ??= peer;
|
|
767
|
+
const e = peer.editing;
|
|
768
|
+
if (e && e.sheet === sheet && e.row === row && e.col === col) lock = peer;
|
|
769
|
+
}
|
|
770
|
+
return {
|
|
771
|
+
cursor,
|
|
772
|
+
selection,
|
|
773
|
+
lock
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/** The cell editor opened or closed: the soft lock for the other users. */
|
|
778
|
+
editing(cell) {
|
|
779
|
+
this.collab?.setEditing(cell && {
|
|
780
|
+
sheet: this.sheetId,
|
|
781
|
+
...cell
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
#sync = () => {
|
|
785
|
+
if (this.#destroyed) return;
|
|
786
|
+
const state = this.stateHost.read();
|
|
787
|
+
const active = state.activeCell ?? null;
|
|
788
|
+
const changed = active?.rowId !== this.active?.rowId || active?.columnId !== this.active?.columnId;
|
|
789
|
+
if (changed) {
|
|
790
|
+
this.active = active;
|
|
791
|
+
if (active) forget(this.table.getRow(active.rowId, true), active.columnId);
|
|
792
|
+
this.collab?.setPresence({
|
|
793
|
+
cursor: active && {
|
|
794
|
+
sheet: this.sheetId,
|
|
795
|
+
row: active.rowId,
|
|
796
|
+
col: active.columnId
|
|
797
|
+
},
|
|
798
|
+
selection: this.#selection()
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
const first = Math.floor(this.#top() / this.rowHeight);
|
|
802
|
+
const {
|
|
803
|
+
rows,
|
|
804
|
+
cols
|
|
805
|
+
} = this.sheet.frozen;
|
|
806
|
+
const key = [this.sheetId, first, this.#firstCol(), this.sheet.rows.length, this.sheet.cols.length, rows, cols].join(':');
|
|
807
|
+
if (key !== this.#watchKey) {
|
|
808
|
+
this.#watchKey = key;
|
|
809
|
+
this.#requestWatch();
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
#top() {
|
|
813
|
+
return this.stateHost.read().scroll?.top ?? 0;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/** The index of the first center column in view, from the scroll offset and the column sizes. */
|
|
817
|
+
#firstCol() {
|
|
818
|
+
const left = this.stateHost.read().scroll?.left ?? 0;
|
|
819
|
+
const cols = this.sheet.cols;
|
|
820
|
+
let at = 0;
|
|
821
|
+
for (let i = this.sheet.frozen.cols; i < cols.length; i++) {
|
|
822
|
+
at += this.columnSize(cols[i]);
|
|
823
|
+
if (at > left) return i;
|
|
824
|
+
}
|
|
825
|
+
return cols.length;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/** The frozen columns, and the center columns from `WATCH_LEFT` px before the view. */
|
|
829
|
+
#watchCols() {
|
|
830
|
+
const cols = this.sheet.cols;
|
|
831
|
+
const frozen = this.sheet.frozen.cols;
|
|
832
|
+
const left = this.stateHost.read().scroll?.left ?? 0;
|
|
833
|
+
const out = cols.slice(0, frozen);
|
|
834
|
+
let at = 0;
|
|
835
|
+
for (let i = frozen; i < cols.length && at < left + WATCH_RIGHT; i++) {
|
|
836
|
+
const size = this.columnSize(cols[i]);
|
|
837
|
+
if (at + size > left - WATCH_LEFT) out.push(cols[i]);
|
|
838
|
+
at += size;
|
|
839
|
+
}
|
|
840
|
+
return out;
|
|
841
|
+
}
|
|
842
|
+
#selection() {
|
|
843
|
+
const range = this.table.getCellSelectionBounds().at(-1);
|
|
844
|
+
if (!range) return null;
|
|
845
|
+
const rows = this.table.getRowModel().rows;
|
|
846
|
+
const cols = this.table.getAllLeafColumns();
|
|
847
|
+
const r0 = rows[range.minRowIndex]?.id;
|
|
848
|
+
const r1 = rows[range.maxRowIndex]?.id;
|
|
849
|
+
const c0 = cols[range.minColumnIndex]?.id;
|
|
850
|
+
const c1 = cols[range.maxColumnIndex]?.id;
|
|
851
|
+
if (!r0 || !r1 || !c0 || !c1 || c0 === ROW_COLUMN) return null;
|
|
852
|
+
return {
|
|
853
|
+
sheet: this.sheetId,
|
|
854
|
+
start: {
|
|
855
|
+
row: r0,
|
|
856
|
+
col: c0
|
|
857
|
+
},
|
|
858
|
+
end: {
|
|
859
|
+
row: r1,
|
|
860
|
+
col: c1
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/** One watch call in flight; the newest range wins (ADR 0015: the engine diffs only these). */
|
|
866
|
+
#requestWatch() {
|
|
867
|
+
if (this.#watching) {
|
|
868
|
+
this.#again = true;
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
this.#watching = true;
|
|
872
|
+
void this.#runWatch();
|
|
873
|
+
}
|
|
874
|
+
async #runWatch() {
|
|
875
|
+
const engine = this.workbook.engine;
|
|
876
|
+
try {
|
|
877
|
+
do {
|
|
878
|
+
this.#again = false;
|
|
879
|
+
if (!engine.watch || this.#destroyed) return;
|
|
880
|
+
const sheet = this.sheet;
|
|
881
|
+
const first = Math.floor(this.#top() / this.rowHeight);
|
|
882
|
+
const frozen = sheet.frozen.rows;
|
|
883
|
+
const from = Math.max(frozen, first - WATCH_BEFORE);
|
|
884
|
+
const rows = [...sheet.rows.slice(0, frozen), ...sheet.rows.slice(from, first + WATCH_AFTER)];
|
|
885
|
+
const changes = await engine.watch([{
|
|
886
|
+
sheet: sheet.id,
|
|
887
|
+
rows,
|
|
888
|
+
cols: this.#watchCols()
|
|
889
|
+
}]);
|
|
890
|
+
if (this.#destroyed) return;
|
|
891
|
+
for (const {
|
|
892
|
+
sheet: id,
|
|
893
|
+
row,
|
|
894
|
+
col,
|
|
895
|
+
value
|
|
896
|
+
} of changes) {
|
|
897
|
+
this.workbook.sheets.find(s => s.id === id)?.updateCell(row, col, {
|
|
898
|
+
computed: value
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
} while (this.#again);
|
|
902
|
+
} finally {
|
|
903
|
+
this.#watching = false;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** Give it to the `EditController` of a `LatticeSheet`: `new EditController({ onCellEdit: sheetCellEdit })`. */
|
|
909
|
+
function sheetCellEdit(row, columnId, value) {
|
|
910
|
+
const ref = row.original;
|
|
911
|
+
if (!(ref instanceof SheetRowRef)) {
|
|
912
|
+
return Promise.reject(new Error('Lattice: sheetCellEdit needs a row of a LatticeSheet'));
|
|
913
|
+
}
|
|
914
|
+
return ref.surface.edit(row, columnId, value);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// LatticeSheet: the Sheet surface (plan section 4.7, ADR 0017). It renders the active sheet of a
|
|
918
|
+
// `Workbook` with `LatticeGrid` in the `sheet` preset, a formula bar with function help, sheet
|
|
919
|
+
// tabs, notes and the marks of other users.
|
|
920
|
+
/** The most functions that the help list shows. */const HELP_LIMIT = 8;
|
|
921
|
+
/** The text before the caret outside string literals, or null inside a string. */
|
|
922
|
+
function codeBefore(text, caret) {
|
|
923
|
+
const before = text.slice(0, caret);
|
|
924
|
+
return (before.match(/"/g)?.length ?? 0) % 2 === 0 ? before : null;
|
|
925
|
+
}
|
|
926
|
+
/** The function name that the user types at the caret, for example `SU` in `=1+SU`. */
|
|
927
|
+
function nameAt(text, caret) {
|
|
928
|
+
const before = codeBefore(text, caret);
|
|
929
|
+
if (!text.startsWith('=') || before === null) return null;
|
|
930
|
+
return /(?:^=|[^A-Za-z0-9_.$!:])([A-Za-z][A-Za-z0-9.]*)$/.exec(before)?.[1] ?? null;
|
|
931
|
+
}
|
|
932
|
+
/** The name of the innermost open call at the caret, for example `IF` in `=IF(A1>2, `. */
|
|
933
|
+
function callAt(text, caret) {
|
|
934
|
+
const before = codeBefore(text, caret);
|
|
935
|
+
if (!text.startsWith('=') || before === null) return null;
|
|
936
|
+
let depth = 0;
|
|
937
|
+
for (let i = before.length - 1; i >= 0; i--) {
|
|
938
|
+
const ch = before[i];
|
|
939
|
+
if (ch === ')') depth++;else if (ch === '(') {
|
|
940
|
+
if (depth === 0) return /([A-Za-z][A-Za-z0-9.]*)$/.exec(before.slice(0, i))?.[1] ?? null;
|
|
941
|
+
depth--;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
946
|
+
class LatticeSheet extends Component {
|
|
947
|
+
id = guidFor(this);
|
|
948
|
+
surface = new SheetSurface(this.args.workbook, {
|
|
949
|
+
collab: this.args.collab,
|
|
950
|
+
rowHeight: this.args.rowHeight ?? 28,
|
|
951
|
+
locale: () => this.l
|
|
952
|
+
});
|
|
953
|
+
get l() {
|
|
954
|
+
return latticeLocale(getOwner(this), this.args.localeText, this.args.locale);
|
|
955
|
+
}
|
|
956
|
+
/** The formula bar text while the user types, for one cell; null shows the active cell. */
|
|
957
|
+
static {
|
|
958
|
+
g(this.prototype, "draft", [tracked], function () {
|
|
959
|
+
return null;
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
#draft = (i(this, "draft"), void 0);
|
|
963
|
+
static {
|
|
964
|
+
g(this.prototype, "renaming", [tracked], function () {
|
|
965
|
+
return null;
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
#renaming = (i(this, "renaming"), void 0);
|
|
969
|
+
/** The sheet in a rename, or null. */
|
|
970
|
+
static {
|
|
971
|
+
g(this.prototype, "caret", [tracked], function () {
|
|
972
|
+
return 0;
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
#caret = (i(this, "caret"), void 0);
|
|
976
|
+
/** The caret position in the formula bar. */
|
|
977
|
+
static {
|
|
978
|
+
g(this.prototype, "helpIndex", [tracked], function () {
|
|
979
|
+
return 0;
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
#helpIndex = (i(this, "helpIndex"), void 0);
|
|
983
|
+
/** The index of the active option in the function list. */
|
|
984
|
+
static {
|
|
985
|
+
g(this.prototype, "helpClosed", [tracked], function () {
|
|
986
|
+
return null;
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
#helpClosed = (i(this, "helpClosed"), void 0);
|
|
990
|
+
/** The text for which the user closed the list with Escape. */
|
|
991
|
+
willDestroy() {
|
|
992
|
+
super.willDestroy();
|
|
993
|
+
this.surface.destroy();
|
|
994
|
+
}
|
|
995
|
+
get panelId() {
|
|
996
|
+
return `${this.id}-panel`;
|
|
997
|
+
}
|
|
998
|
+
get sheets() {
|
|
999
|
+
return this.args.workbook.sheets;
|
|
1000
|
+
}
|
|
1001
|
+
get renameId() {
|
|
1002
|
+
return `${this.id}-rename`;
|
|
1003
|
+
}
|
|
1004
|
+
get barId() {
|
|
1005
|
+
return `${this.id}-address`;
|
|
1006
|
+
}
|
|
1007
|
+
get listId() {
|
|
1008
|
+
return `${this.id}-functions`;
|
|
1009
|
+
}
|
|
1010
|
+
get hintId() {
|
|
1011
|
+
return `${this.id}-hint`;
|
|
1012
|
+
}
|
|
1013
|
+
optionId = index => `${this.id}-fn-${index}`;
|
|
1014
|
+
isHelpActive = index => index === this.helpIndex;
|
|
1015
|
+
/** The functions that start with the name at the caret, with their signatures. */
|
|
1016
|
+
get help() {
|
|
1017
|
+
const text = this.barText;
|
|
1018
|
+
if (this.helpClosed === text) return [];
|
|
1019
|
+
const name = nameAt(text, this.caret)?.toUpperCase();
|
|
1020
|
+
if (!name) return [];
|
|
1021
|
+
return this.args.workbook.engine.functions().filter(f => f.name.startsWith(name)).slice(0, HELP_LIMIT);
|
|
1022
|
+
}
|
|
1023
|
+
get helpOpen() {
|
|
1024
|
+
return this.help.length > 0;
|
|
1025
|
+
}
|
|
1026
|
+
get activeOption() {
|
|
1027
|
+
return this.helpOpen ? this.optionId(this.helpIndex) : undefined;
|
|
1028
|
+
}
|
|
1029
|
+
/** The signature of the call at the caret. */
|
|
1030
|
+
get hint() {
|
|
1031
|
+
const name = callAt(this.barText, this.caret)?.toUpperCase();
|
|
1032
|
+
if (!name) return undefined;
|
|
1033
|
+
const fn = this.args.workbook.engine.functions().find(f => f.name === name);
|
|
1034
|
+
return fn ? fn.signature ?? `${fn.name}()` : undefined;
|
|
1035
|
+
}
|
|
1036
|
+
get barDescribedBy() {
|
|
1037
|
+
return this.hint ? `${this.barId} ${this.hintId}` : this.barId;
|
|
1038
|
+
}
|
|
1039
|
+
signatureOf = fn => fn.signature ?? fn.name;
|
|
1040
|
+
isActive = sheet => sheet.id === this.surface.sheetId;
|
|
1041
|
+
onSelect = sheet => () => this.select(sheet);
|
|
1042
|
+
onRename = sheet => () => this.startRename(sheet);
|
|
1043
|
+
tabId = sheet => `${this.id}-tab-${sheet.id}`;
|
|
1044
|
+
get active() {
|
|
1045
|
+
return this.surface.active;
|
|
1046
|
+
}
|
|
1047
|
+
get address() {
|
|
1048
|
+
const a = this.active;
|
|
1049
|
+
return a ? this.surface.address(a.rowId, a.columnId) : '';
|
|
1050
|
+
}
|
|
1051
|
+
get editable() {
|
|
1052
|
+
const a = this.active;
|
|
1053
|
+
return !!a && this.surface.colIndex.has(a.columnId);
|
|
1054
|
+
}
|
|
1055
|
+
get cellKey() {
|
|
1056
|
+
const a = this.active;
|
|
1057
|
+
return a ? `${this.surface.sheetId}\u0000${a.rowId}\u0000${a.columnId}` : '';
|
|
1058
|
+
}
|
|
1059
|
+
get barText() {
|
|
1060
|
+
const a = this.active;
|
|
1061
|
+
// A draft of another cell does not show.
|
|
1062
|
+
if (this.draft && this.draft.key === this.cellKey) return this.draft.text;
|
|
1063
|
+
if (!a || !this.editable) return '';
|
|
1064
|
+
return this.args.workbook.formulaText(this.surface.sheetId, a.rowId, a.columnId);
|
|
1065
|
+
}
|
|
1066
|
+
/** The cell notes for the grid (`@notes`): the grid draws the mark and the note box. */
|
|
1067
|
+
notes = {
|
|
1068
|
+
noteAt: (rowId, columnId) => this.surface.sheet.cell(rowId, columnId)?.note
|
|
1069
|
+
};
|
|
1070
|
+
get peers() {
|
|
1071
|
+
return this.surface.peers;
|
|
1072
|
+
}
|
|
1073
|
+
peerPlace = peer => {
|
|
1074
|
+
const c = peer.cursor;
|
|
1075
|
+
if (!c) return '';
|
|
1076
|
+
const sheet = this.args.workbook.sheets.find(s => s.id === c.sheet);
|
|
1077
|
+
if (!sheet) return '';
|
|
1078
|
+
const where = c.sheet === this.surface.sheetId ? this.surface.address(c.row, c.col) : sheet.name;
|
|
1079
|
+
return peer.editing ? this.l.t('sheet.peerEditing', {
|
|
1080
|
+
place: where
|
|
1081
|
+
}) : where;
|
|
1082
|
+
};
|
|
1083
|
+
onBarInput = event => {
|
|
1084
|
+
if (event.target instanceof HTMLInputElement) {
|
|
1085
|
+
this.draft = {
|
|
1086
|
+
key: this.cellKey,
|
|
1087
|
+
text: event.target.value
|
|
1088
|
+
};
|
|
1089
|
+
this.readCaret(event);
|
|
1090
|
+
this.helpIndex = 0;
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
readCaret = event => {
|
|
1094
|
+
if (event.target instanceof HTMLInputElement) {
|
|
1095
|
+
this.caret = event.target.selectionStart ?? event.target.value.length;
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
/** Puts `NAME(` in place of the typed name, and the caret after it. */
|
|
1099
|
+
insertFunction = fn => {
|
|
1100
|
+
const text = this.barText;
|
|
1101
|
+
const name = nameAt(text, this.caret) ?? '';
|
|
1102
|
+
const start = this.caret - name.length;
|
|
1103
|
+
const next = `${text.slice(0, start)}${fn.name}(${text.slice(this.caret)}`;
|
|
1104
|
+
const caret = start + fn.name.length + 1;
|
|
1105
|
+
this.draft = {
|
|
1106
|
+
key: this.cellKey,
|
|
1107
|
+
text: next
|
|
1108
|
+
};
|
|
1109
|
+
this.caret = caret;
|
|
1110
|
+
this.helpIndex = 0;
|
|
1111
|
+
void renderSettled().then(() => {
|
|
1112
|
+
const input = document.querySelector(`#${this.id} .lt-sheet-formula`);
|
|
1113
|
+
if (input instanceof HTMLInputElement) input.setSelectionRange(caret, caret);
|
|
1114
|
+
});
|
|
1115
|
+
};
|
|
1116
|
+
onOptionDown = fn => event => {
|
|
1117
|
+
// Keep the focus in the bar.
|
|
1118
|
+
event.preventDefault();
|
|
1119
|
+
this.insertFunction(fn);
|
|
1120
|
+
};
|
|
1121
|
+
/** The list keys: the arrows move, Enter and Tab insert, Escape closes. True when handled. */
|
|
1122
|
+
helpKey(event) {
|
|
1123
|
+
const help = this.help;
|
|
1124
|
+
if (help.length === 0) return false;
|
|
1125
|
+
const step = event.key === 'ArrowDown' ? 1 : event.key === 'ArrowUp' ? -1 : 0;
|
|
1126
|
+
if (step) this.helpIndex = (this.helpIndex + step + help.length) % help.length;else if (event.key === 'Enter' || event.key === 'Tab') {
|
|
1127
|
+
this.insertFunction(help[this.helpIndex] ?? help[0]);
|
|
1128
|
+
} else if (event.key === 'Escape') this.helpClosed = this.barText;else return false;
|
|
1129
|
+
event.preventDefault();
|
|
1130
|
+
return true;
|
|
1131
|
+
}
|
|
1132
|
+
onBarKey = async event => {
|
|
1133
|
+
if (this.helpKey(event)) return;
|
|
1134
|
+
if (event.key === 'Escape') {
|
|
1135
|
+
this.draft = null;
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
if (event.key !== 'Enter') return;
|
|
1139
|
+
event.preventDefault();
|
|
1140
|
+
const a = this.active;
|
|
1141
|
+
const draft = this.draft;
|
|
1142
|
+
if (!a || !draft || draft.key !== this.cellKey) return;
|
|
1143
|
+
const text = draft.text;
|
|
1144
|
+
this.draft = null;
|
|
1145
|
+
try {
|
|
1146
|
+
await this.surface.input(a.rowId, a.columnId, text);
|
|
1147
|
+
} catch {
|
|
1148
|
+
// The surface keeps the message for the live region.
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
/** The keys of the grid panel: undo and redo with `@collab`. The grid owns Ctrl+D and Ctrl+R. */
|
|
1152
|
+
onPanelKey = event => {
|
|
1153
|
+
if (!(event.ctrlKey || event.metaKey) || event.altKey) return;
|
|
1154
|
+
const target = event.target;
|
|
1155
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLSelectElement) return;
|
|
1156
|
+
const key = event.key.toLowerCase();
|
|
1157
|
+
// With `@collab`, Ctrl+Z and Ctrl+Y (or Ctrl+Shift+Z) go to the session, not the editor stack.
|
|
1158
|
+
if (!this.args.collab || key !== 'z' && key !== 'y') return;
|
|
1159
|
+
event.preventDefault();
|
|
1160
|
+
event.stopPropagation();
|
|
1161
|
+
void (key === 'y' || event.shiftKey ? this.surface.redo() : this.surface.undo());
|
|
1162
|
+
};
|
|
1163
|
+
select = sheet => {
|
|
1164
|
+
this.renaming = null;
|
|
1165
|
+
this.draft = null;
|
|
1166
|
+
this.surface.select(sheet.id);
|
|
1167
|
+
};
|
|
1168
|
+
onTabKey = event => {
|
|
1169
|
+
const sheets = this.args.workbook.sheets;
|
|
1170
|
+
const at = sheets.findIndex(s => s.id === this.surface.sheetId);
|
|
1171
|
+
const step = event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0;
|
|
1172
|
+
if (step === 0) return;
|
|
1173
|
+
event.preventDefault();
|
|
1174
|
+
const sheet = sheets[(at + step + sheets.length) % sheets.length];
|
|
1175
|
+
this.select(sheet);
|
|
1176
|
+
void renderSettled().then(() => document.getElementById(this.tabId(sheet))?.focus());
|
|
1177
|
+
};
|
|
1178
|
+
startRename = sheet => {
|
|
1179
|
+
this.renaming = sheet;
|
|
1180
|
+
void renderSettled().then(() => {
|
|
1181
|
+
const input = document.getElementById(this.renameId);
|
|
1182
|
+
if (input instanceof HTMLInputElement) {
|
|
1183
|
+
input.focus();
|
|
1184
|
+
input.select();
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
};
|
|
1188
|
+
onRenameKey = async event => {
|
|
1189
|
+
const sheet = this.renaming;
|
|
1190
|
+
if (!sheet || !(event.target instanceof HTMLInputElement)) return;
|
|
1191
|
+
if (event.key === 'Escape') this.renaming = null;
|
|
1192
|
+
if (event.key !== 'Enter') return;
|
|
1193
|
+
event.preventDefault();
|
|
1194
|
+
const name = event.target.value;
|
|
1195
|
+
this.renaming = null;
|
|
1196
|
+
await this.surface.rename(sheet.id, name);
|
|
1197
|
+
};
|
|
1198
|
+
addSheet = async () => {
|
|
1199
|
+
this.renaming = null;
|
|
1200
|
+
await this.surface.addSheet();
|
|
1201
|
+
};
|
|
1202
|
+
static {
|
|
1203
|
+
setComponentTemplate(precompileTemplate("<div class=\"lt-sheet\" id={{this.id}} role=\"group\" aria-label={{@label}} ...attributes>\n <div class=\"lt-sheet-bar\">\n <span class=\"lt-sheet-address\" id={{this.barId}}>{{this.address}}</span>\n <input class=\"lt-sheet-formula\" role=\"combobox\" aria-label={{this.l.t \"sheet.formula\"}} aria-describedby={{this.barDescribedBy}} aria-autocomplete=\"list\" aria-expanded={{if this.helpOpen \"true\" \"false\"}} aria-controls={{if this.helpOpen this.listId}} aria-activedescendant={{this.activeOption}} spellcheck=\"false\" autocomplete=\"off\" value={{this.barText}} disabled={{if this.editable false true}} {{on \"input\" this.onBarInput}} {{on \"keydown\" this.onBarKey}} {{on \"keyup\" this.readCaret}} {{on \"click\" this.readCaret}} />\n </div>\n {{#if this.helpOpen}}\n {{!-- lt-sheet-note: the theme places it as a popup under the bar. --}}\n <ul class=\"lt-sheet-note lt-sheet-help\" role=\"listbox\" id={{this.listId}} aria-label={{this.l.t \"sheet.functions\"}}>\n {{#each this.help as |fn index|}}\n <li class=\"lt-sheet-fn\" role=\"option\" id={{this.optionId index}} aria-selected={{if (this.isHelpActive index) \"true\" \"false\"}} {{on \"mousedown\" (this.onOptionDown fn)}}>{{this.signatureOf fn}}</li>\n {{/each}}\n </ul>\n {{/if}}\n {{#if this.hint}}\n <div class=\"lt-sheet-hint\" role=\"tooltip\" id={{this.hintId}}>{{this.hint}}</div>\n {{/if}}\n <div class=\"lt-sheet-panel\" role=\"tabpanel\" id={{this.panelId}} aria-labelledby={{this.tabId this.surface.sheet}} {{on \"keydown\" this.onPanelKey capture=true}}>\n <LatticeGrid @table={{this.surface.table}} @label={{@label}} @rowHeight={{this.surface.rowHeight}} @editing={{@editing}} @stateHost={{this.surface.stateHost}} @notes={{this.notes}} data-lt-preset=\"sheet\" data-lt-borders=\"cells\" />\n </div>\n <div class=\"lt-sheet-tabs\">\n <div role=\"tablist\" aria-label={{this.l.t \"sheet.tabs\"}} {{on \"keydown\" this.onTabKey}}>\n {{#each this.sheets as |sheet|}}\n <button type=\"button\" role=\"tab\" class=\"lt-sheet-tab\" id={{this.tabId sheet}} aria-selected={{if (this.isActive sheet) \"true\" \"false\"}} aria-controls={{this.panelId}} tabindex={{if (this.isActive sheet) \"0\" \"-1\"}} {{on \"click\" (this.onSelect sheet)}} {{on \"dblclick\" (this.onRename sheet)}}>{{sheet.name}}</button>\n {{/each}}\n </div>\n {{#if this.renaming}}\n <input class=\"lt-sheet-rename\" id={{this.renameId}} aria-label={{this.l.t \"sheet.sheetName\"}} value={{this.renaming.name}} {{on \"keydown\" this.onRenameKey}} />\n {{/if}}\n <button type=\"button\" class=\"lt-sheet-add\" {{on \"click\" this.addSheet}}>{{this.l.t \"sheet.addSheet\"}}</button>\n {{#if this.peers.length}}\n <ul class=\"lt-sheet-peers\" aria-label={{this.l.t \"sheet.otherUsers\"}}>\n {{#each this.peers as |peer|}}\n <li class=\"lt-sheet-peer\">{{peer.name}}\n <span class=\"lt-sheet-peer-place\">{{this.peerPlace peer}}</span></li>\n {{/each}}\n </ul>\n {{/if}}\n </div>\n <div class=\"lt-sheet-live\" role=\"status\" aria-label={{this.l.t \"sheet.messages\"}}>{{this.surface.message}}</div>\n</div>", {
|
|
1204
|
+
strictMode: true,
|
|
1205
|
+
scope: () => ({
|
|
1206
|
+
on,
|
|
1207
|
+
LatticeGrid
|
|
1208
|
+
})
|
|
1209
|
+
}), this);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export { LatticeSheet, ROW_COLUMN, SheetCellValue, SheetRowRef, SheetSurface, sheetCellEdit };
|
|
1214
|
+
//# sourceMappingURL=index.js.map
|