@dxos/plugin-sheet 0.8.4-main.72ec0f3 → 0.8.4-main.765dc60934
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/LICENSE +102 -5
- package/dist/lib/neutral/RangeList-HYB5S6KQ.mjs +46 -0
- package/dist/lib/neutral/RangeList-HYB5S6KQ.mjs.map +7 -0
- package/dist/lib/neutral/SheetArticle-5AJRM3V3.mjs +33 -0
- package/dist/lib/neutral/SheetArticle-5AJRM3V3.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/neutral/anchor-sort-TTCKGX7V.mjs +22 -0
- 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/{browser/chunk-7VEWYJJN.mjs → neutral/chunk-4SBAIU6F.mjs} +15 -15
- package/dist/lib/neutral/chunk-4SBAIU6F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FZWVUKE2.mjs +8 -0
- package/dist/lib/neutral/chunk-FZWVUKE2.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-KC2SMDNF.mjs +373 -0
- package/dist/lib/neutral/chunk-KC2SMDNF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YFY6U524.mjs +83 -0
- package/dist/lib/neutral/chunk-YFY6U524.mjs.map +7 -0
- package/dist/lib/{browser/chunk-FWFAAGXL.mjs → neutral/chunk-ZWOQCLH7.mjs} +2 -9
- 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/neutral/components/index.mjs +1551 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/compute-graph-registry-IEQBF5XZ.mjs +20 -0
- 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 -3
- package/dist/lib/neutral/insert-axis-ZFFNG22G.mjs +16 -0
- package/dist/lib/neutral/insert-axis-ZFFNG22G.mjs.map +7 -0
- package/dist/lib/neutral/markdown-I2AKJYPF.mjs +28 -0
- 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/neutral/react-surface-VSTQNVPT.mjs +44 -0
- package/dist/lib/neutral/react-surface-VSTQNVPT.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-QPOGMAQG.mjs +33 -0
- package/dist/lib/neutral/scroll-to-anchor-QPOGMAQG.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 -2
- 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 +3 -1
- 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 +4 -2
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -1
- 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 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +3 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +1 -1
- 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 -66
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +14 -21
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +14 -20
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -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/SheetArticle/SheetArticle.d.ts +12 -0
- package/dist/types/src/containers/SheetArticle/SheetArticle.d.ts.map +1 -0
- package/dist/types/src/containers/SheetArticle/SheetArticle.stories.d.ts +92 -0
- package/dist/types/src/containers/SheetArticle/SheetArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SheetArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SheetArticle/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/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +4 -4
- 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 +17 -17
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +74 -38
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +41 -35
- 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 -1
- 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 +2 -68
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +3 -2
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +130 -81
- package/src/SheetPlugin.node.ts +21 -0
- package/src/SheetPlugin.test.ts +30 -0
- package/src/SheetPlugin.tsx +37 -68
- package/src/capabilities/anchor-sort.ts +19 -13
- package/src/capabilities/comment-config.ts +24 -0
- package/src/capabilities/compute-graph-registry.ts +19 -13
- package/src/capabilities/create-object.ts +30 -0
- package/src/capabilities/index.ts +16 -8
- package/src/capabilities/markdown.ts +21 -13
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +38 -30
- 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 +25 -17
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +14 -10
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +21 -20
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +68 -50
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +8 -7
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +55 -42
- 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 +46 -39
- package/src/components/SheetToolbar/align.ts +50 -25
- package/src/components/SheetToolbar/style.ts +52 -22
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +23 -18
- package/src/containers/RangeList/index.ts +5 -0
- package/src/containers/SheetArticle/SheetArticle.stories.tsx +110 -0
- package/src/containers/SheetArticle/SheetArticle.tsx +57 -0
- package/src/containers/SheetArticle/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +31 -21
- package/src/extensions/compute.ts +2 -2
- package/src/extensions/editor/sheet-extension.test.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +18 -15
- package/src/index.ts +2 -2
- package/src/integrations/thread-ranges.ts +19 -56
- package/src/meta.ts +3 -3
- package/src/model/sheet-model.test.ts +5 -5
- package/src/model/sheet-model.ts +80 -48
- 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 +4 -3
- package/src/plugin.ts +11 -0
- package/src/sanity.test.ts +10 -3
- package/src/serializer.ts +3 -3
- package/src/testing/data.ts +1 -1
- package/src/testing/testing.tsx +4 -4
- package/src/translations.ts +41 -35
- package/src/types/Sheet.ts +32 -32
- package/src/types/SheetCapabilities.ts +26 -0
- package/src/types/SheetOperation.ts +75 -0
- package/src/types/index.ts +4 -1
- package/src/types/sheet-range-types.ts +3 -3
- package/src/types/types.ts +4 -40
- package/src/types/util.ts +3 -2
- package/dist/lib/browser/SheetContainer-66BNB3XG.mjs +0 -349
- package/dist/lib/browser/SheetContainer-66BNB3XG.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-FCQ5OZZK.mjs +0 -23
- package/dist/lib/browser/anchor-sort-FCQ5OZZK.mjs.map +0 -7
- package/dist/lib/browser/chunk-73AV3NH6.mjs +0 -15
- package/dist/lib/browser/chunk-73AV3NH6.mjs.map +0 -7
- package/dist/lib/browser/chunk-7VEWYJJN.mjs.map +0 -7
- package/dist/lib/browser/chunk-DVJ3QW3F.mjs +0 -907
- package/dist/lib/browser/chunk-DVJ3QW3F.mjs.map +0 -7
- package/dist/lib/browser/chunk-FWFAAGXL.mjs.map +0 -7
- package/dist/lib/browser/chunk-OU5KTWY3.mjs +0 -852
- package/dist/lib/browser/chunk-OU5KTWY3.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-AP5RA7W3.mjs +0 -21
- package/dist/lib/browser/compute-graph-registry-AP5RA7W3.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -154
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-66OAYVQF.mjs +0 -56
- package/dist/lib/browser/intent-resolver-66OAYVQF.mjs.map +0 -7
- package/dist/lib/browser/markdown-B6VKYY2S.mjs +0 -26
- package/dist/lib/browser/markdown-B6VKYY2S.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-5GYLVSMR.mjs +0 -54
- package/dist/lib/browser/react-surface-5GYLVSMR.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-NWEQETAY.mjs +0 -350
- package/dist/lib/node-esm/SheetContainer-NWEQETAY.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-ZE7IS7SH.mjs +0 -24
- package/dist/lib/node-esm/anchor-sort-ZE7IS7SH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-44YTKTMP.mjs +0 -16
- package/dist/lib/node-esm/chunk-44YTKTMP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4H2EHVWE.mjs +0 -908
- package/dist/lib/node-esm/chunk-4H2EHVWE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4MT3JJU2.mjs +0 -853
- package/dist/lib/node-esm/chunk-4MT3JJU2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4QV4AGWK.mjs +0 -236
- package/dist/lib/node-esm/chunk-4QV4AGWK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HILDMVPL.mjs +0 -29
- package/dist/lib/node-esm/chunk-HILDMVPL.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-UMQ5UYCL.mjs +0 -22
- package/dist/lib/node-esm/compute-graph-registry-UMQ5UYCL.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -155
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-VNKIMQQT.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-VNKIMQQT.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-VKY7HXU2.mjs +0 -27
- package/dist/lib/node-esm/markdown-VKY7HXU2.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-RK32YZWR.mjs +0 -55
- package/dist/lib/node-esm/react-surface-RK32YZWR.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.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 -54
- 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 -11
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -55
- 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/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -93
- package/src/components/SheetContainer/SheetContainer.tsx +0 -41
- package/src/components/SheetContainer/index.ts +0 -7
- package/src/components/SheetContext/index.ts +0 -5
- /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
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { inRange } from '@dxos/compute';
|
|
8
|
-
import { createDocAccessor } from '@dxos/
|
|
7
|
+
import { inRange } from '@dxos/compute-hyperformula';
|
|
8
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
9
|
import { cellClassesForFieldType, parseValue } from '@dxos/react-ui-form';
|
|
10
10
|
import {
|
|
11
11
|
type DxGridAxisMeta,
|
|
@@ -19,10 +19,11 @@ import {
|
|
|
19
19
|
commentedClassName,
|
|
20
20
|
rowToA1Notation,
|
|
21
21
|
} from '@dxos/react-ui-grid';
|
|
22
|
-
import { mx } from '@dxos/
|
|
22
|
+
import { mx } from '@dxos/ui-theme';
|
|
23
|
+
|
|
24
|
+
import { cellClassNameForRange, rangeFromIndex } from '#types';
|
|
23
25
|
|
|
24
26
|
import { type SheetModel } from '../../model';
|
|
25
|
-
import { cellClassNameForRange, rangeFromIndex } from '../../types';
|
|
26
27
|
|
|
27
28
|
const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
|
|
28
29
|
return model.sheet.columns.reduce(
|
|
@@ -96,13 +97,13 @@ const gridCellGetter = (model: SheetModel) => {
|
|
|
96
97
|
|
|
97
98
|
export const rowLabelCell = (row: number) => ({
|
|
98
99
|
value: rowToA1Notation(row),
|
|
99
|
-
className: '!bg-
|
|
100
|
+
className: '!bg-toolbar-surface text-subdued text-end pe-1',
|
|
100
101
|
resizeHandle: 'row',
|
|
101
102
|
});
|
|
102
103
|
|
|
103
104
|
export const colLabelCell = (col: number) => ({
|
|
104
105
|
value: colToA1Notation(col),
|
|
105
|
-
className: '!bg-
|
|
106
|
+
className: '!bg-toolbar-surface text-subdued',
|
|
106
107
|
resizeHandle: 'col',
|
|
107
108
|
});
|
|
108
109
|
|
|
@@ -114,7 +115,7 @@ const cellGetter = (model: SheetModel) => {
|
|
|
114
115
|
return getGridCells(nextBounds);
|
|
115
116
|
case 'fixedStartStart': {
|
|
116
117
|
return {
|
|
117
|
-
'0,0': { className: '!bg-
|
|
118
|
+
'0,0': { className: '!bg-toolbar-surface' },
|
|
118
119
|
};
|
|
119
120
|
}
|
|
120
121
|
case 'frozenColsStart':
|
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import {
|
|
8
|
+
type CellAddress,
|
|
9
|
+
type CellRange,
|
|
10
|
+
type CompleteCellRange,
|
|
11
|
+
type ComputeGraph,
|
|
12
|
+
} from '@dxos/compute-hyperformula';
|
|
13
|
+
import { raise } from '@dxos/debug';
|
|
10
14
|
import {
|
|
11
15
|
Grid,
|
|
12
16
|
type GridContentProps,
|
|
@@ -15,12 +19,13 @@ import {
|
|
|
15
19
|
useGridContext,
|
|
16
20
|
} from '@dxos/react-ui-grid';
|
|
17
21
|
|
|
22
|
+
import { type Sheet } from '#types';
|
|
23
|
+
|
|
18
24
|
import { type SheetModel, useSheetModel } from '../../model';
|
|
19
|
-
import { type Sheet } from '../../types';
|
|
20
25
|
|
|
21
26
|
export type SheetContextValue = {
|
|
22
27
|
id: string;
|
|
23
|
-
|
|
28
|
+
attendableId: string;
|
|
24
29
|
model: SheetModel;
|
|
25
30
|
|
|
26
31
|
// Cursor state.
|
|
@@ -39,29 +44,62 @@ export type SheetContextValue = {
|
|
|
39
44
|
activeRefs: GridContentProps['activeRefs'];
|
|
40
45
|
setActiveRefs: (activeRefs: GridContentProps['activeRefs']) => void;
|
|
41
46
|
|
|
47
|
+
// Flags
|
|
48
|
+
ignoreAttention?: boolean;
|
|
49
|
+
|
|
42
50
|
// Events.
|
|
43
51
|
// TODO(burdon): Generalize.
|
|
44
52
|
onInfo?: () => void;
|
|
45
|
-
|
|
46
|
-
// Flags
|
|
47
|
-
ignoreAttention?: boolean;
|
|
48
53
|
};
|
|
49
54
|
|
|
55
|
+
// TODO(burdon): Use radix context.
|
|
50
56
|
const SheetContext = createContext<SheetContextValue | undefined>(undefined);
|
|
51
57
|
|
|
52
58
|
export const useSheetContext = (): SheetContextValue => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
return useContext(SheetContext) ?? raise(new Error('Missing SheetContext'));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type SheetRootProps = {
|
|
63
|
+
graph: ComputeGraph;
|
|
64
|
+
sheet: Sheet.Sheet;
|
|
65
|
+
attendableId: string;
|
|
66
|
+
readonly?: boolean;
|
|
67
|
+
ignoreAttention?: boolean;
|
|
68
|
+
} & Pick<SheetContextValue, 'onInfo'>;
|
|
69
|
+
|
|
70
|
+
export const SheetRoot = ({
|
|
71
|
+
children,
|
|
72
|
+
graph,
|
|
73
|
+
sheet,
|
|
74
|
+
attendableId,
|
|
75
|
+
readonly,
|
|
76
|
+
ignoreAttention,
|
|
77
|
+
onInfo,
|
|
78
|
+
}: PropsWithChildren<SheetRootProps>) => {
|
|
79
|
+
const model = useSheetModel(graph, sheet, { readonly });
|
|
80
|
+
if (!model) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Grid.Root id={attendableId}>
|
|
86
|
+
<SheetProviderImpl model={model} attendableId={attendableId} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
87
|
+
{children}
|
|
88
|
+
</SheetProviderImpl>
|
|
89
|
+
</Grid.Root>
|
|
90
|
+
);
|
|
56
91
|
};
|
|
57
92
|
|
|
58
93
|
const SheetProviderImpl = ({
|
|
94
|
+
__gridScope,
|
|
95
|
+
children,
|
|
96
|
+
attendableId,
|
|
97
|
+
ignoreAttention,
|
|
59
98
|
model,
|
|
60
99
|
onInfo,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model' | 'ignoreAttention'>>>) => {
|
|
100
|
+
}: GridScopedProps<
|
|
101
|
+
PropsWithChildren<Pick<SheetContextValue, 'attendableId' | 'ignoreAttention' | 'model' | 'onInfo'>>
|
|
102
|
+
>) => {
|
|
65
103
|
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
66
104
|
|
|
67
105
|
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
@@ -92,6 +130,7 @@ const SheetProviderImpl = ({
|
|
|
92
130
|
<SheetContext.Provider
|
|
93
131
|
value={{
|
|
94
132
|
id,
|
|
133
|
+
attendableId,
|
|
95
134
|
model,
|
|
96
135
|
editing,
|
|
97
136
|
setEditing,
|
|
@@ -102,38 +141,12 @@ const SheetProviderImpl = ({
|
|
|
102
141
|
cursorFallbackRange,
|
|
103
142
|
activeRefs,
|
|
104
143
|
setActiveRefs,
|
|
144
|
+
ignoreAttention,
|
|
105
145
|
// TODO(burdon): Change to event.
|
|
106
146
|
onInfo,
|
|
107
|
-
ignoreAttention,
|
|
108
147
|
}}
|
|
109
148
|
>
|
|
110
149
|
{children}
|
|
111
150
|
</SheetContext.Provider>
|
|
112
151
|
);
|
|
113
152
|
};
|
|
114
|
-
|
|
115
|
-
export type SheetProviderProps = {
|
|
116
|
-
graph: ComputeGraph;
|
|
117
|
-
sheet: Sheet.Sheet;
|
|
118
|
-
readonly?: boolean;
|
|
119
|
-
ignoreAttention?: boolean;
|
|
120
|
-
} & Pick<SheetContextValue, 'onInfo'>;
|
|
121
|
-
|
|
122
|
-
export const SheetProvider = ({
|
|
123
|
-
children,
|
|
124
|
-
graph,
|
|
125
|
-
sheet,
|
|
126
|
-
readonly,
|
|
127
|
-
ignoreAttention,
|
|
128
|
-
onInfo,
|
|
129
|
-
}: PropsWithChildren<SheetProviderProps>) => {
|
|
130
|
-
const model = useSheetModel(graph, sheet, { readonly });
|
|
131
|
-
|
|
132
|
-
return !model ? null : (
|
|
133
|
-
<Grid.Root id={Obj.getDXN(sheet).toString()}>
|
|
134
|
-
<SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
135
|
-
{children}
|
|
136
|
-
</SheetProviderImpl>
|
|
137
|
-
</Grid.Root>
|
|
138
|
-
);
|
|
139
|
-
};
|
package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx}
RENAMED
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute';
|
|
7
|
+
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute-hyperformula';
|
|
8
8
|
import { Icon } from '@dxos/react-ui';
|
|
9
|
+
import { composable, composableProps, mx } from '@dxos/ui-theme';
|
|
9
10
|
|
|
10
|
-
import { mapFormulaIndicesToRefs } from '
|
|
11
|
-
import { useSheetContext } from '../SheetContext';
|
|
11
|
+
import { mapFormulaIndicesToRefs } from '#types';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import { useSheetContext } from '../SheetRoot';
|
|
14
|
+
|
|
15
|
+
export type SheetStatusbarProps = {};
|
|
16
|
+
|
|
17
|
+
export const SheetStatusbar = composable<HTMLDivElement, SheetStatusbarProps>((props, forwardedRef) => {
|
|
18
|
+
const { className, ...rest } = composableProps(props);
|
|
14
19
|
const { model, cursor, range } = useSheetContext();
|
|
15
20
|
|
|
16
21
|
let value;
|
|
@@ -26,16 +31,23 @@ export const FunctionEditor = () => {
|
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
return (
|
|
29
|
-
<div
|
|
34
|
+
<div
|
|
35
|
+
ref={forwardedRef}
|
|
36
|
+
{...rest}
|
|
37
|
+
className={mx(
|
|
38
|
+
'flex shrink-0 justify-between items-center px-4 py-1 text-sm bg-toolbar-surface border-y !border-subdued-separator',
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
30
42
|
<div className='flex gap-4 items-center'>
|
|
31
|
-
<div className='flex
|
|
43
|
+
<div className='flex w-16 items-center font-mono'>
|
|
32
44
|
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
33
45
|
</div>
|
|
34
46
|
<div className='flex gap-2 items-center'>
|
|
35
|
-
<Icon icon='ph--function--regular' classNames={['text-
|
|
47
|
+
<Icon icon='ph--function--regular' classNames={['text-green-text', formula ? 'visible' : 'invisible']} />
|
|
36
48
|
<span className='font-mono'>{value}</span>
|
|
37
49
|
</div>
|
|
38
50
|
</div>
|
|
39
51
|
</div>
|
|
40
52
|
);
|
|
41
|
-
};
|
|
53
|
+
});
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
8
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
9
9
|
|
|
10
|
-
import { translations } from '
|
|
10
|
+
import { translations } from '#translations';
|
|
11
11
|
|
|
12
12
|
import { SheetToolbar } from './SheetToolbar';
|
|
13
13
|
|
|
14
14
|
const DefaultStory = () => {
|
|
15
|
-
// TODO(wittjosiah): Depends on
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetRoot.
|
|
16
16
|
// return <SheetToolbar id='test' />;
|
|
17
17
|
return <>TODO</>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const meta = {
|
|
21
|
-
title: 'plugins/plugin-sheet/Toolbar',
|
|
21
|
+
title: 'plugins/plugin-sheet/components/Toolbar',
|
|
22
22
|
component: SheetToolbar as any,
|
|
23
23
|
render: DefaultStory,
|
|
24
|
-
decorators: [withTheme],
|
|
24
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
25
25
|
parameters: {
|
|
26
26
|
layout: 'fullscreen',
|
|
27
27
|
translations,
|
|
@@ -2,36 +2,40 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
-
import React, {
|
|
5
|
+
import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useAppGraph } from '@dxos/app-
|
|
9
|
-
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
MenuProvider,
|
|
13
|
-
ToolbarMenu,
|
|
14
|
-
atomFromSignal,
|
|
15
|
-
createGapSeparator,
|
|
16
|
-
useMenuActions,
|
|
17
|
-
} from '@dxos/react-ui-menu';
|
|
8
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { type CompleteCellRange } from '@dxos/compute-hyperformula';
|
|
10
|
+
import { type ActionGraphProps, Menu, createGapSeparator, useMenuActions } from '@dxos/react-ui-menu';
|
|
11
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
18
12
|
|
|
19
13
|
import { type SheetModel } from '../../model';
|
|
20
|
-
import { useSheetContext } from '../
|
|
21
|
-
|
|
14
|
+
import { useSheetContext } from '../SheetRoot';
|
|
22
15
|
import { createAlign, useAlignState } from './align';
|
|
23
16
|
import { createStyle, useStyleState } from './style';
|
|
24
|
-
import { type
|
|
17
|
+
import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
|
|
18
|
+
|
|
19
|
+
type ToolbarActionsContext = {
|
|
20
|
+
model: SheetModel;
|
|
21
|
+
stateAtom: ToolbarStateAtom;
|
|
22
|
+
registry: Registry.Registry;
|
|
23
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
24
|
+
customActions?: Atom.Atom<ActionGraphProps>;
|
|
25
|
+
};
|
|
25
26
|
|
|
26
|
-
const createToolbarActions = (
|
|
27
|
-
model
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const createToolbarActions = ({
|
|
28
|
+
model,
|
|
29
|
+
stateAtom,
|
|
30
|
+
registry,
|
|
31
|
+
cursorFallbackRange,
|
|
32
|
+
customActions,
|
|
33
|
+
}: ToolbarActionsContext): Atom.Atom<ActionGraphProps> => {
|
|
32
34
|
return Atom.make((get) => {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
+
const state = get(stateAtom);
|
|
36
|
+
const context = { model, state, stateAtom, registry, cursorFallbackRange };
|
|
37
|
+
const align = createAlign(context);
|
|
38
|
+
const style = createStyle(context);
|
|
35
39
|
const gap = createGapSeparator();
|
|
36
40
|
|
|
37
41
|
const graph: ActionGraphProps = {
|
|
@@ -49,35 +53,38 @@ const createToolbarActions = (
|
|
|
49
53
|
});
|
|
50
54
|
};
|
|
51
55
|
|
|
52
|
-
export type SheetToolbarProps =
|
|
56
|
+
export type SheetToolbarProps = {};
|
|
53
57
|
|
|
54
|
-
export const SheetToolbar = (
|
|
55
|
-
const { model, cursorFallbackRange } = useSheetContext();
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
export const SheetToolbar = composable<HTMLDivElement, SheetToolbarProps>((props, forwardedRef) => {
|
|
59
|
+
const { attendableId, model, cursorFallbackRange } = useSheetContext();
|
|
60
|
+
const stateAtom = useToolbarState({});
|
|
61
|
+
const registry = useContext(RegistryContext);
|
|
62
|
+
useAlignState(stateAtom);
|
|
63
|
+
useStyleState(stateAtom);
|
|
59
64
|
|
|
60
65
|
const { graph } = useAppGraph();
|
|
61
66
|
const customActions = useMemo(() => {
|
|
62
67
|
return Atom.make((get) => {
|
|
63
|
-
const actions = get(graph.actions(
|
|
68
|
+
const actions = get(graph.actions(attendableId));
|
|
64
69
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
65
70
|
return {
|
|
66
71
|
nodes,
|
|
67
|
-
edges: nodes.map((node) => ({ source: 'root', target: node.id })),
|
|
72
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id, relation: 'child' })),
|
|
68
73
|
};
|
|
69
74
|
});
|
|
70
|
-
}, [graph]);
|
|
75
|
+
}, [graph, attendableId]);
|
|
71
76
|
|
|
72
77
|
const actionsCreator = useMemo(
|
|
73
|
-
() => createToolbarActions(model,
|
|
74
|
-
[model,
|
|
78
|
+
() => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
|
|
79
|
+
[model, stateAtom, registry, cursorFallbackRange, customActions],
|
|
75
80
|
);
|
|
76
|
-
const
|
|
81
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
77
82
|
|
|
78
83
|
return (
|
|
79
|
-
<
|
|
80
|
-
<
|
|
81
|
-
</
|
|
84
|
+
<Menu.Root {...menuActions} attendableId={attendableId}>
|
|
85
|
+
<Menu.Toolbar {...composableProps(props)} ref={forwardedRef} />
|
|
86
|
+
</Menu.Root>
|
|
82
87
|
);
|
|
83
|
-
};
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
SheetToolbar.displayName = 'SheetToolbar';
|
|
@@ -2,17 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useEffect } from 'react';
|
|
6
7
|
|
|
7
|
-
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import {
|
|
8
|
+
import { type CompleteCellRange, inRange } from '@dxos/compute-hyperformula';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import {
|
|
11
|
+
type ActionGraphProps,
|
|
12
|
+
type ToolbarMenuActionGroupProperties,
|
|
13
|
+
createMenuAction,
|
|
14
|
+
createMenuItemGroup,
|
|
15
|
+
} from '@dxos/react-ui-menu';
|
|
9
16
|
|
|
10
|
-
import { meta } from '
|
|
11
|
-
import { type
|
|
12
|
-
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
|
-
import { useSheetContext } from '../SheetContext';
|
|
17
|
+
import { meta } from '#meta';
|
|
18
|
+
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '#types';
|
|
14
19
|
|
|
15
|
-
import { type
|
|
20
|
+
import { type SheetModel } from '../../model';
|
|
21
|
+
import { useSheetContext } from '../SheetRoot';
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
16
23
|
|
|
17
24
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
18
25
|
|
|
@@ -24,29 +31,40 @@ const aligns: Record<AlignValue, string> = {
|
|
|
24
31
|
end: 'ph--text-align-right--regular',
|
|
25
32
|
};
|
|
26
33
|
|
|
27
|
-
export const useAlignState = (
|
|
34
|
+
export const useAlignState = (stateAtom: ToolbarStateAtom) => {
|
|
35
|
+
const registry = useContext(RegistryContext);
|
|
28
36
|
const { cursor, model } = useSheetContext();
|
|
29
37
|
useEffect(() => {
|
|
30
38
|
// TODO(thure): Can this O(n) call be memoized?
|
|
31
|
-
|
|
39
|
+
const alignValue = (
|
|
32
40
|
cursor
|
|
33
41
|
? model.sheet.ranges?.findLast(
|
|
34
42
|
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
35
43
|
)?.value
|
|
36
44
|
: undefined
|
|
37
45
|
) as AlignValue | undefined;
|
|
38
|
-
|
|
46
|
+
const prev = registry.get(stateAtom);
|
|
47
|
+
registry.set(stateAtom, { ...prev, [alignKey]: alignValue });
|
|
48
|
+
}, [cursor, model.sheet, registry, stateAtom]);
|
|
39
49
|
};
|
|
40
50
|
|
|
41
51
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
42
52
|
createMenuItemGroup('align', {
|
|
43
|
-
label: ['align
|
|
53
|
+
label: ['align.label', { ns: meta.id }],
|
|
44
54
|
variant: 'toggleGroup',
|
|
45
55
|
selectCardinality: 'single',
|
|
46
56
|
value: `${alignKey}--${value}`,
|
|
47
57
|
} as ToolbarMenuActionGroupProperties);
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
type AlignActionsContext = {
|
|
60
|
+
model: SheetModel;
|
|
61
|
+
state: ToolbarState;
|
|
62
|
+
stateAtom: ToolbarStateAtom;
|
|
63
|
+
registry: Registry.Registry;
|
|
64
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: AlignActionsContext) =>
|
|
50
68
|
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
51
69
|
return createMenuAction<AlignAction>(
|
|
52
70
|
`${alignKey}--${alignValue}`,
|
|
@@ -64,36 +82,43 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
64
82
|
key: alignKey,
|
|
65
83
|
value: alignValue as AlignValue,
|
|
66
84
|
};
|
|
85
|
+
const currentState = registry.get(stateAtom);
|
|
67
86
|
if (index < 0) {
|
|
68
|
-
model.sheet
|
|
69
|
-
|
|
87
|
+
Obj.update(model.sheet, (obj) => {
|
|
88
|
+
obj.ranges?.push(nextRangeEntity);
|
|
89
|
+
});
|
|
90
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
70
91
|
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
71
|
-
model.sheet
|
|
72
|
-
|
|
92
|
+
Obj.update(model.sheet, (obj) => {
|
|
93
|
+
obj.ranges?.splice(index, 1);
|
|
94
|
+
});
|
|
95
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
73
96
|
} else {
|
|
74
|
-
model.sheet
|
|
75
|
-
|
|
97
|
+
Obj.update(model.sheet, (obj) => {
|
|
98
|
+
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
|
+
});
|
|
100
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
76
101
|
}
|
|
77
102
|
},
|
|
78
103
|
{
|
|
79
104
|
key: alignKey,
|
|
80
105
|
value: alignValue as AlignValue,
|
|
81
106
|
checked: state[alignKey] === alignValue,
|
|
82
|
-
label: [`range
|
|
107
|
+
label: [`range-value.${alignValue}.label`, { ns: meta.id }],
|
|
83
108
|
icon,
|
|
84
109
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
85
110
|
},
|
|
86
111
|
);
|
|
87
112
|
});
|
|
88
113
|
|
|
89
|
-
export const createAlign = (
|
|
90
|
-
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
91
|
-
const alignActions = createAlignActions(
|
|
114
|
+
export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
|
|
115
|
+
const alignGroup = createAlignGroupAction(context.state[alignKey]);
|
|
116
|
+
const alignActions = createAlignActions(context);
|
|
92
117
|
return {
|
|
93
118
|
nodes: [alignGroup, ...alignActions],
|
|
94
119
|
edges: [
|
|
95
|
-
{ source: 'root', target: 'align' },
|
|
96
|
-
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id })),
|
|
120
|
+
{ source: 'root', target: 'align', relation: 'child' },
|
|
121
|
+
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id, relation: 'child' })),
|
|
97
122
|
],
|
|
98
123
|
};
|
|
99
124
|
};
|