@dxos/plugin-sheet 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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/{chunk-KE3AKN5W.mjs → chunk-CBNIKBPQ.mjs} +21 -140
- package/dist/lib/browser/chunk-CBNIKBPQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-GZ2EV64I.mjs +118 -0
- package/dist/lib/browser/chunk-GZ2EV64I.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/drop-axis-PB7F3LBV.mjs +23 -0
- package/dist/lib/browser/drop-axis-PB7F3LBV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +104 -86
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/insert-axis-DH5CO4AY.mjs +16 -0
- package/dist/lib/browser/insert-axis-DH5CO4AY.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/restore-axis-Y5H5IOC6.mjs +16 -0
- package/dist/lib/browser/restore-axis-Y5H5IOC6.mjs.map +7 -0
- package/dist/lib/browser/scroll-to-anchor-MN36E3X7.mjs +65 -0
- package/dist/lib/browser/scroll-to-anchor-MN36E3X7.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -3
- package/dist/lib/node-esm/{chunk-6J5L47IB.mjs → chunk-3ZYLQWHC.mjs} +21 -140
- package/dist/lib/node-esm/chunk-3ZYLQWHC.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-74MOADQ7.mjs +119 -0
- package/dist/lib/node-esm/chunk-74MOADQ7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/drop-axis-UBBQCU6D.mjs +24 -0
- package/dist/lib/node-esm/drop-axis-UBBQCU6D.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +104 -86
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/insert-axis-S7BR2RSJ.mjs +17 -0
- package/dist/lib/node-esm/insert-axis-S7BR2RSJ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/restore-axis-6B25SOHX.mjs +17 -0
- package/dist/lib/node-esm/restore-axis-6B25SOHX.mjs.map +7 -0
- package/dist/lib/node-esm/scroll-to-anchor-YLB4MYGF.mjs +66 -0
- package/dist/lib/node-esm/scroll-to-anchor-YLB4MYGF.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -3
- 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 +5 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +9 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +6 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +29 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/index.d.ts +2 -0
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +10 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts +63 -0
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/index.d.ts +2 -0
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
- package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +7 -5
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +10 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +9 -5
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +72 -68
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts +1 -1
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/containers/RangeList/index.d.ts +3 -0
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts +58 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +0 -2
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +45 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/drop-axis.d.ts +5 -0
- package/dist/types/src/operations/drop-axis.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/insert-axis.d.ts +5 -0
- package/dist/types/src/operations/insert-axis.d.ts.map +1 -0
- package/dist/types/src/operations/restore-axis.d.ts +5 -0
- package/dist/types/src/operations/restore-axis.d.ts.map +1 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts +5 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +1 -1
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +5 -5
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +38 -36
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +7 -7
- package/dist/types/src/types/Sheet.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +12 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -92
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +81 -63
- package/src/SheetPlugin.tsx +46 -28
- package/src/capabilities/{anchor-sort/anchor-sort.ts → anchor-sort.ts} +4 -3
- package/src/capabilities/{compute-graph-registry/compute-graph-registry.ts → compute-graph-registry.ts} +2 -2
- package/src/capabilities/index.ts +13 -5
- package/src/capabilities/{markdown/markdown.ts → markdown.ts} +2 -2
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +49 -0
- package/src/capabilities/state.ts +29 -0
- package/src/capabilities/undo-mappings.ts +30 -0
- package/src/components/ComputeGraph/compute-graph.stories.tsx +13 -8
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +6 -6
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +15 -14
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +42 -22
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +4 -4
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +45 -38
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +19 -7
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +4 -4
- package/src/components/SheetToolbar/SheetToolbar.tsx +18 -21
- package/src/components/SheetToolbar/align.ts +13 -13
- package/src/components/SheetToolbar/style.ts +10 -10
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +16 -15
- package/src/containers/RangeList/index.ts +7 -0
- package/src/{components → containers}/SheetContainer/SheetContainer.stories.tsx +38 -42
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/{components → containers}/SheetContainer/index.ts +1 -1
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +13 -12
- package/src/extensions/editor/sheet-extension.ts +10 -10
- package/src/integrations/thread-ranges.ts +6 -39
- package/src/meta.ts +1 -1
- package/src/model/sheet-model.test.ts +3 -3
- package/src/model/sheet-model.ts +38 -36
- package/src/model/testing.ts +1 -1
- package/src/model/useSheetModel.ts +1 -1
- package/src/operations/definitions.ts +73 -0
- package/src/operations/drop-axis.ts +26 -0
- package/src/operations/index.ts +14 -0
- package/src/operations/insert-axis.ts +19 -0
- package/src/operations/restore-axis.ts +19 -0
- package/src/operations/scroll-to-anchor.ts +31 -0
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +1 -1
- package/src/sanity.test.ts +6 -3
- package/src/serializer.ts +1 -1
- package/src/testing/data.ts +1 -1
- package/src/testing/testing.tsx +2 -2
- package/src/translations.ts +38 -36
- package/src/types/Sheet.ts +13 -7
- package/src/types/capabilities.ts +14 -2
- package/src/types/sheet-range-types.ts +3 -3
- package/src/types/types.ts +0 -80
- package/dist/lib/browser/SheetContainer-J72HS2FI.mjs +0 -397
- package/dist/lib/browser/SheetContainer-J72HS2FI.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-LLO7PZKF.mjs +0 -23
- package/dist/lib/browser/anchor-sort-LLO7PZKF.mjs.map +0 -7
- package/dist/lib/browser/chunk-IFLWVS2V.mjs +0 -234
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +0 -7
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +0 -7
- package/dist/lib/browser/chunk-S27QJYTN.mjs +0 -1473
- package/dist/lib/browser/chunk-S27QJYTN.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +0 -21
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +0 -7
- package/dist/lib/browser/markdown-D2T2DOVX.mjs +0 -29
- package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-YDOW72CN.mjs +0 -79
- package/dist/lib/browser/operation-resolver-YDOW72CN.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JIYVFH42.mjs +0 -51
- package/dist/lib/browser/react-surface-JIYVFH42.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-OGSSDOZU.mjs +0 -398
- package/dist/lib/node-esm/SheetContainer-OGSSDOZU.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-OX5I2YOW.mjs +0 -24
- package/dist/lib/node-esm/anchor-sort-OX5I2YOW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs +0 -236
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y4V6HVHO.mjs +0 -1474
- package/dist/lib/node-esm/chunk-Y4V6HVHO.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +0 -22
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs +0 -30
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-Q63VQBVA.mjs +0 -80
- package/dist/lib/node-esm/operation-resolver-Q63VQBVA.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SWRZSZVR.mjs +0 -52
- package/dist/lib/node-esm/react-surface-SWRZSZVR.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +0 -5
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +0 -3
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +0 -5
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +0 -3
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
- package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -55
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/index.d.ts +0 -2
- package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/index.d.ts +0 -2
- package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -10
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -57
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/index.d.ts +0 -2
- package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
- package/src/capabilities/anchor-sort/index.ts +0 -7
- package/src/capabilities/compute-graph-registry/index.ts +0 -7
- package/src/capabilities/markdown/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -77
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -43
- package/src/components/SheetContainer/SheetContainer.tsx +0 -48
- package/src/components/SheetContext/index.ts +0 -5
- /package/dist/types/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +0 -0
- /package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +0 -0
- /package/dist/types/src/{components → containers}/SheetContainer/index.d.ts +0 -0
package/src/model/sheet-model.ts
CHANGED
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
insertIndices,
|
|
39
39
|
mapFormulaIndicesToRefs,
|
|
40
40
|
mapFormulaRefsToIndices,
|
|
41
|
-
} from '
|
|
42
|
-
import { type Sheet, type SheetAction } from '
|
|
41
|
+
} from '#types';
|
|
42
|
+
import { type Sheet, type SheetAction } from '#types';
|
|
43
43
|
|
|
44
44
|
// TODO(burdon): Move to compute.
|
|
45
45
|
// Map sheet types to system types.
|
|
@@ -122,8 +122,8 @@ export class SheetModel extends Resource {
|
|
|
122
122
|
*/
|
|
123
123
|
protected override async _open(): Promise<void> {
|
|
124
124
|
log('initialize', { id: this.id });
|
|
125
|
-
Obj.change(this._sheet, (
|
|
126
|
-
initialize(
|
|
125
|
+
Obj.change(this._sheet, (obj) => {
|
|
126
|
+
initialize(obj);
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
this._graph.update.on((event) => {
|
|
@@ -184,8 +184,8 @@ export class SheetModel extends Resource {
|
|
|
184
184
|
|
|
185
185
|
insertRows(i: number, n = 1): string[] {
|
|
186
186
|
let idx: string[] = [];
|
|
187
|
-
Obj.change(this._sheet, (
|
|
188
|
-
idx = insertIndices(
|
|
187
|
+
Obj.change(this._sheet, (obj) => {
|
|
188
|
+
idx = insertIndices(obj.rows, i, n, MAX_ROWS);
|
|
189
189
|
});
|
|
190
190
|
this.reset();
|
|
191
191
|
return idx;
|
|
@@ -193,8 +193,8 @@ export class SheetModel extends Resource {
|
|
|
193
193
|
|
|
194
194
|
insertColumns(i: number, n = 1): string[] {
|
|
195
195
|
let idx: string[] = [];
|
|
196
|
-
Obj.change(this._sheet, (
|
|
197
|
-
idx = insertIndices(
|
|
196
|
+
Obj.change(this._sheet, (obj) => {
|
|
197
|
+
idx = insertIndices(obj.columns, i, n, MAX_COLS);
|
|
198
198
|
});
|
|
199
199
|
this.reset();
|
|
200
200
|
return idx;
|
|
@@ -208,9 +208,9 @@ export class SheetModel extends Resource {
|
|
|
208
208
|
const values = this.getCellValues(range).flat();
|
|
209
209
|
const index = this._sheet.rows.indexOf(rowIndex);
|
|
210
210
|
this.clear(range);
|
|
211
|
-
Obj.change(this._sheet, (
|
|
212
|
-
|
|
213
|
-
delete
|
|
211
|
+
Obj.change(this._sheet, (obj) => {
|
|
212
|
+
obj.rows.splice(index, 1);
|
|
213
|
+
delete obj.rowMeta[rowIndex];
|
|
214
214
|
});
|
|
215
215
|
this.reset();
|
|
216
216
|
return { axis: 'row', index, axisIndex: rowIndex, axisMeta: this._sheet.rowMeta[rowIndex], values };
|
|
@@ -224,39 +224,41 @@ export class SheetModel extends Resource {
|
|
|
224
224
|
const values = this.getCellValues(range).flat();
|
|
225
225
|
const index = this._sheet.columns.indexOf(colIndex);
|
|
226
226
|
this.clear(range);
|
|
227
|
-
Obj.change(this._sheet, (
|
|
228
|
-
|
|
229
|
-
delete
|
|
227
|
+
Obj.change(this._sheet, (obj) => {
|
|
228
|
+
obj.columns.splice(index, 1);
|
|
229
|
+
delete obj.columnMeta[colIndex];
|
|
230
230
|
});
|
|
231
231
|
this.reset();
|
|
232
232
|
return { axis: 'col', index, axisIndex: colIndex, axisMeta: this._sheet.rowMeta[colIndex], values };
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
restoreRow({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
|
|
236
|
-
Obj.change(this._sheet, (
|
|
237
|
-
|
|
236
|
+
Obj.change(this._sheet, (obj) => {
|
|
237
|
+
obj.rows.splice(index, 0, axisIndex);
|
|
238
238
|
values.forEach((value, col) => {
|
|
239
239
|
if (value) {
|
|
240
|
-
|
|
240
|
+
obj.cells[`${obj.columns[col]}@${axisIndex}`] = { value };
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
|
+
|
|
243
244
|
if (axisMeta) {
|
|
244
|
-
|
|
245
|
+
obj.rowMeta[axisIndex] = axisMeta;
|
|
245
246
|
}
|
|
246
247
|
});
|
|
247
248
|
this.reset();
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
restoreColumn({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
|
|
251
|
-
Obj.change(this._sheet, (
|
|
252
|
-
|
|
252
|
+
Obj.change(this._sheet, (obj) => {
|
|
253
|
+
obj.columns.splice(index, 0, axisIndex);
|
|
253
254
|
values.forEach((value, row) => {
|
|
254
255
|
if (value) {
|
|
255
|
-
|
|
256
|
+
obj.cells[`${axisIndex}@${obj.rows[row]}`] = { value };
|
|
256
257
|
}
|
|
257
258
|
});
|
|
259
|
+
|
|
258
260
|
if (axisMeta) {
|
|
259
|
-
|
|
261
|
+
obj.columnMeta[axisIndex] = axisMeta;
|
|
260
262
|
}
|
|
261
263
|
});
|
|
262
264
|
this.reset();
|
|
@@ -275,10 +277,10 @@ export class SheetModel extends Resource {
|
|
|
275
277
|
const topLeft = getTopLeft(range);
|
|
276
278
|
const values = this._iterRange(range, () => null);
|
|
277
279
|
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
278
|
-
Obj.change(this._sheet, (
|
|
280
|
+
Obj.change(this._sheet, (obj) => {
|
|
279
281
|
this._iterRange(range, (cell) => {
|
|
280
282
|
const idx = addressToIndex(this._sheet, cell);
|
|
281
|
-
delete
|
|
283
|
+
delete obj.cells[idx];
|
|
282
284
|
});
|
|
283
285
|
});
|
|
284
286
|
}
|
|
@@ -286,10 +288,10 @@ export class SheetModel extends Resource {
|
|
|
286
288
|
cut(range: CellRange): void {
|
|
287
289
|
invariant(this._node);
|
|
288
290
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
289
|
-
Obj.change(this._sheet, (
|
|
291
|
+
Obj.change(this._sheet, (obj) => {
|
|
290
292
|
this._iterRange(range, (cell) => {
|
|
291
293
|
const idx = addressToIndex(this._sheet, cell);
|
|
292
|
-
delete
|
|
294
|
+
delete obj.cells[idx];
|
|
293
295
|
});
|
|
294
296
|
});
|
|
295
297
|
}
|
|
@@ -303,12 +305,12 @@ export class SheetModel extends Resource {
|
|
|
303
305
|
invariant(this._node);
|
|
304
306
|
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
305
307
|
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
306
|
-
Obj.change(this._sheet, (
|
|
308
|
+
Obj.change(this._sheet, (obj) => {
|
|
307
309
|
for (const change of changes) {
|
|
308
310
|
if (change instanceof ExportedCellChange) {
|
|
309
311
|
const { address, newValue } = change;
|
|
310
312
|
const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
|
|
311
|
-
|
|
313
|
+
obj.cells[idx] = { value: newValue };
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
316
|
});
|
|
@@ -402,14 +404,14 @@ export class SheetModel extends Resource {
|
|
|
402
404
|
// Reallocate if > current bounds.
|
|
403
405
|
let refresh = false;
|
|
404
406
|
if (cell.row >= this._sheet.rows.length) {
|
|
405
|
-
Obj.change(this._sheet, (
|
|
406
|
-
insertIndices(
|
|
407
|
+
Obj.change(this._sheet, (obj) => {
|
|
408
|
+
insertIndices(obj.rows, cell.row, 1, MAX_ROWS);
|
|
407
409
|
});
|
|
408
410
|
refresh = true;
|
|
409
411
|
}
|
|
410
412
|
if (cell.col >= this._sheet.columns.length) {
|
|
411
|
-
Obj.change(this._sheet, (
|
|
412
|
-
insertIndices(
|
|
413
|
+
Obj.change(this._sheet, (obj) => {
|
|
414
|
+
insertIndices(obj.columns, cell.col, 1, MAX_COLS);
|
|
413
415
|
});
|
|
414
416
|
refresh = true;
|
|
415
417
|
}
|
|
@@ -427,16 +429,16 @@ export class SheetModel extends Resource {
|
|
|
427
429
|
// Insert into sheet.
|
|
428
430
|
const idx = addressToIndex(this._sheet, cell);
|
|
429
431
|
if (value === undefined || value === null) {
|
|
430
|
-
Obj.change(this._sheet, (
|
|
431
|
-
delete
|
|
432
|
+
Obj.change(this._sheet, (obj) => {
|
|
433
|
+
delete obj.cells[idx];
|
|
432
434
|
});
|
|
433
435
|
} else {
|
|
434
436
|
if (isFormula(value)) {
|
|
435
437
|
value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
|
|
436
438
|
}
|
|
437
439
|
|
|
438
|
-
Obj.change(this._sheet, (
|
|
439
|
-
|
|
440
|
+
Obj.change(this._sheet, (obj) => {
|
|
441
|
+
obj.cells[idx] = { value };
|
|
440
442
|
});
|
|
441
443
|
}
|
|
442
444
|
}
|
package/src/model/testing.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
|
|
|
7
7
|
import { type ComputeGraph } from '@dxos/compute';
|
|
8
8
|
|
|
9
9
|
import { SheetModel } from '../model';
|
|
10
|
-
import { type Sheet } from '
|
|
10
|
+
import { type Sheet } from '#types';
|
|
11
11
|
|
|
12
12
|
export type UseSheetModelOptions = {
|
|
13
13
|
readonly?: boolean;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
|
|
12
|
+
const SHEET_OPERATION = `${meta.id}.operation`;
|
|
13
|
+
|
|
14
|
+
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
15
|
+
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
16
|
+
|
|
17
|
+
export const InsertAxis = Operation.make({
|
|
18
|
+
meta: { key: `${SHEET_OPERATION}.axis-insert`, name: 'Insert Axis' },
|
|
19
|
+
input: Schema.Struct({
|
|
20
|
+
model: Schema.Any,
|
|
21
|
+
axis: Axis,
|
|
22
|
+
index: Schema.Number,
|
|
23
|
+
count: Schema.optional(Schema.Number),
|
|
24
|
+
}),
|
|
25
|
+
output: Schema.Void,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DropAxisOutput = Schema.Struct({
|
|
29
|
+
axis: Axis.annotations({ description: 'The axis type (row or col).' }),
|
|
30
|
+
axisIndex: Schema.String.annotations({ description: 'The dropped axis index.' }),
|
|
31
|
+
index: Schema.Number.annotations({ description: 'The position the axis was at.' }),
|
|
32
|
+
axisMeta: Schema.Any.annotations({ description: 'The row/column metadata.' }),
|
|
33
|
+
values: Schema.Array(Schema.Any).annotations({ description: 'The cell values that were dropped.' }),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type DropAxisOutput = Schema.Schema.Type<typeof DropAxisOutput>;
|
|
37
|
+
|
|
38
|
+
export const DropAxis = Operation.make({
|
|
39
|
+
meta: { key: `${SHEET_OPERATION}.axis-drop`, name: 'Drop Axis' },
|
|
40
|
+
input: Schema.Struct({
|
|
41
|
+
model: Schema.Any,
|
|
42
|
+
axis: Axis,
|
|
43
|
+
axisIndex: Schema.String,
|
|
44
|
+
}),
|
|
45
|
+
output: DropAxisOutput,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const ScrollToAnchor = Operation.make({
|
|
49
|
+
meta: { key: `${SHEET_OPERATION}.scroll-to-anchor`, name: 'Scroll To Anchor' },
|
|
50
|
+
services: [Capability.Service],
|
|
51
|
+
input: Schema.Struct({
|
|
52
|
+
subject: Schema.String.annotations({ description: 'Attendable ID of the sheet.' }),
|
|
53
|
+
cursor: Schema.String.annotations({ description: 'Cell range coordinates.' }),
|
|
54
|
+
ref: Schema.optional(Schema.Any.annotations({ description: 'Active refs for highlighting.' })),
|
|
55
|
+
}),
|
|
56
|
+
output: Schema.Void,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Restore a dropped axis (inverse of DropAxis).
|
|
61
|
+
*/
|
|
62
|
+
export const RestoreAxis = Operation.make({
|
|
63
|
+
meta: { key: `${SHEET_OPERATION}.restore-axis`, name: 'Restore Axis' },
|
|
64
|
+
input: Schema.Struct({
|
|
65
|
+
model: Schema.Any.annotations({ description: 'The sheet model.' }),
|
|
66
|
+
axis: Axis.annotations({ description: 'The axis type (row or col).' }),
|
|
67
|
+
axisIndex: Schema.String.annotations({ description: 'The axis index to restore.' }),
|
|
68
|
+
index: Schema.Number.annotations({ description: 'The position to restore at.' }),
|
|
69
|
+
axisMeta: Schema.Any.annotations({ description: 'The row/column metadata.' }),
|
|
70
|
+
values: Schema.Array(Schema.Any).annotations({ description: 'The cell values to restore.' }),
|
|
71
|
+
}),
|
|
72
|
+
output: Schema.Void,
|
|
73
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/operation';
|
|
8
|
+
|
|
9
|
+
import { DropAxis } from './definitions';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof DropAxis> = DropAxis.pipe(
|
|
12
|
+
Operation.withHandler(({ model, axis, axisIndex }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
const undoData = model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
15
|
+
return {
|
|
16
|
+
axis: undoData.axis,
|
|
17
|
+
axisIndex: undoData.axisIndex,
|
|
18
|
+
index: undoData.index,
|
|
19
|
+
axisMeta: undoData.axisMeta,
|
|
20
|
+
values: undoData.values,
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export default handler;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
|
+
|
|
7
|
+
export * as SheetOperation from './definitions';
|
|
8
|
+
|
|
9
|
+
export const SheetOperationHandlerSet = OperationHandlerSet.lazy(
|
|
10
|
+
() => import('./drop-axis'),
|
|
11
|
+
() => import('./insert-axis'),
|
|
12
|
+
() => import('./restore-axis'),
|
|
13
|
+
() => import('./scroll-to-anchor'),
|
|
14
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/operation';
|
|
8
|
+
|
|
9
|
+
import { InsertAxis } from './definitions';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof InsertAxis> = InsertAxis.pipe(
|
|
12
|
+
Operation.withHandler(({ model, axis, index, count }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
model[axis === 'col' ? 'insertColumns' : 'insertRows'](index, count);
|
|
15
|
+
}),
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default handler;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/operation';
|
|
8
|
+
|
|
9
|
+
import { RestoreAxis } from './definitions';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof RestoreAxis> = RestoreAxis.pipe(
|
|
12
|
+
Operation.withHandler(({ model, axis, ...restoreData }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
model[axis === 'col' ? 'restoreColumn' : 'restoreRow'](restoreData);
|
|
15
|
+
}),
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default handler;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
|
|
10
|
+
import { parseThreadAnchorAsCellRange } from '../integrations/thread-ranges';
|
|
11
|
+
import { SheetCapabilities } from '../types';
|
|
12
|
+
import { ScrollToAnchor } from './definitions';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof ScrollToAnchor> = ScrollToAnchor.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ subject, cursor, ref }) {
|
|
17
|
+
const gridInstances = yield* Capability.get(SheetCapabilities.GridInstances);
|
|
18
|
+
const entry = gridInstances.get(subject);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
entry.setActiveRefs(ref);
|
|
23
|
+
const range = parseThreadAnchorAsCellRange(cursor);
|
|
24
|
+
if (range) {
|
|
25
|
+
entry.grid.setFocus({ ...range.to, plane: 'grid' }, true);
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export default handler;
|
|
@@ -10,7 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
...e2ePreset(import.meta.dirname),
|
|
11
11
|
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
12
12
|
webServer: {
|
|
13
|
-
command: '
|
|
13
|
+
command: 'pnpm storybook dev --ci --quiet --port=9005 --config-dir=.storybook',
|
|
14
14
|
port: 9005,
|
|
15
15
|
reuseExistingServer: false,
|
|
16
16
|
},
|
|
@@ -15,7 +15,7 @@ test.describe('plugin-sheet', () => {
|
|
|
15
15
|
|
|
16
16
|
test.beforeEach(async ({ browser }) => {
|
|
17
17
|
const setup = await setupPage(browser, {
|
|
18
|
-
url: storybookUrl('plugins-plugin-sheet-sheetcontainer--spec', 9005),
|
|
18
|
+
url: storybookUrl('plugins-plugin-sheet-containers-sheetcontainer--spec', 9005),
|
|
19
19
|
viewportSize: { width: 1280, height: 720 },
|
|
20
20
|
});
|
|
21
21
|
page = setup.page;
|
package/src/sanity.test.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Client } from '@dxos/client';
|
|
8
|
-
import {
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { Operation } from '@dxos/operation';
|
|
9
10
|
|
|
10
11
|
// Part 2.
|
|
11
12
|
// TODO(burdon): Cannot test outside of browser.
|
|
@@ -22,7 +23,7 @@ import { Function } from '@dxos/functions';
|
|
|
22
23
|
describe('test', () => {
|
|
23
24
|
test('test', async () => {
|
|
24
25
|
const client = new Client();
|
|
25
|
-
await client.addTypes([
|
|
26
|
+
await client.addTypes([Operation.PersistentOperation]);
|
|
26
27
|
await client.initialize();
|
|
27
28
|
await client.halo.createIdentity();
|
|
28
29
|
|
|
@@ -33,7 +34,9 @@ describe('test', () => {
|
|
|
33
34
|
// - ERROR "process.nextTick is not a function"
|
|
34
35
|
// - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
|
|
35
36
|
const space = await client.spaces.create();
|
|
36
|
-
const fn = space.db.add(
|
|
37
|
+
const fn = space.db.add(
|
|
38
|
+
Obj.make(Operation.PersistentOperation, { name: 'test', version: '0.0.1', binding: 'HELLO' }),
|
|
39
|
+
);
|
|
37
40
|
expect(fn).to.exist;
|
|
38
41
|
});
|
|
39
42
|
});
|
package/src/serializer.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Obj } from '@dxos/echo';
|
|
|
6
6
|
import { getObjectCore } from '@dxos/echo-db';
|
|
7
7
|
import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
|
|
8
8
|
|
|
9
|
-
import { Sheet } from '
|
|
9
|
+
import { Sheet } from '#types';
|
|
10
10
|
|
|
11
11
|
export const serializer: TypedObjectSerializer<Sheet.Sheet> = {
|
|
12
12
|
serialize: async ({ object }): Promise<string> => {
|
package/src/testing/data.ts
CHANGED
package/src/testing/testing.tsx
CHANGED
|
@@ -10,8 +10,8 @@ import { createMockedComputeRuntimeProvider } from '@dxos/compute/testing';
|
|
|
10
10
|
import { type Space } from '@dxos/react-client/echo';
|
|
11
11
|
import { useAsyncState } from '@dxos/react-hooks';
|
|
12
12
|
|
|
13
|
-
import { ComputeGraphContextProvider } from '
|
|
14
|
-
import { Sheet } from '
|
|
13
|
+
import { ComputeGraphContextProvider } from '#components';
|
|
14
|
+
import { Sheet } from '#types';
|
|
15
15
|
|
|
16
16
|
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: Sheet.SheetProps) => {
|
|
17
17
|
const [sheet] = useAsyncState(async () => {
|
package/src/translations.ts
CHANGED
|
@@ -4,49 +4,51 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import { Sheet } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
import { Sheet } from '#types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
13
|
[Sheet.Sheet.typename]: {
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'object
|
|
14
|
+
'typename.label': 'Sheet',
|
|
15
|
+
'typename.label_zero': 'Sheets',
|
|
16
|
+
'typename.label_one': 'Sheet',
|
|
17
|
+
'typename.label_other': 'Sheets',
|
|
18
|
+
'object-name.placeholder': 'New sheet',
|
|
19
|
+
'add-object.label': 'Add sheet',
|
|
20
|
+
'rename-object.label': 'Rename sheet',
|
|
21
|
+
'delete-object.label': 'Delete sheet',
|
|
22
|
+
'object-deleted.label': 'Sheet deleted',
|
|
22
23
|
},
|
|
23
24
|
[meta.id]: {
|
|
24
|
-
'plugin
|
|
25
|
-
'cell
|
|
26
|
-
'range
|
|
27
|
-
'range
|
|
28
|
-
'range
|
|
29
|
-
'range
|
|
30
|
-
'range
|
|
31
|
-
'range
|
|
32
|
-
'range
|
|
33
|
-
'toolbar
|
|
34
|
-
'selection
|
|
35
|
-
'comment
|
|
36
|
-
'comment
|
|
37
|
-
'no
|
|
38
|
-
'
|
|
39
|
-
'add
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'add
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
25
|
+
'plugin.name': 'Sheets',
|
|
26
|
+
'cell.placeholder': 'Cell value...',
|
|
27
|
+
'range-key-alignment.label': 'Align',
|
|
28
|
+
'range-key-style.label': 'Style',
|
|
29
|
+
'range-value-start.label': 'Align left',
|
|
30
|
+
'range-value-center.label': 'Align center',
|
|
31
|
+
'range-value-end.label': 'Align right',
|
|
32
|
+
'range-value-softwrap.label': 'Wrap text',
|
|
33
|
+
'range-value-highlight.label': 'Highlight',
|
|
34
|
+
'toolbar-action.label': '{{value}}',
|
|
35
|
+
'selection-overlaps-existing-comment.label': 'Selected cell already has a comment',
|
|
36
|
+
'comment.label': 'Add comment',
|
|
37
|
+
'comment-ranges-not-supported.label': 'Commenting on ranges is not yet supported',
|
|
38
|
+
'no-cursor.label': 'Select a cell to comment',
|
|
39
|
+
'add-col-before.label': 'Add column before',
|
|
40
|
+
'add-col-after.label': 'Add column after',
|
|
41
|
+
'delete-col.label': 'Delete column',
|
|
42
|
+
'add-row-before.label': 'Add row before',
|
|
43
|
+
'add-row-after.label': 'Add row after',
|
|
44
|
+
'delete-row.label': 'Delete row',
|
|
45
|
+
'range-list.heading': 'Ranges',
|
|
46
|
+
'no-ranges.message': 'No ranges',
|
|
47
|
+
'range.title': '{{position}} — {{value}}',
|
|
48
|
+
'col-dropped.label': 'Deleted a column',
|
|
49
|
+
'row-dropped.label': 'Deleted a row',
|
|
50
|
+
'align.label': 'Text align',
|
|
51
|
+
'axis-dropped.label': 'Drop axis', // TODO(burdon): What does this mean?
|
|
50
52
|
},
|
|
51
53
|
},
|
|
52
54
|
},
|
package/src/types/Sheet.ts
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import * as Schema from 'effect/Schema';
|
|
6
8
|
|
|
7
9
|
import { addressFromA1Notation, isFormula } from '@dxos/compute';
|
|
8
|
-
import { Obj, Type } from '@dxos/echo';
|
|
10
|
+
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
9
11
|
import { FormInputAnnotation } from '@dxos/echo/internal';
|
|
10
12
|
|
|
11
13
|
import { addressToIndex, initialize, mapFormulaRefsToIndices } from './util';
|
|
@@ -62,9 +64,13 @@ export const Sheet = Schema.Struct({
|
|
|
62
64
|
ranges: Schema.Array(Range).pipe(FormInputAnnotation.set(false)),
|
|
63
65
|
}).pipe(
|
|
64
66
|
Type.object({
|
|
65
|
-
typename: 'dxos.
|
|
67
|
+
typename: 'org.dxos.type.sheet',
|
|
66
68
|
version: '0.1.0',
|
|
67
69
|
}),
|
|
70
|
+
Annotation.IconAnnotation.set({
|
|
71
|
+
icon: 'ph--grid-nine--regular',
|
|
72
|
+
hue: 'indigo',
|
|
73
|
+
}),
|
|
68
74
|
);
|
|
69
75
|
|
|
70
76
|
export interface Sheet extends Schema.Schema.Type<typeof Sheet> {}
|
|
@@ -78,17 +84,17 @@ export const make = ({ name, cells = {}, ...size }: SheetProps = {}) => {
|
|
|
78
84
|
const sheet = Obj.make(Sheet, { name, cells: {}, rows: [], columns: [], rowMeta: {}, columnMeta: {}, ranges: [] });
|
|
79
85
|
|
|
80
86
|
// Initialize and set cells within Obj.change to satisfy change context requirements.
|
|
81
|
-
Obj.change(sheet, (
|
|
82
|
-
initialize(
|
|
87
|
+
Obj.change(sheet, (obj) => {
|
|
88
|
+
initialize(obj, size);
|
|
83
89
|
|
|
84
90
|
if (cells) {
|
|
85
91
|
Object.entries(cells).forEach(([key, { value }]) => {
|
|
86
|
-
const idx = addressToIndex(
|
|
92
|
+
const idx = addressToIndex(obj, addressFromA1Notation(key));
|
|
87
93
|
if (isFormula(value)) {
|
|
88
|
-
value = mapFormulaRefsToIndices(
|
|
94
|
+
value = mapFormulaRefsToIndices(obj, value);
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
|
|
97
|
+
obj.cells[idx] = { value };
|
|
92
98
|
});
|
|
93
99
|
}
|
|
94
100
|
});
|
|
@@ -4,11 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import { Capability } from '@dxos/app-framework';
|
|
6
6
|
import { type ComputeGraphRegistry } from '@dxos/compute';
|
|
7
|
+
import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
|
|
7
8
|
|
|
8
|
-
import { meta } from '
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
|
|
11
|
+
export type GridEntry = { grid: DxGridElement; setActiveRefs: (refs: GridContentProps['activeRefs']) => void };
|
|
12
|
+
|
|
13
|
+
export type GridRegistry = {
|
|
14
|
+
register: (attendableId: string, grid: DxGridElement, setActiveRefs: GridEntry['setActiveRefs']) => void;
|
|
15
|
+
unregister: (attendableId: string) => void;
|
|
16
|
+
get: (attendableId: string) => GridEntry | undefined;
|
|
17
|
+
};
|
|
9
18
|
|
|
10
19
|
export namespace SheetCapabilities {
|
|
11
20
|
export const ComputeGraphRegistry = Capability.make<ComputeGraphRegistry>(
|
|
12
|
-
`${meta.id}
|
|
21
|
+
`${meta.id}.capability.compute-graph-registry`,
|
|
13
22
|
);
|
|
23
|
+
|
|
24
|
+
/** Registry of active grid instances keyed by attendable ID. */
|
|
25
|
+
export const GridInstances = Capability.make<GridRegistry>(`${meta.id}.capability.grid-instances`);
|
|
14
26
|
}
|