@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
package/src/types/types.ts
CHANGED
|
@@ -2,66 +2,101 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
10
|
+
import { Collection } from '@dxos/schema';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
rows: number;
|
|
13
|
-
columns: number;
|
|
14
|
-
};
|
|
12
|
+
import { meta } from '../meta';
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
name?: string;
|
|
18
|
-
cells?: Record<string, CellValue>;
|
|
19
|
-
} & Partial<SheetSize>;
|
|
14
|
+
import * as Sheet from './Sheet';
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export class Create extends Schema.TaggedClass<Create>()(`${SHEET_ACTION}/create`, {
|
|
25
|
-
input: Schema.Struct({
|
|
26
|
-
name: Schema.optional(Schema.String),
|
|
27
|
-
}),
|
|
28
|
-
output: Schema.Struct({
|
|
29
|
-
object: SheetType,
|
|
30
|
-
}),
|
|
31
|
-
}) {}
|
|
32
|
-
|
|
33
|
-
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
34
|
-
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
35
|
-
|
|
36
|
-
export class InsertAxis extends Schema.TaggedClass<InsertAxis>()(`${SHEET_ACTION}/axis-insert`, {
|
|
37
|
-
input: Schema.Struct({
|
|
38
|
-
// TODO(wittjosiah): Schema.instanceOf(SheetModel) throws when running tests.
|
|
39
|
-
model: Schema.Any.pipe(Schema.filter((model) => model instanceof SheetModel)) as Schema.Schema<SheetModel>,
|
|
40
|
-
axis: Axis,
|
|
41
|
-
index: Schema.Number,
|
|
42
|
-
count: Schema.optional(Schema.Number),
|
|
43
|
-
}),
|
|
44
|
-
output: Schema.Void,
|
|
45
|
-
}) {}
|
|
16
|
+
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
17
|
+
const ActionAxis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
46
18
|
|
|
19
|
+
export namespace SheetAction {
|
|
47
20
|
export const RestoreAxis = Schema.Struct({
|
|
48
|
-
axis:
|
|
21
|
+
axis: ActionAxis,
|
|
49
22
|
axisIndex: Schema.String,
|
|
50
23
|
index: Schema.Number,
|
|
51
|
-
axisMeta: RowColumnMeta,
|
|
24
|
+
axisMeta: Sheet.RowColumnMeta,
|
|
52
25
|
values: Schema.Array(Schema.Any),
|
|
53
26
|
});
|
|
54
27
|
|
|
55
28
|
export type RestoreAxis = Schema.Schema.Type<typeof RestoreAxis>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const SHEET_OPERATION = `${meta.id}/operation`;
|
|
32
|
+
|
|
33
|
+
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
34
|
+
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
35
|
+
|
|
36
|
+
export namespace SheetOperation {
|
|
37
|
+
export const OnCreateSpace = Operation.make({
|
|
38
|
+
meta: { key: `${SHEET_OPERATION}/on-create-space`, name: 'On Create Space' },
|
|
39
|
+
services: [Capability.Service],
|
|
40
|
+
schema: {
|
|
41
|
+
input: Schema.Struct({
|
|
42
|
+
space: SpaceSchema,
|
|
43
|
+
rootCollection: Collection.Collection,
|
|
44
|
+
isDefault: Schema.optional(Schema.Boolean),
|
|
45
|
+
}),
|
|
46
|
+
output: Schema.Void,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const InsertAxis = Operation.make({
|
|
51
|
+
meta: { key: `${SHEET_OPERATION}/axis-insert`, name: 'Insert Axis' },
|
|
52
|
+
schema: {
|
|
53
|
+
input: Schema.Struct({
|
|
54
|
+
model: Schema.Any,
|
|
55
|
+
axis: Axis,
|
|
56
|
+
index: Schema.Number,
|
|
57
|
+
count: Schema.optional(Schema.Number),
|
|
58
|
+
}),
|
|
59
|
+
output: Schema.Void,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const DropAxisOutput = Schema.Struct({
|
|
64
|
+
axis: Axis.annotations({ description: 'The axis type (row or col).' }),
|
|
65
|
+
axisIndex: Schema.String.annotations({ description: 'The dropped axis index.' }),
|
|
66
|
+
index: Schema.Number.annotations({ description: 'The position the axis was at.' }),
|
|
67
|
+
axisMeta: Schema.Any.annotations({ description: 'The row/column metadata.' }),
|
|
68
|
+
values: Schema.Array(Schema.Any).annotations({ description: 'The cell values that were dropped.' }),
|
|
69
|
+
});
|
|
56
70
|
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
export type DropAxisOutput = Schema.Schema.Type<typeof DropAxisOutput>;
|
|
72
|
+
|
|
73
|
+
export const DropAxis = Operation.make({
|
|
74
|
+
meta: { key: `${SHEET_OPERATION}/axis-drop`, name: 'Drop Axis' },
|
|
75
|
+
schema: {
|
|
76
|
+
input: Schema.Struct({
|
|
77
|
+
model: Schema.Any,
|
|
78
|
+
axis: Axis,
|
|
79
|
+
axisIndex: Schema.String,
|
|
80
|
+
}),
|
|
81
|
+
output: DropAxisOutput,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Restore a dropped axis (inverse of DropAxis).
|
|
87
|
+
*/
|
|
88
|
+
export const RestoreAxis = Operation.make({
|
|
89
|
+
meta: { key: `${SHEET_OPERATION}/restore-axis`, name: 'Restore Axis' },
|
|
90
|
+
schema: {
|
|
91
|
+
input: Schema.Struct({
|
|
92
|
+
model: Schema.Any.annotations({ description: 'The sheet model.' }),
|
|
93
|
+
axis: Axis.annotations({ description: 'The axis type (row or col).' }),
|
|
94
|
+
axisIndex: Schema.String.annotations({ description: 'The axis index to restore.' }),
|
|
95
|
+
index: Schema.Number.annotations({ description: 'The position to restore at.' }),
|
|
96
|
+
axisMeta: Schema.Any.annotations({ description: 'The row/column metadata.' }),
|
|
97
|
+
values: Schema.Array(Schema.Any).annotations({ description: 'The cell values to restore.' }),
|
|
98
|
+
}),
|
|
99
|
+
output: Schema.Void,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
67
102
|
}
|
package/src/types/util.ts
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
addressFromA1Notation,
|
|
7
|
-
addressToA1Notation,
|
|
8
|
-
isFormula,
|
|
9
6
|
type CellAddress,
|
|
10
7
|
type CellRange,
|
|
11
8
|
type CompleteCellRange,
|
|
9
|
+
addressFromA1Notation,
|
|
10
|
+
addressToA1Notation,
|
|
11
|
+
isFormula,
|
|
12
12
|
} from '@dxos/compute';
|
|
13
13
|
import { randomBytes } from '@dxos/crypto';
|
|
14
|
-
import { Obj } from '@dxos/echo';
|
|
14
|
+
import { type Obj } from '@dxos/echo';
|
|
15
15
|
import { invariant } from '@dxos/invariant';
|
|
16
16
|
|
|
17
|
-
import { type
|
|
17
|
+
import { type Sheet } from '../types';
|
|
18
18
|
|
|
19
19
|
export const MAX_ROWS = 500;
|
|
20
20
|
export const MAX_COLS = 676; // 26^2;
|
|
@@ -56,8 +56,8 @@ export const insertIndices = (indices: string[], i: number, n: number, max: numb
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
export const initialize = (
|
|
59
|
-
sheet:
|
|
60
|
-
{ rows = DEFAULT_ROWS, columns = DEFAULT_COLS }: Partial<SheetSize> = {},
|
|
59
|
+
sheet: Obj.Mutable<Sheet.Sheet>,
|
|
60
|
+
{ rows = DEFAULT_ROWS, columns = DEFAULT_COLS }: Partial<Sheet.SheetSize> = {},
|
|
61
61
|
) => {
|
|
62
62
|
if (!sheet.rows.length) {
|
|
63
63
|
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
@@ -67,44 +67,17 @@ export const initialize = (
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const createSheet = ({ name, cells, ...size }: CreateSheetOptions = {}): SheetType => {
|
|
71
|
-
const sheet = Obj.make(SheetType, {
|
|
72
|
-
name,
|
|
73
|
-
cells: {},
|
|
74
|
-
rows: [],
|
|
75
|
-
columns: [],
|
|
76
|
-
rowMeta: {},
|
|
77
|
-
columnMeta: {},
|
|
78
|
-
ranges: [],
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
initialize(sheet, size);
|
|
82
|
-
|
|
83
|
-
if (cells) {
|
|
84
|
-
Object.entries(cells).forEach(([key, { value }]) => {
|
|
85
|
-
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
86
|
-
if (isFormula(value)) {
|
|
87
|
-
value = mapFormulaRefsToIndices(sheet, value);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
sheet.cells[idx] = { value };
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return sheet;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
70
|
/**
|
|
98
71
|
* E.g., "A1" => "CA2@CB3".
|
|
99
72
|
*/
|
|
100
|
-
export const addressToIndex = (sheet:
|
|
73
|
+
export const addressToIndex = (sheet: Sheet.Sheet, cell: CellAddress): string => {
|
|
101
74
|
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
102
75
|
};
|
|
103
76
|
|
|
104
77
|
/**
|
|
105
78
|
* E.g., "CA2@CB3" => "A1".
|
|
106
79
|
*/
|
|
107
|
-
export const addressFromIndex = (sheet:
|
|
80
|
+
export const addressFromIndex = (sheet: Sheet.Sheet, idx: string): CellAddress => {
|
|
108
81
|
const [column, row] = idx.split('@');
|
|
109
82
|
return {
|
|
110
83
|
col: sheet.columns.indexOf(column),
|
|
@@ -115,14 +88,14 @@ export const addressFromIndex = (sheet: SheetType, idx: string): CellAddress =>
|
|
|
115
88
|
/**
|
|
116
89
|
* E.g., "A1:B2" => "CA2@CB3:CC4@CD5".
|
|
117
90
|
*/
|
|
118
|
-
export const rangeToIndex = (sheet:
|
|
91
|
+
export const rangeToIndex = (sheet: Sheet.Sheet, range: CellRange): string => {
|
|
119
92
|
return [range.from, range.to ?? range.from].map((cell) => addressToIndex(sheet, cell)).join(':');
|
|
120
93
|
};
|
|
121
94
|
|
|
122
95
|
/**
|
|
123
96
|
* E.g., "CA2@CB3:CC4@CD5" => "A1:B2".
|
|
124
97
|
*/
|
|
125
|
-
export const rangeFromIndex = (sheet:
|
|
98
|
+
export const rangeFromIndex = (sheet: Sheet.Sheet, idx: string): CompleteCellRange => {
|
|
126
99
|
const [from, to] = idx.split(':').map((index) => addressFromIndex(sheet, index));
|
|
127
100
|
return { from, to };
|
|
128
101
|
};
|
|
@@ -131,7 +104,7 @@ export const rangeFromIndex = (sheet: SheetType, idx: string): CompleteCellRange
|
|
|
131
104
|
* Compares the positions of two cell indexes in a sheet.
|
|
132
105
|
* Sorts primarily by row, then by column if rows are equal.
|
|
133
106
|
*/
|
|
134
|
-
export const compareIndexPositions = (sheet:
|
|
107
|
+
export const compareIndexPositions = (sheet: Sheet.Sheet, indexA: string, indexB: string): number => {
|
|
135
108
|
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
136
109
|
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
137
110
|
|
|
@@ -148,7 +121,7 @@ export const compareIndexPositions = (sheet: SheetType, indexA: string, indexB:
|
|
|
148
121
|
/**
|
|
149
122
|
* Map from A1 notation to indices.
|
|
150
123
|
*/
|
|
151
|
-
export const mapFormulaRefsToIndices = (sheet:
|
|
124
|
+
export const mapFormulaRefsToIndices = (sheet: Sheet.Sheet, formula: string): string => {
|
|
152
125
|
invariant(isFormula(formula));
|
|
153
126
|
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
154
127
|
return addressToIndex(sheet, addressFromA1Notation(match));
|
|
@@ -158,7 +131,7 @@ export const mapFormulaRefsToIndices = (sheet: SheetType, formula: string): stri
|
|
|
158
131
|
/**
|
|
159
132
|
* Map from indices to A1 notation.
|
|
160
133
|
*/
|
|
161
|
-
export const mapFormulaIndicesToRefs = (sheet:
|
|
134
|
+
export const mapFormulaIndicesToRefs = (sheet: Sheet.Sheet, formula: string): string => {
|
|
162
135
|
invariant(isFormula(formula));
|
|
163
136
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
164
137
|
return addressToA1Notation(addressFromIndex(sheet, idx));
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GridSheet,
|
|
3
|
-
SheetProvider,
|
|
4
|
-
useComputeGraph,
|
|
5
|
-
useSheetContext
|
|
6
|
-
} from "./chunk-5TA43LO4.mjs";
|
|
7
|
-
import {
|
|
8
|
-
alignKey,
|
|
9
|
-
mapFormulaIndicesToRefs,
|
|
10
|
-
rangeFromIndex,
|
|
11
|
-
rangeToIndex
|
|
12
|
-
} from "./chunk-I7FZ4TWJ.mjs";
|
|
13
|
-
import "./chunk-FJRLDX7Z.mjs";
|
|
14
|
-
import {
|
|
15
|
-
SHEET_PLUGIN
|
|
16
|
-
} from "./chunk-D3G4UGEK.mjs";
|
|
17
|
-
|
|
18
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer/SheetContainer.tsx
|
|
19
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
20
|
-
import React3 from "react";
|
|
21
|
-
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
22
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
23
|
-
|
|
24
|
-
// packages/plugins/plugin-sheet/src/components/FunctionEditor/FunctionEditor.tsx
|
|
25
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
26
|
-
import React from "react";
|
|
27
|
-
import { addressToA1Notation, isFormula, rangeToA1Notation } from "@dxos/compute";
|
|
28
|
-
import { Icon } from "@dxos/react-ui";
|
|
29
|
-
var FunctionEditor = () => {
|
|
30
|
-
var _effect = _useSignals();
|
|
31
|
-
try {
|
|
32
|
-
const { model, cursor, range } = useSheetContext();
|
|
33
|
-
let value;
|
|
34
|
-
let formula = false;
|
|
35
|
-
if (cursor) {
|
|
36
|
-
value = model.getCellValue(cursor);
|
|
37
|
-
if (isFormula(value)) {
|
|
38
|
-
value = model.graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(model.sheet, value));
|
|
39
|
-
formula = true;
|
|
40
|
-
} else if (value != null) {
|
|
41
|
-
value = String(value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
45
|
-
className: "flex shrink-0 justify-between items-center px-4 py-1 text-sm bg-toolbarSurface border-bs !border-subduedSeparator"
|
|
46
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
47
|
-
className: "flex gap-4 items-center"
|
|
48
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
49
|
-
className: "flex w-16 items-center font-mono"
|
|
50
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React.createElement("div", {
|
|
51
|
-
className: "flex gap-2 items-center"
|
|
52
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
53
|
-
icon: "ph--function--regular",
|
|
54
|
-
classNames: [
|
|
55
|
-
"text-greenText",
|
|
56
|
-
formula ? "visible" : "invisible"
|
|
57
|
-
]
|
|
58
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
59
|
-
className: "font-mono"
|
|
60
|
-
}, value))));
|
|
61
|
-
} finally {
|
|
62
|
-
_effect.f();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// packages/plugins/plugin-sheet/src/components/SheetToolbar/SheetToolbar.tsx
|
|
67
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
68
|
-
import { Rx } from "@effect-rx/rx-react";
|
|
69
|
-
import React2, { useMemo as useMemo2 } from "react";
|
|
70
|
-
import { useAppGraph } from "@dxos/app-framework";
|
|
71
|
-
import { createGapSeparator, MenuProvider, rxFromSignal, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
|
|
72
|
-
|
|
73
|
-
// packages/plugins/plugin-sheet/src/components/SheetToolbar/align.ts
|
|
74
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
75
|
-
import { useEffect } from "react";
|
|
76
|
-
import { inRange } from "@dxos/compute";
|
|
77
|
-
import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
|
|
78
|
-
var aligns = {
|
|
79
|
-
start: "ph--text-align-left--regular",
|
|
80
|
-
center: "ph--text-align-center--regular",
|
|
81
|
-
end: "ph--text-align-right--regular"
|
|
82
|
-
};
|
|
83
|
-
var useAlignState = (state) => {
|
|
84
|
-
var _effect = _useSignals2();
|
|
85
|
-
try {
|
|
86
|
-
const { cursor, model } = useSheetContext();
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
state[alignKey] = cursor ? model.sheet.ranges?.findLast(({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor))?.value : void 0;
|
|
89
|
-
}, [
|
|
90
|
-
cursor,
|
|
91
|
-
model.sheet
|
|
92
|
-
]);
|
|
93
|
-
} finally {
|
|
94
|
-
_effect.f();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var createAlignGroupAction = (value) => createMenuItemGroup("align", {
|
|
98
|
-
label: [
|
|
99
|
-
"align label",
|
|
100
|
-
{
|
|
101
|
-
ns: SHEET_PLUGIN
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
variant: "toggleGroup",
|
|
105
|
-
selectCardinality: "single",
|
|
106
|
-
value: `${alignKey}--${value}`
|
|
107
|
-
});
|
|
108
|
-
var createAlignActions = (model, state, cursorFallbackRange) => Object.entries(aligns).map(([alignValue, icon]) => {
|
|
109
|
-
return createMenuAction(`${alignKey}--${alignValue}`, () => {
|
|
110
|
-
if (!cursorFallbackRange) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const index = model.sheet.ranges?.findIndex((range) => range.key === alignKey && inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from)) ?? -1;
|
|
114
|
-
const nextRangeEntity = {
|
|
115
|
-
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
116
|
-
key: alignKey,
|
|
117
|
-
value: alignValue
|
|
118
|
-
};
|
|
119
|
-
if (index < 0) {
|
|
120
|
-
model.sheet.ranges?.push(nextRangeEntity);
|
|
121
|
-
state[alignKey] = nextRangeEntity.value;
|
|
122
|
-
} else if (model.sheet.ranges[index].value === nextRangeEntity.value) {
|
|
123
|
-
model.sheet.ranges?.splice(index, 1);
|
|
124
|
-
state[alignKey] = void 0;
|
|
125
|
-
} else {
|
|
126
|
-
model.sheet.ranges?.splice(index, 1, nextRangeEntity);
|
|
127
|
-
state[alignKey] = nextRangeEntity.value;
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: alignKey,
|
|
131
|
-
value: alignValue,
|
|
132
|
-
checked: state[alignKey] === alignValue,
|
|
133
|
-
label: [
|
|
134
|
-
`range value ${alignValue} label`,
|
|
135
|
-
{
|
|
136
|
-
ns: SHEET_PLUGIN
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
icon,
|
|
140
|
-
testId: `grid.toolbar.${alignKey}.${alignValue}`
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
var createAlign = (model, state, cursorFallbackRange) => {
|
|
144
|
-
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
145
|
-
const alignActions = createAlignActions(model, state, cursorFallbackRange);
|
|
146
|
-
return {
|
|
147
|
-
nodes: [
|
|
148
|
-
alignGroup,
|
|
149
|
-
...alignActions
|
|
150
|
-
],
|
|
151
|
-
edges: [
|
|
152
|
-
{
|
|
153
|
-
source: "root",
|
|
154
|
-
target: "align"
|
|
155
|
-
},
|
|
156
|
-
...alignActions.map(({ id }) => ({
|
|
157
|
-
source: alignGroup.id,
|
|
158
|
-
target: id
|
|
159
|
-
}))
|
|
160
|
-
]
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// packages/plugins/plugin-sheet/src/components/SheetToolbar/style.ts
|
|
165
|
-
import { useEffect as useEffect2 } from "react";
|
|
166
|
-
import { inRange as inRange2 } from "@dxos/compute";
|
|
167
|
-
import { createMenuAction as createMenuAction2, createMenuItemGroup as createMenuItemGroup2 } from "@dxos/react-ui-menu";
|
|
168
|
-
var styles = {
|
|
169
|
-
highlight: "ph--highlighter--regular",
|
|
170
|
-
softwrap: "ph--paragraph--regular"
|
|
171
|
-
};
|
|
172
|
-
var useStyleState = (state) => {
|
|
173
|
-
const { cursorFallbackRange, model } = useSheetContext();
|
|
174
|
-
useEffect2(() => {
|
|
175
|
-
state.highlight = false;
|
|
176
|
-
state.softwrap = false;
|
|
177
|
-
if (cursorFallbackRange && model.sheet.ranges) {
|
|
178
|
-
model.sheet.ranges.filter(({ range, key }) => key === "style" && inRange2(rangeFromIndex(model.sheet, range), cursorFallbackRange.from)).forEach(({ value }) => {
|
|
179
|
-
state[value] = true;
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}, [
|
|
183
|
-
cursorFallbackRange,
|
|
184
|
-
model.sheet
|
|
185
|
-
]);
|
|
186
|
-
};
|
|
187
|
-
var createStyleGroup = (state) => {
|
|
188
|
-
return createMenuItemGroup2("style", {
|
|
189
|
-
variant: "toggleGroup",
|
|
190
|
-
selectCardinality: "multiple",
|
|
191
|
-
value: Object.keys(styles).filter((key) => !!state[key]).map((styleValue) => `style--${styleValue}`)
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
var createStyleActions = (model, state, cursorFallbackRange) => Object.entries(styles).map(([styleValue, icon]) => {
|
|
195
|
-
return createMenuAction2(`style--${styleValue}`, () => {
|
|
196
|
-
if (!cursorFallbackRange) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const index = model.sheet.ranges?.findIndex((range) => range.key === "style" && inRange2(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from)) ?? -1;
|
|
200
|
-
const nextRangeEntity = {
|
|
201
|
-
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
202
|
-
key: "style",
|
|
203
|
-
value: styleValue
|
|
204
|
-
};
|
|
205
|
-
if (model.sheet.ranges.filter(({ range, key: rangeKey }) => rangeKey === "style" && inRange2(rangeFromIndex(model.sheet, range), cursorFallbackRange.from)).some(({ value: rangeValue }) => rangeValue === styleValue)) {
|
|
206
|
-
if (index >= 0) {
|
|
207
|
-
model.sheet.ranges?.splice(index, 1);
|
|
208
|
-
}
|
|
209
|
-
state[nextRangeEntity.value] = false;
|
|
210
|
-
} else {
|
|
211
|
-
model.sheet.ranges?.push(nextRangeEntity);
|
|
212
|
-
state[nextRangeEntity.value] = true;
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "style",
|
|
216
|
-
value: styleValue,
|
|
217
|
-
icon,
|
|
218
|
-
label: [
|
|
219
|
-
`range value ${styleValue} label`,
|
|
220
|
-
{
|
|
221
|
-
ns: SHEET_PLUGIN
|
|
222
|
-
}
|
|
223
|
-
],
|
|
224
|
-
checked: !!state[styleValue]
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
var createStyle = (model, state, cursorFallbackRange) => {
|
|
228
|
-
const styleGroupAction = createStyleGroup(state);
|
|
229
|
-
const styleActions = createStyleActions(model, state, cursorFallbackRange);
|
|
230
|
-
return {
|
|
231
|
-
nodes: [
|
|
232
|
-
styleGroupAction,
|
|
233
|
-
...styleActions
|
|
234
|
-
],
|
|
235
|
-
edges: [
|
|
236
|
-
{
|
|
237
|
-
source: "root",
|
|
238
|
-
target: "style"
|
|
239
|
-
},
|
|
240
|
-
...styleActions.map(({ id }) => ({
|
|
241
|
-
source: styleGroupAction.id,
|
|
242
|
-
target: id
|
|
243
|
-
}))
|
|
244
|
-
]
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// packages/plugins/plugin-sheet/src/components/SheetToolbar/useToolbarState.ts
|
|
249
|
-
import { useMemo } from "react";
|
|
250
|
-
import { live } from "@dxos/live-object";
|
|
251
|
-
var useToolbarState = (initialState = {}) => {
|
|
252
|
-
return useMemo(() => live(initialState), []);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// packages/plugins/plugin-sheet/src/components/SheetToolbar/SheetToolbar.tsx
|
|
256
|
-
var createToolbarActions = (model, state, cursorFallbackRange, customActions) => {
|
|
257
|
-
return Rx.make((get) => {
|
|
258
|
-
const align = get(rxFromSignal(() => createAlign(model, state, cursorFallbackRange)));
|
|
259
|
-
const style = get(rxFromSignal(() => createStyle(model, state, cursorFallbackRange)));
|
|
260
|
-
const gap = createGapSeparator();
|
|
261
|
-
const nodes = [
|
|
262
|
-
...align.nodes,
|
|
263
|
-
...style.nodes,
|
|
264
|
-
...gap.nodes
|
|
265
|
-
];
|
|
266
|
-
const edges = [
|
|
267
|
-
...align.edges,
|
|
268
|
-
...style.edges,
|
|
269
|
-
...gap.edges
|
|
270
|
-
];
|
|
271
|
-
if (customActions) {
|
|
272
|
-
const custom = get(customActions);
|
|
273
|
-
nodes.push(...custom.nodes);
|
|
274
|
-
edges.push(...custom.edges);
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
nodes,
|
|
278
|
-
edges
|
|
279
|
-
};
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
var SheetToolbar = ({ id, classNames }) => {
|
|
283
|
-
var _effect = _useSignals3();
|
|
284
|
-
try {
|
|
285
|
-
const { model, cursorFallbackRange } = useSheetContext();
|
|
286
|
-
const state = useToolbarState({});
|
|
287
|
-
useAlignState(state);
|
|
288
|
-
useStyleState(state);
|
|
289
|
-
const { graph } = useAppGraph();
|
|
290
|
-
const customActions = useMemo2(() => {
|
|
291
|
-
return Rx.make((get) => {
|
|
292
|
-
const actions = get(graph.actions(id));
|
|
293
|
-
const nodes = actions.filter((action) => action.properties.disposition === "toolbar");
|
|
294
|
-
return {
|
|
295
|
-
nodes,
|
|
296
|
-
edges: nodes.map((node) => ({
|
|
297
|
-
source: "root",
|
|
298
|
-
target: node.id
|
|
299
|
-
}))
|
|
300
|
-
};
|
|
301
|
-
});
|
|
302
|
-
}, [
|
|
303
|
-
graph
|
|
304
|
-
]);
|
|
305
|
-
const actionsCreator = useMemo2(() => createToolbarActions(model, state, cursorFallbackRange, customActions), [
|
|
306
|
-
model,
|
|
307
|
-
state,
|
|
308
|
-
cursorFallbackRange,
|
|
309
|
-
customActions
|
|
310
|
-
]);
|
|
311
|
-
const menu = useMenuActions(actionsCreator);
|
|
312
|
-
return /* @__PURE__ */ React2.createElement(MenuProvider, {
|
|
313
|
-
...menu,
|
|
314
|
-
attendableId: id
|
|
315
|
-
}, /* @__PURE__ */ React2.createElement(ToolbarMenu, {
|
|
316
|
-
classNames
|
|
317
|
-
}));
|
|
318
|
-
} finally {
|
|
319
|
-
_effect.f();
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer/SheetContainer.tsx
|
|
324
|
-
var SheetContainer = ({ space, sheet, role, ignoreAttention }) => {
|
|
325
|
-
var _effect = _useSignals4();
|
|
326
|
-
try {
|
|
327
|
-
const graph = useComputeGraph(space);
|
|
328
|
-
return graph ? /* @__PURE__ */ React3.createElement(SheetProvider, {
|
|
329
|
-
sheet,
|
|
330
|
-
graph,
|
|
331
|
-
ignoreAttention
|
|
332
|
-
}, /* @__PURE__ */ React3.createElement(StackItem.Content, {
|
|
333
|
-
toolbar: true,
|
|
334
|
-
statusbar: true,
|
|
335
|
-
...role === "section" && {
|
|
336
|
-
classNames: "aspect-video"
|
|
337
|
-
}
|
|
338
|
-
}, /* @__PURE__ */ React3.createElement(SheetToolbar, {
|
|
339
|
-
id: fullyQualifiedId(sheet)
|
|
340
|
-
}), /* @__PURE__ */ React3.createElement(GridSheet, null), /* @__PURE__ */ React3.createElement(FunctionEditor, null))) : null;
|
|
341
|
-
} finally {
|
|
342
|
-
_effect.f();
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer/index.ts
|
|
347
|
-
var SheetContainer_default = SheetContainer;
|
|
348
|
-
export {
|
|
349
|
-
SheetContainer_default as default
|
|
350
|
-
};
|
|
351
|
-
//# sourceMappingURL=SheetContainer-BDZXBB5U.mjs.map
|