@dxos/plugin-sheet 0.6.13-main.ed424a1 → 0.6.13
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-U4H5D34A.mjs +1772 -0
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-5WPZCXNS.mjs → browser/chunk-D5AGLXJP.mjs} +678 -411
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/chunk-FUAGSXA4.mjs +82 -0
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/browser/chunk-JRL5LGCE.mjs +18 -0
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -93
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +12 -6
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +1765 -0
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-5KKJ4NPP.cjs} +678 -418
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs +51 -0
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-DSYKOI4E.cjs} +51 -40
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +69 -105
- package/dist/lib/node/index.cjs.map +3 -3
- 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/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +15 -9
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +14 -0
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/SheetCellEditor.stories.d.ts → CellEditor/CellEditor.stories.d.ts} +4 -4
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/{extensions/editor → components/CellEditor}/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -0
- package/dist/types/src/components/CellEditor/extension.test.d.ts.map +1 -0
- package/dist/types/src/components/CellEditor/index.d.ts +3 -0
- package/dist/types/src/components/CellEditor/index.d.ts.map +1 -0
- package/dist/types/src/{graph/functions → components/ComputeGraph}/async-function.d.ts +5 -14
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts +21 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +20 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +55 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +54 -0
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +52 -0
- package/dist/types/src/components/Sheet/grid.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/Sheet/nav.d.ts +29 -0
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/sheet-context.d.ts +25 -0
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/util.d.ts +18 -0
- package/dist/types/src/components/Sheet/util.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +9 -0
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +9 -33
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +15 -19
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/common.d.ts +20 -0
- package/dist/types/src/components/Toolbar/common.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +9 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/functions/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +67 -13
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +40 -125
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +52 -58
- package/src/SheetPlugin.tsx +74 -52
- package/src/components/{GridSheet/SheetCellEditor.stories.tsx → CellEditor/CellEditor.stories.tsx} +8 -8
- package/src/components/CellEditor/CellEditor.tsx +113 -0
- package/src/{extensions/editor → components/CellEditor}/extension.test.ts +6 -4
- package/src/{extensions/editor → components/CellEditor}/extension.ts +6 -5
- package/src/{extensions/editor → components/CellEditor}/index.ts +1 -0
- package/src/{graph/functions → components/ComputeGraph}/async-function.ts +15 -25
- package/src/{graph/testing/test-plugin.ts → components/ComputeGraph/custom.ts} +14 -44
- package/src/{graph/functions → components/ComputeGraph}/edge-function.ts +14 -16
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +287 -0
- package/src/components/Sheet/Sheet.tsx +1160 -0
- package/src/components/Sheet/formatting.ts +106 -0
- package/src/components/Sheet/grid.ts +191 -0
- package/src/{testing → components/Sheet}/index.ts +1 -1
- package/src/components/Sheet/nav.ts +157 -0
- package/src/components/Sheet/sheet-context.tsx +150 -0
- package/src/components/Sheet/util.ts +56 -0
- package/src/components/SheetContainer.tsx +34 -0
- package/src/components/Toolbar/Toolbar.tsx +112 -242
- package/src/components/Toolbar/common.tsx +72 -0
- package/src/components/index.ts +0 -2
- package/src/meta.tsx +18 -0
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -24
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +47 -40
- package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs +0 -290
- package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs +0 -74
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-D3QTX46O.mjs +0 -14
- package/dist/lib/browser/chunk-D3QTX46O.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +0 -2966
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/browser/chunk-HOG37RYS.mjs +0 -1528
- package/dist/lib/browser/chunk-HOG37RYS.mjs.map +0 -7
- package/dist/lib/browser/graph-M4IQ76QX.mjs +0 -33
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-J7XROAMN.cjs +0 -300
- package/dist/lib/node/SheetContainer-J7XROAMN.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-AXQZA2YS.cjs +0 -1527
- package/dist/lib/node/chunk-AXQZA2YS.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/chunk-QIFIGEKV.cjs +0 -37
- package/dist/lib/node/chunk-QIFIGEKV.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs +0 -55
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs +0 -291
- package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs +0 -1529
- package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +0 -16
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs +0 -75
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +0 -34
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -280
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -17
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.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 -9
- 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 +0 -16
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -11
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/index.d.ts +0 -3
- package/dist/types/src/components/SheetContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +0 -26
- 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/dist/types/src/defs/index.d.ts +0 -4
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts +0 -13
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -6
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/index.d.ts +0 -2
- package/dist/types/src/extensions/editor/index.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -3
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -64
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -26
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts +0 -4
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -5
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts +0 -3
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -25
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.test.d.ts +0 -2
- package/dist/types/src/model/sheet-model.test.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -8
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +0 -45
- package/src/components/FunctionEditor/index.ts +0 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -41
- package/src/components/GridSheet/GridSheet.tsx +0 -163
- package/src/components/GridSheet/index.ts +0 -5
- package/src/components/GridSheet/util.ts +0 -158
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -40
- package/src/components/SheetContainer/SheetContainer.tsx +0 -27
- package/src/components/SheetContainer/index.ts +0 -7
- package/src/components/SheetContext/SheetContext.tsx +0 -104
- package/src/components/SheetContext/index.ts +0 -5
- package/src/defs/index.ts +0 -7
- package/src/defs/sheet-range-types.ts +0 -46
- package/src/defs/util.ts +0 -151
- package/src/extensions/compute.stories.tsx +0 -151
- package/src/extensions/compute.ts +0 -147
- package/src/extensions/index.ts +0 -6
- package/src/graph/compute-graph-registry.ts +0 -90
- package/src/graph/compute-graph.stories.tsx +0 -93
- package/src/graph/compute-graph.test.ts +0 -87
- package/src/graph/compute-graph.ts +0 -242
- package/src/graph/compute-node.ts +0 -63
- package/src/graph/functions/index.ts +0 -7
- package/src/graph/hyperformula.test.ts +0 -14
- package/src/graph/index.ts +0 -8
- package/src/graph/testing/index.ts +0 -6
- package/src/graph/testing/test-builder.ts +0 -54
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/hooks/useSheetModel.ts +0 -40
- package/src/meta.ts +0 -14
- package/src/model/decorations.ts +0 -64
- package/src/model/sheet-model.test.ts +0 -57
- package/src/model/sheet-model.ts +0 -418
- package/src/sanity.test.ts +0 -40
- package/src/testing/testing.tsx +0 -68
- /package/dist/types/src/{extensions/editor → components/CellEditor}/extension.test.d.ts +0 -0
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/functions/function-defs.ts → model/functions.ts} +0 -0
package/src/model/sheet-model.ts
DELETED
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type SimpleCellRange } from 'hyperformula/typings/AbsoluteCellRange';
|
|
6
|
-
import { type SimpleCellAddress } from 'hyperformula/typings/Cell';
|
|
7
|
-
import { type SimpleDate, type SimpleDateTime } from 'hyperformula/typings/DateTimeHelper';
|
|
8
|
-
|
|
9
|
-
import { Event } from '@dxos/async';
|
|
10
|
-
import { Resource } from '@dxos/context';
|
|
11
|
-
import { getTypename } from '@dxos/echo-schema';
|
|
12
|
-
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import { PublicKey } from '@dxos/keys';
|
|
14
|
-
import { log } from '@dxos/log';
|
|
15
|
-
import { FieldValueType } from '@dxos/schema';
|
|
16
|
-
|
|
17
|
-
import { DetailedCellError, ExportedCellChange } from '#hyperformula';
|
|
18
|
-
import {
|
|
19
|
-
addressFromA1Notation,
|
|
20
|
-
addressToA1Notation,
|
|
21
|
-
type CellAddress,
|
|
22
|
-
type CellRange,
|
|
23
|
-
MAX_COLUMNS,
|
|
24
|
-
MAX_ROWS,
|
|
25
|
-
} from '../defs';
|
|
26
|
-
import { addressFromIndex, addressToIndex, initialize, insertIndices, ReadonlyException } from '../defs';
|
|
27
|
-
import { type ComputeNode, type ComputeGraph, createSheetName, type ComputeNodeEvent } from '../graph';
|
|
28
|
-
import { type CellScalarValue, type CellValue, type SheetType } from '../types';
|
|
29
|
-
|
|
30
|
-
// Map sheet types to system types.
|
|
31
|
-
const typeMap: Record<string, FieldValueType> = {
|
|
32
|
-
BOOLEAN: FieldValueType.Boolean,
|
|
33
|
-
NUMBER_RAW: FieldValueType.Number,
|
|
34
|
-
NUMBER_PERCENT: FieldValueType.Percent,
|
|
35
|
-
NUMBER_CURRENCY: FieldValueType.Currency,
|
|
36
|
-
NUMBER_DATETIME: FieldValueType.DateTime,
|
|
37
|
-
NUMBER_DATE: FieldValueType.Date,
|
|
38
|
-
NUMBER_TIME: FieldValueType.Time,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const getTopLeft = (range: CellRange): CellAddress => {
|
|
42
|
-
const to = range.to ?? range.from;
|
|
43
|
-
return { row: Math.min(range.from.row, to.row), col: Math.min(range.from.col, to.col) };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const toSimpleCellAddress = (sheet: number, cell: CellAddress): SimpleCellAddress => ({
|
|
47
|
-
sheet,
|
|
48
|
-
row: cell.row,
|
|
49
|
-
col: cell.col,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const toModelRange = (sheet: number, range: CellRange): SimpleCellRange => ({
|
|
53
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
54
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export type SheetModelOptions = {
|
|
58
|
-
readonly?: boolean;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Spreadsheet data model.
|
|
63
|
-
*
|
|
64
|
-
* [ComputeGraphContext] > [SheetContext]:[SheetModel] > [Sheet.Root]
|
|
65
|
-
*/
|
|
66
|
-
// TODO(burdon): Factor out commonality with ComputeNode. Factor out HF.
|
|
67
|
-
export class SheetModel extends Resource {
|
|
68
|
-
public readonly id = `model-${PublicKey.random().truncate()}`;
|
|
69
|
-
|
|
70
|
-
// Wraps compute node.
|
|
71
|
-
public readonly update = new Event<ComputeNodeEvent>();
|
|
72
|
-
|
|
73
|
-
private _node?: ComputeNode;
|
|
74
|
-
|
|
75
|
-
constructor(
|
|
76
|
-
private readonly _graph: ComputeGraph,
|
|
77
|
-
private readonly _sheet: SheetType,
|
|
78
|
-
private readonly _options: SheetModelOptions = {},
|
|
79
|
-
) {
|
|
80
|
-
super();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get graph() {
|
|
84
|
-
return this._graph;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get sheet() {
|
|
88
|
-
return this._sheet;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get readonly() {
|
|
92
|
-
return this._options.readonly;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
get bounds() {
|
|
96
|
-
return {
|
|
97
|
-
rows: this._sheet.rows.length,
|
|
98
|
-
columns: this._sheet.columns.length,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Initialize sheet and engine.
|
|
104
|
-
*/
|
|
105
|
-
protected override async _open() {
|
|
106
|
-
log('initialize', { id: this.id });
|
|
107
|
-
initialize(this._sheet);
|
|
108
|
-
|
|
109
|
-
// TODO(burdon): SheetModel should extend ComputeNode and be constructed via the graph.
|
|
110
|
-
this._node = this._graph.getOrCreateNode(createSheetName({ type: getTypename(this._sheet)!, id: this._sheet.id }));
|
|
111
|
-
await this._node.open();
|
|
112
|
-
|
|
113
|
-
// Listen for model updates (e.g., async calculations).
|
|
114
|
-
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
115
|
-
this._ctx.onDispose(unsubscribe);
|
|
116
|
-
|
|
117
|
-
this.reset();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Update engine.
|
|
122
|
-
* NOTE: This resets the undo history.
|
|
123
|
-
* @deprecated
|
|
124
|
-
*/
|
|
125
|
-
reset() {
|
|
126
|
-
invariant(this._node);
|
|
127
|
-
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
128
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
129
|
-
invariant(this._node);
|
|
130
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
131
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
132
|
-
value = this._graph.mapFormulaToNative(
|
|
133
|
-
this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)),
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row, col }, value);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Recalculate formulas.
|
|
143
|
-
* NOTE: This resets the undo history.
|
|
144
|
-
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
145
|
-
* @deprecated
|
|
146
|
-
*/
|
|
147
|
-
// TODO(burdon): Remove.
|
|
148
|
-
recalculate() {
|
|
149
|
-
this._node?.graph.hf.rebuildAndRecalculate();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
insertRows(i: number, n = 1) {
|
|
153
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
154
|
-
this.reset();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
insertColumns(i: number, n = 1) {
|
|
158
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
159
|
-
this.reset();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//
|
|
163
|
-
// Undoable actions.
|
|
164
|
-
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Clear range of values.
|
|
169
|
-
*/
|
|
170
|
-
clear(range: CellRange) {
|
|
171
|
-
invariant(this._node);
|
|
172
|
-
const topLeft = getTopLeft(range);
|
|
173
|
-
const values = this._iterRange(range, () => null);
|
|
174
|
-
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
175
|
-
this._iterRange(range, (cell) => {
|
|
176
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
177
|
-
delete this._sheet.cells[idx];
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
cut(range: CellRange) {
|
|
182
|
-
invariant(this._node);
|
|
183
|
-
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
184
|
-
this._iterRange(range, (cell) => {
|
|
185
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
186
|
-
delete this._sheet.cells[idx];
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
copy(range: CellRange) {
|
|
191
|
-
invariant(this._node);
|
|
192
|
-
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
paste(cell: CellAddress) {
|
|
196
|
-
invariant(this._node);
|
|
197
|
-
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
198
|
-
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
199
|
-
for (const change of changes) {
|
|
200
|
-
if (change instanceof ExportedCellChange) {
|
|
201
|
-
const { address, newValue } = change;
|
|
202
|
-
const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
|
|
203
|
-
this._sheet.cells[idx] = { value: newValue };
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// TODO(burdon): Display undo/redo state.
|
|
210
|
-
undo() {
|
|
211
|
-
invariant(this._node);
|
|
212
|
-
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
213
|
-
this._node.graph.hf.undo();
|
|
214
|
-
// this.update.emit();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
redo() {
|
|
219
|
-
invariant(this._node);
|
|
220
|
-
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
221
|
-
this._node.graph.hf.redo();
|
|
222
|
-
// this.update.emit();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Get value from sheet.
|
|
228
|
-
*/
|
|
229
|
-
getCellValue(cell: CellAddress): CellScalarValue {
|
|
230
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
231
|
-
return this._sheet.cells[idx]?.value ?? null;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Get value as a string for editing.
|
|
236
|
-
*/
|
|
237
|
-
getCellText(cell: CellAddress): string | undefined {
|
|
238
|
-
const value = this.getCellValue(cell);
|
|
239
|
-
if (value == null) {
|
|
240
|
-
return undefined;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
244
|
-
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
245
|
-
} else {
|
|
246
|
-
return String(value);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Get array of raw values from sheet.
|
|
252
|
-
*/
|
|
253
|
-
getCellValues(range: CellRange): CellScalarValue[][] {
|
|
254
|
-
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Gets the regular or computed value from the engine.
|
|
259
|
-
*/
|
|
260
|
-
getValue(cell: CellAddress): CellScalarValue {
|
|
261
|
-
// Applies rounding and post-processing.
|
|
262
|
-
invariant(this._node);
|
|
263
|
-
const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
264
|
-
if (value instanceof DetailedCellError) {
|
|
265
|
-
return value.toString();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return value;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Get value type.
|
|
273
|
-
*/
|
|
274
|
-
getValueType(cell: CellAddress): FieldValueType {
|
|
275
|
-
invariant(this._node);
|
|
276
|
-
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
277
|
-
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
278
|
-
return typeMap[type];
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Sets the value, updating the sheet and engine.
|
|
283
|
-
*/
|
|
284
|
-
setValue(cell: CellAddress, value: CellScalarValue) {
|
|
285
|
-
invariant(this._node);
|
|
286
|
-
if (this._options.readonly) {
|
|
287
|
-
throw new ReadonlyException();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Reallocate if > current bounds.
|
|
291
|
-
let refresh = false;
|
|
292
|
-
if (cell.row >= this._sheet.rows.length) {
|
|
293
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
294
|
-
refresh = true;
|
|
295
|
-
}
|
|
296
|
-
if (cell.col >= this._sheet.columns.length) {
|
|
297
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
298
|
-
refresh = true;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (refresh) {
|
|
302
|
-
// TODO(burdon): Remove.
|
|
303
|
-
this.reset();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Insert into engine.
|
|
307
|
-
this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row: cell.row, col: cell.col }, [
|
|
308
|
-
[typeof value === 'string' && value.charAt(0) === '=' ? this._graph.mapFormulaToNative(value) : value],
|
|
309
|
-
]);
|
|
310
|
-
|
|
311
|
-
// Insert into sheet.
|
|
312
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
313
|
-
if (value === undefined || value === null) {
|
|
314
|
-
delete this._sheet.cells[idx];
|
|
315
|
-
} else {
|
|
316
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
317
|
-
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
this._sheet.cells[idx] = { value };
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Sets values from a simple map.
|
|
326
|
-
*/
|
|
327
|
-
setValues(values: Record<string, CellValue>) {
|
|
328
|
-
Object.entries(values).forEach(([key, { value }]) => {
|
|
329
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Iterate range.
|
|
335
|
-
*/
|
|
336
|
-
private _iterRange(range: CellRange, cb: (cell: CellAddress) => CellScalarValue | void): CellScalarValue[][] {
|
|
337
|
-
const to = range.to ?? range.from;
|
|
338
|
-
const rowRange = [Math.min(range.from.row, to.row), Math.max(range.from.row, to.row)];
|
|
339
|
-
const columnRange = [Math.min(range.from.col, to.col), Math.max(range.from.col, to.col)];
|
|
340
|
-
const rows: CellScalarValue[][] = [];
|
|
341
|
-
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
342
|
-
const rowCells: CellScalarValue[] = [];
|
|
343
|
-
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
344
|
-
const value = cb({ row, col: column });
|
|
345
|
-
if (value !== undefined) {
|
|
346
|
-
rowCells.push(value);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
rows.push(rowCells);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return rows;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// TODO(burdon): Delete index.
|
|
357
|
-
private _deleteIndices(indices: string[], i: number, n: number) {
|
|
358
|
-
throw new Error('Not implemented');
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
362
|
-
private _moveIndices(indices: string[], i: number, j: number, n: number) {
|
|
363
|
-
throw new Error('Not implemented');
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
//
|
|
367
|
-
// Indices.
|
|
368
|
-
//
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Map from A1 notation to indices.
|
|
372
|
-
*/
|
|
373
|
-
mapFormulaRefsToIndices(formula: string): string {
|
|
374
|
-
invariant(formula.charAt(0) === '=');
|
|
375
|
-
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
376
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Map from indices to A1 notation.
|
|
382
|
-
*/
|
|
383
|
-
mapFormulaIndicesToRefs(formula: string): string {
|
|
384
|
-
invariant(formula.charAt(0) === '=');
|
|
385
|
-
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
386
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
//
|
|
391
|
-
// Values
|
|
392
|
-
//
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
396
|
-
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
397
|
-
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
398
|
-
*/
|
|
399
|
-
toLocalDate(num: number): Date {
|
|
400
|
-
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
401
|
-
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
toDateTime(num: number): SimpleDateTime {
|
|
405
|
-
invariant(this._node);
|
|
406
|
-
return this._node.graph.hf.numberToDateTime(num) as SimpleDateTime;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
toDate(num: number): SimpleDate {
|
|
410
|
-
invariant(this._node);
|
|
411
|
-
return this._node.graph.hf.numberToDate(num) as SimpleDate;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
toTime(num: number): SimpleDate {
|
|
415
|
-
invariant(this._node);
|
|
416
|
-
return this._node.graph.hf.numberToTime(num) as SimpleDate;
|
|
417
|
-
}
|
|
418
|
-
}
|
package/src/sanity.test.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, test, expect } from 'vitest';
|
|
6
|
-
|
|
7
|
-
// Part 2.
|
|
8
|
-
// TODO(burdon): Cannot test outside of browser.
|
|
9
|
-
// - Cannot test Hyperformula
|
|
10
|
-
// - throws "Cannot convert undefined or null to object" in vitest (no browser).
|
|
11
|
-
// - throws "process.nextTick is not a function" (if browser)
|
|
12
|
-
|
|
13
|
-
import { Client } from '@dxos/client';
|
|
14
|
-
import { create } from '@dxos/client/echo';
|
|
15
|
-
import { FunctionType } from '@dxos/plugin-script/types';
|
|
16
|
-
|
|
17
|
-
// TODO(burdon): Fix test infrastructure:
|
|
18
|
-
// - Need docs? esp. needed for config. need pristine example package?
|
|
19
|
-
// - NOTE for non browser tests, import types from x-plugin/types (otherwise will bring in react deps).
|
|
20
|
-
// - Can't add flags to our tools?
|
|
21
|
-
// - .only / .skip ignored (have to comment out tests)
|
|
22
|
-
|
|
23
|
-
describe('test', () => {
|
|
24
|
-
test('test', async () => {
|
|
25
|
-
const client = new Client();
|
|
26
|
-
client.addTypes([FunctionType]);
|
|
27
|
-
await client.initialize();
|
|
28
|
-
await client.halo.createIdentity();
|
|
29
|
-
|
|
30
|
-
// Part 1.
|
|
31
|
-
// Create script.
|
|
32
|
-
// VITEST_ENV=chromium p test
|
|
33
|
-
// TODO(burdon): Test after initialize.
|
|
34
|
-
// - ERROR "process.nextTick is not a function"
|
|
35
|
-
// - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
|
|
36
|
-
const space = await client.spaces.create();
|
|
37
|
-
const fn = space.db.add(create(FunctionType, { version: 1, binding: 'HELLO' }));
|
|
38
|
-
expect(fn).to.exist;
|
|
39
|
-
});
|
|
40
|
-
});
|
package/src/testing/testing.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Decorator } from '@storybook/react';
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
9
|
-
import { useAsyncState } from '@dxos/react-hooks';
|
|
10
|
-
|
|
11
|
-
import { ComputeGraphContextProvider } from '../components';
|
|
12
|
-
import { createSheet } from '../defs';
|
|
13
|
-
import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '../graph';
|
|
14
|
-
import { type CellValue, type CreateSheetOptions } from '../types';
|
|
15
|
-
|
|
16
|
-
const testSheetName = 'test';
|
|
17
|
-
|
|
18
|
-
export const createTestCells = (): Record<string, CellValue> => ({
|
|
19
|
-
B1: { value: 'Qty2' },
|
|
20
|
-
B3: { value: 1 },
|
|
21
|
-
B4: { value: 2 },
|
|
22
|
-
B5: { value: 3 },
|
|
23
|
-
B7: { value: 'Total' },
|
|
24
|
-
|
|
25
|
-
C1: { value: 'Price' },
|
|
26
|
-
C3: { value: 2_000 },
|
|
27
|
-
C4: { value: 2_500 },
|
|
28
|
-
C5: { value: 3_000 },
|
|
29
|
-
C7: { value: '=SUMPRODUCT(B2:B6, C2:C6)' },
|
|
30
|
-
// C8: { value: '=C7*CRYPTO(D7)' },
|
|
31
|
-
C8: { value: '=C7*TEST()' },
|
|
32
|
-
|
|
33
|
-
D7: { value: 'USD' },
|
|
34
|
-
D8: { value: 'BTC' },
|
|
35
|
-
|
|
36
|
-
E3: { value: '=TODAY()' },
|
|
37
|
-
E4: { value: '=NOW()' },
|
|
38
|
-
|
|
39
|
-
F1: { value: `=${testSheetName}!A1` }, // Ref test sheet.
|
|
40
|
-
F3: { value: true },
|
|
41
|
-
F4: { value: false },
|
|
42
|
-
F5: { value: '8%' },
|
|
43
|
-
F6: { value: '$10000' },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: CreateSheetOptions) => {
|
|
47
|
-
const [sheet] = useAsyncState(async () => {
|
|
48
|
-
if (!space || !graph) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const sheet = createSheet(options);
|
|
53
|
-
space.db.add(sheet);
|
|
54
|
-
return sheet;
|
|
55
|
-
}, [space, graph]);
|
|
56
|
-
return sheet;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const withComputeGraphDecorator =
|
|
60
|
-
(options?: ComputeGraphOptions): Decorator =>
|
|
61
|
-
(Story) => {
|
|
62
|
-
const [registry] = useState(new ComputeGraphRegistry(options));
|
|
63
|
-
return (
|
|
64
|
-
<ComputeGraphContextProvider registry={registry}>
|
|
65
|
-
<Story />
|
|
66
|
-
</ComputeGraphContextProvider>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|