@dxos/plugin-sheet 0.6.13-main.548ca8d → 0.6.13-staging.1e988a3
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 +10 -4
- 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-ER3PM7GD.cjs → chunk-DSYKOI4E.cjs} +45 -29
- 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 +14 -8
- 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 +6 -36
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +14 -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 -3
- 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 +32 -98
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +52 -57
- 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/{model/formatting-model.ts → components/Sheet/formatting.ts} +20 -30
- 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 +85 -167
- 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 -3
- 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 +41 -40
- package/dist/lib/browser/SheetContainer-NDNIS44E.mjs +0 -265
- package/dist/lib/browser/SheetContainer-NDNIS44E.mjs.map +0 -7
- package/dist/lib/browser/chunk-AQSGDA4X.mjs +0 -1614
- package/dist/lib/browser/chunk-AQSGDA4X.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-GKI67SEF.mjs +0 -69
- package/dist/lib/browser/chunk-GKI67SEF.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/graph-M4IQ76QX.mjs +0 -33
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-YSQGJD7K.cjs +0 -276
- package/dist/lib/node/SheetContainer-YSQGJD7K.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-6F43RV45.cjs +0 -1610
- package/dist/lib/node/chunk-6F43RV45.cjs.map +0 -7
- package/dist/lib/node/chunk-ER3PM7GD.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-M7WRMZDU.mjs +0 -266
- package/dist/lib/node-esm/SheetContainer-M7WRMZDU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ELTFPX5B.mjs +0 -1615
- package/dist/lib/node-esm/chunk-ELTFPX5B.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-ZVLLQ2PJ.mjs +0 -70
- package/dist/lib/node-esm/chunk-ZVLLQ2PJ.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 -27
- 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 -3
- package/dist/types/src/defs/index.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 -5
- 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/useFormattingModel.d.ts +0 -3
- package/dist/types/src/hooks/useFormattingModel.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/formatting-model.d.ts +0 -19
- package/dist/types/src/model/formatting-model.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 -161
- package/src/components/GridSheet/index.ts +0 -5
- package/src/components/GridSheet/util.ts +0 -144
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -40
- package/src/components/SheetContainer/SheetContainer.tsx +0 -52
- package/src/components/SheetContainer/index.ts +0 -7
- package/src/components/SheetContext/SheetContext.tsx +0 -108
- package/src/components/SheetContext/index.ts +0 -5
- package/src/defs/index.ts +0 -6
- 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 -8
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/hooks/useFormattingModel.ts +0 -11
- 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
|
@@ -2,130 +2,71 @@
|
|
|
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';
|
|
5
16
|
import { createContext } from '@radix-ui/react-context';
|
|
6
17
|
import React, { type PropsWithChildren } from 'react';
|
|
7
18
|
|
|
8
19
|
import {
|
|
9
|
-
|
|
20
|
+
DensityProvider,
|
|
21
|
+
ElevationProvider,
|
|
10
22
|
Toolbar as NaturalToolbar,
|
|
11
|
-
useTranslation,
|
|
12
|
-
Tooltip,
|
|
13
|
-
type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,
|
|
14
|
-
type ToolbarButtonProps as NaturalToolbarButtonProps,
|
|
15
|
-
type ToolbarToggleProps as NaturalToolbarToggleProps,
|
|
16
23
|
type ThemedClassName,
|
|
24
|
+
useTranslation,
|
|
17
25
|
} from '@dxos/react-ui';
|
|
18
|
-
import { useAttention } from '@dxos/react-ui-attention';
|
|
19
|
-
import { nonNullable } from '@dxos/util';
|
|
20
26
|
|
|
21
|
-
import {
|
|
27
|
+
import { ToolbarButton, ToolbarSeparator, ToolbarToggleButton } from './common';
|
|
22
28
|
import { SHEET_PLUGIN } from '../../meta';
|
|
23
29
|
import { type Formatting } from '../../types';
|
|
24
|
-
import { useSheetContext } from '../SheetContext';
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
// Buttons
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
const buttonStyles = 'min-bs-0 p-2';
|
|
31
|
-
const tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };
|
|
32
|
-
|
|
33
|
-
const ToolbarSeparator = () => <div role='separator' className='grow' />;
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
// ToolbarItem
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
type ToolbarItemProps =
|
|
40
|
-
| (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })
|
|
41
|
-
| (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })
|
|
42
|
-
| (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });
|
|
43
|
-
|
|
44
|
-
export const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {
|
|
45
|
-
const Invoker =
|
|
46
|
-
itemType === 'toggleGroupItem'
|
|
47
|
-
? NaturalToolbar.ToggleGroupItem
|
|
48
|
-
: itemType === 'toggle'
|
|
49
|
-
? NaturalToolbar.Toggle
|
|
50
|
-
: NaturalToolbar.Button;
|
|
51
|
-
return (
|
|
52
|
-
<Tooltip.Root>
|
|
53
|
-
<Tooltip.Trigger asChild>
|
|
54
|
-
{/* TODO(thure): type the props spread better. */}
|
|
55
|
-
<Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>
|
|
56
|
-
<Icon icon={icon} size={5} />
|
|
57
|
-
<span className='sr-only'>{children}</span>
|
|
58
|
-
</Invoker>
|
|
59
|
-
</Tooltip.Trigger>
|
|
60
|
-
<Tooltip.Portal>
|
|
61
|
-
<Tooltip.Content {...tooltipProps}>
|
|
62
|
-
{children}
|
|
63
|
-
<Tooltip.Arrow />
|
|
64
|
-
</Tooltip.Content>
|
|
65
|
-
</Tooltip.Portal>
|
|
66
|
-
</Tooltip.Root>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
30
|
|
|
70
31
|
//
|
|
71
32
|
// Root
|
|
72
33
|
//
|
|
73
34
|
|
|
74
|
-
type
|
|
75
|
-
type AlignAction = { type: 'align'; value: AlignValue };
|
|
76
|
-
|
|
77
|
-
type CommentAction = { type: 'comment'; anchor: string; cellContent?: string };
|
|
35
|
+
export type ToolbarActionType = 'clear' | 'highlight' | 'left' | 'center' | 'right' | 'date' | 'currency';
|
|
78
36
|
|
|
79
|
-
type
|
|
80
|
-
type
|
|
81
|
-
|
|
82
|
-
type StyleValue = 'highlight' | 'unset';
|
|
83
|
-
type StyleAction = { type: 'style'; value: StyleValue };
|
|
84
|
-
|
|
85
|
-
export type ToolbarAction = StyleAction | AlignAction | FormatAction | CommentAction;
|
|
86
|
-
|
|
87
|
-
export type ToolbarActionType = ToolbarAction['type'];
|
|
37
|
+
export type ToolbarAction = {
|
|
38
|
+
type: ToolbarActionType;
|
|
39
|
+
};
|
|
88
40
|
|
|
89
|
-
export type ToolbarActionHandler = (
|
|
41
|
+
export type ToolbarActionHandler = ({ type }: ToolbarAction) => void;
|
|
90
42
|
|
|
91
43
|
export type ToolbarProps = ThemedClassName<
|
|
92
44
|
PropsWithChildren<{
|
|
93
45
|
onAction?: ToolbarActionHandler;
|
|
94
|
-
role?: string;
|
|
95
46
|
}>
|
|
96
47
|
>;
|
|
97
48
|
|
|
98
49
|
const [ToolbarContextProvider, useToolbarContext] = createContext<ToolbarProps>('Toolbar');
|
|
99
50
|
|
|
100
|
-
|
|
101
|
-
const sectionToolbarLayout =
|
|
102
|
-
'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';
|
|
103
|
-
|
|
104
|
-
const ToolbarRoot = ({ children, onAction, role, classNames }: ToolbarProps) => {
|
|
105
|
-
const { id } = useSheetContext();
|
|
106
|
-
const { hasAttention } = useAttention(id);
|
|
107
|
-
|
|
51
|
+
const ToolbarRoot = ({ children, onAction, classNames }: ToolbarProps) => {
|
|
108
52
|
return (
|
|
109
53
|
<ToolbarContextProvider onAction={onAction}>
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
>
|
|
118
|
-
{children}
|
|
119
|
-
</NaturalToolbar.Root>
|
|
54
|
+
<DensityProvider density='fine'>
|
|
55
|
+
<ElevationProvider elevation='chrome'>
|
|
56
|
+
<NaturalToolbar.Root classNames={['is-full shrink-0 overflow-x-auto overflow-y-hidden p-1', classNames]}>
|
|
57
|
+
{children}
|
|
58
|
+
</NaturalToolbar.Root>
|
|
59
|
+
</ElevationProvider>
|
|
60
|
+
</DensityProvider>
|
|
120
61
|
</ToolbarContextProvider>
|
|
121
62
|
);
|
|
122
63
|
};
|
|
123
64
|
|
|
124
65
|
// TODO(burdon): Generalize.
|
|
125
66
|
// TODO(burdon): Detect and display current state.
|
|
126
|
-
type ButtonProps
|
|
127
|
-
|
|
128
|
-
|
|
67
|
+
type ButtonProps = {
|
|
68
|
+
type: ToolbarActionType;
|
|
69
|
+
Icon: Icon;
|
|
129
70
|
getState: (state: Formatting) => boolean;
|
|
130
71
|
disabled?: (state: Formatting) => boolean;
|
|
131
72
|
};
|
|
@@ -134,9 +75,9 @@ type ButtonProps<T> = {
|
|
|
134
75
|
// Alignment
|
|
135
76
|
//
|
|
136
77
|
|
|
137
|
-
const formatOptions: ButtonProps
|
|
138
|
-
{
|
|
139
|
-
{
|
|
78
|
+
const formatOptions: ButtonProps[] = [
|
|
79
|
+
{ type: 'date', Icon: Calendar, getState: (state) => false },
|
|
80
|
+
{ type: 'currency', Icon: CurrencyDollar, getState: (state) => false },
|
|
140
81
|
];
|
|
141
82
|
|
|
142
83
|
const Format = () => {
|
|
@@ -148,25 +89,26 @@ const Format = () => {
|
|
|
148
89
|
type='single'
|
|
149
90
|
// value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}
|
|
150
91
|
>
|
|
151
|
-
{formatOptions.map(({
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
onClick={() => onAction?.({ type:
|
|
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 })}
|
|
158
100
|
>
|
|
159
|
-
{t(`toolbar ${
|
|
160
|
-
</
|
|
101
|
+
{t(`toolbar ${type} label`)}
|
|
102
|
+
</ToolbarToggleButton>
|
|
161
103
|
))}
|
|
162
104
|
</NaturalToolbar.ToggleGroup>
|
|
163
105
|
);
|
|
164
106
|
};
|
|
165
107
|
|
|
166
|
-
const alignmentOptions: ButtonProps
|
|
167
|
-
{
|
|
168
|
-
{
|
|
169
|
-
{
|
|
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 },
|
|
170
112
|
];
|
|
171
113
|
|
|
172
114
|
const Alignment = () => {
|
|
@@ -177,41 +119,50 @@ const Alignment = () => {
|
|
|
177
119
|
<NaturalToolbar.ToggleGroup
|
|
178
120
|
type='single'
|
|
179
121
|
// value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}
|
|
180
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
181
|
-
onValueChange={(value: AlignValue) => onAction?.({ type: 'align', value })}
|
|
182
122
|
>
|
|
183
|
-
{alignmentOptions.map(({
|
|
184
|
-
<
|
|
185
|
-
{
|
|
186
|
-
|
|
123
|
+
{alignmentOptions.map(({ type, getState, Icon }) => (
|
|
124
|
+
<ToolbarToggleButton
|
|
125
|
+
key={type}
|
|
126
|
+
value={type}
|
|
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>
|
|
187
134
|
))}
|
|
188
135
|
</NaturalToolbar.ToggleGroup>
|
|
189
136
|
);
|
|
190
137
|
};
|
|
191
138
|
|
|
192
|
-
const styleOptions: ButtonProps
|
|
193
|
-
{
|
|
139
|
+
const styleOptions: ButtonProps[] = [
|
|
140
|
+
{ type: 'clear', Icon: Eraser, getState: (state) => false },
|
|
141
|
+
{ type: 'highlight', Icon: HighlighterCircle, getState: (state) => false },
|
|
194
142
|
];
|
|
195
143
|
|
|
196
144
|
const Styles = () => {
|
|
197
|
-
const { onAction } = useToolbarContext('
|
|
145
|
+
const { onAction } = useToolbarContext('Alignment');
|
|
198
146
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
199
147
|
|
|
200
148
|
return (
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
149
|
+
<NaturalToolbar.ToggleGroup
|
|
150
|
+
type='single'
|
|
151
|
+
// value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}
|
|
152
|
+
>
|
|
153
|
+
{styleOptions.map(({ type, getState, Icon }) => (
|
|
154
|
+
<ToolbarToggleButton
|
|
155
|
+
key={type}
|
|
156
|
+
value={type}
|
|
157
|
+
Icon={Icon}
|
|
158
|
+
// disabled={state?.blockType === 'codeblock'}
|
|
159
|
+
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
160
|
+
onClick={() => onAction?.({ type })}
|
|
210
161
|
>
|
|
211
|
-
{t(`toolbar ${
|
|
212
|
-
</
|
|
162
|
+
{t(`toolbar ${type} label`)}
|
|
163
|
+
</ToolbarToggleButton>
|
|
213
164
|
))}
|
|
214
|
-
|
|
165
|
+
</NaturalToolbar.ToggleGroup>
|
|
215
166
|
);
|
|
216
167
|
};
|
|
217
168
|
|
|
@@ -220,51 +171,18 @@ const Styles = () => {
|
|
|
220
171
|
//
|
|
221
172
|
|
|
222
173
|
const Actions = () => {
|
|
223
|
-
const { onAction } = useToolbarContext('Actions');
|
|
224
|
-
const { cursor, range, model } = useSheetContext();
|
|
174
|
+
// const { onAction } = useToolbarContext('Actions');
|
|
225
175
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
226
|
-
|
|
227
|
-
const overlapsCommentAnchor = (model.sheet.threads ?? [])
|
|
228
|
-
.filter(nonNullable)
|
|
229
|
-
.filter((thread) => thread.status !== 'resolved')
|
|
230
|
-
.some((thread) => {
|
|
231
|
-
if (!cursor) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
return addressToIndex(model.sheet, cursor) === thread.anchor;
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
const hasCursor = !!cursor;
|
|
238
|
-
const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;
|
|
239
|
-
|
|
240
|
-
const tooltipLabelKey = !hasCursor
|
|
241
|
-
? 'no cursor label'
|
|
242
|
-
: overlapsCommentAnchor
|
|
243
|
-
? 'selection overlaps existing comment label'
|
|
244
|
-
: range
|
|
245
|
-
? 'comment ranges not supported label'
|
|
246
|
-
: 'comment label';
|
|
247
|
-
|
|
248
176
|
return (
|
|
249
|
-
<
|
|
250
|
-
itemType='button'
|
|
177
|
+
<ToolbarButton
|
|
251
178
|
value='comment'
|
|
252
|
-
|
|
179
|
+
Icon={ChatText}
|
|
253
180
|
data-testid='editor.toolbar.comment'
|
|
254
|
-
onClick={() => {
|
|
255
|
-
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
return onAction?.({
|
|
259
|
-
type: 'comment',
|
|
260
|
-
anchor: addressToIndex(model.sheet, cursor),
|
|
261
|
-
cellContent: model.getCellText(cursor),
|
|
262
|
-
});
|
|
263
|
-
}}
|
|
264
|
-
disabled={!cursorOnly || overlapsCommentAnchor}
|
|
181
|
+
// onClick={() => onAction?.({ type: 'comment' })}
|
|
182
|
+
// disabled={!state || state.comment || !state.selection}
|
|
265
183
|
>
|
|
266
|
-
{t(
|
|
267
|
-
</
|
|
184
|
+
{t('comment label')}
|
|
185
|
+
</ToolbarButton>
|
|
268
186
|
);
|
|
269
187
|
};
|
|
270
188
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Icon } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Toolbar as NaturalToolbar,
|
|
10
|
+
Tooltip,
|
|
11
|
+
type ToolbarButtonProps as NaturalToolbarButtonProps,
|
|
12
|
+
type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,
|
|
13
|
+
} from '@dxos/react-ui';
|
|
14
|
+
import { getSize } from '@dxos/react-ui-theme';
|
|
15
|
+
|
|
16
|
+
// TODO(burdon): Factor out in common with react-ui-editor.
|
|
17
|
+
|
|
18
|
+
export const iconStyles = getSize(5);
|
|
19
|
+
export const buttonStyles = 'min-bs-0 p-2';
|
|
20
|
+
export const tooltipProps = { side: 'top' as const, classNames: 'z-10' };
|
|
21
|
+
|
|
22
|
+
export const ToolbarSeparator = () => <div role='separator' className='grow' />;
|
|
23
|
+
|
|
24
|
+
//
|
|
25
|
+
// ToolbarButton
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
type ToolbarButtonProps = NaturalToolbarButtonProps & { Icon: Icon };
|
|
29
|
+
|
|
30
|
+
export const ToolbarButton = ({ Icon, children, ...props }: ToolbarButtonProps) => {
|
|
31
|
+
return (
|
|
32
|
+
<Tooltip.Root>
|
|
33
|
+
<Tooltip.Trigger asChild>
|
|
34
|
+
<NaturalToolbar.Button variant='ghost' {...props} classNames={buttonStyles}>
|
|
35
|
+
<Icon className={iconStyles} />
|
|
36
|
+
<span className='sr-only'>{children}</span>
|
|
37
|
+
</NaturalToolbar.Button>
|
|
38
|
+
</Tooltip.Trigger>
|
|
39
|
+
<Tooltip.Portal>
|
|
40
|
+
<Tooltip.Content {...tooltipProps}>
|
|
41
|
+
{children}
|
|
42
|
+
<Tooltip.Arrow />
|
|
43
|
+
</Tooltip.Content>
|
|
44
|
+
</Tooltip.Portal>
|
|
45
|
+
</Tooltip.Root>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//
|
|
50
|
+
// ToolbarToggleButton
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
export type ToolbarToggleButtonProps = NaturalToolbarToggleGroupItemProps & { Icon: Icon };
|
|
54
|
+
|
|
55
|
+
export const ToolbarToggleButton = ({ Icon, children, ...props }: ToolbarToggleButtonProps) => {
|
|
56
|
+
return (
|
|
57
|
+
<Tooltip.Root>
|
|
58
|
+
<Tooltip.Trigger asChild>
|
|
59
|
+
<NaturalToolbar.ToggleGroupItem variant='ghost' {...props} classNames={buttonStyles}>
|
|
60
|
+
<Icon className={iconStyles} />
|
|
61
|
+
<span className='sr-only'>{children}</span>
|
|
62
|
+
</NaturalToolbar.ToggleGroupItem>
|
|
63
|
+
</Tooltip.Trigger>
|
|
64
|
+
<Tooltip.Portal>
|
|
65
|
+
<Tooltip.Content {...tooltipProps}>
|
|
66
|
+
{children}
|
|
67
|
+
<Tooltip.Arrow />
|
|
68
|
+
</Tooltip.Content>
|
|
69
|
+
</Tooltip.Portal>
|
|
70
|
+
</Tooltip.Root>
|
|
71
|
+
);
|
|
72
|
+
};
|
package/src/components/index.ts
CHANGED
package/src/meta.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { GridNine, type IconProps } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { pluginMeta } from '@dxos/app-framework';
|
|
9
|
+
|
|
10
|
+
export const SHEET_PLUGIN = 'dxos.org/plugin/sheet';
|
|
11
|
+
|
|
12
|
+
export default pluginMeta({
|
|
13
|
+
id: SHEET_PLUGIN,
|
|
14
|
+
name: 'Sheet',
|
|
15
|
+
description: 'A simple spreadsheet plugin.',
|
|
16
|
+
iconComponent: (props: IconProps) => <GridNine {...props} />,
|
|
17
|
+
iconSymbol: 'ph--grid-nine--regular',
|
|
18
|
+
});
|
package/src/model/index.ts
CHANGED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { expect } from 'chai';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { SheetModel } from './model';
|
|
9
|
+
import { addressFromA1Notation, rangeFromA1Notation } from './types';
|
|
10
|
+
import { createComputeGraph } from '../components';
|
|
11
|
+
import { createSheet, ValueTypeEnum } from '../types';
|
|
12
|
+
|
|
13
|
+
// TODO(burdon): Test undo (e.g., clear cells).
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* VITEST_ENV=chrome p vitest --watch
|
|
17
|
+
* NOTE: Browser test required for hyperformula due to raw translation files.
|
|
18
|
+
*/
|
|
19
|
+
describe('model', () => {
|
|
20
|
+
const createModel = async () => {
|
|
21
|
+
const graph = createComputeGraph();
|
|
22
|
+
const sheet = createSheet();
|
|
23
|
+
const model = new SheetModel(graph, sheet, undefined, { rows: 5, columns: 5 });
|
|
24
|
+
await model.initialize();
|
|
25
|
+
return model;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
test('create', async () => {
|
|
29
|
+
const model = await createModel();
|
|
30
|
+
expect(model.bounds).to.deep.eq({ rows: 5, columns: 5 });
|
|
31
|
+
model.setValue(addressFromA1Notation('A1'), 100);
|
|
32
|
+
const value = model.getValue(addressFromA1Notation('A1'));
|
|
33
|
+
expect(value).to.eq(100);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('map formula', async () => {
|
|
37
|
+
const model = await createModel();
|
|
38
|
+
const x1 = model.mapFormulaRefsToIndices('=SUM(A1:A3)');
|
|
39
|
+
const x2 = model.mapFormulaIndicesToRefs(x1);
|
|
40
|
+
expect(x2).to.eq('=SUM(A1:A3)');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('dates', async () => {
|
|
44
|
+
const model = await createModel();
|
|
45
|
+
const cell = addressFromA1Notation('A1');
|
|
46
|
+
model.setValue(cell, '=NOW()');
|
|
47
|
+
const type = model.getValueType(cell);
|
|
48
|
+
expect(type).to.eq(ValueTypeEnum.DateTime);
|
|
49
|
+
const value = model.getValue(cell);
|
|
50
|
+
const date = model.toLocalDate(value as number);
|
|
51
|
+
const now = new Date();
|
|
52
|
+
expect(date.getUTCFullYear()).to.eq(now.getUTCFullYear());
|
|
53
|
+
expect(date.getUTCMonth()).to.eq(now.getUTCMonth());
|
|
54
|
+
expect(date.getUTCDate()).to.eq(now.getUTCDate());
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('formula', async () => {
|
|
58
|
+
const model = await createModel();
|
|
59
|
+
|
|
60
|
+
// Nested formula.
|
|
61
|
+
{
|
|
62
|
+
model.setValue(addressFromA1Notation('A1'), 100);
|
|
63
|
+
model.setValue(addressFromA1Notation('A2'), 200);
|
|
64
|
+
model.setValue(addressFromA1Notation('A3'), '=SUM(A1:A2)');
|
|
65
|
+
model.setValue(addressFromA1Notation('A4'), '=SUM(A1:A3)');
|
|
66
|
+
const value = model.getValue(addressFromA1Notation('A4'));
|
|
67
|
+
expect(value).to.eq(600);
|
|
68
|
+
// console.log(JSON.stringify(model.sheet.cells, undefined, 2));
|
|
69
|
+
|
|
70
|
+
const cells = model.getCellValues(rangeFromA1Notation('A1:A4'));
|
|
71
|
+
expect(cells).to.deep.eq([
|
|
72
|
+
[100],
|
|
73
|
+
[200],
|
|
74
|
+
[model.mapFormulaRefsToIndices('=SUM(A1:A2)')],
|
|
75
|
+
[model.mapFormulaRefsToIndices('=SUM(A1:A3)')],
|
|
76
|
+
]);
|
|
77
|
+
// console.log(JSON.stringify(model.sheet.cells, undefined, 2));
|
|
78
|
+
// console.log(cells);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Insert row.
|
|
82
|
+
{
|
|
83
|
+
model.insertRows(2, 1);
|
|
84
|
+
model.setValue(addressFromA1Notation('A3'), 400);
|
|
85
|
+
const value = model.getValue(addressFromA1Notation('A5'));
|
|
86
|
+
expect(value).to.eq(1000);
|
|
87
|
+
|
|
88
|
+
const cells = model.getCellValues(rangeFromA1Notation('A1:A5'));
|
|
89
|
+
expect(cells).to.deep.eq([
|
|
90
|
+
[100],
|
|
91
|
+
[200],
|
|
92
|
+
[400],
|
|
93
|
+
[model.mapFormulaRefsToIndices('=SUM(A1:A2)')],
|
|
94
|
+
[model.mapFormulaRefsToIndices('=SUM(A1:A4)')],
|
|
95
|
+
]);
|
|
96
|
+
// console.log(JSON.stringify(model.sheet.cells, undefined, 2));
|
|
97
|
+
// console.log(cells);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|