@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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { effect } from '@preact/signals-core';
|
|
6
|
+
import { CellError, ErrorType, FunctionArgumentType } from 'hyperformula';
|
|
6
7
|
import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
|
|
7
8
|
import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
8
9
|
|
|
@@ -12,20 +13,17 @@ import { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';
|
|
|
12
13
|
import { FunctionType } from '@dxos/plugin-script/types';
|
|
13
14
|
import { nonNullable } from '@dxos/util';
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
-
import { type AsyncFunction, AsyncFunctionPlugin } from './async-function';
|
|
16
|
+
import { type AsyncFunction, FunctionPluginAsync } from './async-function';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const FUNCTION_TTL = 10_000;
|
|
18
|
+
const EDGE_FUNCTION_TTL = 10_000;
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
|
-
* A hyperformula function plugin for calling
|
|
21
|
+
* A hyperformula function plugin for calling EDGE functions.
|
|
24
22
|
*
|
|
25
23
|
* https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
|
|
26
24
|
*/
|
|
27
|
-
export class EdgeFunctionPlugin extends
|
|
28
|
-
|
|
25
|
+
export class EdgeFunctionPlugin extends FunctionPluginAsync {
|
|
26
|
+
edge(ast: ProcedureAst, state: InterpreterState) {
|
|
29
27
|
const handler =
|
|
30
28
|
(subscribe = false): AsyncFunction =>
|
|
31
29
|
async (binding: string, ...args: any) => {
|
|
@@ -49,7 +47,7 @@ export class EdgeFunctionPlugin extends AsyncFunctionPlugin {
|
|
|
49
47
|
|
|
50
48
|
// TODO(wittjosiah): `ttl` should be 0 to force a recalculation when a new version is deployed.
|
|
51
49
|
// This needs a ttl to prevent a binding change from causing the function not to be found.
|
|
52
|
-
this.runAsyncFunction(ast, state, handler(false), { ttl:
|
|
50
|
+
this.runAsyncFunction(ast, state, handler(false), { ttl: EDGE_FUNCTION_TTL });
|
|
53
51
|
});
|
|
54
52
|
|
|
55
53
|
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
@@ -61,22 +59,22 @@ export class EdgeFunctionPlugin extends AsyncFunctionPlugin {
|
|
|
61
59
|
headers: { 'Content-Type': 'application/json' },
|
|
62
60
|
body: JSON.stringify({ args: args.filter(nonNullable) }),
|
|
63
61
|
});
|
|
64
|
-
|
|
65
62
|
return await result.text();
|
|
66
63
|
};
|
|
67
64
|
|
|
68
|
-
return this.runAsyncFunction(ast, state, handler(true), { ttl:
|
|
65
|
+
return this.runAsyncFunction(ast, state, handler(true), { ttl: EDGE_FUNCTION_TTL });
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
EdgeFunctionPlugin.implementedFunctions = {
|
|
73
|
-
|
|
74
|
-
method: '
|
|
70
|
+
EDGE: {
|
|
71
|
+
method: 'edge',
|
|
75
72
|
parameters: [
|
|
76
73
|
// Binding
|
|
77
74
|
{ argumentType: FunctionArgumentType.STRING },
|
|
78
75
|
|
|
79
|
-
// Remote function arguments (currently supporting up to
|
|
76
|
+
// Remote function arguments (currently supporting up to 9).
|
|
77
|
+
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
80
78
|
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
81
79
|
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
82
80
|
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
@@ -92,9 +90,9 @@ EdgeFunctionPlugin.implementedFunctions = {
|
|
|
92
90
|
|
|
93
91
|
export const EdgeFunctionPluginTranslations = {
|
|
94
92
|
enGB: {
|
|
95
|
-
|
|
93
|
+
EDGE: 'EDGE',
|
|
96
94
|
},
|
|
97
95
|
enUS: {
|
|
98
|
-
|
|
96
|
+
EDGE: 'EDGE',
|
|
99
97
|
},
|
|
100
98
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { createContext, type PropsWithChildren, useContext, useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
8
|
+
|
|
9
|
+
import { type FunctionContextOptions } from './async-function';
|
|
10
|
+
import { CustomPlugin, CustomPluginTranslations } from './custom';
|
|
11
|
+
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './edge-function';
|
|
12
|
+
import { createComputeGraph, type ComputeGraph } from './graph';
|
|
13
|
+
|
|
14
|
+
export type ComputeGraphContextType = {
|
|
15
|
+
graphs: Record<string, ComputeGraph>;
|
|
16
|
+
setGraph: (key: string, graph: ComputeGraph) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const ComputeGraphContext = createContext<ComputeGraphContextType>({ graphs: {}, setGraph: () => {} });
|
|
20
|
+
|
|
21
|
+
export const ComputeGraphContextProvider = ({
|
|
22
|
+
children,
|
|
23
|
+
graphs,
|
|
24
|
+
setGraph,
|
|
25
|
+
}: PropsWithChildren<ComputeGraphContextType>) => {
|
|
26
|
+
return <ComputeGraphContext.Provider value={{ graphs, setGraph }}>{children}</ComputeGraphContext.Provider>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const useComputeGraph = (space: Space, options?: Partial<FunctionContextOptions>): ComputeGraph => {
|
|
30
|
+
const { graphs, setGraph } = useContext(ComputeGraphContext);
|
|
31
|
+
const graph =
|
|
32
|
+
graphs[space.id] ??
|
|
33
|
+
createComputeGraph(
|
|
34
|
+
[
|
|
35
|
+
{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },
|
|
36
|
+
// TODO(wittjosiah): Remove. Needed for current test sheet generated data.
|
|
37
|
+
{ plugin: CustomPlugin, translations: CustomPluginTranslations },
|
|
38
|
+
],
|
|
39
|
+
space,
|
|
40
|
+
options,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!graphs[space.id]) {
|
|
45
|
+
setGraph(space.id, graph);
|
|
46
|
+
}
|
|
47
|
+
}, [space]);
|
|
48
|
+
|
|
49
|
+
return graph;
|
|
50
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { expect } from 'chai';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { Trigger } from '@dxos/async';
|
|
9
|
+
|
|
10
|
+
import { CustomPlugin, CustomPluginTranslations } from './custom';
|
|
11
|
+
import { createComputeGraph } from './graph';
|
|
12
|
+
import { addressFromA1Notation, SheetModel } from '../../model';
|
|
13
|
+
import { type CellScalarValue, createSheet } from '../../types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* VITEST_ENV=chrome p vitest --watch
|
|
17
|
+
* NOTE: Browser test required for hyperformula due to raw translation files.
|
|
18
|
+
*/
|
|
19
|
+
describe('compute graph', () => {
|
|
20
|
+
const createModel = async () => {
|
|
21
|
+
const graph = createComputeGraph([{ plugin: CustomPlugin, translations: CustomPluginTranslations }]);
|
|
22
|
+
const sheet = createSheet();
|
|
23
|
+
const model = new SheetModel(graph, sheet, undefined, { rows: 5, columns: 5 });
|
|
24
|
+
graph.update.on(() => model.update.emit());
|
|
25
|
+
return { graph, model };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
test('async function', async () => {
|
|
29
|
+
const { graph, model } = await createModel();
|
|
30
|
+
|
|
31
|
+
// Triggers function.
|
|
32
|
+
model.setValue(addressFromA1Notation('A1'), '=TEST()');
|
|
33
|
+
|
|
34
|
+
const trigger = new Trigger<CellScalarValue>();
|
|
35
|
+
model.update.on(() => {
|
|
36
|
+
const value = model.getValue(addressFromA1Notation('A1'));
|
|
37
|
+
trigger.wake(value);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Get initial value (i.e., null).
|
|
41
|
+
const v1 = model.getValue(addressFromA1Notation('A1'));
|
|
42
|
+
expect(v1).to.be.null;
|
|
43
|
+
expect(graph.context.info.invocations.TEST).to.eq(undefined);
|
|
44
|
+
|
|
45
|
+
// Wait until async update triggered.
|
|
46
|
+
const v2 = await trigger.wait();
|
|
47
|
+
expect(v2).not.to.be.null;
|
|
48
|
+
expect(graph.context.info.invocations.TEST).to.eq(1);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type FunctionPluginDefinition, HyperFormula } from 'hyperformula';
|
|
6
|
+
import { type FunctionTranslationsPackage } from 'hyperformula/typings/interpreter';
|
|
7
|
+
|
|
8
|
+
import { Event } from '@dxos/async';
|
|
9
|
+
import { type Space } from '@dxos/client/echo';
|
|
10
|
+
import { PublicKey } from '@dxos/keys';
|
|
11
|
+
import { log } from '@dxos/log';
|
|
12
|
+
|
|
13
|
+
import { FunctionContext, type FunctionContextOptions } from './async-function';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create root graph for space.
|
|
17
|
+
*/
|
|
18
|
+
export const createComputeGraph = (
|
|
19
|
+
// TODO(wittjosiah): Factor out this type to make these easier to define.
|
|
20
|
+
functionPlugins: { plugin: FunctionPluginDefinition; translations: FunctionTranslationsPackage }[] = [],
|
|
21
|
+
space?: Space,
|
|
22
|
+
options?: Partial<FunctionContextOptions>,
|
|
23
|
+
): ComputeGraph => {
|
|
24
|
+
functionPlugins.forEach(({ plugin, translations }) => {
|
|
25
|
+
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const hf = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' });
|
|
29
|
+
return new ComputeGraph(hf, space, options);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Per-space compute and dependency graph.
|
|
34
|
+
*/
|
|
35
|
+
// TODO(burdon): Create instance for each space.
|
|
36
|
+
export class ComputeGraph {
|
|
37
|
+
public readonly id = `graph-${PublicKey.random().truncate()}`;
|
|
38
|
+
public readonly update = new Event();
|
|
39
|
+
|
|
40
|
+
// The context is passed to all functions.
|
|
41
|
+
public readonly context = new FunctionContext(
|
|
42
|
+
this.hf,
|
|
43
|
+
this._space,
|
|
44
|
+
() => {
|
|
45
|
+
this.refresh();
|
|
46
|
+
},
|
|
47
|
+
this._options,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
constructor(
|
|
51
|
+
public readonly hf: HyperFormula,
|
|
52
|
+
private readonly _space?: Space,
|
|
53
|
+
private readonly _options?: Partial<FunctionContextOptions>,
|
|
54
|
+
) {
|
|
55
|
+
this.hf.updateConfig({ context: this.context });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
refresh() {
|
|
59
|
+
log('refresh', { id: this.id });
|
|
60
|
+
this.update.emit();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Decorator } from '@storybook/react';
|
|
8
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { Client } from '@dxos/client';
|
|
11
|
+
import { type EchoReactiveObject } from '@dxos/echo-schema';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
import { getSpace, type Space } from '@dxos/react-client/echo';
|
|
14
|
+
import { Button } from '@dxos/react-ui';
|
|
15
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
16
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
17
|
+
|
|
18
|
+
import { Sheet } from './Sheet';
|
|
19
|
+
import { type SizeMap } from './grid';
|
|
20
|
+
import { useSheetContext } from './sheet-context';
|
|
21
|
+
import { createTestSheet, testSheetName } from '../../testing';
|
|
22
|
+
import { ValueTypeEnum, SheetType } from '../../types';
|
|
23
|
+
import { type ComputeGraph, createComputeGraph } from '../ComputeGraph';
|
|
24
|
+
// TODO(wittjosiah): Refactor. This is not exported from ./components due to depending on ECHO.
|
|
25
|
+
import { ComputeGraphContext, ComputeGraphContextProvider, useComputeGraph } from '../ComputeGraph/graph-context';
|
|
26
|
+
import { Toolbar, type ToolbarActionHandler } from '../Toolbar';
|
|
27
|
+
|
|
28
|
+
// TODO(burdon): Allow toolbar to access sheet context; provide state for current cursor/range.
|
|
29
|
+
const SheetWithToolbar = ({ debug, space }: { debug?: boolean; space: Space }) => {
|
|
30
|
+
const { model, cursor, range } = useSheetContext();
|
|
31
|
+
|
|
32
|
+
// TODO(burdon): Factor out.
|
|
33
|
+
const handleAction: ToolbarActionHandler = ({ type }) => {
|
|
34
|
+
log.info('action', { type, cursor, range });
|
|
35
|
+
if (!cursor) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const idx = range ? model.rangeToIndex(range) : model.addressToIndex(cursor);
|
|
40
|
+
model.sheet.formatting[idx] ??= {};
|
|
41
|
+
const format = model.sheet.formatting[idx];
|
|
42
|
+
|
|
43
|
+
switch (type) {
|
|
44
|
+
case 'clear': {
|
|
45
|
+
// TODO(burdon): Toggle to show all ranges to allow user to delete range.
|
|
46
|
+
format.classNames = [];
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'highlight': {
|
|
50
|
+
// TODO(burdon): Util to add to set.
|
|
51
|
+
format.classNames = ['bg-green-300 dark:bg-green-700'];
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
case 'left': {
|
|
56
|
+
format.classNames = ['text-left'];
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'center': {
|
|
60
|
+
format.classNames = ['text-center'];
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case 'right': {
|
|
64
|
+
format.classNames = ['text-right'];
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
case 'date': {
|
|
69
|
+
format.type = ValueTypeEnum.Date;
|
|
70
|
+
format.format = 'YYYY-MM-DD';
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'currency': {
|
|
74
|
+
format.type = ValueTypeEnum.Currency;
|
|
75
|
+
format.precision = 2;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const graph = useComputeGraph(space);
|
|
82
|
+
const handleRefresh = () => {
|
|
83
|
+
graph.refresh();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className='flex flex-col overflow-hidden'>
|
|
88
|
+
<Toolbar.Root onAction={handleAction}>
|
|
89
|
+
<Toolbar.Styles />
|
|
90
|
+
<Toolbar.Format />
|
|
91
|
+
<Toolbar.Alignment />
|
|
92
|
+
<Toolbar.Separator />
|
|
93
|
+
<Toolbar.Actions />
|
|
94
|
+
<Button onClick={handleRefresh}>Refresh</Button>
|
|
95
|
+
</Toolbar.Root>
|
|
96
|
+
<Sheet.Main />
|
|
97
|
+
{debug && <Sheet.Debug />}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const withGraphDecorator: Decorator = (Story) => {
|
|
103
|
+
const [graphs, setGraphs] = useState<Record<string, ComputeGraph>>({});
|
|
104
|
+
|
|
105
|
+
const setGraph = (key: string, graph: ComputeGraph) => {
|
|
106
|
+
if (!graph.hf.doesSheetExist(testSheetName)) {
|
|
107
|
+
const sheetName = graph.hf.addSheet(testSheetName);
|
|
108
|
+
const sheet = graph.hf.getSheetId(sheetName)!;
|
|
109
|
+
graph.hf.setCellContents({ sheet, col: 0, row: 0 }, Math.random());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setGraphs((graphs) => ({ ...graphs, [key]: graph }));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<ComputeGraphContextProvider graphs={graphs} setGraph={setGraph}>
|
|
117
|
+
<Story />
|
|
118
|
+
</ComputeGraphContextProvider>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default {
|
|
123
|
+
title: 'plugin-sheet/Sheet',
|
|
124
|
+
component: Sheet,
|
|
125
|
+
decorators: [withTheme, withLayout({ fullscreen: true, tooltips: true, classNames: 'inset-4' }), withGraphDecorator],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const Default = () => {
|
|
129
|
+
const [debug, setDebug] = useState(false);
|
|
130
|
+
const sheet = useTestSheet();
|
|
131
|
+
const space = getSpace(sheet);
|
|
132
|
+
if (!sheet || !space) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Sheet.Root sheet={sheet} space={space} onInfo={() => setDebug((debug) => !debug)}>
|
|
138
|
+
<SheetWithToolbar debug={debug} space={space} />
|
|
139
|
+
</Sheet.Root>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const Debug = () => {
|
|
144
|
+
const sheet = useTestSheet();
|
|
145
|
+
const space = getSpace(sheet);
|
|
146
|
+
if (!sheet || !space) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<Sheet.Root sheet={sheet} space={space}>
|
|
152
|
+
<Sheet.Main />
|
|
153
|
+
<Sheet.Debug />
|
|
154
|
+
</Sheet.Root>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const Rows = () => {
|
|
159
|
+
const [rowSizes, setRowSizes] = useState<SizeMap>({});
|
|
160
|
+
const sheet = useTestSheet();
|
|
161
|
+
const space = getSpace(sheet);
|
|
162
|
+
if (!sheet || !space) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<Sheet.Root sheet={sheet} space={space}>
|
|
168
|
+
<Sheet.Rows
|
|
169
|
+
rows={sheet.rows}
|
|
170
|
+
sizes={rowSizes}
|
|
171
|
+
onResize={(id, size) => setRowSizes((sizes) => ({ ...sizes, [id]: size }))}
|
|
172
|
+
/>
|
|
173
|
+
</Sheet.Root>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const Columns = () => {
|
|
178
|
+
const [columnSizes, setColumnSizes] = useState<SizeMap>({});
|
|
179
|
+
const sheet = useTestSheet();
|
|
180
|
+
const space = getSpace(sheet);
|
|
181
|
+
if (!sheet || !space) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<Sheet.Root sheet={sheet} space={space}>
|
|
187
|
+
<Sheet.Columns
|
|
188
|
+
columns={sheet.columns}
|
|
189
|
+
sizes={columnSizes}
|
|
190
|
+
onResize={(id, size) => setColumnSizes((sizes) => ({ ...sizes, [id]: size }))}
|
|
191
|
+
/>
|
|
192
|
+
</Sheet.Root>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const Main = () => {
|
|
197
|
+
const sheet = useTestSheet();
|
|
198
|
+
const space = getSpace(sheet);
|
|
199
|
+
if (!sheet || !space) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Sheet.Root sheet={sheet} space={space}>
|
|
205
|
+
<Sheet.Grid
|
|
206
|
+
size={{
|
|
207
|
+
numRows: 50,
|
|
208
|
+
numColumns: 26,
|
|
209
|
+
}}
|
|
210
|
+
rows={sheet.rows}
|
|
211
|
+
columns={sheet.columns}
|
|
212
|
+
rowSizes={{}}
|
|
213
|
+
columnSizes={{}}
|
|
214
|
+
/>
|
|
215
|
+
</Sheet.Root>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Scrolling container with fixed border that overlaps the border of inner elements.
|
|
221
|
+
*/
|
|
222
|
+
export const ScrollLayout = () => {
|
|
223
|
+
return (
|
|
224
|
+
<div className='relative flex grow overflow-hidden'>
|
|
225
|
+
{/* Fixed border. */}
|
|
226
|
+
<div className='z-20 absolute inset-0 border border-primary-500 pointer-events-none' />
|
|
227
|
+
|
|
228
|
+
{/* Scroll container. */}
|
|
229
|
+
<div className='grow overflow-auto scrollbar-thin'>
|
|
230
|
+
{/* Scroll content. */}
|
|
231
|
+
<div className='relative w-[2000px] h-[2000px]'>
|
|
232
|
+
<Cell label='A1' className='absolute left-0 top-0 w-20 h-20' />
|
|
233
|
+
<Cell label='A1' className='absolute right-0 top-0 w-20 h-20' />
|
|
234
|
+
<Cell label='A1' className='absolute left-0 bottom-0 w-20 h-20' />
|
|
235
|
+
<Cell label='A1' className='absolute right-0 bottom-0 w-20 h-20' />
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const GridLayout = () => {
|
|
243
|
+
return (
|
|
244
|
+
<div className='grid grid-cols-[40px_1fr_40px] grid-rows-[40px_1fr_40px] grow'>
|
|
245
|
+
<Cell label='A1' />
|
|
246
|
+
<Cell label='B1' />
|
|
247
|
+
<Cell label='C1' />
|
|
248
|
+
<Cell label='A2' />
|
|
249
|
+
<Cell label='B2' />
|
|
250
|
+
<Cell label='C2' />
|
|
251
|
+
<Cell label='A3' />
|
|
252
|
+
<Cell label='B3' />
|
|
253
|
+
<Cell label='C3' />
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const Cell = ({ className, label }: { className?: string; label: string }) => (
|
|
259
|
+
<div className={mx('flex items-center justify-center border', className)}>{label}</div>
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
const useTestSheet = () => {
|
|
263
|
+
const { graphs, setGraph } = useContext(ComputeGraphContext);
|
|
264
|
+
const [sheet, setSheet] = useState<EchoReactiveObject<SheetType>>();
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
const t = setTimeout(async () => {
|
|
267
|
+
const client = new Client();
|
|
268
|
+
await client.initialize();
|
|
269
|
+
await client.halo.createIdentity();
|
|
270
|
+
const space = await client.spaces.create();
|
|
271
|
+
client.addTypes([SheetType]);
|
|
272
|
+
|
|
273
|
+
const graph = graphs[space.id] ?? createComputeGraph();
|
|
274
|
+
if (!graphs[space.id]) {
|
|
275
|
+
setGraph(space.id, graph);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const sheet = await createTestSheet({ graph });
|
|
279
|
+
space.db.add(sheet);
|
|
280
|
+
setSheet(sheet);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
return () => clearTimeout(t);
|
|
284
|
+
}, []);
|
|
285
|
+
|
|
286
|
+
return sheet;
|
|
287
|
+
};
|