@dxos/plugin-sheet 0.6.13-main.ed424a1 → 0.6.13
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-U4H5D34A.mjs +1772 -0
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-5WPZCXNS.mjs → browser/chunk-D5AGLXJP.mjs} +678 -411
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/chunk-FUAGSXA4.mjs +82 -0
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/browser/chunk-JRL5LGCE.mjs +18 -0
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -93
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +12 -6
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +1765 -0
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-5KKJ4NPP.cjs} +678 -418
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs +51 -0
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-DSYKOI4E.cjs} +51 -40
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +69 -105
- package/dist/lib/node/index.cjs.map +3 -3
- 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/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +15 -9
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +14 -0
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/SheetCellEditor.stories.d.ts → CellEditor/CellEditor.stories.d.ts} +4 -4
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/{extensions/editor → components/CellEditor}/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -0
- package/dist/types/src/components/CellEditor/extension.test.d.ts.map +1 -0
- package/dist/types/src/components/CellEditor/index.d.ts +3 -0
- package/dist/types/src/components/CellEditor/index.d.ts.map +1 -0
- package/dist/types/src/{graph/functions → components/ComputeGraph}/async-function.d.ts +5 -14
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts +21 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +20 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +55 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +54 -0
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +52 -0
- package/dist/types/src/components/Sheet/grid.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/Sheet/nav.d.ts +29 -0
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/sheet-context.d.ts +25 -0
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/util.d.ts +18 -0
- package/dist/types/src/components/Sheet/util.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +9 -0
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +9 -33
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +15 -19
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/common.d.ts +20 -0
- package/dist/types/src/components/Toolbar/common.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +9 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/functions/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +67 -13
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +40 -125
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +52 -58
- package/src/SheetPlugin.tsx +74 -52
- package/src/components/{GridSheet/SheetCellEditor.stories.tsx → CellEditor/CellEditor.stories.tsx} +8 -8
- package/src/components/CellEditor/CellEditor.tsx +113 -0
- package/src/{extensions/editor → components/CellEditor}/extension.test.ts +6 -4
- package/src/{extensions/editor → components/CellEditor}/extension.ts +6 -5
- package/src/{extensions/editor → components/CellEditor}/index.ts +1 -0
- package/src/{graph/functions → components/ComputeGraph}/async-function.ts +15 -25
- package/src/{graph/testing/test-plugin.ts → components/ComputeGraph/custom.ts} +14 -44
- package/src/{graph/functions → components/ComputeGraph}/edge-function.ts +14 -16
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +287 -0
- package/src/components/Sheet/Sheet.tsx +1160 -0
- package/src/components/Sheet/formatting.ts +106 -0
- package/src/components/Sheet/grid.ts +191 -0
- package/src/{testing → components/Sheet}/index.ts +1 -1
- package/src/components/Sheet/nav.ts +157 -0
- package/src/components/Sheet/sheet-context.tsx +150 -0
- package/src/components/Sheet/util.ts +56 -0
- package/src/components/SheetContainer.tsx +34 -0
- package/src/components/Toolbar/Toolbar.tsx +112 -242
- package/src/components/Toolbar/common.tsx +72 -0
- package/src/components/index.ts +0 -2
- package/src/meta.tsx +18 -0
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -24
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +47 -40
- package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs +0 -290
- package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs +0 -74
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-D3QTX46O.mjs +0 -14
- package/dist/lib/browser/chunk-D3QTX46O.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +0 -2966
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/browser/chunk-HOG37RYS.mjs +0 -1528
- package/dist/lib/browser/chunk-HOG37RYS.mjs.map +0 -7
- package/dist/lib/browser/graph-M4IQ76QX.mjs +0 -33
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-J7XROAMN.cjs +0 -300
- package/dist/lib/node/SheetContainer-J7XROAMN.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-AXQZA2YS.cjs +0 -1527
- package/dist/lib/node/chunk-AXQZA2YS.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/chunk-QIFIGEKV.cjs +0 -37
- package/dist/lib/node/chunk-QIFIGEKV.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs +0 -55
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs +0 -291
- package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs +0 -1529
- package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +0 -16
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs +0 -75
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +0 -34
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -280
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -17
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.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 -9
- 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 +0 -16
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -11
- 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 +0 -26
- 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/defs/index.d.ts +0 -4
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts +0 -13
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -6
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.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.map +0 -1
- package/dist/types/src/extensions/editor/index.d.ts +0 -2
- package/dist/types/src/extensions/editor/index.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -3
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -64
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -26
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts +0 -4
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -5
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts +0 -3
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -25
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.test.d.ts +0 -2
- package/dist/types/src/model/sheet-model.test.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -8
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +0 -45
- package/src/components/FunctionEditor/index.ts +0 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -41
- package/src/components/GridSheet/GridSheet.tsx +0 -163
- package/src/components/GridSheet/index.ts +0 -5
- package/src/components/GridSheet/util.ts +0 -158
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -40
- package/src/components/SheetContainer/SheetContainer.tsx +0 -27
- package/src/components/SheetContainer/index.ts +0 -7
- package/src/components/SheetContext/SheetContext.tsx +0 -104
- package/src/components/SheetContext/index.ts +0 -5
- package/src/defs/index.ts +0 -7
- package/src/defs/sheet-range-types.ts +0 -46
- package/src/defs/util.ts +0 -151
- package/src/extensions/compute.stories.tsx +0 -151
- package/src/extensions/compute.ts +0 -147
- package/src/extensions/index.ts +0 -6
- package/src/graph/compute-graph-registry.ts +0 -90
- package/src/graph/compute-graph.stories.tsx +0 -93
- package/src/graph/compute-graph.test.ts +0 -87
- package/src/graph/compute-graph.ts +0 -242
- package/src/graph/compute-node.ts +0 -63
- package/src/graph/functions/index.ts +0 -7
- package/src/graph/hyperformula.test.ts +0 -14
- package/src/graph/index.ts +0 -8
- package/src/graph/testing/index.ts +0 -6
- package/src/graph/testing/test-builder.ts +0 -54
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/hooks/useSheetModel.ts +0 -40
- package/src/meta.ts +0 -14
- package/src/model/decorations.ts +0 -64
- package/src/model/sheet-model.test.ts +0 -57
- package/src/model/sheet-model.ts +0 -418
- package/src/sanity.test.ts +0 -40
- package/src/testing/testing.tsx +0 -68
- /package/dist/types/src/{extensions/editor → components/CellEditor}/extension.test.d.ts +0 -0
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/functions/function-defs.ts → model/functions.ts} +0 -0
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
GridSheet,
|
|
4
|
-
SheetProvider,
|
|
5
|
-
addressToA1Notation,
|
|
6
|
-
addressToIndex,
|
|
7
|
-
inRange,
|
|
8
|
-
rangeToA1Notation,
|
|
9
|
-
useSheetContext
|
|
10
|
-
} from "./chunk-BPXXIAOQ.mjs";
|
|
11
|
-
import "./chunk-WFDTY3IC.mjs";
|
|
12
|
-
import {
|
|
13
|
-
SHEET_PLUGIN
|
|
14
|
-
} from "./chunk-VCYJWE3O.mjs";
|
|
15
|
-
import "./chunk-5WPZCXNS.mjs";
|
|
16
|
-
|
|
17
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer/SheetContainer.tsx
|
|
18
|
-
import React3 from "react";
|
|
19
|
-
|
|
20
|
-
// packages/plugins/plugin-sheet/src/components/FunctionEditor/FunctionEditor.tsx
|
|
21
|
-
import React from "react";
|
|
22
|
-
import { Icon } from "@dxos/react-ui";
|
|
23
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
24
|
-
var FunctionEditor = () => {
|
|
25
|
-
const { model, cursor, range } = useSheetContext();
|
|
26
|
-
let value;
|
|
27
|
-
let isFormula = false;
|
|
28
|
-
if (cursor) {
|
|
29
|
-
value = model.getCellValue(cursor);
|
|
30
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
31
|
-
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
32
|
-
isFormula = true;
|
|
33
|
-
} else if (value != null) {
|
|
34
|
-
value = String(value);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
38
|
-
className: mx("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-bs !border-separator attention-surface")
|
|
39
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
40
|
-
className: "flex gap-4 items-center"
|
|
41
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
42
|
-
className: "flex w-16 items-center font-mono"
|
|
43
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React.createElement("div", {
|
|
44
|
-
className: "flex gap-2 items-center"
|
|
45
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
46
|
-
icon: "ph--function--regular",
|
|
47
|
-
classNames: [
|
|
48
|
-
"text-greenText",
|
|
49
|
-
isFormula ? "visible" : "invisible"
|
|
50
|
-
]
|
|
51
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
52
|
-
className: "font-mono"
|
|
53
|
-
}, value))));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// packages/plugins/plugin-sheet/src/components/Toolbar/Toolbar.tsx
|
|
57
|
-
import { createContext } from "@radix-ui/react-context";
|
|
58
|
-
import React2, { useCallback, useMemo } from "react";
|
|
59
|
-
import { useIntentDispatcher } from "@dxos/app-framework";
|
|
60
|
-
import { Icon as Icon2, Toolbar as NaturalToolbar, useTranslation, Tooltip } from "@dxos/react-ui";
|
|
61
|
-
import { useAttention } from "@dxos/react-ui-attention";
|
|
62
|
-
import { nonNullable } from "@dxos/util";
|
|
63
|
-
var buttonStyles = "min-bs-0 p-2";
|
|
64
|
-
var tooltipProps = {
|
|
65
|
-
side: "bottom",
|
|
66
|
-
classNames: "z-10"
|
|
67
|
-
};
|
|
68
|
-
var ToolbarSeparator = () => /* @__PURE__ */ React2.createElement("div", {
|
|
69
|
-
role: "separator",
|
|
70
|
-
className: "grow"
|
|
71
|
-
});
|
|
72
|
-
var ToolbarItem = ({ itemType, icon, children, ...props }) => {
|
|
73
|
-
const Invoker = itemType === "toggleGroupItem" ? NaturalToolbar.ToggleGroupItem : itemType === "toggle" ? NaturalToolbar.Toggle : NaturalToolbar.Button;
|
|
74
|
-
return /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
75
|
-
asChild: true
|
|
76
|
-
}, /* @__PURE__ */ React2.createElement(Invoker, {
|
|
77
|
-
variant: "ghost",
|
|
78
|
-
...props,
|
|
79
|
-
classNames: buttonStyles
|
|
80
|
-
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
81
|
-
icon,
|
|
82
|
-
size: 5
|
|
83
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
84
|
-
className: "sr-only"
|
|
85
|
-
}, children))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, tooltipProps, children, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null))));
|
|
86
|
-
};
|
|
87
|
-
var [ToolbarContextProvider, useToolbarContext] = createContext("Toolbar");
|
|
88
|
-
var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
|
|
89
|
-
var ToolbarRoot = ({ children, role, classNames }) => {
|
|
90
|
-
const { id, model, range, cursor } = useSheetContext();
|
|
91
|
-
const { hasAttention } = useAttention(id);
|
|
92
|
-
const dispatch = useIntentDispatcher();
|
|
93
|
-
const handleAction = useCallback((action) => {
|
|
94
|
-
switch (action.key) {
|
|
95
|
-
case "align":
|
|
96
|
-
if (cursor) {
|
|
97
|
-
const index = model.sheet.ranges?.findIndex((range2) => range2.key === action.key && inRange(range2.range, cursor));
|
|
98
|
-
const nextRange = range ? {
|
|
99
|
-
from: range.from,
|
|
100
|
-
to: range.to ?? range.from
|
|
101
|
-
} : {
|
|
102
|
-
from: cursor,
|
|
103
|
-
to: cursor
|
|
104
|
-
};
|
|
105
|
-
const nextRangeEntity = {
|
|
106
|
-
range: nextRange,
|
|
107
|
-
key: action.key,
|
|
108
|
-
value: action.value
|
|
109
|
-
};
|
|
110
|
-
if (index < 0) {
|
|
111
|
-
model.sheet.ranges?.push(nextRangeEntity);
|
|
112
|
-
} else {
|
|
113
|
-
model.sheet.ranges?.splice(index, 1, nextRangeEntity);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
break;
|
|
117
|
-
case "style":
|
|
118
|
-
if (action.value === "unset") {
|
|
119
|
-
const index = model.sheet.ranges?.findIndex((range2) => range2.key === action.key);
|
|
120
|
-
if (index >= 0) {
|
|
121
|
-
model.sheet.ranges?.splice(index, 1);
|
|
122
|
-
}
|
|
123
|
-
} else if (range || cursor) {
|
|
124
|
-
const nextRange = range ? {
|
|
125
|
-
from: range.from,
|
|
126
|
-
to: range.to ?? range.from
|
|
127
|
-
} : {
|
|
128
|
-
from: cursor,
|
|
129
|
-
to: cursor
|
|
130
|
-
};
|
|
131
|
-
model.sheet.ranges?.push({
|
|
132
|
-
range: nextRange,
|
|
133
|
-
key: action.key,
|
|
134
|
-
value: action.value
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
case "comment": {
|
|
139
|
-
void dispatch({
|
|
140
|
-
action: "dxos.org/plugin/thread/action/create",
|
|
141
|
-
data: {
|
|
142
|
-
cursor: action.value,
|
|
143
|
-
name: action.cellContent,
|
|
144
|
-
subject: model.sheet
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}, [
|
|
150
|
-
model.sheet,
|
|
151
|
-
range,
|
|
152
|
-
cursor,
|
|
153
|
-
dispatch
|
|
154
|
-
]);
|
|
155
|
-
return /* @__PURE__ */ React2.createElement(ToolbarContextProvider, {
|
|
156
|
-
onAction: handleAction
|
|
157
|
-
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Root, {
|
|
158
|
-
classNames: [
|
|
159
|
-
...role === "section" ? [
|
|
160
|
-
"z-[2] group-focus-within/section:visible",
|
|
161
|
-
!hasAttention && "invisible",
|
|
162
|
-
sectionToolbarLayout
|
|
163
|
-
] : [
|
|
164
|
-
"attention-surface"
|
|
165
|
-
],
|
|
166
|
-
classNames
|
|
167
|
-
]
|
|
168
|
-
}, children));
|
|
169
|
-
};
|
|
170
|
-
var alignmentOptions = [
|
|
171
|
-
{
|
|
172
|
-
value: "start",
|
|
173
|
-
icon: "ph--text-align-left--regular"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
value: "center",
|
|
177
|
-
icon: "ph--text-align-center--regular"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
value: "end",
|
|
181
|
-
icon: "ph--text-align-right--regular"
|
|
182
|
-
}
|
|
183
|
-
];
|
|
184
|
-
var Alignment = () => {
|
|
185
|
-
const { cursor, model } = useSheetContext();
|
|
186
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
187
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
188
|
-
const value = useMemo(() => cursor ? model.sheet.ranges?.find(({ range, key }) => key === "alignment" && inRange(range, cursor))?.value : void 0, [
|
|
189
|
-
cursor,
|
|
190
|
-
model.sheet.ranges
|
|
191
|
-
]);
|
|
192
|
-
return /* @__PURE__ */ React2.createElement(NaturalToolbar.ToggleGroup, {
|
|
193
|
-
type: "single",
|
|
194
|
-
value,
|
|
195
|
-
onValueChange: (value2) => onAction?.({
|
|
196
|
-
key: "align",
|
|
197
|
-
value: value2
|
|
198
|
-
})
|
|
199
|
-
}, alignmentOptions.map(({ value: value2, icon }) => /* @__PURE__ */ React2.createElement(ToolbarItem, {
|
|
200
|
-
itemType: "toggleGroupItem",
|
|
201
|
-
key: value2,
|
|
202
|
-
value: value2,
|
|
203
|
-
icon
|
|
204
|
-
}, t(`toolbar ${value2} label`))));
|
|
205
|
-
};
|
|
206
|
-
var styleOptions = [
|
|
207
|
-
{
|
|
208
|
-
value: "highlight",
|
|
209
|
-
icon: "ph--highlighter--regular"
|
|
210
|
-
}
|
|
211
|
-
];
|
|
212
|
-
var Styles = () => {
|
|
213
|
-
const { cursor, model } = useSheetContext();
|
|
214
|
-
const { onAction } = useToolbarContext("Styles");
|
|
215
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
216
|
-
const activeValues = useMemo(() => cursor ? model.sheet.ranges?.filter(({ range, key }) => key === "style" && inRange(range, cursor)).reduce((acc, { value }) => {
|
|
217
|
-
acc.add(value);
|
|
218
|
-
return acc;
|
|
219
|
-
}, /* @__PURE__ */ new Set()) : void 0, [
|
|
220
|
-
cursor,
|
|
221
|
-
model.sheet.ranges
|
|
222
|
-
]);
|
|
223
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, styleOptions.map(({ value, icon }) => /* @__PURE__ */ React2.createElement(ToolbarItem, {
|
|
224
|
-
itemType: "toggle",
|
|
225
|
-
key: value,
|
|
226
|
-
pressed: activeValues?.has(value),
|
|
227
|
-
onPressedChange: (nextPressed) => onAction?.({
|
|
228
|
-
key: "style",
|
|
229
|
-
value: nextPressed ? value : "unset"
|
|
230
|
-
}),
|
|
231
|
-
icon
|
|
232
|
-
}, t(`toolbar ${value} label`))));
|
|
233
|
-
};
|
|
234
|
-
var Actions = () => {
|
|
235
|
-
const { onAction } = useToolbarContext("Actions");
|
|
236
|
-
const { cursor, range, model } = useSheetContext();
|
|
237
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
238
|
-
const overlapsCommentAnchor = (model.sheet.threads ?? []).filter(nonNullable).filter((thread) => thread.status !== "resolved").some((thread) => {
|
|
239
|
-
if (!cursor) {
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
return addressToIndex(model.sheet, cursor) === thread.anchor;
|
|
243
|
-
});
|
|
244
|
-
const hasCursor = !!cursor;
|
|
245
|
-
const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;
|
|
246
|
-
const tooltipLabelKey = !hasCursor ? "no cursor label" : overlapsCommentAnchor ? "selection overlaps existing comment label" : range ? "comment ranges not supported label" : "comment label";
|
|
247
|
-
return /* @__PURE__ */ React2.createElement(ToolbarItem, {
|
|
248
|
-
itemType: "button",
|
|
249
|
-
value: "comment",
|
|
250
|
-
icon: "ph--chat-text--regular",
|
|
251
|
-
"data-testid": "editor.toolbar.comment",
|
|
252
|
-
onClick: () => {
|
|
253
|
-
if (!cursor) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
return onAction?.({
|
|
257
|
-
key: "comment",
|
|
258
|
-
value: addressToIndex(model.sheet, cursor),
|
|
259
|
-
cellContent: model.getCellText(cursor)
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
disabled: !cursorOnly || overlapsCommentAnchor
|
|
263
|
-
}, t(tooltipLabelKey));
|
|
264
|
-
};
|
|
265
|
-
var Toolbar = {
|
|
266
|
-
Root: ToolbarRoot,
|
|
267
|
-
Separator: ToolbarSeparator,
|
|
268
|
-
Alignment,
|
|
269
|
-
Styles,
|
|
270
|
-
Actions
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer/SheetContainer.tsx
|
|
274
|
-
var SheetContainer = ({ graph, sheet, role }) => {
|
|
275
|
-
return /* @__PURE__ */ React3.createElement(SheetProvider, {
|
|
276
|
-
sheet,
|
|
277
|
-
graph
|
|
278
|
-
}, /* @__PURE__ */ React3.createElement(Toolbar.Root, {
|
|
279
|
-
role
|
|
280
|
-
}, /* @__PURE__ */ React3.createElement(Toolbar.Styles, null), /* @__PURE__ */ React3.createElement(Toolbar.Alignment, null), /* @__PURE__ */ React3.createElement(Toolbar.Separator, null), /* @__PURE__ */ React3.createElement(Toolbar.Actions, null)), /* @__PURE__ */ React3.createElement("div", {
|
|
281
|
-
role: "none",
|
|
282
|
-
className: "border-bs border-separator grid cols-1 rows-[1fr_min-content] min-bs-0"
|
|
283
|
-
}, /* @__PURE__ */ React3.createElement(GridSheet, null), /* @__PURE__ */ React3.createElement(FunctionEditor, null)));
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer/index.ts
|
|
287
|
-
var SheetContainer_default = SheetContainer;
|
|
288
|
-
export {
|
|
289
|
-
SheetContainer_default as default
|
|
290
|
-
};
|
|
291
|
-
//# sourceMappingURL=SheetContainer-YWQVKHQB.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/SheetContainer/SheetContainer.tsx", "../../../src/components/FunctionEditor/FunctionEditor.tsx", "../../../src/components/Toolbar/Toolbar.tsx", "../../../src/components/SheetContainer/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { FunctionEditor } from '../FunctionEditor';\nimport { GridSheet } from '../GridSheet';\nimport { SheetProvider, type SheetProviderProps } from '../SheetContext';\nimport { Toolbar } from '../Toolbar';\n\nexport const SheetContainer = ({ graph, sheet, role }: SheetProviderProps & { role?: string }) => {\n return (\n <SheetProvider sheet={sheet} graph={graph}>\n <Toolbar.Root role={role}>\n <Toolbar.Styles />\n <Toolbar.Alignment />\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n <div role='none' className='border-bs border-separator grid cols-1 rows-[1fr_min-content] min-bs-0'>\n <GridSheet />\n <FunctionEditor />\n </div>\n </SheetProvider>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Icon } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { addressToA1Notation, rangeToA1Notation } from '../../defs';\nimport { useSheetContext } from '../SheetContext';\n\nexport const FunctionEditor = () => {\n const { model, cursor, range } = useSheetContext();\n\n let value;\n let isFormula = false;\n if (cursor) {\n value = model.getCellValue(cursor);\n if (typeof value === 'string' && value.charAt(0) === '=') {\n value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));\n isFormula = true;\n } else if (value != null) {\n value = String(value);\n }\n }\n\n return (\n <div\n className={mx(\n 'flex shrink-0 justify-between items-center px-4 py-1 text-sm border-bs !border-separator attention-surface',\n )}\n >\n <div className='flex gap-4 items-center'>\n <div className='flex w-16 items-center font-mono'>\n {(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}\n </div>\n <div className='flex gap-2 items-center'>\n <Icon icon='ph--function--regular' classNames={['text-greenText', isFormula ? 'visible' : 'invisible']} />\n <span className='font-mono'>{value}</span>\n </div>\n </div>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren, useCallback, useMemo } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport {\n Icon,\n Toolbar as NaturalToolbar,\n useTranslation,\n Tooltip,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleProps as NaturalToolbarToggleProps,\n type ThemedClassName,\n} from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { nonNullable } from '@dxos/util';\n\nimport {\n addressToIndex,\n type AlignKey,\n type AlignValue,\n type CommentKey,\n type CommentValue,\n inRange,\n type StyleKey,\n type StyleValue,\n} from '../../defs';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type SheetType } from '../../types';\nimport { useSheetContext } from '../SheetContext';\n\n//\n// Buttons\n//\n\nconst buttonStyles = 'min-bs-0 p-2';\nconst tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };\n\nconst ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarItem\n//\n\ntype ToolbarItemProps =\n | (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })\n | (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })\n | (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });\n\nexport const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {\n const Invoker =\n itemType === 'toggleGroupItem'\n ? NaturalToolbar.ToggleGroupItem\n : itemType === 'toggle'\n ? NaturalToolbar.Toggle\n : NaturalToolbar.Button;\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n {/* TODO(thure): type the props spread better. */}\n <Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>\n <Icon icon={icon} size={5} />\n <span className='sr-only'>{children}</span>\n </Invoker>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n\n//\n// Root\n//\n\ntype AlignAction = { key: AlignKey; value: AlignValue };\ntype CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };\ntype StyleAction = { key: StyleKey; value: StyleValue };\n\nexport type ToolbarAction = StyleAction | AlignAction | CommentAction;\n\nexport type ToolbarActionType = ToolbarAction['key'];\n\nexport type ToolbarActionHandler = (action: ToolbarAction) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n role?: string;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<{ onAction: (action: ToolbarAction) => void }>(\n 'Toolbar',\n);\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nconst sectionToolbarLayout =\n 'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';\n\ntype Range = SheetType['ranges'][number];\n\nconst ToolbarRoot = ({ children, role, classNames }: ToolbarProps) => {\n const { id, model, range, cursor } = useSheetContext();\n const { hasAttention } = useAttention(id);\n const dispatch = useIntentDispatcher();\n\n // TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.\n const handleAction = useCallback(\n (action: ToolbarAction) => {\n switch (action.key) {\n case 'align':\n if (cursor) {\n const index = model.sheet.ranges?.findIndex(\n (range) => range.key === action.key && inRange(range.range, cursor),\n );\n const nextRange = range ? { from: range.from, to: range.to ?? range.from } : { from: cursor, to: cursor };\n const nextRangeEntity = {\n range: nextRange as Range['range'],\n key: action.key,\n value: action.value,\n };\n if (index < 0) {\n model.sheet.ranges?.push(nextRangeEntity);\n } else {\n model.sheet.ranges?.splice(index, 1, nextRangeEntity);\n }\n }\n break;\n case 'style':\n if (action.value === 'unset') {\n const index = model.sheet.ranges?.findIndex((range) => range.key === action.key);\n if (index >= 0) {\n model.sheet.ranges?.splice(index, 1);\n }\n } else if (range || cursor) {\n const nextRange = range ? { from: range.from, to: range.to ?? range.from } : { from: cursor, to: cursor };\n model.sheet.ranges?.push({\n range: nextRange as Range['range'],\n key: action.key,\n value: action.value,\n });\n }\n break;\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: action.value,\n name: action.cellContent,\n subject: model.sheet,\n },\n });\n }\n }\n },\n [model.sheet, range, cursor, dispatch],\n );\n\n return (\n <ToolbarContextProvider onAction={handleAction}>\n <NaturalToolbar.Root\n classNames={[\n ...(role === 'section'\n ? ['z-[2] group-focus-within/section:visible', !hasAttention && 'invisible', sectionToolbarLayout]\n : ['attention-surface']),\n classNames,\n ]}\n >\n {children}\n </NaturalToolbar.Root>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps<T> = {\n value: T;\n icon: string;\n disabled?: (state: Range) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst alignmentOptions: ButtonProps<AlignValue>[] = [\n { value: 'start', icon: 'ph--text-align-left--regular' },\n { value: 'center', icon: 'ph--text-align-center--regular' },\n { value: 'end', icon: 'ph--text-align-right--regular' },\n];\n\nconst Alignment = () => {\n const { cursor, model } = useSheetContext();\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const value = useMemo(\n () =>\n cursor\n ? model.sheet.ranges?.find(({ range, key }) => key === 'alignment' && inRange(range, cursor))?.value\n : undefined,\n [cursor, model.sheet.ranges],\n );\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n value={value}\n onValueChange={(value: AlignValue) => onAction?.({ key: 'align', value })}\n >\n {alignmentOptions.map(({ value, icon }) => (\n <ToolbarItem itemType='toggleGroupItem' key={value} value={value} icon={icon}>\n {t(`toolbar ${value} label`)}\n </ToolbarItem>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps<StyleValue>[] = [{ value: 'highlight', icon: 'ph--highlighter--regular' }];\n\nconst Styles = () => {\n const { cursor, model } = useSheetContext();\n const { onAction } = useToolbarContext('Styles');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const activeValues = useMemo(\n () =>\n cursor\n ? model.sheet.ranges\n ?.filter(({ range, key }) => key === 'style' && inRange(range, cursor))\n .reduce((acc, { value }) => {\n acc.add(value);\n return acc;\n }, new Set())\n : undefined,\n [cursor, model.sheet.ranges],\n );\n\n return (\n <>\n {styleOptions.map(({ value, icon }) => (\n <ToolbarItem\n itemType='toggle'\n key={value}\n pressed={activeValues?.has(value)}\n onPressedChange={(nextPressed: boolean) => onAction?.({ key: 'style', value: nextPressed ? value : 'unset' })}\n icon={icon}\n >\n {t(`toolbar ${value} label`)}\n </ToolbarItem>\n ))}\n </>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursor, range, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursor) {\n return false;\n }\n return addressToIndex(model.sheet, cursor) === thread.anchor;\n });\n\n const hasCursor = !!cursor;\n const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;\n\n const tooltipLabelKey = !hasCursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : range\n ? 'comment ranges not supported label'\n : 'comment label';\n\n return (\n <ToolbarItem\n itemType='button'\n value='comment'\n icon='ph--chat-text--regular'\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursor) {\n return;\n }\n return onAction?.({\n key: 'comment',\n value: addressToIndex(model.sheet, cursor),\n cellContent: model.getCellText(cursor),\n });\n }}\n disabled={!cursorOnly || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarItem>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SheetContainer } from './SheetContainer';\n\nexport default SheetContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAIA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAElB,SAASC,YAAY;AACrB,SAASC,UAAU;AAKZ,IAAMC,iBAAiB,MAA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AAMa,OAAOX,MAAAA;QACnCwB,aAAa1B,MAAMmE,YAAYjE,MAAAA;MACjC,CAAA;IACF;IACAkE,UAAU,CAACL,cAAcT;KAExBvB,EAAEiC,eAAAA,CAAAA;AAGT;AAEO,IAAMK,UAAU;EACrBrF,MAAMc;EACNwE,WAAWtG;EACX8D;EACAY;EACAW;AACF;;;AF1TO,IAAMkB,iBAAiB,CAAC,EAAEC,OAAOC,OAAOC,KAAI,MAA0C;AAC3F,SACE,gBAAAC,OAAA,cAACC,eAAAA;IAAcH;IAAcD;KAC3B,gBAAAG,OAAA,cAACE,QAAQC,MAAI;IAACJ;KACZ,gBAAAC,OAAA,cAACE,QAAQE,QAAM,IAAA,GACf,gBAAAJ,OAAA,cAACE,QAAQG,WAAS,IAAA,GAClB,gBAAAL,OAAA,cAACE,QAAQI,WAAS,IAAA,GAClB,gBAAAN,OAAA,cAACE,QAAQK,SAAO,IAAA,CAAA,GAElB,gBAAAP,OAAA,cAACQ,OAAAA;IAAIT,MAAK;IAAOU,WAAU;KACzB,gBAAAT,OAAA,cAACU,WAAAA,IAAAA,GACD,gBAAAV,OAAA,cAACW,gBAAAA,IAAAA,CAAAA,CAAAA;AAIT;;;AGpBA,IAAA,yBAAeC;",
|
|
6
|
-
"names": ["React", "React", "Icon", "mx", "FunctionEditor", "model", "cursor", "range", "useSheetContext", "value", "isFormula", "getCellValue", "charAt", "graph", "mapFunctionBindingFromId", "mapFormulaIndicesToRefs", "String", "div", "className", "mx", "rangeToA1Notation", "addressToA1Notation", "Icon", "icon", "classNames", "span", "createContext", "React", "useCallback", "useMemo", "useIntentDispatcher", "Icon", "Toolbar", "NaturalToolbar", "useTranslation", "Tooltip", "useAttention", "nonNullable", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "React", "div", "role", "className", "ToolbarItem", "itemType", "icon", "children", "props", "Invoker", "NaturalToolbar", "ToggleGroupItem", "Toggle", "Button", "Tooltip", "Root", "Trigger", "asChild", "variant", "Icon", "size", "span", "Portal", "Content", "Arrow", "ToolbarContextProvider", "useToolbarContext", "createContext", "sectionToolbarLayout", "ToolbarRoot", "id", "model", "range", "cursor", "useSheetContext", "hasAttention", "useAttention", "dispatch", "useIntentDispatcher", "handleAction", "useCallback", "action", "key", "index", "sheet", "ranges", "findIndex", "inRange", "nextRange", "from", "to", "nextRangeEntity", "value", "push", "splice", "data", "name", "cellContent", "subject", "onAction", "alignmentOptions", "Alignment", "t", "useTranslation", "SHEET_PLUGIN", "useMemo", "find", "undefined", "ToggleGroup", "type", "onValueChange", "map", "styleOptions", "Styles", "activeValues", "filter", "reduce", "acc", "add", "Set", "pressed", "has", "onPressedChange", "nextPressed", "Actions", "overlapsCommentAnchor", "threads", "nonNullable", "thread", "status", "some", "addressToIndex", "anchor", "hasCursor", "cursorOnly", "tooltipLabelKey", "data-testid", "onClick", "getCellText", "disabled", "Toolbar", "Separator", "SheetContainer", "graph", "sheet", "role", "React", "SheetProvider", "Toolbar", "Root", "Styles", "Alignment", "Separator", "Actions", "div", "className", "GridSheet", "FunctionEditor", "SheetContainer"]
|
|
7
|
-
}
|