@dxos/plugin-sheet 0.6.13 → 0.6.14-staging.9e90729
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/SheetContainer-JBB7W52Y.mjs +280 -0
- package/dist/lib/browser/SheetContainer-JBB7W52Y.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-2ZK3YMZG.mjs} +621 -675
- package/dist/lib/browser/chunk-2ZK3YMZG.mjs.map +7 -0
- package/dist/lib/browser/chunk-3QWIMZZJ.mjs +65 -0
- package/dist/lib/browser/chunk-3QWIMZZJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-D3QTX46O.mjs +14 -0
- package/dist/lib/browser/chunk-D3QTX46O.mjs.map +7 -0
- package/dist/lib/browser/chunk-XXDHBYZQ.mjs +1455 -0
- package/dist/lib/browser/chunk-XXDHBYZQ.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-ZQKB6QVP.mjs +35 -0
- package/dist/lib/browser/compute-graph-ZQKB6QVP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +139 -65
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +6 -12
- package/dist/lib/node/SheetContainer-L37HUFCF.cjs +286 -0
- package/dist/lib/node/SheetContainer-L37HUFCF.cjs.map +7 -0
- package/dist/lib/node/chunk-7AWAC3R3.cjs +1441 -0
- package/dist/lib/node/chunk-7AWAC3R3.cjs.map +7 -0
- package/dist/lib/node/chunk-QIFIGEKV.cjs +37 -0
- package/dist/lib/node/chunk-QIFIGEKV.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-QNFMTK3X.cjs} +638 -674
- package/dist/lib/node/chunk-QNFMTK3X.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-V7E5JZBD.cjs} +31 -51
- package/dist/lib/node/chunk-V7E5JZBD.cjs.map +7 -0
- package/dist/lib/node/compute-graph-RJB6OVW6.cjs +57 -0
- package/dist/lib/node/compute-graph-RJB6OVW6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +148 -73
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +9 -15
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-CLKFEM35.mjs +281 -0
- package/dist/lib/node-esm/SheetContainer-CLKFEM35.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3JYJEOCF.mjs +1456 -0
- package/dist/lib/node-esm/chunk-3JYJEOCF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JBTORSST.mjs +3182 -0
- package/dist/lib/node-esm/chunk-JBTORSST.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SPQFLYC2.mjs +66 -0
- package/dist/lib/node-esm/chunk-SPQFLYC2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +16 -0
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-VKRG526N.mjs +36 -0
- package/dist/lib/node-esm/compute-graph-VKRG526N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +323 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +17 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +13 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +3 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/index.d.ts +2 -0
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +6 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/{CellEditor/CellEditor.stories.d.ts → GridSheet/SheetCellEditor.stories.d.ts} +5 -9
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/index.d.ts +2 -0
- package/dist/types/src/components/GridSheet/index.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +16 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts +9 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/index.d.ts +2 -0
- package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +6 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/index.d.ts +3 -0
- package/dist/types/src/components/SheetContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +28 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/index.d.ts +2 -0
- package/dist/types/src/components/SheetContext/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +33 -9
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +4 -32
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.d.ts +64 -0
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts +6 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-node.d.ts +26 -0
- package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → compute-graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → compute-graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/index.d.ts +4 -0
- package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/index.d.ts +5 -0
- package/dist/types/src/compute-graph/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/index.d.ts +3 -0
- package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/compute-graph/util.d.ts +2 -0
- package/dist/types/src/compute-graph/util.d.ts.map +1 -0
- package/dist/types/src/defs/index.d.ts +4 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/defs/sheet-range-types.d.ts +13 -0
- package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -0
- package/dist/types/src/defs/types.d.ts +28 -0
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +39 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +6 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +21 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/extension.d.ts +39 -0
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/index.d.ts +2 -0
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +3 -0
- package/dist/types/src/extensions/index.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/index.d.ts +2 -0
- package/dist/types/src/integrations/index.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts +8 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -9
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +2 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +13 -67
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
- package/dist/types/src/model/useSheetModel.d.ts +8 -0
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +4 -0
- package/dist/types/src/serializer.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +23 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +100 -41
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +60 -61
- package/src/SheetPlugin.tsx +69 -78
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +37 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/FunctionEditor/FunctionEditor.tsx +45 -0
- package/src/components/FunctionEditor/index.ts +5 -0
- package/src/components/GridSheet/GridSheet.stories.tsx +46 -0
- package/src/components/GridSheet/GridSheet.tsx +296 -0
- package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +18 -15
- package/src/components/GridSheet/index.ts +5 -0
- package/src/components/GridSheet/util.ts +164 -0
- package/src/components/RangeList/RangeList.tsx +38 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +43 -0
- package/src/components/SheetContainer/SheetContainer.tsx +27 -0
- package/src/components/SheetContainer/index.ts +7 -0
- package/src/components/SheetContext/SheetContext.tsx +127 -0
- package/src/components/SheetContext/index.ts +5 -0
- package/src/components/Toolbar/Toolbar.stories.tsx +9 -6
- package/src/components/Toolbar/Toolbar.tsx +240 -111
- package/src/components/index.ts +5 -3
- package/src/compute-graph/compute-graph-registry.ts +90 -0
- package/src/compute-graph/compute-graph.stories.tsx +97 -0
- package/src/compute-graph/compute-graph.test.ts +87 -0
- package/src/compute-graph/compute-graph.ts +245 -0
- package/src/compute-graph/compute-node.ts +62 -0
- package/src/{components/ComputeGraph → compute-graph/functions}/async-function.ts +25 -15
- package/src/{components/ComputeGraph → compute-graph/functions}/edge-function.ts +16 -14
- package/src/compute-graph/functions/index.ts +7 -0
- package/src/compute-graph/hyperformula.test.ts +14 -0
- package/src/compute-graph/index.ts +8 -0
- package/src/compute-graph/testing/index.ts +6 -0
- package/src/compute-graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → compute-graph/testing/test-plugin.ts} +44 -14
- package/src/compute-graph/util.ts +8 -0
- package/src/defs/index.ts +7 -0
- package/src/defs/sheet-range-types.ts +47 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/defs/types.ts +86 -0
- package/src/defs/util.ts +135 -0
- package/src/extensions/compute.stories.tsx +155 -0
- package/src/extensions/compute.ts +147 -0
- package/src/{components/CellEditor → extensions/editor}/extension.test.ts +4 -6
- package/src/{components/CellEditor → extensions/editor}/extension.ts +51 -27
- package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
- package/src/extensions/index.ts +6 -0
- package/src/index.ts +2 -2
- package/src/integrations/index.ts +5 -0
- package/src/integrations/thread-ranges.ts +101 -0
- package/src/meta.ts +14 -0
- package/src/model/index.ts +2 -3
- package/src/model/sheet-model.test.ts +57 -0
- package/src/model/sheet-model.ts +423 -0
- package/src/model/useSheetModel.ts +40 -0
- package/src/sanity.test.ts +40 -0
- package/src/serializer.ts +27 -0
- package/src/{components/Sheet → testing}/index.ts +1 -1
- package/src/testing/testing.tsx +68 -0
- package/src/translations.ts +12 -1
- package/src/types.ts +41 -46
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +0 -19
- package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
- package/dist/types/src/components/CellEditor/index.d.ts +0 -3
- package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/grid.d.ts +0 -52
- package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/index.d.ts +0 -2
- package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/nav.d.ts +0 -29
- package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/util.d.ts +0 -18
- package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer.d.ts +0 -9
- package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/common.d.ts +0 -20
- package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts +0 -17
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/CellEditor/CellEditor.tsx +0 -113
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/components/Sheet/Sheet.stories.tsx +0 -287
- package/src/components/Sheet/Sheet.tsx +0 -1160
- package/src/components/Sheet/formatting.ts +0 -106
- package/src/components/Sheet/grid.ts +0 -191
- package/src/components/Sheet/nav.ts +0 -157
- package/src/components/Sheet/sheet-context.tsx +0 -150
- package/src/components/Sheet/util.ts +0 -56
- package/src/components/SheetContainer.tsx +0 -34
- package/src/components/Toolbar/common.tsx +0 -72
- package/src/meta.tsx +0 -18
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/types.ts +0 -71
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
- /package/src/{model/functions.ts → compute-graph/functions/function-defs.ts} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { invariant } from '@dxos/invariant';
|
|
8
|
+
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
|
+
import {
|
|
10
|
+
Grid,
|
|
11
|
+
type GridContentProps,
|
|
12
|
+
type GridEditing,
|
|
13
|
+
type GridScopedProps,
|
|
14
|
+
useGridContext,
|
|
15
|
+
} from '@dxos/react-ui-grid';
|
|
16
|
+
|
|
17
|
+
import { type ComputeGraph } from '../../compute-graph';
|
|
18
|
+
import { type CellAddress, type CellRange, type CompleteCellRange } from '../../defs';
|
|
19
|
+
import { type SheetModel, useSheetModel } from '../../model';
|
|
20
|
+
import { type SheetType } from '../../types';
|
|
21
|
+
|
|
22
|
+
export type SheetContextValue = {
|
|
23
|
+
id: string;
|
|
24
|
+
|
|
25
|
+
model: SheetModel;
|
|
26
|
+
|
|
27
|
+
// Cursor state.
|
|
28
|
+
// TODO(burdon): Cursor and range should use indices.
|
|
29
|
+
cursor?: CellAddress;
|
|
30
|
+
setCursor: (cell: CellAddress | undefined) => void;
|
|
31
|
+
range?: CellRange;
|
|
32
|
+
setRange: (range: CellRange | undefined) => void;
|
|
33
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
34
|
+
|
|
35
|
+
// Editing state (undefined if not editing).
|
|
36
|
+
editing: GridEditing;
|
|
37
|
+
setEditing: (editing: GridEditing) => void;
|
|
38
|
+
|
|
39
|
+
// Active refs
|
|
40
|
+
activeRefs: GridContentProps['activeRefs'];
|
|
41
|
+
setActiveRefs: (activeRefs: GridContentProps['activeRefs']) => void;
|
|
42
|
+
|
|
43
|
+
// Events.
|
|
44
|
+
// TODO(burdon): Generalize.
|
|
45
|
+
onInfo?: () => void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const SheetContext = createContext<SheetContextValue | undefined>(undefined);
|
|
49
|
+
|
|
50
|
+
export const useSheetContext = (): SheetContextValue => {
|
|
51
|
+
const context = useContext(SheetContext);
|
|
52
|
+
invariant(context);
|
|
53
|
+
return context;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const SheetProviderImpl = ({
|
|
57
|
+
model,
|
|
58
|
+
onInfo,
|
|
59
|
+
children,
|
|
60
|
+
__gridScope,
|
|
61
|
+
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model'>>>) => {
|
|
62
|
+
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
63
|
+
|
|
64
|
+
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
65
|
+
const [range, setRangeInternal] = useState<CellRange>();
|
|
66
|
+
const [cursorFallbackRange, setCursorFallbackRange] = useState<CompleteCellRange>();
|
|
67
|
+
const [activeRefs, setActiveRefs] = useState<GridContentProps['activeRefs']>('');
|
|
68
|
+
|
|
69
|
+
const setCursor = useCallback(
|
|
70
|
+
(nextCursor?: CellAddress) => {
|
|
71
|
+
setCursorInternal(nextCursor);
|
|
72
|
+
setCursorFallbackRange(
|
|
73
|
+
range?.to ? (range as CompleteCellRange) : nextCursor ? { from: nextCursor!, to: nextCursor! } : undefined,
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
[range],
|
|
77
|
+
);
|
|
78
|
+
const setRange = useCallback(
|
|
79
|
+
(nextRange?: CellRange) => {
|
|
80
|
+
setRangeInternal(nextRange);
|
|
81
|
+
setCursorFallbackRange(
|
|
82
|
+
nextRange?.to ? (nextRange as CompleteCellRange) : cursor ? { from: cursor!, to: cursor! } : undefined,
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
[cursor],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<SheetContext.Provider
|
|
90
|
+
value={{
|
|
91
|
+
id,
|
|
92
|
+
model,
|
|
93
|
+
editing,
|
|
94
|
+
setEditing,
|
|
95
|
+
cursor,
|
|
96
|
+
setCursor,
|
|
97
|
+
range,
|
|
98
|
+
setRange,
|
|
99
|
+
cursorFallbackRange,
|
|
100
|
+
activeRefs,
|
|
101
|
+
setActiveRefs,
|
|
102
|
+
// TODO(burdon): Change to event.
|
|
103
|
+
onInfo,
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{children}
|
|
107
|
+
</SheetContext.Provider>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type SheetProviderProps = {
|
|
112
|
+
graph: ComputeGraph;
|
|
113
|
+
sheet: SheetType;
|
|
114
|
+
readonly?: boolean;
|
|
115
|
+
} & Pick<SheetContextValue, 'onInfo'>;
|
|
116
|
+
|
|
117
|
+
export const SheetProvider = ({ children, graph, sheet, readonly, onInfo }: PropsWithChildren<SheetProviderProps>) => {
|
|
118
|
+
const model = useSheetModel(graph, sheet, { readonly });
|
|
119
|
+
|
|
120
|
+
return !model ? null : (
|
|
121
|
+
<Grid.Root id={fullyQualifiedId(sheet)}>
|
|
122
|
+
<SheetProviderImpl model={model} onInfo={onInfo}>
|
|
123
|
+
{children}
|
|
124
|
+
</SheetProviderImpl>
|
|
125
|
+
</Grid.Root>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
+
import { type Meta } from '@storybook/react';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
|
|
9
10
|
import { textBlockWidth } from '@dxos/react-ui-theme';
|
|
@@ -12,7 +13,7 @@ import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
|
12
13
|
import { Toolbar } from './Toolbar';
|
|
13
14
|
import translations from '../../translations';
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const DefaultStory = () => {
|
|
16
17
|
return (
|
|
17
18
|
<Toolbar.Root classNames={textBlockWidth}>
|
|
18
19
|
<Toolbar.Alignment />
|
|
@@ -20,12 +21,14 @@ const Story = () => {
|
|
|
20
21
|
);
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
export const Default = {};
|
|
25
|
+
|
|
26
|
+
const meta: Meta<typeof Toolbar.Root> = {
|
|
27
|
+
title: 'plugins/plugin-sheet/Toolbar',
|
|
28
|
+
component: Toolbar.Root,
|
|
29
|
+
render: DefaultStory,
|
|
26
30
|
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
27
31
|
parameters: { translations, layout: 'fullscreen' },
|
|
28
|
-
render: (args: any) => <Story {...args} />,
|
|
29
32
|
};
|
|
30
33
|
|
|
31
|
-
export
|
|
34
|
+
export default meta;
|
|
@@ -2,167 +2,269 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
type Icon,
|
|
7
|
-
Calendar,
|
|
8
|
-
ChatText,
|
|
9
|
-
CurrencyDollar,
|
|
10
|
-
Eraser,
|
|
11
|
-
HighlighterCircle,
|
|
12
|
-
TextAlignCenter,
|
|
13
|
-
TextAlignLeft,
|
|
14
|
-
TextAlignRight,
|
|
15
|
-
} from '@phosphor-icons/react';
|
|
16
5
|
import { createContext } from '@radix-ui/react-context';
|
|
17
|
-
import React, { type PropsWithChildren } from 'react';
|
|
6
|
+
import React, { type PropsWithChildren, useCallback, useMemo } from 'react';
|
|
18
7
|
|
|
8
|
+
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
19
9
|
import {
|
|
20
|
-
|
|
21
|
-
ElevationProvider,
|
|
10
|
+
Icon,
|
|
22
11
|
Toolbar as NaturalToolbar,
|
|
12
|
+
Tooltip,
|
|
13
|
+
type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,
|
|
14
|
+
type ToolbarButtonProps as NaturalToolbarButtonProps,
|
|
15
|
+
type ToolbarToggleProps as NaturalToolbarToggleProps,
|
|
23
16
|
type ThemedClassName,
|
|
24
17
|
useTranslation,
|
|
25
18
|
} from '@dxos/react-ui';
|
|
19
|
+
import { useAttention } from '@dxos/react-ui-attention';
|
|
20
|
+
import { nonNullable } from '@dxos/util';
|
|
26
21
|
|
|
27
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
type AlignKey,
|
|
24
|
+
type AlignValue,
|
|
25
|
+
type CommentKey,
|
|
26
|
+
type CommentValue,
|
|
27
|
+
inRange,
|
|
28
|
+
rangeFromIndex,
|
|
29
|
+
rangeToIndex,
|
|
30
|
+
type StyleKey,
|
|
31
|
+
type StyleValue,
|
|
32
|
+
} from '../../defs';
|
|
33
|
+
import { completeCellRangeToThreadCursor } from '../../integrations';
|
|
28
34
|
import { SHEET_PLUGIN } from '../../meta';
|
|
29
|
-
import { type
|
|
35
|
+
import { type SheetType } from '../../types';
|
|
36
|
+
import { useSheetContext } from '../SheetContext';
|
|
30
37
|
|
|
31
38
|
//
|
|
32
|
-
//
|
|
39
|
+
// Buttons
|
|
33
40
|
//
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
const buttonStyles = 'min-bs-0 p-2';
|
|
43
|
+
const tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };
|
|
44
|
+
|
|
45
|
+
const ToolbarSeparator = () => <div role='separator' className='grow' />;
|
|
46
|
+
|
|
47
|
+
//
|
|
48
|
+
// ToolbarItem
|
|
49
|
+
//
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
type ToolbarItemProps =
|
|
52
|
+
| (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })
|
|
53
|
+
| (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })
|
|
54
|
+
| (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });
|
|
55
|
+
|
|
56
|
+
export const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {
|
|
57
|
+
const Invoker =
|
|
58
|
+
itemType === 'toggleGroupItem'
|
|
59
|
+
? NaturalToolbar.ToggleGroupItem
|
|
60
|
+
: itemType === 'toggle'
|
|
61
|
+
? NaturalToolbar.Toggle
|
|
62
|
+
: NaturalToolbar.Button;
|
|
63
|
+
return (
|
|
64
|
+
<Tooltip.Root>
|
|
65
|
+
<Tooltip.Trigger asChild>
|
|
66
|
+
{/* TODO(thure): type the props spread better. */}
|
|
67
|
+
<Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>
|
|
68
|
+
<Icon icon={icon} size={5} />
|
|
69
|
+
<span className='sr-only'>{children}</span>
|
|
70
|
+
</Invoker>
|
|
71
|
+
</Tooltip.Trigger>
|
|
72
|
+
<Tooltip.Portal>
|
|
73
|
+
<Tooltip.Content {...tooltipProps}>
|
|
74
|
+
{children}
|
|
75
|
+
<Tooltip.Arrow />
|
|
76
|
+
</Tooltip.Content>
|
|
77
|
+
</Tooltip.Portal>
|
|
78
|
+
</Tooltip.Root>
|
|
79
|
+
);
|
|
39
80
|
};
|
|
40
81
|
|
|
41
|
-
|
|
82
|
+
//
|
|
83
|
+
// Root
|
|
84
|
+
//
|
|
85
|
+
|
|
86
|
+
type AlignAction = { key: AlignKey; value: AlignValue };
|
|
87
|
+
type CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };
|
|
88
|
+
type StyleAction = { key: StyleKey; value: StyleValue };
|
|
89
|
+
|
|
90
|
+
export type ToolbarAction = StyleAction | AlignAction | CommentAction;
|
|
91
|
+
|
|
92
|
+
export type ToolbarActionType = ToolbarAction['key'];
|
|
93
|
+
|
|
94
|
+
export type ToolbarActionHandler = (action: ToolbarAction) => void;
|
|
42
95
|
|
|
43
96
|
export type ToolbarProps = ThemedClassName<
|
|
44
97
|
PropsWithChildren<{
|
|
45
|
-
|
|
98
|
+
role?: string;
|
|
46
99
|
}>
|
|
47
100
|
>;
|
|
48
101
|
|
|
49
|
-
const [ToolbarContextProvider, useToolbarContext] = createContext<
|
|
102
|
+
const [ToolbarContextProvider, useToolbarContext] = createContext<{ onAction: (action: ToolbarAction) => void }>(
|
|
103
|
+
'Toolbar',
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// TODO(Zan): Factor out, copied this from MarkdownPlugin.
|
|
107
|
+
const sectionToolbarLayout =
|
|
108
|
+
'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';
|
|
109
|
+
|
|
110
|
+
type Range = SheetType['ranges'][number];
|
|
111
|
+
|
|
112
|
+
const ToolbarRoot = ({ children, role, classNames }: ToolbarProps) => {
|
|
113
|
+
const { id, model, cursorFallbackRange, cursor } = useSheetContext();
|
|
114
|
+
const { hasAttention } = useAttention(id);
|
|
115
|
+
const dispatch = useIntentDispatcher();
|
|
116
|
+
|
|
117
|
+
// TODO(Zan): Externalize the toolbar action handler. E.g., Toolbar/keys should both fire events.
|
|
118
|
+
const handleAction = useCallback(
|
|
119
|
+
(action: ToolbarAction) => {
|
|
120
|
+
switch (action.key) {
|
|
121
|
+
case 'align':
|
|
122
|
+
if (cursor && cursorFallbackRange) {
|
|
123
|
+
const index = model.sheet.ranges?.findIndex(
|
|
124
|
+
(range) => range.key === action.key && inRange(rangeFromIndex(model.sheet, range.range), cursor),
|
|
125
|
+
);
|
|
126
|
+
const nextRangeEntity = {
|
|
127
|
+
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
128
|
+
key: action.key,
|
|
129
|
+
value: action.value,
|
|
130
|
+
};
|
|
131
|
+
if (index < 0) {
|
|
132
|
+
model.sheet.ranges?.push(nextRangeEntity);
|
|
133
|
+
} else {
|
|
134
|
+
model.sheet.ranges?.splice(index, 1, nextRangeEntity);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case 'style':
|
|
139
|
+
if (action.value === 'unset') {
|
|
140
|
+
const index = model.sheet.ranges?.findIndex((range) => range.key === action.key);
|
|
141
|
+
if (index >= 0) {
|
|
142
|
+
model.sheet.ranges?.splice(index, 1);
|
|
143
|
+
}
|
|
144
|
+
} else if (cursorFallbackRange) {
|
|
145
|
+
model.sheet.ranges?.push({
|
|
146
|
+
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
147
|
+
key: action.key,
|
|
148
|
+
value: action.value,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case 'comment': {
|
|
153
|
+
// TODO(Zan): We shouldn't hardcode the action ID.
|
|
154
|
+
if (cursorFallbackRange) {
|
|
155
|
+
void dispatch({
|
|
156
|
+
action: 'dxos.org/plugin/thread/action/create',
|
|
157
|
+
data: {
|
|
158
|
+
cursor: completeCellRangeToThreadCursor(cursorFallbackRange),
|
|
159
|
+
name: action.cellContent,
|
|
160
|
+
subject: model.sheet,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
[model.sheet, cursorFallbackRange, cursor, dispatch],
|
|
168
|
+
);
|
|
50
169
|
|
|
51
|
-
const ToolbarRoot = ({ children, onAction, classNames }: ToolbarProps) => {
|
|
52
170
|
return (
|
|
53
|
-
<ToolbarContextProvider onAction={
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
171
|
+
<ToolbarContextProvider onAction={handleAction}>
|
|
172
|
+
<NaturalToolbar.Root
|
|
173
|
+
classNames={[
|
|
174
|
+
...(role === 'section'
|
|
175
|
+
? ['z-[2] group-focus-within/section:visible', !hasAttention && 'invisible', sectionToolbarLayout]
|
|
176
|
+
: ['attention-surface']),
|
|
177
|
+
classNames,
|
|
178
|
+
]}
|
|
179
|
+
>
|
|
180
|
+
{children}
|
|
181
|
+
</NaturalToolbar.Root>
|
|
61
182
|
</ToolbarContextProvider>
|
|
62
183
|
);
|
|
63
184
|
};
|
|
64
185
|
|
|
65
186
|
// TODO(burdon): Generalize.
|
|
66
187
|
// TODO(burdon): Detect and display current state.
|
|
67
|
-
type ButtonProps = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
disabled?: (state: Formatting) => boolean;
|
|
188
|
+
type ButtonProps<T> = {
|
|
189
|
+
value: T;
|
|
190
|
+
icon: string;
|
|
191
|
+
disabled?: (state: Range) => boolean;
|
|
72
192
|
};
|
|
73
193
|
|
|
74
194
|
//
|
|
75
195
|
// Alignment
|
|
76
196
|
//
|
|
77
197
|
|
|
78
|
-
const
|
|
79
|
-
{
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const Format = () => {
|
|
84
|
-
const { onAction } = useToolbarContext('Format');
|
|
85
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<NaturalToolbar.ToggleGroup
|
|
89
|
-
type='single'
|
|
90
|
-
// value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}
|
|
91
|
-
>
|
|
92
|
-
{formatOptions.map(({ type, getState, Icon }) => (
|
|
93
|
-
<ToolbarToggleButton
|
|
94
|
-
key={type}
|
|
95
|
-
value={type}
|
|
96
|
-
Icon={Icon}
|
|
97
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
98
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
99
|
-
onClick={() => onAction?.({ type })}
|
|
100
|
-
>
|
|
101
|
-
{t(`toolbar ${type} label`)}
|
|
102
|
-
</ToolbarToggleButton>
|
|
103
|
-
))}
|
|
104
|
-
</NaturalToolbar.ToggleGroup>
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const alignmentOptions: ButtonProps[] = [
|
|
109
|
-
{ type: 'left', Icon: TextAlignLeft, getState: (state) => false },
|
|
110
|
-
{ type: 'center', Icon: TextAlignCenter, getState: (state) => false },
|
|
111
|
-
{ type: 'right', Icon: TextAlignRight, getState: (state) => false },
|
|
198
|
+
const alignmentOptions: ButtonProps<AlignValue>[] = [
|
|
199
|
+
{ value: 'start', icon: 'ph--text-align-left--regular' },
|
|
200
|
+
{ value: 'center', icon: 'ph--text-align-center--regular' },
|
|
201
|
+
{ value: 'end', icon: 'ph--text-align-right--regular' },
|
|
112
202
|
];
|
|
113
203
|
|
|
114
204
|
const Alignment = () => {
|
|
205
|
+
const { cursor, model } = useSheetContext();
|
|
115
206
|
const { onAction } = useToolbarContext('Alignment');
|
|
116
207
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
117
208
|
|
|
209
|
+
const value = useMemo(
|
|
210
|
+
() =>
|
|
211
|
+
cursor
|
|
212
|
+
? model.sheet.ranges?.find(
|
|
213
|
+
({ range, key }) => key === 'alignment' && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
214
|
+
)?.value
|
|
215
|
+
: undefined,
|
|
216
|
+
[cursor, model.sheet.ranges],
|
|
217
|
+
);
|
|
218
|
+
|
|
118
219
|
return (
|
|
119
220
|
<NaturalToolbar.ToggleGroup
|
|
120
221
|
type='single'
|
|
121
|
-
|
|
222
|
+
value={value}
|
|
223
|
+
onValueChange={(value: AlignValue) => onAction?.({ key: 'align', value })}
|
|
122
224
|
>
|
|
123
|
-
{alignmentOptions.map(({
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
Icon={Icon}
|
|
128
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
129
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
130
|
-
onClick={() => onAction?.({ type })}
|
|
131
|
-
>
|
|
132
|
-
{t(`toolbar ${type} label`)}
|
|
133
|
-
</ToolbarToggleButton>
|
|
225
|
+
{alignmentOptions.map(({ value, icon }) => (
|
|
226
|
+
<ToolbarItem itemType='toggleGroupItem' key={value} value={value} icon={icon}>
|
|
227
|
+
{t(`toolbar ${value} label`)}
|
|
228
|
+
</ToolbarItem>
|
|
134
229
|
))}
|
|
135
230
|
</NaturalToolbar.ToggleGroup>
|
|
136
231
|
);
|
|
137
232
|
};
|
|
138
233
|
|
|
139
|
-
const styleOptions: ButtonProps[] = [
|
|
140
|
-
{ type: 'clear', Icon: Eraser, getState: (state) => false },
|
|
141
|
-
{ type: 'highlight', Icon: HighlighterCircle, getState: (state) => false },
|
|
142
|
-
];
|
|
234
|
+
const styleOptions: ButtonProps<StyleValue>[] = [{ value: 'highlight', icon: 'ph--highlighter--regular' }];
|
|
143
235
|
|
|
144
236
|
const Styles = () => {
|
|
145
|
-
const {
|
|
237
|
+
const { cursor, model } = useSheetContext();
|
|
238
|
+
const { onAction } = useToolbarContext('Styles');
|
|
146
239
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
147
240
|
|
|
241
|
+
const activeValues = useMemo(
|
|
242
|
+
() =>
|
|
243
|
+
cursor
|
|
244
|
+
? model.sheet.ranges
|
|
245
|
+
?.filter(({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursor))
|
|
246
|
+
.reduce((acc, { value }) => {
|
|
247
|
+
acc.add(value);
|
|
248
|
+
return acc;
|
|
249
|
+
}, new Set())
|
|
250
|
+
: undefined,
|
|
251
|
+
[cursor, model.sheet.ranges],
|
|
252
|
+
);
|
|
253
|
+
|
|
148
254
|
return (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
Icon={Icon}
|
|
158
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
159
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
160
|
-
onClick={() => onAction?.({ type })}
|
|
255
|
+
<>
|
|
256
|
+
{styleOptions.map(({ value, icon }) => (
|
|
257
|
+
<ToolbarItem
|
|
258
|
+
itemType='toggle'
|
|
259
|
+
key={value}
|
|
260
|
+
pressed={activeValues?.has(value)}
|
|
261
|
+
onPressedChange={(nextPressed: boolean) => onAction?.({ key: 'style', value: nextPressed ? value : 'unset' })}
|
|
262
|
+
icon={icon}
|
|
161
263
|
>
|
|
162
|
-
{t(`toolbar ${
|
|
163
|
-
</
|
|
264
|
+
{t(`toolbar ${value} label`)}
|
|
265
|
+
</ToolbarItem>
|
|
164
266
|
))}
|
|
165
|
-
|
|
267
|
+
</>
|
|
166
268
|
);
|
|
167
269
|
};
|
|
168
270
|
|
|
@@ -171,18 +273,46 @@ const Styles = () => {
|
|
|
171
273
|
//
|
|
172
274
|
|
|
173
275
|
const Actions = () => {
|
|
174
|
-
|
|
276
|
+
const { onAction } = useToolbarContext('Actions');
|
|
277
|
+
const { cursorFallbackRange, cursor, model } = useSheetContext();
|
|
175
278
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
279
|
+
|
|
280
|
+
const overlapsCommentAnchor = (model.sheet.threads ?? [])
|
|
281
|
+
.filter(nonNullable)
|
|
282
|
+
.filter((thread) => thread.status !== 'resolved')
|
|
283
|
+
.some((thread) => {
|
|
284
|
+
if (!cursorFallbackRange) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
return rangeToIndex(model.sheet, cursorFallbackRange) === thread.anchor;
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const tooltipLabelKey = !cursor
|
|
291
|
+
? 'no cursor label'
|
|
292
|
+
: overlapsCommentAnchor
|
|
293
|
+
? 'selection overlaps existing comment label'
|
|
294
|
+
: 'comment label';
|
|
295
|
+
|
|
176
296
|
return (
|
|
177
|
-
<
|
|
297
|
+
<ToolbarItem
|
|
298
|
+
itemType='button'
|
|
178
299
|
value='comment'
|
|
179
|
-
|
|
300
|
+
icon='ph--chat-text--regular'
|
|
180
301
|
data-testid='editor.toolbar.comment'
|
|
181
|
-
|
|
182
|
-
|
|
302
|
+
onClick={() => {
|
|
303
|
+
if (!(cursorFallbackRange && cursor)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
return onAction?.({
|
|
307
|
+
key: 'comment',
|
|
308
|
+
value: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
309
|
+
cellContent: model.getCellText(cursor),
|
|
310
|
+
});
|
|
311
|
+
}}
|
|
312
|
+
disabled={!cursor || overlapsCommentAnchor}
|
|
183
313
|
>
|
|
184
|
-
{t(
|
|
185
|
-
</
|
|
314
|
+
{t(tooltipLabelKey)}
|
|
315
|
+
</ToolbarItem>
|
|
186
316
|
);
|
|
187
317
|
};
|
|
188
318
|
|
|
@@ -190,7 +320,6 @@ export const Toolbar = {
|
|
|
190
320
|
Root: ToolbarRoot,
|
|
191
321
|
Separator: ToolbarSeparator,
|
|
192
322
|
Alignment,
|
|
193
|
-
Format,
|
|
194
323
|
Styles,
|
|
195
324
|
Actions,
|
|
196
325
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { lazy } from 'react';
|
|
6
6
|
|
|
7
7
|
export * from './ComputeGraph';
|
|
8
|
+
export * from './GridSheet';
|
|
9
|
+
export * from './RangeList';
|
|
10
|
+
export * from './SheetContext';
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
export const SheetContainer = React.lazy(() => import('./SheetContainer'));
|
|
12
|
+
export const SheetContainer = lazy(() => import('./SheetContainer'));
|