@dxos/plugin-sheet 0.8.4-main.67995b8 → 0.8.4-main.ae835ea
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-KDGD4AVG.mjs → SheetContainer-GTINUSNB.mjs} +31 -33
- package/dist/lib/browser/SheetContainer-GTINUSNB.mjs.map +7 -0
- package/dist/lib/browser/{anchor-sort-VHURGBOY.mjs → anchor-sort-R5CB37J7.mjs} +7 -7
- package/dist/lib/browser/anchor-sort-R5CB37J7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KJWZUQVA.mjs → chunk-73AV3NH6.mjs} +4 -4
- package/dist/lib/browser/chunk-73AV3NH6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7HQX4NQP.mjs → chunk-7VEWYJJN.mjs} +2 -2
- package/dist/lib/browser/chunk-7VEWYJJN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SI4X5GUR.mjs → chunk-DVJ3QW3F.mjs} +220 -205
- package/dist/lib/browser/chunk-DVJ3QW3F.mjs.map +7 -0
- package/dist/lib/browser/chunk-FWFAAGXL.mjs +28 -0
- package/dist/lib/browser/chunk-FWFAAGXL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JUOVL3LE.mjs → chunk-LS6D4GG7.mjs} +208 -205
- package/dist/lib/browser/chunk-LS6D4GG7.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-AP5RA7W3.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-AP5RA7W3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -21
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-WOJGZMSV.mjs → intent-resolver-66OAYVQF.mjs} +10 -10
- package/dist/lib/browser/intent-resolver-66OAYVQF.mjs.map +7 -0
- package/dist/lib/browser/{markdown-VXMIPUQC.mjs → markdown-B6VKYY2S.mjs} +6 -6
- package/dist/lib/browser/markdown-B6VKYY2S.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-SE4HGAEH.mjs → react-surface-F3VQPGDV.mjs} +14 -14
- package/dist/lib/browser/react-surface-F3VQPGDV.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -12
- package/dist/lib/node-esm/{SheetContainer-RMG24NZC.mjs → SheetContainer-PW4KNZME.mjs} +31 -33
- package/dist/lib/node-esm/SheetContainer-PW4KNZME.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-CTJGOPET.mjs → anchor-sort-HEND452H.mjs} +7 -7
- package/dist/lib/node-esm/anchor-sort-HEND452H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6SK5LJ5S.mjs → chunk-44YTKTMP.mjs} +4 -4
- package/dist/lib/node-esm/chunk-44YTKTMP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CADTJFAS.mjs → chunk-4H2EHVWE.mjs} +220 -205
- package/dist/lib/node-esm/chunk-4H2EHVWE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Q6UYC4G5.mjs → chunk-4QV4AGWK.mjs} +2 -2
- package/dist/lib/node-esm/chunk-4QV4AGWK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HILDMVPL.mjs +29 -0
- package/dist/lib/node-esm/chunk-HILDMVPL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IFMIRCZH.mjs → chunk-LYUIM3QG.mjs} +208 -205
- package/dist/lib/node-esm/chunk-LYUIM3QG.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-UMQ5UYCL.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-UMQ5UYCL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -21
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-PZRXBNIJ.mjs → intent-resolver-VNKIMQQT.mjs} +10 -10
- package/dist/lib/node-esm/intent-resolver-VNKIMQQT.mjs.map +7 -0
- package/dist/lib/node-esm/{markdown-4VPQJZNZ.mjs → markdown-VKY7HXU2.mjs} +6 -6
- package/dist/lib/node-esm/markdown-VKY7HXU2.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-LAU23XBH.mjs → react-surface-GGX76V2Y.mjs} +14 -14
- package/dist/lib/node-esm/react-surface-GGX76V2Y.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -12
- package/dist/types/src/SheetPlugin.d.ts +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort.d.ts +2 -2
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +1 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -8
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -3
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 +50 -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 +2 -2
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +52 -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 +86 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +2 -2
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.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/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +5 -5
- 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/sheet-manager.d.ts +1 -1
- package/dist/types/src/playwright/sheet-manager.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 +27 -3
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/{schema.d.ts → Sheet.d.ts} +37 -4
- package/dist/types/src/types/Sheet.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -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 +7 -16
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +9 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +67 -67
- package/src/SheetPlugin.tsx +71 -62
- package/src/capabilities/anchor-sort.ts +3 -3
- package/src/capabilities/capabilities.ts +2 -2
- package/src/capabilities/compute-graph-registry.ts +9 -14
- package/src/capabilities/intent-resolver.ts +5 -5
- package/src/capabilities/markdown.ts +3 -2
- package/src/capabilities/react-surface.tsx +9 -8
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
- package/src/components/GridSheet/GridSheet.stories.tsx +19 -13
- package/src/components/GridSheet/GridSheet.tsx +23 -22
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +40 -42
- package/src/components/GridSheet/util.ts +6 -6
- package/src/components/RangeList/RangeList.tsx +8 -8
- package/src/components/SheetContainer/SheetContainer.stories.tsx +41 -40
- package/src/components/SheetContainer/SheetContainer.tsx +8 -4
- package/src/components/SheetContext/SheetContext.tsx +3 -3
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
- package/src/components/SheetToolbar/SheetToolbar.tsx +20 -24
- package/src/components/SheetToolbar/align.ts +7 -6
- package/src/components/SheetToolbar/style.ts +4 -4
- package/src/extensions/compute.stories.tsx +29 -25
- package/src/extensions/compute.ts +2 -3
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
- package/src/integrations/thread-ranges.ts +11 -10
- package/src/meta.ts +7 -5
- package/src/model/sheet-model.test.ts +5 -4
- package/src/model/sheet-model.ts +9 -9
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/sheet-manager.ts +1 -1
- package/src/playwright/sheet.spec.ts +1 -1
- package/src/sanity.test.ts +4 -5
- package/src/serializer.ts +3 -3
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +11 -5
- package/src/translations.ts +2 -2
- package/src/types/Sheet.ts +103 -0
- package/src/types/index.ts +1 -1
- package/src/types/sheet-range-types.ts +2 -2
- package/src/types/types.ts +6 -15
- package/src/types/util.ts +13 -41
- package/dist/lib/browser/SheetContainer-KDGD4AVG.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-VHURGBOY.mjs.map +0 -7
- package/dist/lib/browser/chunk-6AKBCBL4.mjs +0 -18
- package/dist/lib/browser/chunk-6AKBCBL4.mjs.map +0 -7
- package/dist/lib/browser/chunk-7HQX4NQP.mjs.map +0 -7
- package/dist/lib/browser/chunk-JUOVL3LE.mjs.map +0 -7
- package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
- package/dist/lib/browser/chunk-SI4X5GUR.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-VG7VP7IV.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-VG7VP7IV.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-WOJGZMSV.mjs.map +0 -7
- package/dist/lib/browser/markdown-VXMIPUQC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SE4HGAEH.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-RMG24NZC.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-CTJGOPET.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs +0 -20
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CADTJFAS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IFMIRCZH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q6UYC4G5.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-3K3Q2A5T.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-3K3Q2A5T.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-PZRXBNIJ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-4VPQJZNZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LAU23XBH.mjs.map +0 -7
- 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/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -61
- /package/src/extensions/editor/{extension.ts → sheet-extension.ts} +0 -0
|
@@ -7,55 +7,51 @@ import React, { type PropsWithChildren, useMemo } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useAppGraph } from '@dxos/app-framework';
|
|
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,
|
|
15
|
+
rxFromSignal,
|
|
19
16
|
useMenuActions,
|
|
20
17
|
} from '@dxos/react-ui-menu';
|
|
21
18
|
|
|
22
|
-
import { createAlign, useAlignState } from './align';
|
|
23
|
-
import { createStyle, useStyleState } from './style';
|
|
24
|
-
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
25
19
|
import { type SheetModel } from '../../model';
|
|
26
20
|
import { useSheetContext } from '../SheetContext';
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export type SheetToolbarProps = ThemedClassName<PropsWithChildren<{ id: string }>>;
|
|
22
|
+
import { createAlign, useAlignState } from './align';
|
|
23
|
+
import { createStyle, useStyleState } from './style';
|
|
24
|
+
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
33
25
|
|
|
34
26
|
const createToolbarActions = (
|
|
35
27
|
model: SheetModel,
|
|
36
28
|
state: ToolbarState,
|
|
37
29
|
cursorFallbackRange?: CompleteCellRange,
|
|
38
30
|
customActions?: Rx.Rx<ActionGraphProps>,
|
|
39
|
-
) => {
|
|
31
|
+
): Rx.Rx<ActionGraphProps> => {
|
|
40
32
|
return Rx.make((get) => {
|
|
41
33
|
const align = get(rxFromSignal(() => createAlign(model, state, cursorFallbackRange)));
|
|
42
34
|
const style = get(rxFromSignal(() => createStyle(model, state, cursorFallbackRange)));
|
|
43
35
|
const gap = createGapSeparator();
|
|
44
|
-
|
|
45
|
-
const
|
|
36
|
+
|
|
37
|
+
const graph: ActionGraphProps = {
|
|
38
|
+
nodes: [...align.nodes, ...style.nodes, ...gap.nodes],
|
|
39
|
+
edges: [...align.edges, ...style.edges, ...gap.edges],
|
|
40
|
+
};
|
|
41
|
+
|
|
46
42
|
if (customActions) {
|
|
47
43
|
const custom = get(customActions);
|
|
48
|
-
nodes.push(...custom.nodes);
|
|
49
|
-
edges.push(...custom.edges);
|
|
44
|
+
graph.nodes.push(...custom.nodes);
|
|
45
|
+
graph.edges.push(...custom.edges);
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
edges,
|
|
54
|
-
};
|
|
47
|
+
|
|
48
|
+
return graph;
|
|
55
49
|
});
|
|
56
50
|
};
|
|
57
51
|
|
|
58
|
-
export
|
|
52
|
+
export type SheetToolbarProps = PropsWithChildren<{ id: string }>;
|
|
53
|
+
|
|
54
|
+
export const SheetToolbar = ({ id }: SheetToolbarProps) => {
|
|
59
55
|
const { model, cursorFallbackRange } = useSheetContext();
|
|
60
56
|
const state = useToolbarState({});
|
|
61
57
|
useAlignState(state);
|
|
@@ -78,7 +74,7 @@ export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
|
|
|
78
74
|
|
|
79
75
|
return (
|
|
80
76
|
<MenuProvider {...menu} attendableId={id}>
|
|
81
|
-
<ToolbarMenu
|
|
77
|
+
<ToolbarMenu />
|
|
82
78
|
</MenuProvider>
|
|
83
79
|
);
|
|
84
80
|
};
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import { createMenuAction, createMenuItemGroup
|
|
8
|
+
import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import { SHEET_PLUGIN } from '../../meta';
|
|
10
|
+
import { meta } from '../../meta';
|
|
12
11
|
import { type SheetModel } from '../../model';
|
|
13
|
-
import { type AlignKey,
|
|
12
|
+
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
14
13
|
import { useSheetContext } from '../SheetContext';
|
|
15
14
|
|
|
15
|
+
import { type ToolbarState } from './useToolbarState';
|
|
16
|
+
|
|
16
17
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
17
18
|
|
|
18
19
|
export type AlignState = { [alignKey]: AlignValue | undefined };
|
|
@@ -39,7 +40,7 @@ export const useAlignState = (state: Partial<AlignState>) => {
|
|
|
39
40
|
|
|
40
41
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
41
42
|
createMenuItemGroup('align', {
|
|
42
|
-
label: ['align label', { ns:
|
|
43
|
+
label: ['align label', { ns: meta.id }],
|
|
43
44
|
variant: 'toggleGroup',
|
|
44
45
|
selectCardinality: 'single',
|
|
45
46
|
value: `${alignKey}--${value}`,
|
|
@@ -78,7 +79,7 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
78
79
|
key: alignKey,
|
|
79
80
|
value: alignValue as AlignValue,
|
|
80
81
|
checked: state[alignKey] === alignValue,
|
|
81
|
-
label: [`range value ${alignValue} label`, { ns:
|
|
82
|
+
label: [`range value ${alignValue} label`, { ns: meta.id }],
|
|
82
83
|
icon,
|
|
83
84
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
84
85
|
},
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import { createMenuAction, createMenuItemGroup
|
|
8
|
+
import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
11
|
import { type SheetModel } from '../../model';
|
|
12
|
-
import {
|
|
12
|
+
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
13
|
import { useSheetContext } from '../SheetContext';
|
|
14
14
|
|
|
15
15
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
@@ -89,7 +89,7 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
89
89
|
key: 'style',
|
|
90
90
|
value: styleValue as StyleValue,
|
|
91
91
|
icon,
|
|
92
|
-
label: [`range value ${styleValue} label`, { ns:
|
|
92
|
+
label: [`range value ${styleValue} label`, { ns: meta.id }],
|
|
93
93
|
checked: !!state[styleValue as StyleValue],
|
|
94
94
|
},
|
|
95
95
|
);
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useMemo } from 'react';
|
|
9
7
|
|
|
8
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
10
|
import { PublicKey } from '@dxos/keys';
|
|
11
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
12
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
13
|
import { useThemeContext } from '@dxos/react-ui';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
15
|
import {
|
|
15
16
|
createBasicExtensions,
|
|
16
17
|
createMarkdownExtensions,
|
|
@@ -19,14 +20,14 @@ import {
|
|
|
19
20
|
documentId,
|
|
20
21
|
useTextEditor,
|
|
21
22
|
} from '@dxos/react-ui-editor';
|
|
22
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
23
23
|
import { isNonNullable } from '@dxos/util';
|
|
24
24
|
|
|
25
|
-
import { compute, computeGraphFacet } from './compute';
|
|
26
25
|
import { GridSheet, SheetProvider, useComputeGraph } from '../components';
|
|
27
26
|
import { useSheetModel } from '../model';
|
|
28
27
|
import { useTestSheet, withComputeGraphDecorator } from '../testing';
|
|
29
|
-
import {
|
|
28
|
+
import { Sheet } from '../types';
|
|
29
|
+
|
|
30
|
+
import { compute, computeGraphFacet } from './compute';
|
|
30
31
|
|
|
31
32
|
const str = (...lines: string[]) => lines.join('\n');
|
|
32
33
|
|
|
@@ -41,7 +42,7 @@ type EditorProps = {
|
|
|
41
42
|
|
|
42
43
|
const SHEET_NAME = 'Test Sheet';
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const DefaultStory = ({ text }: EditorProps) => {
|
|
45
46
|
const id = useMemo(() => PublicKey.random(), []);
|
|
46
47
|
const { themeMode } = useThemeContext();
|
|
47
48
|
const space = useSpace();
|
|
@@ -51,7 +52,7 @@ const EditorStory = ({ text }: EditorProps) => {
|
|
|
51
52
|
initialValue: text,
|
|
52
53
|
extensions: [
|
|
53
54
|
createBasicExtensions(),
|
|
54
|
-
createMarkdownExtensions(
|
|
55
|
+
createMarkdownExtensions(),
|
|
55
56
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
56
57
|
documentId.of(id.toHex()),
|
|
57
58
|
computeGraph && computeGraphFacet.of(computeGraph),
|
|
@@ -92,15 +93,31 @@ const Grid = () => {
|
|
|
92
93
|
const GraphStory = (props: EditorProps) => {
|
|
93
94
|
return (
|
|
94
95
|
<div className='grid grid-rows-2'>
|
|
95
|
-
<
|
|
96
|
+
<DefaultStory {...props} />
|
|
96
97
|
<Grid />
|
|
97
98
|
</div>
|
|
98
99
|
);
|
|
99
100
|
};
|
|
100
101
|
|
|
102
|
+
const meta = {
|
|
103
|
+
title: 'plugins/plugin-sheet/extensions',
|
|
104
|
+
decorators: [
|
|
105
|
+
withTheme,
|
|
106
|
+
withClientProvider({ types: [Sheet.Sheet], createIdentity: true, createSpace: true }),
|
|
107
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
108
|
+
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
109
|
+
withComputeGraphDecorator(),
|
|
110
|
+
],
|
|
111
|
+
parameters: {
|
|
112
|
+
layout: 'fullscreen',
|
|
113
|
+
},
|
|
114
|
+
} satisfies Meta;
|
|
115
|
+
|
|
116
|
+
export default meta;
|
|
117
|
+
|
|
101
118
|
// TODO(burdon): Inline formulae.
|
|
102
|
-
export const Default = {
|
|
103
|
-
render:
|
|
119
|
+
export const Default: StoryObj<typeof DefaultStory> = {
|
|
120
|
+
render: DefaultStory,
|
|
104
121
|
args: {
|
|
105
122
|
text: str(
|
|
106
123
|
//
|
|
@@ -123,7 +140,7 @@ export const Default = {
|
|
|
123
140
|
},
|
|
124
141
|
};
|
|
125
142
|
|
|
126
|
-
export const Graph = {
|
|
143
|
+
export const Graph: StoryObj<typeof GraphStory> = {
|
|
127
144
|
render: GraphStory,
|
|
128
145
|
args: {
|
|
129
146
|
text: str(
|
|
@@ -140,16 +157,3 @@ export const Graph = {
|
|
|
140
157
|
),
|
|
141
158
|
},
|
|
142
159
|
};
|
|
143
|
-
|
|
144
|
-
const meta: Meta = {
|
|
145
|
-
title: 'plugins/plugin-sheet/extensions',
|
|
146
|
-
decorators: [
|
|
147
|
-
withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
|
|
148
|
-
withComputeGraphDecorator(),
|
|
149
|
-
withTheme,
|
|
150
|
-
withLayout({ fullscreen: true, classNames: 'justify-center' }),
|
|
151
|
-
],
|
|
152
|
-
parameters: { layout: 'fullscreen' },
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export default meta;
|
|
@@ -16,11 +16,11 @@ import { Decoration, EditorView, ViewPlugin, WidgetType } from '@codemirror/view
|
|
|
16
16
|
|
|
17
17
|
import { type CleanupFn, debounce } from '@dxos/async';
|
|
18
18
|
import {
|
|
19
|
-
createSheetName,
|
|
20
19
|
type CellAddress,
|
|
21
20
|
type CellScalarValue,
|
|
22
21
|
type ComputeGraph,
|
|
23
22
|
type ComputeNode,
|
|
23
|
+
createSheetName,
|
|
24
24
|
} from '@dxos/compute';
|
|
25
25
|
import { invariant } from '@dxos/invariant';
|
|
26
26
|
import { documentId, singleValueFacet } from '@dxos/react-ui-editor';
|
|
@@ -34,7 +34,7 @@ export const computeGraphFacet = singleValueFacet<ComputeGraph>();
|
|
|
34
34
|
|
|
35
35
|
export type ComputeOptions = {};
|
|
36
36
|
|
|
37
|
-
export const compute = (
|
|
37
|
+
export const compute = (_options: ComputeOptions = {}): Extension => {
|
|
38
38
|
let computeNode: ComputeNode | undefined;
|
|
39
39
|
|
|
40
40
|
const update = (state: EditorState, current?: RangeSet<Decoration>) => {
|
|
@@ -53,7 +53,6 @@ export const compute = (options: ComputeOptions = {}): Extension => {
|
|
|
53
53
|
const text = node.node.getChild('CodeText');
|
|
54
54
|
if (type === LANGUAGE_TAG && text) {
|
|
55
55
|
const formula = state.sliceDoc(text.from, text.to);
|
|
56
|
-
|
|
57
56
|
const iter = current?.iter(node.node.from);
|
|
58
57
|
if (iter?.value && iter?.value.spec.formula === formula) {
|
|
59
58
|
// Add existing widget.
|
|
@@ -10,7 +10,7 @@ import { describe, expect, test } from 'vitest';
|
|
|
10
10
|
|
|
11
11
|
import { defaultFunctions } from '@dxos/compute';
|
|
12
12
|
|
|
13
|
-
import { sheetExtension } from './extension';
|
|
13
|
+
import { sheetExtension } from './sheet-extension';
|
|
14
14
|
|
|
15
15
|
describe('formula parser', () => {
|
|
16
16
|
const {
|
|
@@ -2,28 +2,29 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
6
7
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
7
8
|
|
|
8
9
|
import {
|
|
10
|
+
LayoutAction,
|
|
11
|
+
chain,
|
|
9
12
|
createIntent,
|
|
10
13
|
createResolver,
|
|
11
|
-
LayoutAction,
|
|
12
|
-
useIntentResolver,
|
|
13
14
|
useIntentDispatcher,
|
|
14
|
-
|
|
15
|
+
useIntentResolver,
|
|
15
16
|
} from '@dxos/app-framework';
|
|
16
17
|
import { debounce } from '@dxos/async';
|
|
17
18
|
import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
|
|
18
19
|
import { Obj, Relation } from '@dxos/echo';
|
|
19
20
|
import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
|
|
20
|
-
import {
|
|
21
|
-
import { Filter, fullyQualifiedId, getSpace,
|
|
21
|
+
import { Thread, ThreadAction } from '@dxos/plugin-thread/types';
|
|
22
|
+
import { Filter, Query, fullyQualifiedId, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
22
23
|
import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
|
|
23
24
|
import { AnchoredTo } from '@dxos/schema';
|
|
24
25
|
|
|
25
26
|
import { useSheetContext } from '../components';
|
|
26
|
-
import {
|
|
27
|
+
import { meta } from '../meta';
|
|
27
28
|
|
|
28
29
|
export const completeCellRangeToThreadCursor = (range: CompleteCellRange): string => {
|
|
29
30
|
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
@@ -72,7 +73,7 @@ export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null
|
|
|
72
73
|
[model.sheet, setActiveRefs],
|
|
73
74
|
);
|
|
74
75
|
|
|
75
|
-
useIntentResolver(
|
|
76
|
+
useIntentResolver(meta.id, scrollIntoViewResolver);
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
export const useSelectThreadOnCellFocus = () => {
|
|
@@ -90,7 +91,7 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
90
91
|
|
|
91
92
|
const closestThread = anchors.find((anchor) => {
|
|
92
93
|
const source = Relation.getSource(anchor);
|
|
93
|
-
if (anchor.anchor && Obj.instanceOf(
|
|
94
|
+
if (anchor.anchor && Obj.instanceOf(Thread.Thread, source)) {
|
|
94
95
|
const range = parseThreadAnchorAsCellRange(anchor.anchor);
|
|
95
96
|
return range ? inRange(range, cellAddress) : false;
|
|
96
97
|
} else {
|
|
@@ -100,7 +101,7 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
100
101
|
|
|
101
102
|
if (closestThread) {
|
|
102
103
|
const primary = fullyQualifiedId(model.sheet);
|
|
103
|
-
const intent = pipe(
|
|
104
|
+
const intent = Function.pipe(
|
|
104
105
|
createIntent(ThreadAction.Select, { current: fullyQualifiedId(closestThread) }),
|
|
105
106
|
chain(DeckAction.ChangeCompanion, { primary, companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments` }),
|
|
106
107
|
);
|
package/src/meta.ts
CHANGED
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
export const SHEET_PLUGIN = 'dxos.org/plugin/sheet';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
8
7
|
|
|
9
8
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
9
|
+
id: 'dxos.org/plugin/sheet',
|
|
11
10
|
name: 'Sheet',
|
|
12
|
-
description:
|
|
13
|
-
|
|
11
|
+
description: trim`
|
|
12
|
+
Full-featured spreadsheet application with over 400 built-in formulas for calculations and data analysis.
|
|
13
|
+
Create custom JavaScript functions and integrate with AI agents for advanced automation.
|
|
14
|
+
`,
|
|
14
15
|
icon: 'ph--grid-nine--regular',
|
|
16
|
+
iconHue: 'indigo',
|
|
15
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-sheet',
|
|
16
18
|
screenshots: ['https://dxos.network/plugin-details-sheet-dark.png'],
|
|
17
19
|
};
|
|
@@ -7,17 +7,18 @@ import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'v
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { type CellScalarValue, addressFromA1Notation, isFormula } from '@dxos/compute';
|
|
9
9
|
import { TestBuilder, testFunctionPlugins } from '@dxos/compute/testing';
|
|
10
|
-
import {
|
|
10
|
+
import { Function } from '@dxos/functions';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
|
|
13
|
+
import { Sheet, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from '../types';
|
|
14
|
+
|
|
13
15
|
import { SheetModel } from './sheet-model';
|
|
14
16
|
import { createTestGrid } from './testing';
|
|
15
|
-
import { createSheet, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from '../types';
|
|
16
17
|
|
|
17
18
|
describe('SheetModel', () => {
|
|
18
19
|
let testBuilder: TestBuilder;
|
|
19
20
|
beforeEach(async () => {
|
|
20
|
-
testBuilder = new TestBuilder({ types: [
|
|
21
|
+
testBuilder = new TestBuilder({ types: [Function.Function], plugins: testFunctionPlugins });
|
|
21
22
|
await testBuilder.open();
|
|
22
23
|
});
|
|
23
24
|
afterEach(async () => {
|
|
@@ -30,7 +31,7 @@ describe('SheetModel', () => {
|
|
|
30
31
|
await graph.open();
|
|
31
32
|
|
|
32
33
|
// TODO(burdon): Create via factory.
|
|
33
|
-
const sheet =
|
|
34
|
+
const sheet = Sheet.make({ rows: 5, columns: 5 });
|
|
34
35
|
const model = new SheetModel(graph, sheet);
|
|
35
36
|
await model.open();
|
|
36
37
|
testBuilder.ctx.onDispose(() => model.close());
|
package/src/model/sheet-model.ts
CHANGED
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
6
|
import {
|
|
7
|
-
addressFromA1Notation,
|
|
8
|
-
addressToA1Notation,
|
|
9
|
-
createSheetName,
|
|
10
|
-
isFormula,
|
|
11
7
|
type CellAddress,
|
|
12
8
|
type CellRange,
|
|
13
9
|
type CellScalarValue,
|
|
@@ -16,14 +12,18 @@ import {
|
|
|
16
12
|
type ComputeNodeEvent,
|
|
17
13
|
DetailedCellError,
|
|
18
14
|
ExportedCellChange,
|
|
19
|
-
type SimpleCellRange,
|
|
20
15
|
type SimpleCellAddress,
|
|
16
|
+
type SimpleCellRange,
|
|
21
17
|
type SimpleDate,
|
|
22
18
|
type SimpleDateTime,
|
|
19
|
+
addressFromA1Notation,
|
|
20
|
+
addressToA1Notation,
|
|
21
|
+
createSheetName,
|
|
22
|
+
isFormula,
|
|
23
23
|
} from '@dxos/compute';
|
|
24
24
|
import { Resource } from '@dxos/context';
|
|
25
25
|
import { Obj } from '@dxos/echo';
|
|
26
|
-
import { FormatEnum, TypeEnum } from '@dxos/echo
|
|
26
|
+
import { FormatEnum, TypeEnum } from '@dxos/echo/internal';
|
|
27
27
|
import { invariant } from '@dxos/invariant';
|
|
28
28
|
import { PublicKey } from '@dxos/keys';
|
|
29
29
|
import { log } from '@dxos/log';
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
mapFormulaIndicesToRefs,
|
|
40
40
|
mapFormulaRefsToIndices,
|
|
41
41
|
} from '../types';
|
|
42
|
-
import { type
|
|
42
|
+
import { type Sheet, type SheetAction } from '../types';
|
|
43
43
|
|
|
44
44
|
// TODO(burdon): Move to compute.
|
|
45
45
|
// Map sheet types to system types.
|
|
@@ -92,7 +92,7 @@ export class SheetModel extends Resource {
|
|
|
92
92
|
|
|
93
93
|
constructor(
|
|
94
94
|
private readonly _graph: ComputeGraph,
|
|
95
|
-
private readonly _sheet:
|
|
95
|
+
private readonly _sheet: Sheet.Sheet,
|
|
96
96
|
private readonly _options: SheetModelOptions = {},
|
|
97
97
|
) {
|
|
98
98
|
super();
|
|
@@ -414,7 +414,7 @@ export class SheetModel extends Resource {
|
|
|
414
414
|
/**
|
|
415
415
|
* Sets values from a simple map.
|
|
416
416
|
*/
|
|
417
|
-
setValues(values: Record<string, CellValue>): void {
|
|
417
|
+
setValues(values: Record<string, Sheet.CellValue>): void {
|
|
418
418
|
Object.entries(values).forEach(([key, { value }]) => {
|
|
419
419
|
this.setValue(addressFromA1Notation(key), value);
|
|
420
420
|
});
|
package/src/model/testing.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import { addressToA1Notation } from '@dxos/compute';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Sheet } from '../types';
|
|
8
8
|
|
|
9
9
|
// TODO(burdon): Create testing endpoint.
|
|
10
10
|
// TODO(burdon): Move to react-ui-sheet.
|
|
11
|
-
export const createTestGrid = ({ cols = 4, rows = 10 }: { cols: number; rows: number }):
|
|
11
|
+
export const createTestGrid = ({ cols = 4, rows = 10 }: { cols: number; rows: number }): Sheet.Sheet => {
|
|
12
12
|
const year = new Date().getFullYear();
|
|
13
13
|
|
|
14
|
-
const cells: Record<string, CellValue> = {};
|
|
14
|
+
const cells: Record<string, Sheet.CellValue> = {};
|
|
15
15
|
for (let col = 1; col <= cols; col++) {
|
|
16
16
|
for (let row = 1; row <= 10; row++) {
|
|
17
17
|
const cell = addressToA1Notation({ col, row });
|
|
@@ -27,7 +27,7 @@ export const createTestGrid = ({ cols = 4, rows = 10 }: { cols: number; rows: nu
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const sheet =
|
|
30
|
+
const sheet = Sheet.make({
|
|
31
31
|
name: 'Test',
|
|
32
32
|
cells,
|
|
33
33
|
});
|
|
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
|
|
|
7
7
|
import { type ComputeGraph } from '@dxos/compute';
|
|
8
8
|
|
|
9
9
|
import { SheetModel } from '../model';
|
|
10
|
-
import { type
|
|
10
|
+
import { type Sheet } from '../types';
|
|
11
11
|
|
|
12
12
|
export type UseSheetModelOptions = {
|
|
13
13
|
readonly?: boolean;
|
|
@@ -15,7 +15,7 @@ export type UseSheetModelOptions = {
|
|
|
15
15
|
|
|
16
16
|
export const useSheetModel = (
|
|
17
17
|
graph?: ComputeGraph,
|
|
18
|
-
sheet?:
|
|
18
|
+
sheet?: Sheet.Sheet,
|
|
19
19
|
{ readonly }: UseSheetModelOptions = {},
|
|
20
20
|
): SheetModel | undefined => {
|
|
21
21
|
const [model, setModel] = useState<SheetModel>();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type Locator, type Page } from '@playwright/test';
|
|
6
6
|
|
|
7
7
|
import { DxGridManager } from '@dxos/lit-grid/testing';
|
|
8
|
-
import { type
|
|
8
|
+
import { type DxGridAxis, type DxGridPosition } from '@dxos/react-ui-grid';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Test helper for managing dx-grid interactions and assertions in Playwright tests.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect, test
|
|
5
|
+
import { type Page, expect, test } from '@playwright/test';
|
|
6
6
|
|
|
7
7
|
import { faker } from '@dxos/random';
|
|
8
8
|
import { setupPage, storybookUrl } from '@dxos/test-utils/playwright';
|
package/src/sanity.test.ts
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { describe,
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Client } from '@dxos/client';
|
|
8
|
-
import {
|
|
9
|
-
import { FunctionType } from '@dxos/functions';
|
|
8
|
+
import { Function } from '@dxos/functions';
|
|
10
9
|
|
|
11
10
|
// Part 2.
|
|
12
11
|
// TODO(burdon): Cannot test outside of browser.
|
|
@@ -23,7 +22,7 @@ import { FunctionType } from '@dxos/functions';
|
|
|
23
22
|
describe('test', () => {
|
|
24
23
|
test('test', async () => {
|
|
25
24
|
const client = new Client();
|
|
26
|
-
client.addTypes([
|
|
25
|
+
client.addTypes([Function.Function]);
|
|
27
26
|
await client.initialize();
|
|
28
27
|
await client.halo.createIdentity();
|
|
29
28
|
|
|
@@ -34,7 +33,7 @@ describe('test', () => {
|
|
|
34
33
|
// - ERROR "process.nextTick is not a function"
|
|
35
34
|
// - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
|
|
36
35
|
const space = await client.spaces.create();
|
|
37
|
-
const fn = space.db.add(
|
|
36
|
+
const fn = space.db.add(Function.make({ name: 'test', version: '0.0.1', binding: 'HELLO' }));
|
|
38
37
|
expect(fn).to.exist;
|
|
39
38
|
});
|
|
40
39
|
});
|
package/src/serializer.ts
CHANGED
|
@@ -6,16 +6,16 @@ import { Obj } from '@dxos/echo';
|
|
|
6
6
|
import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
|
|
7
7
|
import { getObjectCore } from '@dxos/react-client/echo';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Sheet } from './types';
|
|
10
10
|
|
|
11
|
-
export const serializer: TypedObjectSerializer<
|
|
11
|
+
export const serializer: TypedObjectSerializer<Sheet.Sheet> = {
|
|
12
12
|
serialize: async ({ object }): Promise<string> => {
|
|
13
13
|
return JSON.stringify(object, null, 2);
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
deserialize: async ({ content, newId }) => {
|
|
17
17
|
const { id, ...parsed } = JSON.parse(content);
|
|
18
|
-
const sheet = Obj.make(
|
|
18
|
+
const sheet = Obj.make(Sheet.Sheet, parsed);
|
|
19
19
|
|
|
20
20
|
if (!newId) {
|
|
21
21
|
const core = getObjectCore(sheet);
|
package/src/testing/data.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { Sheet } from '../types';
|
|
6
6
|
|
|
7
|
-
export const createTestCells = (testSheetName = 'test'): Record<string, CellValue> => ({
|
|
7
|
+
export const createTestCells = (testSheetName = 'test'): Record<string, Sheet.CellValue> => ({
|
|
8
8
|
B1: { value: 'Qty2' },
|
|
9
9
|
B3: { value: 1 },
|
|
10
10
|
B4: { value: 2 },
|
package/src/testing/testing.tsx
CHANGED
|
@@ -6,19 +6,20 @@ import { type Decorator } from '@storybook/react';
|
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '@dxos/compute';
|
|
9
|
+
import { createMockedComputeRuntimeProvider } from '@dxos/compute/testing';
|
|
9
10
|
import { type Space } from '@dxos/react-client/echo';
|
|
10
11
|
import { useAsyncState } from '@dxos/react-hooks';
|
|
11
12
|
|
|
12
13
|
import { ComputeGraphContextProvider } from '../components';
|
|
13
|
-
import {
|
|
14
|
+
import { Sheet } from '../types';
|
|
14
15
|
|
|
15
|
-
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?:
|
|
16
|
+
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: Sheet.SheetProps) => {
|
|
16
17
|
const [sheet] = useAsyncState(async () => {
|
|
17
18
|
if (!space || !graph) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const sheet =
|
|
22
|
+
const sheet = Sheet.make(options);
|
|
22
23
|
space.db.add(sheet);
|
|
23
24
|
return sheet;
|
|
24
25
|
}, [space, graph]);
|
|
@@ -26,9 +27,14 @@ export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: Crea
|
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
export const withComputeGraphDecorator =
|
|
29
|
-
(options?: ComputeGraphOptions): Decorator =>
|
|
30
|
+
(options?: Partial<ComputeGraphOptions>): Decorator =>
|
|
30
31
|
(Story) => {
|
|
31
|
-
const [registry] = useState(
|
|
32
|
+
const [registry] = useState(
|
|
33
|
+
new ComputeGraphRegistry({
|
|
34
|
+
...options,
|
|
35
|
+
computeRuntime: options?.computeRuntime ?? createMockedComputeRuntimeProvider(),
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
32
38
|
return (
|
|
33
39
|
<ComputeGraphContextProvider registry={registry}>
|
|
34
40
|
<Story />
|