@dxos/plugin-sheet 0.8.4-main.2e9d522 → 0.8.4-main.548089c
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-BDLFSILO.mjs} +38 -40
- package/dist/lib/browser/SheetContainer-BDLFSILO.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-FCQ5OZZK.mjs +23 -0
- package/dist/lib/browser/anchor-sort-FCQ5OZZK.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-JUOVL3LE.mjs → chunk-7KRJ2IT5.mjs} +218 -213
- package/dist/lib/browser/chunk-7KRJ2IT5.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/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-GXHVZHKU.mjs} +16 -15
- package/dist/lib/browser/react-surface-GXHVZHKU.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -12
- package/dist/lib/node-esm/{SheetContainer-RMG24NZC.mjs → SheetContainer-CK5HSJPL.mjs} +38 -40
- package/dist/lib/node-esm/SheetContainer-CK5HSJPL.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-CTJGOPET.mjs → anchor-sort-ZE7IS7SH.mjs} +10 -11
- package/dist/lib/node-esm/anchor-sort-ZE7IS7SH.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-SMYD6H7Q.mjs} +218 -213
- package/dist/lib/node-esm/chunk-SMYD6H7Q.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-45L45WN6.mjs} +16 -15
- package/dist/lib/node-esm/react-surface-45L45WN6.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 -4
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -1
- 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 +5 -10
- 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 -64
- package/src/SheetPlugin.tsx +71 -62
- package/src/capabilities/anchor-sort.ts +7 -8
- 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 +11 -9
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +1 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +19 -13
- package/src/components/GridSheet/GridSheet.tsx +39 -26
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +40 -42
- package/src/components/GridSheet/util.ts +15 -9
- package/src/components/RangeList/RangeList.tsx +8 -8
- package/src/components/SheetContainer/SheetContainer.stories.tsx +48 -44
- package/src/components/SheetContainer/SheetContainer.tsx +10 -5
- package/src/components/SheetContext/SheetContext.tsx +5 -5
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
- package/src/components/SheetToolbar/SheetToolbar.tsx +29 -30
- 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 +15 -20
- 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 +0 -24
- 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
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
// Copyright 2024 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 from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
|
-
import { SheetToolbar } from './SheetToolbar';
|
|
13
10
|
import { translations } from '../../translations';
|
|
14
11
|
|
|
12
|
+
import { SheetToolbar } from './SheetToolbar';
|
|
13
|
+
|
|
15
14
|
const DefaultStory = () => {
|
|
16
|
-
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetProvider.
|
|
16
|
+
// return <SheetToolbar id='test' />;
|
|
17
|
+
return <>TODO</>;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const meta: Meta = {
|
|
20
|
+
const meta = {
|
|
22
21
|
title: 'plugins/plugin-sheet/Toolbar',
|
|
23
|
-
component: SheetToolbar,
|
|
22
|
+
component: SheetToolbar as any,
|
|
24
23
|
render: DefaultStory,
|
|
25
|
-
decorators: [withTheme
|
|
26
|
-
parameters: {
|
|
27
|
-
|
|
24
|
+
decorators: [withTheme],
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: 'fullscreen',
|
|
27
|
+
translations,
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
28
30
|
|
|
29
31
|
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof meta>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {};
|
|
@@ -2,60 +2,56 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import React, { type PropsWithChildren, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useAppGraph } from '@dxos/app-framework';
|
|
8
|
+
import { useAppGraph } from '@dxos/app-framework/react';
|
|
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
|
-
customActions?:
|
|
39
|
-
) => {
|
|
40
|
-
return
|
|
30
|
+
customActions?: Atom.Atom<ActionGraphProps>,
|
|
31
|
+
): Atom.Atom<ActionGraphProps> => {
|
|
32
|
+
return Atom.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);
|
|
@@ -63,10 +59,13 @@ export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
|
|
|
63
59
|
|
|
64
60
|
const { graph } = useAppGraph();
|
|
65
61
|
const customActions = useMemo(() => {
|
|
66
|
-
return
|
|
62
|
+
return Atom.make((get) => {
|
|
67
63
|
const actions = get(graph.actions(id));
|
|
68
64
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
69
|
-
return {
|
|
65
|
+
return {
|
|
66
|
+
nodes,
|
|
67
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id })),
|
|
68
|
+
};
|
|
70
69
|
});
|
|
71
70
|
}, [graph]);
|
|
72
71
|
|
|
@@ -78,7 +77,7 @@ export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
|
|
|
78
77
|
|
|
79
78
|
return (
|
|
80
79
|
<MenuProvider {...menu} attendableId={id}>
|
|
81
|
-
<ToolbarMenu
|
|
80
|
+
<ToolbarMenu />
|
|
82
81
|
</MenuProvider>
|
|
83
82
|
);
|
|
84
83
|
};
|
|
@@ -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,23 @@
|
|
|
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
|
-
import {
|
|
9
|
-
|
|
10
|
-
createResolver,
|
|
11
|
-
LayoutAction,
|
|
12
|
-
useIntentResolver,
|
|
13
|
-
useIntentDispatcher,
|
|
14
|
-
chain,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
9
|
+
import { LayoutAction, chain, createIntent, createResolver } from '@dxos/app-framework';
|
|
10
|
+
import { useIntentDispatcher, useIntentResolver } from '@dxos/app-framework/react';
|
|
16
11
|
import { debounce } from '@dxos/async';
|
|
17
12
|
import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
|
|
18
13
|
import { Obj, Relation } from '@dxos/echo';
|
|
19
14
|
import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
|
|
20
|
-
import {
|
|
21
|
-
import { Filter,
|
|
15
|
+
import { Thread, ThreadAction } from '@dxos/plugin-thread/types';
|
|
16
|
+
import { Filter, Query, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
22
17
|
import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
|
|
23
|
-
import { AnchoredTo } from '@dxos/
|
|
18
|
+
import { AnchoredTo } from '@dxos/types';
|
|
24
19
|
|
|
25
20
|
import { useSheetContext } from '../components';
|
|
26
|
-
import {
|
|
21
|
+
import { meta } from '../meta';
|
|
27
22
|
|
|
28
23
|
export const completeCellRangeToThreadCursor = (range: CompleteCellRange): string => {
|
|
29
24
|
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
@@ -60,7 +55,7 @@ export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null
|
|
|
60
55
|
return false;
|
|
61
56
|
}
|
|
62
57
|
|
|
63
|
-
return data.subject ===
|
|
58
|
+
return data.subject === Obj.getDXN(model.sheet).toString() && !!data.options?.cursor;
|
|
64
59
|
},
|
|
65
60
|
resolve: ({ options: { cursor, ref } }) => {
|
|
66
61
|
setActiveRefs(ref);
|
|
@@ -72,7 +67,7 @@ export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null
|
|
|
72
67
|
[model.sheet, setActiveRefs],
|
|
73
68
|
);
|
|
74
69
|
|
|
75
|
-
useIntentResolver(
|
|
70
|
+
useIntentResolver(meta.id, scrollIntoViewResolver);
|
|
76
71
|
};
|
|
77
72
|
|
|
78
73
|
export const useSelectThreadOnCellFocus = () => {
|
|
@@ -80,7 +75,7 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
80
75
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
81
76
|
|
|
82
77
|
const space = getSpace(model.sheet);
|
|
83
|
-
const anchors = useQuery(space, Query.select(Filter.ids(model.sheet.id)).targetOf(AnchoredTo));
|
|
78
|
+
const anchors = useQuery(space, Query.select(Filter.ids(model.sheet.id)).targetOf(AnchoredTo.AnchoredTo));
|
|
84
79
|
|
|
85
80
|
const selectClosestThread = useCallback(
|
|
86
81
|
(cellAddress: CellAddress) => {
|
|
@@ -90,7 +85,7 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
90
85
|
|
|
91
86
|
const closestThread = anchors.find((anchor) => {
|
|
92
87
|
const source = Relation.getSource(anchor);
|
|
93
|
-
if (anchor.anchor && Obj.instanceOf(
|
|
88
|
+
if (anchor.anchor && Obj.instanceOf(Thread.Thread, source)) {
|
|
94
89
|
const range = parseThreadAnchorAsCellRange(anchor.anchor);
|
|
95
90
|
return range ? inRange(range, cellAddress) : false;
|
|
96
91
|
} else {
|
|
@@ -99,9 +94,9 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
99
94
|
});
|
|
100
95
|
|
|
101
96
|
if (closestThread) {
|
|
102
|
-
const primary =
|
|
103
|
-
const intent = pipe(
|
|
104
|
-
createIntent(ThreadAction.Select, { current:
|
|
97
|
+
const primary = Obj.getDXN(model.sheet).toString();
|
|
98
|
+
const intent = Function.pipe(
|
|
99
|
+
createIntent(ThreadAction.Select, { current: Obj.getDXN(closestThread).toString() }),
|
|
105
100
|
chain(DeckAction.ChangeCompanion, { primary, companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments` }),
|
|
106
101
|
);
|
|
107
102
|
void dispatch(intent);
|
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';
|