@dxos/plugin-sheet 0.6.12 → 0.6.13-main.548ca8d
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-NDNIS44E.mjs +265 -0
- package/dist/lib/browser/SheetContainer-NDNIS44E.mjs.map +7 -0
- package/dist/lib/browser/chunk-AQSGDA4X.mjs +1614 -0
- package/dist/lib/browser/chunk-AQSGDA4X.mjs.map +7 -0
- package/dist/lib/browser/chunk-D3QTX46O.mjs +14 -0
- package/dist/lib/browser/chunk-D3QTX46O.mjs.map +7 -0
- package/dist/lib/browser/chunk-GKI67SEF.mjs +69 -0
- package/dist/lib/browser/chunk-GKI67SEF.mjs.map +7 -0
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +2966 -0
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +93 -62
- 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/types.mjs +4 -10
- package/dist/lib/node/SheetContainer-YSQGJD7K.cjs +276 -0
- package/dist/lib/node/SheetContainer-YSQGJD7K.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-5XPK2V4A.cjs} +418 -678
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
- package/dist/lib/node/chunk-6F43RV45.cjs +1610 -0
- package/dist/lib/node/chunk-6F43RV45.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-ER3PM7GD.cjs} +29 -45
- package/dist/lib/node/chunk-ER3PM7GD.cjs.map +7 -0
- package/dist/lib/node/chunk-QIFIGEKV.cjs +37 -0
- package/dist/lib/node/chunk-QIFIGEKV.cjs.map +7 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs +55 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +7 -0
- package/dist/lib/node/index.cjs +105 -69
- 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/types.cjs +8 -14
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-M7WRMZDU.mjs +266 -0
- package/dist/lib/node-esm/SheetContainer-M7WRMZDU.mjs.map +7 -0
- package/dist/lib/{browser/chunk-D5AGLXJP.mjs → node-esm/chunk-5WPZCXNS.mjs} +411 -678
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ELTFPX5B.mjs +1615 -0
- package/dist/lib/node-esm/chunk-ELTFPX5B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +16 -0
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZVLLQ2PJ.mjs +70 -0
- package/dist/lib/node-esm/chunk-ZVLLQ2PJ.mjs.map +7 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +280 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +17 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +3 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/index.d.ts +2 -0
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/{CellEditor/CellEditor.stories.d.ts → GridSheet/SheetCellEditor.stories.d.ts} +4 -4
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/index.d.ts +2 -0
- package/dist/types/src/components/GridSheet/index.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +16 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +11 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/index.d.ts +3 -0
- package/dist/types/src/components/SheetContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +27 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/index.d.ts +2 -0
- package/dist/types/src/components/SheetContext/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +36 -6
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +19 -14
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +43 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +6 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/{components/CellEditor → extensions/editor}/extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/index.d.ts +2 -0
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +3 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +64 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +26 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/functions/index.d.ts +4 -0
- package/dist/types/src/graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +5 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +3 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/threads.d.ts +8 -0
- package/dist/types/src/hooks/threads.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -9
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/decorations.d.ts +25 -0
- package/dist/types/src/model/decorations.d.ts.map +1 -0
- package/dist/types/src/model/formatting-model.d.ts +19 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +13 -67
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +98 -32
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +57 -52
- package/src/SheetPlugin.tsx +52 -74
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/FunctionEditor/FunctionEditor.tsx +45 -0
- package/src/components/FunctionEditor/index.ts +5 -0
- package/src/components/GridSheet/GridSheet.stories.tsx +41 -0
- package/src/components/GridSheet/GridSheet.tsx +161 -0
- package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +8 -8
- package/src/components/GridSheet/index.ts +5 -0
- package/src/components/GridSheet/util.ts +144 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +40 -0
- package/src/components/SheetContainer/SheetContainer.tsx +52 -0
- package/src/components/SheetContainer/index.ts +7 -0
- package/src/components/SheetContext/SheetContext.tsx +108 -0
- package/src/components/SheetContext/index.ts +5 -0
- package/src/components/Toolbar/Toolbar.tsx +167 -85
- package/src/components/index.ts +2 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/{model → defs}/types.ts +24 -14
- package/src/defs/util.ts +151 -0
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +147 -0
- package/src/{components/CellEditor → extensions/editor}/extension.test.ts +4 -6
- package/src/{components/CellEditor → extensions/editor}/extension.ts +5 -6
- package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
- package/src/extensions/index.ts +6 -0
- package/src/graph/compute-graph-registry.ts +90 -0
- package/src/graph/compute-graph.stories.tsx +93 -0
- package/src/graph/compute-graph.test.ts +87 -0
- package/src/graph/compute-graph.ts +242 -0
- package/src/graph/compute-node.ts +63 -0
- package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
- package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
- package/src/graph/functions/index.ts +7 -0
- package/src/graph/hyperformula.test.ts +14 -0
- package/src/graph/index.ts +8 -0
- package/src/graph/testing/index.ts +6 -0
- package/src/graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/threads.ts +147 -0
- package/src/hooks/useComputeGraph.ts +28 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +40 -0
- package/src/meta.ts +14 -0
- package/src/model/decorations.ts +64 -0
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +30 -20
- package/src/model/index.ts +3 -3
- package/src/model/sheet-model.test.ts +57 -0
- package/src/model/sheet-model.ts +418 -0
- package/src/sanity.test.ts +40 -0
- package/src/{components/Sheet → testing}/index.ts +1 -1
- package/src/testing/testing.tsx +68 -0
- package/src/translations.ts +6 -1
- package/src/types.ts +40 -41
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/index.d.ts +0 -3
- package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/grid.d.ts +0 -52
- package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/index.d.ts +0 -2
- package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/nav.d.ts +0 -29
- package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/util.d.ts +0 -18
- package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer.d.ts +0 -9
- package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/common.d.ts +0 -20
- package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/CellEditor/CellEditor.tsx +0 -113
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/components/Sheet/Sheet.stories.tsx +0 -287
- package/src/components/Sheet/Sheet.tsx +0 -1160
- package/src/components/Sheet/grid.ts +0 -191
- package/src/components/Sheet/nav.ts +0 -157
- package/src/components/Sheet/sheet-context.tsx +0 -150
- package/src/components/Sheet/util.ts +0 -56
- package/src/components/SheetContainer.tsx +0 -34
- package/src/components/Toolbar/common.tsx +0 -72
- package/src/meta.tsx +0 -18
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
- /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-sheet",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.13-main.548ca8d",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
|
+
"imports": {
|
|
10
|
+
"#hyperformula": {
|
|
11
|
+
"types": "hyperformula",
|
|
12
|
+
"default": "./dist/vendor/hyperformula.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
"exports": {
|
|
10
16
|
".": {
|
|
11
17
|
"browser": "./dist/lib/browser/index.mjs",
|
|
12
18
|
"node": {
|
|
13
|
-
"
|
|
19
|
+
"require": "./dist/lib/node/index.cjs",
|
|
20
|
+
"default": "./dist/lib/node-esm/index.mjs"
|
|
14
21
|
},
|
|
15
22
|
"types": "./dist/types/src/index.d.ts"
|
|
16
23
|
},
|
|
17
24
|
"./meta": {
|
|
18
25
|
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
26
|
"node": {
|
|
20
|
-
"
|
|
27
|
+
"require": "./dist/lib/node/meta.cjs",
|
|
28
|
+
"default": "./dist/lib/node-esm/meta.mjs"
|
|
21
29
|
},
|
|
22
30
|
"types": "./dist/types/src/meta.d.ts"
|
|
23
31
|
},
|
|
24
|
-
"./testing": {
|
|
25
|
-
"browser": "./dist/lib/browser/testing.mjs",
|
|
26
|
-
"node": {
|
|
27
|
-
"default": "./dist/lib/node/testing.cjs"
|
|
28
|
-
},
|
|
29
|
-
"types": "./dist/types/src/testing.d.ts"
|
|
30
|
-
},
|
|
31
32
|
"./types": {
|
|
32
33
|
"browser": "./dist/lib/browser/types.mjs",
|
|
33
34
|
"node": {
|
|
34
|
-
"
|
|
35
|
+
"require": "./dist/lib/node/types.cjs",
|
|
36
|
+
"default": "./dist/lib/node-esm/types.mjs"
|
|
35
37
|
},
|
|
36
38
|
"types": "./dist/types/src/types.d.ts"
|
|
37
39
|
}
|
|
@@ -42,9 +44,6 @@
|
|
|
42
44
|
"meta": [
|
|
43
45
|
"dist/types/src/meta.d.ts"
|
|
44
46
|
],
|
|
45
|
-
"testing": [
|
|
46
|
-
"dist/types/src/testing.d.ts"
|
|
47
|
-
],
|
|
48
47
|
"types": [
|
|
49
48
|
"dist/types/src/types.d.ts"
|
|
50
49
|
]
|
|
@@ -55,50 +54,56 @@
|
|
|
55
54
|
"src"
|
|
56
55
|
],
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"@codemirror/autocomplete": "^6.18.
|
|
59
|
-
"@codemirror/language": "^6.10.
|
|
57
|
+
"@codemirror/autocomplete": "^6.18.1",
|
|
58
|
+
"@codemirror/language": "^6.10.3",
|
|
60
59
|
"@codemirror/state": "^6.4.1",
|
|
61
|
-
"@codemirror/view": "^6.
|
|
60
|
+
"@codemirror/view": "^6.34.1",
|
|
62
61
|
"@dnd-kit/core": "^6.0.5",
|
|
63
62
|
"@dnd-kit/modifiers": "^6.0.0",
|
|
64
63
|
"@dnd-kit/sortable": "^7.0.1",
|
|
65
64
|
"@dnd-kit/utilities": "^3.2.0",
|
|
66
|
-
"@
|
|
67
|
-
"@lezer/
|
|
65
|
+
"@effect/schema": "^0.75.1",
|
|
66
|
+
"@lezer/common": "^1.2.2",
|
|
67
|
+
"@lezer/highlight": "^1.2.1",
|
|
68
68
|
"@lezer/lezer": "^1.1.2",
|
|
69
69
|
"@lezer/lr": "^1.4.2",
|
|
70
70
|
"@preact/signals-core": "^1.6.0",
|
|
71
71
|
"@radix-ui/react-context": "^1.0.0",
|
|
72
72
|
"@tanstack/react-virtual": "^3.9.0",
|
|
73
73
|
"codemirror-lang-spreadsheet": "^1.3.0",
|
|
74
|
+
"date-fns": "^3.3.1",
|
|
74
75
|
"hyperformula": "^2.7.1",
|
|
75
76
|
"lodash.defaultsdeep": "^4.6.1",
|
|
76
77
|
"re-resizable": "^6.9.17",
|
|
77
78
|
"react-markdown": "^8.0.5",
|
|
78
79
|
"react-resize-detector": "^11.0.1",
|
|
79
|
-
"@dxos/app-framework": "0.6.
|
|
80
|
-
"@dxos/async": "0.6.
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/crypto": "0.6.
|
|
84
|
-
"@dxos/
|
|
85
|
-
"@dxos/
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/log": "0.6.
|
|
89
|
-
"@dxos/plugin-client": "0.6.
|
|
90
|
-
"@dxos/plugin-
|
|
91
|
-
"@dxos/plugin-graph": "0.6.
|
|
92
|
-
"@dxos/plugin-
|
|
93
|
-
"@dxos/plugin-
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/
|
|
97
|
-
"@dxos/react-
|
|
80
|
+
"@dxos/app-framework": "0.6.13-main.548ca8d",
|
|
81
|
+
"@dxos/async": "0.6.13-main.548ca8d",
|
|
82
|
+
"@dxos/context": "0.6.13-main.548ca8d",
|
|
83
|
+
"@dxos/client": "0.6.13-main.548ca8d",
|
|
84
|
+
"@dxos/crypto": "0.6.13-main.548ca8d",
|
|
85
|
+
"@dxos/debug": "0.6.13-main.548ca8d",
|
|
86
|
+
"@dxos/invariant": "0.6.13-main.548ca8d",
|
|
87
|
+
"@dxos/keys": "0.6.13-main.548ca8d",
|
|
88
|
+
"@dxos/echo-schema": "0.6.13-main.548ca8d",
|
|
89
|
+
"@dxos/log": "0.6.13-main.548ca8d",
|
|
90
|
+
"@dxos/plugin-client": "0.6.13-main.548ca8d",
|
|
91
|
+
"@dxos/plugin-attention": "0.6.13-main.548ca8d",
|
|
92
|
+
"@dxos/plugin-graph": "0.6.13-main.548ca8d",
|
|
93
|
+
"@dxos/plugin-markdown": "0.6.13-main.548ca8d",
|
|
94
|
+
"@dxos/plugin-space": "0.6.13-main.548ca8d",
|
|
95
|
+
"@dxos/plugin-script": "0.6.13-main.548ca8d",
|
|
96
|
+
"@dxos/plugin-stack": "0.6.13-main.548ca8d",
|
|
97
|
+
"@dxos/react-client": "0.6.13-main.548ca8d",
|
|
98
|
+
"@dxos/react-hooks": "0.6.13-main.548ca8d",
|
|
99
|
+
"@dxos/react-ui-attention": "0.6.13-main.548ca8d",
|
|
100
|
+
"@dxos/react-ui-editor": "0.6.13-main.548ca8d",
|
|
101
|
+
"@dxos/react-ui-grid": "0.6.13-main.548ca8d",
|
|
102
|
+
"@dxos/schema": "0.6.13-main.548ca8d",
|
|
103
|
+
"@dxos/util": "0.6.13-main.548ca8d"
|
|
98
104
|
},
|
|
99
105
|
"devDependencies": {
|
|
100
106
|
"@lezer/generator": "^1.7.1",
|
|
101
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
102
107
|
"@tldraw/indices": "^2.0.0-alpha.14",
|
|
103
108
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
104
109
|
"@types/react": "~18.2.0",
|
|
@@ -106,20 +111,20 @@
|
|
|
106
111
|
"@types/react-window": "^1.8.8",
|
|
107
112
|
"react": "~18.2.0",
|
|
108
113
|
"react-dom": "~18.2.0",
|
|
109
|
-
"vite": "
|
|
110
|
-
"@dxos/echo-generator": "0.6.
|
|
111
|
-
"@dxos/random": "0.6.
|
|
112
|
-
"@dxos/react-ui": "0.6.
|
|
113
|
-
"@dxos/react-ui-theme": "0.6.
|
|
114
|
-
"@dxos/react-ui-types": "0.6.
|
|
115
|
-
"@dxos/storybook-utils": "0.6.
|
|
114
|
+
"vite": "5.4.7",
|
|
115
|
+
"@dxos/echo-generator": "0.6.13-main.548ca8d",
|
|
116
|
+
"@dxos/random": "0.6.13-main.548ca8d",
|
|
117
|
+
"@dxos/react-ui": "0.6.13-main.548ca8d",
|
|
118
|
+
"@dxos/react-ui-theme": "0.6.13-main.548ca8d",
|
|
119
|
+
"@dxos/react-ui-types": "0.6.13-main.548ca8d",
|
|
120
|
+
"@dxos/storybook-utils": "0.6.13-main.548ca8d",
|
|
121
|
+
"@dxos/react-ui-syntax-highlighter": "0.6.13-main.548ca8d"
|
|
116
122
|
},
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"react": "
|
|
120
|
-
"react-
|
|
121
|
-
"@dxos/react-ui": "0.6.
|
|
122
|
-
"@dxos/react-ui-theme": "0.6.12"
|
|
123
|
+
"peerDependencies": {
|
|
124
|
+
"react": "~18.2.0",
|
|
125
|
+
"react-dom": "~18.2.0",
|
|
126
|
+
"@dxos/react-ui": "0.6.13-main.548ca8d",
|
|
127
|
+
"@dxos/react-ui-theme": "0.6.13-main.548ca8d"
|
|
123
128
|
},
|
|
124
129
|
"publishConfig": {
|
|
125
130
|
"access": "public"
|
package/src/SheetPlugin.tsx
CHANGED
|
@@ -2,84 +2,71 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type IconProps, GridNine } from '@phosphor-icons/react';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
parseIntentPlugin,
|
|
11
|
-
resolvePlugin,
|
|
12
|
-
type PluginDefinition,
|
|
13
|
-
type LayoutCoordinate,
|
|
14
|
-
} from '@dxos/app-framework';
|
|
15
|
-
import { create } from '@dxos/echo-schema';
|
|
7
|
+
import { NavigationAction, parseIntentPlugin, resolvePlugin, type PluginDefinition } from '@dxos/app-framework';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
16
9
|
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
17
|
-
import {
|
|
10
|
+
import { createExtension, isActionGroup, type ActionGroup } from '@dxos/plugin-graph';
|
|
18
11
|
import { FunctionType } from '@dxos/plugin-script/types';
|
|
19
12
|
import { SpaceAction } from '@dxos/plugin-space';
|
|
20
13
|
import { getSpace, isEchoObject } from '@dxos/react-client/echo';
|
|
14
|
+
import { Icon } from '@dxos/react-ui';
|
|
21
15
|
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
type ComputeGraph,
|
|
28
|
-
} from './components';
|
|
29
|
-
// TODO(wittjosiah): Refactor. These are not exported from ./components due to depending on ECHO.
|
|
30
|
-
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './components/ComputeGraph/edge-function';
|
|
31
|
-
import { ComputeGraphContextProvider } from './components/ComputeGraph/graph-context';
|
|
16
|
+
import { ComputeGraphContextProvider, SheetContainer } from './components';
|
|
17
|
+
import { compareIndexPositions, createSheet } from './defs';
|
|
18
|
+
import { computeGraphFacet } from './extensions';
|
|
19
|
+
import { type ComputeGraphRegistry } from './graph';
|
|
20
|
+
import { useComputeGraph } from './hooks';
|
|
32
21
|
import meta, { SHEET_PLUGIN } from './meta';
|
|
33
|
-
import { SheetModel } from './model';
|
|
34
22
|
import translations from './translations';
|
|
35
|
-
import {
|
|
23
|
+
import { SheetAction, SheetType, type SheetPluginProvides } from './types';
|
|
36
24
|
|
|
37
25
|
export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
const graphs = create<Record<string, ComputeGraph>>({});
|
|
41
|
-
const setGraph = (key: string, graph: ComputeGraph) => {
|
|
42
|
-
graphs[key] = graph;
|
|
43
|
-
};
|
|
26
|
+
let computeGraphRegistry: ComputeGraphRegistry | undefined;
|
|
44
27
|
|
|
45
28
|
return {
|
|
46
29
|
meta,
|
|
47
30
|
ready: async (plugins) => {
|
|
48
31
|
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
32
|
+
invariant(client);
|
|
33
|
+
let remoteFunctionUrl: string | undefined;
|
|
53
34
|
if (client.config.values.runtime?.services?.edge?.url) {
|
|
54
35
|
const url = new URL('/functions', client.config.values.runtime?.services?.edge?.url);
|
|
55
36
|
url.protocol = 'https';
|
|
56
37
|
remoteFunctionUrl = url.toString();
|
|
57
38
|
}
|
|
39
|
+
|
|
40
|
+
// Async import removes direct dependency on hyperformula.
|
|
41
|
+
const { ComputeGraphRegistry } = await import('./graph');
|
|
42
|
+
computeGraphRegistry = new ComputeGraphRegistry({ remoteFunctionUrl });
|
|
58
43
|
},
|
|
59
44
|
provides: {
|
|
60
45
|
context: ({ children }) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{children}
|
|
64
|
-
</ComputeGraphContextProvider>
|
|
65
|
-
);
|
|
46
|
+
invariant(computeGraphRegistry);
|
|
47
|
+
return <ComputeGraphContextProvider registry={computeGraphRegistry}>{children}</ComputeGraphContextProvider>;
|
|
66
48
|
},
|
|
67
49
|
metadata: {
|
|
68
50
|
records: {
|
|
69
51
|
[SheetType.typename]: {
|
|
70
|
-
label: (object: any) => (object instanceof SheetType ? object.
|
|
52
|
+
label: (object: any) => (object instanceof SheetType ? object.name : undefined),
|
|
71
53
|
placeholder: ['sheet title placeholder', { ns: SHEET_PLUGIN }],
|
|
72
|
-
icon:
|
|
73
|
-
iconSymbol: 'ph--grid-nine--regular',
|
|
54
|
+
icon: 'ph--grid-nine--regular',
|
|
74
55
|
},
|
|
75
56
|
},
|
|
76
57
|
},
|
|
77
58
|
translations,
|
|
78
59
|
echo: {
|
|
79
60
|
// TODO(wittjosiah): Factor out to common package/plugin.
|
|
80
|
-
//
|
|
61
|
+
// FunctionType is currently registered here in case script plugin isn't enabled.
|
|
81
62
|
schema: [SheetType, FunctionType],
|
|
82
63
|
},
|
|
64
|
+
space: {
|
|
65
|
+
onSpaceCreate: {
|
|
66
|
+
label: ['create sheet label', { ns: SHEET_PLUGIN }],
|
|
67
|
+
action: SheetAction.CREATE,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
83
70
|
graph: {
|
|
84
71
|
builder: (plugins) => {
|
|
85
72
|
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
@@ -113,8 +100,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
113
100
|
},
|
|
114
101
|
properties: {
|
|
115
102
|
label: ['create sheet label', { ns: SHEET_PLUGIN }],
|
|
116
|
-
icon:
|
|
117
|
-
iconSymbol: 'ph--grid-nine--regular',
|
|
103
|
+
icon: 'ph--grid-nine--regular',
|
|
118
104
|
testId: 'sheetPlugin.createObject',
|
|
119
105
|
},
|
|
120
106
|
},
|
|
@@ -123,6 +109,16 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
123
109
|
});
|
|
124
110
|
},
|
|
125
111
|
},
|
|
112
|
+
markdown: {
|
|
113
|
+
extensions: ({ document: doc }) => {
|
|
114
|
+
invariant(computeGraphRegistry);
|
|
115
|
+
const space = getSpace(doc);
|
|
116
|
+
if (space) {
|
|
117
|
+
const computeGraph = computeGraphRegistry.getOrCreateGraph(space);
|
|
118
|
+
return computeGraphFacet.of(computeGraph);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
},
|
|
126
122
|
stack: {
|
|
127
123
|
creators: [
|
|
128
124
|
{
|
|
@@ -130,7 +126,8 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
130
126
|
testId: 'sheetPlugin.createSection',
|
|
131
127
|
type: ['plugin name', { ns: SHEET_PLUGIN }],
|
|
132
128
|
label: ['create sheet section label', { ns: SHEET_PLUGIN }],
|
|
133
|
-
|
|
129
|
+
// TODO(thure): Refactor to use strings
|
|
130
|
+
icon: (props: any) => <Icon icon='ph--grid-nine--regular' {...props} />,
|
|
134
131
|
intent: {
|
|
135
132
|
plugin: SHEET_PLUGIN,
|
|
136
133
|
action: SheetAction.CREATE,
|
|
@@ -138,23 +135,20 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
138
135
|
},
|
|
139
136
|
],
|
|
140
137
|
},
|
|
138
|
+
thread: {
|
|
139
|
+
predicate: (data) => data instanceof SheetType,
|
|
140
|
+
createSort: (sheet) => (indexA, indexB) =>
|
|
141
|
+
!indexA || !indexB ? 0 : compareIndexPositions(sheet, indexA, indexB),
|
|
142
|
+
},
|
|
141
143
|
surface: {
|
|
142
|
-
component: ({ data, role
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
144
|
+
component: ({ data, role }) => {
|
|
145
|
+
const space = isEchoObject(data.object) ? getSpace(data.object) : undefined;
|
|
146
|
+
const graph = useComputeGraph(space);
|
|
147
|
+
if (graph && data.object instanceof SheetType) {
|
|
146
148
|
switch (role) {
|
|
147
149
|
case 'article':
|
|
148
150
|
case 'section': {
|
|
149
|
-
return
|
|
150
|
-
<SheetContainer
|
|
151
|
-
sheet={data.object}
|
|
152
|
-
space={space}
|
|
153
|
-
role={role}
|
|
154
|
-
coordinate={data.coordinate as LayoutCoordinate}
|
|
155
|
-
remoteFunctionUrl={remoteFunctionUrl}
|
|
156
|
-
/>
|
|
157
|
-
);
|
|
151
|
+
return <SheetContainer graph={graph} sheet={data.object} role={role} />;
|
|
158
152
|
}
|
|
159
153
|
}
|
|
160
154
|
}
|
|
@@ -166,23 +160,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
166
160
|
resolver: async (intent) => {
|
|
167
161
|
switch (intent.action) {
|
|
168
162
|
case SheetAction.CREATE: {
|
|
169
|
-
|
|
170
|
-
const sheet = createSheet();
|
|
171
|
-
const graph =
|
|
172
|
-
graphs[space.id] ??
|
|
173
|
-
createComputeGraph(
|
|
174
|
-
[
|
|
175
|
-
{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },
|
|
176
|
-
// TODO(wittjosiah): Remove. Needed for current test sheet generated data.
|
|
177
|
-
{ plugin: CustomPlugin, translations: CustomPluginTranslations },
|
|
178
|
-
],
|
|
179
|
-
space,
|
|
180
|
-
{ remoteFunctionUrl },
|
|
181
|
-
);
|
|
182
|
-
const model = new SheetModel(graph, sheet);
|
|
183
|
-
await model.initialize();
|
|
184
|
-
await model.destroy();
|
|
185
|
-
return { data: sheet };
|
|
163
|
+
return { data: createSheet() };
|
|
186
164
|
}
|
|
187
165
|
}
|
|
188
166
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { 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);
|
|
32
|
+
if (!sheet || !graph) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<SheetProvider graph={graph} sheet={sheet}>
|
|
38
|
+
<GridSheet />
|
|
39
|
+
</SheetProvider>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
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, formatting, 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
|
+
setCursor(cell && cell.plane === 'grid' ? { col: cell.col, row: cell.row } : undefined);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
[editing],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// TODO(burdon): Validate formula before closing: hf.validateFormula();
|
|
61
|
+
const handleClose = useCallback<NonNullable<EditorKeysProps['onClose']> | NonNullable<EditorKeysProps['onNav']>>(
|
|
62
|
+
(value, { key, shift }) => {
|
|
63
|
+
if (value !== undefined) {
|
|
64
|
+
model.setValue(dxGridCellIndexToSheetCellAddress(editing!.index), value);
|
|
65
|
+
}
|
|
66
|
+
setEditing(null);
|
|
67
|
+
const axis = ['Enter', 'ArrowUp', 'ArrowDown'].includes(key)
|
|
68
|
+
? 'row'
|
|
69
|
+
: ['Tab', 'ArrowLeft', 'ArrowRight'].includes(key)
|
|
70
|
+
? 'col'
|
|
71
|
+
: undefined;
|
|
72
|
+
const delta = key.startsWith('Arrow') ? (['ArrowUp', 'ArrowLeft'].includes(key) ? -1 : 1) : shift ? -1 : 1;
|
|
73
|
+
dxGrid.current?.refocus(axis, delta);
|
|
74
|
+
},
|
|
75
|
+
[model, editing, setEditing],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const handleAxisResize = useCallback<NonNullable<GridContentProps['onAxisResize']>>(
|
|
79
|
+
({ axis, size, index: numericIndex }) => {
|
|
80
|
+
if (axis === 'row') {
|
|
81
|
+
const rowId = model.sheet.rows[parseInt(numericIndex)];
|
|
82
|
+
model.sheet.rowMeta[rowId] ??= {};
|
|
83
|
+
model.sheet.rowMeta[rowId].size = size;
|
|
84
|
+
} else {
|
|
85
|
+
const columnId = model.sheet.columns[parseInt(numericIndex)];
|
|
86
|
+
model.sheet.columnMeta[columnId] ??= {};
|
|
87
|
+
model.sheet.columnMeta[columnId].size = size;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
[model],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const handleSelect = useCallback<NonNullable<GridContentProps['onSelect']>>(
|
|
94
|
+
({ minCol, maxCol, minRow, maxRow }) => {
|
|
95
|
+
const range: CellRange = { from: { col: minCol, row: minRow } };
|
|
96
|
+
if (minCol !== maxCol || minRow !== maxRow) {
|
|
97
|
+
range.to = { col: maxCol, row: maxRow };
|
|
98
|
+
}
|
|
99
|
+
if (editing) {
|
|
100
|
+
// Update range selection in formula.
|
|
101
|
+
rangeNotifier.current?.(rangeToA1Notation(range));
|
|
102
|
+
} else {
|
|
103
|
+
// Setting range while editing causes focus to move to null, avoid doing so.
|
|
104
|
+
setRange(range.to ? range : undefined);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
[editing],
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const handleWheel = useCallback(
|
|
111
|
+
(event: WheelEvent) => {
|
|
112
|
+
if (!hasAttention) {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
[hasAttention],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model, formatting);
|
|
120
|
+
|
|
121
|
+
const extension = useMemo(
|
|
122
|
+
() => [
|
|
123
|
+
editorKeys({ onClose: handleClose, ...(editing?.initialContent && { onNav: handleClose }) }),
|
|
124
|
+
sheetExtension({ functions: model.graph.getFunctions() }),
|
|
125
|
+
rangeExtension((fn) => (rangeNotifier.current = fn)),
|
|
126
|
+
],
|
|
127
|
+
[model, handleClose, editing],
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const getCellContent = useCallback(
|
|
131
|
+
(index: string) => {
|
|
132
|
+
const cell = dxGridCellIndexToSheetCellAddress(index);
|
|
133
|
+
return model.getCellText(cell);
|
|
134
|
+
},
|
|
135
|
+
[model],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
useUpdateFocusedCellOnThreadSelection(model, dxGrid);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<>
|
|
142
|
+
<GridCellEditor getCellContent={getCellContent} extension={extension} />
|
|
143
|
+
<Grid.Content
|
|
144
|
+
initialCells={initialCells}
|
|
145
|
+
limitColumns={DEFAULT_COLUMNS}
|
|
146
|
+
limitRows={DEFAULT_ROWS}
|
|
147
|
+
columns={columns}
|
|
148
|
+
rows={rows}
|
|
149
|
+
onAxisResize={handleAxisResize}
|
|
150
|
+
onSelect={handleSelect}
|
|
151
|
+
rowDefault={sheetRowDefault}
|
|
152
|
+
columnDefault={sheetColDefault}
|
|
153
|
+
frozen={frozen}
|
|
154
|
+
onFocus={handleFocus}
|
|
155
|
+
onWheelCapture={handleWheel}
|
|
156
|
+
className='[--dx-grid-base:var(--surface-bg)]'
|
|
157
|
+
ref={dxGrid}
|
|
158
|
+
/>
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
};
|