@dxos/plugin-sheet 0.8.2-main.f11618f → 0.8.2-staging.42af850
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/dist/lib/browser/SheetContainer-GXPG3ZDN.mjs +351 -0
- package/dist/lib/browser/SheetContainer-GXPG3ZDN.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-CUTFYIT4.mjs +24 -0
- package/dist/lib/browser/anchor-sort-CUTFYIT4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HRTIOTK7.mjs → chunk-5FLX3UGU.mjs} +53 -61
- package/dist/lib/browser/chunk-5FLX3UGU.mjs.map +7 -0
- package/dist/lib/browser/chunk-AYMJXZFS.mjs +847 -0
- package/dist/lib/browser/chunk-AYMJXZFS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-AT5ZK6JD.mjs → chunk-FJRLDX7Z.mjs} +1 -1
- package/dist/lib/browser/chunk-FJRLDX7Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EMSCNWEK.mjs → chunk-IR42IS3F.mjs} +2 -2
- package/dist/lib/{node-esm/chunk-76T5X4VP.mjs.map → browser/chunk-IR42IS3F.mjs.map} +1 -1
- package/dist/lib/browser/{compute-graph-registry-WEJLJJ6T.mjs → compute-graph-registry-IXGGJJBU.mjs} +3 -3
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +15 -14
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-OMXW6BDZ.mjs → intent-resolver-UI4DHURQ.mjs} +2 -2
- package/dist/lib/browser/{markdown-DR4RDEEY.mjs → markdown-T4TUP4BF.mjs} +4 -4
- package/dist/lib/browser/markdown-T4TUP4BF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-RTQDRQ4X.mjs → react-surface-KI6T5M2X.mjs} +5 -5
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/SheetContainer-UUDOHLZR.cjs +351 -0
- package/dist/lib/node/SheetContainer-UUDOHLZR.cjs.map +7 -0
- package/dist/lib/node/{thread-NVEWN3H2.cjs → anchor-sort-LTLYUTUP.cjs} +17 -10
- package/dist/lib/node/anchor-sort-LTLYUTUP.cjs.map +7 -0
- package/dist/lib/node/{chunk-C3Q4GSES.cjs → chunk-76NESQLB.cjs} +69 -77
- package/dist/lib/node/chunk-76NESQLB.cjs.map +7 -0
- package/dist/lib/node/chunk-BXBNSNDK.cjs +855 -0
- package/dist/lib/node/chunk-BXBNSNDK.cjs.map +7 -0
- package/dist/lib/node/{chunk-LEV7OSTK.cjs → chunk-FIM6EZ6M.cjs} +4 -4
- package/dist/lib/node/chunk-FIM6EZ6M.cjs.map +7 -0
- package/dist/lib/node/{chunk-O2FOEUYB.cjs → chunk-LJWWS53Z.cjs} +5 -5
- package/dist/lib/node/{chunk-O2FOEUYB.cjs.map → chunk-LJWWS53Z.cjs.map} +1 -1
- package/dist/lib/node/{compute-graph-registry-VVSRJUGS.cjs → compute-graph-registry-ARLDHPFW.cjs} +7 -7
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs.map +7 -0
- package/dist/lib/node/index.cjs +21 -20
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-KI5DG7LR.cjs → intent-resolver-EVLGL7VZ.cjs} +9 -9
- package/dist/lib/node/{markdown-E7OUIMZO.cjs → markdown-DBPOAYI7.cjs} +8 -8
- package/dist/lib/node/markdown-DBPOAYI7.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-ZDOTWZ4Q.cjs → react-surface-QHAPOAR2.cjs} +14 -14
- package/dist/lib/node/types/index.cjs +29 -29
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/SheetContainer-44KHKMPI.mjs +352 -0
- package/dist/lib/node-esm/SheetContainer-44KHKMPI.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-3E2VGLO6.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-3E2VGLO6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SWRUEW6J.mjs → chunk-DIF3IOAB.mjs} +53 -61
- package/dist/lib/node-esm/chunk-DIF3IOAB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GCCM7R45.mjs +848 -0
- package/dist/lib/node-esm/chunk-GCCM7R45.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-76T5X4VP.mjs → chunk-IQ76YE6M.mjs} +2 -2
- package/dist/lib/{browser/chunk-EMSCNWEK.mjs.map → node-esm/chunk-IQ76YE6M.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-HXBUY5ET.mjs → chunk-NMCVJWDT.mjs} +1 -1
- package/dist/lib/node-esm/chunk-NMCVJWDT.mjs.map +7 -0
- package/dist/lib/node-esm/{compute-graph-registry-PBQ52KH6.mjs → compute-graph-registry-7PDWXMHF.mjs} +3 -3
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +15 -14
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-3FVOBB3K.mjs → intent-resolver-TPOH5JM5.mjs} +2 -2
- package/dist/lib/node-esm/{markdown-BPKS2TNG.mjs → markdown-WWUJ3E5F.mjs} +4 -4
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-T4OVUZY2.mjs → react-surface-XT2J3S67.mjs} +5 -5
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +2 -2
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +2 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +3 -2
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +2 -2
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +4 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +3 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +2 -3
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -6
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -54
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +38 -374
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +36 -36
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -48
- package/src/SheetPlugin.tsx +7 -5
- package/src/capabilities/anchor-sort.ts +22 -0
- package/src/capabilities/compute-graph-registry.ts +3 -3
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/markdown.ts +3 -3
- package/src/components/ComputeGraph/compute-graph.stories.tsx +2 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +1 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +5 -2
- package/src/components/GridSheet/GridSheet.tsx +18 -12
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +2 -2
- package/src/components/GridSheet/util.ts +17 -11
- package/src/components/RangeList/RangeList.tsx +2 -2
- package/src/components/SheetContainer/SheetContainer.stories.tsx +3 -6
- package/src/components/SheetContainer/SheetContainer.tsx +5 -8
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +2 -2
- package/src/components/SheetToolbar/SheetToolbar.tsx +56 -20
- package/src/components/SheetToolbar/align.ts +44 -14
- package/src/components/SheetToolbar/style.ts +48 -12
- package/src/components/SheetToolbar/useToolbarState.ts +1 -2
- package/src/extensions/compute.ts +1 -1
- package/src/integrations/thread-ranges.ts +14 -17
- package/src/model/sheet-model.test.ts +1 -1
- package/src/model/sheet-model.ts +17 -17
- package/src/sanity.test.ts +1 -1
- package/src/serializer.ts +1 -2
- package/src/testing/playwright/sheet-manager.ts +9 -9
- package/src/types/schema.ts +20 -22
- package/src/types/types.ts +25 -25
- package/src/types/util.ts +0 -1
- package/dist/lib/browser/SheetContainer-7DK3ZZUT.mjs +0 -370
- package/dist/lib/browser/SheetContainer-7DK3ZZUT.mjs.map +0 -7
- package/dist/lib/browser/chunk-AT5ZK6JD.mjs.map +0 -7
- package/dist/lib/browser/chunk-HRTIOTK7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IE42HBFC.mjs +0 -815
- package/dist/lib/browser/chunk-IE42HBFC.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-WEJLJJ6T.mjs.map +0 -7
- package/dist/lib/browser/markdown-DR4RDEEY.mjs.map +0 -7
- package/dist/lib/browser/thread-HV32Z27A.mjs +0 -17
- package/dist/lib/browser/thread-HV32Z27A.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-6RPY4P7E.cjs +0 -364
- package/dist/lib/node/SheetContainer-6RPY4P7E.cjs.map +0 -7
- package/dist/lib/node/chunk-C3Q4GSES.cjs.map +0 -7
- package/dist/lib/node/chunk-LEV7OSTK.cjs.map +0 -7
- package/dist/lib/node/chunk-UXSU6W7E.cjs +0 -822
- package/dist/lib/node/chunk-UXSU6W7E.cjs.map +0 -7
- package/dist/lib/node/compute-graph-registry-VVSRJUGS.cjs.map +0 -7
- package/dist/lib/node/markdown-E7OUIMZO.cjs.map +0 -7
- package/dist/lib/node/thread-NVEWN3H2.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-QQUB22WF.mjs +0 -371
- package/dist/lib/node-esm/SheetContainer-QQUB22WF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HXBUY5ET.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JSVXC3QP.mjs +0 -816
- package/dist/lib/node-esm/chunk-JSVXC3QP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SWRUEW6J.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-PBQ52KH6.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-BPKS2TNG.mjs.map +0 -7
- package/dist/lib/node-esm/thread-DTWGGMW4.mjs +0 -18
- package/dist/lib/node-esm/thread-DTWGGMW4.mjs.map +0 -7
- package/dist/types/src/capabilities/thread.d.ts +0 -6
- package/dist/types/src/capabilities/thread.d.ts.map +0 -1
- package/dist/types/src/components/SheetToolbar/comment.d.ts +0 -23
- package/dist/types/src/components/SheetToolbar/comment.d.ts.map +0 -1
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +0 -8
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +0 -1
- package/src/capabilities/thread.ts +0 -14
- package/src/components/SheetToolbar/comment.ts +0 -56
- package/src/components/SheetToolbar/useToolbarAction.ts +0 -87
- /package/dist/lib/browser/{intent-resolver-OMXW6BDZ.mjs.map → intent-resolver-UI4DHURQ.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-RTQDRQ4X.mjs.map → react-surface-KI6T5M2X.mjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-KI5DG7LR.cjs.map → intent-resolver-EVLGL7VZ.cjs.map} +0 -0
- /package/dist/lib/node/{react-surface-ZDOTWZ4Q.cjs.map → react-surface-QHAPOAR2.cjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-3FVOBB3K.mjs.map → intent-resolver-TPOH5JM5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-T4OVUZY2.mjs.map → react-surface-XT2J3S67.mjs.map} +0 -0
package/src/model/sheet-model.ts
CHANGED
|
@@ -119,7 +119,7 @@ export class SheetModel extends Resource {
|
|
|
119
119
|
/**
|
|
120
120
|
* Initialize sheet and engine.
|
|
121
121
|
*/
|
|
122
|
-
protected override async _open() {
|
|
122
|
+
protected override async _open(): Promise<void> {
|
|
123
123
|
log('initialize', { id: this.id });
|
|
124
124
|
initialize(this._sheet);
|
|
125
125
|
|
|
@@ -145,7 +145,7 @@ export class SheetModel extends Resource {
|
|
|
145
145
|
* NOTE: This resets the undo history.
|
|
146
146
|
* @deprecated
|
|
147
147
|
*/
|
|
148
|
-
reset() {
|
|
148
|
+
reset(): void {
|
|
149
149
|
invariant(this._node);
|
|
150
150
|
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
151
151
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
@@ -173,17 +173,17 @@ export class SheetModel extends Resource {
|
|
|
173
173
|
* @deprecated
|
|
174
174
|
*/
|
|
175
175
|
// TODO(burdon): Remove.
|
|
176
|
-
recalculate() {
|
|
176
|
+
recalculate(): void {
|
|
177
177
|
this._node?.graph.hf.rebuildAndRecalculate();
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
insertRows(i: number, n = 1) {
|
|
180
|
+
insertRows(i: number, n = 1): string[] {
|
|
181
181
|
const idx = insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
182
182
|
this.reset();
|
|
183
183
|
return idx;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
insertColumns(i: number, n = 1) {
|
|
186
|
+
insertColumns(i: number, n = 1): string[] {
|
|
187
187
|
const idx = insertIndices(this._sheet.columns, i, n, MAX_COLS);
|
|
188
188
|
this.reset();
|
|
189
189
|
return idx;
|
|
@@ -217,7 +217,7 @@ export class SheetModel extends Resource {
|
|
|
217
217
|
return { axis: 'col', index, axisIndex: colIndex, axisMeta: this._sheet.rowMeta[colIndex], values };
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
restoreRow({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis) {
|
|
220
|
+
restoreRow({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
|
|
221
221
|
this._sheet.rows.splice(index, 0, axisIndex);
|
|
222
222
|
values.forEach((value, col) => {
|
|
223
223
|
if (value) {
|
|
@@ -230,7 +230,7 @@ export class SheetModel extends Resource {
|
|
|
230
230
|
this.reset();
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
restoreColumn({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis) {
|
|
233
|
+
restoreColumn({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
|
|
234
234
|
this._sheet.columns.splice(index, 0, axisIndex);
|
|
235
235
|
values.forEach((value, row) => {
|
|
236
236
|
if (value) {
|
|
@@ -251,7 +251,7 @@ export class SheetModel extends Resource {
|
|
|
251
251
|
/**
|
|
252
252
|
* Clear range of values.
|
|
253
253
|
*/
|
|
254
|
-
clear(range: CellRange) {
|
|
254
|
+
clear(range: CellRange): void {
|
|
255
255
|
invariant(this._node);
|
|
256
256
|
const topLeft = getTopLeft(range);
|
|
257
257
|
const values = this._iterRange(range, () => null);
|
|
@@ -262,7 +262,7 @@ export class SheetModel extends Resource {
|
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
cut(range: CellRange) {
|
|
265
|
+
cut(range: CellRange): void {
|
|
266
266
|
invariant(this._node);
|
|
267
267
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
268
268
|
this._iterRange(range, (cell) => {
|
|
@@ -271,12 +271,12 @@ export class SheetModel extends Resource {
|
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
copy(range: CellRange) {
|
|
274
|
+
copy(range: CellRange): void {
|
|
275
275
|
invariant(this._node);
|
|
276
276
|
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
paste(cell: CellAddress) {
|
|
279
|
+
paste(cell: CellAddress): void {
|
|
280
280
|
invariant(this._node);
|
|
281
281
|
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
282
282
|
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
@@ -291,7 +291,7 @@ export class SheetModel extends Resource {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
// TODO(burdon): Display undo/redo state.
|
|
294
|
-
undo() {
|
|
294
|
+
undo(): void {
|
|
295
295
|
invariant(this._node);
|
|
296
296
|
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
297
297
|
this._node.graph.hf.undo();
|
|
@@ -299,7 +299,7 @@ export class SheetModel extends Resource {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
redo() {
|
|
302
|
+
redo(): void {
|
|
303
303
|
invariant(this._node);
|
|
304
304
|
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
305
305
|
this._node.graph.hf.redo();
|
|
@@ -368,7 +368,7 @@ export class SheetModel extends Resource {
|
|
|
368
368
|
/**
|
|
369
369
|
* Sets the value, updating the sheet and engine.
|
|
370
370
|
*/
|
|
371
|
-
setValue(cell: CellAddress, value: CellScalarValue) {
|
|
371
|
+
setValue(cell: CellAddress, value: CellScalarValue): void {
|
|
372
372
|
invariant(this._node);
|
|
373
373
|
if (this._options.readonly) {
|
|
374
374
|
throw new ReadonlyException();
|
|
@@ -411,7 +411,7 @@ export class SheetModel extends Resource {
|
|
|
411
411
|
/**
|
|
412
412
|
* Sets values from a simple map.
|
|
413
413
|
*/
|
|
414
|
-
setValues(values: Record<string, CellValue>) {
|
|
414
|
+
setValues(values: Record<string, CellValue>): void {
|
|
415
415
|
Object.entries(values).forEach(([key, { value }]) => {
|
|
416
416
|
this.setValue(addressFromA1Notation(key), value);
|
|
417
417
|
});
|
|
@@ -441,12 +441,12 @@ export class SheetModel extends Resource {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
// TODO(burdon): Delete index.
|
|
444
|
-
private _deleteIndices(indices: string[], i: number, n: number) {
|
|
444
|
+
private _deleteIndices(indices: string[], i: number, n: number): void {
|
|
445
445
|
throw new Error('Not implemented');
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
449
|
-
private _moveIndices(indices: string[], i: number, j: number, n: number) {
|
|
449
|
+
private _moveIndices(indices: string[], i: number, j: number, n: number): void {
|
|
450
450
|
throw new Error('Not implemented');
|
|
451
451
|
}
|
|
452
452
|
|
package/src/sanity.test.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { describe, test, expect } from 'vitest';
|
|
|
12
12
|
|
|
13
13
|
import { Client } from '@dxos/client';
|
|
14
14
|
import { live } from '@dxos/client/echo';
|
|
15
|
-
import { FunctionType } from '@dxos/functions
|
|
15
|
+
import { FunctionType } from '@dxos/functions';
|
|
16
16
|
|
|
17
17
|
// TODO(burdon): Fix test infrastructure:
|
|
18
18
|
// - Need docs? esp. needed for config. need pristine example package?
|
package/src/serializer.ts
CHANGED
|
@@ -9,8 +9,7 @@ import { SheetType } from './types';
|
|
|
9
9
|
|
|
10
10
|
export const serializer: TypedObjectSerializer<SheetType> = {
|
|
11
11
|
serialize: async ({ object }): Promise<string> => {
|
|
12
|
-
|
|
13
|
-
return JSON.stringify(sheet, null, 2);
|
|
12
|
+
return JSON.stringify(object, null, 2);
|
|
14
13
|
},
|
|
15
14
|
|
|
16
15
|
deserialize: async ({ content, newId }) => {
|
|
@@ -25,21 +25,21 @@ export class SheetManager {
|
|
|
25
25
|
return this.cellByText('Ready').waitFor({ state: 'visible' });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async fill(text: string) {
|
|
28
|
+
async fill(text: string): Promise<void> {
|
|
29
29
|
// TODO(thure): Do these timeouts help with test flakiness?
|
|
30
30
|
await this.page.waitForTimeout(200);
|
|
31
31
|
await this.cellEditor().fill(text);
|
|
32
32
|
await this.page.waitForTimeout(200);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async press(key: string) {
|
|
35
|
+
async press(key: string): Promise<void> {
|
|
36
36
|
// TODO(thure): Does these timeouts help with test flakiness?
|
|
37
37
|
await this.page.waitForTimeout(200);
|
|
38
38
|
await this.page.keyboard.press(key);
|
|
39
39
|
await this.page.waitForTimeout(200);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async commit(key: string) {
|
|
42
|
+
async commit(key: string): Promise<void> {
|
|
43
43
|
// TODO(thure): Why do we need to wait? Enter is ignored otherwise…
|
|
44
44
|
await this.page.waitForTimeout(500);
|
|
45
45
|
await this.press(key);
|
|
@@ -49,7 +49,7 @@ export class SheetManager {
|
|
|
49
49
|
return this.grid.grid.getByText(text);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
async setFocusedCellValue(text: string, commitKey: string) {
|
|
52
|
+
async setFocusedCellValue(text: string, commitKey: string): Promise<void> {
|
|
53
53
|
const mode = await this.grid.mode();
|
|
54
54
|
if (mode === 'browse') {
|
|
55
55
|
await this.commit('Enter');
|
|
@@ -58,7 +58,7 @@ export class SheetManager {
|
|
|
58
58
|
await this.commit(commitKey);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async selectRange(start: DxGridPosition, end: DxGridPosition) {
|
|
61
|
+
async selectRange(start: DxGridPosition, end: DxGridPosition): Promise<void> {
|
|
62
62
|
const startCell = this.grid.cell(start.col, start.row, start.plane);
|
|
63
63
|
const endCell = this.grid.cell(end.col, end.row, end.plane);
|
|
64
64
|
const startBox = await startCell.boundingBox();
|
|
@@ -69,7 +69,7 @@ export class SheetManager {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
async deleteAxis(axis: DxGridAxis, position: number) {
|
|
72
|
+
async deleteAxis(axis: DxGridAxis, position: number): Promise<void> {
|
|
73
73
|
const col = axis === 'row' ? 0 : position;
|
|
74
74
|
const row = axis === 'row' ? position : 0;
|
|
75
75
|
const plane = axis === 'row' ? 'frozenColsStart' : 'frozenRowsStart';
|
|
@@ -77,15 +77,15 @@ export class SheetManager {
|
|
|
77
77
|
await this.page.getByTestId(`grid.${axis}.drop`).click();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
toolbarAction(key: string, value: string) {
|
|
80
|
+
toolbarAction(key: string, value: string): Locator {
|
|
81
81
|
return this.page.getByTestId(`grid.toolbar.${key}.${value}`);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
cellEditor() {
|
|
84
|
+
cellEditor(): Locator {
|
|
85
85
|
return this.page.getByTestId('grid.cell-editor').getByRole('textbox');
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
rangeInList(a1Coords: string) {
|
|
88
|
+
rangeInList(a1Coords: string): Locator {
|
|
89
89
|
return this.page.getByTestId('grid.range-list').getByText(a1Coords);
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/types/schema.ts
CHANGED
|
@@ -2,55 +2,53 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { ThreadType } from '@dxos/plugin-space/types';
|
|
5
|
+
import { Schema } from 'effect';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
import { TypedObject } from '@dxos/echo-schema';
|
|
8
|
+
|
|
9
|
+
export const CellValue = Schema.Struct({
|
|
9
10
|
// TODO(burdon): How to store dates (datetime, date, time), percentages, etc.
|
|
10
11
|
// Consider import/export; natural access for other plugins. Special handling for currency (precision).
|
|
11
12
|
// TODO(burdon): Automerge (long string) or short string or number.
|
|
12
|
-
value:
|
|
13
|
+
value: Schema.Any,
|
|
13
14
|
});
|
|
14
15
|
|
|
15
|
-
export type CellValue =
|
|
16
|
+
export type CellValue = Schema.Schema.Type<typeof CellValue>;
|
|
16
17
|
|
|
17
18
|
// TODO(burdon): IMPORTANT: Reconcile with Field definition.
|
|
18
|
-
export const Range =
|
|
19
|
-
range:
|
|
20
|
-
key:
|
|
21
|
-
value:
|
|
19
|
+
export const Range = Schema.Struct({
|
|
20
|
+
range: Schema.String,
|
|
21
|
+
key: Schema.String,
|
|
22
|
+
value: Schema.String,
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
export type Range =
|
|
25
|
+
export type Range = Schema.Schema.Type<typeof Range>;
|
|
25
26
|
|
|
26
27
|
// TODO(burdon): Visibility, locked, frozen, etc.
|
|
27
|
-
export const RowColumnMeta =
|
|
28
|
-
size:
|
|
28
|
+
export const RowColumnMeta = Schema.Struct({
|
|
29
|
+
size: Schema.optional(Schema.Number),
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
// TODO(burdon): Reconcile col/column (across packages).
|
|
32
33
|
// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.
|
|
33
34
|
export class SheetType extends TypedObject({ typename: 'dxos.org/type/Sheet', version: '0.1.0' })({
|
|
34
|
-
name:
|
|
35
|
+
name: Schema.optional(Schema.String),
|
|
35
36
|
|
|
36
37
|
// Sparse map of cells referenced by index.
|
|
37
|
-
cells:
|
|
38
|
+
cells: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(CellValue) })),
|
|
38
39
|
|
|
39
40
|
// Ordered row indices.
|
|
40
|
-
rows:
|
|
41
|
+
rows: Schema.mutable(Schema.Array(Schema.String)),
|
|
41
42
|
|
|
42
43
|
// Ordered column indices.
|
|
43
|
-
columns:
|
|
44
|
+
columns: Schema.mutable(Schema.Array(Schema.String)),
|
|
44
45
|
|
|
45
46
|
// Row metadata referenced by index.
|
|
46
|
-
rowMeta:
|
|
47
|
+
rowMeta: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(RowColumnMeta) })),
|
|
47
48
|
|
|
48
49
|
// Column metadata referenced by index.
|
|
49
|
-
columnMeta:
|
|
50
|
+
columnMeta: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(RowColumnMeta) })),
|
|
50
51
|
|
|
51
52
|
// Cell formatting referenced by indexed range.
|
|
52
|
-
ranges:
|
|
53
|
-
|
|
54
|
-
// Threads associated with the sheet
|
|
55
|
-
threads: S.optional(S.mutable(S.Array(Ref(ThreadType)))),
|
|
53
|
+
ranges: Schema.mutable(Schema.Array(Range)),
|
|
56
54
|
}) {}
|
package/src/types/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { type CellValue, RowColumnMeta, SheetType } from './schema';
|
|
8
8
|
import { SHEET_PLUGIN } from '../meta';
|
|
@@ -21,47 +21,47 @@ export type CreateSheetOptions = {
|
|
|
21
21
|
export namespace SheetAction {
|
|
22
22
|
const SHEET_ACTION = `${SHEET_PLUGIN}/action`;
|
|
23
23
|
|
|
24
|
-
export class Create extends
|
|
25
|
-
input:
|
|
26
|
-
name:
|
|
24
|
+
export class Create extends Schema.TaggedClass<Create>()(`${SHEET_ACTION}/create`, {
|
|
25
|
+
input: Schema.Struct({
|
|
26
|
+
name: Schema.optional(Schema.String),
|
|
27
27
|
}),
|
|
28
|
-
output:
|
|
28
|
+
output: Schema.Struct({
|
|
29
29
|
object: SheetType,
|
|
30
30
|
}),
|
|
31
31
|
}) {}
|
|
32
32
|
|
|
33
33
|
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
34
|
-
const Axis =
|
|
34
|
+
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
35
35
|
|
|
36
|
-
export class InsertAxis extends
|
|
37
|
-
input:
|
|
38
|
-
// TODO(wittjosiah):
|
|
39
|
-
model:
|
|
36
|
+
export class InsertAxis extends Schema.TaggedClass<InsertAxis>()(`${SHEET_ACTION}/axis-insert`, {
|
|
37
|
+
input: Schema.Struct({
|
|
38
|
+
// TODO(wittjosiah): Schema.instanceOf(SheetModel) throws when running tests.
|
|
39
|
+
model: Schema.Any.pipe(Schema.filter((model) => model instanceof SheetModel)) as Schema.Schema<SheetModel>,
|
|
40
40
|
axis: Axis,
|
|
41
|
-
index:
|
|
42
|
-
count:
|
|
41
|
+
index: Schema.Number,
|
|
42
|
+
count: Schema.optional(Schema.Number),
|
|
43
43
|
}),
|
|
44
|
-
output:
|
|
44
|
+
output: Schema.Void,
|
|
45
45
|
}) {}
|
|
46
46
|
|
|
47
|
-
export const RestoreAxis =
|
|
47
|
+
export const RestoreAxis = Schema.Struct({
|
|
48
48
|
axis: Axis,
|
|
49
|
-
axisIndex:
|
|
50
|
-
index:
|
|
49
|
+
axisIndex: Schema.String,
|
|
50
|
+
index: Schema.Number,
|
|
51
51
|
axisMeta: RowColumnMeta,
|
|
52
|
-
values:
|
|
52
|
+
values: Schema.Array(Schema.Any),
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
export type RestoreAxis =
|
|
55
|
+
export type RestoreAxis = Schema.Schema.Type<typeof RestoreAxis>;
|
|
56
56
|
|
|
57
|
-
export class DropAxis extends
|
|
58
|
-
input:
|
|
59
|
-
// TODO(wittjosiah):
|
|
60
|
-
model:
|
|
57
|
+
export class DropAxis extends Schema.TaggedClass<DropAxis>()(`${SHEET_ACTION}/axis-drop`, {
|
|
58
|
+
input: Schema.Struct({
|
|
59
|
+
// TODO(wittjosiah): Schema.instanceOf(SheetModel) throws when running tests.
|
|
60
|
+
model: Schema.Any.pipe(Schema.filter((model) => model instanceof SheetModel)) as Schema.Schema<SheetModel>,
|
|
61
61
|
axis: Axis,
|
|
62
|
-
axisIndex:
|
|
63
|
-
deletionData:
|
|
62
|
+
axisIndex: Schema.String,
|
|
63
|
+
deletionData: Schema.optional(RestoreAxis),
|
|
64
64
|
}),
|
|
65
|
-
output:
|
|
65
|
+
output: Schema.Void,
|
|
66
66
|
}) {}
|
|
67
67
|
}
|