@dxos/plugin-sheet 0.6.13 → 0.6.14-main.1366248
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-JZEKRM4Z.mjs +297 -0
- package/dist/lib/browser/SheetContainer-JZEKRM4Z.mjs.map +7 -0
- package/dist/lib/browser/chunk-BVUN7SHF.mjs +67 -0
- package/dist/lib/browser/chunk-BVUN7SHF.mjs.map +7 -0
- package/dist/lib/browser/chunk-G2FUL6PK.mjs +1671 -0
- package/dist/lib/browser/chunk-G2FUL6PK.mjs.map +7 -0
- package/dist/lib/browser/chunk-RABELMEQ.mjs +15 -0
- package/dist/lib/browser/chunk-RABELMEQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-VMSX6Z4X.mjs} +659 -675
- package/dist/lib/browser/chunk-VMSX6Z4X.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-GGWUX644.mjs +35 -0
- package/dist/lib/browser/compute-graph-GGWUX644.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +168 -67
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +6 -12
- package/dist/lib/node/SheetContainer-PJE74VO4.cjs +300 -0
- package/dist/lib/node/SheetContainer-PJE74VO4.cjs.map +7 -0
- package/dist/lib/node/chunk-2ZVZI2KJ.cjs +38 -0
- package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-AWKOWDMI.cjs} +34 -52
- package/dist/lib/node/chunk-AWKOWDMI.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-O7XR4R7Y.cjs} +678 -674
- package/dist/lib/node/chunk-O7XR4R7Y.cjs.map +7 -0
- package/dist/lib/node/chunk-STZ7S7RF.cjs +1656 -0
- package/dist/lib/node/chunk-STZ7S7RF.cjs.map +7 -0
- package/dist/lib/node/compute-graph-KGWA2QLE.cjs +57 -0
- package/dist/lib/node/compute-graph-KGWA2QLE.cjs.map +7 -0
- package/dist/lib/node/index.cjs +178 -75
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +9 -15
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-R73XEXHU.mjs +298 -0
- package/dist/lib/node-esm/SheetContainer-R73XEXHU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs +17 -0
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CR4K75EL.mjs +3220 -0
- package/dist/lib/node-esm/chunk-CR4K75EL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UIBWRHW7.mjs +68 -0
- package/dist/lib/node-esm/chunk-UIBWRHW7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-V5N3Y2O5.mjs +1672 -0
- package/dist/lib/node-esm/chunk-V5N3Y2O5.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-2SCZT7N5.mjs +36 -0
- package/dist/lib/node-esm/compute-graph-2SCZT7N5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +350 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +17 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +13 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +3 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/index.d.ts +2 -0
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +6 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/{CellEditor/CellEditor.stories.d.ts → GridSheet/SheetCellEditor.stories.d.ts} +5 -9
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/index.d.ts +2 -0
- package/dist/types/src/components/GridSheet/index.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +15 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/index.d.ts +2 -0
- package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +9 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +6 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/index.d.ts +3 -0
- package/dist/types/src/components/SheetContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +28 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/index.d.ts +2 -0
- package/dist/types/src/components/SheetContext/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +36 -9
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +4 -32
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +7 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.d.ts +64 -0
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts +6 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-node.d.ts +26 -0
- package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → compute-graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → compute-graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/index.d.ts +4 -0
- package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/index.d.ts +5 -0
- package/dist/types/src/compute-graph/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/index.d.ts +3 -0
- package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/compute-graph/util.d.ts +2 -0
- package/dist/types/src/compute-graph/util.d.ts.map +1 -0
- package/dist/types/src/defs/index.d.ts +4 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/defs/sheet-range-types.d.ts +13 -0
- package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -0
- package/dist/types/src/defs/types.d.ts +28 -0
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +39 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +6 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +21 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/extension.d.ts +39 -0
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/index.d.ts +2 -0
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +3 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/index.d.ts +2 -0
- package/dist/types/src/integrations/index.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +4 -9
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +2 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +22 -69
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
- package/dist/types/src/model/useSheetModel.d.ts +8 -0
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +4 -0
- package/dist/types/src/serializer.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +32 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +132 -43
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +60 -61
- package/src/SheetPlugin.tsx +89 -78
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +37 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/FunctionEditor/FunctionEditor.tsx +45 -0
- package/src/components/FunctionEditor/index.ts +5 -0
- package/src/components/GridSheet/GridSheet.stories.tsx +46 -0
- package/src/components/GridSheet/GridSheet.tsx +358 -0
- package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +18 -15
- package/src/components/GridSheet/index.ts +5 -0
- package/src/components/GridSheet/util.ts +170 -0
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +45 -0
- package/src/components/SheetContainer/SheetContainer.tsx +33 -0
- package/src/components/SheetContainer/index.ts +7 -0
- package/src/components/SheetContext/SheetContext.tsx +127 -0
- package/src/components/SheetContext/index.ts +5 -0
- package/src/components/Toolbar/Toolbar.stories.tsx +9 -6
- package/src/components/Toolbar/Toolbar.tsx +265 -111
- package/src/components/index.ts +5 -3
- package/src/compute-graph/compute-graph-registry.ts +90 -0
- package/src/compute-graph/compute-graph.stories.tsx +97 -0
- package/src/compute-graph/compute-graph.test.ts +87 -0
- package/src/compute-graph/compute-graph.ts +260 -0
- package/src/compute-graph/compute-node.ts +62 -0
- package/src/{components/ComputeGraph → compute-graph/functions}/async-function.ts +26 -15
- package/src/{components/ComputeGraph → compute-graph/functions}/edge-function.ts +21 -17
- package/src/compute-graph/functions/index.ts +7 -0
- package/src/compute-graph/hyperformula.test.ts +14 -0
- package/src/compute-graph/index.ts +8 -0
- package/src/compute-graph/testing/index.ts +6 -0
- package/src/compute-graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → compute-graph/testing/test-plugin.ts} +44 -14
- package/src/compute-graph/util.ts +8 -0
- package/src/defs/index.ts +7 -0
- package/src/defs/sheet-range-types.ts +49 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/defs/types.ts +86 -0
- package/src/defs/util.ts +136 -0
- package/src/extensions/compute.stories.tsx +155 -0
- package/src/extensions/compute.ts +147 -0
- package/src/{components/CellEditor → extensions/editor}/extension.test.ts +4 -6
- package/src/{components/CellEditor → extensions/editor}/extension.ts +51 -27
- package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
- package/src/extensions/index.ts +6 -0
- package/src/index.ts +2 -2
- package/src/integrations/index.ts +5 -0
- package/src/integrations/thread-ranges.ts +101 -0
- package/src/meta.ts +15 -0
- package/src/model/index.ts +2 -3
- package/src/model/sheet-model.test.ts +59 -0
- package/src/model/sheet-model.ts +495 -0
- package/src/model/useSheetModel.ts +40 -0
- package/src/sanity.test.ts +40 -0
- package/src/serializer.ts +27 -0
- package/src/{components/Sheet → testing}/index.ts +1 -1
- package/src/testing/testing.tsx +68 -0
- package/src/translations.ts +24 -4
- package/src/types.ts +62 -47
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +0 -19
- package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/index.d.ts +0 -3
- package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/grid.d.ts +0 -52
- package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/index.d.ts +0 -2
- package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/nav.d.ts +0 -29
- package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/util.d.ts +0 -18
- package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer.d.ts +0 -9
- package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/common.d.ts +0 -20
- package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts +0 -17
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/CellEditor/CellEditor.tsx +0 -113
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/components/Sheet/Sheet.stories.tsx +0 -287
- package/src/components/Sheet/Sheet.tsx +0 -1160
- package/src/components/Sheet/formatting.ts +0 -106
- package/src/components/Sheet/grid.ts +0 -191
- package/src/components/Sheet/nav.ts +0 -157
- package/src/components/Sheet/sheet-context.tsx +0 -150
- package/src/components/Sheet/util.ts +0 -56
- package/src/components/SheetContainer.tsx +0 -34
- package/src/components/Toolbar/common.tsx +0 -72
- package/src/meta.tsx +0 -18
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/types.ts +0 -71
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
- /package/src/{model/functions.ts → compute-graph/functions/function-defs.ts} +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { syntaxTree } from '@codemirror/language';
|
|
6
|
+
import {
|
|
7
|
+
type EditorState,
|
|
8
|
+
type Extension,
|
|
9
|
+
type RangeSet,
|
|
10
|
+
RangeSetBuilder,
|
|
11
|
+
StateEffect,
|
|
12
|
+
StateField,
|
|
13
|
+
type Transaction,
|
|
14
|
+
} from '@codemirror/state';
|
|
15
|
+
import { Decoration, EditorView, ViewPlugin, WidgetType } from '@codemirror/view';
|
|
16
|
+
|
|
17
|
+
import { type UnsubscribeCallback, debounce } from '@dxos/async';
|
|
18
|
+
import { invariant } from '@dxos/invariant';
|
|
19
|
+
import { documentId, singleValueFacet } from '@dxos/react-ui-editor';
|
|
20
|
+
|
|
21
|
+
import { type ComputeGraph, type ComputeNode, createSheetName } from '../compute-graph';
|
|
22
|
+
import { type CellAddress } from '../defs';
|
|
23
|
+
import { type CellScalarValue } from '../types';
|
|
24
|
+
|
|
25
|
+
const LANGUAGE_TAG = 'dx';
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Create marker just for our decorator?
|
|
28
|
+
const updateAllDecorations = StateEffect.define<void>();
|
|
29
|
+
|
|
30
|
+
export const computeGraphFacet = singleValueFacet<ComputeGraph>();
|
|
31
|
+
|
|
32
|
+
export type ComputeOptions = {};
|
|
33
|
+
|
|
34
|
+
export const compute = (options: ComputeOptions = {}): Extension => {
|
|
35
|
+
let computeNode: ComputeNode | undefined;
|
|
36
|
+
|
|
37
|
+
const update = (state: EditorState, current?: RangeSet<Decoration>) => {
|
|
38
|
+
const builder = new RangeSetBuilder<Decoration>();
|
|
39
|
+
if (computeNode) {
|
|
40
|
+
computeNode.clear();
|
|
41
|
+
syntaxTree(state).iterate({
|
|
42
|
+
enter: (node) => {
|
|
43
|
+
switch (node.name) {
|
|
44
|
+
case 'FencedCode': {
|
|
45
|
+
const cursor = state.selection.main.head;
|
|
46
|
+
if (state.readOnly || cursor < node.from || cursor > node.to) {
|
|
47
|
+
const info = node.node.getChild('CodeInfo');
|
|
48
|
+
if (info) {
|
|
49
|
+
const type = state.sliceDoc(info.from, info.to);
|
|
50
|
+
const text = node.node.getChild('CodeText');
|
|
51
|
+
if (type === LANGUAGE_TAG && text) {
|
|
52
|
+
const formula = state.sliceDoc(text.from, text.to);
|
|
53
|
+
|
|
54
|
+
const iter = current?.iter(node.node.from);
|
|
55
|
+
if (iter?.value && iter?.value.spec.formula === formula) {
|
|
56
|
+
// Add existing widget.
|
|
57
|
+
builder.add(node.from, node.to, iter.value);
|
|
58
|
+
} else {
|
|
59
|
+
// TODO(burdon): Create ordered list of cells on each decoration run.
|
|
60
|
+
const cell: CellAddress = { col: node.node.from, row: 0 };
|
|
61
|
+
invariant(computeNode);
|
|
62
|
+
// NOTE: This triggers re-render (below).
|
|
63
|
+
computeNode.setValue(cell, formula);
|
|
64
|
+
const value = computeNode.getValue(cell);
|
|
65
|
+
builder.add(
|
|
66
|
+
node.from,
|
|
67
|
+
node.to,
|
|
68
|
+
Decoration.replace({
|
|
69
|
+
widget: new ComputeWidget(formula, value),
|
|
70
|
+
formula,
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return builder.finish();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return [
|
|
89
|
+
ViewPlugin.fromClass(
|
|
90
|
+
class {
|
|
91
|
+
// Graph subscription.
|
|
92
|
+
private _subscription?: UnsubscribeCallback;
|
|
93
|
+
constructor(view: EditorView) {
|
|
94
|
+
const id = view.state.facet(documentId);
|
|
95
|
+
const computeGraph = view.state.facet(computeGraphFacet);
|
|
96
|
+
if (id && computeGraph) {
|
|
97
|
+
queueMicrotask(async () => {
|
|
98
|
+
computeNode = computeGraph.getOrCreateNode(createSheetName({ type: '', id }));
|
|
99
|
+
await computeNode.open();
|
|
100
|
+
|
|
101
|
+
// Trigger re-render if values updated.
|
|
102
|
+
// TODO(burdon): Trigger only if formula value updated (currently triggered during render).
|
|
103
|
+
this._subscription = computeNode.update.on(
|
|
104
|
+
debounce(({ type, ...rest }) => {
|
|
105
|
+
if (type === 'valuesUpdated') {
|
|
106
|
+
view.dispatch({
|
|
107
|
+
effects: updateAllDecorations.of(),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, 250),
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
destroy() {
|
|
117
|
+
this._subscription?.();
|
|
118
|
+
void computeNode?.close();
|
|
119
|
+
computeNode = undefined;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
),
|
|
123
|
+
|
|
124
|
+
StateField.define<RangeSet<Decoration>>({
|
|
125
|
+
create: (state) => update(state),
|
|
126
|
+
update: (rangeSet: RangeSet<Decoration>, tr: Transaction) => update(tr.state, rangeSet),
|
|
127
|
+
provide: (field) => EditorView.decorations.from(field),
|
|
128
|
+
}),
|
|
129
|
+
];
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// TODO(burdon): Click to edit.
|
|
133
|
+
class ComputeWidget extends WidgetType {
|
|
134
|
+
constructor(
|
|
135
|
+
private readonly formula: string,
|
|
136
|
+
private readonly value: CellScalarValue,
|
|
137
|
+
) {
|
|
138
|
+
super();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
override toDOM(_view: EditorView) {
|
|
142
|
+
const div = document.createElement('div');
|
|
143
|
+
div.setAttribute('title', this.formula);
|
|
144
|
+
div.innerText = String(this.value);
|
|
145
|
+
return div;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { CompletionContext, type CompletionSource } from '@codemirror/autocomplete';
|
|
6
6
|
import { EditorState } from '@codemirror/state';
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
import { testTree } from '@lezer/generator/test';
|
|
9
|
-
import { expect } from 'chai';
|
|
10
8
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
11
|
-
import { describe, test } from 'vitest';
|
|
9
|
+
import { describe, expect, test } from 'vitest';
|
|
12
10
|
|
|
13
11
|
import { sheetExtension } from './extension';
|
|
14
|
-
import { defaultFunctions } from '../../
|
|
12
|
+
import { defaultFunctions } from '../../compute-graph';
|
|
15
13
|
|
|
16
14
|
describe('formula parser', () => {
|
|
17
15
|
const {
|
|
@@ -37,8 +35,8 @@ describe('formula parser', () => {
|
|
|
37
35
|
extensions: sheetExtension({ functions }),
|
|
38
36
|
});
|
|
39
37
|
|
|
40
|
-
const [
|
|
41
|
-
const result = await
|
|
38
|
+
const [fn] = state.languageDataAt<CompletionSource>('autocomplete', text.length);
|
|
39
|
+
const result = await fn(new CompletionContext(state, text.length, true));
|
|
42
40
|
expect(result?.options).to.have.length(1);
|
|
43
41
|
});
|
|
44
42
|
});
|
|
@@ -12,15 +12,17 @@ import {
|
|
|
12
12
|
startCompletion,
|
|
13
13
|
} from '@codemirror/autocomplete';
|
|
14
14
|
import { HighlightStyle, type Language, syntaxHighlighting } from '@codemirror/language';
|
|
15
|
-
import { type Extension
|
|
15
|
+
import { type Extension } from '@codemirror/state';
|
|
16
16
|
import { type EditorView, ViewPlugin, type ViewUpdate, keymap } from '@codemirror/view';
|
|
17
17
|
import { type SyntaxNode } from '@lezer/common';
|
|
18
18
|
import { tags } from '@lezer/highlight';
|
|
19
19
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
20
20
|
|
|
21
|
+
import { singleValueFacet } from '@dxos/react-ui-editor';
|
|
21
22
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
23
|
|
|
23
|
-
import { type FunctionDefinition } from '../../
|
|
24
|
+
import { type FunctionDefinition } from '../../compute-graph';
|
|
25
|
+
import { RANGE_NOTATION } from '../../defs';
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* https://codemirror.net/examples/styling
|
|
@@ -59,7 +61,7 @@ const highlightStyles = HighlightStyle.define([
|
|
|
59
61
|
},
|
|
60
62
|
]);
|
|
61
63
|
|
|
62
|
-
const languageFacet =
|
|
64
|
+
const languageFacet = singleValueFacet<Language>();
|
|
63
65
|
|
|
64
66
|
export type SheetExtensionOptions = {
|
|
65
67
|
functions?: FunctionDefinition[];
|
|
@@ -165,8 +167,6 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
|
|
|
165
167
|
icons: false,
|
|
166
168
|
tooltipClass: () =>
|
|
167
169
|
mx(
|
|
168
|
-
// TODO(burdon): Factor out fragments.
|
|
169
|
-
// TODO(burdon): Size to make width same as column.
|
|
170
170
|
'!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]',
|
|
171
171
|
'[&>ul>li[aria-selected]]:!bg-accentSurface',
|
|
172
172
|
'border-separator',
|
|
@@ -196,34 +196,53 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
|
|
|
196
196
|
];
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
export type
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
export type SelectionRange = { from: number; to: number };
|
|
200
|
+
|
|
201
|
+
export interface RangeController {
|
|
202
|
+
setRange(range: string): void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type RangeExtensionOptions = {
|
|
206
|
+
/**
|
|
207
|
+
* Provides controller callback when extension is initialized.
|
|
208
|
+
*/
|
|
209
|
+
onInit?: (controller: RangeController) => void;
|
|
210
|
+
/**
|
|
211
|
+
* Called when the active range changes.
|
|
212
|
+
* @param state The current state.
|
|
213
|
+
* @param state.activeRange undefined if no range is active, otherwise a possibly partially defined range.
|
|
214
|
+
*/
|
|
215
|
+
onStateChange?: (state: { activeRange: string | undefined }) => void;
|
|
216
|
+
};
|
|
202
217
|
|
|
203
218
|
/**
|
|
204
219
|
* Tracks the currently active cell within a formula and provides a callback to modify it.
|
|
205
220
|
*/
|
|
206
|
-
export const rangeExtension = (onInit
|
|
221
|
+
export const rangeExtension = ({ onInit, onStateChange }: RangeExtensionOptions): Extension => {
|
|
207
222
|
let view: EditorView;
|
|
208
|
-
let activeRange:
|
|
209
|
-
const provider: CellRangeNotifier = (range: string) => {
|
|
210
|
-
if (activeRange) {
|
|
211
|
-
view.dispatch(
|
|
212
|
-
view.state.update({
|
|
213
|
-
changes: { ...activeRange, insert: range.toString() },
|
|
214
|
-
selection: { anchor: activeRange.from + range.length },
|
|
215
|
-
}),
|
|
216
|
-
);
|
|
217
|
-
}
|
|
223
|
+
let activeRange: SelectionRange | undefined;
|
|
218
224
|
|
|
219
|
-
|
|
225
|
+
// Called externally to provide current range.
|
|
226
|
+
const notifier: RangeController = {
|
|
227
|
+
setRange: (range: string) => {
|
|
228
|
+
if (activeRange) {
|
|
229
|
+
view.dispatch(
|
|
230
|
+
view.state.update({
|
|
231
|
+
changes: { ...activeRange, insert: range.toString() },
|
|
232
|
+
selection: { anchor: activeRange.from + range.length },
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
view.focus();
|
|
238
|
+
},
|
|
220
239
|
};
|
|
221
240
|
|
|
222
241
|
return ViewPlugin.fromClass(
|
|
223
242
|
class {
|
|
224
243
|
constructor(_view: EditorView) {
|
|
225
244
|
view = _view;
|
|
226
|
-
onInit(
|
|
245
|
+
onInit?.(notifier);
|
|
227
246
|
}
|
|
228
247
|
|
|
229
248
|
update(view: ViewUpdate) {
|
|
@@ -231,22 +250,20 @@ export const rangeExtension = (onInit: (notifier: CellRangeNotifier) => void): E
|
|
|
231
250
|
|
|
232
251
|
// Find first Range or cell at cursor.
|
|
233
252
|
activeRange = undefined;
|
|
234
|
-
const
|
|
253
|
+
const language = view.state.facet(languageFacet);
|
|
235
254
|
const { topNode } = language.parser.parse(view.state.doc.toString());
|
|
236
255
|
visitTree(topNode, ({ type, from, to }) => {
|
|
237
256
|
if (from <= anchor && to >= anchor) {
|
|
238
257
|
switch (type.name) {
|
|
239
|
-
case 'Function':
|
|
258
|
+
case 'Function':
|
|
240
259
|
// Mark but keep looking.
|
|
241
260
|
activeRange = { from: to, to };
|
|
242
261
|
break;
|
|
243
|
-
}
|
|
244
262
|
|
|
245
|
-
case 'CloseParen':
|
|
263
|
+
case 'CloseParen':
|
|
246
264
|
// Mark but keep looking.
|
|
247
265
|
activeRange = { from, to: from };
|
|
248
266
|
break;
|
|
249
|
-
}
|
|
250
267
|
|
|
251
268
|
case 'RangeToken':
|
|
252
269
|
case 'CellToken':
|
|
@@ -260,8 +277,15 @@ export const rangeExtension = (onInit: (notifier: CellRangeNotifier) => void): E
|
|
|
260
277
|
|
|
261
278
|
// Allow start of formula.
|
|
262
279
|
if (!activeRange && view.state.doc.toString()[0] === '=') {
|
|
263
|
-
|
|
280
|
+
const str = view.state.doc.sliceString(1);
|
|
281
|
+
if (RANGE_NOTATION.test(str)) {
|
|
282
|
+
activeRange = { from: 1, to: str.length + 1 };
|
|
283
|
+
}
|
|
264
284
|
}
|
|
285
|
+
|
|
286
|
+
onStateChange?.({
|
|
287
|
+
activeRange: activeRange ? view.state.doc.sliceString(activeRange.from, activeRange.to) : undefined,
|
|
288
|
+
});
|
|
265
289
|
}
|
|
266
290
|
},
|
|
267
291
|
);
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type IntentResolver, LayoutAction, useIntentDispatcher, useIntentResolver } from '@dxos/app-framework';
|
|
8
|
+
import { debounce } from '@dxos/async';
|
|
9
|
+
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
|
+
import { type DxGridElement, type DxGridPosition } from '@dxos/react-ui-grid';
|
|
11
|
+
|
|
12
|
+
import { useSheetContext } from '../components';
|
|
13
|
+
import { type CellAddress, type CompleteCellRange, inRange } from '../defs';
|
|
14
|
+
import { SHEET_PLUGIN } from '../meta';
|
|
15
|
+
|
|
16
|
+
export const completeCellRangeToThreadCursor = (range: CompleteCellRange): string => {
|
|
17
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const parseThreadAnchorAsCellRange = (cursor: string): CompleteCellRange | null => {
|
|
21
|
+
const coords = cursor.split(',');
|
|
22
|
+
if (coords.length !== 4) {
|
|
23
|
+
return null;
|
|
24
|
+
} else {
|
|
25
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
26
|
+
return {
|
|
27
|
+
from: { col: parseInt(fromCol), row: parseInt(fromRow) },
|
|
28
|
+
to: { col: parseInt(toCol), row: parseInt(toRow) },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null) => {
|
|
34
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
35
|
+
const handleScrollIntoView: IntentResolver = useCallback(
|
|
36
|
+
({ action, data }) => {
|
|
37
|
+
switch (action) {
|
|
38
|
+
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
39
|
+
if (!data?.id || data?.cursor === undefined || data?.id !== fullyQualifiedId(model.sheet)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setActiveRefs(data.thread);
|
|
43
|
+
// TODO(Zan): Everywhere we refer to the cursor in a thread context should change to `anchor`.
|
|
44
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
45
|
+
range && grid?.setFocus({ ...range.to, plane: 'grid' }, true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
[model.sheet, setActiveRefs],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const useSelectThreadOnCellFocus = () => {
|
|
56
|
+
const { model, cursor } = useSheetContext();
|
|
57
|
+
const dispatch = useIntentDispatcher();
|
|
58
|
+
|
|
59
|
+
const threads = useMemo(
|
|
60
|
+
() => model.sheet.threads?.filter((thread): thread is NonNullable<typeof thread> => !!thread) ?? [],
|
|
61
|
+
[
|
|
62
|
+
// TODO(thure): Surely we can find a better dependency for this…
|
|
63
|
+
JSON.stringify(model.sheet.threads),
|
|
64
|
+
],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const selectClosestThread = useCallback(
|
|
68
|
+
(cellAddress: CellAddress) => {
|
|
69
|
+
if (!cellAddress || !threads) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
74
|
+
if (anchor) {
|
|
75
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
76
|
+
return range ? inRange(range, cellAddress) : false;
|
|
77
|
+
} else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (closestThread) {
|
|
83
|
+
void dispatch([
|
|
84
|
+
{ action: 'dxos.org/plugin/thread/action/select', data: { current: fullyQualifiedId(closestThread) } },
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[dispatch, threads],
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const debounced = useMemo(() => {
|
|
92
|
+
return debounce((cellCoords: DxGridPosition) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
93
|
+
}, [selectClosestThread]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!cursor) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
debounced(cursor);
|
|
100
|
+
}, [cursor, debounced]);
|
|
101
|
+
};
|
package/src/meta.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const SHEET_PLUGIN = 'dxos.org/plugin/sheet';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: SHEET_PLUGIN,
|
|
11
|
+
name: 'Sheet',
|
|
12
|
+
description: 'A simple spreadsheet plugin.',
|
|
13
|
+
icon: 'ph--grid-nine--regular',
|
|
14
|
+
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-sheet',
|
|
15
|
+
} satisfies PluginMeta;
|
package/src/model/index.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { Trigger } from '@dxos/async';
|
|
8
|
+
import { FunctionType } from '@dxos/plugin-script/types';
|
|
9
|
+
|
|
10
|
+
import { SheetModel } from './sheet-model';
|
|
11
|
+
import { TestBuilder, testFunctionPlugins } from '../compute-graph/testing';
|
|
12
|
+
import { addressFromA1Notation, createSheet } from '../defs';
|
|
13
|
+
import { type CellScalarValue } from '../types';
|
|
14
|
+
|
|
15
|
+
describe('SheetModel', () => {
|
|
16
|
+
let testBuilder: TestBuilder;
|
|
17
|
+
beforeEach(async () => {
|
|
18
|
+
testBuilder = new TestBuilder({ types: [FunctionType], plugins: testFunctionPlugins });
|
|
19
|
+
await testBuilder.open();
|
|
20
|
+
});
|
|
21
|
+
afterEach(async () => {
|
|
22
|
+
await testBuilder.close();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('async function', async () => {
|
|
26
|
+
const space = await testBuilder.client.spaces.create();
|
|
27
|
+
const graph = testBuilder.registry.createGraph(space);
|
|
28
|
+
await graph.open();
|
|
29
|
+
|
|
30
|
+
// TODO(burdon): Create via factory.
|
|
31
|
+
const sheet = createSheet({ rows: 5, columns: 5 });
|
|
32
|
+
const model = new SheetModel(graph, sheet);
|
|
33
|
+
await model.open();
|
|
34
|
+
testBuilder.ctx.onDispose(() => model.close());
|
|
35
|
+
|
|
36
|
+
// Trigger waits for function invocation.
|
|
37
|
+
const trigger = new Trigger<CellScalarValue>();
|
|
38
|
+
model.setValue(addressFromA1Notation('A1'), '=TEST(100)');
|
|
39
|
+
// TODO(wittjosiah): Currently this fires twice, once for the binding loading & once for the function invocation.
|
|
40
|
+
const unsubscribe = model.update.on((update) => {
|
|
41
|
+
const { type } = update;
|
|
42
|
+
if (type === 'valuesUpdated') {
|
|
43
|
+
const value = model.getValue(addressFromA1Notation('A1'));
|
|
44
|
+
value && trigger.wake(value);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
onTestFinished(() => unsubscribe());
|
|
48
|
+
|
|
49
|
+
// Initial value will be null.
|
|
50
|
+
const v1 = model.getValue(addressFromA1Notation('A1'));
|
|
51
|
+
expect(v1).to.be.null;
|
|
52
|
+
expect(graph.context.info.invocations.TEST).not.to.exist;
|
|
53
|
+
|
|
54
|
+
// Wait until async update triggered.
|
|
55
|
+
const v2 = await trigger.wait();
|
|
56
|
+
expect(v2).to.eq(100);
|
|
57
|
+
expect(graph.context.info.invocations.TEST).to.eq(1);
|
|
58
|
+
});
|
|
59
|
+
});
|