@dxos/plugin-sheet 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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/neutral/RangeList-HYB5S6KQ.mjs +46 -0
- package/dist/lib/neutral/RangeList-HYB5S6KQ.mjs.map +7 -0
- package/dist/lib/neutral/SheetContainer-ZOVKGHLT.mjs +33 -0
- package/dist/lib/neutral/SheetContainer-ZOVKGHLT.mjs.map +7 -0
- package/dist/lib/neutral/SheetPlugin.mjs +48 -0
- package/dist/lib/neutral/SheetPlugin.mjs.map +7 -0
- package/dist/lib/neutral/SheetPlugin.node.mjs +27 -0
- package/dist/lib/neutral/SheetPlugin.node.mjs.map +7 -0
- package/dist/lib/{browser/anchor-sort-AMMLA66W.mjs → neutral/anchor-sort-TTCKGX7V.mjs} +5 -7
- package/dist/lib/neutral/anchor-sort-TTCKGX7V.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +25 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4GWJDLTH.mjs +83 -0
- package/dist/lib/neutral/chunk-4GWJDLTH.mjs.map +7 -0
- package/dist/lib/{browser/chunk-IFLWVS2V.mjs → neutral/chunk-4SBAIU6F.mjs} +12 -12
- package/dist/lib/neutral/chunk-4SBAIU6F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/{browser/chunk-KE3AKN5W.mjs → neutral/chunk-KC2SMDNF.mjs} +167 -191
- package/dist/lib/neutral/chunk-KC2SMDNF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YFHTB6MX.mjs +8 -0
- package/dist/lib/neutral/chunk-YFHTB6MX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZWOQCLH7.mjs +21 -0
- package/dist/lib/neutral/chunk-ZWOQCLH7.mjs.map +7 -0
- package/dist/lib/neutral/comment-config-ZBWNCJMZ.mjs +20 -0
- package/dist/lib/neutral/comment-config-ZBWNCJMZ.mjs.map +7 -0
- package/dist/lib/{browser/chunk-EDWHV64N.mjs → neutral/components/index.mjs} +552 -474
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/{browser/compute-graph-registry-RC5L7RE4.mjs → neutral/compute-graph-registry-IEQBF5XZ.mjs} +5 -6
- package/dist/lib/neutral/compute-graph-registry-IEQBF5XZ.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-OKQAXJCW.mjs +27 -0
- package/dist/lib/neutral/create-object-OKQAXJCW.mjs.map +7 -0
- package/dist/lib/neutral/drop-axis-G6UOXG54.mjs +23 -0
- package/dist/lib/neutral/drop-axis-G6UOXG54.mjs.map +7 -0
- package/dist/lib/{node-esm/types → neutral}/index.mjs +14 -6
- package/dist/lib/neutral/insert-axis-ZFFNG22G.mjs +16 -0
- package/dist/lib/neutral/insert-axis-ZFFNG22G.mjs.map +7 -0
- package/dist/lib/{browser/markdown-D2T2DOVX.mjs → neutral/markdown-I2AKJYPF.mjs} +5 -6
- package/dist/lib/neutral/markdown-I2AKJYPF.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-TB6LFV2H.mjs +13 -0
- package/dist/lib/neutral/operation-handler-TB6LFV2H.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-surface-45CRAB5G.mjs → neutral/react-surface-ID4JCAFR.mjs} +16 -23
- package/dist/lib/neutral/react-surface-ID4JCAFR.mjs.map +7 -0
- package/dist/lib/neutral/restore-axis-44DM6N54.mjs +16 -0
- package/dist/lib/neutral/restore-axis-44DM6N54.mjs.map +7 -0
- package/dist/lib/neutral/scroll-to-anchor-WHX3HJC7.mjs +33 -0
- package/dist/lib/neutral/scroll-to-anchor-WHX3HJC7.mjs.map +7 -0
- package/dist/lib/neutral/state-HPA27MX2.mjs +29 -0
- package/dist/lib/neutral/state-HPA27MX2.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +103 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +55 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/types/index.mjs +6 -5
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/undo-mappings-3FQLSTCZ.mjs +31 -0
- package/dist/lib/neutral/undo-mappings-3FQLSTCZ.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts +1 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/SheetPlugin.node.d.ts +4 -0
- package/dist/types/src/SheetPlugin.node.d.ts.map +1 -0
- package/dist/types/src/SheetPlugin.test.d.ts +2 -0
- package/dist/types/src/SheetPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/comment-config.d.ts +12 -0
- package/dist/types/src/capabilities/comment-config.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +23 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +6 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.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 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +17 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/index.d.ts +2 -0
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +6 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts +93 -0
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/index.d.ts +2 -0
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +1 -1
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
- package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +8 -6
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +6 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +5 -5
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +72 -68
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +2 -2
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +2 -2
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/RangeList.d.ts +7 -0
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/containers/RangeList/index.d.ts +2 -0
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts +92 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/index.d.ts +2 -0
- package/dist/types/src/containers/SheetContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +1 -3
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +2 -2
- 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 +2 -2
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/operations/drop-axis.d.ts +5 -0
- package/dist/types/src/operations/drop-axis.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/insert-axis.d.ts +5 -0
- package/dist/types/src/operations/insert-axis.d.ts.map +1 -0
- package/dist/types/src/operations/restore-axis.d.ts +5 -0
- package/dist/types/src/operations/restore-axis.d.ts.map +1 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts +5 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +2 -2
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +4 -4
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +74 -39
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +3 -3
- package/dist/types/src/types/Sheet.d.ts.map +1 -1
- package/dist/types/src/types/SheetCapabilities.d.ts +16 -0
- package/dist/types/src/types/SheetCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/SheetOperation.d.ts +45 -0
- package/dist/types/src/types/SheetOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -92
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +1 -1
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +116 -74
- package/src/SheetPlugin.node.ts +21 -0
- package/src/SheetPlugin.test.ts +30 -0
- package/src/SheetPlugin.tsx +25 -35
- package/src/capabilities/{anchor-sort/anchor-sort.ts → anchor-sort.ts} +1 -1
- package/src/capabilities/comment-config.ts +24 -0
- package/src/capabilities/{compute-graph-registry/compute-graph-registry.ts → compute-graph-registry.ts} +4 -2
- package/src/capabilities/create-object.ts +30 -0
- package/src/capabilities/index.ts +17 -5
- package/src/capabilities/{markdown/markdown.ts → markdown.ts} +3 -2
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +49 -0
- package/src/capabilities/state.ts +29 -0
- package/src/capabilities/undo-mappings.ts +30 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +18 -15
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +9 -8
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +19 -18
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +45 -25
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +6 -5
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +52 -39
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +20 -8
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +5 -5
- package/src/components/SheetToolbar/SheetToolbar.tsx +18 -22
- package/src/components/SheetToolbar/align.ts +12 -12
- package/src/components/SheetToolbar/style.ts +10 -10
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +22 -20
- package/src/containers/RangeList/index.ts +5 -0
- package/src/{components → containers}/SheetContainer/SheetContainer.stories.tsx +42 -45
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/containers/SheetContainer/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +16 -15
- package/src/extensions/compute.ts +1 -1
- package/src/extensions/editor/sheet-extension.test.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +12 -12
- package/src/index.ts +2 -2
- package/src/integrations/thread-ranges.ts +7 -40
- package/src/meta.ts +1 -1
- package/src/model/sheet-model.test.ts +5 -5
- package/src/model/sheet-model.ts +17 -17
- package/src/model/testing.ts +2 -2
- package/src/model/useSheetModel.ts +3 -2
- package/src/operations/drop-axis.ts +26 -0
- package/src/operations/index.ts +12 -0
- package/src/operations/insert-axis.ts +19 -0
- package/src/operations/restore-axis.ts +19 -0
- package/src/operations/scroll-to-anchor.ts +30 -0
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +3 -3
- package/src/plugin.ts +11 -0
- package/src/sanity.test.ts +6 -3
- package/src/serializer.ts +2 -2
- package/src/testing/data.ts +1 -1
- package/src/testing/testing.tsx +4 -4
- package/src/translations.ts +41 -36
- package/src/types/Sheet.ts +15 -9
- package/src/types/SheetCapabilities.ts +26 -0
- package/src/types/SheetOperation.ts +75 -0
- package/src/types/index.ts +4 -2
- package/src/types/sheet-range-types.ts +3 -3
- package/src/types/types.ts +0 -80
- package/src/types/util.ts +1 -1
- package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs +0 -397
- package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +0 -7
- package/dist/lib/browser/chunk-EDWHV64N.mjs.map +0 -7
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +0 -7
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -145
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +0 -79
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +0 -7
- package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +0 -398
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs +0 -398
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +0 -1474
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs +0 -236
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +0 -22
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -146
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs +0 -30
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +0 -80
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs +0 -52
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +0 -3
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +0 -5
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +0 -3
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
- package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -55
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/index.d.ts +0 -2
- package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +0 -7
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/index.d.ts +0 -2
- package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -10
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -57
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/index.d.ts +0 -3
- package/dist/types/src/components/SheetContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/index.d.ts +0 -2
- package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -6
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/src/capabilities/anchor-sort/index.ts +0 -7
- package/src/capabilities/compute-graph-registry/index.ts +0 -7
- package/src/capabilities/markdown/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -77
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -43
- package/src/components/SheetContainer/SheetContainer.tsx +0 -48
- package/src/components/SheetContainer/index.ts +0 -7
- package/src/components/SheetContext/index.ts +0 -5
- package/src/types/capabilities.ts +0 -14
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
- /package/dist/types/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +0 -0
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rangeExtension,
|
|
3
3
|
sheetExtension
|
|
4
|
-
} from "
|
|
4
|
+
} from "../chunk-4SBAIU6F.mjs";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
MAX_ROWS,
|
|
10
|
-
ReadonlyException,
|
|
11
|
-
SheetOperation,
|
|
12
|
-
Sheet_exports,
|
|
13
|
-
addressFromIndex,
|
|
14
|
-
addressToIndex,
|
|
15
|
-
cellClassNameForRange,
|
|
16
|
-
initialize,
|
|
17
|
-
insertIndices,
|
|
18
|
-
mapFormulaIndicesToRefs,
|
|
19
|
-
mapFormulaRefsToIndices,
|
|
20
|
-
meta,
|
|
21
|
-
rangeFromIndex
|
|
22
|
-
} from "./chunk-KE3AKN5W.mjs";
|
|
6
|
+
useSelectThreadOnCellFocus
|
|
7
|
+
} from "../chunk-4GWJDLTH.mjs";
|
|
8
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
23
9
|
|
|
24
10
|
// src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
25
11
|
import React, { createContext, useContext } from "react";
|
|
@@ -48,183 +34,35 @@ var useComputeGraph = (space) => {
|
|
|
48
34
|
return graph;
|
|
49
35
|
};
|
|
50
36
|
|
|
51
|
-
// src/components/
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import { rangeToA1Notation } from "@dxos/compute";
|
|
55
|
-
import { Obj } from "@dxos/echo";
|
|
56
|
-
import { Callout, useTranslation } from "@dxos/react-ui";
|
|
57
|
-
import { List } from "@dxos/react-ui-list";
|
|
58
|
-
import { ghostHover } from "@dxos/ui-theme";
|
|
59
|
-
var RangeList = ({ sheet }) => {
|
|
60
|
-
const { t } = useTranslation(meta.id);
|
|
61
|
-
const handleSelectRange = (range) => {
|
|
62
|
-
};
|
|
63
|
-
const handleDeleteRange = useCallback((range) => {
|
|
64
|
-
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
65
|
-
Obj.change(sheet, (obj) => {
|
|
66
|
-
obj.ranges.splice(index, 1);
|
|
67
|
-
});
|
|
68
|
-
}, [
|
|
69
|
-
sheet
|
|
70
|
-
]);
|
|
71
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
|
|
72
|
-
className: "mbs-cardSpacingBlock mbe-labelSpacingBlock text-sm font-semibold"
|
|
73
|
-
}, t("range list heading")), sheet.ranges.length < 1 ? /* @__PURE__ */ React2.createElement(Callout.Root, null, /* @__PURE__ */ React2.createElement(Callout.Title, null, t("no ranges message"))) : /* @__PURE__ */ React2.createElement(List.Root, {
|
|
74
|
-
items: sheet.ranges,
|
|
75
|
-
isItem: Schema.is(Sheet_exports.Range)
|
|
76
|
-
}, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ React2.createElement(List.Item, {
|
|
77
|
-
key: i,
|
|
78
|
-
item: range,
|
|
79
|
-
classNames: [
|
|
80
|
-
"p-2",
|
|
81
|
-
ghostHover
|
|
82
|
-
]
|
|
83
|
-
}, /* @__PURE__ */ React2.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React2.createElement(List.ItemTitle, {
|
|
84
|
-
onClick: () => handleSelectRange(range)
|
|
85
|
-
}, t("range title", {
|
|
86
|
-
position: rangeToA1Notation(rangeFromIndex(sheet, range.range)),
|
|
87
|
-
key: t(`range key ${range.key} label`),
|
|
88
|
-
value: t(`range value ${range.value} label`)
|
|
89
|
-
})), /* @__PURE__ */ React2.createElement(List.ItemDeleteButton, {
|
|
90
|
-
onClick: () => handleDeleteRange(range)
|
|
91
|
-
})))));
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/components/index.ts
|
|
95
|
-
import { lazy } from "react";
|
|
96
|
-
|
|
97
|
-
// src/components/GridSheet/GridSheet.tsx
|
|
98
|
-
import React4, { useCallback as useCallback4, useMemo as useMemo2, useRef, useState as useState4 } from "react";
|
|
99
|
-
import { useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/ui";
|
|
100
|
-
import { rangeToA1Notation as rangeToA1Notation2 } from "@dxos/compute";
|
|
101
|
-
import { Obj as Obj5 } from "@dxos/echo";
|
|
37
|
+
// src/components/SheetContent/SheetContent.tsx
|
|
38
|
+
import React3, { useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef, useState as useState4 } from "react";
|
|
39
|
+
import { useCapabilities, useOperationInvoker } from "@dxos/app-framework/ui";
|
|
40
|
+
import { rangeToA1Notation } from "@dxos/compute-hyperformula";
|
|
41
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
102
42
|
import { defaultColSize, defaultRowSize } from "@dxos/lit-grid";
|
|
103
|
-
import { DropdownMenu, Icon, useTranslation
|
|
43
|
+
import { DropdownMenu, Icon, useTranslation } from "@dxos/react-ui";
|
|
104
44
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
105
45
|
import { Grid as Grid2, GridCellEditor, closestCell, editorKeys, parseCellIndex } from "@dxos/react-ui-grid";
|
|
46
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
47
|
+
import { meta } from "#meta";
|
|
48
|
+
import { SheetOperation } from "#types";
|
|
49
|
+
import { DEFAULT_COLS, DEFAULT_ROWS, SheetCapabilities } from "#types";
|
|
106
50
|
|
|
107
|
-
// src/
|
|
108
|
-
import
|
|
109
|
-
import {
|
|
110
|
-
import { useOperationInvoker, useOperationResolver } from "@dxos/app-framework/ui";
|
|
111
|
-
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
112
|
-
import { debounce } from "@dxos/async";
|
|
113
|
-
import { inRange } from "@dxos/compute";
|
|
114
|
-
import { Obj as Obj2, Relation } from "@dxos/echo";
|
|
115
|
-
import { OperationResolver } from "@dxos/operation";
|
|
116
|
-
import { ATTENDABLE_PATH_SEPARATOR, DeckOperation } from "@dxos/plugin-deck/types";
|
|
117
|
-
import { ThreadOperation } from "@dxos/plugin-thread/types";
|
|
118
|
-
import { Filter, Query, useQuery } from "@dxos/react-client/echo";
|
|
119
|
-
import { AnchoredTo, Thread } from "@dxos/types";
|
|
120
|
-
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
121
|
-
const coords = cursor.split(",");
|
|
122
|
-
if (coords.length !== 4) {
|
|
123
|
-
return null;
|
|
124
|
-
} else {
|
|
125
|
-
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
126
|
-
return {
|
|
127
|
-
from: {
|
|
128
|
-
col: parseInt(fromCol),
|
|
129
|
-
row: parseInt(fromRow)
|
|
130
|
-
},
|
|
131
|
-
to: {
|
|
132
|
-
col: parseInt(toCol),
|
|
133
|
-
row: parseInt(toRow)
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
139
|
-
const { model, setActiveRefs } = useSheetContext();
|
|
140
|
-
const sheetId = Obj2.getDXN(model.sheet).toString();
|
|
141
|
-
const scrollIntoViewHandler = useMemo(() => OperationResolver.make({
|
|
142
|
-
operation: LayoutOperation.ScrollIntoView,
|
|
143
|
-
position: "hoist",
|
|
144
|
-
filter: (input) => input.subject === sheetId && !!input.cursor,
|
|
145
|
-
handler: (input) => Effect.sync(() => {
|
|
146
|
-
const { cursor, ref } = input;
|
|
147
|
-
if (cursor) {
|
|
148
|
-
setActiveRefs(ref);
|
|
149
|
-
const range = parseThreadAnchorAsCellRange(cursor);
|
|
150
|
-
range && grid?.setFocus({
|
|
151
|
-
...range.to,
|
|
152
|
-
plane: "grid"
|
|
153
|
-
}, true);
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
}), [
|
|
157
|
-
sheetId,
|
|
158
|
-
setActiveRefs,
|
|
159
|
-
grid
|
|
160
|
-
]);
|
|
161
|
-
useOperationResolver(meta.id, scrollIntoViewHandler);
|
|
162
|
-
};
|
|
163
|
-
var useSelectThreadOnCellFocus = () => {
|
|
164
|
-
const { model, cursor } = useSheetContext();
|
|
165
|
-
const { invokePromise } = useOperationInvoker();
|
|
166
|
-
const db = Obj2.getDatabase(model.sheet);
|
|
167
|
-
const anchors = useQuery(db, Query.select(Filter.id(model.sheet.id)).targetOf(AnchoredTo.AnchoredTo));
|
|
168
|
-
const selectClosestThread = useCallback2((cellAddress) => {
|
|
169
|
-
if (!cellAddress) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const closestThread = anchors.find((anchor) => {
|
|
173
|
-
const source = Relation.getSource(anchor);
|
|
174
|
-
if (anchor.anchor && Obj2.instanceOf(Thread.Thread, source)) {
|
|
175
|
-
const range = parseThreadAnchorAsCellRange(anchor.anchor);
|
|
176
|
-
return range ? inRange(range, cellAddress) : false;
|
|
177
|
-
} else {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
if (closestThread) {
|
|
182
|
-
const primary = Obj2.getDXN(model.sheet).toString();
|
|
183
|
-
void (async () => {
|
|
184
|
-
await invokePromise(ThreadOperation.Select, {
|
|
185
|
-
current: Relation.getDXN(closestThread).toString()
|
|
186
|
-
});
|
|
187
|
-
await invokePromise(DeckOperation.ChangeCompanion, {
|
|
188
|
-
primary,
|
|
189
|
-
companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments`
|
|
190
|
-
});
|
|
191
|
-
})();
|
|
192
|
-
}
|
|
193
|
-
}, [
|
|
194
|
-
invokePromise,
|
|
195
|
-
anchors
|
|
196
|
-
]);
|
|
197
|
-
const debounced = useMemo(() => {
|
|
198
|
-
return debounce((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
199
|
-
}, [
|
|
200
|
-
selectClosestThread
|
|
201
|
-
]);
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
if (!cursor) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
debounced(cursor);
|
|
207
|
-
}, [
|
|
208
|
-
cursor,
|
|
209
|
-
debounced
|
|
210
|
-
]);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// src/components/SheetContext/SheetContext.tsx
|
|
214
|
-
import React3, { createContext as createContext2, useCallback as useCallback3, useContext as useContext2, useState as useState2 } from "react";
|
|
215
|
-
import { Obj as Obj4 } from "@dxos/echo";
|
|
216
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
51
|
+
// src/components/SheetRoot/SheetRoot.tsx
|
|
52
|
+
import React2, { createContext as createContext2, useCallback, useContext as useContext2, useState as useState2 } from "react";
|
|
53
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
217
54
|
import { Grid, useGridContext } from "@dxos/react-ui-grid";
|
|
218
55
|
|
|
219
56
|
// src/model/sheet-model.ts
|
|
220
57
|
import { Event } from "@dxos/async";
|
|
221
|
-
import { DetailedCellError, ExportedCellChange, addressFromA1Notation, addressToA1Notation, createSheetName, isFormula } from "@dxos/compute";
|
|
58
|
+
import { DetailedCellError, ExportedCellChange, addressFromA1Notation, addressToA1Notation, createSheetName, isFormula } from "@dxos/compute-hyperformula";
|
|
222
59
|
import { Resource } from "@dxos/context";
|
|
223
|
-
import { Obj
|
|
60
|
+
import { Obj } from "@dxos/echo";
|
|
224
61
|
import { Format, TypeEnum } from "@dxos/echo/internal";
|
|
225
62
|
import { invariant } from "@dxos/invariant";
|
|
226
63
|
import { PublicKey } from "@dxos/keys";
|
|
227
64
|
import { log } from "@dxos/log";
|
|
65
|
+
import { MAX_COLS, MAX_ROWS, ReadonlyException, addressFromIndex, addressToIndex, initialize, insertIndices, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from "#types";
|
|
228
66
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
229
67
|
var typeMap = {
|
|
230
68
|
BOOLEAN: {
|
|
@@ -302,13 +140,8 @@ var SheetModel = class extends Resource {
|
|
|
302
140
|
async _open() {
|
|
303
141
|
log("initialize", {
|
|
304
142
|
id: this.id
|
|
305
|
-
}, {
|
|
306
|
-
|
|
307
|
-
L: 124,
|
|
308
|
-
S: this,
|
|
309
|
-
C: (f, a) => f(...a)
|
|
310
|
-
});
|
|
311
|
-
Obj3.change(this._sheet, (obj) => {
|
|
143
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 96, S: this });
|
|
144
|
+
Obj.update(this._sheet, (obj) => {
|
|
312
145
|
initialize(obj);
|
|
313
146
|
});
|
|
314
147
|
this._graph.update.on((event) => {
|
|
@@ -317,7 +150,7 @@ var SheetModel = class extends Resource {
|
|
|
317
150
|
}
|
|
318
151
|
});
|
|
319
152
|
this._node = this._graph.getOrCreateNode(createSheetName({
|
|
320
|
-
type:
|
|
153
|
+
type: Obj.getTypename(this._sheet),
|
|
321
154
|
id: this._sheet.id
|
|
322
155
|
}));
|
|
323
156
|
await this._node.open();
|
|
@@ -331,26 +164,10 @@ var SheetModel = class extends Resource {
|
|
|
331
164
|
* @deprecated
|
|
332
165
|
*/
|
|
333
166
|
reset() {
|
|
334
|
-
invariant(this._node, void 0, {
|
|
335
|
-
F: __dxlog_file,
|
|
336
|
-
L: 154,
|
|
337
|
-
S: this,
|
|
338
|
-
A: [
|
|
339
|
-
"this._node",
|
|
340
|
-
""
|
|
341
|
-
]
|
|
342
|
-
});
|
|
167
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 123, S: this, A: ["this._node", ""] });
|
|
343
168
|
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
344
169
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
345
|
-
invariant(this._node, void 0, {
|
|
346
|
-
F: __dxlog_file,
|
|
347
|
-
L: 157,
|
|
348
|
-
S: this,
|
|
349
|
-
A: [
|
|
350
|
-
"this._node",
|
|
351
|
-
""
|
|
352
|
-
]
|
|
353
|
-
});
|
|
170
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 126, S: this, A: ["this._node", ""] });
|
|
354
171
|
const { col, row } = addressFromIndex(this._sheet, key);
|
|
355
172
|
if (isFormula(value)) {
|
|
356
173
|
const binding = this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
|
|
@@ -379,7 +196,7 @@ var SheetModel = class extends Resource {
|
|
|
379
196
|
}
|
|
380
197
|
insertRows(i, n = 1) {
|
|
381
198
|
let idx = [];
|
|
382
|
-
|
|
199
|
+
Obj.update(this._sheet, (obj) => {
|
|
383
200
|
idx = insertIndices(obj.rows, i, n, MAX_ROWS);
|
|
384
201
|
});
|
|
385
202
|
this.reset();
|
|
@@ -387,7 +204,7 @@ var SheetModel = class extends Resource {
|
|
|
387
204
|
}
|
|
388
205
|
insertColumns(i, n = 1) {
|
|
389
206
|
let idx = [];
|
|
390
|
-
|
|
207
|
+
Obj.update(this._sheet, (obj) => {
|
|
391
208
|
idx = insertIndices(obj.columns, i, n, MAX_COLS);
|
|
392
209
|
});
|
|
393
210
|
this.reset();
|
|
@@ -401,7 +218,7 @@ var SheetModel = class extends Resource {
|
|
|
401
218
|
const values = this.getCellValues(range).flat();
|
|
402
219
|
const index = this._sheet.rows.indexOf(rowIndex);
|
|
403
220
|
this.clear(range);
|
|
404
|
-
|
|
221
|
+
Obj.update(this._sheet, (obj) => {
|
|
405
222
|
obj.rows.splice(index, 1);
|
|
406
223
|
delete obj.rowMeta[rowIndex];
|
|
407
224
|
});
|
|
@@ -422,7 +239,7 @@ var SheetModel = class extends Resource {
|
|
|
422
239
|
const values = this.getCellValues(range).flat();
|
|
423
240
|
const index = this._sheet.columns.indexOf(colIndex);
|
|
424
241
|
this.clear(range);
|
|
425
|
-
|
|
242
|
+
Obj.update(this._sheet, (obj) => {
|
|
426
243
|
obj.columns.splice(index, 1);
|
|
427
244
|
delete obj.columnMeta[colIndex];
|
|
428
245
|
});
|
|
@@ -436,7 +253,7 @@ var SheetModel = class extends Resource {
|
|
|
436
253
|
};
|
|
437
254
|
}
|
|
438
255
|
restoreRow({ index, axisIndex, axisMeta, values }) {
|
|
439
|
-
|
|
256
|
+
Obj.update(this._sheet, (obj) => {
|
|
440
257
|
obj.rows.splice(index, 0, axisIndex);
|
|
441
258
|
values.forEach((value, col) => {
|
|
442
259
|
if (value) {
|
|
@@ -452,7 +269,7 @@ var SheetModel = class extends Resource {
|
|
|
452
269
|
this.reset();
|
|
453
270
|
}
|
|
454
271
|
restoreColumn({ index, axisIndex, axisMeta, values }) {
|
|
455
|
-
|
|
272
|
+
Obj.update(this._sheet, (obj) => {
|
|
456
273
|
obj.columns.splice(index, 0, axisIndex);
|
|
457
274
|
values.forEach((value, row) => {
|
|
458
275
|
if (value) {
|
|
@@ -475,19 +292,11 @@ var SheetModel = class extends Resource {
|
|
|
475
292
|
* Clear range of values.
|
|
476
293
|
*/
|
|
477
294
|
clear(range) {
|
|
478
|
-
invariant(this._node, void 0, {
|
|
479
|
-
F: __dxlog_file,
|
|
480
|
-
L: 276,
|
|
481
|
-
S: this,
|
|
482
|
-
A: [
|
|
483
|
-
"this._node",
|
|
484
|
-
""
|
|
485
|
-
]
|
|
486
|
-
});
|
|
295
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 251, S: this, A: ["this._node", ""] });
|
|
487
296
|
const topLeft = getTopLeft(range);
|
|
488
297
|
const values = this._iterRange(range, () => null);
|
|
489
298
|
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
490
|
-
|
|
299
|
+
Obj.update(this._sheet, (obj) => {
|
|
491
300
|
this._iterRange(range, (cell) => {
|
|
492
301
|
const idx = addressToIndex(this._sheet, cell);
|
|
493
302
|
delete obj.cells[idx];
|
|
@@ -495,17 +304,9 @@ var SheetModel = class extends Resource {
|
|
|
495
304
|
});
|
|
496
305
|
}
|
|
497
306
|
cut(range) {
|
|
498
|
-
invariant(this._node, void 0, {
|
|
499
|
-
F: __dxlog_file,
|
|
500
|
-
L: 289,
|
|
501
|
-
S: this,
|
|
502
|
-
A: [
|
|
503
|
-
"this._node",
|
|
504
|
-
""
|
|
505
|
-
]
|
|
506
|
-
});
|
|
307
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 263, S: this, A: ["this._node", ""] });
|
|
507
308
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
508
|
-
|
|
309
|
+
Obj.update(this._sheet, (obj) => {
|
|
509
310
|
this._iterRange(range, (cell) => {
|
|
510
311
|
const idx = addressToIndex(this._sheet, cell);
|
|
511
312
|
delete obj.cells[idx];
|
|
@@ -513,30 +314,14 @@ var SheetModel = class extends Resource {
|
|
|
513
314
|
});
|
|
514
315
|
}
|
|
515
316
|
copy(range) {
|
|
516
|
-
invariant(this._node, void 0, {
|
|
517
|
-
F: __dxlog_file,
|
|
518
|
-
L: 300,
|
|
519
|
-
S: this,
|
|
520
|
-
A: [
|
|
521
|
-
"this._node",
|
|
522
|
-
""
|
|
523
|
-
]
|
|
524
|
-
});
|
|
317
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 273, S: this, A: ["this._node", ""] });
|
|
525
318
|
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
526
319
|
}
|
|
527
320
|
paste(cell) {
|
|
528
|
-
invariant(this._node, void 0, {
|
|
529
|
-
F: __dxlog_file,
|
|
530
|
-
L: 305,
|
|
531
|
-
S: this,
|
|
532
|
-
A: [
|
|
533
|
-
"this._node",
|
|
534
|
-
""
|
|
535
|
-
]
|
|
536
|
-
});
|
|
321
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: this, A: ["this._node", ""] });
|
|
537
322
|
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
538
323
|
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
539
|
-
|
|
324
|
+
Obj.update(this._sheet, (obj) => {
|
|
540
325
|
for (const change of changes) {
|
|
541
326
|
if (change instanceof ExportedCellChange) {
|
|
542
327
|
const { address, newValue } = change;
|
|
@@ -554,29 +339,13 @@ var SheetModel = class extends Resource {
|
|
|
554
339
|
}
|
|
555
340
|
// TODO(burdon): Display undo/redo state.
|
|
556
341
|
undo() {
|
|
557
|
-
invariant(this._node, void 0, {
|
|
558
|
-
F: __dxlog_file,
|
|
559
|
-
L: 322,
|
|
560
|
-
S: this,
|
|
561
|
-
A: [
|
|
562
|
-
"this._node",
|
|
563
|
-
""
|
|
564
|
-
]
|
|
565
|
-
});
|
|
342
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 298, S: this, A: ["this._node", ""] });
|
|
566
343
|
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
567
344
|
this._node.graph.hf.undo();
|
|
568
345
|
}
|
|
569
346
|
}
|
|
570
347
|
redo() {
|
|
571
|
-
invariant(this._node, void 0, {
|
|
572
|
-
F: __dxlog_file,
|
|
573
|
-
L: 330,
|
|
574
|
-
S: this,
|
|
575
|
-
A: [
|
|
576
|
-
"this._node",
|
|
577
|
-
""
|
|
578
|
-
]
|
|
579
|
-
});
|
|
348
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 305, S: this, A: ["this._node", ""] });
|
|
580
349
|
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
581
350
|
this._node.graph.hf.redo();
|
|
582
351
|
}
|
|
@@ -612,27 +381,14 @@ var SheetModel = class extends Resource {
|
|
|
612
381
|
* Gets the regular or computed value from the engine.
|
|
613
382
|
*/
|
|
614
383
|
getValue(cell) {
|
|
615
|
-
invariant(this._node, void 0, {
|
|
616
|
-
F: __dxlog_file,
|
|
617
|
-
L: 373,
|
|
618
|
-
S: this,
|
|
619
|
-
A: [
|
|
620
|
-
"this._node",
|
|
621
|
-
""
|
|
622
|
-
]
|
|
623
|
-
});
|
|
384
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 339, S: this, A: ["this._node", ""] });
|
|
624
385
|
const address = toSimpleCellAddress(this._node.sheetId, cell);
|
|
625
386
|
const value = this._node.graph.hf.getCellValue(address);
|
|
626
387
|
if (value instanceof DetailedCellError) {
|
|
627
388
|
log.warn("cell error", {
|
|
628
389
|
cell,
|
|
629
390
|
error: value
|
|
630
|
-
}, {
|
|
631
|
-
F: __dxlog_file,
|
|
632
|
-
L: 378,
|
|
633
|
-
S: this,
|
|
634
|
-
C: (f, a) => f(...a)
|
|
635
|
-
});
|
|
391
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 344, S: this });
|
|
636
392
|
return value.toString();
|
|
637
393
|
}
|
|
638
394
|
return value;
|
|
@@ -641,15 +397,7 @@ var SheetModel = class extends Resource {
|
|
|
641
397
|
* Get value type.
|
|
642
398
|
*/
|
|
643
399
|
getValueDescription(cell) {
|
|
644
|
-
invariant(this._node, void 0, {
|
|
645
|
-
F: __dxlog_file,
|
|
646
|
-
L: 389,
|
|
647
|
-
S: this,
|
|
648
|
-
A: [
|
|
649
|
-
"this._node",
|
|
650
|
-
""
|
|
651
|
-
]
|
|
652
|
-
});
|
|
400
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 355, S: this, A: ["this._node", ""] });
|
|
653
401
|
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
654
402
|
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
655
403
|
return typeMap[type];
|
|
@@ -658,27 +406,19 @@ var SheetModel = class extends Resource {
|
|
|
658
406
|
* Sets the value, updating the sheet and engine.
|
|
659
407
|
*/
|
|
660
408
|
setValue(cell, value) {
|
|
661
|
-
invariant(this._node, void 0, {
|
|
662
|
-
F: __dxlog_file,
|
|
663
|
-
L: 399,
|
|
664
|
-
S: this,
|
|
665
|
-
A: [
|
|
666
|
-
"this._node",
|
|
667
|
-
""
|
|
668
|
-
]
|
|
669
|
-
});
|
|
409
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 363, S: this, A: ["this._node", ""] });
|
|
670
410
|
if (this._options.readonly) {
|
|
671
411
|
throw new ReadonlyException();
|
|
672
412
|
}
|
|
673
413
|
let refresh = false;
|
|
674
414
|
if (cell.row >= this._sheet.rows.length) {
|
|
675
|
-
|
|
415
|
+
Obj.update(this._sheet, (obj) => {
|
|
676
416
|
insertIndices(obj.rows, cell.row, 1, MAX_ROWS);
|
|
677
417
|
});
|
|
678
418
|
refresh = true;
|
|
679
419
|
}
|
|
680
420
|
if (cell.col >= this._sheet.columns.length) {
|
|
681
|
-
|
|
421
|
+
Obj.update(this._sheet, (obj) => {
|
|
682
422
|
insertIndices(obj.columns, cell.col, 1, MAX_COLS);
|
|
683
423
|
});
|
|
684
424
|
refresh = true;
|
|
@@ -697,14 +437,14 @@ var SheetModel = class extends Resource {
|
|
|
697
437
|
]);
|
|
698
438
|
const idx = addressToIndex(this._sheet, cell);
|
|
699
439
|
if (value === void 0 || value === null) {
|
|
700
|
-
|
|
440
|
+
Obj.update(this._sheet, (obj) => {
|
|
701
441
|
delete obj.cells[idx];
|
|
702
442
|
});
|
|
703
443
|
} else {
|
|
704
444
|
if (isFormula(value)) {
|
|
705
445
|
value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
|
|
706
446
|
}
|
|
707
|
-
|
|
447
|
+
Obj.update(this._sheet, (obj) => {
|
|
708
448
|
obj.cells[idx] = {
|
|
709
449
|
value
|
|
710
450
|
};
|
|
@@ -760,15 +500,7 @@ var SheetModel = class extends Resource {
|
|
|
760
500
|
* Map from indices to A1 notation.
|
|
761
501
|
*/
|
|
762
502
|
mapFormulaIndicesToRefs(formula) {
|
|
763
|
-
invariant(isFormula(formula), void 0, {
|
|
764
|
-
F: __dxlog_file,
|
|
765
|
-
L: 492,
|
|
766
|
-
S: this,
|
|
767
|
-
A: [
|
|
768
|
-
"isFormula(formula)",
|
|
769
|
-
""
|
|
770
|
-
]
|
|
771
|
-
});
|
|
503
|
+
invariant(isFormula(formula), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 458, S: this, A: ["isFormula(formula)", ""] });
|
|
772
504
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
773
505
|
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
774
506
|
});
|
|
@@ -786,48 +518,24 @@ var SheetModel = class extends Resource {
|
|
|
786
518
|
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
787
519
|
}
|
|
788
520
|
toDateTime(num) {
|
|
789
|
-
invariant(this._node, void 0, {
|
|
790
|
-
F: __dxlog_file,
|
|
791
|
-
L: 513,
|
|
792
|
-
S: this,
|
|
793
|
-
A: [
|
|
794
|
-
"this._node",
|
|
795
|
-
""
|
|
796
|
-
]
|
|
797
|
-
});
|
|
521
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 475, S: this, A: ["this._node", ""] });
|
|
798
522
|
return this._node.graph.hf.numberToDateTime(num);
|
|
799
523
|
}
|
|
800
524
|
toDate(num) {
|
|
801
|
-
invariant(this._node, void 0, {
|
|
802
|
-
F: __dxlog_file,
|
|
803
|
-
L: 518,
|
|
804
|
-
S: this,
|
|
805
|
-
A: [
|
|
806
|
-
"this._node",
|
|
807
|
-
""
|
|
808
|
-
]
|
|
809
|
-
});
|
|
525
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 479, S: this, A: ["this._node", ""] });
|
|
810
526
|
return this._node.graph.hf.numberToDate(num);
|
|
811
527
|
}
|
|
812
528
|
toTime(num) {
|
|
813
|
-
invariant(this._node, void 0, {
|
|
814
|
-
F: __dxlog_file,
|
|
815
|
-
L: 523,
|
|
816
|
-
S: this,
|
|
817
|
-
A: [
|
|
818
|
-
"this._node",
|
|
819
|
-
""
|
|
820
|
-
]
|
|
821
|
-
});
|
|
529
|
+
invariant(this._node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 483, S: this, A: ["this._node", ""] });
|
|
822
530
|
return this._node.graph.hf.numberToTime(num);
|
|
823
531
|
}
|
|
824
532
|
};
|
|
825
533
|
|
|
826
534
|
// src/model/useSheetModel.ts
|
|
827
|
-
import { useEffect
|
|
535
|
+
import { useEffect, useState } from "react";
|
|
828
536
|
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
829
537
|
const [model, setModel] = useState();
|
|
830
|
-
|
|
538
|
+
useEffect(() => {
|
|
831
539
|
if (!graph || !sheet) {
|
|
832
540
|
return;
|
|
833
541
|
}
|
|
@@ -851,29 +559,34 @@ var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
|
851
559
|
return model;
|
|
852
560
|
};
|
|
853
561
|
|
|
854
|
-
// src/components/
|
|
855
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
562
|
+
// src/components/SheetRoot/SheetRoot.tsx
|
|
856
563
|
var SheetContext = /* @__PURE__ */ createContext2(void 0);
|
|
857
564
|
var useSheetContext = () => {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
A: [
|
|
864
|
-
"context",
|
|
865
|
-
""
|
|
866
|
-
]
|
|
565
|
+
return useContext2(SheetContext) ?? raise2(new Error("Missing SheetContext"));
|
|
566
|
+
};
|
|
567
|
+
var SheetRoot = ({ children, graph, sheet, attendableId, readonly, ignoreAttention, onInfo }) => {
|
|
568
|
+
const model = useSheetModel(graph, sheet, {
|
|
569
|
+
readonly
|
|
867
570
|
});
|
|
868
|
-
|
|
571
|
+
if (!model) {
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
return /* @__PURE__ */ React2.createElement(Grid.Root, {
|
|
575
|
+
id: attendableId
|
|
576
|
+
}, /* @__PURE__ */ React2.createElement(SheetProviderImpl, {
|
|
577
|
+
model,
|
|
578
|
+
attendableId,
|
|
579
|
+
onInfo,
|
|
580
|
+
ignoreAttention
|
|
581
|
+
}, children));
|
|
869
582
|
};
|
|
870
|
-
var SheetProviderImpl = ({ __gridScope, children, ignoreAttention, model, onInfo }) => {
|
|
583
|
+
var SheetProviderImpl = ({ __gridScope, children, attendableId, ignoreAttention, model, onInfo }) => {
|
|
871
584
|
const { id, editing, setEditing } = useGridContext("SheetProvider", __gridScope);
|
|
872
585
|
const [cursor, setCursorInternal] = useState2();
|
|
873
586
|
const [range, setRangeInternal] = useState2();
|
|
874
587
|
const [cursorFallbackRange, setCursorFallbackRange] = useState2();
|
|
875
588
|
const [activeRefs, setActiveRefs] = useState2("");
|
|
876
|
-
const setCursor =
|
|
589
|
+
const setCursor = useCallback((nextCursor) => {
|
|
877
590
|
setCursorInternal(nextCursor);
|
|
878
591
|
setCursorFallbackRange(range?.to ? range : nextCursor ? {
|
|
879
592
|
from: nextCursor,
|
|
@@ -882,7 +595,7 @@ var SheetProviderImpl = ({ __gridScope, children, ignoreAttention, model, onInfo
|
|
|
882
595
|
}, [
|
|
883
596
|
range
|
|
884
597
|
]);
|
|
885
|
-
const setRange =
|
|
598
|
+
const setRange = useCallback((nextRange) => {
|
|
886
599
|
setRangeInternal(nextRange);
|
|
887
600
|
setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
|
|
888
601
|
from: cursor,
|
|
@@ -891,9 +604,10 @@ var SheetProviderImpl = ({ __gridScope, children, ignoreAttention, model, onInfo
|
|
|
891
604
|
}, [
|
|
892
605
|
cursor
|
|
893
606
|
]);
|
|
894
|
-
return /* @__PURE__ */
|
|
607
|
+
return /* @__PURE__ */ React2.createElement(SheetContext.Provider, {
|
|
895
608
|
value: {
|
|
896
609
|
id,
|
|
610
|
+
attendableId,
|
|
897
611
|
model,
|
|
898
612
|
editing,
|
|
899
613
|
setEditing,
|
|
@@ -904,32 +618,21 @@ var SheetProviderImpl = ({ __gridScope, children, ignoreAttention, model, onInfo
|
|
|
904
618
|
cursorFallbackRange,
|
|
905
619
|
activeRefs,
|
|
906
620
|
setActiveRefs,
|
|
621
|
+
ignoreAttention,
|
|
907
622
|
// TODO(burdon): Change to event.
|
|
908
|
-
onInfo
|
|
909
|
-
ignoreAttention
|
|
623
|
+
onInfo
|
|
910
624
|
}
|
|
911
625
|
}, children);
|
|
912
626
|
};
|
|
913
|
-
var SheetProvider = ({ children, graph, sheet, readonly, ignoreAttention, onInfo }) => {
|
|
914
|
-
const model = useSheetModel(graph, sheet, {
|
|
915
|
-
readonly
|
|
916
|
-
});
|
|
917
|
-
return !model ? null : /* @__PURE__ */ React3.createElement(Grid.Root, {
|
|
918
|
-
id: Obj4.getDXN(sheet).toString()
|
|
919
|
-
}, /* @__PURE__ */ React3.createElement(SheetProviderImpl, {
|
|
920
|
-
model,
|
|
921
|
-
onInfo,
|
|
922
|
-
ignoreAttention
|
|
923
|
-
}, children));
|
|
924
|
-
};
|
|
925
627
|
|
|
926
|
-
// src/components/
|
|
927
|
-
import { useEffect as
|
|
928
|
-
import { inRange
|
|
628
|
+
// src/components/SheetContent/util.ts
|
|
629
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
630
|
+
import { inRange } from "@dxos/compute-hyperformula";
|
|
929
631
|
import { createDocAccessor } from "@dxos/echo-db";
|
|
930
632
|
import { cellClassesForFieldType, parseValue } from "@dxos/react-ui-form";
|
|
931
633
|
import { colToA1Notation, commentedClassName, rowToA1Notation } from "@dxos/react-ui-grid";
|
|
932
634
|
import { mx } from "@dxos/ui-theme";
|
|
635
|
+
import { cellClassNameForRange, rangeFromIndex } from "#types";
|
|
933
636
|
var createDxGridColumns = (model) => {
|
|
934
637
|
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
935
638
|
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
@@ -962,7 +665,7 @@ var projectCellProps = (model, col, row) => {
|
|
|
962
665
|
row
|
|
963
666
|
};
|
|
964
667
|
const rawValue = model.getValue(address);
|
|
965
|
-
const ranges = model.sheet.ranges?.filter(({ range }) =>
|
|
668
|
+
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(rangeFromIndex(model.sheet, range), address));
|
|
966
669
|
const threadRefs = void 0;
|
|
967
670
|
const description = model.getValueDescription(address);
|
|
968
671
|
const type = description?.type;
|
|
@@ -1000,12 +703,12 @@ var gridCellGetter = (model) => {
|
|
|
1000
703
|
};
|
|
1001
704
|
var rowLabelCell = (row) => ({
|
|
1002
705
|
value: rowToA1Notation(row),
|
|
1003
|
-
className: "!bg-
|
|
706
|
+
className: "!bg-toolbar-surface text-subdued text-end pe-1",
|
|
1004
707
|
resizeHandle: "row"
|
|
1005
708
|
});
|
|
1006
709
|
var colLabelCell = (col) => ({
|
|
1007
710
|
value: colToA1Notation(col),
|
|
1008
|
-
className: "!bg-
|
|
711
|
+
className: "!bg-toolbar-surface text-subdued",
|
|
1009
712
|
resizeHandle: "col"
|
|
1010
713
|
});
|
|
1011
714
|
var cellGetter = (model) => {
|
|
@@ -1017,7 +720,7 @@ var cellGetter = (model) => {
|
|
|
1017
720
|
case "fixedStartStart": {
|
|
1018
721
|
return {
|
|
1019
722
|
"0,0": {
|
|
1020
|
-
className: "!bg-
|
|
723
|
+
className: "!bg-toolbar-surface"
|
|
1021
724
|
}
|
|
1022
725
|
};
|
|
1023
726
|
}
|
|
@@ -1045,7 +748,7 @@ var cellGetter = (model) => {
|
|
|
1045
748
|
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1046
749
|
const [columns, setColumns] = useState3(createDxGridColumns(model));
|
|
1047
750
|
const [rows, setRows] = useState3(createDxGridRows(model));
|
|
1048
|
-
|
|
751
|
+
useEffect2(() => {
|
|
1049
752
|
const cellsAccessor = createDocAccessor(model.sheet, [
|
|
1050
753
|
"cells"
|
|
1051
754
|
]);
|
|
@@ -1065,7 +768,7 @@ var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
|
1065
768
|
model,
|
|
1066
769
|
dxGrid
|
|
1067
770
|
]);
|
|
1068
|
-
|
|
771
|
+
useEffect2(() => {
|
|
1069
772
|
const columnMetaAccessor = createDocAccessor(model.sheet, [
|
|
1070
773
|
"columnMeta"
|
|
1071
774
|
]);
|
|
@@ -1094,7 +797,7 @@ var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
|
1094
797
|
};
|
|
1095
798
|
};
|
|
1096
799
|
|
|
1097
|
-
// src/components/
|
|
800
|
+
// src/components/SheetContent/SheetContent.tsx
|
|
1098
801
|
var inertPosition = {
|
|
1099
802
|
plane: "grid",
|
|
1100
803
|
col: 0,
|
|
@@ -1141,15 +844,15 @@ var sheetRowDefault = {
|
|
|
1141
844
|
resizeable: true
|
|
1142
845
|
}
|
|
1143
846
|
};
|
|
1144
|
-
var
|
|
1145
|
-
const { t } =
|
|
1146
|
-
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } = useSheetContext();
|
|
847
|
+
var SheetContent = composable((props, forwardedRef) => {
|
|
848
|
+
const { t } = useTranslation(meta.id);
|
|
849
|
+
const { id, attendableId, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, setActiveRefs, ignoreAttention } = useSheetContext();
|
|
1147
850
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
1148
851
|
const [extraplanarFocus, setExtraplanarFocus] = useState4(null);
|
|
1149
|
-
const { invokePromise } =
|
|
852
|
+
const { invokePromise } = useOperationInvoker();
|
|
1150
853
|
const rangeController = useRef(null);
|
|
1151
854
|
const { hasAttention } = useAttention(id);
|
|
1152
|
-
const handleFocus =
|
|
855
|
+
const handleFocus = useCallback2((event) => {
|
|
1153
856
|
if (!editing) {
|
|
1154
857
|
const cell = closestCell(event.target);
|
|
1155
858
|
if (cell) {
|
|
@@ -1169,7 +872,7 @@ var GridSheet = () => {
|
|
|
1169
872
|
}, [
|
|
1170
873
|
editing
|
|
1171
874
|
]);
|
|
1172
|
-
const handleClose =
|
|
875
|
+
const handleClose = useCallback2((_value, event) => {
|
|
1173
876
|
if (event) {
|
|
1174
877
|
const { key, shift } = event;
|
|
1175
878
|
const axis = [
|
|
@@ -1192,7 +895,7 @@ var GridSheet = () => {
|
|
|
1192
895
|
editing,
|
|
1193
896
|
dxGrid
|
|
1194
897
|
]);
|
|
1195
|
-
const handleBlur =
|
|
898
|
+
const handleBlur = useCallback2((value) => {
|
|
1196
899
|
if (value !== void 0) {
|
|
1197
900
|
model.setValue(parseCellIndex(editing.index), value);
|
|
1198
901
|
}
|
|
@@ -1200,8 +903,8 @@ var GridSheet = () => {
|
|
|
1200
903
|
model,
|
|
1201
904
|
editing
|
|
1202
905
|
]);
|
|
1203
|
-
const handleAxisResize =
|
|
1204
|
-
|
|
906
|
+
const handleAxisResize = useCallback2(({ axis, size, index: numericIndex }) => {
|
|
907
|
+
Obj2.update(model.sheet, (sheet) => {
|
|
1205
908
|
if (axis === "row") {
|
|
1206
909
|
const rowId = sheet.rows[parseInt(numericIndex)];
|
|
1207
910
|
sheet.rowMeta[rowId] ??= {};
|
|
@@ -1215,7 +918,7 @@ var GridSheet = () => {
|
|
|
1215
918
|
}, [
|
|
1216
919
|
model
|
|
1217
920
|
]);
|
|
1218
|
-
const handleSelect =
|
|
921
|
+
const handleSelect = useCallback2(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1219
922
|
const range = {
|
|
1220
923
|
from: {
|
|
1221
924
|
col: minCol,
|
|
@@ -1229,14 +932,14 @@ var GridSheet = () => {
|
|
|
1229
932
|
};
|
|
1230
933
|
}
|
|
1231
934
|
if (editing) {
|
|
1232
|
-
rangeController.current?.setRange(
|
|
935
|
+
rangeController.current?.setRange(rangeToA1Notation(range));
|
|
1233
936
|
} else {
|
|
1234
937
|
setRange(range.to ? range : void 0);
|
|
1235
938
|
}
|
|
1236
939
|
}, [
|
|
1237
940
|
editing
|
|
1238
941
|
]);
|
|
1239
|
-
const handleWheel =
|
|
942
|
+
const handleWheel = useCallback2((event) => {
|
|
1240
943
|
if (!ignoreAttention && !hasAttention) {
|
|
1241
944
|
event.stopPropagation();
|
|
1242
945
|
}
|
|
@@ -1244,7 +947,7 @@ var GridSheet = () => {
|
|
|
1244
947
|
hasAttention,
|
|
1245
948
|
ignoreAttention
|
|
1246
949
|
]);
|
|
1247
|
-
const selectEntireAxis =
|
|
950
|
+
const selectEntireAxis = useCallback2((pos) => {
|
|
1248
951
|
switch (pos.plane) {
|
|
1249
952
|
case "frozenRowsStart":
|
|
1250
953
|
return dxGrid?.setSelection({
|
|
@@ -1277,7 +980,7 @@ var GridSheet = () => {
|
|
|
1277
980
|
dxGrid,
|
|
1278
981
|
model.sheet
|
|
1279
982
|
]);
|
|
1280
|
-
const handleClick =
|
|
983
|
+
const handleClick = useCallback2((event) => {
|
|
1281
984
|
const cell = closestCell(event.target);
|
|
1282
985
|
if (cell) {
|
|
1283
986
|
selectEntireAxis(cell);
|
|
@@ -1285,7 +988,7 @@ var GridSheet = () => {
|
|
|
1285
988
|
}, [
|
|
1286
989
|
selectEntireAxis
|
|
1287
990
|
]);
|
|
1288
|
-
const handleKeyDown =
|
|
991
|
+
const handleKeyDown = useCallback2((event) => {
|
|
1289
992
|
switch (event.key) {
|
|
1290
993
|
case "Backspace":
|
|
1291
994
|
case "Delete":
|
|
@@ -1335,7 +1038,7 @@ var GridSheet = () => {
|
|
|
1335
1038
|
const contextMenuAnchorRef = useRef(null);
|
|
1336
1039
|
const [contextMenuOpen, setContextMenuOpen] = useState4(null);
|
|
1337
1040
|
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1338
|
-
const handleContextMenu =
|
|
1041
|
+
const handleContextMenu = useCallback2((event) => {
|
|
1339
1042
|
const cell = closestCell(event.target);
|
|
1340
1043
|
if (cell && cell.plane.startsWith("frozen")) {
|
|
1341
1044
|
event.preventDefault();
|
|
@@ -1343,7 +1046,7 @@ var GridSheet = () => {
|
|
|
1343
1046
|
setContextMenuOpen(cell);
|
|
1344
1047
|
}
|
|
1345
1048
|
}, []);
|
|
1346
|
-
const handleAxisMenuAction =
|
|
1049
|
+
const handleAxisMenuAction = useCallback2((operation) => {
|
|
1347
1050
|
switch (operation) {
|
|
1348
1051
|
case "insert-before":
|
|
1349
1052
|
case "insert-after":
|
|
@@ -1366,7 +1069,7 @@ var GridSheet = () => {
|
|
|
1366
1069
|
invokePromise
|
|
1367
1070
|
]);
|
|
1368
1071
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1369
|
-
const extensions =
|
|
1072
|
+
const extensions = useMemo(() => [
|
|
1370
1073
|
editorKeys({
|
|
1371
1074
|
onClose: handleClose,
|
|
1372
1075
|
...editing?.initialContent && {
|
|
@@ -1389,85 +1092,460 @@ var GridSheet = () => {
|
|
|
1389
1092
|
handleClose,
|
|
1390
1093
|
editing
|
|
1391
1094
|
]);
|
|
1392
|
-
const getCellContent =
|
|
1095
|
+
const getCellContent = useCallback2((index) => {
|
|
1393
1096
|
return model.getCellText(parseCellIndex(index));
|
|
1394
1097
|
}, [
|
|
1395
1098
|
model
|
|
1396
1099
|
]);
|
|
1397
|
-
|
|
1100
|
+
const [gridInstances] = useCapabilities(SheetCapabilities.GridInstances);
|
|
1101
|
+
useEffect3(() => {
|
|
1102
|
+
if (dxGrid && gridInstances) {
|
|
1103
|
+
gridInstances.register(attendableId, dxGrid, setActiveRefs);
|
|
1104
|
+
return () => gridInstances.unregister(attendableId);
|
|
1105
|
+
}
|
|
1106
|
+
}, [
|
|
1107
|
+
dxGrid,
|
|
1108
|
+
gridInstances,
|
|
1109
|
+
attendableId,
|
|
1110
|
+
setActiveRefs
|
|
1111
|
+
]);
|
|
1398
1112
|
useSelectThreadOnCellFocus();
|
|
1399
|
-
return (
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1113
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1114
|
+
ref: forwardedRef,
|
|
1115
|
+
...composableProps(props, {
|
|
1116
|
+
classNames: "relative min-h-0"
|
|
1117
|
+
})
|
|
1118
|
+
}, /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
1119
|
+
getCellContent,
|
|
1120
|
+
extensions,
|
|
1121
|
+
onBlur: handleBlur
|
|
1122
|
+
}), /* @__PURE__ */ React3.createElement(Grid2.Content, {
|
|
1123
|
+
className: "[--dx-grid-base:var(--base-surface)] [&_.dx-grid]:absolute [&_.dx-grid]:inset-0",
|
|
1124
|
+
initialCells,
|
|
1125
|
+
limitColumns: DEFAULT_COLS,
|
|
1126
|
+
limitRows: DEFAULT_ROWS,
|
|
1127
|
+
columns,
|
|
1128
|
+
rows,
|
|
1129
|
+
columnDefault: sheetColDefault,
|
|
1130
|
+
rowDefault: sheetRowDefault,
|
|
1131
|
+
activeRefs,
|
|
1132
|
+
frozen,
|
|
1133
|
+
overscroll: "trap",
|
|
1134
|
+
onAxisResize: handleAxisResize,
|
|
1135
|
+
onSelect: handleSelect,
|
|
1136
|
+
onFocus: handleFocus,
|
|
1137
|
+
onWheelCapture: handleWheel,
|
|
1138
|
+
onKeyDown: handleKeyDown,
|
|
1139
|
+
onContextMenu: handleContextMenu,
|
|
1140
|
+
onClick: handleClick,
|
|
1141
|
+
ref: setDxGrid
|
|
1142
|
+
}), /* @__PURE__ */ React3.createElement(DropdownMenu.Root, {
|
|
1143
|
+
modal: false,
|
|
1144
|
+
open: !!contextMenuOpen,
|
|
1145
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1146
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.VirtualTrigger, {
|
|
1147
|
+
virtualRef: contextMenuAnchorRef
|
|
1148
|
+
}), /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
|
|
1149
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1150
|
+
sideOffset: 4,
|
|
1151
|
+
collisionPadding: 8
|
|
1152
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
1153
|
+
onClick: () => handleAxisMenuAction("insert-before"),
|
|
1154
|
+
"data-testid": `grid.${contextMenuAxis}.insert-before`
|
|
1155
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
1156
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1157
|
+
}), /* @__PURE__ */ React3.createElement("span", null, t(`add-${contextMenuAxis}-before.label`))), /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
1158
|
+
onClick: () => handleAxisMenuAction("insert-after"),
|
|
1159
|
+
"data-testid": `grid.${contextMenuAxis}.insert-after`
|
|
1160
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
1161
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1162
|
+
}), /* @__PURE__ */ React3.createElement("span", null, t(`add-${contextMenuAxis}-after.label`))), /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
1163
|
+
onClick: () => handleAxisMenuAction("drop"),
|
|
1164
|
+
"data-testid": `grid.${contextMenuAxis}.drop`
|
|
1165
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
1166
|
+
icon: "ph--backspace--regular"
|
|
1167
|
+
}), /* @__PURE__ */ React3.createElement("span", null, t(`delete-${contextMenuAxis}.label`)))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
// src/components/SheetStatusbar/SheetStatusbar.tsx
|
|
1171
|
+
import React4 from "react";
|
|
1172
|
+
import { addressToA1Notation as addressToA1Notation2, isFormula as isFormula2, rangeToA1Notation as rangeToA1Notation2 } from "@dxos/compute-hyperformula";
|
|
1173
|
+
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
1174
|
+
import { composable as composable2, composableProps as composableProps2, mx as mx2 } from "@dxos/ui-theme";
|
|
1175
|
+
import { mapFormulaIndicesToRefs as mapFormulaIndicesToRefs2 } from "#types";
|
|
1176
|
+
var SheetStatusbar = composable2((props, forwardedRef) => {
|
|
1177
|
+
const { className, ...rest } = composableProps2(props);
|
|
1178
|
+
const { model, cursor, range } = useSheetContext();
|
|
1179
|
+
let value;
|
|
1180
|
+
let formula = false;
|
|
1181
|
+
if (cursor) {
|
|
1182
|
+
value = model.getCellValue(cursor);
|
|
1183
|
+
if (isFormula2(value)) {
|
|
1184
|
+
value = model.graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs2(model.sheet, value));
|
|
1185
|
+
formula = true;
|
|
1186
|
+
} else if (value != null) {
|
|
1187
|
+
value = String(value);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1191
|
+
ref: forwardedRef,
|
|
1192
|
+
...rest,
|
|
1193
|
+
className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm bg-toolbar-surface border-y !border-subdued-separator", className)
|
|
1194
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
1195
|
+
className: "flex gap-4 items-center"
|
|
1196
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
1197
|
+
className: "flex w-16 items-center font-mono"
|
|
1198
|
+
}, range && rangeToA1Notation2(range) || cursor && addressToA1Notation2(cursor)), /* @__PURE__ */ React4.createElement("div", {
|
|
1199
|
+
className: "flex gap-2 items-center"
|
|
1200
|
+
}, /* @__PURE__ */ React4.createElement(Icon2, {
|
|
1201
|
+
icon: "ph--function--regular",
|
|
1202
|
+
classNames: [
|
|
1203
|
+
"text-green-text",
|
|
1204
|
+
formula ? "visible" : "invisible"
|
|
1205
|
+
]
|
|
1206
|
+
}), /* @__PURE__ */ React4.createElement("span", {
|
|
1207
|
+
className: "font-mono"
|
|
1208
|
+
}, value))));
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
// src/components/SheetToolbar/SheetToolbar.tsx
|
|
1212
|
+
import { Atom as Atom2, RegistryContext as RegistryContext4 } from "@effect-atom/atom-react";
|
|
1213
|
+
import React5, { useContext as useContext6, useMemo as useMemo3 } from "react";
|
|
1214
|
+
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
1215
|
+
import { Menu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
|
|
1216
|
+
import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
|
|
1217
|
+
|
|
1218
|
+
// src/components/SheetToolbar/align.ts
|
|
1219
|
+
import { RegistryContext } from "@effect-atom/atom-react";
|
|
1220
|
+
import { useContext as useContext3, useEffect as useEffect4 } from "react";
|
|
1221
|
+
import { inRange as inRange2 } from "@dxos/compute-hyperformula";
|
|
1222
|
+
import { Obj as Obj3 } from "@dxos/echo";
|
|
1223
|
+
import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
|
|
1224
|
+
import { meta as meta2 } from "#meta";
|
|
1225
|
+
import { alignKey, rangeFromIndex as rangeFromIndex2, rangeToIndex } from "#types";
|
|
1226
|
+
var aligns = {
|
|
1227
|
+
start: "ph--text-align-left--regular",
|
|
1228
|
+
center: "ph--text-align-center--regular",
|
|
1229
|
+
end: "ph--text-align-right--regular"
|
|
1230
|
+
};
|
|
1231
|
+
var useAlignState = (stateAtom) => {
|
|
1232
|
+
const registry = useContext3(RegistryContext);
|
|
1233
|
+
const { cursor, model } = useSheetContext();
|
|
1234
|
+
useEffect4(() => {
|
|
1235
|
+
const alignValue = cursor ? model.sheet.ranges?.findLast(({ range, key }) => key === alignKey && inRange2(rangeFromIndex2(model.sheet, range), cursor))?.value : void 0;
|
|
1236
|
+
const prev = registry.get(stateAtom);
|
|
1237
|
+
registry.set(stateAtom, {
|
|
1238
|
+
...prev,
|
|
1239
|
+
[alignKey]: alignValue
|
|
1240
|
+
});
|
|
1241
|
+
}, [
|
|
1242
|
+
cursor,
|
|
1243
|
+
model.sheet,
|
|
1244
|
+
registry,
|
|
1245
|
+
stateAtom
|
|
1246
|
+
]);
|
|
1247
|
+
};
|
|
1248
|
+
var createAlignGroupAction = (value) => createMenuItemGroup("align", {
|
|
1249
|
+
label: [
|
|
1250
|
+
"align.label",
|
|
1251
|
+
{
|
|
1252
|
+
ns: meta2.id
|
|
1253
|
+
}
|
|
1254
|
+
],
|
|
1255
|
+
variant: "toggleGroup",
|
|
1256
|
+
selectCardinality: "single",
|
|
1257
|
+
value: `${alignKey}--${value}`
|
|
1258
|
+
});
|
|
1259
|
+
var createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackRange }) => Object.entries(aligns).map(([alignValue, icon]) => {
|
|
1260
|
+
return createMenuAction(`${alignKey}--${alignValue}`, () => {
|
|
1261
|
+
if (!cursorFallbackRange) {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
const index = model.sheet.ranges?.findIndex((range) => range.key === alignKey && inRange2(rangeFromIndex2(model.sheet, range.range), cursorFallbackRange.from)) ?? -1;
|
|
1265
|
+
const nextRangeEntity = {
|
|
1266
|
+
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
1267
|
+
key: alignKey,
|
|
1268
|
+
value: alignValue
|
|
1269
|
+
};
|
|
1270
|
+
const currentState = registry.get(stateAtom);
|
|
1271
|
+
if (index < 0) {
|
|
1272
|
+
Obj3.update(model.sheet, (obj) => {
|
|
1273
|
+
obj.ranges?.push(nextRangeEntity);
|
|
1274
|
+
});
|
|
1275
|
+
registry.set(stateAtom, {
|
|
1276
|
+
...currentState,
|
|
1277
|
+
[alignKey]: nextRangeEntity.value
|
|
1278
|
+
});
|
|
1279
|
+
} else if (model.sheet.ranges[index].value === nextRangeEntity.value) {
|
|
1280
|
+
Obj3.update(model.sheet, (obj) => {
|
|
1281
|
+
obj.ranges?.splice(index, 1);
|
|
1282
|
+
});
|
|
1283
|
+
registry.set(stateAtom, {
|
|
1284
|
+
...currentState,
|
|
1285
|
+
[alignKey]: void 0
|
|
1286
|
+
});
|
|
1287
|
+
} else {
|
|
1288
|
+
Obj3.update(model.sheet, (obj) => {
|
|
1289
|
+
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
1290
|
+
});
|
|
1291
|
+
registry.set(stateAtom, {
|
|
1292
|
+
...currentState,
|
|
1293
|
+
[alignKey]: nextRangeEntity.value
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
}, {
|
|
1297
|
+
key: alignKey,
|
|
1298
|
+
value: alignValue,
|
|
1299
|
+
checked: state[alignKey] === alignValue,
|
|
1300
|
+
label: [
|
|
1301
|
+
`range-value.${alignValue}.label`,
|
|
1302
|
+
{
|
|
1303
|
+
ns: meta2.id
|
|
1304
|
+
}
|
|
1305
|
+
],
|
|
1306
|
+
icon,
|
|
1307
|
+
testId: `grid.toolbar.${alignKey}.${alignValue}`
|
|
1308
|
+
});
|
|
1309
|
+
});
|
|
1310
|
+
var createAlign = (context) => {
|
|
1311
|
+
const alignGroup = createAlignGroupAction(context.state[alignKey]);
|
|
1312
|
+
const alignActions = createAlignActions(context);
|
|
1313
|
+
return {
|
|
1314
|
+
nodes: [
|
|
1315
|
+
alignGroup,
|
|
1316
|
+
...alignActions
|
|
1317
|
+
],
|
|
1318
|
+
edges: [
|
|
1319
|
+
{
|
|
1320
|
+
source: "root",
|
|
1321
|
+
target: "align",
|
|
1322
|
+
relation: "child"
|
|
1323
|
+
},
|
|
1324
|
+
...alignActions.map(({ id }) => ({
|
|
1325
|
+
source: alignGroup.id,
|
|
1326
|
+
target: id,
|
|
1327
|
+
relation: "child"
|
|
1328
|
+
}))
|
|
1329
|
+
]
|
|
1330
|
+
};
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// src/components/SheetToolbar/style.ts
|
|
1334
|
+
import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1335
|
+
import { useContext as useContext4, useEffect as useEffect5 } from "react";
|
|
1336
|
+
import { inRange as inRange3 } from "@dxos/compute-hyperformula";
|
|
1337
|
+
import { Obj as Obj4 } from "@dxos/echo";
|
|
1338
|
+
import { createMenuAction as createMenuAction2, createMenuItemGroup as createMenuItemGroup2 } from "@dxos/react-ui-menu";
|
|
1339
|
+
import { meta as meta3 } from "#meta";
|
|
1340
|
+
import { rangeFromIndex as rangeFromIndex3, rangeToIndex as rangeToIndex2 } from "#types";
|
|
1341
|
+
var styles = {
|
|
1342
|
+
highlight: "ph--highlighter--regular",
|
|
1343
|
+
softwrap: "ph--paragraph--regular"
|
|
1344
|
+
};
|
|
1345
|
+
var useStyleState = (stateAtom) => {
|
|
1346
|
+
const registry = useContext4(RegistryContext2);
|
|
1347
|
+
const { cursorFallbackRange, model } = useSheetContext();
|
|
1348
|
+
useEffect5(() => {
|
|
1349
|
+
let highlight = false;
|
|
1350
|
+
let softwrap = false;
|
|
1351
|
+
if (cursorFallbackRange && model.sheet.ranges) {
|
|
1352
|
+
model.sheet.ranges.filter(({ range, key }) => key === "style" && inRange3(rangeFromIndex3(model.sheet, range), cursorFallbackRange.from)).forEach(({ value }) => {
|
|
1353
|
+
if (value === "highlight") {
|
|
1354
|
+
highlight = true;
|
|
1355
|
+
}
|
|
1356
|
+
if (value === "softwrap") {
|
|
1357
|
+
softwrap = true;
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
const prev = registry.get(stateAtom);
|
|
1362
|
+
registry.set(stateAtom, {
|
|
1363
|
+
...prev,
|
|
1364
|
+
highlight,
|
|
1365
|
+
softwrap
|
|
1366
|
+
});
|
|
1367
|
+
}, [
|
|
1368
|
+
cursorFallbackRange,
|
|
1369
|
+
model.sheet,
|
|
1370
|
+
registry,
|
|
1371
|
+
stateAtom
|
|
1372
|
+
]);
|
|
1373
|
+
};
|
|
1374
|
+
var createStyleGroup = (state) => {
|
|
1375
|
+
return createMenuItemGroup2("style", {
|
|
1376
|
+
variant: "toggleGroup",
|
|
1377
|
+
selectCardinality: "multiple",
|
|
1378
|
+
value: Object.keys(styles).filter((key) => !!state[key]).map((styleValue) => `style--${styleValue}`)
|
|
1379
|
+
});
|
|
1380
|
+
};
|
|
1381
|
+
var createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackRange }) => Object.entries(styles).map(([styleValue, icon]) => {
|
|
1382
|
+
return createMenuAction2(`style--${styleValue}`, () => {
|
|
1383
|
+
if (!cursorFallbackRange) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
const index = model.sheet.ranges?.findIndex((range) => range.key === "style" && inRange3(rangeFromIndex3(model.sheet, range.range), cursorFallbackRange.from)) ?? -1;
|
|
1387
|
+
const nextRangeEntity = {
|
|
1388
|
+
range: rangeToIndex2(model.sheet, cursorFallbackRange),
|
|
1389
|
+
key: "style",
|
|
1390
|
+
value: styleValue
|
|
1391
|
+
};
|
|
1392
|
+
const currentState = registry.get(stateAtom);
|
|
1393
|
+
if (model.sheet.ranges.filter(({ range, key: rangeKey }) => rangeKey === "style" && inRange3(rangeFromIndex3(model.sheet, range), cursorFallbackRange.from)).some(({ value: rangeValue }) => rangeValue === styleValue)) {
|
|
1394
|
+
if (index >= 0) {
|
|
1395
|
+
Obj4.update(model.sheet, (obj) => {
|
|
1396
|
+
obj.ranges?.splice(index, 1);
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
registry.set(stateAtom, {
|
|
1400
|
+
...currentState,
|
|
1401
|
+
[nextRangeEntity.value]: false
|
|
1402
|
+
});
|
|
1403
|
+
} else {
|
|
1404
|
+
Obj4.update(model.sheet, (obj) => {
|
|
1405
|
+
obj.ranges?.push(nextRangeEntity);
|
|
1406
|
+
});
|
|
1407
|
+
registry.set(stateAtom, {
|
|
1408
|
+
...currentState,
|
|
1409
|
+
[nextRangeEntity.value]: true
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
}, {
|
|
1413
|
+
key: "style",
|
|
1414
|
+
value: styleValue,
|
|
1415
|
+
icon,
|
|
1416
|
+
label: [
|
|
1417
|
+
`range-value.${styleValue}.label`,
|
|
1418
|
+
{
|
|
1419
|
+
ns: meta3.id
|
|
1420
|
+
}
|
|
1421
|
+
],
|
|
1422
|
+
checked: !!state[styleValue]
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
var createStyle = (context) => {
|
|
1426
|
+
const styleGroupAction = createStyleGroup(context.state);
|
|
1427
|
+
const styleActions = createStyleActions(context);
|
|
1428
|
+
return {
|
|
1429
|
+
nodes: [
|
|
1430
|
+
styleGroupAction,
|
|
1431
|
+
...styleActions
|
|
1432
|
+
],
|
|
1433
|
+
edges: [
|
|
1434
|
+
{
|
|
1435
|
+
source: "root",
|
|
1436
|
+
target: "style",
|
|
1437
|
+
relation: "child"
|
|
1438
|
+
},
|
|
1439
|
+
...styleActions.map(({ id }) => ({
|
|
1440
|
+
source: styleGroupAction.id,
|
|
1441
|
+
target: id,
|
|
1442
|
+
relation: "child"
|
|
1443
|
+
}))
|
|
1444
|
+
]
|
|
1445
|
+
};
|
|
1459
1446
|
};
|
|
1460
1447
|
|
|
1461
|
-
// src/components/
|
|
1462
|
-
|
|
1448
|
+
// src/components/SheetToolbar/useToolbarState.ts
|
|
1449
|
+
import { Atom, RegistryContext as RegistryContext3, useAtomValue } from "@effect-atom/atom-react";
|
|
1450
|
+
import { useContext as useContext5, useMemo as useMemo2 } from "react";
|
|
1451
|
+
var useToolbarState = (initialState = {}) => {
|
|
1452
|
+
return useMemo2(() => Atom.make(initialState).pipe(Atom.keepAlive), []);
|
|
1453
|
+
};
|
|
1463
1454
|
|
|
1455
|
+
// src/components/SheetToolbar/SheetToolbar.tsx
|
|
1456
|
+
var createToolbarActions = ({ model, stateAtom, registry, cursorFallbackRange, customActions }) => {
|
|
1457
|
+
return Atom2.make((get) => {
|
|
1458
|
+
const state = get(stateAtom);
|
|
1459
|
+
const context = {
|
|
1460
|
+
model,
|
|
1461
|
+
state,
|
|
1462
|
+
stateAtom,
|
|
1463
|
+
registry,
|
|
1464
|
+
cursorFallbackRange
|
|
1465
|
+
};
|
|
1466
|
+
const align = createAlign(context);
|
|
1467
|
+
const style = createStyle(context);
|
|
1468
|
+
const gap = createGapSeparator();
|
|
1469
|
+
const graph = {
|
|
1470
|
+
nodes: [
|
|
1471
|
+
...align.nodes,
|
|
1472
|
+
...style.nodes,
|
|
1473
|
+
...gap.nodes
|
|
1474
|
+
],
|
|
1475
|
+
edges: [
|
|
1476
|
+
...align.edges,
|
|
1477
|
+
...style.edges,
|
|
1478
|
+
...gap.edges
|
|
1479
|
+
]
|
|
1480
|
+
};
|
|
1481
|
+
if (customActions) {
|
|
1482
|
+
const custom = get(customActions);
|
|
1483
|
+
graph.nodes.push(...custom.nodes);
|
|
1484
|
+
graph.edges.push(...custom.edges);
|
|
1485
|
+
}
|
|
1486
|
+
return graph;
|
|
1487
|
+
});
|
|
1488
|
+
};
|
|
1489
|
+
var SheetToolbar = composable3((props, forwardedRef) => {
|
|
1490
|
+
const { attendableId, model, cursorFallbackRange } = useSheetContext();
|
|
1491
|
+
const stateAtom = useToolbarState({});
|
|
1492
|
+
const registry = useContext6(RegistryContext4);
|
|
1493
|
+
useAlignState(stateAtom);
|
|
1494
|
+
useStyleState(stateAtom);
|
|
1495
|
+
const { graph } = useAppGraph();
|
|
1496
|
+
const customActions = useMemo3(() => {
|
|
1497
|
+
return Atom2.make((get) => {
|
|
1498
|
+
const actions = get(graph.actions(attendableId));
|
|
1499
|
+
const nodes = actions.filter((action) => action.properties.disposition === "toolbar");
|
|
1500
|
+
return {
|
|
1501
|
+
nodes,
|
|
1502
|
+
edges: nodes.map((node) => ({
|
|
1503
|
+
source: "root",
|
|
1504
|
+
target: node.id,
|
|
1505
|
+
relation: "child"
|
|
1506
|
+
}))
|
|
1507
|
+
};
|
|
1508
|
+
});
|
|
1509
|
+
}, [
|
|
1510
|
+
graph,
|
|
1511
|
+
attendableId
|
|
1512
|
+
]);
|
|
1513
|
+
const actionsCreator = useMemo3(() => createToolbarActions({
|
|
1514
|
+
model,
|
|
1515
|
+
stateAtom,
|
|
1516
|
+
registry,
|
|
1517
|
+
cursorFallbackRange,
|
|
1518
|
+
customActions
|
|
1519
|
+
}), [
|
|
1520
|
+
model,
|
|
1521
|
+
stateAtom,
|
|
1522
|
+
registry,
|
|
1523
|
+
cursorFallbackRange,
|
|
1524
|
+
customActions
|
|
1525
|
+
]);
|
|
1526
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
1527
|
+
return /* @__PURE__ */ React5.createElement(Menu.Root, {
|
|
1528
|
+
...menuActions,
|
|
1529
|
+
attendableId
|
|
1530
|
+
}, /* @__PURE__ */ React5.createElement(Menu.Toolbar, {
|
|
1531
|
+
...composableProps3(props),
|
|
1532
|
+
ref: forwardedRef
|
|
1533
|
+
}));
|
|
1534
|
+
});
|
|
1535
|
+
SheetToolbar.displayName = "SheetToolbar";
|
|
1536
|
+
|
|
1537
|
+
// src/components/Sheet/Sheet.tsx
|
|
1538
|
+
var Sheet = {
|
|
1539
|
+
Root: SheetRoot,
|
|
1540
|
+
Toolbar: SheetToolbar,
|
|
1541
|
+
Content: SheetContent,
|
|
1542
|
+
Statusbar: SheetStatusbar
|
|
1543
|
+
};
|
|
1464
1544
|
export {
|
|
1545
|
+
ComputeGraphContext,
|
|
1465
1546
|
ComputeGraphContextProvider,
|
|
1547
|
+
Sheet,
|
|
1466
1548
|
useComputeGraph,
|
|
1467
|
-
useSheetContext
|
|
1468
|
-
SheetProvider,
|
|
1469
|
-
GridSheet,
|
|
1470
|
-
RangeList,
|
|
1471
|
-
SheetContainer
|
|
1549
|
+
useSheetContext
|
|
1472
1550
|
};
|
|
1473
|
-
//# sourceMappingURL=
|
|
1551
|
+
//# sourceMappingURL=index.mjs.map
|