@dxos/plugin-sheet 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/RangeList-S3SHV7T6.mjs +53 -0
- package/dist/lib/browser/RangeList-S3SHV7T6.mjs.map +7 -0
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs +1805 -0
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs +24 -0
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SSN4HYJL.mjs → chunk-NNWF7EKC.mjs} +17 -17
- package/dist/lib/browser/chunk-NNWF7EKC.mjs.map +7 -0
- package/dist/lib/browser/chunk-S445OQGW.mjs +397 -0
- package/dist/lib/browser/chunk-S445OQGW.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +71 -80
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-S6GVLHB4.mjs +29 -0
- package/dist/lib/browser/markdown-S6GVLHB4.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs +79 -0
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs.map +7 -0
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs +51 -0
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs +54 -0
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs.map +7 -0
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs +1806 -0
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs → chunk-M52YLLWU.mjs} +17 -17
- package/dist/lib/node-esm/chunk-M52YLLWU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs +398 -0
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +71 -80
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs +30 -0
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs +52 -0
- package/dist/lib/node-esm/react-surface-7FZAE3S7.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 -9
- 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/Sheet/Sheet.d.ts +11 -0
- package/dist/types/src/components/Sheet/Sheet.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/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +1 -1
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +5 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/GridSheet.stories.d.ts → SheetContent/SheetContent.stories.d.ts} +5 -4
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/index.d.ts +2 -0
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
- package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +6 -6
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +5 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +6 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +12 -19
- 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 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/containers/RangeList/index.d.ts +3 -0
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/SheetContainer.stories.d.ts +4 -3
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
- 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 -2
- 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/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 +26 -2
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -2
- 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 +91 -74
- 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 +74 -67
- package/src/SheetPlugin.tsx +41 -61
- 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 +46 -0
- package/src/components/ComputeGraph/compute-graph.stories.tsx +10 -10
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +13 -10
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +16 -15
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +52 -39
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +14 -8
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +42 -40
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +10 -5
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +4 -4
- package/src/components/SheetToolbar/SheetToolbar.tsx +45 -35
- package/src/components/SheetToolbar/align.ts +44 -19
- package/src/components/SheetToolbar/style.ts +48 -18
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +17 -12
- package/src/containers/RangeList/index.ts +7 -0
- package/src/containers/SheetContainer/SheetContainer.stories.tsx +94 -0
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/{components → containers}/SheetContainer/index.ts +1 -1
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +24 -14
- package/src/extensions/compute.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +16 -13
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +38 -49
- package/src/meta.ts +8 -4
- package/src/model/sheet-model.test.ts +4 -4
- package/src/model/sheet-model.ts +80 -48
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +2 -1
- package/src/sanity.test.ts +3 -4
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +3 -3
- package/src/translations.ts +3 -2
- package/src/types/Sheet.ts +97 -0
- package/src/{capabilities → types}/capabilities.ts +2 -2
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +5 -5
- package/src/types/types.ts +82 -48
- package/src/types/util.ts +11 -38
- package/dist/lib/browser/SheetContainer-VL34UND4.mjs +0 -351
- package/dist/lib/browser/SheetContainer-VL34UND4.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-3N44DS5F.mjs +0 -24
- package/dist/lib/browser/anchor-sort-3N44DS5F.mjs.map +0 -7
- package/dist/lib/browser/chunk-ADK2HW4A.mjs +0 -906
- package/dist/lib/browser/chunk-ADK2HW4A.mjs.map +0 -7
- package/dist/lib/browser/chunk-CSBSADPQ.mjs +0 -16
- package/dist/lib/browser/chunk-CSBSADPQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-SSN4HYJL.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZJWJMX4E.mjs +0 -852
- package/dist/lib/browser/chunk-ZJWJMX4E.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZMPNHFIP.mjs +0 -15
- package/dist/lib/browser/chunk-ZMPNHFIP.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs +0 -21
- package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs +0 -56
- package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs.map +0 -7
- package/dist/lib/browser/markdown-RMTMI237.mjs +0 -26
- package/dist/lib/browser/markdown-RMTMI237.mjs.map +0 -7
- package/dist/lib/browser/react-surface-7ZDMQDCT.mjs +0 -53
- package/dist/lib/browser/react-surface-7ZDMQDCT.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs +0 -352
- package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-YL2OZHYM.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-YL2OZHYM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BZAPYBSH.mjs +0 -907
- package/dist/lib/node-esm/chunk-BZAPYBSH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H3GSD33H.mjs +0 -18
- package/dist/lib/node-esm/chunk-H3GSD33H.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IK4O7FUJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LN6ZSAII.mjs +0 -16
- package/dist/lib/node-esm/chunk-LN6ZSAII.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YL7BVJPC.mjs +0 -853
- package/dist/lib/node-esm/chunk-YL7BVJPC.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs +0 -22
- package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-EDIWHA3P.mjs +0 -27
- package/dist/lib/node-esm/markdown-EDIWHA3P.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TUME5MM2.mjs +0 -54
- package/dist/lib/node-esm/react-surface-TUME5MM2.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 -4
- 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/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.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.map +0 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/index.d.ts +0 -2
- package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -11
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- 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/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/compute-graph-registry.ts +0 -23
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -23
- package/src/capabilities/react-surface.tsx +0 -40
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -90
- package/src/components/SheetContainer/SheetContainer.tsx +0 -40
- package/src/components/SheetContext/index.ts +0 -5
- package/src/types/schema.ts +0 -61
- /package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +0 -0
- /package/dist/types/src/{components → containers}/SheetContainer/index.d.ts +0 -0
|
@@ -2,43 +2,46 @@
|
|
|
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
11
|
type ActionGraphProps,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Menu,
|
|
13
|
+
type MenuRootProps,
|
|
15
14
|
createGapSeparator,
|
|
16
|
-
rxFromSignal,
|
|
17
15
|
useMenuActions,
|
|
18
16
|
} from '@dxos/react-ui-menu';
|
|
19
17
|
|
|
20
18
|
import { type SheetModel } from '../../model';
|
|
21
|
-
import { useSheetContext } from '../
|
|
19
|
+
import { useSheetContext } from '../SheetRoot';
|
|
22
20
|
|
|
23
21
|
import { createAlign, useAlignState } from './align';
|
|
24
22
|
import { createStyle, useStyleState } from './style';
|
|
25
|
-
import { type
|
|
23
|
+
import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
type ToolbarActionsContext = {
|
|
26
|
+
model: SheetModel;
|
|
27
|
+
stateAtom: ToolbarStateAtom;
|
|
28
|
+
registry: Registry.Registry;
|
|
29
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
30
|
+
customActions?: Atom.Atom<ActionGraphProps>;
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
const createToolbarActions = (
|
|
34
|
-
model
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
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);
|
|
42
45
|
const gap = createGapSeparator();
|
|
43
46
|
|
|
44
47
|
const graph: ActionGraphProps = {
|
|
@@ -56,30 +59,37 @@ const createToolbarActions = (
|
|
|
56
59
|
});
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
export
|
|
62
|
+
export type SheetToolbarProps = { id: string } & Partial<MenuRootProps> &
|
|
63
|
+
PropsWithChildren<{ id: string } & Partial<MenuRootProps>>;
|
|
64
|
+
|
|
65
|
+
export const SheetToolbar = ({ id, ...props }: SheetToolbarProps) => {
|
|
60
66
|
const { model, cursorFallbackRange } = useSheetContext();
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
const stateAtom = useToolbarState({});
|
|
68
|
+
const registry = useContext(RegistryContext);
|
|
69
|
+
useAlignState(stateAtom);
|
|
70
|
+
useStyleState(stateAtom);
|
|
64
71
|
|
|
65
72
|
const { graph } = useAppGraph();
|
|
66
73
|
const customActions = useMemo(() => {
|
|
67
|
-
return
|
|
74
|
+
return Atom.make((get) => {
|
|
68
75
|
const actions = get(graph.actions(id));
|
|
69
76
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
70
|
-
return {
|
|
77
|
+
return {
|
|
78
|
+
nodes,
|
|
79
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id, relation: 'child' })),
|
|
80
|
+
};
|
|
71
81
|
});
|
|
72
|
-
}, [graph]);
|
|
82
|
+
}, [graph, id]);
|
|
73
83
|
|
|
74
84
|
const actionsCreator = useMemo(
|
|
75
|
-
() => createToolbarActions(model,
|
|
76
|
-
[model,
|
|
85
|
+
() => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
|
|
86
|
+
[model, stateAtom, registry, cursorFallbackRange, customActions],
|
|
77
87
|
);
|
|
78
88
|
const menu = useMenuActions(actionsCreator);
|
|
79
89
|
|
|
80
90
|
return (
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
</
|
|
91
|
+
<Menu.Root {...props} {...menu} attendableId={id}>
|
|
92
|
+
<Menu.Toolbar />
|
|
93
|
+
</Menu.Root>
|
|
84
94
|
);
|
|
85
95
|
};
|
|
@@ -2,17 +2,24 @@
|
|
|
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
17
|
import { meta } from '../../meta';
|
|
11
18
|
import { type SheetModel } from '../../model';
|
|
12
19
|
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
|
-
import { useSheetContext } from '../
|
|
20
|
+
import { useSheetContext } from '../SheetRoot';
|
|
14
21
|
|
|
15
|
-
import { type ToolbarState } from './useToolbarState';
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
16
23
|
|
|
17
24
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
18
25
|
|
|
@@ -24,18 +31,21 @@ const aligns: Record<AlignValue, string> = {
|
|
|
24
31
|
end: 'ph--text-align-right--regular',
|
|
25
32
|
};
|
|
26
33
|
|
|
27
|
-
export const useAlignState = (
|
|
34
|
+
export const useAlignState = (stateAtom: ToolbarStateAtom) => {
|
|
35
|
+
const registry = useContext(RegistryContext);
|
|
28
36
|
const { cursor, model } = useSheetContext();
|
|
29
37
|
useEffect(() => {
|
|
30
38
|
// TODO(thure): Can this O(n) call be memoized?
|
|
31
|
-
|
|
39
|
+
const alignValue = (
|
|
32
40
|
cursor
|
|
33
41
|
? model.sheet.ranges?.findLast(
|
|
34
42
|
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
35
43
|
)?.value
|
|
36
44
|
: undefined
|
|
37
45
|
) as AlignValue | undefined;
|
|
38
|
-
|
|
46
|
+
const prev = registry.get(stateAtom);
|
|
47
|
+
registry.set(stateAtom, { ...prev, [alignKey]: alignValue });
|
|
48
|
+
}, [cursor, model.sheet, registry, stateAtom]);
|
|
39
49
|
};
|
|
40
50
|
|
|
41
51
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
@@ -46,7 +56,15 @@ const createAlignGroupAction = (value?: AlignValue) =>
|
|
|
46
56
|
value: `${alignKey}--${value}`,
|
|
47
57
|
} as ToolbarMenuActionGroupProperties);
|
|
48
58
|
|
|
49
|
-
|
|
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) =>
|
|
50
68
|
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
51
69
|
return createMenuAction<AlignAction>(
|
|
52
70
|
`${alignKey}--${alignValue}`,
|
|
@@ -64,15 +82,22 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
64
82
|
key: alignKey,
|
|
65
83
|
value: alignValue as AlignValue,
|
|
66
84
|
};
|
|
85
|
+
const currentState = registry.get(stateAtom);
|
|
67
86
|
if (index < 0) {
|
|
68
|
-
model.sheet
|
|
69
|
-
|
|
87
|
+
Obj.change(model.sheet, (obj) => {
|
|
88
|
+
obj.ranges?.push(nextRangeEntity);
|
|
89
|
+
});
|
|
90
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
70
91
|
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
71
|
-
model.sheet
|
|
72
|
-
|
|
92
|
+
Obj.change(model.sheet, (obj) => {
|
|
93
|
+
obj.ranges?.splice(index, 1);
|
|
94
|
+
});
|
|
95
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
73
96
|
} else {
|
|
74
|
-
model.sheet
|
|
75
|
-
|
|
97
|
+
Obj.change(model.sheet, (obj) => {
|
|
98
|
+
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
|
+
});
|
|
100
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
76
101
|
}
|
|
77
102
|
},
|
|
78
103
|
{
|
|
@@ -86,14 +111,14 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
86
111
|
);
|
|
87
112
|
});
|
|
88
113
|
|
|
89
|
-
export const createAlign = (
|
|
90
|
-
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
91
|
-
const alignActions = createAlignActions(
|
|
114
|
+
export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
|
|
115
|
+
const alignGroup = createAlignGroupAction(context.state[alignKey]);
|
|
116
|
+
const alignActions = createAlignActions(context);
|
|
92
117
|
return {
|
|
93
118
|
nodes: [alignGroup, ...alignActions],
|
|
94
119
|
edges: [
|
|
95
|
-
{ source: 'root', target: 'align' },
|
|
96
|
-
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id })),
|
|
120
|
+
{ source: 'root', target: 'align', relation: 'child' },
|
|
121
|
+
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id, relation: 'child' })),
|
|
97
122
|
],
|
|
98
123
|
};
|
|
99
124
|
};
|
|
@@ -2,15 +2,24 @@
|
|
|
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
17
|
import { meta } from '../../meta';
|
|
11
18
|
import { type SheetModel } from '../../model';
|
|
12
19
|
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
|
-
import { useSheetContext } from '../
|
|
20
|
+
import { useSheetContext } from '../SheetRoot';
|
|
21
|
+
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
14
23
|
|
|
15
24
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
16
25
|
|
|
@@ -21,22 +30,30 @@ const styles: Record<StyleValue, string> = {
|
|
|
21
30
|
softwrap: 'ph--paragraph--regular',
|
|
22
31
|
};
|
|
23
32
|
|
|
24
|
-
export const useStyleState = (
|
|
33
|
+
export const useStyleState = (stateAtom: ToolbarStateAtom) => {
|
|
34
|
+
const registry = useContext(RegistryContext);
|
|
25
35
|
const { cursorFallbackRange, model } = useSheetContext();
|
|
26
36
|
|
|
27
37
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
let highlight = false;
|
|
39
|
+
let softwrap = false;
|
|
30
40
|
if (cursorFallbackRange && model.sheet.ranges) {
|
|
31
41
|
model.sheet.ranges
|
|
32
42
|
.filter(
|
|
33
43
|
({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
34
44
|
)
|
|
35
45
|
.forEach(({ value }) => {
|
|
36
|
-
|
|
46
|
+
if (value === 'highlight') {
|
|
47
|
+
highlight = true;
|
|
48
|
+
}
|
|
49
|
+
if (value === 'softwrap') {
|
|
50
|
+
softwrap = true;
|
|
51
|
+
}
|
|
37
52
|
});
|
|
38
53
|
}
|
|
39
|
-
|
|
54
|
+
const prev = registry.get(stateAtom);
|
|
55
|
+
registry.set(stateAtom, { ...prev, highlight, softwrap });
|
|
56
|
+
}, [cursorFallbackRange, model.sheet, registry, stateAtom]);
|
|
40
57
|
};
|
|
41
58
|
|
|
42
59
|
const createStyleGroup = (state: StyleState) => {
|
|
@@ -49,7 +66,15 @@ const createStyleGroup = (state: StyleState) => {
|
|
|
49
66
|
} as ToolbarMenuActionGroupProperties);
|
|
50
67
|
};
|
|
51
68
|
|
|
52
|
-
|
|
69
|
+
type StyleActionsContext = {
|
|
70
|
+
model: SheetModel;
|
|
71
|
+
state: ToolbarState;
|
|
72
|
+
stateAtom: ToolbarStateAtom;
|
|
73
|
+
registry: Registry.Registry;
|
|
74
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: StyleActionsContext) =>
|
|
53
78
|
Object.entries(styles).map(([styleValue, icon]) => {
|
|
54
79
|
return createMenuAction<StyleAction>(
|
|
55
80
|
`style--${styleValue}`,
|
|
@@ -67,6 +92,7 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
67
92
|
key: 'style',
|
|
68
93
|
value: styleValue as StyleValue,
|
|
69
94
|
};
|
|
95
|
+
const currentState = registry.get(stateAtom);
|
|
70
96
|
if (
|
|
71
97
|
model.sheet.ranges
|
|
72
98
|
.filter(
|
|
@@ -77,12 +103,16 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
77
103
|
) {
|
|
78
104
|
// this value should be unset
|
|
79
105
|
if (index >= 0) {
|
|
80
|
-
model.sheet
|
|
106
|
+
Obj.change(model.sheet, (obj) => {
|
|
107
|
+
obj.ranges?.splice(index, 1);
|
|
108
|
+
});
|
|
81
109
|
}
|
|
82
|
-
|
|
110
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
|
|
83
111
|
} else {
|
|
84
|
-
model.sheet
|
|
85
|
-
|
|
112
|
+
Obj.change(model.sheet, (obj) => {
|
|
113
|
+
obj.ranges?.push(nextRangeEntity);
|
|
114
|
+
});
|
|
115
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: true });
|
|
86
116
|
}
|
|
87
117
|
},
|
|
88
118
|
{
|
|
@@ -95,14 +125,14 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
95
125
|
);
|
|
96
126
|
});
|
|
97
127
|
|
|
98
|
-
export const createStyle = (
|
|
99
|
-
const styleGroupAction = createStyleGroup(state);
|
|
100
|
-
const styleActions = createStyleActions(
|
|
128
|
+
export const createStyle = (context: StyleActionsContext): ActionGraphProps => {
|
|
129
|
+
const styleGroupAction = createStyleGroup(context.state);
|
|
130
|
+
const styleActions = createStyleActions(context);
|
|
101
131
|
return {
|
|
102
132
|
nodes: [styleGroupAction, ...styleActions],
|
|
103
133
|
edges: [
|
|
104
|
-
{ source: 'root', target: 'style' },
|
|
105
|
-
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id })),
|
|
134
|
+
{ source: 'root', target: 'style', relation: 'child' },
|
|
135
|
+
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id, relation: 'child' })),
|
|
106
136
|
],
|
|
107
137
|
};
|
|
108
138
|
};
|
|
@@ -2,15 +2,32 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { live } from '@dxos/live-object';
|
|
5
|
+
import { Atom, type Registry, RegistryContext, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useMemo } from 'react';
|
|
8
7
|
|
|
9
8
|
import { type AlignState } from './align';
|
|
10
9
|
import { type StyleState } from './style';
|
|
11
10
|
|
|
12
11
|
export type ToolbarState = Partial<StyleState & AlignState>;
|
|
12
|
+
export type ToolbarStateAtom = Atom.Writable<ToolbarState>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a reactive toolbar state Atom.
|
|
16
|
+
*/
|
|
17
|
+
export const useToolbarState = (initialState: ToolbarState = {}): ToolbarStateAtom => {
|
|
18
|
+
return useMemo(() => Atom.make<ToolbarState>(initialState).pipe(Atom.keepAlive), []);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook to read the current toolbar state value.
|
|
23
|
+
*/
|
|
24
|
+
export const useToolbarStateValue = (stateAtom: ToolbarStateAtom): ToolbarState => {
|
|
25
|
+
return useAtomValue(stateAtom);
|
|
26
|
+
};
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Hook to get the registry for updating toolbar state.
|
|
30
|
+
*/
|
|
31
|
+
export const useToolbarStateRegistry = (): Registry.Registry => {
|
|
32
|
+
return useContext(RegistryContext);
|
|
16
33
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -2,11 +2,5 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { lazy } from 'react';
|
|
6
|
-
|
|
7
5
|
export * from './ComputeGraph';
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './RangeList';
|
|
10
|
-
export * from './SheetContext';
|
|
11
|
-
|
|
12
|
-
export const SheetContainer = lazy(() => import('./SheetContainer'));
|
|
6
|
+
export * from './Sheet';
|
|
@@ -6,38 +6,43 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
8
|
import { rangeToA1Notation } from '@dxos/compute';
|
|
9
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { Input, Message, useTranslation } from '@dxos/react-ui';
|
|
10
11
|
import { List } from '@dxos/react-ui-list';
|
|
11
|
-
import { ghostHover } from '@dxos/
|
|
12
|
+
import { ghostHover } from '@dxos/ui-theme';
|
|
12
13
|
|
|
13
14
|
import { meta } from '../../meta';
|
|
14
15
|
import { rangeFromIndex } from '../../types';
|
|
15
|
-
import {
|
|
16
|
+
import { Sheet } from '../../types';
|
|
16
17
|
|
|
17
18
|
export type RangeListProps = {
|
|
18
|
-
sheet:
|
|
19
|
+
sheet: Sheet.Sheet;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export const RangeList = ({ sheet }: RangeListProps) => {
|
|
22
23
|
const { t } = useTranslation(meta.id);
|
|
23
24
|
// TODO(thure): Implement similar to comments, #8121
|
|
24
|
-
const handleSelectRange = (range: Range) => {};
|
|
25
|
+
const handleSelectRange = (range: Sheet.Range) => {};
|
|
25
26
|
const handleDeleteRange = useCallback(
|
|
26
|
-
(range: Range) => {
|
|
27
|
+
(range: Sheet.Range) => {
|
|
27
28
|
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
28
|
-
|
|
29
|
+
Obj.change(sheet, (obj) => {
|
|
30
|
+
obj.ranges.splice(index, 1);
|
|
31
|
+
});
|
|
29
32
|
},
|
|
30
33
|
[sheet],
|
|
31
34
|
);
|
|
32
35
|
return (
|
|
33
36
|
<>
|
|
34
|
-
<
|
|
37
|
+
<Input.Root>
|
|
38
|
+
<Input.Label>{t('range list heading')}</Input.Label>
|
|
39
|
+
</Input.Root>
|
|
35
40
|
{sheet.ranges.length < 1 ? (
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
</
|
|
41
|
+
<Message.Root>
|
|
42
|
+
<Message.Title>{t('no ranges message')}</Message.Title>
|
|
43
|
+
</Message.Root>
|
|
39
44
|
) : (
|
|
40
|
-
<List.Root<Range> items={sheet.ranges} isItem={Schema.is(Range)}>
|
|
45
|
+
<List.Root<Sheet.Range> items={sheet.ranges} isItem={Schema.is(Sheet.Range)}>
|
|
41
46
|
{({ items: ranges }) =>
|
|
42
47
|
ranges.map((range, i) => (
|
|
43
48
|
<List.Item key={i} item={range} classNames={['p-2', ghostHover]}>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
10
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
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';
|
|
15
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
|
+
import { AttendableContainer } from '@dxos/react-ui-attention';
|
|
18
|
+
|
|
19
|
+
import { ComputeGraphContext, useComputeGraph } from '../../components';
|
|
20
|
+
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
21
|
+
import { translations } from '../../translations';
|
|
22
|
+
import { Sheet, SheetOperation } from '../../types';
|
|
23
|
+
import RangeList from '../RangeList';
|
|
24
|
+
|
|
25
|
+
import { SheetContainer } from './SheetContainer';
|
|
26
|
+
|
|
27
|
+
const meta = {
|
|
28
|
+
title: 'plugins/plugin-sheet/containers/SheetContainer',
|
|
29
|
+
component: SheetContainer,
|
|
30
|
+
decorators: [
|
|
31
|
+
withTheme(),
|
|
32
|
+
withLayout({ layout: 'fullscreen' }),
|
|
33
|
+
withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
|
|
34
|
+
withComputeGraphDecorator(),
|
|
35
|
+
withPluginManager({
|
|
36
|
+
plugins: [...corePlugins()],
|
|
37
|
+
capabilities: [
|
|
38
|
+
Capability.contributes(Capabilities.OperationResolver, [
|
|
39
|
+
OperationResolver.make({
|
|
40
|
+
operation: SheetOperation.DropAxis,
|
|
41
|
+
handler: ({ model, axis, axisIndex }) =>
|
|
42
|
+
Effect.sync(() => {
|
|
43
|
+
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
44
|
+
return { axis, axisIndex, index: 0, axisMeta: null, values: [] };
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
]),
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
parameters: {
|
|
52
|
+
layout: 'fullscreen',
|
|
53
|
+
translations,
|
|
54
|
+
},
|
|
55
|
+
} satisfies Meta<typeof SheetContainer>;
|
|
56
|
+
|
|
57
|
+
export default meta;
|
|
58
|
+
|
|
59
|
+
export const Default = () => {
|
|
60
|
+
const space = useSpace();
|
|
61
|
+
const graph = useComputeGraph(space);
|
|
62
|
+
const { registry } = useContext(ComputeGraphContext) ?? {};
|
|
63
|
+
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
64
|
+
if (!sheet || !space || !registry) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
70
|
+
<SheetContainer role='article' space={space} subject={sheet} registry={registry} ignoreAttention />
|
|
71
|
+
</AttendableContainer>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Spec = () => {
|
|
76
|
+
const space = useSpace();
|
|
77
|
+
const graph = useComputeGraph(space);
|
|
78
|
+
const { registry } = useContext(ComputeGraphContext) ?? {};
|
|
79
|
+
const sheet = useTestSheet(space, graph, { cells: { A1: { value: 'Ready' } } });
|
|
80
|
+
if (!sheet || !space || !registry) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
86
|
+
<div role='none' className='w-full grid grid-cols-[1fr_20rem]'>
|
|
87
|
+
<SheetContainer role='article' space={space} subject={sheet} registry={registry} ignoreAttention />
|
|
88
|
+
<div role='none' data-testid='grid.range-list'>
|
|
89
|
+
<RangeList sheet={sheet} />
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</AttendableContainer>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { type ComputeGraphRegistry } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
11
|
+
import { Panel } from '@dxos/react-ui';
|
|
12
|
+
|
|
13
|
+
import { ComputeGraphContextProvider, Sheet, useComputeGraph } from '../../components';
|
|
14
|
+
import { type Sheet as SheetType } from '../../types';
|
|
15
|
+
|
|
16
|
+
export type SheetContainerProps = SurfaceComponentProps<
|
|
17
|
+
SheetType.Sheet,
|
|
18
|
+
{
|
|
19
|
+
space: Space;
|
|
20
|
+
registry: ComputeGraphRegistry;
|
|
21
|
+
ignoreAttention?: boolean;
|
|
22
|
+
}
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export const SheetContainer = ({ registry, ...props }: SheetContainerProps) => (
|
|
26
|
+
<ComputeGraphContextProvider registry={registry}>
|
|
27
|
+
<SheetContainerInner {...props} />
|
|
28
|
+
</ComputeGraphContextProvider>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const SheetContainerInner = ({
|
|
32
|
+
role,
|
|
33
|
+
subject: sheet,
|
|
34
|
+
space,
|
|
35
|
+
ignoreAttention,
|
|
36
|
+
}: Omit<SheetContainerProps, 'registry'>) => {
|
|
37
|
+
const graph = useComputeGraph(space);
|
|
38
|
+
if (!graph) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Sheet.Root graph={graph} sheet={sheet} ignoreAttention={ignoreAttention}>
|
|
44
|
+
<Panel.Root classNames={role === 'section' && 'aspect-aquare'}>
|
|
45
|
+
<Panel.Toolbar asChild>
|
|
46
|
+
<Sheet.Toolbar id={Obj.getDXN(sheet).toString()} />
|
|
47
|
+
</Panel.Toolbar>
|
|
48
|
+
<Panel.Content asChild>
|
|
49
|
+
<Sheet.Content />
|
|
50
|
+
</Panel.Content>
|
|
51
|
+
<Panel.Statusbar asChild>
|
|
52
|
+
<Sheet.Statusbar />
|
|
53
|
+
</Panel.Statusbar>
|
|
54
|
+
</Panel.Root>
|
|
55
|
+
</Sheet.Root>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComponentType, lazy } from 'react';
|
|
6
|
+
|
|
7
|
+
export const RangeList: ComponentType<any> = lazy(() => import('./RangeList'));
|
|
8
|
+
export const SheetContainer: ComponentType<any> = lazy(() => import('./SheetContainer'));
|