@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
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { createContext, type PropsWithChildren } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type ComputeGraphRegistry } from '../../graph';
|
|
8
|
-
|
|
9
|
-
export type ComputeGraphContextType = {
|
|
10
|
-
registry: ComputeGraphRegistry;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The compute graph context manages a ComputeGraph for each space.
|
|
15
|
-
*/
|
|
16
|
-
export const ComputeGraphContext = createContext<ComputeGraphContextType | undefined>(undefined);
|
|
17
|
-
|
|
18
|
-
export const ComputeGraphContextProvider = ({ registry, children }: PropsWithChildren<ComputeGraphContextType>) => {
|
|
19
|
-
return <ComputeGraphContext.Provider value={{ registry }}>{children}</ComputeGraphContext.Provider>;
|
|
20
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { Icon } from '@dxos/react-ui';
|
|
8
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
-
|
|
10
|
-
import { addressToA1Notation, rangeToA1Notation } from '../../defs';
|
|
11
|
-
import { useSheetContext } from '../SheetContext';
|
|
12
|
-
|
|
13
|
-
export const FunctionEditor = () => {
|
|
14
|
-
const { model, cursor, range } = useSheetContext();
|
|
15
|
-
|
|
16
|
-
let value;
|
|
17
|
-
let isFormula = false;
|
|
18
|
-
if (cursor) {
|
|
19
|
-
value = model.getCellValue(cursor);
|
|
20
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
21
|
-
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
22
|
-
isFormula = true;
|
|
23
|
-
} else if (value != null) {
|
|
24
|
-
value = String(value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={mx(
|
|
31
|
-
'flex shrink-0 justify-between items-center px-4 py-1 text-sm border-bs !border-separator attention-surface',
|
|
32
|
-
)}
|
|
33
|
-
>
|
|
34
|
-
<div className='flex gap-4 items-center'>
|
|
35
|
-
<div className='flex w-16 items-center font-mono'>
|
|
36
|
-
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
37
|
-
</div>
|
|
38
|
-
<div className='flex gap-2 items-center'>
|
|
39
|
-
<Icon icon='ph--function--regular' classNames={['text-greenText', isFormula ? 'visible' : 'invisible']} />
|
|
40
|
-
<span className='font-mono'>{value}</span>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { useSpace } from '@dxos/react-client/echo';
|
|
8
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
9
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
10
|
-
|
|
11
|
-
import { GridSheet } from './GridSheet';
|
|
12
|
-
import { useComputeGraph } from '../../hooks';
|
|
13
|
-
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
14
|
-
import { SheetType } from '../../types';
|
|
15
|
-
import { SheetProvider } from '../SheetContext';
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
title: 'plugin-sheet/GridSheet',
|
|
19
|
-
component: GridSheet,
|
|
20
|
-
decorators: [
|
|
21
|
-
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
22
|
-
withComputeGraphDecorator(),
|
|
23
|
-
withTheme,
|
|
24
|
-
withLayout({ fullscreen: true, tooltips: true }),
|
|
25
|
-
],
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const Basic = () => {
|
|
29
|
-
const space = useSpace();
|
|
30
|
-
const graph = useComputeGraph(space);
|
|
31
|
-
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
32
|
-
if (!sheet || !graph) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<SheetProvider graph={graph} sheet={sheet}>
|
|
38
|
-
<GridSheet />
|
|
39
|
-
</SheetProvider>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useMemo, useRef, type FocusEvent, type WheelEvent } from 'react';
|
|
6
|
-
|
|
7
|
-
import { useAttention } from '@dxos/react-ui-attention';
|
|
8
|
-
import {
|
|
9
|
-
type DxGridElement,
|
|
10
|
-
Grid,
|
|
11
|
-
type GridContentProps,
|
|
12
|
-
editorKeys,
|
|
13
|
-
type EditorKeysProps,
|
|
14
|
-
GridCellEditor,
|
|
15
|
-
closestCell,
|
|
16
|
-
} from '@dxos/react-ui-grid';
|
|
17
|
-
|
|
18
|
-
import { colLabelCell, dxGridCellIndexToSheetCellAddress, rowLabelCell, useSheetModelDxGridProps } from './util';
|
|
19
|
-
import { rangeToA1Notation, type CellRange, DEFAULT_COLUMNS, DEFAULT_ROWS } from '../../defs';
|
|
20
|
-
import { rangeExtension, sheetExtension, type CellRangeNotifier } from '../../extensions';
|
|
21
|
-
import { useUpdateFocusedCellOnThreadSelection } from '../../hooks';
|
|
22
|
-
import { useSheetContext } from '../SheetContext';
|
|
23
|
-
|
|
24
|
-
const initialCells = {
|
|
25
|
-
grid: {},
|
|
26
|
-
frozenColsStart: [...Array(64)].reduce((acc, _, i) => {
|
|
27
|
-
acc[`0,${i}`] = rowLabelCell(i);
|
|
28
|
-
return acc;
|
|
29
|
-
}, {}),
|
|
30
|
-
frozenRowsStart: [...Array(12)].reduce((acc, _, i) => {
|
|
31
|
-
acc[`${i},0`] = colLabelCell(i);
|
|
32
|
-
return acc;
|
|
33
|
-
}, {}),
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const frozen = {
|
|
37
|
-
frozenColsStart: 1,
|
|
38
|
-
frozenRowsStart: 1,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const sheetRowDefault = { grid: { size: 32, resizeable: true } };
|
|
42
|
-
const sheetColDefault = { frozenColsStart: { size: 48 }, grid: { size: 180, resizeable: true } };
|
|
43
|
-
|
|
44
|
-
export const GridSheet = () => {
|
|
45
|
-
const { id, model, editing, setEditing, setCursor, setRange } = useSheetContext();
|
|
46
|
-
const dxGrid = useRef<DxGridElement | null>(null);
|
|
47
|
-
const rangeNotifier = useRef<CellRangeNotifier>();
|
|
48
|
-
const { hasAttention } = useAttention(id);
|
|
49
|
-
|
|
50
|
-
const handleFocus = useCallback(
|
|
51
|
-
(event: FocusEvent) => {
|
|
52
|
-
if (!editing) {
|
|
53
|
-
const cell = closestCell(event.target);
|
|
54
|
-
if (cell && cell.plane === 'grid') {
|
|
55
|
-
setCursor({ col: cell.col, row: cell.row });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
[editing],
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// TODO(burdon): Validate formula before closing: hf.validateFormula();
|
|
63
|
-
const handleClose = useCallback<NonNullable<EditorKeysProps['onClose']> | NonNullable<EditorKeysProps['onNav']>>(
|
|
64
|
-
(value, { key, shift }) => {
|
|
65
|
-
if (value !== undefined) {
|
|
66
|
-
model.setValue(dxGridCellIndexToSheetCellAddress(editing!.index), value);
|
|
67
|
-
}
|
|
68
|
-
setEditing(null);
|
|
69
|
-
const axis = ['Enter', 'ArrowUp', 'ArrowDown'].includes(key)
|
|
70
|
-
? 'row'
|
|
71
|
-
: ['Tab', 'ArrowLeft', 'ArrowRight'].includes(key)
|
|
72
|
-
? 'col'
|
|
73
|
-
: undefined;
|
|
74
|
-
const delta = key.startsWith('Arrow') ? (['ArrowUp', 'ArrowLeft'].includes(key) ? -1 : 1) : shift ? -1 : 1;
|
|
75
|
-
dxGrid.current?.refocus(axis, delta);
|
|
76
|
-
},
|
|
77
|
-
[model, editing, setEditing],
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const handleAxisResize = useCallback<NonNullable<GridContentProps['onAxisResize']>>(
|
|
81
|
-
({ axis, size, index: numericIndex }) => {
|
|
82
|
-
if (axis === 'row') {
|
|
83
|
-
const rowId = model.sheet.rows[parseInt(numericIndex)];
|
|
84
|
-
model.sheet.rowMeta[rowId] ??= {};
|
|
85
|
-
model.sheet.rowMeta[rowId].size = size;
|
|
86
|
-
} else {
|
|
87
|
-
const columnId = model.sheet.columns[parseInt(numericIndex)];
|
|
88
|
-
model.sheet.columnMeta[columnId] ??= {};
|
|
89
|
-
model.sheet.columnMeta[columnId].size = size;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
[model],
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const handleSelect = useCallback<NonNullable<GridContentProps['onSelect']>>(
|
|
96
|
-
({ minCol, maxCol, minRow, maxRow }) => {
|
|
97
|
-
const range: CellRange = { from: { col: minCol, row: minRow } };
|
|
98
|
-
if (minCol !== maxCol || minRow !== maxRow) {
|
|
99
|
-
range.to = { col: maxCol, row: maxRow };
|
|
100
|
-
}
|
|
101
|
-
if (editing) {
|
|
102
|
-
// Update range selection in formula.
|
|
103
|
-
rangeNotifier.current?.(rangeToA1Notation(range));
|
|
104
|
-
} else {
|
|
105
|
-
// Setting range while editing causes focus to move to null, avoid doing so.
|
|
106
|
-
setRange(range.to ? range : undefined);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
[editing],
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
const handleWheel = useCallback(
|
|
113
|
-
(event: WheelEvent) => {
|
|
114
|
-
if (!hasAttention) {
|
|
115
|
-
event.stopPropagation();
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
[hasAttention],
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
122
|
-
|
|
123
|
-
const extension = useMemo(
|
|
124
|
-
() => [
|
|
125
|
-
editorKeys({ onClose: handleClose, ...(editing?.initialContent && { onNav: handleClose }) }),
|
|
126
|
-
sheetExtension({ functions: model.graph.getFunctions() }),
|
|
127
|
-
rangeExtension((fn) => (rangeNotifier.current = fn)),
|
|
128
|
-
],
|
|
129
|
-
[model, handleClose, editing],
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const getCellContent = useCallback(
|
|
133
|
-
(index: string) => {
|
|
134
|
-
const cell = dxGridCellIndexToSheetCellAddress(index);
|
|
135
|
-
return model.getCellText(cell);
|
|
136
|
-
},
|
|
137
|
-
[model],
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
useUpdateFocusedCellOnThreadSelection(model, dxGrid);
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<>
|
|
144
|
-
<GridCellEditor getCellContent={getCellContent} extension={extension} />
|
|
145
|
-
<Grid.Content
|
|
146
|
-
initialCells={initialCells}
|
|
147
|
-
limitColumns={DEFAULT_COLUMNS}
|
|
148
|
-
limitRows={DEFAULT_ROWS}
|
|
149
|
-
columns={columns}
|
|
150
|
-
rows={rows}
|
|
151
|
-
onAxisResize={handleAxisResize}
|
|
152
|
-
onSelect={handleSelect}
|
|
153
|
-
rowDefault={sheetRowDefault}
|
|
154
|
-
columnDefault={sheetColDefault}
|
|
155
|
-
frozen={frozen}
|
|
156
|
-
onFocus={handleFocus}
|
|
157
|
-
onWheelCapture={handleWheel}
|
|
158
|
-
className='[--dx-grid-base:var(--surface-bg)]'
|
|
159
|
-
ref={dxGrid}
|
|
160
|
-
/>
|
|
161
|
-
</>
|
|
162
|
-
);
|
|
163
|
-
};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type MutableRefObject, useEffect, useLayoutEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { createDocAccessor } from '@dxos/react-client/echo';
|
|
8
|
-
import { parseValue, cellClassesForFieldType } from '@dxos/react-ui-data';
|
|
9
|
-
import {
|
|
10
|
-
type GridContentProps,
|
|
11
|
-
type DxGridElement,
|
|
12
|
-
type DxGridAxisMeta,
|
|
13
|
-
type DxGridPlane,
|
|
14
|
-
type DxGridPlaneRange,
|
|
15
|
-
type DxGridPlaneCells,
|
|
16
|
-
type DxGridCellValue,
|
|
17
|
-
colToA1Notation,
|
|
18
|
-
rowToA1Notation,
|
|
19
|
-
} from '@dxos/react-ui-grid';
|
|
20
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
21
|
-
|
|
22
|
-
import { type CellAddress, inRange, cellClassNameForRange } from '../../defs';
|
|
23
|
-
import { type SheetModel } from '../../model';
|
|
24
|
-
|
|
25
|
-
export const dxGridCellIndexToSheetCellAddress = (index: string): CellAddress => {
|
|
26
|
-
const [colStr, rowStr] = index.split(',');
|
|
27
|
-
return {
|
|
28
|
-
col: parseInt(colStr),
|
|
29
|
-
row: parseInt(rowStr),
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
|
|
34
|
-
return model.sheet.columns.reduce(
|
|
35
|
-
(acc: DxGridAxisMeta, columnId, numericIndex) => {
|
|
36
|
-
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
37
|
-
acc.grid[numericIndex] = { size: model.sheet.columnMeta[columnId].size, resizeable: true };
|
|
38
|
-
}
|
|
39
|
-
return acc;
|
|
40
|
-
},
|
|
41
|
-
{ grid: {} },
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createDxGridRows = (model: SheetModel): DxGridAxisMeta => {
|
|
46
|
-
return model.sheet.rows.reduce(
|
|
47
|
-
(acc: DxGridAxisMeta, rowId, numericIndex) => {
|
|
48
|
-
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
49
|
-
acc.grid[numericIndex] = { size: model.sheet.rowMeta[rowId].size, resizeable: true };
|
|
50
|
-
}
|
|
51
|
-
return acc;
|
|
52
|
-
},
|
|
53
|
-
{ grid: {} },
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const projectCellProps = (model: SheetModel, col: number, row: number): DxGridCellValue => {
|
|
58
|
-
const address = { col, row };
|
|
59
|
-
const rawValue = model.getValue(address);
|
|
60
|
-
if (rawValue === undefined || rawValue === null) {
|
|
61
|
-
return { value: '' };
|
|
62
|
-
}
|
|
63
|
-
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(range, address));
|
|
64
|
-
const type = model.getValueType(address);
|
|
65
|
-
const classNames = ranges?.map(cellClassNameForRange).reverse();
|
|
66
|
-
|
|
67
|
-
return { value: parseValue(type, rawValue), className: mx(cellClassesForFieldType(type), classNames) };
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const gridCellGetter = (model: SheetModel) => {
|
|
71
|
-
// TODO(thure): Actually use the cache.
|
|
72
|
-
const cachedGridCells: DxGridPlaneCells = {};
|
|
73
|
-
return (nextBounds: DxGridPlaneRange): DxGridPlaneCells => {
|
|
74
|
-
[...Array(nextBounds.end.col - nextBounds.start.col)].forEach((_, c0) => {
|
|
75
|
-
return [...Array(nextBounds.end.row - nextBounds.start.row)].forEach((_, r0) => {
|
|
76
|
-
const col = nextBounds.start.col + c0;
|
|
77
|
-
const row = nextBounds.start.row + r0;
|
|
78
|
-
const cell = projectCellProps(model, col, row);
|
|
79
|
-
if (cell.value) {
|
|
80
|
-
cachedGridCells;
|
|
81
|
-
cachedGridCells[`${col},${row}`] = cell;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
return cachedGridCells;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const rowLabelCell = (row: number) => ({
|
|
90
|
-
value: rowToA1Notation(row),
|
|
91
|
-
className: 'text-end !pie-1',
|
|
92
|
-
resizeHandle: 'row',
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
export const colLabelCell = (col: number) => ({ value: colToA1Notation(col), resizeHandle: 'col' });
|
|
96
|
-
|
|
97
|
-
const cellGetter = (model: SheetModel) => {
|
|
98
|
-
const getGridCells = gridCellGetter(model);
|
|
99
|
-
return (nextBounds: DxGridPlaneRange, plane: DxGridPlane): DxGridPlaneCells => {
|
|
100
|
-
switch (plane) {
|
|
101
|
-
case 'grid':
|
|
102
|
-
return getGridCells(nextBounds);
|
|
103
|
-
case 'frozenColsStart':
|
|
104
|
-
return [...Array(nextBounds.end.row - nextBounds.start.row)].reduce((acc, _, r0) => {
|
|
105
|
-
const r = nextBounds.start.row + r0;
|
|
106
|
-
acc[`0,${r}`] = rowLabelCell(r);
|
|
107
|
-
return acc;
|
|
108
|
-
}, {});
|
|
109
|
-
case 'frozenRowsStart':
|
|
110
|
-
return [...Array(nextBounds.end.col - nextBounds.start.col)].reduce((acc, _, c0) => {
|
|
111
|
-
const c = nextBounds.start.col + c0;
|
|
112
|
-
acc[`${c},0`] = colLabelCell(c);
|
|
113
|
-
return acc;
|
|
114
|
-
}, {});
|
|
115
|
-
default:
|
|
116
|
-
return {};
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const useSheetModelDxGridProps = (
|
|
122
|
-
dxGridRef: MutableRefObject<DxGridElement | null>,
|
|
123
|
-
model: SheetModel,
|
|
124
|
-
): Pick<GridContentProps, 'columns' | 'rows'> => {
|
|
125
|
-
const [columns, setColumns] = useState<DxGridAxisMeta>(createDxGridColumns(model));
|
|
126
|
-
const [rows, setRows] = useState<DxGridAxisMeta>(createDxGridColumns(model));
|
|
127
|
-
|
|
128
|
-
useLayoutEffect(() => {
|
|
129
|
-
const cellsAccessor = createDocAccessor(model.sheet, ['cells']);
|
|
130
|
-
if (dxGridRef.current) {
|
|
131
|
-
dxGridRef.current.getCells = cellGetter(model);
|
|
132
|
-
}
|
|
133
|
-
const handleCellsUpdate = () => {
|
|
134
|
-
dxGridRef.current?.requestUpdate('initialCells');
|
|
135
|
-
};
|
|
136
|
-
cellsAccessor.handle.addListener('change', handleCellsUpdate);
|
|
137
|
-
return () => cellsAccessor.handle.removeListener('change', handleCellsUpdate);
|
|
138
|
-
}, [model]);
|
|
139
|
-
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
const columnMetaAccessor = createDocAccessor(model.sheet, ['columnMeta']);
|
|
142
|
-
const rowMetaAccessor = createDocAccessor(model.sheet, ['rowMeta']);
|
|
143
|
-
const handleColumnMetaUpdate = () => {
|
|
144
|
-
setColumns(createDxGridColumns(model));
|
|
145
|
-
};
|
|
146
|
-
const handleRowMetaUpdate = () => {
|
|
147
|
-
setRows(createDxGridRows(model));
|
|
148
|
-
};
|
|
149
|
-
columnMetaAccessor.handle.addListener('change', handleColumnMetaUpdate);
|
|
150
|
-
rowMetaAccessor.handle.addListener('change', handleRowMetaUpdate);
|
|
151
|
-
return () => {
|
|
152
|
-
columnMetaAccessor.handle.removeListener('change', handleColumnMetaUpdate);
|
|
153
|
-
rowMetaAccessor.handle.removeListener('change', handleRowMetaUpdate);
|
|
154
|
-
};
|
|
155
|
-
}, [model]);
|
|
156
|
-
|
|
157
|
-
return { columns, rows };
|
|
158
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { useSpace } from '@dxos/react-client/echo';
|
|
8
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
9
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
10
|
-
|
|
11
|
-
import { SheetContainer } from './SheetContainer';
|
|
12
|
-
import { useComputeGraph } from '../../hooks';
|
|
13
|
-
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
14
|
-
import { SheetType } from '../../types';
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: 'plugin-sheet/SheetContainer',
|
|
18
|
-
component: SheetContainer,
|
|
19
|
-
decorators: [
|
|
20
|
-
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
21
|
-
withComputeGraphDecorator(),
|
|
22
|
-
withTheme,
|
|
23
|
-
withLayout({
|
|
24
|
-
fullscreen: true,
|
|
25
|
-
tooltips: true,
|
|
26
|
-
classNames: 'grid grid-cols-1 grid-rows-[min-content_minmax(0,1fr)_min-content]',
|
|
27
|
-
}),
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const Basic = () => {
|
|
32
|
-
const space = useSpace();
|
|
33
|
-
const graph = useComputeGraph(space);
|
|
34
|
-
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
35
|
-
if (!sheet || !graph) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return <SheetContainer graph={graph} sheet={sheet} role='article' />;
|
|
40
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { FunctionEditor } from '../FunctionEditor';
|
|
8
|
-
import { GridSheet } from '../GridSheet';
|
|
9
|
-
import { SheetProvider, type SheetProviderProps } from '../SheetContext';
|
|
10
|
-
import { Toolbar } from '../Toolbar';
|
|
11
|
-
|
|
12
|
-
export const SheetContainer = ({ graph, sheet, role }: SheetProviderProps & { role?: string }) => {
|
|
13
|
-
return (
|
|
14
|
-
<SheetProvider sheet={sheet} graph={graph}>
|
|
15
|
-
<Toolbar.Root role={role}>
|
|
16
|
-
<Toolbar.Styles />
|
|
17
|
-
<Toolbar.Alignment />
|
|
18
|
-
<Toolbar.Separator />
|
|
19
|
-
<Toolbar.Actions />
|
|
20
|
-
</Toolbar.Root>
|
|
21
|
-
<div role='none' className='border-bs border-separator grid cols-1 rows-[1fr_min-content] min-bs-0'>
|
|
22
|
-
<GridSheet />
|
|
23
|
-
<FunctionEditor />
|
|
24
|
-
</div>
|
|
25
|
-
</SheetProvider>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type PropsWithChildren, createContext, useContext, useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { invariant } from '@dxos/invariant';
|
|
8
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
|
-
import { Grid, useGridContext, type GridScopedProps, type GridEditing } from '@dxos/react-ui-grid';
|
|
10
|
-
|
|
11
|
-
import { type CellAddress, type CellRange } from '../../defs';
|
|
12
|
-
import { type ComputeGraph } from '../../graph';
|
|
13
|
-
import { useSheetModel, useSelectThreadOnCellFocus, useThreadDecorations } from '../../hooks';
|
|
14
|
-
import { type SheetModel, createDecorations } from '../../model';
|
|
15
|
-
import { type SheetType } from '../../types';
|
|
16
|
-
|
|
17
|
-
export type SheetContextValue = {
|
|
18
|
-
id: string;
|
|
19
|
-
|
|
20
|
-
model: SheetModel;
|
|
21
|
-
|
|
22
|
-
// Cursor state.
|
|
23
|
-
// TODO(burdon): Cursor and range should use indices.
|
|
24
|
-
cursor?: CellAddress;
|
|
25
|
-
setCursor: (cell: CellAddress | undefined) => void;
|
|
26
|
-
range?: CellRange;
|
|
27
|
-
setRange: (range: CellRange | undefined) => void;
|
|
28
|
-
|
|
29
|
-
// Editing state (undefined if not editing).
|
|
30
|
-
editing: GridEditing;
|
|
31
|
-
setEditing: (editing: GridEditing) => void;
|
|
32
|
-
|
|
33
|
-
// Events.
|
|
34
|
-
// TODO(burdon): Generalize.
|
|
35
|
-
onInfo?: () => void;
|
|
36
|
-
|
|
37
|
-
// Decorations.
|
|
38
|
-
decorations: ReturnType<typeof createDecorations>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const SheetContext = createContext<SheetContextValue | null>(null);
|
|
42
|
-
|
|
43
|
-
export const useSheetContext = (): SheetContextValue => {
|
|
44
|
-
const context = useContext(SheetContext);
|
|
45
|
-
invariant(context);
|
|
46
|
-
return context;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const SheetProviderImpl = ({
|
|
50
|
-
model,
|
|
51
|
-
onInfo,
|
|
52
|
-
children,
|
|
53
|
-
__gridScope,
|
|
54
|
-
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model'>>>) => {
|
|
55
|
-
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
56
|
-
|
|
57
|
-
// TODO(Zan): Impl. set range and set cursor that scrolls to that cell or range if it is not visible.
|
|
58
|
-
const decorations = useMemo(() => createDecorations(), []);
|
|
59
|
-
|
|
60
|
-
// TODO(thure): Reconnect these.
|
|
61
|
-
const [cursor, setCursor] = useState<CellAddress>();
|
|
62
|
-
const [range, setRange] = useState<CellRange>();
|
|
63
|
-
|
|
64
|
-
useSelectThreadOnCellFocus(model, cursor);
|
|
65
|
-
useThreadDecorations(model, decorations);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<SheetContext.Provider
|
|
69
|
-
value={{
|
|
70
|
-
id,
|
|
71
|
-
model,
|
|
72
|
-
editing,
|
|
73
|
-
setEditing,
|
|
74
|
-
cursor,
|
|
75
|
-
setCursor,
|
|
76
|
-
range,
|
|
77
|
-
setRange,
|
|
78
|
-
// TODO(burdon): Change to event.
|
|
79
|
-
onInfo,
|
|
80
|
-
decorations,
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
83
|
-
{children}
|
|
84
|
-
</SheetContext.Provider>
|
|
85
|
-
);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export type SheetProviderProps = {
|
|
89
|
-
graph: ComputeGraph;
|
|
90
|
-
sheet: SheetType;
|
|
91
|
-
readonly?: boolean;
|
|
92
|
-
} & Pick<SheetContextValue, 'onInfo'>;
|
|
93
|
-
|
|
94
|
-
export const SheetProvider = ({ children, graph, sheet, readonly, onInfo }: PropsWithChildren<SheetProviderProps>) => {
|
|
95
|
-
const model = useSheetModel(graph, sheet, { readonly });
|
|
96
|
-
|
|
97
|
-
return !model ? null : (
|
|
98
|
-
<Grid.Root id={fullyQualifiedId(sheet)}>
|
|
99
|
-
<SheetProviderImpl model={model} onInfo={onInfo}>
|
|
100
|
-
{children}
|
|
101
|
-
</SheetProviderImpl>
|
|
102
|
-
</Grid.Root>
|
|
103
|
-
);
|
|
104
|
-
};
|
package/src/defs/index.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type ClassNameValue } from '@dxos/react-ui';
|
|
6
|
-
|
|
7
|
-
import { type SheetType } from '../types';
|
|
8
|
-
|
|
9
|
-
export const alignKey = 'align';
|
|
10
|
-
export type AlignKey = typeof alignKey;
|
|
11
|
-
export type AlignValue = 'start' | 'center' | 'end' | 'unset';
|
|
12
|
-
|
|
13
|
-
export const commentKey = 'comment';
|
|
14
|
-
export type CommentKey = typeof commentKey;
|
|
15
|
-
export type CommentValue = string;
|
|
16
|
-
|
|
17
|
-
export const styleKey = 'style';
|
|
18
|
-
export type StyleKey = typeof styleKey;
|
|
19
|
-
export type StyleValue = 'highlight' | 'unset';
|
|
20
|
-
|
|
21
|
-
export const cellClassNameForRange = ({ key, value }: SheetType['ranges'][number]): ClassNameValue => {
|
|
22
|
-
switch (key) {
|
|
23
|
-
case 'align':
|
|
24
|
-
switch (value) {
|
|
25
|
-
case 'start':
|
|
26
|
-
return 'text-start';
|
|
27
|
-
case 'center':
|
|
28
|
-
return 'text-center';
|
|
29
|
-
case 'end':
|
|
30
|
-
return 'text-end';
|
|
31
|
-
default:
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
case 'comment':
|
|
35
|
-
return 'bg-gridComment';
|
|
36
|
-
case 'style':
|
|
37
|
-
switch (value) {
|
|
38
|
-
case 'highlight':
|
|
39
|
-
return 'bg-gridHighlight';
|
|
40
|
-
default:
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
default:
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
};
|