@dxos/plugin-sheet 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/RangeList-S3SHV7T6.mjs +53 -0
- package/dist/lib/browser/RangeList-S3SHV7T6.mjs.map +7 -0
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs +1805 -0
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs +24 -0
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7HQX4NQP.mjs → chunk-NNWF7EKC.mjs} +14 -14
- package/dist/lib/browser/chunk-NNWF7EKC.mjs.map +7 -0
- package/dist/lib/browser/chunk-S445OQGW.mjs +397 -0
- package/dist/lib/browser/chunk-S445OQGW.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +72 -82
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-S6GVLHB4.mjs +29 -0
- package/dist/lib/browser/markdown-S6GVLHB4.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs +79 -0
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs.map +7 -0
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs +51 -0
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs +54 -0
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs.map +7 -0
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs +1806 -0
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Q6UYC4G5.mjs → chunk-M52YLLWU.mjs} +14 -14
- package/dist/lib/node-esm/chunk-M52YLLWU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs +398 -0
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +72 -82
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs +30 -0
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs +52 -0
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -12
- package/dist/types/src/SheetPlugin.d.ts +2 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -11
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +11 -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 +16 -0
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +5 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts +55 -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} +7 -7
- 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 +5 -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 +6 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +88 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +13 -20
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
- 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/{components → containers}/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/containers/RangeList/index.d.ts +3 -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 +56 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/index.d.ts.map +1 -1
- 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 +10 -13
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/index.d.ts +1 -1
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -6
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +2 -2
- 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/playwright/sheet-manager.d.ts +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -1
- 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 +2 -2
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +27 -3
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +76 -0
- package/dist/types/src/types/Sheet.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +6 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +2 -2
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +92 -75
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +10 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +81 -72
- package/src/SheetPlugin.tsx +52 -64
- package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
- package/src/capabilities/compute-graph-registry/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +30 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +46 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +22 -21
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/SheetContent/SheetCellEditor.stories.tsx +94 -0
- package/src/components/SheetContent/SheetContent.stories.tsx +60 -0
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +74 -60
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +20 -14
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +43 -41
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +10 -5
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +20 -14
- package/src/components/SheetToolbar/SheetToolbar.tsx +57 -46
- package/src/components/SheetToolbar/align.ts +49 -23
- package/src/components/SheetToolbar/style.ts +51 -21
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +20 -15
- package/src/containers/RangeList/index.ts +7 -0
- package/src/containers/SheetContainer/SheetContainer.stories.tsx +94 -0
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/{components → containers}/SheetContainer/index.ts +1 -1
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +46 -32
- package/src/extensions/compute.ts +3 -4
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
- package/src/extensions/editor/{extension.ts → sheet-extension.ts} +16 -13
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +39 -49
- package/src/meta.ts +9 -7
- package/src/model/sheet-model.test.ts +5 -4
- package/src/model/sheet-model.ts +85 -53
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet-manager.ts +1 -1
- package/src/playwright/sheet.spec.ts +3 -2
- package/src/sanity.test.ts +4 -5
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +11 -5
- package/src/translations.ts +3 -2
- package/src/types/Sheet.ts +97 -0
- package/src/types/capabilities.ts +14 -0
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +5 -5
- package/src/types/types.ts +84 -49
- package/src/types/util.ts +14 -41
- package/dist/lib/browser/SheetContainer-KDGD4AVG.mjs +0 -351
- package/dist/lib/browser/SheetContainer-KDGD4AVG.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-VHURGBOY.mjs +0 -24
- package/dist/lib/browser/anchor-sort-VHURGBOY.mjs.map +0 -7
- package/dist/lib/browser/chunk-6AKBCBL4.mjs +0 -18
- package/dist/lib/browser/chunk-6AKBCBL4.mjs.map +0 -7
- package/dist/lib/browser/chunk-7HQX4NQP.mjs.map +0 -7
- package/dist/lib/browser/chunk-JUOVL3LE.mjs +0 -847
- package/dist/lib/browser/chunk-JUOVL3LE.mjs.map +0 -7
- package/dist/lib/browser/chunk-KJWZUQVA.mjs +0 -15
- package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
- package/dist/lib/browser/chunk-SI4X5GUR.mjs +0 -892
- package/dist/lib/browser/chunk-SI4X5GUR.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-VG7VP7IV.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-VG7VP7IV.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-WOJGZMSV.mjs +0 -56
- package/dist/lib/browser/intent-resolver-WOJGZMSV.mjs.map +0 -7
- package/dist/lib/browser/markdown-VXMIPUQC.mjs +0 -26
- package/dist/lib/browser/markdown-VXMIPUQC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SE4HGAEH.mjs +0 -53
- package/dist/lib/browser/react-surface-SE4HGAEH.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-RMG24NZC.mjs +0 -352
- package/dist/lib/node-esm/SheetContainer-RMG24NZC.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-CTJGOPET.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-CTJGOPET.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs +0 -20
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs +0 -16
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CADTJFAS.mjs +0 -893
- package/dist/lib/node-esm/chunk-CADTJFAS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IFMIRCZH.mjs +0 -848
- package/dist/lib/node-esm/chunk-IFMIRCZH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q6UYC4G5.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-3K3Q2A5T.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-3K3Q2A5T.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-PZRXBNIJ.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-PZRXBNIJ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-4VPQJZNZ.mjs +0 -27
- package/dist/lib/node-esm/markdown-4VPQJZNZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LAU23XBH.mjs +0 -54
- package/dist/lib/node-esm/react-surface-LAU23XBH.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
- 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/compute-graph-registry.d.ts +0 -4
- package/dist/types/src/capabilities/compute-graph-registry.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/capabilities/markdown.d.ts +0 -6
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/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 -7
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +0 -25
- 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.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 -8
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.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/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -37
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -22
- package/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/compute-graph-registry.ts +0 -28
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -39
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -53
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +0 -93
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -89
- package/src/components/SheetContainer/SheetContainer.tsx +0 -36
- package/src/components/SheetContext/index.ts +0 -5
- package/src/types/schema.ts +0 -61
- /package/dist/types/src/{components → containers}/SheetContainer/index.d.ts +0 -0
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { type CellAddress, type CellRange, type CompleteCellRange, type ComputeGraph } from '@dxos/compute';
|
|
8
|
+
import { raise } from '@dxos/debug';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
10
|
import {
|
|
11
11
|
Grid,
|
|
12
12
|
type GridContentProps,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '@dxos/react-ui-grid';
|
|
17
17
|
|
|
18
18
|
import { type SheetModel, useSheetModel } from '../../model';
|
|
19
|
-
import { type
|
|
19
|
+
import { type Sheet } from '../../types';
|
|
20
20
|
|
|
21
21
|
export type SheetContextValue = {
|
|
22
22
|
id: string;
|
|
@@ -39,29 +39,57 @@ export type SheetContextValue = {
|
|
|
39
39
|
activeRefs: GridContentProps['activeRefs'];
|
|
40
40
|
setActiveRefs: (activeRefs: GridContentProps['activeRefs']) => void;
|
|
41
41
|
|
|
42
|
+
// Flags
|
|
43
|
+
ignoreAttention?: boolean;
|
|
44
|
+
|
|
42
45
|
// Events.
|
|
43
46
|
// TODO(burdon): Generalize.
|
|
44
47
|
onInfo?: () => void;
|
|
45
|
-
|
|
46
|
-
// Flags
|
|
47
|
-
ignoreAttention?: boolean;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
// TODO(burdon): Use radix context.
|
|
50
51
|
const SheetContext = createContext<SheetContextValue | undefined>(undefined);
|
|
51
52
|
|
|
52
53
|
export const useSheetContext = (): SheetContextValue => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
return useContext(SheetContext) ?? raise(new Error('Missing SheetContext'));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type SheetRootProps = {
|
|
58
|
+
graph: ComputeGraph;
|
|
59
|
+
sheet: Sheet.Sheet;
|
|
60
|
+
readonly?: boolean;
|
|
61
|
+
ignoreAttention?: boolean;
|
|
62
|
+
} & Pick<SheetContextValue, 'onInfo'>;
|
|
63
|
+
|
|
64
|
+
export const SheetRoot = ({
|
|
65
|
+
children,
|
|
66
|
+
graph,
|
|
67
|
+
sheet,
|
|
68
|
+
readonly,
|
|
69
|
+
ignoreAttention,
|
|
70
|
+
onInfo,
|
|
71
|
+
}: PropsWithChildren<SheetRootProps>) => {
|
|
72
|
+
const model = useSheetModel(graph, sheet, { readonly });
|
|
73
|
+
if (!model) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Grid.Root id={Obj.getDXN(sheet).toString()}>
|
|
79
|
+
<SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
80
|
+
{children}
|
|
81
|
+
</SheetProviderImpl>
|
|
82
|
+
</Grid.Root>
|
|
83
|
+
);
|
|
56
84
|
};
|
|
57
85
|
|
|
58
86
|
const SheetProviderImpl = ({
|
|
87
|
+
__gridScope,
|
|
88
|
+
children,
|
|
89
|
+
ignoreAttention,
|
|
59
90
|
model,
|
|
60
91
|
onInfo,
|
|
61
|
-
|
|
62
|
-
children,
|
|
63
|
-
__gridScope,
|
|
64
|
-
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model' | 'ignoreAttention'>>>) => {
|
|
92
|
+
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'ignoreAttention' | 'model' | 'onInfo'>>>) => {
|
|
65
93
|
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
66
94
|
|
|
67
95
|
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
@@ -102,38 +130,12 @@ const SheetProviderImpl = ({
|
|
|
102
130
|
cursorFallbackRange,
|
|
103
131
|
activeRefs,
|
|
104
132
|
setActiveRefs,
|
|
133
|
+
ignoreAttention,
|
|
105
134
|
// TODO(burdon): Change to event.
|
|
106
135
|
onInfo,
|
|
107
|
-
ignoreAttention,
|
|
108
136
|
}}
|
|
109
137
|
>
|
|
110
138
|
{children}
|
|
111
139
|
</SheetContext.Provider>
|
|
112
140
|
);
|
|
113
141
|
};
|
|
114
|
-
|
|
115
|
-
export type SheetProviderProps = {
|
|
116
|
-
graph: ComputeGraph;
|
|
117
|
-
sheet: SheetType;
|
|
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={fullyQualifiedId(sheet)}>
|
|
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
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute';
|
|
8
|
-
import { Icon } from '@dxos/react-ui';
|
|
8
|
+
import { type ComposableProps, Icon } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
import { mapFormulaIndicesToRefs } from '../../types';
|
|
11
|
-
import { useSheetContext } from '../
|
|
11
|
+
import { useSheetContext } from '../SheetRoot';
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type SheetStatusbarProps = ComposableProps;
|
|
14
|
+
|
|
15
|
+
export const SheetStatusbar = (props: SheetStatusbarProps) => {
|
|
14
16
|
const { model, cursor, range } = useSheetContext();
|
|
15
17
|
|
|
16
18
|
let value;
|
|
@@ -26,13 +28,16 @@ export const FunctionEditor = () => {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
return (
|
|
29
|
-
<div
|
|
31
|
+
<div
|
|
32
|
+
{...props}
|
|
33
|
+
className='flex shrink-0 justify-between items-center px-4 py-1 text-sm bg-toolbar-surface border-y !border-subdued-separator'
|
|
34
|
+
>
|
|
30
35
|
<div className='flex gap-4 items-center'>
|
|
31
36
|
<div className='flex w-16 items-center font-mono'>
|
|
32
37
|
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
33
38
|
</div>
|
|
34
39
|
<div className='flex gap-2 items-center'>
|
|
35
|
-
<Icon icon='ph--function--regular' classNames={['text-
|
|
40
|
+
<Icon icon='ph--function--regular' classNames={['text-green-text', formula ? 'visible' : 'invisible']} />
|
|
36
41
|
<span className='font-mono'>{value}</span>
|
|
37
42
|
</div>
|
|
38
43
|
</div>
|
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { withLayout, withTheme } from '@dxos/
|
|
8
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
|
-
import { SheetToolbar } from './SheetToolbar';
|
|
13
10
|
import { translations } from '../../translations';
|
|
14
11
|
|
|
12
|
+
import { SheetToolbar } from './SheetToolbar';
|
|
13
|
+
|
|
15
14
|
const DefaultStory = () => {
|
|
16
|
-
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetRoot.
|
|
16
|
+
// return <SheetToolbar id='test' />;
|
|
17
|
+
return <>TODO</>;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
title: 'plugins/plugin-sheet/Toolbar',
|
|
23
|
-
component: SheetToolbar,
|
|
20
|
+
const meta = {
|
|
21
|
+
title: 'plugins/plugin-sheet/components/Toolbar',
|
|
22
|
+
component: SheetToolbar as any,
|
|
24
23
|
render: DefaultStory,
|
|
25
|
-
decorators: [withTheme, withLayout()],
|
|
26
|
-
parameters: {
|
|
27
|
-
|
|
24
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: 'fullscreen',
|
|
27
|
+
translations,
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
28
30
|
|
|
29
31
|
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof meta>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {};
|
|
@@ -2,83 +2,94 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import React, { type PropsWithChildren, useMemo } from 'react';
|
|
5
|
+
import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { type PropsWithChildren, useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useAppGraph } from '@dxos/app-
|
|
8
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
10
|
import {
|
|
12
|
-
type ActionGraphEdges,
|
|
13
|
-
type ActionGraphNodes,
|
|
14
11
|
type ActionGraphProps,
|
|
12
|
+
Menu,
|
|
13
|
+
type MenuRootProps,
|
|
15
14
|
createGapSeparator,
|
|
16
|
-
MenuProvider,
|
|
17
|
-
rxFromSignal,
|
|
18
|
-
ToolbarMenu,
|
|
19
15
|
useMenuActions,
|
|
20
16
|
} from '@dxos/react-ui-menu';
|
|
21
17
|
|
|
22
|
-
import { createAlign, useAlignState } from './align';
|
|
23
|
-
import { createStyle, useStyleState } from './style';
|
|
24
|
-
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
25
18
|
import { type SheetModel } from '../../model';
|
|
26
|
-
import { useSheetContext } from '../
|
|
19
|
+
import { useSheetContext } from '../SheetRoot';
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
import { createAlign, useAlignState } from './align';
|
|
22
|
+
import { createStyle, useStyleState } from './style';
|
|
23
|
+
import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
type ToolbarActionsContext = {
|
|
26
|
+
model: SheetModel;
|
|
27
|
+
stateAtom: ToolbarStateAtom;
|
|
28
|
+
registry: Registry.Registry;
|
|
29
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
30
|
+
customActions?: Atom.Atom<ActionGraphProps>;
|
|
31
|
+
};
|
|
33
32
|
|
|
34
|
-
const createToolbarActions = (
|
|
35
|
-
model
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
33
|
+
const createToolbarActions = ({
|
|
34
|
+
model,
|
|
35
|
+
stateAtom,
|
|
36
|
+
registry,
|
|
37
|
+
cursorFallbackRange,
|
|
38
|
+
customActions,
|
|
39
|
+
}: ToolbarActionsContext): Atom.Atom<ActionGraphProps> => {
|
|
40
|
+
return Atom.make((get) => {
|
|
41
|
+
const state = get(stateAtom);
|
|
42
|
+
const context = { model, state, stateAtom, registry, cursorFallbackRange };
|
|
43
|
+
const align = createAlign(context);
|
|
44
|
+
const style = createStyle(context);
|
|
43
45
|
const gap = createGapSeparator();
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
+
|
|
47
|
+
const graph: ActionGraphProps = {
|
|
48
|
+
nodes: [...align.nodes, ...style.nodes, ...gap.nodes],
|
|
49
|
+
edges: [...align.edges, ...style.edges, ...gap.edges],
|
|
50
|
+
};
|
|
51
|
+
|
|
46
52
|
if (customActions) {
|
|
47
53
|
const custom = get(customActions);
|
|
48
|
-
nodes.push(...custom.nodes);
|
|
49
|
-
edges.push(...custom.edges);
|
|
54
|
+
graph.nodes.push(...custom.nodes);
|
|
55
|
+
graph.edges.push(...custom.edges);
|
|
50
56
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
edges,
|
|
54
|
-
};
|
|
57
|
+
|
|
58
|
+
return graph;
|
|
55
59
|
});
|
|
56
60
|
};
|
|
57
61
|
|
|
58
|
-
export
|
|
62
|
+
export type SheetToolbarProps = { id: string } & Partial<MenuRootProps> &
|
|
63
|
+
PropsWithChildren<{ id: string } & Partial<MenuRootProps>>;
|
|
64
|
+
|
|
65
|
+
export const SheetToolbar = ({ id, ...props }: SheetToolbarProps) => {
|
|
59
66
|
const { model, cursorFallbackRange } = useSheetContext();
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
const stateAtom = useToolbarState({});
|
|
68
|
+
const registry = useContext(RegistryContext);
|
|
69
|
+
useAlignState(stateAtom);
|
|
70
|
+
useStyleState(stateAtom);
|
|
63
71
|
|
|
64
72
|
const { graph } = useAppGraph();
|
|
65
73
|
const customActions = useMemo(() => {
|
|
66
|
-
return
|
|
74
|
+
return Atom.make((get) => {
|
|
67
75
|
const actions = get(graph.actions(id));
|
|
68
76
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
69
|
-
return {
|
|
77
|
+
return {
|
|
78
|
+
nodes,
|
|
79
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id, relation: 'child' })),
|
|
80
|
+
};
|
|
70
81
|
});
|
|
71
|
-
}, [graph]);
|
|
82
|
+
}, [graph, id]);
|
|
72
83
|
|
|
73
84
|
const actionsCreator = useMemo(
|
|
74
|
-
() => createToolbarActions(model,
|
|
75
|
-
[model,
|
|
85
|
+
() => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
|
|
86
|
+
[model, stateAtom, registry, cursorFallbackRange, customActions],
|
|
76
87
|
);
|
|
77
88
|
const menu = useMenuActions(actionsCreator);
|
|
78
89
|
|
|
79
90
|
return (
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
</
|
|
91
|
+
<Menu.Root {...props} {...menu} attendableId={id}>
|
|
92
|
+
<Menu.Toolbar />
|
|
93
|
+
</Menu.Root>
|
|
83
94
|
);
|
|
84
95
|
};
|
|
@@ -2,16 +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
8
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import {
|
|
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 {
|
|
11
|
-
import { SHEET_PLUGIN } from '../../meta';
|
|
17
|
+
import { meta } from '../../meta';
|
|
12
18
|
import { type SheetModel } from '../../model';
|
|
13
|
-
import { type AlignKey,
|
|
14
|
-
import { useSheetContext } from '../
|
|
19
|
+
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
20
|
+
import { useSheetContext } from '../SheetRoot';
|
|
21
|
+
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
15
23
|
|
|
16
24
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
17
25
|
|
|
@@ -23,29 +31,40 @@ const aligns: Record<AlignValue, string> = {
|
|
|
23
31
|
end: 'ph--text-align-right--regular',
|
|
24
32
|
};
|
|
25
33
|
|
|
26
|
-
export const useAlignState = (
|
|
34
|
+
export const useAlignState = (stateAtom: ToolbarStateAtom) => {
|
|
35
|
+
const registry = useContext(RegistryContext);
|
|
27
36
|
const { cursor, model } = useSheetContext();
|
|
28
37
|
useEffect(() => {
|
|
29
38
|
// TODO(thure): Can this O(n) call be memoized?
|
|
30
|
-
|
|
39
|
+
const alignValue = (
|
|
31
40
|
cursor
|
|
32
41
|
? model.sheet.ranges?.findLast(
|
|
33
42
|
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
34
43
|
)?.value
|
|
35
44
|
: undefined
|
|
36
45
|
) as AlignValue | undefined;
|
|
37
|
-
|
|
46
|
+
const prev = registry.get(stateAtom);
|
|
47
|
+
registry.set(stateAtom, { ...prev, [alignKey]: alignValue });
|
|
48
|
+
}, [cursor, model.sheet, registry, stateAtom]);
|
|
38
49
|
};
|
|
39
50
|
|
|
40
51
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
41
52
|
createMenuItemGroup('align', {
|
|
42
|
-
label: ['align label', { ns:
|
|
53
|
+
label: ['align label', { ns: meta.id }],
|
|
43
54
|
variant: 'toggleGroup',
|
|
44
55
|
selectCardinality: 'single',
|
|
45
56
|
value: `${alignKey}--${value}`,
|
|
46
57
|
} as ToolbarMenuActionGroupProperties);
|
|
47
58
|
|
|
48
|
-
|
|
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) =>
|
|
49
68
|
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
50
69
|
return createMenuAction<AlignAction>(
|
|
51
70
|
`${alignKey}--${alignValue}`,
|
|
@@ -63,36 +82,43 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
63
82
|
key: alignKey,
|
|
64
83
|
value: alignValue as AlignValue,
|
|
65
84
|
};
|
|
85
|
+
const currentState = registry.get(stateAtom);
|
|
66
86
|
if (index < 0) {
|
|
67
|
-
model.sheet
|
|
68
|
-
|
|
87
|
+
Obj.change(model.sheet, (obj) => {
|
|
88
|
+
obj.ranges?.push(nextRangeEntity);
|
|
89
|
+
});
|
|
90
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
69
91
|
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
70
|
-
model.sheet
|
|
71
|
-
|
|
92
|
+
Obj.change(model.sheet, (obj) => {
|
|
93
|
+
obj.ranges?.splice(index, 1);
|
|
94
|
+
});
|
|
95
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
72
96
|
} else {
|
|
73
|
-
model.sheet
|
|
74
|
-
|
|
97
|
+
Obj.change(model.sheet, (obj) => {
|
|
98
|
+
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
|
+
});
|
|
100
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
75
101
|
}
|
|
76
102
|
},
|
|
77
103
|
{
|
|
78
104
|
key: alignKey,
|
|
79
105
|
value: alignValue as AlignValue,
|
|
80
106
|
checked: state[alignKey] === alignValue,
|
|
81
|
-
label: [`range value ${alignValue} label`, { ns:
|
|
107
|
+
label: [`range value ${alignValue} label`, { ns: meta.id }],
|
|
82
108
|
icon,
|
|
83
109
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
84
110
|
},
|
|
85
111
|
);
|
|
86
112
|
});
|
|
87
113
|
|
|
88
|
-
export const createAlign = (
|
|
89
|
-
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
90
|
-
const alignActions = createAlignActions(
|
|
114
|
+
export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
|
|
115
|
+
const alignGroup = createAlignGroupAction(context.state[alignKey]);
|
|
116
|
+
const alignActions = createAlignActions(context);
|
|
91
117
|
return {
|
|
92
118
|
nodes: [alignGroup, ...alignActions],
|
|
93
119
|
edges: [
|
|
94
|
-
{ source: 'root', target: 'align' },
|
|
95
|
-
...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' })),
|
|
96
122
|
],
|
|
97
123
|
};
|
|
98
124
|
};
|
|
@@ -2,15 +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
8
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import {
|
|
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 {
|
|
17
|
+
import { meta } from '../../meta';
|
|
11
18
|
import { type SheetModel } from '../../model';
|
|
12
|
-
import {
|
|
13
|
-
import { useSheetContext } from '../
|
|
19
|
+
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
20
|
+
import { useSheetContext } from '../SheetRoot';
|
|
21
|
+
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
14
23
|
|
|
15
24
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
16
25
|
|
|
@@ -21,22 +30,30 @@ const styles: Record<StyleValue, string> = {
|
|
|
21
30
|
softwrap: 'ph--paragraph--regular',
|
|
22
31
|
};
|
|
23
32
|
|
|
24
|
-
export const useStyleState = (
|
|
33
|
+
export const useStyleState = (stateAtom: ToolbarStateAtom) => {
|
|
34
|
+
const registry = useContext(RegistryContext);
|
|
25
35
|
const { cursorFallbackRange, model } = useSheetContext();
|
|
26
36
|
|
|
27
37
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
let highlight = false;
|
|
39
|
+
let softwrap = false;
|
|
30
40
|
if (cursorFallbackRange && model.sheet.ranges) {
|
|
31
41
|
model.sheet.ranges
|
|
32
42
|
.filter(
|
|
33
43
|
({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
34
44
|
)
|
|
35
45
|
.forEach(({ value }) => {
|
|
36
|
-
|
|
46
|
+
if (value === 'highlight') {
|
|
47
|
+
highlight = true;
|
|
48
|
+
}
|
|
49
|
+
if (value === 'softwrap') {
|
|
50
|
+
softwrap = true;
|
|
51
|
+
}
|
|
37
52
|
});
|
|
38
53
|
}
|
|
39
|
-
|
|
54
|
+
const prev = registry.get(stateAtom);
|
|
55
|
+
registry.set(stateAtom, { ...prev, highlight, softwrap });
|
|
56
|
+
}, [cursorFallbackRange, model.sheet, registry, stateAtom]);
|
|
40
57
|
};
|
|
41
58
|
|
|
42
59
|
const createStyleGroup = (state: StyleState) => {
|
|
@@ -49,7 +66,15 @@ const createStyleGroup = (state: StyleState) => {
|
|
|
49
66
|
} as ToolbarMenuActionGroupProperties);
|
|
50
67
|
};
|
|
51
68
|
|
|
52
|
-
|
|
69
|
+
type StyleActionsContext = {
|
|
70
|
+
model: SheetModel;
|
|
71
|
+
state: ToolbarState;
|
|
72
|
+
stateAtom: ToolbarStateAtom;
|
|
73
|
+
registry: Registry.Registry;
|
|
74
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: StyleActionsContext) =>
|
|
53
78
|
Object.entries(styles).map(([styleValue, icon]) => {
|
|
54
79
|
return createMenuAction<StyleAction>(
|
|
55
80
|
`style--${styleValue}`,
|
|
@@ -67,6 +92,7 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
67
92
|
key: 'style',
|
|
68
93
|
value: styleValue as StyleValue,
|
|
69
94
|
};
|
|
95
|
+
const currentState = registry.get(stateAtom);
|
|
70
96
|
if (
|
|
71
97
|
model.sheet.ranges
|
|
72
98
|
.filter(
|
|
@@ -77,32 +103,36 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
77
103
|
) {
|
|
78
104
|
// this value should be unset
|
|
79
105
|
if (index >= 0) {
|
|
80
|
-
model.sheet
|
|
106
|
+
Obj.change(model.sheet, (obj) => {
|
|
107
|
+
obj.ranges?.splice(index, 1);
|
|
108
|
+
});
|
|
81
109
|
}
|
|
82
|
-
|
|
110
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
|
|
83
111
|
} else {
|
|
84
|
-
model.sheet
|
|
85
|
-
|
|
112
|
+
Obj.change(model.sheet, (obj) => {
|
|
113
|
+
obj.ranges?.push(nextRangeEntity);
|
|
114
|
+
});
|
|
115
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: true });
|
|
86
116
|
}
|
|
87
117
|
},
|
|
88
118
|
{
|
|
89
119
|
key: 'style',
|
|
90
120
|
value: styleValue as StyleValue,
|
|
91
121
|
icon,
|
|
92
|
-
label: [`range value ${styleValue} label`, { ns:
|
|
122
|
+
label: [`range value ${styleValue} label`, { ns: meta.id }],
|
|
93
123
|
checked: !!state[styleValue as StyleValue],
|
|
94
124
|
},
|
|
95
125
|
);
|
|
96
126
|
});
|
|
97
127
|
|
|
98
|
-
export const createStyle = (
|
|
99
|
-
const styleGroupAction = createStyleGroup(state);
|
|
100
|
-
const styleActions = createStyleActions(
|
|
128
|
+
export const createStyle = (context: StyleActionsContext): ActionGraphProps => {
|
|
129
|
+
const styleGroupAction = createStyleGroup(context.state);
|
|
130
|
+
const styleActions = createStyleActions(context);
|
|
101
131
|
return {
|
|
102
132
|
nodes: [styleGroupAction, ...styleActions],
|
|
103
133
|
edges: [
|
|
104
|
-
{ source: 'root', target: 'style' },
|
|
105
|
-
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id })),
|
|
134
|
+
{ source: 'root', target: 'style', relation: 'child' },
|
|
135
|
+
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id, relation: 'child' })),
|
|
106
136
|
],
|
|
107
137
|
};
|
|
108
138
|
};
|