@dxos/plugin-sheet 0.8.3 → 0.8.4-main.1068cf700f
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-6DNFC4TY.mjs +397 -0
- package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs +24 -0
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +7 -0
- package/dist/lib/browser/chunk-EDWHV64N.mjs +1473 -0
- package/dist/lib/browser/chunk-EDWHV64N.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FJRLDX7Z.mjs → chunk-IFLWVS2V.mjs} +7 -7
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
- package/dist/lib/browser/chunk-KE3AKN5W.mjs +397 -0
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +80 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-D2T2DOVX.mjs +29 -0
- package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +79 -0
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +7 -0
- package/dist/lib/browser/react-surface-45CRAB5G.mjs +51 -0
- package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +398 -0
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs +398 -0
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +1474 -0
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NMCVJWDT.mjs → chunk-PPOYR7DK.mjs} +7 -7
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +80 -89
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs +30 -0
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs +52 -0
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -12
- package/dist/types/src/SheetPlugin.d.ts +2 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -11
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +51 -3
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +54 -5
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +3 -3
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +88 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +13 -20
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts +10 -13
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/index.d.ts +1 -1
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -6
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +2 -2
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +2 -2
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/{testing/playwright → playwright}/sheet-manager.d.ts +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/sheet.spec.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +2 -2
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -2
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +27 -3
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -62
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +76 -0
- package/dist/types/src/types/Sheet.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +6 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +2 -2
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +92 -75
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +10 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +83 -73
- package/src/SheetPlugin.tsx +53 -65
- package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
- package/src/capabilities/compute-graph-registry/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +30 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +43 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
- package/src/components/GridSheet/GridSheet.stories.tsx +23 -17
- package/src/components/GridSheet/GridSheet.tsx +63 -52
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +44 -43
- package/src/components/GridSheet/util.ts +17 -11
- package/src/components/RangeList/RangeList.tsx +13 -10
- package/src/components/SheetContainer/SheetContainer.stories.tsx +71 -47
- package/src/components/SheetContainer/SheetContainer.tsx +30 -18
- package/src/components/SheetContext/SheetContext.tsx +9 -9
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
- package/src/components/SheetToolbar/SheetToolbar.tsx +52 -42
- package/src/components/SheetToolbar/align.ts +46 -20
- package/src/components/SheetToolbar/style.ts +48 -18
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/extensions/compute.stories.tsx +43 -30
- package/src/extensions/compute.ts +3 -4
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
- package/src/extensions/editor/{extension.ts → sheet-extension.ts} +7 -4
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +43 -51
- package/src/meta.ts +9 -7
- package/src/model/sheet-model.test.ts +5 -4
- package/src/model/sheet-model.ts +85 -53
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +17 -0
- package/src/{testing/playwright → playwright}/sheet-manager.ts +1 -1
- package/src/{testing/playwright → playwright}/sheet.spec.ts +3 -2
- package/src/sanity.test.ts +4 -5
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +11 -5
- package/src/translations.ts +10 -7
- package/src/types/Sheet.ts +97 -0
- package/src/types/capabilities.ts +14 -0
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +2 -2
- package/src/types/types.ts +84 -49
- package/src/types/util.ts +14 -41
- package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs +0 -351
- package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs +0 -24
- package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs.map +0 -7
- package/dist/lib/browser/chunk-5TA43LO4.mjs +0 -847
- package/dist/lib/browser/chunk-5TA43LO4.mjs.map +0 -7
- package/dist/lib/browser/chunk-D3G4UGEK.mjs +0 -18
- package/dist/lib/browser/chunk-D3G4UGEK.mjs.map +0 -7
- package/dist/lib/browser/chunk-FJRLDX7Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-I7FZ4TWJ.mjs +0 -892
- package/dist/lib/browser/chunk-I7FZ4TWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-IR42IS3F.mjs +0 -15
- package/dist/lib/browser/chunk-IR42IS3F.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-IBBI6B74.mjs +0 -56
- package/dist/lib/browser/intent-resolver-IBBI6B74.mjs.map +0 -7
- package/dist/lib/browser/markdown-T4TUP4BF.mjs +0 -26
- package/dist/lib/browser/markdown-T4TUP4BF.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI46P43F.mjs +0 -53
- package/dist/lib/browser/react-surface-UI46P43F.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs +0 -351
- package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs.map +0 -7
- package/dist/lib/node/anchor-sort-A7NABMJM.cjs +0 -39
- package/dist/lib/node/anchor-sort-A7NABMJM.cjs.map +0 -7
- package/dist/lib/node/chunk-FIM6EZ6M.cjs +0 -256
- package/dist/lib/node/chunk-FIM6EZ6M.cjs.map +0 -7
- package/dist/lib/node/chunk-JSIDCZHB.cjs +0 -41
- package/dist/lib/node/chunk-JSIDCZHB.cjs.map +0 -7
- package/dist/lib/node/chunk-LJWWS53Z.cjs +0 -34
- package/dist/lib/node/chunk-LJWWS53Z.cjs.map +0 -7
- package/dist/lib/node/chunk-N7FSEUIN.cjs +0 -927
- package/dist/lib/node/chunk-N7FSEUIN.cjs.map +0 -7
- package/dist/lib/node/chunk-ST3WA73J.cjs +0 -855
- package/dist/lib/node/chunk-ST3WA73J.cjs.map +0 -7
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs +0 -56
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -173
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-2657YDOU.cjs +0 -69
- package/dist/lib/node/intent-resolver-2657YDOU.cjs.map +0 -7
- package/dist/lib/node/markdown-DBPOAYI7.cjs +0 -40
- package/dist/lib/node/markdown-DBPOAYI7.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-XQEIRKWU.cjs +0 -71
- package/dist/lib/node/react-surface-XQEIRKWU.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -84
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs +0 -352
- package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C4IKYVTV.mjs +0 -893
- package/dist/lib/node-esm/chunk-C4IKYVTV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IQ76YE6M.mjs +0 -16
- package/dist/lib/node-esm/chunk-IQ76YE6M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NMCVJWDT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SOC52B67.mjs +0 -848
- package/dist/lib/node-esm/chunk-SOC52B67.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs +0 -20
- package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs +0 -27
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs +0 -54
- package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -6
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/sheet.spec.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -37
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -22
- package/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/compute-graph-registry.ts +0 -28
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -39
- package/src/testing/playwright/playwright.config.cts +0 -18
- package/src/types/schema.ts +0 -60
- /package/dist/types/src/{testing/playwright → playwright}/sheet.spec.d.ts +0 -0
|
@@ -2,28 +2,63 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
5
|
+
import { type Meta } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
8
7
|
import React from 'react';
|
|
9
8
|
|
|
10
|
-
import { Capabilities,
|
|
9
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
11
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { OperationResolver } from '@dxos/operation';
|
|
13
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
14
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
14
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
17
|
import { AttendableContainer } from '@dxos/react-ui-attention';
|
|
16
|
-
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
17
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
18
18
|
|
|
19
|
-
import { SheetContainer } from './SheetContainer';
|
|
20
19
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
21
|
-
import translations from '../../translations';
|
|
22
|
-
import {
|
|
20
|
+
import { translations } from '../../translations';
|
|
21
|
+
import { Sheet, SheetOperation } from '../../types';
|
|
23
22
|
import { useComputeGraph } from '../ComputeGraph';
|
|
24
23
|
import { RangeList } from '../RangeList';
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
import { SheetContainer } from './SheetContainer';
|
|
26
|
+
|
|
27
|
+
const meta = {
|
|
28
|
+
title: 'plugins/plugin-sheet/SheetContainer',
|
|
29
|
+
component: SheetContainer,
|
|
30
|
+
decorators: [
|
|
31
|
+
withTheme(),
|
|
32
|
+
withLayout({ layout: 'fullscreen' }),
|
|
33
|
+
withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
|
|
34
|
+
withComputeGraphDecorator(),
|
|
35
|
+
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
36
|
+
withPluginManager({
|
|
37
|
+
plugins: [...corePlugins()],
|
|
38
|
+
capabilities: [
|
|
39
|
+
Capability.contributes(Capabilities.OperationResolver, [
|
|
40
|
+
OperationResolver.make({
|
|
41
|
+
operation: SheetOperation.DropAxis,
|
|
42
|
+
handler: ({ model, axis, axisIndex }) =>
|
|
43
|
+
Effect.sync(() => {
|
|
44
|
+
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
45
|
+
// Return stub output for story purposes.
|
|
46
|
+
return { axis, axisIndex, index: 0, axisMeta: null, values: [] };
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
]),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
parameters: {
|
|
54
|
+
layout: 'fullscreen',
|
|
55
|
+
translations,
|
|
56
|
+
},
|
|
57
|
+
} satisfies Meta<typeof SheetContainer>;
|
|
58
|
+
|
|
59
|
+
export default meta;
|
|
60
|
+
|
|
61
|
+
export const Default = () => {
|
|
27
62
|
const space = useSpace();
|
|
28
63
|
const graph = useComputeGraph(space);
|
|
29
64
|
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
@@ -32,12 +67,31 @@ export const Basic = () => {
|
|
|
32
67
|
}
|
|
33
68
|
|
|
34
69
|
return (
|
|
35
|
-
<AttendableContainer id={
|
|
36
|
-
<SheetContainer space={space}
|
|
70
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
71
|
+
<SheetContainer role='article' space={space} subject={sheet} ignoreAttention />
|
|
37
72
|
</AttendableContainer>
|
|
38
73
|
);
|
|
39
74
|
};
|
|
40
75
|
|
|
76
|
+
export const Section = () => {
|
|
77
|
+
const space = useSpace();
|
|
78
|
+
const graph = useComputeGraph(space);
|
|
79
|
+
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
80
|
+
if (!sheet || !space) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className='is-full flex justify-center'>
|
|
86
|
+
<div className='is-[40rem]'>
|
|
87
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
88
|
+
<SheetContainer role='section' space={space} subject={sheet} ignoreAttention />
|
|
89
|
+
</AttendableContainer>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
41
95
|
export const Spec = () => {
|
|
42
96
|
const space = useSpace();
|
|
43
97
|
const graph = useComputeGraph(space);
|
|
@@ -47,9 +101,9 @@ export const Spec = () => {
|
|
|
47
101
|
}
|
|
48
102
|
|
|
49
103
|
return (
|
|
50
|
-
<AttendableContainer id={
|
|
51
|
-
<div role='none' className='grid grid-
|
|
52
|
-
<SheetContainer space={space}
|
|
104
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
105
|
+
<div role='none' className='is-full grid grid-cols-[1fr_20rem]'>
|
|
106
|
+
<SheetContainer role='article' space={space} subject={sheet} ignoreAttention />
|
|
53
107
|
<div role='none' data-testid='grid.range-list'>
|
|
54
108
|
<RangeList sheet={sheet} />
|
|
55
109
|
</div>
|
|
@@ -57,33 +111,3 @@ export const Spec = () => {
|
|
|
57
111
|
</AttendableContainer>
|
|
58
112
|
);
|
|
59
113
|
};
|
|
60
|
-
|
|
61
|
-
const meta: Meta = {
|
|
62
|
-
title: 'plugins/plugin-sheet/SheetContainer',
|
|
63
|
-
component: SheetContainer,
|
|
64
|
-
decorators: [
|
|
65
|
-
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
66
|
-
withComputeGraphDecorator(),
|
|
67
|
-
withTheme,
|
|
68
|
-
withLayout({ fullscreen: true, classNames: 'grid' }),
|
|
69
|
-
withAttention,
|
|
70
|
-
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
71
|
-
withPluginManager({
|
|
72
|
-
plugins: [IntentPlugin(), GraphPlugin()],
|
|
73
|
-
capabilities: [
|
|
74
|
-
contributes(
|
|
75
|
-
Capabilities.IntentResolver,
|
|
76
|
-
createResolver({
|
|
77
|
-
intent: SheetAction.DropAxis,
|
|
78
|
-
resolve: ({ model, axis, axisIndex }) => {
|
|
79
|
-
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
80
|
-
},
|
|
81
|
-
}),
|
|
82
|
-
),
|
|
83
|
-
],
|
|
84
|
-
}),
|
|
85
|
-
],
|
|
86
|
-
parameters: { translations },
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export default meta;
|
|
@@ -2,35 +2,47 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
10
|
+
import { Flex, type FlexProps, Layout } from '@dxos/react-ui';
|
|
9
11
|
|
|
10
|
-
import { type
|
|
12
|
+
import { type Sheet } from '../../types';
|
|
11
13
|
import { useComputeGraph } from '../ComputeGraph';
|
|
12
14
|
import { FunctionEditor } from '../FunctionEditor';
|
|
13
15
|
import { GridSheet } from '../GridSheet';
|
|
14
16
|
import { SheetProvider } from '../SheetContext';
|
|
15
17
|
import { SheetToolbar } from '../SheetToolbar';
|
|
16
18
|
|
|
17
|
-
export type SheetContainerProps =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
19
|
+
export type SheetContainerProps = SurfaceComponentProps<
|
|
20
|
+
Sheet.Sheet,
|
|
21
|
+
{
|
|
22
|
+
space: Space;
|
|
23
|
+
ignoreAttention?: boolean;
|
|
24
|
+
}
|
|
25
|
+
>;
|
|
23
26
|
|
|
24
|
-
export const SheetContainer = ({
|
|
27
|
+
export const SheetContainer = ({ role, subject: sheet, space, ignoreAttention }: SheetContainerProps) => {
|
|
25
28
|
const graph = useComputeGraph(space);
|
|
29
|
+
if (!graph) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const Root = role === 'section' ? Container : Fragment;
|
|
26
34
|
|
|
27
|
-
return
|
|
35
|
+
return (
|
|
28
36
|
<SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
<Root>
|
|
38
|
+
<Layout.Main toolbar statusbar>
|
|
39
|
+
<SheetToolbar id={Obj.getDXN(sheet).toString()} />
|
|
40
|
+
<GridSheet />
|
|
41
|
+
<FunctionEditor />
|
|
42
|
+
</Layout.Main>
|
|
43
|
+
</Root>
|
|
34
44
|
</SheetProvider>
|
|
35
|
-
)
|
|
45
|
+
);
|
|
36
46
|
};
|
|
47
|
+
|
|
48
|
+
const Container = (props: FlexProps) => <Flex {...props} classNames='aspect-square' />;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type CellAddress, type CellRange, type CompleteCellRange, type ComputeGraph } from '@dxos/compute';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
10
|
import {
|
|
11
11
|
Grid,
|
|
12
12
|
type GridContentProps,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '@dxos/react-ui-grid';
|
|
17
17
|
|
|
18
18
|
import { type SheetModel, useSheetModel } from '../../model';
|
|
19
|
-
import { type
|
|
19
|
+
import { type Sheet } from '../../types';
|
|
20
20
|
|
|
21
21
|
export type SheetContextValue = {
|
|
22
22
|
id: string;
|
|
@@ -56,12 +56,12 @@ export const useSheetContext = (): SheetContextValue => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const SheetProviderImpl = ({
|
|
59
|
+
__gridScope,
|
|
60
|
+
children,
|
|
61
|
+
ignoreAttention,
|
|
59
62
|
model,
|
|
60
63
|
onInfo,
|
|
61
|
-
|
|
62
|
-
children,
|
|
63
|
-
__gridScope,
|
|
64
|
-
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model' | 'ignoreAttention'>>>) => {
|
|
64
|
+
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'ignoreAttention' | 'model' | 'onInfo'>>>) => {
|
|
65
65
|
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
66
66
|
|
|
67
67
|
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
@@ -114,7 +114,7 @@ const SheetProviderImpl = ({
|
|
|
114
114
|
|
|
115
115
|
export type SheetProviderProps = {
|
|
116
116
|
graph: ComputeGraph;
|
|
117
|
-
sheet:
|
|
117
|
+
sheet: Sheet.Sheet;
|
|
118
118
|
readonly?: boolean;
|
|
119
119
|
ignoreAttention?: boolean;
|
|
120
120
|
} & Pick<SheetContextValue, 'onInfo'>;
|
|
@@ -130,7 +130,7 @@ export const SheetProvider = ({
|
|
|
130
130
|
const model = useSheetModel(graph, sheet, { readonly });
|
|
131
131
|
|
|
132
132
|
return !model ? null : (
|
|
133
|
-
<Grid.Root id={
|
|
133
|
+
<Grid.Root id={Obj.getDXN(sheet).toString()}>
|
|
134
134
|
<SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
135
135
|
{children}
|
|
136
136
|
</SheetProviderImpl>
|
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
|
|
10
|
+
import { translations } from '../../translations';
|
|
11
11
|
|
|
12
12
|
import { SheetToolbar } from './SheetToolbar';
|
|
13
|
-
import translations from '../../translations';
|
|
14
13
|
|
|
15
14
|
const DefaultStory = () => {
|
|
16
|
-
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetProvider.
|
|
16
|
+
// return <SheetToolbar id='test' />;
|
|
17
|
+
return <>TODO</>;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const meta: Meta = {
|
|
20
|
+
const meta = {
|
|
22
21
|
title: 'plugins/plugin-sheet/Toolbar',
|
|
23
|
-
component: SheetToolbar,
|
|
22
|
+
component: SheetToolbar as any,
|
|
24
23
|
render: DefaultStory,
|
|
25
|
-
decorators: [withTheme
|
|
26
|
-
parameters: {
|
|
27
|
-
|
|
24
|
+
decorators: [withTheme()],
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: 'fullscreen',
|
|
27
|
+
translations,
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
28
30
|
|
|
29
31
|
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof meta>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {};
|
|
@@ -2,83 +2,93 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import React, { type PropsWithChildren, useMemo } from 'react';
|
|
5
|
+
import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { type PropsWithChildren, useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useAppGraph } from '@dxos/app-
|
|
8
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
10
|
import {
|
|
12
|
-
type ActionGraphEdges,
|
|
13
|
-
type ActionGraphNodes,
|
|
14
11
|
type ActionGraphProps,
|
|
15
|
-
createGapSeparator,
|
|
16
12
|
MenuProvider,
|
|
17
|
-
rxFromSignal,
|
|
18
13
|
ToolbarMenu,
|
|
14
|
+
createGapSeparator,
|
|
19
15
|
useMenuActions,
|
|
20
16
|
} from '@dxos/react-ui-menu';
|
|
21
17
|
|
|
22
|
-
import { createAlign, useAlignState } from './align';
|
|
23
|
-
import { createStyle, useStyleState } from './style';
|
|
24
|
-
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
25
18
|
import { type SheetModel } from '../../model';
|
|
26
19
|
import { useSheetContext } from '../SheetContext';
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
import { createAlign, useAlignState } from './align';
|
|
22
|
+
import { createStyle, useStyleState } from './style';
|
|
23
|
+
import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
type ToolbarActionsContext = {
|
|
26
|
+
model: SheetModel;
|
|
27
|
+
stateAtom: ToolbarStateAtom;
|
|
28
|
+
registry: Registry.Registry;
|
|
29
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
30
|
+
customActions?: Atom.Atom<ActionGraphProps>;
|
|
31
|
+
};
|
|
33
32
|
|
|
34
|
-
const createToolbarActions = (
|
|
35
|
-
model
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
33
|
+
const createToolbarActions = ({
|
|
34
|
+
model,
|
|
35
|
+
stateAtom,
|
|
36
|
+
registry,
|
|
37
|
+
cursorFallbackRange,
|
|
38
|
+
customActions,
|
|
39
|
+
}: ToolbarActionsContext): Atom.Atom<ActionGraphProps> => {
|
|
40
|
+
return Atom.make((get) => {
|
|
41
|
+
const state = get(stateAtom);
|
|
42
|
+
const context = { model, state, stateAtom, registry, cursorFallbackRange };
|
|
43
|
+
const align = createAlign(context);
|
|
44
|
+
const style = createStyle(context);
|
|
43
45
|
const gap = createGapSeparator();
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
+
|
|
47
|
+
const graph: ActionGraphProps = {
|
|
48
|
+
nodes: [...align.nodes, ...style.nodes, ...gap.nodes],
|
|
49
|
+
edges: [...align.edges, ...style.edges, ...gap.edges],
|
|
50
|
+
};
|
|
51
|
+
|
|
46
52
|
if (customActions) {
|
|
47
53
|
const custom = get(customActions);
|
|
48
|
-
nodes.push(...custom.nodes);
|
|
49
|
-
edges.push(...custom.edges);
|
|
54
|
+
graph.nodes.push(...custom.nodes);
|
|
55
|
+
graph.edges.push(...custom.edges);
|
|
50
56
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
edges,
|
|
54
|
-
};
|
|
57
|
+
|
|
58
|
+
return graph;
|
|
55
59
|
});
|
|
56
60
|
};
|
|
57
61
|
|
|
58
|
-
export
|
|
62
|
+
export type SheetToolbarProps = PropsWithChildren<{ id: string }>;
|
|
63
|
+
|
|
64
|
+
export const SheetToolbar = ({ id }: SheetToolbarProps) => {
|
|
59
65
|
const { model, cursorFallbackRange } = useSheetContext();
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
const stateAtom = useToolbarState({});
|
|
67
|
+
const registry = useContext(RegistryContext);
|
|
68
|
+
useAlignState(stateAtom);
|
|
69
|
+
useStyleState(stateAtom);
|
|
63
70
|
|
|
64
71
|
const { graph } = useAppGraph();
|
|
65
72
|
const customActions = useMemo(() => {
|
|
66
|
-
return
|
|
73
|
+
return Atom.make((get) => {
|
|
67
74
|
const actions = get(graph.actions(id));
|
|
68
75
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
69
|
-
return {
|
|
76
|
+
return {
|
|
77
|
+
nodes,
|
|
78
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id })),
|
|
79
|
+
};
|
|
70
80
|
});
|
|
71
|
-
}, [graph]);
|
|
81
|
+
}, [graph, id]);
|
|
72
82
|
|
|
73
83
|
const actionsCreator = useMemo(
|
|
74
|
-
() => createToolbarActions(model,
|
|
75
|
-
[model,
|
|
84
|
+
() => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
|
|
85
|
+
[model, stateAtom, registry, cursorFallbackRange, customActions],
|
|
76
86
|
);
|
|
77
87
|
const menu = useMenuActions(actionsCreator);
|
|
78
88
|
|
|
79
89
|
return (
|
|
80
90
|
<MenuProvider {...menu} attendableId={id}>
|
|
81
|
-
<ToolbarMenu
|
|
91
|
+
<ToolbarMenu />
|
|
82
92
|
</MenuProvider>
|
|
83
93
|
);
|
|
84
94
|
};
|
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useEffect } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import {
|
|
11
|
+
type ActionGraphProps,
|
|
12
|
+
type ToolbarMenuActionGroupProperties,
|
|
13
|
+
createMenuAction,
|
|
14
|
+
createMenuItemGroup,
|
|
15
|
+
} from '@dxos/react-ui-menu';
|
|
9
16
|
|
|
10
|
-
import {
|
|
11
|
-
import { SHEET_PLUGIN } from '../../meta';
|
|
17
|
+
import { meta } from '../../meta';
|
|
12
18
|
import { type SheetModel } from '../../model';
|
|
13
|
-
import { type AlignKey,
|
|
19
|
+
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
14
20
|
import { useSheetContext } from '../SheetContext';
|
|
15
21
|
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
23
|
+
|
|
16
24
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
17
25
|
|
|
18
26
|
export type AlignState = { [alignKey]: AlignValue | undefined };
|
|
@@ -23,29 +31,40 @@ const aligns: Record<AlignValue, string> = {
|
|
|
23
31
|
end: 'ph--text-align-right--regular',
|
|
24
32
|
};
|
|
25
33
|
|
|
26
|
-
export const useAlignState = (
|
|
34
|
+
export const useAlignState = (stateAtom: ToolbarStateAtom) => {
|
|
35
|
+
const registry = useContext(RegistryContext);
|
|
27
36
|
const { cursor, model } = useSheetContext();
|
|
28
37
|
useEffect(() => {
|
|
29
38
|
// TODO(thure): Can this O(n) call be memoized?
|
|
30
|
-
|
|
39
|
+
const alignValue = (
|
|
31
40
|
cursor
|
|
32
41
|
? model.sheet.ranges?.findLast(
|
|
33
42
|
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
34
43
|
)?.value
|
|
35
44
|
: undefined
|
|
36
45
|
) as AlignValue | undefined;
|
|
37
|
-
|
|
46
|
+
const prev = registry.get(stateAtom);
|
|
47
|
+
registry.set(stateAtom, { ...prev, [alignKey]: alignValue });
|
|
48
|
+
}, [cursor, model.sheet, registry, stateAtom]);
|
|
38
49
|
};
|
|
39
50
|
|
|
40
51
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
41
52
|
createMenuItemGroup('align', {
|
|
42
|
-
label: ['align label', { ns:
|
|
53
|
+
label: ['align label', { ns: meta.id }],
|
|
43
54
|
variant: 'toggleGroup',
|
|
44
55
|
selectCardinality: 'single',
|
|
45
56
|
value: `${alignKey}--${value}`,
|
|
46
57
|
} as ToolbarMenuActionGroupProperties);
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
type AlignActionsContext = {
|
|
60
|
+
model: SheetModel;
|
|
61
|
+
state: ToolbarState;
|
|
62
|
+
stateAtom: ToolbarStateAtom;
|
|
63
|
+
registry: Registry.Registry;
|
|
64
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: AlignActionsContext) =>
|
|
49
68
|
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
50
69
|
return createMenuAction<AlignAction>(
|
|
51
70
|
`${alignKey}--${alignValue}`,
|
|
@@ -63,31 +82,38 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
63
82
|
key: alignKey,
|
|
64
83
|
value: alignValue as AlignValue,
|
|
65
84
|
};
|
|
85
|
+
const currentState = registry.get(stateAtom);
|
|
66
86
|
if (index < 0) {
|
|
67
|
-
model.sheet
|
|
68
|
-
|
|
87
|
+
Obj.change(model.sheet, (obj) => {
|
|
88
|
+
obj.ranges?.push(nextRangeEntity);
|
|
89
|
+
});
|
|
90
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
69
91
|
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
70
|
-
model.sheet
|
|
71
|
-
|
|
92
|
+
Obj.change(model.sheet, (obj) => {
|
|
93
|
+
obj.ranges?.splice(index, 1);
|
|
94
|
+
});
|
|
95
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
72
96
|
} else {
|
|
73
|
-
model.sheet
|
|
74
|
-
|
|
97
|
+
Obj.change(model.sheet, (obj) => {
|
|
98
|
+
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
|
+
});
|
|
100
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
75
101
|
}
|
|
76
102
|
},
|
|
77
103
|
{
|
|
78
104
|
key: alignKey,
|
|
79
105
|
value: alignValue as AlignValue,
|
|
80
106
|
checked: state[alignKey] === alignValue,
|
|
81
|
-
label: [`range value ${alignValue} label`, { ns:
|
|
107
|
+
label: [`range value ${alignValue} label`, { ns: meta.id }],
|
|
82
108
|
icon,
|
|
83
109
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
84
110
|
},
|
|
85
111
|
);
|
|
86
112
|
});
|
|
87
113
|
|
|
88
|
-
export const createAlign = (
|
|
89
|
-
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
90
|
-
const alignActions = createAlignActions(
|
|
114
|
+
export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
|
|
115
|
+
const alignGroup = createAlignGroupAction(context.state[alignKey]);
|
|
116
|
+
const alignActions = createAlignActions(context);
|
|
91
117
|
return {
|
|
92
118
|
nodes: [alignGroup, ...alignActions],
|
|
93
119
|
edges: [
|