@dxos/plugin-sheet 0.8.4-main.1da679c → 0.8.4-main.21d9917
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-ESCXPI7Y.mjs +397 -0
- package/dist/lib/browser/SheetContainer-ESCXPI7Y.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-JBRMW6OY.mjs +23 -0
- package/dist/lib/browser/anchor-sort-JBRMW6OY.mjs.map +7 -0
- package/dist/lib/browser/chunk-2SAGT3BB.mjs +397 -0
- package/dist/lib/browser/chunk-2SAGT3BB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SSN4HYJL.mjs → chunk-IFLWVS2V.mjs} +9 -9
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
- package/dist/lib/browser/chunk-W6N44ONZ.mjs +1470 -0
- package/dist/lib/browser/chunk-W6N44ONZ.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-DL2PX7TF.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-DL2PX7TF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +71 -82
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-BC4KBDUO.mjs +29 -0
- package/dist/lib/browser/markdown-BC4KBDUO.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-FJ4UWZUM.mjs +79 -0
- package/dist/lib/browser/operation-resolver-FJ4UWZUM.mjs.map +7 -0
- package/dist/lib/browser/react-surface-5BXM6TJ3.mjs +51 -0
- package/dist/lib/browser/react-surface-5BXM6TJ3.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/SheetContainer-YVIDJKP4.mjs +398 -0
- package/dist/lib/node-esm/SheetContainer-YVIDJKP4.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-C3XFPI6S.mjs +24 -0
- package/dist/lib/node-esm/anchor-sort-C3XFPI6S.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IMWGSIDG.mjs +398 -0
- package/dist/lib/node-esm/chunk-IMWGSIDG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs → chunk-PPOYR7DK.mjs} +9 -9
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-S7RYX7DG.mjs +1471 -0
- package/dist/lib/node-esm/chunk-S7RYX7DG.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-VXH55GDI.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-VXH55GDI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +71 -82
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-6DGZCJRM.mjs +30 -0
- package/dist/lib/node-esm/markdown-6DGZCJRM.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-OGXEUWHA.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-OGXEUWHA.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-RLHC6B77.mjs +52 -0
- package/dist/lib/node-esm/react-surface-RLHC6B77.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 +5 -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/ComputeGraph/compute-graph.stories.d.ts +0 -1
- 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 +4 -3
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +2 -3
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +8 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +2 -2
- 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 +3 -2
- 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 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts +2 -3
- 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 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -6
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +2 -2
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +2 -2
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/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 +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 +92 -75
- 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 +79 -72
- package/src/SheetPlugin.tsx +51 -64
- package/src/capabilities/anchor-sort/anchor-sort.ts +26 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
- package/src/capabilities/compute-graph-registry/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +30 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +43 -0
- package/src/components/ComputeGraph/compute-graph.stories.tsx +10 -12
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
- package/src/components/GridSheet/GridSheet.stories.tsx +14 -11
- package/src/components/GridSheet/GridSheet.tsx +32 -25
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +14 -12
- package/src/components/GridSheet/util.ts +11 -5
- package/src/components/RangeList/RangeList.tsx +13 -10
- package/src/components/SheetContainer/SheetContainer.stories.tsx +68 -47
- package/src/components/SheetContainer/SheetContainer.tsx +30 -18
- package/src/components/SheetContext/SheetContext.tsx +8 -8
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +9 -6
- package/src/components/SheetToolbar/SheetToolbar.tsx +39 -30
- package/src/components/SheetToolbar/align.ts +44 -19
- package/src/components/SheetToolbar/style.ts +47 -17
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/extensions/compute.stories.tsx +29 -17
- package/src/extensions/compute.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +7 -4
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +40 -49
- package/src/meta.ts +9 -7
- package/src/model/sheet-model.test.ts +4 -4
- package/src/model/sheet-model.ts +78 -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 +1 -0
- 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 +11 -5
- package/src/translations.ts +3 -2
- package/src/types/Sheet.ts +106 -0
- package/src/types/capabilities.ts +14 -0
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +2 -2
- package/src/types/types.ts +83 -49
- package/src/types/util.ts +10 -38
- package/dist/lib/browser/SheetContainer-OUN6AARA.mjs +0 -350
- package/dist/lib/browser/SheetContainer-OUN6AARA.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-CAYLDDRF.mjs +0 -24
- package/dist/lib/browser/anchor-sort-CAYLDDRF.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-KJWZUQVA.mjs +0 -15
- package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
- package/dist/lib/browser/chunk-SSN4HYJL.mjs.map +0 -7
- package/dist/lib/browser/chunk-X4EWLDT3.mjs +0 -851
- package/dist/lib/browser/chunk-X4EWLDT3.mjs.map +0 -7
- package/dist/lib/browser/chunk-XSXUU6FO.mjs +0 -906
- package/dist/lib/browser/chunk-XSXUU6FO.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-WHF3BJTJ.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-WHF3BJTJ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-LKZXAJRJ.mjs +0 -56
- package/dist/lib/browser/intent-resolver-LKZXAJRJ.mjs.map +0 -7
- package/dist/lib/browser/markdown-XKFA4Z2M.mjs +0 -26
- package/dist/lib/browser/markdown-XKFA4Z2M.mjs.map +0 -7
- package/dist/lib/browser/react-surface-N6NYHHT3.mjs +0 -53
- package/dist/lib/browser/react-surface-N6NYHHT3.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-NFLLTGNV.mjs +0 -351
- package/dist/lib/node-esm/SheetContainer-NFLLTGNV.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-4R2ID6GE.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-4R2ID6GE.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 +0 -16
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IK4O7FUJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ODP4L4OV.mjs +0 -907
- package/dist/lib/node-esm/chunk-ODP4L4OV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PYF4ZJXN.mjs +0 -852
- package/dist/lib/node-esm/chunk-PYF4ZJXN.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-3IUZXRXJ.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-3IUZXRXJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-JHH6ZVJ4.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-JHH6ZVJ4.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-NOKROLCG.mjs +0 -27
- package/dist/lib/node-esm/markdown-NOKROLCG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TYBS4DOF.mjs +0 -54
- package/dist/lib/node-esm/react-surface-TYBS4DOF.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/types/schema.d.ts +0 -37
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -22
- package/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/compute-graph-registry.ts +0 -28
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -23
- package/src/capabilities/react-surface.tsx +0 -40
- package/src/types/schema.ts +0 -61
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useRef, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
11
|
-
import { Filter
|
|
12
|
-
import {
|
|
9
|
+
import { Filter } from '@dxos/echo';
|
|
10
|
+
import { Function } from '@dxos/functions';
|
|
13
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
14
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
13
|
import { Button, Input, Toolbar } from '@dxos/react-ui';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
15
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
17
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
18
16
|
|
|
19
17
|
import { useSheetModel } from '../../model';
|
|
20
18
|
import { withComputeGraphDecorator } from '../../testing';
|
|
21
|
-
import {
|
|
19
|
+
import { Sheet } from '../../types';
|
|
22
20
|
|
|
23
21
|
import { useComputeGraph } from './ComputeGraphContextProvider';
|
|
24
22
|
|
|
@@ -27,13 +25,13 @@ const FUNCTION_NAME = 'TEST';
|
|
|
27
25
|
const DefaultStory = () => {
|
|
28
26
|
const space = useSpace();
|
|
29
27
|
const graph = useComputeGraph(space);
|
|
30
|
-
const [sheet, setSheet] = useState<
|
|
28
|
+
const [sheet, setSheet] = useState<Sheet.Sheet>();
|
|
31
29
|
const [text, setText] = useState(`${FUNCTION_NAME}(100)`);
|
|
32
30
|
const [result, setResult] = useState<any>();
|
|
33
31
|
const model = useSheetModel(graph, sheet);
|
|
34
32
|
useEffect(() => {
|
|
35
33
|
if (space) {
|
|
36
|
-
const sheet = space.db.add(
|
|
34
|
+
const sheet = space.db.add(Sheet.make());
|
|
37
35
|
setSheet(sheet);
|
|
38
36
|
}
|
|
39
37
|
}, [space]);
|
|
@@ -46,14 +44,14 @@ const DefaultStory = () => {
|
|
|
46
44
|
setResult({ functions: { standard: f1.length, echo: f2.length } });
|
|
47
45
|
});
|
|
48
46
|
|
|
49
|
-
space.db.add(
|
|
47
|
+
space.db.add(Function.make({ name: 'test', version: '0.0.1', binding: FUNCTION_NAME }));
|
|
50
48
|
}
|
|
51
49
|
}, [space, graph]);
|
|
52
50
|
|
|
53
51
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
54
52
|
const handleTest = async () => {
|
|
55
53
|
if (space && graph) {
|
|
56
|
-
const
|
|
54
|
+
const objects = await space.db.query(Filter.type(Function.Function)).run();
|
|
57
55
|
const mapped = graph.mapFunctionBindingToId(text);
|
|
58
56
|
const unmapped = graph.mapFunctionBindingFromId(mapped);
|
|
59
57
|
const internal = graph.mapFormulaToNative(text);
|
|
@@ -89,9 +87,9 @@ const meta = {
|
|
|
89
87
|
title: 'plugins/plugin-sheet/functions',
|
|
90
88
|
render: DefaultStory,
|
|
91
89
|
decorators: [
|
|
92
|
-
withClientProvider({ types: [FunctionType, SheetType], createIdentity: true, createSpace: true }),
|
|
93
|
-
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
94
90
|
withTheme,
|
|
91
|
+
withClientProvider({ types: [Function.Function, Sheet.Sheet], createIdentity: true, createSpace: true }),
|
|
92
|
+
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
95
93
|
],
|
|
96
94
|
} satisfies Meta<typeof DefaultStory>;
|
|
97
95
|
|
|
@@ -26,9 +26,9 @@ export const FunctionEditor = () => {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
|
-
<div className='flex shrink-0 justify-between items-center
|
|
29
|
+
<div className='flex shrink-0 justify-between items-center pli-4 plb-1 text-sm bg-toolbarSurface border-bs !border-subduedSeparator'>
|
|
30
30
|
<div className='flex gap-4 items-center'>
|
|
31
|
-
<div className='flex
|
|
31
|
+
<div className='flex is-16 items-center font-mono'>
|
|
32
32
|
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
33
33
|
</div>
|
|
34
34
|
<div className='flex gap-2 items-center'>
|
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
8
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
10
|
+
import { OperationPlugin, RuntimePlugin } from '@dxos/plugin-testing';
|
|
12
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
13
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
-
import {
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
14
|
|
|
16
15
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
17
16
|
import { translations } from '../../translations';
|
|
18
|
-
import {
|
|
17
|
+
import { Sheet } from '../../types';
|
|
19
18
|
import { useComputeGraph } from '../ComputeGraph';
|
|
20
19
|
import { SheetProvider } from '../SheetContext';
|
|
21
20
|
|
|
@@ -31,7 +30,9 @@ export const Basic = () => {
|
|
|
31
30
|
|
|
32
31
|
return (
|
|
33
32
|
<SheetProvider graph={graph} sheet={sheet} ignoreAttention>
|
|
34
|
-
<
|
|
33
|
+
<div role='none' className='grid bs-full is-full'>
|
|
34
|
+
<GridSheet />
|
|
35
|
+
</div>
|
|
35
36
|
</SheetProvider>
|
|
36
37
|
);
|
|
37
38
|
};
|
|
@@ -40,15 +41,17 @@ const meta = {
|
|
|
40
41
|
title: 'plugins/plugin-sheet/GridSheet',
|
|
41
42
|
component: GridSheet,
|
|
42
43
|
decorators: [
|
|
43
|
-
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
44
|
-
withComputeGraphDecorator(),
|
|
45
44
|
withTheme,
|
|
46
|
-
|
|
45
|
+
withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
|
|
46
|
+
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
47
47
|
withPluginManager({
|
|
48
|
-
plugins: [
|
|
48
|
+
plugins: [OperationPlugin(), RuntimePlugin()],
|
|
49
49
|
}),
|
|
50
50
|
],
|
|
51
|
-
parameters: {
|
|
51
|
+
parameters: {
|
|
52
|
+
layout: 'fullscreen',
|
|
53
|
+
translations,
|
|
54
|
+
},
|
|
52
55
|
} satisfies Meta<typeof GridSheet>;
|
|
53
56
|
|
|
54
57
|
export default meta;
|
|
@@ -13,7 +13,7 @@ import React, {
|
|
|
13
13
|
useState,
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { useOperationInvoker } from '@dxos/app-framework/react';
|
|
17
17
|
import { type CellRange, rangeToA1Notation } from '@dxos/compute';
|
|
18
18
|
import { defaultColSize, defaultRowSize } from '@dxos/lit-grid';
|
|
19
19
|
import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
|
|
@@ -34,8 +34,8 @@ import {
|
|
|
34
34
|
|
|
35
35
|
import { type RangeController, rangeExtension, sheetExtension } from '../../extensions';
|
|
36
36
|
import { useSelectThreadOnCellFocus, useUpdateFocusedCellOnThreadSelection } from '../../integrations';
|
|
37
|
-
import {
|
|
38
|
-
import { DEFAULT_COLS, DEFAULT_ROWS,
|
|
37
|
+
import { meta } from '../../meta';
|
|
38
|
+
import { DEFAULT_COLS, DEFAULT_ROWS, SheetOperation } from '../../types';
|
|
39
39
|
import { useSheetContext } from '../SheetContext';
|
|
40
40
|
|
|
41
41
|
import { colLabelCell, rowLabelCell, useSheetModelDxGridProps } from './util';
|
|
@@ -69,15 +69,15 @@ const sheetRowDefault = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
export const GridSheet = () => {
|
|
72
|
-
const { t } = useTranslation(
|
|
72
|
+
const { t } = useTranslation(meta.id);
|
|
73
73
|
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } =
|
|
74
74
|
useSheetContext();
|
|
75
75
|
// NOTE(thure): using `useState` instead of `useRef` works with refs provided by `@lit/react` and gives us
|
|
76
76
|
// a reliable dependency for `useEffect` whereas `useLayoutEffect` does not guarantee the element will be defined.
|
|
77
77
|
const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
|
|
78
78
|
const [extraplanarFocus, setExtraplanarFocus] = useState<DxGridPosition | null>(null);
|
|
79
|
-
const {
|
|
80
|
-
const rangeController = useRef<RangeController>();
|
|
79
|
+
const { invokePromise } = useOperationInvoker();
|
|
80
|
+
const rangeController = useRef<RangeController>(null);
|
|
81
81
|
const { hasAttention } = useAttention(id);
|
|
82
82
|
|
|
83
83
|
const handleFocus = useCallback(
|
|
@@ -172,12 +172,20 @@ export const GridSheet = () => {
|
|
|
172
172
|
case 'frozenRowsStart':
|
|
173
173
|
return dxGrid?.setSelection({
|
|
174
174
|
start: { col: pos.col, row: 0, plane: 'grid' },
|
|
175
|
-
end: {
|
|
175
|
+
end: {
|
|
176
|
+
col: pos.col,
|
|
177
|
+
row: model.sheet.rows.length - 1,
|
|
178
|
+
plane: 'grid',
|
|
179
|
+
},
|
|
176
180
|
});
|
|
177
181
|
case 'frozenColsStart':
|
|
178
182
|
return dxGrid?.setSelection({
|
|
179
183
|
start: { row: pos.row, col: 0, plane: 'grid' },
|
|
180
|
-
end: {
|
|
184
|
+
end: {
|
|
185
|
+
row: pos.row,
|
|
186
|
+
col: model.sheet.columns.length - 1,
|
|
187
|
+
plane: 'grid',
|
|
188
|
+
},
|
|
181
189
|
});
|
|
182
190
|
}
|
|
183
191
|
},
|
|
@@ -257,31 +265,30 @@ export const GridSheet = () => {
|
|
|
257
265
|
switch (operation) {
|
|
258
266
|
case 'insert-before':
|
|
259
267
|
case 'insert-after':
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}),
|
|
266
|
-
);
|
|
268
|
+
return invokePromise(SheetOperation.InsertAxis, {
|
|
269
|
+
model,
|
|
270
|
+
axis: contextMenuAxis,
|
|
271
|
+
index: contextMenuOpen![contextMenuAxis] + (operation === 'insert-before' ? 0 : 1),
|
|
272
|
+
});
|
|
267
273
|
case 'drop':
|
|
268
|
-
return
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}),
|
|
274
|
-
);
|
|
274
|
+
return invokePromise(SheetOperation.DropAxis, {
|
|
275
|
+
model,
|
|
276
|
+
axis: contextMenuAxis,
|
|
277
|
+
axisIndex: model.sheet[contextMenuAxis === 'row' ? 'rows' : 'columns'][contextMenuOpen![contextMenuAxis]],
|
|
278
|
+
});
|
|
275
279
|
}
|
|
276
280
|
},
|
|
277
|
-
[contextMenuAxis, contextMenuOpen, model,
|
|
281
|
+
[contextMenuAxis, contextMenuOpen, model, invokePromise],
|
|
278
282
|
);
|
|
279
283
|
|
|
280
284
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
281
285
|
|
|
282
286
|
const extensions = useMemo(
|
|
283
287
|
() => [
|
|
284
|
-
editorKeys({
|
|
288
|
+
editorKeys({
|
|
289
|
+
onClose: handleClose,
|
|
290
|
+
...(editing?.initialContent && { onNav: handleClose }),
|
|
291
|
+
}),
|
|
285
292
|
sheetExtension({ functions: model.graph.getFunctions() }),
|
|
286
293
|
rangeExtension({
|
|
287
294
|
onInit: (fn) => (rangeController.current = fn),
|
|
@@ -308,7 +315,7 @@ export const GridSheet = () => {
|
|
|
308
315
|
|
|
309
316
|
return (
|
|
310
317
|
// TODO(thure): Why are Table’s and Sheet’s editor boxes off by 1px?
|
|
311
|
-
<div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent
|
|
318
|
+
<div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent'>
|
|
312
319
|
<GridCellEditor getCellContent={getCellContent} extensions={extensions} onBlur={handleBlur} />
|
|
313
320
|
<Grid.Content
|
|
314
321
|
initialCells={initialCells}
|
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useMemo, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Client } from '@dxos/client';
|
|
11
|
-
import { createDocAccessor } from '@dxos/client/echo';
|
|
12
9
|
import { defaultFunctions } from '@dxos/compute';
|
|
13
10
|
import { getRegisteredFunctionNames } from '@dxos/compute/testing';
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
14
13
|
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
15
|
-
import {
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
15
|
import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
|
|
17
|
-
import {
|
|
16
|
+
import { automerge } from '@dxos/ui-editor';
|
|
18
17
|
|
|
19
18
|
import { sheetExtension } from '../../extensions';
|
|
20
|
-
import {
|
|
19
|
+
import { Sheet } from '../../types';
|
|
21
20
|
|
|
22
21
|
const DefaultStory = ({ value, ...props }: CellEditorProps) => {
|
|
23
22
|
const extensions = useMemo(() => {
|
|
@@ -31,16 +30,18 @@ const DefaultStory = ({ value, ...props }: CellEditorProps) => {
|
|
|
31
30
|
|
|
32
31
|
const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
|
|
33
32
|
const cell = 'A1';
|
|
34
|
-
const [object, setObject] = useState<
|
|
33
|
+
const [object, setObject] = useState<Sheet.Sheet>();
|
|
35
34
|
useAsyncEffect(async () => {
|
|
36
|
-
const client = new Client({ types: [
|
|
35
|
+
const client = new Client({ types: [Sheet.Sheet] });
|
|
37
36
|
await client.initialize();
|
|
38
37
|
await client.halo.createIdentity();
|
|
39
38
|
const space = await client.spaces.create();
|
|
40
39
|
|
|
41
|
-
const sheet =
|
|
42
|
-
sheet
|
|
43
|
-
|
|
40
|
+
const sheet = Sheet.make();
|
|
41
|
+
Obj.change(sheet, (s) => {
|
|
42
|
+
s.name = 'Test';
|
|
43
|
+
s.cells[cell] = { value };
|
|
44
|
+
});
|
|
44
45
|
space.db.add(sheet);
|
|
45
46
|
setObject(sheet);
|
|
46
47
|
}, [value]);
|
|
@@ -61,9 +62,10 @@ const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
|
|
|
61
62
|
|
|
62
63
|
const meta = {
|
|
63
64
|
title: 'plugins/plugin-sheet/CellEditor',
|
|
65
|
+
|
|
66
|
+
decorators: [withTheme],
|
|
64
67
|
component: CellEditor,
|
|
65
68
|
render: DefaultStory,
|
|
66
|
-
decorators: [withTheme],
|
|
67
69
|
} satisfies Meta<typeof DefaultStory>;
|
|
68
70
|
|
|
69
71
|
export default meta;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { inRange } from '@dxos/compute';
|
|
8
|
-
import { createDocAccessor } from '@dxos/
|
|
8
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
9
|
import { cellClassesForFieldType, parseValue } from '@dxos/react-ui-form';
|
|
10
10
|
import {
|
|
11
11
|
type DxGridAxisMeta,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
commentedClassName,
|
|
20
20
|
rowToA1Notation,
|
|
21
21
|
} from '@dxos/react-ui-grid';
|
|
22
|
-
import { mx } from '@dxos/
|
|
22
|
+
import { mx } from '@dxos/ui-theme';
|
|
23
23
|
|
|
24
24
|
import { type SheetModel } from '../../model';
|
|
25
25
|
import { cellClassNameForRange, rangeFromIndex } from '../../types';
|
|
@@ -28,7 +28,10 @@ const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
|
|
|
28
28
|
return model.sheet.columns.reduce(
|
|
29
29
|
(acc: DxGridAxisMeta, columnId, numericIndex) => {
|
|
30
30
|
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
31
|
-
acc.grid[numericIndex] = {
|
|
31
|
+
acc.grid[numericIndex] = {
|
|
32
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
33
|
+
resizeable: true,
|
|
34
|
+
};
|
|
32
35
|
}
|
|
33
36
|
return acc;
|
|
34
37
|
},
|
|
@@ -40,7 +43,10 @@ const createDxGridRows = (model: SheetModel): DxGridAxisMeta => {
|
|
|
40
43
|
return model.sheet.rows.reduce(
|
|
41
44
|
(acc: DxGridAxisMeta, rowId, numericIndex) => {
|
|
42
45
|
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
43
|
-
acc.grid[numericIndex] = {
|
|
46
|
+
acc.grid[numericIndex] = {
|
|
47
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
48
|
+
resizeable: true,
|
|
49
|
+
};
|
|
44
50
|
}
|
|
45
51
|
return acc;
|
|
46
52
|
},
|
|
@@ -59,7 +65,7 @@ const projectCellProps = (model: SheetModel, col: number, row: number): DxGridCe
|
|
|
59
65
|
// const range = thread.target?.anchor && parseThreadAnchorAsCellRange(thread.target!.anchor);
|
|
60
66
|
// return thread && range ? inRange(range, address) : false;
|
|
61
67
|
// })
|
|
62
|
-
// .map((thread) =>
|
|
68
|
+
// .map((thread) => Obj.getDXN(thread!).toString())
|
|
63
69
|
// .join(' ');
|
|
64
70
|
|
|
65
71
|
const description = model.getValueDescription(address);
|
|
@@ -2,30 +2,33 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
8
|
import { rangeToA1Notation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
9
10
|
import { Callout, 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
|
-
import {
|
|
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
|
-
const { t } = useTranslation(
|
|
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, (s) => {
|
|
30
|
+
s.ranges.splice(index, 1);
|
|
31
|
+
});
|
|
29
32
|
},
|
|
30
33
|
[sheet],
|
|
31
34
|
);
|
|
@@ -37,7 +40,7 @@ export const RangeList = ({ sheet }: RangeListProps) => {
|
|
|
37
40
|
<Callout.Title>{t('no ranges message')}</Callout.Title>
|
|
38
41
|
</Callout.Root>
|
|
39
42
|
) : (
|
|
40
|
-
<List.Root<Range> items={sheet.ranges} isItem={Schema.is(Range)}>
|
|
43
|
+
<List.Root<Sheet.Range> items={sheet.ranges} isItem={Schema.is(Sheet.Range)}>
|
|
41
44
|
{({ items: ranges }) =>
|
|
42
45
|
ranges.map((range, i) => (
|
|
43
46
|
<List.Item key={i} item={range} classNames={['p-2', ghostHover]}>
|
|
@@ -2,29 +2,63 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
8
7
|
import React from 'react';
|
|
9
8
|
|
|
10
|
-
import {
|
|
9
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
11
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { OperationResolver } from '@dxos/operation';
|
|
13
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
14
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
14
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
17
|
import { AttendableContainer } from '@dxos/react-ui-attention';
|
|
16
|
-
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
17
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
18
|
|
|
19
19
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
20
20
|
import { translations } from '../../translations';
|
|
21
|
-
import {
|
|
21
|
+
import { Sheet, SheetOperation } from '../../types';
|
|
22
22
|
import { useComputeGraph } from '../ComputeGraph';
|
|
23
23
|
import { RangeList } from '../RangeList';
|
|
24
24
|
|
|
25
25
|
import { SheetContainer } from './SheetContainer';
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const meta = {
|
|
28
|
+
title: 'plugins/plugin-sheet/SheetContainer',
|
|
29
|
+
component: SheetContainer,
|
|
30
|
+
decorators: [
|
|
31
|
+
withTheme,
|
|
32
|
+
withLayout({ layout: 'fullscreen' }),
|
|
33
|
+
withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
|
|
34
|
+
withComputeGraphDecorator(),
|
|
35
|
+
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
36
|
+
withPluginManager({
|
|
37
|
+
plugins: [...corePlugins()],
|
|
38
|
+
capabilities: [
|
|
39
|
+
Capability.contributes(Common.Capability.OperationResolver, [
|
|
40
|
+
OperationResolver.make({
|
|
41
|
+
operation: SheetOperation.DropAxis,
|
|
42
|
+
handler: ({ model, axis, axisIndex }) =>
|
|
43
|
+
Effect.sync(() => {
|
|
44
|
+
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
45
|
+
// Return stub output for story purposes.
|
|
46
|
+
return { axis, axisIndex, index: 0, axisMeta: null, values: [] };
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
]),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
parameters: {
|
|
54
|
+
layout: 'fullscreen',
|
|
55
|
+
translations,
|
|
56
|
+
},
|
|
57
|
+
} satisfies Meta<typeof SheetContainer>;
|
|
58
|
+
|
|
59
|
+
export default meta;
|
|
60
|
+
|
|
61
|
+
export const Default = () => {
|
|
28
62
|
const space = useSpace();
|
|
29
63
|
const graph = useComputeGraph(space);
|
|
30
64
|
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
@@ -33,12 +67,31 @@ export const Basic = () => {
|
|
|
33
67
|
}
|
|
34
68
|
|
|
35
69
|
return (
|
|
36
|
-
<AttendableContainer id={
|
|
37
|
-
<SheetContainer space={space}
|
|
70
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
71
|
+
<SheetContainer role='article' space={space} subject={sheet} ignoreAttention />
|
|
38
72
|
</AttendableContainer>
|
|
39
73
|
);
|
|
40
74
|
};
|
|
41
75
|
|
|
76
|
+
export const Section = () => {
|
|
77
|
+
const space = useSpace();
|
|
78
|
+
const graph = useComputeGraph(space);
|
|
79
|
+
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
80
|
+
if (!sheet || !space) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className='is-full flex justify-center'>
|
|
86
|
+
<div className='is-[40rem]'>
|
|
87
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
88
|
+
<SheetContainer role='section' space={space} subject={sheet} ignoreAttention />
|
|
89
|
+
</AttendableContainer>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
42
95
|
export const Spec = () => {
|
|
43
96
|
const space = useSpace();
|
|
44
97
|
const graph = useComputeGraph(space);
|
|
@@ -48,9 +101,9 @@ export const Spec = () => {
|
|
|
48
101
|
}
|
|
49
102
|
|
|
50
103
|
return (
|
|
51
|
-
<AttendableContainer id={
|
|
52
|
-
<div role='none' className='grid grid-
|
|
53
|
-
<SheetContainer space={space}
|
|
104
|
+
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
105
|
+
<div role='none' className='is-full grid grid-cols-[1fr_20rem]'>
|
|
106
|
+
<SheetContainer role='article' space={space} subject={sheet} ignoreAttention />
|
|
54
107
|
<div role='none' data-testid='grid.range-list'>
|
|
55
108
|
<RangeList sheet={sheet} />
|
|
56
109
|
</div>
|
|
@@ -58,35 +111,3 @@ export const Spec = () => {
|
|
|
58
111
|
</AttendableContainer>
|
|
59
112
|
);
|
|
60
113
|
};
|
|
61
|
-
|
|
62
|
-
const meta = {
|
|
63
|
-
title: 'plugins/plugin-sheet/SheetContainer',
|
|
64
|
-
component: SheetContainer,
|
|
65
|
-
decorators: [
|
|
66
|
-
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
67
|
-
withComputeGraphDecorator(),
|
|
68
|
-
withTheme,
|
|
69
|
-
withLayout({ fullscreen: true, classNames: 'grid' }),
|
|
70
|
-
withAttention,
|
|
71
|
-
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
72
|
-
withPluginManager({
|
|
73
|
-
plugins: [IntentPlugin(), GraphPlugin()],
|
|
74
|
-
capabilities: [
|
|
75
|
-
contributes(
|
|
76
|
-
Capabilities.IntentResolver,
|
|
77
|
-
createResolver({
|
|
78
|
-
intent: SheetAction.DropAxis,
|
|
79
|
-
resolve: ({ model, axis, axisIndex }) => {
|
|
80
|
-
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
),
|
|
84
|
-
],
|
|
85
|
-
}),
|
|
86
|
-
],
|
|
87
|
-
parameters: { translations },
|
|
88
|
-
} satisfies Meta<typeof SheetContainer>;
|
|
89
|
-
|
|
90
|
-
export default meta;
|
|
91
|
-
|
|
92
|
-
type Story = StoryObj<typeof meta>;
|
|
@@ -2,35 +2,47 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
10
|
+
import { Layout, type LayoutFlexProps } from '@dxos/react-ui-mosaic';
|
|
9
11
|
|
|
10
|
-
import { type
|
|
12
|
+
import { type Sheet } from '../../types';
|
|
11
13
|
import { useComputeGraph } from '../ComputeGraph';
|
|
12
14
|
import { FunctionEditor } from '../FunctionEditor';
|
|
13
15
|
import { GridSheet } from '../GridSheet';
|
|
14
16
|
import { SheetProvider } from '../SheetContext';
|
|
15
17
|
import { SheetToolbar } from '../SheetToolbar';
|
|
16
18
|
|
|
17
|
-
export type SheetContainerProps =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
19
|
+
export type SheetContainerProps = SurfaceComponentProps<
|
|
20
|
+
Sheet.Sheet,
|
|
21
|
+
{
|
|
22
|
+
space: Space;
|
|
23
|
+
ignoreAttention?: boolean;
|
|
24
|
+
}
|
|
25
|
+
>;
|
|
23
26
|
|
|
24
|
-
export const SheetContainer = ({
|
|
27
|
+
export const SheetContainer = ({ role, subject: sheet, space, ignoreAttention }: SheetContainerProps) => {
|
|
25
28
|
const graph = useComputeGraph(space);
|
|
29
|
+
if (!graph) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const Root = role === 'section' ? Container : Fragment;
|
|
26
34
|
|
|
27
|
-
return
|
|
35
|
+
return (
|
|
28
36
|
<SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
<Root>
|
|
38
|
+
<Layout.Main toolbar statusbar>
|
|
39
|
+
<SheetToolbar id={Obj.getDXN(sheet).toString()} />
|
|
40
|
+
<GridSheet />
|
|
41
|
+
<FunctionEditor />
|
|
42
|
+
</Layout.Main>
|
|
43
|
+
</Root>
|
|
34
44
|
</SheetProvider>
|
|
35
|
-
)
|
|
45
|
+
);
|
|
36
46
|
};
|
|
47
|
+
|
|
48
|
+
const Container = (props: LayoutFlexProps) => <Layout.Flex {...props} classNames='aspect-square' />;
|