@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
|
@@ -1,1676 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_COLUMNS,
|
|
4
|
-
DEFAULT_ROWS,
|
|
5
|
-
MAX_COLUMNS,
|
|
6
|
-
MAX_ROWS,
|
|
7
|
-
RANGE_NOTATION,
|
|
8
|
-
ReadonlyException,
|
|
9
|
-
addressFromA1Notation,
|
|
10
|
-
addressFromIndex,
|
|
11
|
-
addressToA1Notation,
|
|
12
|
-
addressToIndex,
|
|
13
|
-
cellClassNameForRange,
|
|
14
|
-
createSheetName,
|
|
15
|
-
inRange,
|
|
16
|
-
initialize,
|
|
17
|
-
insertIndices,
|
|
18
|
-
isFormula,
|
|
19
|
-
mapFormulaIndicesToRefs,
|
|
20
|
-
mapFormulaRefsToIndices,
|
|
21
|
-
rangeFromIndex,
|
|
22
|
-
rangeToA1Notation
|
|
23
|
-
} from "./chunk-6JF2AHKO.mjs";
|
|
24
|
-
import {
|
|
25
|
-
Range,
|
|
26
|
-
SheetAction
|
|
27
|
-
} from "./chunk-BVS2IQRO.mjs";
|
|
28
|
-
import {
|
|
29
|
-
SHEET_PLUGIN
|
|
30
|
-
} from "./chunk-BM2Q3FFC.mjs";
|
|
31
|
-
|
|
32
|
-
// packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
33
|
-
import React, { createContext, useContext } from "react";
|
|
34
|
-
import { raise } from "@dxos/debug";
|
|
35
|
-
import { useAsyncState } from "@dxos/react-hooks";
|
|
36
|
-
var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
|
|
37
|
-
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
38
|
-
return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
|
|
39
|
-
value: {
|
|
40
|
-
registry
|
|
41
|
-
}
|
|
42
|
-
}, children);
|
|
43
|
-
};
|
|
44
|
-
var useComputeGraph = (space) => {
|
|
45
|
-
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
46
|
-
const [graph] = useAsyncState(async () => {
|
|
47
|
-
if (space) {
|
|
48
|
-
const graph2 = registry.getOrCreateGraph(space);
|
|
49
|
-
await graph2.open();
|
|
50
|
-
return graph2;
|
|
51
|
-
}
|
|
52
|
-
}, [
|
|
53
|
-
space,
|
|
54
|
-
registry
|
|
55
|
-
]);
|
|
56
|
-
return graph;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// packages/plugins/plugin-sheet/src/extensions/compute.ts
|
|
60
|
-
import { syntaxTree } from "@codemirror/language";
|
|
61
|
-
import { RangeSetBuilder, StateEffect, StateField } from "@codemirror/state";
|
|
62
|
-
import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
|
|
63
|
-
import { debounce } from "@dxos/async";
|
|
64
|
-
import { invariant } from "@dxos/invariant";
|
|
65
|
-
import { documentId, singleValueFacet } from "@dxos/react-ui-editor";
|
|
66
|
-
var updateAllDecorations = StateEffect.define();
|
|
67
|
-
var computeGraphFacet = singleValueFacet();
|
|
68
|
-
|
|
69
|
-
// packages/plugins/plugin-sheet/src/extensions/editor/extension.ts
|
|
70
|
-
import { acceptCompletion, autocompletion, completionStatus, startCompletion } from "@codemirror/autocomplete";
|
|
71
|
-
import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
72
|
-
import { ViewPlugin as ViewPlugin2, keymap } from "@codemirror/view";
|
|
73
|
-
import { tags } from "@lezer/highlight";
|
|
74
|
-
import { spreadsheet } from "codemirror-lang-spreadsheet";
|
|
75
|
-
import { singleValueFacet as singleValueFacet2 } from "@dxos/react-ui-editor";
|
|
76
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
77
|
-
var highlightStyles = HighlightStyle.define([
|
|
78
|
-
// Function.
|
|
79
|
-
{
|
|
80
|
-
tag: tags.name,
|
|
81
|
-
class: "text-accentText"
|
|
82
|
-
},
|
|
83
|
-
// Range.
|
|
84
|
-
{
|
|
85
|
-
tag: tags.tagName,
|
|
86
|
-
class: "text-pinkText"
|
|
87
|
-
},
|
|
88
|
-
// Values.
|
|
89
|
-
{
|
|
90
|
-
tag: tags.number,
|
|
91
|
-
class: "text-tealText"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
tag: tags.bool,
|
|
95
|
-
class: "text-tealText"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
tag: tags.string,
|
|
99
|
-
class: "text-tealText"
|
|
100
|
-
},
|
|
101
|
-
// Error.
|
|
102
|
-
{
|
|
103
|
-
tag: tags.invalid,
|
|
104
|
-
class: "text-unAccent"
|
|
105
|
-
}
|
|
106
|
-
]);
|
|
107
|
-
var languageFacet = singleValueFacet2();
|
|
108
|
-
var sheetExtension = ({ debug, functions = [] }) => {
|
|
109
|
-
const { extension, language } = spreadsheet({
|
|
110
|
-
idiom: "en-US",
|
|
111
|
-
decimalSeparator: "."
|
|
112
|
-
});
|
|
113
|
-
const createCompletion = (name) => {
|
|
114
|
-
const { section = "Custom", description, syntax } = functions.find((value) => value.name === name) ?? {};
|
|
115
|
-
return {
|
|
116
|
-
section,
|
|
117
|
-
label: name,
|
|
118
|
-
info: () => {
|
|
119
|
-
if (!description && !syntax) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
const root = document.createElement("div");
|
|
123
|
-
root.className = "flex flex-col gap-2 text-sm";
|
|
124
|
-
const title = document.createElement("h2");
|
|
125
|
-
title.innerText = name;
|
|
126
|
-
title.className = "text-lg font-mono text-accentText";
|
|
127
|
-
root.appendChild(title);
|
|
128
|
-
if (description) {
|
|
129
|
-
const info = document.createElement("p");
|
|
130
|
-
info.innerText = description;
|
|
131
|
-
info.className = "text-subdued";
|
|
132
|
-
root.appendChild(info);
|
|
133
|
-
}
|
|
134
|
-
if (syntax) {
|
|
135
|
-
const detail = document.createElement("pre");
|
|
136
|
-
detail.innerText = syntax;
|
|
137
|
-
detail.className = "whitespace-pre-wrap text-greenText";
|
|
138
|
-
root.appendChild(detail);
|
|
139
|
-
}
|
|
140
|
-
return root;
|
|
141
|
-
},
|
|
142
|
-
apply: (view, completion, from, to) => {
|
|
143
|
-
const insertParens = to === view.state.doc.toString().length;
|
|
144
|
-
view.dispatch(view.state.update({
|
|
145
|
-
changes: {
|
|
146
|
-
from,
|
|
147
|
-
to,
|
|
148
|
-
insert: completion.label + (insertParens ? "()" : "")
|
|
149
|
-
},
|
|
150
|
-
selection: {
|
|
151
|
-
anchor: from + completion.label.length + 1
|
|
152
|
-
}
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
return [
|
|
158
|
-
extension,
|
|
159
|
-
languageFacet.of(language),
|
|
160
|
-
language.data.of({
|
|
161
|
-
autocomplete: (context) => {
|
|
162
|
-
if (context.state.doc.toString()[0] !== "=") {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
const match = context.matchBefore(/\w*/);
|
|
166
|
-
if (!match || match.from === match.to) {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
const text = match.text.toUpperCase();
|
|
170
|
-
if (!context.explicit && match.text.length < 2) {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
from: match.from,
|
|
175
|
-
options: functions?.filter(({ name }) => name.startsWith(text)).map(({ name }) => createCompletion(name)) ?? []
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}),
|
|
179
|
-
syntaxHighlighting(highlightStyles),
|
|
180
|
-
autocompletion({
|
|
181
|
-
aboveCursor: false,
|
|
182
|
-
defaultKeymap: true,
|
|
183
|
-
activateOnTyping: true,
|
|
184
|
-
closeOnBlur: !debug,
|
|
185
|
-
icons: false,
|
|
186
|
-
tooltipClass: () => mx("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
|
|
187
|
-
}),
|
|
188
|
-
keymap.of([
|
|
189
|
-
{
|
|
190
|
-
key: "Tab",
|
|
191
|
-
run: (view) => {
|
|
192
|
-
return completionStatus(view.state) === "active" ? acceptCompletion(view) : startCompletion(view);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
])
|
|
196
|
-
];
|
|
197
|
-
};
|
|
198
|
-
var rangeExtension = ({ onInit, onStateChange }) => {
|
|
199
|
-
let view;
|
|
200
|
-
let activeRange;
|
|
201
|
-
const notifier = {
|
|
202
|
-
setRange: (range) => {
|
|
203
|
-
if (activeRange) {
|
|
204
|
-
view.dispatch(view.state.update({
|
|
205
|
-
changes: {
|
|
206
|
-
...activeRange,
|
|
207
|
-
insert: range.toString()
|
|
208
|
-
},
|
|
209
|
-
selection: {
|
|
210
|
-
anchor: activeRange.from + range.length
|
|
211
|
-
}
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
view.focus();
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
return ViewPlugin2.fromClass(class {
|
|
218
|
-
constructor(_view) {
|
|
219
|
-
view = _view;
|
|
220
|
-
onInit?.(notifier);
|
|
221
|
-
}
|
|
222
|
-
update(view2) {
|
|
223
|
-
const { anchor } = view2.state.selection.ranges[0];
|
|
224
|
-
activeRange = void 0;
|
|
225
|
-
const language = view2.state.facet(languageFacet);
|
|
226
|
-
const { topNode } = language.parser.parse(view2.state.doc.toString());
|
|
227
|
-
visitTree(topNode, ({ type, from, to }) => {
|
|
228
|
-
if (from <= anchor && to >= anchor) {
|
|
229
|
-
switch (type.name) {
|
|
230
|
-
case "Function":
|
|
231
|
-
activeRange = {
|
|
232
|
-
from: to,
|
|
233
|
-
to
|
|
234
|
-
};
|
|
235
|
-
break;
|
|
236
|
-
case "CloseParen":
|
|
237
|
-
activeRange = {
|
|
238
|
-
from,
|
|
239
|
-
to: from
|
|
240
|
-
};
|
|
241
|
-
break;
|
|
242
|
-
case "RangeToken":
|
|
243
|
-
case "CellToken":
|
|
244
|
-
activeRange = {
|
|
245
|
-
from,
|
|
246
|
-
to
|
|
247
|
-
};
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return false;
|
|
252
|
-
});
|
|
253
|
-
if (!activeRange && view2.state.doc.toString()[0] === "=") {
|
|
254
|
-
const str = view2.state.doc.sliceString(1);
|
|
255
|
-
if (RANGE_NOTATION.test(str)) {
|
|
256
|
-
activeRange = {
|
|
257
|
-
from: 1,
|
|
258
|
-
to: str.length + 1
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
onStateChange?.({
|
|
263
|
-
activeRange: activeRange ? view2.state.doc.sliceString(activeRange.from, activeRange.to) : void 0
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
var visitTree = (node, callback) => {
|
|
269
|
-
if (callback(node)) {
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
for (let child = node.firstChild; child !== null; child = child.nextSibling) {
|
|
273
|
-
if (visitTree(child, callback)) {
|
|
274
|
-
return true;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return false;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
// packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx
|
|
281
|
-
import React2, { createContext as createContext2, useCallback, useContext as useContext2, useState as useState2 } from "react";
|
|
282
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
283
|
-
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
284
|
-
import { Grid, useGridContext } from "@dxos/react-ui-grid";
|
|
285
|
-
|
|
286
|
-
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
287
|
-
import { Event } from "@dxos/async";
|
|
288
|
-
import { Resource } from "@dxos/context";
|
|
289
|
-
import { getTypename, FormatEnum, TypeEnum } from "@dxos/echo-schema";
|
|
290
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
291
|
-
import { PublicKey } from "@dxos/keys";
|
|
292
|
-
import { log } from "@dxos/log";
|
|
293
|
-
import { DetailedCellError, ExportedCellChange } from "#hyperformula";
|
|
294
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
295
|
-
var typeMap = {
|
|
296
|
-
BOOLEAN: {
|
|
297
|
-
type: TypeEnum.Boolean
|
|
298
|
-
},
|
|
299
|
-
NUMBER_RAW: {
|
|
300
|
-
type: TypeEnum.Number
|
|
301
|
-
},
|
|
302
|
-
NUMBER_PERCENT: {
|
|
303
|
-
type: TypeEnum.Number,
|
|
304
|
-
format: FormatEnum.Percent
|
|
305
|
-
},
|
|
306
|
-
NUMBER_CURRENCY: {
|
|
307
|
-
type: TypeEnum.Number,
|
|
308
|
-
format: FormatEnum.Currency
|
|
309
|
-
},
|
|
310
|
-
NUMBER_DATETIME: {
|
|
311
|
-
type: TypeEnum.String,
|
|
312
|
-
format: FormatEnum.DateTime
|
|
313
|
-
},
|
|
314
|
-
NUMBER_DATE: {
|
|
315
|
-
type: TypeEnum.String,
|
|
316
|
-
format: FormatEnum.Date
|
|
317
|
-
},
|
|
318
|
-
NUMBER_TIME: {
|
|
319
|
-
type: TypeEnum.String,
|
|
320
|
-
format: FormatEnum.Time
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
var getTopLeft = (range) => {
|
|
324
|
-
const to = range.to ?? range.from;
|
|
325
|
-
return {
|
|
326
|
-
row: Math.min(range.from.row, to.row),
|
|
327
|
-
col: Math.min(range.from.col, to.col)
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
var toSimpleCellAddress = (sheet, cell) => ({
|
|
331
|
-
sheet,
|
|
332
|
-
row: cell.row,
|
|
333
|
-
col: cell.col
|
|
334
|
-
});
|
|
335
|
-
var toModelRange = (sheet, range) => ({
|
|
336
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
337
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
338
|
-
});
|
|
339
|
-
var SheetModel = class extends Resource {
|
|
340
|
-
constructor(_graph, _sheet, _options = {}) {
|
|
341
|
-
super();
|
|
342
|
-
this._graph = _graph;
|
|
343
|
-
this._sheet = _sheet;
|
|
344
|
-
this._options = _options;
|
|
345
|
-
this.id = `model-${PublicKey.random().truncate()}`;
|
|
346
|
-
this.update = new Event();
|
|
347
|
-
}
|
|
348
|
-
get graph() {
|
|
349
|
-
return this._graph;
|
|
350
|
-
}
|
|
351
|
-
get sheet() {
|
|
352
|
-
return this._sheet;
|
|
353
|
-
}
|
|
354
|
-
get readonly() {
|
|
355
|
-
return this._options.readonly;
|
|
356
|
-
}
|
|
357
|
-
get bounds() {
|
|
358
|
-
return {
|
|
359
|
-
rows: this._sheet.rows.length,
|
|
360
|
-
columns: this._sheet.columns.length
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Initialize sheet and engine.
|
|
365
|
-
*/
|
|
366
|
-
async _open() {
|
|
367
|
-
log("initialize", {
|
|
368
|
-
id: this.id
|
|
369
|
-
}, {
|
|
370
|
-
F: __dxlog_file,
|
|
371
|
-
L: 115,
|
|
372
|
-
S: this,
|
|
373
|
-
C: (f, a) => f(...a)
|
|
374
|
-
});
|
|
375
|
-
initialize(this._sheet);
|
|
376
|
-
this._graph.update.on((event) => {
|
|
377
|
-
if (event.type === "functionsUpdated") {
|
|
378
|
-
this.reset();
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
this._node = this._graph.getOrCreateNode(createSheetName({
|
|
382
|
-
type: getTypename(this._sheet),
|
|
383
|
-
id: this._sheet.id
|
|
384
|
-
}));
|
|
385
|
-
await this._node.open();
|
|
386
|
-
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
387
|
-
this._ctx.onDispose(unsubscribe);
|
|
388
|
-
this.reset();
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Update engine.
|
|
392
|
-
* NOTE: This resets the undo history.
|
|
393
|
-
* @deprecated
|
|
394
|
-
*/
|
|
395
|
-
reset() {
|
|
396
|
-
invariant2(this._node, void 0, {
|
|
397
|
-
F: __dxlog_file,
|
|
398
|
-
L: 141,
|
|
399
|
-
S: this,
|
|
400
|
-
A: [
|
|
401
|
-
"this._node",
|
|
402
|
-
""
|
|
403
|
-
]
|
|
404
|
-
});
|
|
405
|
-
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
406
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
407
|
-
invariant2(this._node, void 0, {
|
|
408
|
-
F: __dxlog_file,
|
|
409
|
-
L: 144,
|
|
410
|
-
S: this,
|
|
411
|
-
A: [
|
|
412
|
-
"this._node",
|
|
413
|
-
""
|
|
414
|
-
]
|
|
415
|
-
});
|
|
416
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
417
|
-
if (isFormula(value)) {
|
|
418
|
-
const binding = this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
|
|
419
|
-
if (binding) {
|
|
420
|
-
value = this._graph.mapFormulaToNative(binding);
|
|
421
|
-
} else {
|
|
422
|
-
value = "";
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
this._node.graph.hf.setCellContents({
|
|
426
|
-
sheet: this._node.sheetId,
|
|
427
|
-
row,
|
|
428
|
-
col
|
|
429
|
-
}, value);
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Recalculate formulas.
|
|
434
|
-
* NOTE: This resets the undo history.
|
|
435
|
-
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
436
|
-
* @deprecated
|
|
437
|
-
*/
|
|
438
|
-
// TODO(burdon): Remove.
|
|
439
|
-
recalculate() {
|
|
440
|
-
this._node?.graph.hf.rebuildAndRecalculate();
|
|
441
|
-
}
|
|
442
|
-
insertRows(i, n = 1) {
|
|
443
|
-
const idx = insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
444
|
-
this.reset();
|
|
445
|
-
return idx;
|
|
446
|
-
}
|
|
447
|
-
insertColumns(i, n = 1) {
|
|
448
|
-
const idx = insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
449
|
-
this.reset();
|
|
450
|
-
return idx;
|
|
451
|
-
}
|
|
452
|
-
dropRow(rowIndex) {
|
|
453
|
-
const range = {
|
|
454
|
-
from: addressFromIndex(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
|
|
455
|
-
to: addressFromIndex(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
|
|
456
|
-
};
|
|
457
|
-
const values = this.getCellValues(range).flat();
|
|
458
|
-
const index = this._sheet.rows.indexOf(rowIndex);
|
|
459
|
-
this.clear(range);
|
|
460
|
-
this._sheet.rows.splice(index, 1);
|
|
461
|
-
delete this._sheet.rowMeta[rowIndex];
|
|
462
|
-
this.reset();
|
|
463
|
-
return {
|
|
464
|
-
axis: "row",
|
|
465
|
-
index,
|
|
466
|
-
axisIndex: rowIndex,
|
|
467
|
-
axisMeta: this._sheet.rowMeta[rowIndex],
|
|
468
|
-
values
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
dropColumn(colIndex) {
|
|
472
|
-
const range = {
|
|
473
|
-
from: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
|
|
474
|
-
to: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
|
|
475
|
-
};
|
|
476
|
-
const values = this.getCellValues(range).flat();
|
|
477
|
-
const index = this._sheet.columns.indexOf(colIndex);
|
|
478
|
-
this.clear(range);
|
|
479
|
-
this._sheet.columns.splice(index, 1);
|
|
480
|
-
delete this._sheet.columnMeta[colIndex];
|
|
481
|
-
this.reset();
|
|
482
|
-
return {
|
|
483
|
-
axis: "col",
|
|
484
|
-
index,
|
|
485
|
-
axisIndex: colIndex,
|
|
486
|
-
axisMeta: this._sheet.rowMeta[colIndex],
|
|
487
|
-
values
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
restoreRow({ index, axisIndex, axisMeta, values }) {
|
|
491
|
-
this._sheet.rows.splice(index, 0, axisIndex);
|
|
492
|
-
values.forEach((value, col) => {
|
|
493
|
-
if (value) {
|
|
494
|
-
this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
|
|
495
|
-
value
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
if (axisMeta) {
|
|
500
|
-
this._sheet.rowMeta[axisIndex] = axisMeta;
|
|
501
|
-
}
|
|
502
|
-
this.reset();
|
|
503
|
-
}
|
|
504
|
-
restoreColumn({ index, axisIndex, axisMeta, values }) {
|
|
505
|
-
this._sheet.columns.splice(index, 0, axisIndex);
|
|
506
|
-
values.forEach((value, row) => {
|
|
507
|
-
if (value) {
|
|
508
|
-
this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
|
|
509
|
-
value
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
if (axisMeta) {
|
|
514
|
-
this._sheet.columnMeta[axisIndex] = axisMeta;
|
|
515
|
-
}
|
|
516
|
-
this.reset();
|
|
517
|
-
}
|
|
518
|
-
//
|
|
519
|
-
// Undoable actions.
|
|
520
|
-
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
521
|
-
//
|
|
522
|
-
/**
|
|
523
|
-
* Clear range of values.
|
|
524
|
-
*/
|
|
525
|
-
clear(range) {
|
|
526
|
-
invariant2(this._node, void 0, {
|
|
527
|
-
F: __dxlog_file,
|
|
528
|
-
L: 247,
|
|
529
|
-
S: this,
|
|
530
|
-
A: [
|
|
531
|
-
"this._node",
|
|
532
|
-
""
|
|
533
|
-
]
|
|
534
|
-
});
|
|
535
|
-
const topLeft = getTopLeft(range);
|
|
536
|
-
const values = this._iterRange(range, () => null);
|
|
537
|
-
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
538
|
-
this._iterRange(range, (cell) => {
|
|
539
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
540
|
-
delete this._sheet.cells[idx];
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
cut(range) {
|
|
544
|
-
invariant2(this._node, void 0, {
|
|
545
|
-
F: __dxlog_file,
|
|
546
|
-
L: 258,
|
|
547
|
-
S: this,
|
|
548
|
-
A: [
|
|
549
|
-
"this._node",
|
|
550
|
-
""
|
|
551
|
-
]
|
|
552
|
-
});
|
|
553
|
-
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
554
|
-
this._iterRange(range, (cell) => {
|
|
555
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
556
|
-
delete this._sheet.cells[idx];
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
copy(range) {
|
|
560
|
-
invariant2(this._node, void 0, {
|
|
561
|
-
F: __dxlog_file,
|
|
562
|
-
L: 267,
|
|
563
|
-
S: this,
|
|
564
|
-
A: [
|
|
565
|
-
"this._node",
|
|
566
|
-
""
|
|
567
|
-
]
|
|
568
|
-
});
|
|
569
|
-
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
570
|
-
}
|
|
571
|
-
paste(cell) {
|
|
572
|
-
invariant2(this._node, void 0, {
|
|
573
|
-
F: __dxlog_file,
|
|
574
|
-
L: 272,
|
|
575
|
-
S: this,
|
|
576
|
-
A: [
|
|
577
|
-
"this._node",
|
|
578
|
-
""
|
|
579
|
-
]
|
|
580
|
-
});
|
|
581
|
-
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
582
|
-
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
583
|
-
for (const change of changes) {
|
|
584
|
-
if (change instanceof ExportedCellChange) {
|
|
585
|
-
const { address, newValue } = change;
|
|
586
|
-
const idx = addressToIndex(this._sheet, {
|
|
587
|
-
row: address.row,
|
|
588
|
-
col: address.col
|
|
589
|
-
});
|
|
590
|
-
this._sheet.cells[idx] = {
|
|
591
|
-
value: newValue
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
// TODO(burdon): Display undo/redo state.
|
|
598
|
-
undo() {
|
|
599
|
-
invariant2(this._node, void 0, {
|
|
600
|
-
F: __dxlog_file,
|
|
601
|
-
L: 287,
|
|
602
|
-
S: this,
|
|
603
|
-
A: [
|
|
604
|
-
"this._node",
|
|
605
|
-
""
|
|
606
|
-
]
|
|
607
|
-
});
|
|
608
|
-
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
609
|
-
this._node.graph.hf.undo();
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
redo() {
|
|
613
|
-
invariant2(this._node, void 0, {
|
|
614
|
-
F: __dxlog_file,
|
|
615
|
-
L: 295,
|
|
616
|
-
S: this,
|
|
617
|
-
A: [
|
|
618
|
-
"this._node",
|
|
619
|
-
""
|
|
620
|
-
]
|
|
621
|
-
});
|
|
622
|
-
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
623
|
-
this._node.graph.hf.redo();
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Get value from sheet.
|
|
628
|
-
*/
|
|
629
|
-
getCellValue(cell) {
|
|
630
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
631
|
-
return this._sheet.cells[idx]?.value ?? null;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Get value as a string for editing.
|
|
635
|
-
*/
|
|
636
|
-
getCellText(cell) {
|
|
637
|
-
const value = this.getCellValue(cell);
|
|
638
|
-
if (value == null) {
|
|
639
|
-
return void 0;
|
|
640
|
-
}
|
|
641
|
-
if (isFormula(value)) {
|
|
642
|
-
return this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
|
|
643
|
-
} else {
|
|
644
|
-
return String(value);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Get array of raw values from sheet.
|
|
649
|
-
*/
|
|
650
|
-
getCellValues(range) {
|
|
651
|
-
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Gets the regular or computed value from the engine.
|
|
655
|
-
*/
|
|
656
|
-
getValue(cell) {
|
|
657
|
-
invariant2(this._node, void 0, {
|
|
658
|
-
F: __dxlog_file,
|
|
659
|
-
L: 338,
|
|
660
|
-
S: this,
|
|
661
|
-
A: [
|
|
662
|
-
"this._node",
|
|
663
|
-
""
|
|
664
|
-
]
|
|
665
|
-
});
|
|
666
|
-
const address = toSimpleCellAddress(this._node.sheetId, cell);
|
|
667
|
-
const value = this._node.graph.hf.getCellValue(address);
|
|
668
|
-
if (value instanceof DetailedCellError) {
|
|
669
|
-
log.info("cell error", {
|
|
670
|
-
cell,
|
|
671
|
-
error: value
|
|
672
|
-
}, {
|
|
673
|
-
F: __dxlog_file,
|
|
674
|
-
L: 343,
|
|
675
|
-
S: this,
|
|
676
|
-
C: (f, a) => f(...a)
|
|
677
|
-
});
|
|
678
|
-
return value.toString();
|
|
679
|
-
}
|
|
680
|
-
return value;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Get value type.
|
|
684
|
-
*/
|
|
685
|
-
getValueDescription(cell) {
|
|
686
|
-
invariant2(this._node, void 0, {
|
|
687
|
-
F: __dxlog_file,
|
|
688
|
-
L: 354,
|
|
689
|
-
S: this,
|
|
690
|
-
A: [
|
|
691
|
-
"this._node",
|
|
692
|
-
""
|
|
693
|
-
]
|
|
694
|
-
});
|
|
695
|
-
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
696
|
-
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
697
|
-
return typeMap[type];
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Sets the value, updating the sheet and engine.
|
|
701
|
-
*/
|
|
702
|
-
setValue(cell, value) {
|
|
703
|
-
invariant2(this._node, void 0, {
|
|
704
|
-
F: __dxlog_file,
|
|
705
|
-
L: 364,
|
|
706
|
-
S: this,
|
|
707
|
-
A: [
|
|
708
|
-
"this._node",
|
|
709
|
-
""
|
|
710
|
-
]
|
|
711
|
-
});
|
|
712
|
-
if (this._options.readonly) {
|
|
713
|
-
throw new ReadonlyException();
|
|
714
|
-
}
|
|
715
|
-
let refresh = false;
|
|
716
|
-
if (cell.row >= this._sheet.rows.length) {
|
|
717
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
718
|
-
refresh = true;
|
|
719
|
-
}
|
|
720
|
-
if (cell.col >= this._sheet.columns.length) {
|
|
721
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
722
|
-
refresh = true;
|
|
723
|
-
}
|
|
724
|
-
if (refresh) {
|
|
725
|
-
this.reset();
|
|
726
|
-
}
|
|
727
|
-
this._node.graph.hf.setCellContents({
|
|
728
|
-
sheet: this._node.sheetId,
|
|
729
|
-
row: cell.row,
|
|
730
|
-
col: cell.col
|
|
731
|
-
}, [
|
|
732
|
-
[
|
|
733
|
-
isFormula(value) ? this._graph.mapFormulaToNative(value) : value
|
|
734
|
-
]
|
|
735
|
-
]);
|
|
736
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
737
|
-
if (value === void 0 || value === null) {
|
|
738
|
-
delete this._sheet.cells[idx];
|
|
739
|
-
} else {
|
|
740
|
-
if (isFormula(value)) {
|
|
741
|
-
value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
|
|
742
|
-
}
|
|
743
|
-
this._sheet.cells[idx] = {
|
|
744
|
-
value
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Sets values from a simple map.
|
|
750
|
-
*/
|
|
751
|
-
setValues(values) {
|
|
752
|
-
Object.entries(values).forEach(([key, { value }]) => {
|
|
753
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* Iterate range.
|
|
758
|
-
*/
|
|
759
|
-
_iterRange(range, cb) {
|
|
760
|
-
const to = range.to ?? range.from;
|
|
761
|
-
const rowRange = [
|
|
762
|
-
Math.min(range.from.row, to.row),
|
|
763
|
-
Math.max(range.from.row, to.row)
|
|
764
|
-
];
|
|
765
|
-
const columnRange = [
|
|
766
|
-
Math.min(range.from.col, to.col),
|
|
767
|
-
Math.max(range.from.col, to.col)
|
|
768
|
-
];
|
|
769
|
-
const rows = [];
|
|
770
|
-
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
771
|
-
const rowCells = [];
|
|
772
|
-
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
773
|
-
const value = cb({
|
|
774
|
-
row,
|
|
775
|
-
col: column
|
|
776
|
-
});
|
|
777
|
-
if (value !== void 0) {
|
|
778
|
-
rowCells.push(value);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
rows.push(rowCells);
|
|
782
|
-
}
|
|
783
|
-
return rows;
|
|
784
|
-
}
|
|
785
|
-
// TODO(burdon): Delete index.
|
|
786
|
-
_deleteIndices(indices, i, n) {
|
|
787
|
-
throw new Error("Not implemented");
|
|
788
|
-
}
|
|
789
|
-
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
790
|
-
_moveIndices(indices, i, j, n) {
|
|
791
|
-
throw new Error("Not implemented");
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Map from indices to A1 notation.
|
|
795
|
-
*/
|
|
796
|
-
mapFormulaIndicesToRefs(formula) {
|
|
797
|
-
invariant2(isFormula(formula), void 0, {
|
|
798
|
-
F: __dxlog_file,
|
|
799
|
-
L: 449,
|
|
800
|
-
S: this,
|
|
801
|
-
A: [
|
|
802
|
-
"isFormula(formula)",
|
|
803
|
-
""
|
|
804
|
-
]
|
|
805
|
-
});
|
|
806
|
-
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
807
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
//
|
|
811
|
-
// Values
|
|
812
|
-
//
|
|
813
|
-
/**
|
|
814
|
-
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
815
|
-
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
816
|
-
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
817
|
-
*/
|
|
818
|
-
toLocalDate(num) {
|
|
819
|
-
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
820
|
-
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
821
|
-
}
|
|
822
|
-
toDateTime(num) {
|
|
823
|
-
invariant2(this._node, void 0, {
|
|
824
|
-
F: __dxlog_file,
|
|
825
|
-
L: 470,
|
|
826
|
-
S: this,
|
|
827
|
-
A: [
|
|
828
|
-
"this._node",
|
|
829
|
-
""
|
|
830
|
-
]
|
|
831
|
-
});
|
|
832
|
-
return this._node.graph.hf.numberToDateTime(num);
|
|
833
|
-
}
|
|
834
|
-
toDate(num) {
|
|
835
|
-
invariant2(this._node, void 0, {
|
|
836
|
-
F: __dxlog_file,
|
|
837
|
-
L: 475,
|
|
838
|
-
S: this,
|
|
839
|
-
A: [
|
|
840
|
-
"this._node",
|
|
841
|
-
""
|
|
842
|
-
]
|
|
843
|
-
});
|
|
844
|
-
return this._node.graph.hf.numberToDate(num);
|
|
845
|
-
}
|
|
846
|
-
toTime(num) {
|
|
847
|
-
invariant2(this._node, void 0, {
|
|
848
|
-
F: __dxlog_file,
|
|
849
|
-
L: 480,
|
|
850
|
-
S: this,
|
|
851
|
-
A: [
|
|
852
|
-
"this._node",
|
|
853
|
-
""
|
|
854
|
-
]
|
|
855
|
-
});
|
|
856
|
-
return this._node.graph.hf.numberToTime(num);
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
|
|
860
|
-
// packages/plugins/plugin-sheet/src/model/useSheetModel.ts
|
|
861
|
-
import { useEffect, useState } from "react";
|
|
862
|
-
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
863
|
-
const [model, setModel] = useState();
|
|
864
|
-
useEffect(() => {
|
|
865
|
-
if (!graph || !sheet) {
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
let model2;
|
|
869
|
-
const t = setTimeout(async () => {
|
|
870
|
-
model2 = new SheetModel(graph, sheet, {
|
|
871
|
-
readonly
|
|
872
|
-
});
|
|
873
|
-
await model2.open();
|
|
874
|
-
setModel(model2);
|
|
875
|
-
});
|
|
876
|
-
return () => {
|
|
877
|
-
clearTimeout(t);
|
|
878
|
-
void model2?.close();
|
|
879
|
-
};
|
|
880
|
-
}, [
|
|
881
|
-
graph,
|
|
882
|
-
sheet,
|
|
883
|
-
readonly
|
|
884
|
-
]);
|
|
885
|
-
return model;
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
// packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx
|
|
889
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
890
|
-
var SheetContext = /* @__PURE__ */ createContext2(void 0);
|
|
891
|
-
var useSheetContext = () => {
|
|
892
|
-
const context = useContext2(SheetContext);
|
|
893
|
-
invariant3(context, void 0, {
|
|
894
|
-
F: __dxlog_file2,
|
|
895
|
-
L: 55,
|
|
896
|
-
S: void 0,
|
|
897
|
-
A: [
|
|
898
|
-
"context",
|
|
899
|
-
""
|
|
900
|
-
]
|
|
901
|
-
});
|
|
902
|
-
return context;
|
|
903
|
-
};
|
|
904
|
-
var SheetProviderImpl = ({ model, onInfo, ignoreAttention, children, __gridScope }) => {
|
|
905
|
-
const { id, editing, setEditing } = useGridContext("SheetProvider", __gridScope);
|
|
906
|
-
const [cursor, setCursorInternal] = useState2();
|
|
907
|
-
const [range, setRangeInternal] = useState2();
|
|
908
|
-
const [cursorFallbackRange, setCursorFallbackRange] = useState2();
|
|
909
|
-
const [activeRefs, setActiveRefs] = useState2("");
|
|
910
|
-
const setCursor = useCallback((nextCursor) => {
|
|
911
|
-
setCursorInternal(nextCursor);
|
|
912
|
-
setCursorFallbackRange(range?.to ? range : nextCursor ? {
|
|
913
|
-
from: nextCursor,
|
|
914
|
-
to: nextCursor
|
|
915
|
-
} : void 0);
|
|
916
|
-
}, [
|
|
917
|
-
range
|
|
918
|
-
]);
|
|
919
|
-
const setRange = useCallback((nextRange) => {
|
|
920
|
-
setRangeInternal(nextRange);
|
|
921
|
-
setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
|
|
922
|
-
from: cursor,
|
|
923
|
-
to: cursor
|
|
924
|
-
} : void 0);
|
|
925
|
-
}, [
|
|
926
|
-
cursor
|
|
927
|
-
]);
|
|
928
|
-
return /* @__PURE__ */ React2.createElement(SheetContext.Provider, {
|
|
929
|
-
value: {
|
|
930
|
-
id,
|
|
931
|
-
model,
|
|
932
|
-
editing,
|
|
933
|
-
setEditing,
|
|
934
|
-
cursor,
|
|
935
|
-
setCursor,
|
|
936
|
-
range,
|
|
937
|
-
setRange,
|
|
938
|
-
cursorFallbackRange,
|
|
939
|
-
activeRefs,
|
|
940
|
-
setActiveRefs,
|
|
941
|
-
// TODO(burdon): Change to event.
|
|
942
|
-
onInfo,
|
|
943
|
-
ignoreAttention
|
|
944
|
-
}
|
|
945
|
-
}, children);
|
|
946
|
-
};
|
|
947
|
-
var SheetProvider = ({ children, graph, sheet, readonly, ignoreAttention, onInfo }) => {
|
|
948
|
-
const model = useSheetModel(graph, sheet, {
|
|
949
|
-
readonly
|
|
950
|
-
});
|
|
951
|
-
return !model ? null : /* @__PURE__ */ React2.createElement(Grid.Root, {
|
|
952
|
-
id: fullyQualifiedId(sheet)
|
|
953
|
-
}, /* @__PURE__ */ React2.createElement(SheetProviderImpl, {
|
|
954
|
-
model,
|
|
955
|
-
onInfo,
|
|
956
|
-
ignoreAttention
|
|
957
|
-
}, children));
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
961
|
-
import React5, { useCallback as useCallback4, useMemo as useMemo2, useRef, useState as useState4 } from "react";
|
|
962
|
-
import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
963
|
-
import { DropdownMenu, Icon, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
964
|
-
import { useAttention } from "@dxos/react-ui-attention";
|
|
965
|
-
import { closestCell, defaultSizeRow, editorKeys, Grid as Grid2, GridCellEditor, parseCellIndex } from "@dxos/react-ui-grid";
|
|
966
|
-
|
|
967
|
-
// packages/plugins/plugin-sheet/src/components/GridSheet/util.ts
|
|
968
|
-
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
969
|
-
import { createDocAccessor, fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
|
|
970
|
-
import { parseValue, cellClassesForFieldType } from "@dxos/react-ui-form";
|
|
971
|
-
import { colToA1Notation, rowToA1Notation, commentedClassName } from "@dxos/react-ui-grid";
|
|
972
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
973
|
-
|
|
974
|
-
// packages/plugins/plugin-sheet/src/integrations/thread-ranges.ts
|
|
975
|
-
import { useCallback as useCallback3, useEffect as useEffect2, useMemo } from "react";
|
|
976
|
-
import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
|
|
977
|
-
import { debounce as debounce2 } from "@dxos/async";
|
|
978
|
-
import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
|
|
979
|
-
|
|
980
|
-
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
981
|
-
import { lazy } from "react";
|
|
982
|
-
|
|
983
|
-
// packages/plugins/plugin-sheet/src/components/RangeList/RangeList.tsx
|
|
984
|
-
import React3, { useCallback as useCallback2 } from "react";
|
|
985
|
-
import { S } from "@dxos/echo-schema";
|
|
986
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
987
|
-
import { List } from "@dxos/react-ui-list";
|
|
988
|
-
import { ghostHover } from "@dxos/react-ui-theme";
|
|
989
|
-
var RangeList = ({ sheet }) => {
|
|
990
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
991
|
-
const handleSelectRange = (range) => {
|
|
992
|
-
};
|
|
993
|
-
const handleDeleteRange = useCallback2((range) => {
|
|
994
|
-
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
995
|
-
sheet.ranges.splice(index, 1);
|
|
996
|
-
}, [
|
|
997
|
-
sheet
|
|
998
|
-
]);
|
|
999
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("h2", {
|
|
1000
|
-
className: "p-2 text-sm font-semibold"
|
|
1001
|
-
}, t("range list heading")), /* @__PURE__ */ React3.createElement(List.Root, {
|
|
1002
|
-
items: sheet.ranges,
|
|
1003
|
-
isItem: S.is(Range)
|
|
1004
|
-
}, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ React3.createElement(List.Item, {
|
|
1005
|
-
key: i,
|
|
1006
|
-
item: range,
|
|
1007
|
-
classNames: [
|
|
1008
|
-
"p-2",
|
|
1009
|
-
ghostHover
|
|
1010
|
-
]
|
|
1011
|
-
}, /* @__PURE__ */ React3.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React3.createElement(List.ItemTitle, {
|
|
1012
|
-
onClick: () => handleSelectRange(range)
|
|
1013
|
-
}, t("range title", {
|
|
1014
|
-
position: rangeToA1Notation(rangeFromIndex(sheet, range.range)),
|
|
1015
|
-
key: t(`range key ${range.key} label`),
|
|
1016
|
-
value: t(`range value ${range.value} label`)
|
|
1017
|
-
})), /* @__PURE__ */ React3.createElement(List.ItemDeleteButton, {
|
|
1018
|
-
onClick: () => handleDeleteRange(range)
|
|
1019
|
-
})))));
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
// packages/plugins/plugin-sheet/src/components/SheetObjectSettings.tsx
|
|
1023
|
-
import React4 from "react";
|
|
1024
|
-
import { SPACE_PLUGIN } from "@dxos/plugin-space/meta";
|
|
1025
|
-
import { Input, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
1026
|
-
var SheetObjectSettings = ({ sheet }) => {
|
|
1027
|
-
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
1028
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", {
|
|
1029
|
-
role: "form",
|
|
1030
|
-
className: "flex flex-col w-full p-2 gap-1"
|
|
1031
|
-
}, /* @__PURE__ */ React4.createElement(Input.Root, null, /* @__PURE__ */ React4.createElement(Input.Label, null, t("name label")), /* @__PURE__ */ React4.createElement(Input.TextInput, {
|
|
1032
|
-
placeholder: t("name placeholder"),
|
|
1033
|
-
value: sheet.name ?? "",
|
|
1034
|
-
onChange: (event) => {
|
|
1035
|
-
sheet.name = event.target.value;
|
|
1036
|
-
}
|
|
1037
|
-
}))), /* @__PURE__ */ React4.createElement(RangeList, {
|
|
1038
|
-
sheet
|
|
1039
|
-
}));
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
1043
|
-
var SheetContainer = lazy(() => import("./SheetContainer-LSBE6Q4X.mjs"));
|
|
1044
|
-
|
|
1045
|
-
// packages/plugins/plugin-sheet/src/integrations/thread-ranges.ts
|
|
1046
|
-
var completeCellRangeToThreadCursor = (range) => {
|
|
1047
|
-
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
1048
|
-
};
|
|
1049
|
-
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
1050
|
-
const coords = cursor.split(",");
|
|
1051
|
-
if (coords.length !== 4) {
|
|
1052
|
-
return null;
|
|
1053
|
-
} else {
|
|
1054
|
-
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
1055
|
-
return {
|
|
1056
|
-
from: {
|
|
1057
|
-
col: parseInt(fromCol),
|
|
1058
|
-
row: parseInt(fromRow)
|
|
1059
|
-
},
|
|
1060
|
-
to: {
|
|
1061
|
-
col: parseInt(toCol),
|
|
1062
|
-
row: parseInt(toRow)
|
|
1063
|
-
}
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
1068
|
-
const { model, setActiveRefs } = useSheetContext();
|
|
1069
|
-
const handleScrollIntoView = useCallback3(({ action, data }) => {
|
|
1070
|
-
switch (action) {
|
|
1071
|
-
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
1072
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId2(model.sheet)) {
|
|
1073
|
-
return;
|
|
1074
|
-
}
|
|
1075
|
-
setActiveRefs(data.thread);
|
|
1076
|
-
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
1077
|
-
range && grid?.setFocus({
|
|
1078
|
-
...range.to,
|
|
1079
|
-
plane: "grid"
|
|
1080
|
-
}, true);
|
|
1081
|
-
return {
|
|
1082
|
-
data: true
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
}, [
|
|
1087
|
-
model.sheet,
|
|
1088
|
-
setActiveRefs
|
|
1089
|
-
]);
|
|
1090
|
-
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
1091
|
-
};
|
|
1092
|
-
var useSelectThreadOnCellFocus = () => {
|
|
1093
|
-
const { model, cursor } = useSheetContext();
|
|
1094
|
-
const dispatch = useIntentDispatcher();
|
|
1095
|
-
const threads = useMemo(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
|
|
1096
|
-
// TODO(thure): Surely we can find a better dependency for this…
|
|
1097
|
-
JSON.stringify(model.sheet.threads)
|
|
1098
|
-
]);
|
|
1099
|
-
const selectClosestThread = useCallback3((cellAddress) => {
|
|
1100
|
-
if (!cellAddress || !threads) {
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
const closestThread = threads?.find(({ anchor }) => {
|
|
1104
|
-
if (anchor) {
|
|
1105
|
-
const range = parseThreadAnchorAsCellRange(anchor);
|
|
1106
|
-
return range ? inRange(range, cellAddress) : false;
|
|
1107
|
-
} else {
|
|
1108
|
-
return false;
|
|
1109
|
-
}
|
|
1110
|
-
});
|
|
1111
|
-
if (closestThread) {
|
|
1112
|
-
void dispatch([
|
|
1113
|
-
{
|
|
1114
|
-
action: "dxos.org/plugin/thread/action/select",
|
|
1115
|
-
data: {
|
|
1116
|
-
current: fullyQualifiedId2(closestThread)
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
]);
|
|
1120
|
-
}
|
|
1121
|
-
}, [
|
|
1122
|
-
dispatch,
|
|
1123
|
-
threads
|
|
1124
|
-
]);
|
|
1125
|
-
const debounced = useMemo(() => {
|
|
1126
|
-
return debounce2((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
1127
|
-
}, [
|
|
1128
|
-
selectClosestThread
|
|
1129
|
-
]);
|
|
1130
|
-
useEffect2(() => {
|
|
1131
|
-
if (!cursor) {
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
debounced(cursor);
|
|
1135
|
-
}, [
|
|
1136
|
-
cursor,
|
|
1137
|
-
debounced
|
|
1138
|
-
]);
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
// packages/plugins/plugin-sheet/src/components/GridSheet/util.ts
|
|
1142
|
-
var createDxGridColumns = (model) => {
|
|
1143
|
-
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
1144
|
-
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
1145
|
-
acc.grid[numericIndex] = {
|
|
1146
|
-
size: model.sheet.columnMeta[columnId].size,
|
|
1147
|
-
resizeable: true
|
|
1148
|
-
};
|
|
1149
|
-
}
|
|
1150
|
-
return acc;
|
|
1151
|
-
}, {
|
|
1152
|
-
grid: {}
|
|
1153
|
-
});
|
|
1154
|
-
};
|
|
1155
|
-
var createDxGridRows = (model) => {
|
|
1156
|
-
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
1157
|
-
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
1158
|
-
acc.grid[numericIndex] = {
|
|
1159
|
-
size: model.sheet.rowMeta[rowId].size,
|
|
1160
|
-
resizeable: true
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
return acc;
|
|
1164
|
-
}, {
|
|
1165
|
-
grid: {}
|
|
1166
|
-
});
|
|
1167
|
-
};
|
|
1168
|
-
var projectCellProps = (model, col, row) => {
|
|
1169
|
-
const address = {
|
|
1170
|
-
col,
|
|
1171
|
-
row
|
|
1172
|
-
};
|
|
1173
|
-
const rawValue = model.getValue(address);
|
|
1174
|
-
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(rangeFromIndex(model.sheet, range), address));
|
|
1175
|
-
const threadRefs = model.sheet.threads?.filter((thread) => {
|
|
1176
|
-
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
|
|
1177
|
-
return thread && range ? inRange(range, address) : false;
|
|
1178
|
-
}).map((thread) => fullyQualifiedId3(thread)).join(" ");
|
|
1179
|
-
const description = model.getValueDescription(address);
|
|
1180
|
-
const type = description?.type;
|
|
1181
|
-
const format = description?.format;
|
|
1182
|
-
const classNames = ranges?.map(cellClassNameForRange).reverse();
|
|
1183
|
-
return {
|
|
1184
|
-
value: parseValue({
|
|
1185
|
-
type,
|
|
1186
|
-
format,
|
|
1187
|
-
value: rawValue
|
|
1188
|
-
}),
|
|
1189
|
-
className: mx2(cellClassesForFieldType({
|
|
1190
|
-
type,
|
|
1191
|
-
format
|
|
1192
|
-
}), threadRefs && commentedClassName, classNames),
|
|
1193
|
-
dataRefs: threadRefs
|
|
1194
|
-
};
|
|
1195
|
-
};
|
|
1196
|
-
var gridCellGetter = (model) => {
|
|
1197
|
-
const cachedGridCells = {};
|
|
1198
|
-
return (nextBounds) => {
|
|
1199
|
-
[
|
|
1200
|
-
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1201
|
-
].forEach((_, c0) => {
|
|
1202
|
-
return [
|
|
1203
|
-
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1204
|
-
].forEach((_2, r0) => {
|
|
1205
|
-
const col = nextBounds.start.col + c0;
|
|
1206
|
-
const row = nextBounds.start.row + r0;
|
|
1207
|
-
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
1208
|
-
});
|
|
1209
|
-
});
|
|
1210
|
-
return cachedGridCells;
|
|
1211
|
-
};
|
|
1212
|
-
};
|
|
1213
|
-
var rowLabelCell = (row) => ({
|
|
1214
|
-
value: rowToA1Notation(row),
|
|
1215
|
-
className: "text-end !pie-1 text-subdued",
|
|
1216
|
-
resizeHandle: "row"
|
|
1217
|
-
});
|
|
1218
|
-
var colLabelCell = (col) => ({
|
|
1219
|
-
value: colToA1Notation(col),
|
|
1220
|
-
className: "text-subdued",
|
|
1221
|
-
resizeHandle: "col"
|
|
1222
|
-
});
|
|
1223
|
-
var cellGetter = (model) => {
|
|
1224
|
-
const getGridCells = gridCellGetter(model);
|
|
1225
|
-
return (nextBounds, plane) => {
|
|
1226
|
-
switch (plane) {
|
|
1227
|
-
case "grid":
|
|
1228
|
-
return getGridCells(nextBounds);
|
|
1229
|
-
case "frozenColsStart":
|
|
1230
|
-
return [
|
|
1231
|
-
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1232
|
-
].reduce((acc, _, r0) => {
|
|
1233
|
-
const r = nextBounds.start.row + r0;
|
|
1234
|
-
acc[`0,${r}`] = rowLabelCell(r);
|
|
1235
|
-
return acc;
|
|
1236
|
-
}, {});
|
|
1237
|
-
case "frozenRowsStart":
|
|
1238
|
-
return [
|
|
1239
|
-
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1240
|
-
].reduce((acc, _, c0) => {
|
|
1241
|
-
const c = nextBounds.start.col + c0;
|
|
1242
|
-
acc[`${c},0`] = colLabelCell(c);
|
|
1243
|
-
return acc;
|
|
1244
|
-
}, {});
|
|
1245
|
-
default:
|
|
1246
|
-
return {};
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
};
|
|
1250
|
-
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1251
|
-
const [columns, setColumns] = useState3(createDxGridColumns(model));
|
|
1252
|
-
const [rows, setRows] = useState3(createDxGridRows(model));
|
|
1253
|
-
useEffect3(() => {
|
|
1254
|
-
const cellsAccessor = createDocAccessor(model.sheet, [
|
|
1255
|
-
"cells"
|
|
1256
|
-
]);
|
|
1257
|
-
if (dxGrid) {
|
|
1258
|
-
dxGrid.getCells = cellGetter(model);
|
|
1259
|
-
}
|
|
1260
|
-
const handleCellsUpdate = () => {
|
|
1261
|
-
dxGrid?.requestUpdate("initialCells");
|
|
1262
|
-
};
|
|
1263
|
-
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1264
|
-
const unsubscribe = model.graph.update.on(handleCellsUpdate);
|
|
1265
|
-
return () => {
|
|
1266
|
-
cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1267
|
-
unsubscribe();
|
|
1268
|
-
};
|
|
1269
|
-
}, [
|
|
1270
|
-
model,
|
|
1271
|
-
dxGrid
|
|
1272
|
-
]);
|
|
1273
|
-
useEffect3(() => {
|
|
1274
|
-
const columnMetaAccessor = createDocAccessor(model.sheet, [
|
|
1275
|
-
"columnMeta"
|
|
1276
|
-
]);
|
|
1277
|
-
const rowMetaAccessor = createDocAccessor(model.sheet, [
|
|
1278
|
-
"rowMeta"
|
|
1279
|
-
]);
|
|
1280
|
-
const handleColumnMetaUpdate = () => {
|
|
1281
|
-
setColumns(createDxGridColumns(model));
|
|
1282
|
-
};
|
|
1283
|
-
const handleRowMetaUpdate = () => {
|
|
1284
|
-
setRows(createDxGridRows(model));
|
|
1285
|
-
};
|
|
1286
|
-
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1287
|
-
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1288
|
-
return () => {
|
|
1289
|
-
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1290
|
-
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1291
|
-
};
|
|
1292
|
-
}, [
|
|
1293
|
-
model,
|
|
1294
|
-
dxGrid
|
|
1295
|
-
]);
|
|
1296
|
-
return {
|
|
1297
|
-
columns,
|
|
1298
|
-
rows
|
|
1299
|
-
};
|
|
1300
|
-
};
|
|
1301
|
-
|
|
1302
|
-
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
1303
|
-
var inertPosition = {
|
|
1304
|
-
plane: "grid",
|
|
1305
|
-
col: 0,
|
|
1306
|
-
row: 0
|
|
1307
|
-
};
|
|
1308
|
-
var initialCells = {
|
|
1309
|
-
grid: {},
|
|
1310
|
-
frozenColsStart: [
|
|
1311
|
-
...Array(64)
|
|
1312
|
-
].reduce((acc, _, i) => {
|
|
1313
|
-
acc[`0,${i}`] = rowLabelCell(i);
|
|
1314
|
-
return acc;
|
|
1315
|
-
}, {}),
|
|
1316
|
-
frozenRowsStart: [
|
|
1317
|
-
...Array(12)
|
|
1318
|
-
].reduce((acc, _, i) => {
|
|
1319
|
-
acc[`${i},0`] = colLabelCell(i);
|
|
1320
|
-
return acc;
|
|
1321
|
-
}, {})
|
|
1322
|
-
};
|
|
1323
|
-
var frozen = {
|
|
1324
|
-
frozenColsStart: 1,
|
|
1325
|
-
frozenRowsStart: 1
|
|
1326
|
-
};
|
|
1327
|
-
var sheetRowDefault = {
|
|
1328
|
-
frozenRowsStart: {
|
|
1329
|
-
size: defaultSizeRow,
|
|
1330
|
-
readonly: true
|
|
1331
|
-
},
|
|
1332
|
-
grid: {
|
|
1333
|
-
size: defaultSizeRow,
|
|
1334
|
-
resizeable: true
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
var sheetColDefault = {
|
|
1338
|
-
frozenColsStart: {
|
|
1339
|
-
size: 48,
|
|
1340
|
-
readonly: true
|
|
1341
|
-
},
|
|
1342
|
-
grid: {
|
|
1343
|
-
size: 180,
|
|
1344
|
-
resizeable: true
|
|
1345
|
-
}
|
|
1346
|
-
};
|
|
1347
|
-
var GridSheet = () => {
|
|
1348
|
-
const { t } = useTranslation3(SHEET_PLUGIN);
|
|
1349
|
-
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } = useSheetContext();
|
|
1350
|
-
const [dxGrid, setDxGrid] = useState4(null);
|
|
1351
|
-
const [extraplanarFocus, setExtraplanarFocus] = useState4(null);
|
|
1352
|
-
const dispatch = useIntentDispatcher2();
|
|
1353
|
-
const rangeController = useRef();
|
|
1354
|
-
const { hasAttention } = useAttention(id);
|
|
1355
|
-
const handleFocus = useCallback4((event) => {
|
|
1356
|
-
if (!editing) {
|
|
1357
|
-
const cell = closestCell(event.target);
|
|
1358
|
-
if (cell) {
|
|
1359
|
-
if (cell.plane === "grid") {
|
|
1360
|
-
setCursor({
|
|
1361
|
-
col: cell.col,
|
|
1362
|
-
row: cell.row
|
|
1363
|
-
});
|
|
1364
|
-
setExtraplanarFocus(null);
|
|
1365
|
-
} else {
|
|
1366
|
-
setExtraplanarFocus(cell);
|
|
1367
|
-
}
|
|
1368
|
-
} else {
|
|
1369
|
-
setExtraplanarFocus(null);
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
}, [
|
|
1373
|
-
editing
|
|
1374
|
-
]);
|
|
1375
|
-
const handleClose = useCallback4((_value, event) => {
|
|
1376
|
-
if (event) {
|
|
1377
|
-
const { key, shift } = event;
|
|
1378
|
-
const axis = [
|
|
1379
|
-
"Enter",
|
|
1380
|
-
"ArrowUp",
|
|
1381
|
-
"ArrowDown"
|
|
1382
|
-
].includes(key) ? "row" : [
|
|
1383
|
-
"Tab",
|
|
1384
|
-
"ArrowLeft",
|
|
1385
|
-
"ArrowRight"
|
|
1386
|
-
].includes(key) ? "col" : void 0;
|
|
1387
|
-
const delta = key.startsWith("Arrow") ? [
|
|
1388
|
-
"ArrowUp",
|
|
1389
|
-
"ArrowLeft"
|
|
1390
|
-
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1391
|
-
dxGrid?.refocus(axis, delta);
|
|
1392
|
-
}
|
|
1393
|
-
}, [
|
|
1394
|
-
model,
|
|
1395
|
-
editing,
|
|
1396
|
-
dxGrid
|
|
1397
|
-
]);
|
|
1398
|
-
const handleBlur = useCallback4((value) => {
|
|
1399
|
-
if (value !== void 0) {
|
|
1400
|
-
model.setValue(parseCellIndex(editing.index), value);
|
|
1401
|
-
}
|
|
1402
|
-
}, [
|
|
1403
|
-
model,
|
|
1404
|
-
editing
|
|
1405
|
-
]);
|
|
1406
|
-
const handleAxisResize = useCallback4(({ axis, size, index: numericIndex }) => {
|
|
1407
|
-
if (axis === "row") {
|
|
1408
|
-
const rowId = model.sheet.rows[parseInt(numericIndex)];
|
|
1409
|
-
model.sheet.rowMeta[rowId] ??= {};
|
|
1410
|
-
model.sheet.rowMeta[rowId].size = size;
|
|
1411
|
-
} else {
|
|
1412
|
-
const columnId = model.sheet.columns[parseInt(numericIndex)];
|
|
1413
|
-
model.sheet.columnMeta[columnId] ??= {};
|
|
1414
|
-
model.sheet.columnMeta[columnId].size = size;
|
|
1415
|
-
}
|
|
1416
|
-
}, [
|
|
1417
|
-
model
|
|
1418
|
-
]);
|
|
1419
|
-
const handleSelect = useCallback4(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1420
|
-
const range = {
|
|
1421
|
-
from: {
|
|
1422
|
-
col: minCol,
|
|
1423
|
-
row: minRow
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1427
|
-
range.to = {
|
|
1428
|
-
col: maxCol,
|
|
1429
|
-
row: maxRow
|
|
1430
|
-
};
|
|
1431
|
-
}
|
|
1432
|
-
if (editing) {
|
|
1433
|
-
rangeController.current?.setRange(rangeToA1Notation(range));
|
|
1434
|
-
} else {
|
|
1435
|
-
setRange(range.to ? range : void 0);
|
|
1436
|
-
}
|
|
1437
|
-
}, [
|
|
1438
|
-
editing
|
|
1439
|
-
]);
|
|
1440
|
-
const handleWheel = useCallback4((event) => {
|
|
1441
|
-
if (!ignoreAttention && !hasAttention) {
|
|
1442
|
-
event.stopPropagation();
|
|
1443
|
-
}
|
|
1444
|
-
}, [
|
|
1445
|
-
hasAttention,
|
|
1446
|
-
ignoreAttention
|
|
1447
|
-
]);
|
|
1448
|
-
const selectEntireAxis = useCallback4((pos) => {
|
|
1449
|
-
switch (pos.plane) {
|
|
1450
|
-
case "frozenRowsStart":
|
|
1451
|
-
return dxGrid?.setSelection({
|
|
1452
|
-
start: {
|
|
1453
|
-
col: pos.col,
|
|
1454
|
-
row: 0,
|
|
1455
|
-
plane: "grid"
|
|
1456
|
-
},
|
|
1457
|
-
end: {
|
|
1458
|
-
col: pos.col,
|
|
1459
|
-
row: model.sheet.rows.length - 1,
|
|
1460
|
-
plane: "grid"
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
case "frozenColsStart":
|
|
1464
|
-
return dxGrid?.setSelection({
|
|
1465
|
-
start: {
|
|
1466
|
-
row: pos.row,
|
|
1467
|
-
col: 0,
|
|
1468
|
-
plane: "grid"
|
|
1469
|
-
},
|
|
1470
|
-
end: {
|
|
1471
|
-
row: pos.row,
|
|
1472
|
-
col: model.sheet.columns.length - 1,
|
|
1473
|
-
plane: "grid"
|
|
1474
|
-
}
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
}, [
|
|
1478
|
-
dxGrid,
|
|
1479
|
-
model.sheet
|
|
1480
|
-
]);
|
|
1481
|
-
const handleClick = useCallback4((event) => {
|
|
1482
|
-
const cell = closestCell(event.target);
|
|
1483
|
-
if (cell) {
|
|
1484
|
-
selectEntireAxis(cell);
|
|
1485
|
-
}
|
|
1486
|
-
}, [
|
|
1487
|
-
selectEntireAxis
|
|
1488
|
-
]);
|
|
1489
|
-
const handleKeyDown = useCallback4((event) => {
|
|
1490
|
-
switch (event.key) {
|
|
1491
|
-
case "Backspace":
|
|
1492
|
-
case "Delete":
|
|
1493
|
-
event.preventDefault();
|
|
1494
|
-
return cursorFallbackRange && model.clear(cursorFallbackRange);
|
|
1495
|
-
case "Enter":
|
|
1496
|
-
case "Space":
|
|
1497
|
-
if (dxGrid && extraplanarFocus) {
|
|
1498
|
-
switch (extraplanarFocus.plane) {
|
|
1499
|
-
case "frozenRowsStart":
|
|
1500
|
-
case "frozenColsStart":
|
|
1501
|
-
event.preventDefault();
|
|
1502
|
-
return selectEntireAxis(extraplanarFocus);
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
if (event.metaKey || event.ctrlKey) {
|
|
1507
|
-
switch (event.key) {
|
|
1508
|
-
case "x":
|
|
1509
|
-
case "X":
|
|
1510
|
-
event.preventDefault();
|
|
1511
|
-
return cursorFallbackRange && model.cut(cursorFallbackRange);
|
|
1512
|
-
case "c":
|
|
1513
|
-
case "C":
|
|
1514
|
-
event.preventDefault();
|
|
1515
|
-
return cursorFallbackRange && model.copy(cursorFallbackRange);
|
|
1516
|
-
case "v":
|
|
1517
|
-
case "V":
|
|
1518
|
-
event.preventDefault();
|
|
1519
|
-
return cursor && model.paste(cursor);
|
|
1520
|
-
case "z":
|
|
1521
|
-
event.preventDefault();
|
|
1522
|
-
return event.shiftKey ? model.redo() : model.undo();
|
|
1523
|
-
case "Z":
|
|
1524
|
-
case "y":
|
|
1525
|
-
event.preventDefault();
|
|
1526
|
-
return model.redo();
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
}, [
|
|
1530
|
-
cursorFallbackRange,
|
|
1531
|
-
model,
|
|
1532
|
-
cursor,
|
|
1533
|
-
extraplanarFocus,
|
|
1534
|
-
selectEntireAxis
|
|
1535
|
-
]);
|
|
1536
|
-
const contextMenuAnchorRef = useRef(null);
|
|
1537
|
-
const [contextMenuOpen, setContextMenuOpen] = useState4(null);
|
|
1538
|
-
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1539
|
-
const handleContextMenu = useCallback4((event) => {
|
|
1540
|
-
const cell = closestCell(event.target);
|
|
1541
|
-
if (cell && cell.plane.startsWith("frozen")) {
|
|
1542
|
-
event.preventDefault();
|
|
1543
|
-
contextMenuAnchorRef.current = event.target;
|
|
1544
|
-
setContextMenuOpen(cell);
|
|
1545
|
-
}
|
|
1546
|
-
}, []);
|
|
1547
|
-
const handleAxisMenuAction = useCallback4((operation) => {
|
|
1548
|
-
switch (operation) {
|
|
1549
|
-
case "insert-before":
|
|
1550
|
-
case "insert-after":
|
|
1551
|
-
return dispatch({
|
|
1552
|
-
action: SheetAction.INSERT_AXIS,
|
|
1553
|
-
data: {
|
|
1554
|
-
model,
|
|
1555
|
-
axis: contextMenuAxis,
|
|
1556
|
-
index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
|
|
1557
|
-
}
|
|
1558
|
-
});
|
|
1559
|
-
break;
|
|
1560
|
-
case "drop":
|
|
1561
|
-
return dispatch({
|
|
1562
|
-
action: SheetAction.DROP_AXIS,
|
|
1563
|
-
data: {
|
|
1564
|
-
model,
|
|
1565
|
-
axis: contextMenuAxis,
|
|
1566
|
-
axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
|
|
1567
|
-
}
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
}, [
|
|
1571
|
-
contextMenuAxis,
|
|
1572
|
-
contextMenuOpen,
|
|
1573
|
-
model,
|
|
1574
|
-
dispatch
|
|
1575
|
-
]);
|
|
1576
|
-
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1577
|
-
const extension = useMemo2(() => [
|
|
1578
|
-
editorKeys({
|
|
1579
|
-
onClose: handleClose,
|
|
1580
|
-
...editing?.initialContent && {
|
|
1581
|
-
onNav: handleClose
|
|
1582
|
-
}
|
|
1583
|
-
}),
|
|
1584
|
-
sheetExtension({
|
|
1585
|
-
functions: model.graph.getFunctions()
|
|
1586
|
-
}),
|
|
1587
|
-
rangeExtension({
|
|
1588
|
-
onInit: (fn) => rangeController.current = fn,
|
|
1589
|
-
onStateChange: (state) => {
|
|
1590
|
-
if (dxGrid) {
|
|
1591
|
-
dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
})
|
|
1595
|
-
], [
|
|
1596
|
-
model,
|
|
1597
|
-
handleClose,
|
|
1598
|
-
editing
|
|
1599
|
-
]);
|
|
1600
|
-
const getCellContent = useCallback4((index) => {
|
|
1601
|
-
return model.getCellText(parseCellIndex(index));
|
|
1602
|
-
}, [
|
|
1603
|
-
model
|
|
1604
|
-
]);
|
|
1605
|
-
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1606
|
-
useSelectThreadOnCellFocus();
|
|
1607
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
1608
|
-
role: "none",
|
|
1609
|
-
className: "relative min-bs-0"
|
|
1610
|
-
}, /* @__PURE__ */ React5.createElement(GridCellEditor, {
|
|
1611
|
-
getCellContent,
|
|
1612
|
-
extension,
|
|
1613
|
-
onBlur: handleBlur
|
|
1614
|
-
}), /* @__PURE__ */ React5.createElement(Grid2.Content, {
|
|
1615
|
-
initialCells,
|
|
1616
|
-
limitColumns: DEFAULT_COLUMNS,
|
|
1617
|
-
limitRows: DEFAULT_ROWS,
|
|
1618
|
-
columns,
|
|
1619
|
-
rows,
|
|
1620
|
-
onAxisResize: handleAxisResize,
|
|
1621
|
-
onSelect: handleSelect,
|
|
1622
|
-
rowDefault: sheetRowDefault,
|
|
1623
|
-
columnDefault: sheetColDefault,
|
|
1624
|
-
frozen,
|
|
1625
|
-
onFocus: handleFocus,
|
|
1626
|
-
onWheelCapture: handleWheel,
|
|
1627
|
-
onKeyDown: handleKeyDown,
|
|
1628
|
-
onContextMenu: handleContextMenu,
|
|
1629
|
-
onClick: handleClick,
|
|
1630
|
-
overscroll: "trap",
|
|
1631
|
-
className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:absolute [&_.dx-grid]:inset-0 [&_.dx-grid]:border-separator",
|
|
1632
|
-
activeRefs,
|
|
1633
|
-
ref: setDxGrid
|
|
1634
|
-
}), /* @__PURE__ */ React5.createElement(DropdownMenu.Root, {
|
|
1635
|
-
modal: false,
|
|
1636
|
-
open: !!contextMenuOpen,
|
|
1637
|
-
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1638
|
-
}, /* @__PURE__ */ React5.createElement(DropdownMenu.VirtualTrigger, {
|
|
1639
|
-
virtualRef: contextMenuAnchorRef
|
|
1640
|
-
}), /* @__PURE__ */ React5.createElement(DropdownMenu.Content, {
|
|
1641
|
-
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1642
|
-
sideOffset: 4,
|
|
1643
|
-
collisionPadding: 8
|
|
1644
|
-
}, /* @__PURE__ */ React5.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
1645
|
-
onClick: () => handleAxisMenuAction("insert-before"),
|
|
1646
|
-
"data-testid": `grid.${contextMenuAxis}.insert-before`
|
|
1647
|
-
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
1648
|
-
size: 5,
|
|
1649
|
-
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1650
|
-
}), /* @__PURE__ */ React5.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
1651
|
-
onClick: () => handleAxisMenuAction("insert-after"),
|
|
1652
|
-
"data-testid": `grid.${contextMenuAxis}.insert-after`
|
|
1653
|
-
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
1654
|
-
size: 5,
|
|
1655
|
-
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1656
|
-
}), /* @__PURE__ */ React5.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
1657
|
-
onClick: () => handleAxisMenuAction("drop"),
|
|
1658
|
-
"data-testid": `grid.${contextMenuAxis}.drop`
|
|
1659
|
-
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
1660
|
-
size: 5,
|
|
1661
|
-
icon: "ph--backspace--regular"
|
|
1662
|
-
}), /* @__PURE__ */ React5.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ React5.createElement(DropdownMenu.Arrow, null))));
|
|
1663
|
-
};
|
|
1664
|
-
|
|
1665
|
-
export {
|
|
1666
|
-
ComputeGraphContextProvider,
|
|
1667
|
-
useComputeGraph,
|
|
1668
|
-
completeCellRangeToThreadCursor,
|
|
1669
|
-
computeGraphFacet,
|
|
1670
|
-
useSheetContext,
|
|
1671
|
-
SheetProvider,
|
|
1672
|
-
GridSheet,
|
|
1673
|
-
SheetObjectSettings,
|
|
1674
|
-
SheetContainer
|
|
1675
|
-
};
|
|
1676
|
-
//# sourceMappingURL=chunk-NYDNXI7L.mjs.map
|