@dxos/plugin-sheet 0.7.4 → 0.7.5-labs.071a3e2
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-IMHGS7Z4.mjs +370 -0
- package/dist/lib/browser/SheetContainer-IMHGS7Z4.mjs.map +7 -0
- package/dist/lib/browser/chunk-AT7F2WDW.mjs +808 -0
- package/dist/lib/browser/chunk-AT7F2WDW.mjs.map +7 -0
- package/dist/lib/browser/chunk-FOO6NGBM.mjs +229 -0
- package/dist/lib/browser/chunk-FOO6NGBM.mjs.map +7 -0
- package/dist/lib/browser/chunk-GAFHJBCU.mjs +18 -0
- package/dist/lib/browser/chunk-GAFHJBCU.mjs.map +7 -0
- package/dist/lib/browser/chunk-LXHRT3CC.mjs +15 -0
- package/dist/lib/browser/chunk-LXHRT3CC.mjs.map +7 -0
- package/dist/lib/browser/chunk-OOSRC36N.mjs +900 -0
- package/dist/lib/browser/chunk-OOSRC36N.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-EGPD4HEX.mjs +27 -0
- package/dist/lib/browser/compute-graph-registry-EGPD4HEX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +80 -324
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-6S2RMLQF.mjs +56 -0
- package/dist/lib/browser/intent-resolver-6S2RMLQF.mjs.map +7 -0
- package/dist/lib/browser/markdown-CFJIWHZX.mjs +26 -0
- package/dist/lib/browser/markdown-CFJIWHZX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-PHKJZYFB.mjs +52 -0
- package/dist/lib/browser/react-surface-PHKJZYFB.mjs.map +7 -0
- package/dist/lib/browser/thread-7ZWW5EA7.mjs +17 -0
- package/dist/lib/browser/thread-7ZWW5EA7.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +62 -0
- package/dist/lib/node/SheetContainer-NNIZN4AK.cjs +364 -0
- package/dist/lib/node/SheetContainer-NNIZN4AK.cjs.map +7 -0
- package/dist/lib/node/chunk-2KCZUH72.cjs +815 -0
- package/dist/lib/node/chunk-2KCZUH72.cjs.map +7 -0
- package/dist/lib/node/chunk-4LSYTNS4.cjs +935 -0
- package/dist/lib/node/chunk-4LSYTNS4.cjs.map +7 -0
- package/dist/lib/node/{chunk-2ZVZI2KJ.cjs → chunk-MLU6KRQN.cjs} +12 -9
- package/dist/lib/node/chunk-MLU6KRQN.cjs.map +7 -0
- package/dist/lib/node/chunk-P4KSGZSS.cjs +251 -0
- package/dist/lib/node/chunk-P4KSGZSS.cjs.map +7 -0
- package/dist/lib/node/{types.cjs → chunk-ZV2RS3QH.cjs} +12 -16
- package/dist/lib/node/chunk-ZV2RS3QH.cjs.map +7 -0
- package/dist/lib/node/compute-graph-registry-GJK5H264.cjs +53 -0
- package/dist/lib/node/compute-graph-registry-GJK5H264.cjs.map +7 -0
- package/dist/lib/node/index.cjs +81 -318
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-I25V7SBT.cjs +69 -0
- package/dist/lib/node/intent-resolver-I25V7SBT.cjs.map +7 -0
- package/dist/lib/node/markdown-YTCSW66K.cjs +40 -0
- package/dist/lib/node/markdown-YTCSW66K.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-HLE6CRA6.cjs +70 -0
- package/dist/lib/node/react-surface-HLE6CRA6.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → thread-DRNYTR6M.cjs} +12 -10
- package/dist/lib/node/thread-DRNYTR6M.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +84 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/SheetContainer-PGDJKGTZ.mjs +371 -0
- package/dist/lib/node-esm/SheetContainer-PGDJKGTZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HPAMZ6SP.mjs +901 -0
- package/dist/lib/node-esm/chunk-HPAMZ6SP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PTOI45NK.mjs +231 -0
- package/dist/lib/node-esm/chunk-PTOI45NK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RTZXXOS2.mjs +20 -0
- package/dist/lib/node-esm/chunk-RTZXXOS2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SX3S7UKU.mjs +16 -0
- package/dist/lib/node-esm/chunk-SX3S7UKU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZM7XLUGL.mjs +809 -0
- package/dist/lib/node-esm/chunk-ZM7XLUGL.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-3F5JCYEN.mjs +28 -0
- package/dist/lib/node-esm/compute-graph-registry-3F5JCYEN.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +80 -324
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-IPRSINII.mjs +57 -0
- package/dist/lib/node-esm/intent-resolver-IPRSINII.mjs.map +7 -0
- package/dist/lib/node-esm/markdown-CGSK44XJ.mjs +27 -0
- package/dist/lib/node-esm/markdown-CGSK44XJ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-PFRJ7V5N.mjs +53 -0
- package/dist/lib/node-esm/react-surface-PFRJ7V5N.mjs.map +7 -0
- package/dist/lib/node-esm/thread-6T5VXPAF.mjs +18 -0
- package/dist/lib/node-esm/thread-6T5VXPAF.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +63 -0
- package/dist/types/src/SheetPlugin.d.ts +1 -3
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +4 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +12 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown.d.ts +6 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/thread.d.ts +6 -0
- package/dist/types/src/capabilities/thread.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +7 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +6 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/align.d.ts +28 -0
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/comment.d.ts +23 -0
- package/dist/types/src/components/SheetToolbar/comment.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/style.d.ts +26 -0
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +8 -0
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +6 -0
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -8
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/{defs → types}/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +105 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/sheet-range-types.d.ts +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +71 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/util.d.ts +5 -1
- package/dist/types/src/types/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -62
- package/src/SheetPlugin.tsx +57 -176
- package/src/capabilities/capabilities.ts +14 -0
- package/src/capabilities/compute-graph-registry.ts +25 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +38 -0
- package/src/capabilities/markdown.ts +22 -0
- package/src/capabilities/react-surface.tsx +37 -0
- package/src/capabilities/thread.ts +14 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
- package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +2 -0
- package/src/components/GridSheet/GridSheet.tsx +15 -18
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
- package/src/components/GridSheet/util.ts +4 -3
- package/src/components/RangeList/RangeList.tsx +2 -1
- package/src/components/SheetContainer/SheetContainer.stories.tsx +28 -23
- package/src/components/SheetContainer/SheetContainer.tsx +3 -8
- package/src/components/SheetContext/SheetContext.tsx +1 -2
- package/src/components/{Toolbar/Toolbar.stories.tsx → SheetToolbar/SheetToolbar.stories.tsx} +4 -8
- package/src/components/SheetToolbar/SheetToolbar.tsx +48 -0
- package/src/components/SheetToolbar/align.ts +68 -0
- package/src/components/SheetToolbar/comment.ts +56 -0
- package/src/components/{Toolbar → SheetToolbar}/index.ts +1 -1
- package/src/components/SheetToolbar/style.ts +72 -0
- package/src/components/SheetToolbar/useToolbarAction.ts +87 -0
- package/src/components/SheetToolbar/useToolbarState.ts +17 -0
- package/src/components/index.ts +0 -1
- package/src/extensions/compute.ts +7 -4
- package/src/extensions/editor/extension.test.ts +2 -1
- package/src/extensions/editor/extension.ts +2 -3
- package/src/index.ts +2 -7
- package/src/integrations/thread-ranges.ts +39 -24
- package/src/meta.ts +4 -2
- package/src/model/sheet-model.test.ts +4 -10
- package/src/model/sheet-model.ts +30 -22
- package/src/model/testing.ts +3 -2
- package/src/model/useSheetModel.ts +2 -1
- package/src/sanity.test.ts +1 -1
- package/src/testing/testing.tsx +2 -3
- package/src/{defs → types}/index.ts +1 -0
- package/src/types/schema.ts +56 -0
- package/src/{defs → types}/sheet-range-types.ts +1 -1
- package/src/types/types.ts +67 -0
- package/src/{defs → types}/util.ts +13 -13
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs +0 -296
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs +0 -1675
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
- package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
- package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
- package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
- package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
- package/dist/lib/browser/chunk-RABELMEQ.mjs +0 -15
- package/dist/lib/browser/chunk-RABELMEQ.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/types.mjs +0 -16
- package/dist/lib/browser/types.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs +0 -298
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
- package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +0 -7
- package/dist/lib/node/chunk-45YW2DX2.cjs +0 -1656
- package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
- package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
- package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
- package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
- package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
- package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
- package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs +0 -297
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs +0 -17
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs +0 -1676
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
- 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/SheetObjectSettings.d.ts +0 -7
- package/dist/types/src/components/SheetObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -48
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -7
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
- package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
- package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/index.d.ts +0 -5
- package/dist/types/src/compute-graph/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
- package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/compute-graph/util.d.ts +0 -2
- package/dist/types/src/compute-graph/util.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts +0 -26
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts +0 -2
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -182
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/SheetObjectSettings.tsx +0 -38
- package/src/components/Toolbar/Toolbar.tsx +0 -346
- package/src/compute-graph/compute-graph-registry.ts +0 -90
- package/src/compute-graph/compute-graph.test.ts +0 -87
- package/src/compute-graph/compute-graph.ts +0 -260
- package/src/compute-graph/compute-node.ts +0 -62
- package/src/compute-graph/functions/async-function.ts +0 -179
- package/src/compute-graph/functions/edge-function.ts +0 -102
- package/src/compute-graph/functions/function-defs.ts +0 -2427
- package/src/compute-graph/functions/index.ts +0 -7
- package/src/compute-graph/hyperformula.test.ts +0 -14
- package/src/compute-graph/index.ts +0 -8
- package/src/compute-graph/testing/index.ts +0 -6
- package/src/compute-graph/testing/test-builder.ts +0 -54
- package/src/compute-graph/testing/test-plugin.ts +0 -100
- package/src/compute-graph/util.ts +0 -8
- package/src/defs/types.test.ts +0 -91
- package/src/defs/types.ts +0 -88
- package/src/types.ts +0 -125
- /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
- /package/dist/lib/{browser/meta.mjs.map → node-esm/types/index.mjs.map} +0 -0
- /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
package/src/SheetPlugin.tsx
CHANGED
|
@@ -2,190 +2,71 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
|
|
6
|
+
import { FunctionType } from '@dxos/functions';
|
|
7
|
+
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
6
8
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
10
|
-
import { createExtension, isActionGroup, type ActionGroup } from '@dxos/plugin-graph';
|
|
11
|
-
import { FunctionType } from '@dxos/plugin-script/types';
|
|
12
|
-
import { SpaceAction } from '@dxos/plugin-space';
|
|
13
|
-
import { getSpace, isEchoObject } from '@dxos/react-client/echo';
|
|
14
|
-
import { Icon } from '@dxos/react-ui';
|
|
15
|
-
|
|
16
|
-
import { ComputeGraphContextProvider, SheetContainer, SheetObjectSettings } from './components';
|
|
17
|
-
import { type ComputeGraphRegistry } from './compute-graph';
|
|
18
|
-
import { compareIndexPositions, createSheet } from './defs';
|
|
19
|
-
import { computeGraphFacet } from './extensions';
|
|
20
|
-
import meta, { SHEET_PLUGIN } from './meta';
|
|
9
|
+
import { Markdown, Thread, ReactSurface, IntentResolver, ComputeGraphRegistry } from './capabilities';
|
|
10
|
+
import { meta, SHEET_PLUGIN } from './meta';
|
|
21
11
|
import { serializer } from './serializer';
|
|
22
12
|
import translations from './translations';
|
|
23
|
-
import { SheetAction, SheetType
|
|
24
|
-
|
|
25
|
-
export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
26
|
-
let computeGraphRegistry: ComputeGraphRegistry | undefined;
|
|
13
|
+
import { SheetAction, SheetType } from './types';
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
metadata: {
|
|
50
|
-
records: {
|
|
51
|
-
[SheetType.typename]: {
|
|
52
|
-
createObject: SheetAction.CREATE,
|
|
15
|
+
export const SheetPlugin = () =>
|
|
16
|
+
definePlugin(meta, [
|
|
17
|
+
defineModule({
|
|
18
|
+
id: `${meta.id}/module/compute-graph-registry`,
|
|
19
|
+
activatesOn: ClientEvents.ClientReady,
|
|
20
|
+
activate: ComputeGraphRegistry,
|
|
21
|
+
}),
|
|
22
|
+
defineModule({
|
|
23
|
+
id: `${meta.id}/module/translations`,
|
|
24
|
+
activatesOn: Events.SetupTranslations,
|
|
25
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
26
|
+
}),
|
|
27
|
+
defineModule({
|
|
28
|
+
id: `${meta.id}/module/metadata`,
|
|
29
|
+
activatesOn: Events.SetupMetadata,
|
|
30
|
+
activate: () =>
|
|
31
|
+
contributes(Capabilities.Metadata, {
|
|
32
|
+
id: SheetType.typename,
|
|
33
|
+
metadata: {
|
|
34
|
+
createObject: (props: { name?: string }) => createIntent(SheetAction.Create, props),
|
|
53
35
|
label: (object: any) => (object instanceof SheetType ? object.name : undefined),
|
|
54
36
|
placeholder: ['sheet title placeholder', { ns: SHEET_PLUGIN }],
|
|
55
37
|
icon: 'ph--grid-nine--regular',
|
|
56
38
|
serializer,
|
|
57
39
|
},
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
}),
|
|
41
|
+
}),
|
|
42
|
+
defineModule({
|
|
43
|
+
id: `${meta.id}/module/schema`,
|
|
44
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
45
|
+
activate: () => [
|
|
46
|
+
contributes(ClientCapabilities.Schema, [SheetType]),
|
|
63
47
|
// TODO(wittjosiah): Factor out to common package/plugin.
|
|
64
48
|
// FunctionType is currently registered here in case script plugin isn't enabled.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
id: `${SHEET_PLUGIN}/create/${node.id}`,
|
|
91
|
-
data: async () => {
|
|
92
|
-
await dispatch([
|
|
93
|
-
{ plugin: SHEET_PLUGIN, action: SheetAction.CREATE, data: { space } },
|
|
94
|
-
{ action: SpaceAction.ADD_OBJECT, data: { target } },
|
|
95
|
-
{ action: NavigationAction.OPEN },
|
|
96
|
-
]);
|
|
97
|
-
},
|
|
98
|
-
properties: {
|
|
99
|
-
label: ['create sheet label', { ns: SHEET_PLUGIN }],
|
|
100
|
-
icon: 'ph--grid-nine--regular',
|
|
101
|
-
testId: 'sheetPlugin.createObject',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
markdown: {
|
|
110
|
-
extensions: ({ document: doc }) => {
|
|
111
|
-
invariant(computeGraphRegistry);
|
|
112
|
-
const space = getSpace(doc);
|
|
113
|
-
if (space) {
|
|
114
|
-
const computeGraph = computeGraphRegistry.getOrCreateGraph(space);
|
|
115
|
-
return computeGraphFacet.of(computeGraph);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
stack: {
|
|
120
|
-
creators: [
|
|
121
|
-
{
|
|
122
|
-
id: 'create-stack-section-sheet',
|
|
123
|
-
testId: 'sheetPlugin.createSection',
|
|
124
|
-
type: ['plugin name', { ns: SHEET_PLUGIN }],
|
|
125
|
-
label: ['create sheet section label', { ns: SHEET_PLUGIN }],
|
|
126
|
-
// TODO(thure): Refactor to use strings
|
|
127
|
-
icon: (props: any) => <Icon icon='ph--grid-nine--regular' {...props} />,
|
|
128
|
-
intent: {
|
|
129
|
-
plugin: SHEET_PLUGIN,
|
|
130
|
-
action: SheetAction.CREATE,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
thread: {
|
|
136
|
-
predicate: (data) => data instanceof SheetType,
|
|
137
|
-
createSort: (sheet) => (indexA, indexB) =>
|
|
138
|
-
!indexA || !indexB ? 0 : compareIndexPositions(sheet, indexA, indexB),
|
|
139
|
-
},
|
|
140
|
-
surface: {
|
|
141
|
-
component: ({ data, role }) => {
|
|
142
|
-
const space = isEchoObject(data.object) ? getSpace(data.object) : undefined;
|
|
143
|
-
switch (role) {
|
|
144
|
-
case 'article':
|
|
145
|
-
case 'section':
|
|
146
|
-
if (space && data.object instanceof SheetType) {
|
|
147
|
-
return <SheetContainer space={space} sheet={data.object} role={role} />;
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
case 'complementary--settings':
|
|
151
|
-
if (data.subject instanceof SheetType) {
|
|
152
|
-
return <SheetObjectSettings sheet={data.subject} />;
|
|
153
|
-
}
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return null;
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
intent: {
|
|
161
|
-
resolver: async (intent) => {
|
|
162
|
-
switch (intent.action) {
|
|
163
|
-
case SheetAction.CREATE: {
|
|
164
|
-
return { data: createSheet() };
|
|
165
|
-
}
|
|
166
|
-
case SheetAction.INSERT_AXIS: {
|
|
167
|
-
const { model, axis, index, count } = intent.data as SheetAction.InsertAxis;
|
|
168
|
-
const _indices = model[axis === 'col' ? 'insertColumns' : 'insertRows'](index, count);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
case SheetAction.DROP_AXIS: {
|
|
172
|
-
if (!intent.undo) {
|
|
173
|
-
const { model, axis, axisIndex } = intent.data as SheetAction.DropAxis;
|
|
174
|
-
const undoData = model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
175
|
-
return {
|
|
176
|
-
undoable: {
|
|
177
|
-
message: (translations[0]['en-US'][SHEET_PLUGIN] as any)[`${axis} dropped label`],
|
|
178
|
-
data: { ...undoData, model },
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
} else {
|
|
182
|
-
const { model, ...undoData } = intent.data as SheetAction.DropAxisRestore;
|
|
183
|
-
model[undoData.axis === 'col' ? 'restoreColumn' : 'restoreRow'](undoData);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
};
|
|
49
|
+
contributes(ClientCapabilities.SystemSchema, [FunctionType]),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
defineModule({
|
|
53
|
+
id: `${meta.id}/module/markdown`,
|
|
54
|
+
activatesOn: Events.Startup,
|
|
55
|
+
activate: Markdown,
|
|
56
|
+
}),
|
|
57
|
+
defineModule({
|
|
58
|
+
id: `${meta.id}/module/thread`,
|
|
59
|
+
activatesOn: Events.Startup,
|
|
60
|
+
activate: Thread,
|
|
61
|
+
}),
|
|
62
|
+
defineModule({
|
|
63
|
+
id: `${meta.id}/module/react-surface`,
|
|
64
|
+
activatesOn: Events.SetupSurfaces,
|
|
65
|
+
activate: ReactSurface,
|
|
66
|
+
}),
|
|
67
|
+
defineModule({
|
|
68
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
69
|
+
activatesOn: Events.SetupIntents,
|
|
70
|
+
activate: IntentResolver,
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineCapability } from '@dxos/app-framework';
|
|
6
|
+
import { type ComputeGraphRegistry } from '@dxos/compute';
|
|
7
|
+
|
|
8
|
+
import { SHEET_PLUGIN } from '../meta';
|
|
9
|
+
|
|
10
|
+
export namespace SheetCapabilities {
|
|
11
|
+
export const ComputeGraphRegistry = defineCapability<ComputeGraphRegistry>(
|
|
12
|
+
`${SHEET_PLUGIN}/capability/compute-graph-registry`,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
7
|
+
|
|
8
|
+
import { SheetCapabilities } from './capabilities';
|
|
9
|
+
|
|
10
|
+
export default async (context: PluginsContext) => {
|
|
11
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
12
|
+
let remoteFunctionUrl: string | undefined;
|
|
13
|
+
if (client.config.values.runtime?.services?.edge?.url) {
|
|
14
|
+
const url = new URL('/functions', client.config.values.runtime?.services?.edge?.url);
|
|
15
|
+
url.protocol = 'https';
|
|
16
|
+
remoteFunctionUrl = url.toString();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO(wittjosiah): This can probably be a module level import now due to lazy capability loading.
|
|
20
|
+
// Async import removes direct dependency on hyperformula.
|
|
21
|
+
const { defaultPlugins, ComputeGraphRegistry } = await import('@dxos/compute');
|
|
22
|
+
const computeGraphRegistry = new ComputeGraphRegistry({ plugins: defaultPlugins, remoteFunctionUrl });
|
|
23
|
+
|
|
24
|
+
return contributes(SheetCapabilities.ComputeGraphRegistry, computeGraphRegistry);
|
|
25
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const ComputeGraphRegistry = lazy(() => import('./compute-graph-registry'));
|
|
8
|
+
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
9
|
+
export const Markdown = lazy(() => import('./markdown'));
|
|
10
|
+
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
11
|
+
export const Thread = lazy(() => import('./thread'));
|
|
12
|
+
|
|
13
|
+
export * from './capabilities';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes, Capabilities, createResolver } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { SHEET_PLUGIN } from '../meta';
|
|
8
|
+
import { createSheet, SheetAction } from '../types';
|
|
9
|
+
|
|
10
|
+
export default () =>
|
|
11
|
+
contributes(Capabilities.IntentResolver, [
|
|
12
|
+
createResolver({
|
|
13
|
+
intent: SheetAction.Create,
|
|
14
|
+
resolve: ({ name }) => ({ data: { object: createSheet({ name }) } }),
|
|
15
|
+
}),
|
|
16
|
+
createResolver({
|
|
17
|
+
intent: SheetAction.InsertAxis,
|
|
18
|
+
resolve: ({ model, axis, index, count }) => {
|
|
19
|
+
const _indices = model[axis === 'col' ? 'insertColumns' : 'insertRows'](index, count);
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
createResolver({
|
|
23
|
+
intent: SheetAction.DropAxis,
|
|
24
|
+
resolve: ({ model, axis, axisIndex, deletionData }, undo) => {
|
|
25
|
+
if (!undo) {
|
|
26
|
+
const undoData = model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
27
|
+
return {
|
|
28
|
+
undoable: {
|
|
29
|
+
message: [`${axis} dropped label`, { ns: SHEET_PLUGIN }],
|
|
30
|
+
data: { ...undoData, model },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
} else if (undo && deletionData) {
|
|
34
|
+
model[deletionData.axis === 'col' ? 'restoreColumn' : 'restoreRow'](deletionData);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import { getSpace } from '@dxos/client/echo';
|
|
7
|
+
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
8
|
+
|
|
9
|
+
import { SheetCapabilities } from './capabilities';
|
|
10
|
+
import { computeGraphFacet } from '../extensions';
|
|
11
|
+
|
|
12
|
+
export default (context: PluginsContext) =>
|
|
13
|
+
contributes(MarkdownCapabilities.Extensions, [
|
|
14
|
+
({ document: doc }) => {
|
|
15
|
+
const computeGraphRegistry = context.requestCapability(SheetCapabilities.ComputeGraphRegistry);
|
|
16
|
+
const space = getSpace(doc);
|
|
17
|
+
if (space) {
|
|
18
|
+
const computeGraph = computeGraphRegistry.getOrCreateGraph(space);
|
|
19
|
+
return computeGraphFacet.of(computeGraph);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createSurface, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
9
|
+
|
|
10
|
+
import { SheetCapabilities } from './capabilities';
|
|
11
|
+
import { ComputeGraphContextProvider, RangeList, SheetContainer } from '../components';
|
|
12
|
+
import { SHEET_PLUGIN } from '../meta';
|
|
13
|
+
import { SheetType } from '../types';
|
|
14
|
+
|
|
15
|
+
export default () =>
|
|
16
|
+
contributes(Capabilities.ReactSurface, [
|
|
17
|
+
createSurface({
|
|
18
|
+
id: `${SHEET_PLUGIN}/sheet`,
|
|
19
|
+
role: ['article', 'section'],
|
|
20
|
+
filter: (data): data is { subject: SheetType } => data.subject instanceof SheetType && !!getSpace(data.subject),
|
|
21
|
+
component: ({ data, role }) => {
|
|
22
|
+
const computeGraphRegistry = useCapability(SheetCapabilities.ComputeGraphRegistry);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ComputeGraphContextProvider registry={computeGraphRegistry}>
|
|
26
|
+
<SheetContainer space={getSpace(data.subject)!} sheet={data.subject} role={role} />
|
|
27
|
+
</ComputeGraphContextProvider>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
createSurface({
|
|
32
|
+
id: `${SHEET_PLUGIN}/settings`,
|
|
33
|
+
role: 'complementary--settings',
|
|
34
|
+
filter: (data): data is { subject: SheetType } => data.subject instanceof SheetType,
|
|
35
|
+
component: ({ data }) => <RangeList sheet={data.subject} />,
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes } from '@dxos/app-framework';
|
|
6
|
+
import { ThreadCapabilities } from '@dxos/plugin-space';
|
|
7
|
+
|
|
8
|
+
import { compareIndexPositions, SheetType } from '../types';
|
|
9
|
+
|
|
10
|
+
export default () =>
|
|
11
|
+
contributes(ThreadCapabilities.Thread, {
|
|
12
|
+
predicate: (data) => data instanceof SheetType,
|
|
13
|
+
createSort: (sheet) => (indexA, indexB) => (!indexA || !indexB ? 0 : compareIndexPositions(sheet, indexA, indexB)),
|
|
14
|
+
});
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { createContext, type PropsWithChildren, useContext } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type ComputeGraph, type ComputeGraphRegistry } from '@dxos/compute';
|
|
7
8
|
import { raise } from '@dxos/debug';
|
|
8
9
|
import { type Space } from '@dxos/react-client/echo';
|
|
9
10
|
import { useAsyncState } from '@dxos/react-hooks';
|
|
10
11
|
|
|
11
|
-
import { type ComputeGraph, type ComputeGraphRegistry } from '../../compute-graph';
|
|
12
|
-
|
|
13
12
|
export type ComputeGraphContextType = {
|
|
14
13
|
registry: ComputeGraphRegistry;
|
|
15
14
|
};
|
|
@@ -7,19 +7,18 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useEffect, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
11
|
+
import { FunctionType } from '@dxos/functions';
|
|
11
12
|
import { create, useSpace, Filter } from '@dxos/react-client/echo';
|
|
12
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
14
|
import { Toolbar, Button, Input } from '@dxos/react-ui';
|
|
14
15
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
15
16
|
import { withTheme } from '@dxos/storybook-utils';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { withComputeGraphDecorator } from '../testing';
|
|
22
|
-
import { SheetType } from '../types';
|
|
18
|
+
import { useComputeGraph } from './ComputeGraphContextProvider';
|
|
19
|
+
import { useSheetModel } from '../../model';
|
|
20
|
+
import { withComputeGraphDecorator } from '../../testing';
|
|
21
|
+
import { createSheet, SheetType } from '../../types';
|
|
23
22
|
|
|
24
23
|
const FUNCTION_NAME = 'TEST';
|
|
25
24
|
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
+
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute';
|
|
7
8
|
import { Icon } from '@dxos/react-ui';
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { mapFormulaIndicesToRefs } from '../../types';
|
|
10
11
|
import { useSheetContext } from '../SheetContext';
|
|
11
12
|
|
|
12
13
|
export const FunctionEditor = () => {
|
|
@@ -7,6 +7,7 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
11
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
13
|
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
@@ -41,6 +42,7 @@ const meta: Meta = {
|
|
|
41
42
|
withComputeGraphDecorator(),
|
|
42
43
|
withTheme,
|
|
43
44
|
withLayout({ fullscreen: true, tooltips: true, classNames: 'grid' }),
|
|
45
|
+
withPluginManager(),
|
|
44
46
|
],
|
|
45
47
|
parameters: { translations },
|
|
46
48
|
};
|
|
@@ -13,7 +13,8 @@ import React, {
|
|
|
13
13
|
useState,
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
|
-
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
16
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
17
|
+
import { rangeToA1Notation, type CellRange } from '@dxos/compute';
|
|
17
18
|
import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
|
|
18
19
|
import { useAttention } from '@dxos/react-ui-attention';
|
|
19
20
|
import {
|
|
@@ -23,20 +24,19 @@ import {
|
|
|
23
24
|
Grid,
|
|
24
25
|
GridCellEditor,
|
|
25
26
|
type DxGridElement,
|
|
27
|
+
type DxGridPosition,
|
|
28
|
+
type DxGridCellIndex,
|
|
26
29
|
type EditorKeyHandler,
|
|
27
30
|
type EditorBlurHandler,
|
|
28
31
|
type GridContentProps,
|
|
29
|
-
type DxGridPosition,
|
|
30
|
-
type DxGridCellIndex,
|
|
31
32
|
parseCellIndex,
|
|
32
33
|
} from '@dxos/react-ui-grid';
|
|
33
34
|
|
|
34
35
|
import { colLabelCell, rowLabelCell, useSheetModelDxGridProps } from './util';
|
|
35
|
-
import { DEFAULT_COLUMNS, DEFAULT_ROWS, rangeToA1Notation, type CellRange } from '../../defs';
|
|
36
36
|
import { rangeExtension, sheetExtension, type RangeController } from '../../extensions';
|
|
37
37
|
import { useSelectThreadOnCellFocus, useUpdateFocusedCellOnThreadSelection } from '../../integrations';
|
|
38
38
|
import { SHEET_PLUGIN } from '../../meta';
|
|
39
|
-
import { SheetAction } from '../../types';
|
|
39
|
+
import { DEFAULT_COLS, DEFAULT_ROWS, SheetAction } from '../../types';
|
|
40
40
|
import { useSheetContext } from '../SheetContext';
|
|
41
41
|
|
|
42
42
|
const inertPosition: DxGridPosition = { plane: 'grid', col: 0, row: 0 };
|
|
@@ -72,7 +72,7 @@ export const GridSheet = () => {
|
|
|
72
72
|
// a reliable dependency for `useEffect` whereas `useLayoutEffect` does not guarantee the element will be defined.
|
|
73
73
|
const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
|
|
74
74
|
const [extraplanarFocus, setExtraplanarFocus] = useState<DxGridPosition | null>(null);
|
|
75
|
-
const dispatch = useIntentDispatcher();
|
|
75
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
76
76
|
const rangeController = useRef<RangeController>();
|
|
77
77
|
const { hasAttention } = useAttention(id);
|
|
78
78
|
|
|
@@ -252,24 +252,21 @@ export const GridSheet = () => {
|
|
|
252
252
|
switch (operation) {
|
|
253
253
|
case 'insert-before':
|
|
254
254
|
case 'insert-after':
|
|
255
|
-
return dispatch(
|
|
256
|
-
|
|
257
|
-
data: {
|
|
255
|
+
return dispatch(
|
|
256
|
+
createIntent(SheetAction.InsertAxis, {
|
|
258
257
|
model,
|
|
259
258
|
axis: contextMenuAxis,
|
|
260
259
|
index: contextMenuOpen![contextMenuAxis] + (operation === 'insert-before' ? 0 : 1),
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
break;
|
|
260
|
+
}),
|
|
261
|
+
);
|
|
264
262
|
case 'drop':
|
|
265
|
-
return dispatch(
|
|
266
|
-
|
|
267
|
-
data: {
|
|
263
|
+
return dispatch(
|
|
264
|
+
createIntent(SheetAction.DropAxis, {
|
|
268
265
|
model,
|
|
269
266
|
axis: contextMenuAxis,
|
|
270
267
|
axisIndex: model.sheet[contextMenuAxis === 'row' ? 'rows' : 'columns'][contextMenuOpen![contextMenuAxis]],
|
|
271
|
-
}
|
|
272
|
-
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
273
270
|
}
|
|
274
271
|
},
|
|
275
272
|
[contextMenuAxis, contextMenuOpen, model, dispatch],
|
|
@@ -309,7 +306,7 @@ export const GridSheet = () => {
|
|
|
309
306
|
<GridCellEditor getCellContent={getCellContent} extension={extension} onBlur={handleBlur} />
|
|
310
307
|
<Grid.Content
|
|
311
308
|
initialCells={initialCells}
|
|
312
|
-
limitColumns={
|
|
309
|
+
limitColumns={DEFAULT_COLS}
|
|
313
310
|
limitRows={DEFAULT_ROWS}
|
|
314
311
|
columns={columns}
|
|
315
312
|
rows={rows}
|
|
@@ -9,21 +9,20 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
9
9
|
|
|
10
10
|
import { Client } from '@dxos/client';
|
|
11
11
|
import { createDocAccessor, type ReactiveEchoObject } from '@dxos/client/echo';
|
|
12
|
+
import { defaultFunctions } from '@dxos/compute';
|
|
13
|
+
import { getRegisteredFunctionNames } from '@dxos/compute/testing';
|
|
12
14
|
import { automerge } from '@dxos/react-ui-editor';
|
|
13
15
|
import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
|
|
14
16
|
import { withTheme } from '@dxos/storybook-utils';
|
|
15
17
|
|
|
16
|
-
import { HyperFormula } from '#hyperformula';
|
|
17
|
-
import { defaultFunctions } from '../../compute-graph';
|
|
18
|
-
import { createSheet } from '../../defs';
|
|
19
18
|
import { sheetExtension } from '../../extensions';
|
|
20
|
-
import { SheetType } from '../../types';
|
|
19
|
+
import { createSheet, SheetType } from '../../types';
|
|
21
20
|
|
|
22
21
|
type StoryProps = CellEditorProps;
|
|
23
22
|
|
|
24
23
|
const Story = ({ value, ...props }: StoryProps) => {
|
|
25
24
|
const extension = useMemo(() => {
|
|
26
|
-
const functionNames =
|
|
25
|
+
const functionNames = getRegisteredFunctionNames();
|
|
27
26
|
const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
|
|
28
27
|
return [sheetExtension({ functions })];
|
|
29
28
|
}, []);
|
|
@@ -54,7 +53,7 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
|
54
53
|
return [];
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
const functionNames =
|
|
56
|
+
const functionNames = getRegisteredFunctionNames();
|
|
58
57
|
const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
|
|
59
58
|
const accessor = createDocAccessor(object, ['cells', cell, 'value']);
|
|
60
59
|
return [automerge(accessor), sheetExtension({ functions })];
|
|
@@ -87,8 +86,8 @@ export const Automerge = {
|
|
|
87
86
|
const meta: Meta = {
|
|
88
87
|
title: 'plugins/plugin-sheet/CellEditor',
|
|
89
88
|
component: CellEditor,
|
|
90
|
-
render: (args: StoryProps) => <Story {...args} />,
|
|
91
89
|
decorators: [withTheme],
|
|
90
|
+
render: (args: StoryProps) => <Story {...args} />,
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
export default meta;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { inRange } from '@dxos/compute';
|
|
7
8
|
import { createDocAccessor, fullyQualifiedId } from '@dxos/react-client/echo';
|
|
8
9
|
import { parseValue, cellClassesForFieldType } from '@dxos/react-ui-form';
|
|
9
10
|
import {
|
|
@@ -20,9 +21,9 @@ import {
|
|
|
20
21
|
} from '@dxos/react-ui-grid';
|
|
21
22
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
23
|
|
|
23
|
-
import { inRange, cellClassNameForRange, rangeFromIndex } from '../../defs';
|
|
24
24
|
import { parseThreadAnchorAsCellRange } from '../../integrations';
|
|
25
25
|
import { type SheetModel } from '../../model';
|
|
26
|
+
import { cellClassNameForRange, rangeFromIndex } from '../../types';
|
|
26
27
|
|
|
27
28
|
const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
|
|
28
29
|
return model.sheet.columns.reduce(
|
|
@@ -54,7 +55,7 @@ const projectCellProps = (model: SheetModel, col: number, row: number): DxGridCe
|
|
|
54
55
|
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(rangeFromIndex(model.sheet, range), address));
|
|
55
56
|
const threadRefs = model.sheet.threads
|
|
56
57
|
?.filter((thread) => {
|
|
57
|
-
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread!.anchor);
|
|
58
|
+
const range = thread.target?.anchor && parseThreadAnchorAsCellRange(thread.target!.anchor);
|
|
58
59
|
return thread && range ? inRange(range, address) : false;
|
|
59
60
|
})
|
|
60
61
|
.map((thread) => fullyQualifiedId(thread!))
|
|
@@ -88,7 +89,7 @@ const gridCellGetter = (model: SheetModel) => {
|
|
|
88
89
|
|
|
89
90
|
export const rowLabelCell = (row: number) => ({
|
|
90
91
|
value: rowToA1Notation(row),
|
|
91
|
-
className: 'text-end
|
|
92
|
+
className: 'text-end pie-1 text-subdued',
|
|
92
93
|
resizeHandle: 'row',
|
|
93
94
|
});
|
|
94
95
|
|