@dxos/plugin-sheet 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/RangeList-IC5RYQYU.mjs +53 -0
- package/dist/lib/browser/RangeList-IC5RYQYU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-S27QJYTN.mjs → SheetContainer-AITFHNUW.mjs} +578 -243
- package/dist/lib/browser/SheetContainer-AITFHNUW.mjs.map +7 -0
- package/dist/lib/browser/{anchor-sort-LLO7PZKF.mjs → anchor-sort-5PYGDBAT.mjs} +5 -4
- package/dist/lib/browser/anchor-sort-5PYGDBAT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KE3AKN5W.mjs → chunk-GUP25ZNZ.mjs} +11 -31
- package/dist/lib/browser/chunk-GUP25ZNZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IFLWVS2V.mjs → chunk-NNWF7EKC.mjs} +10 -10
- package/dist/lib/browser/{chunk-IFLWVS2V.mjs.map → chunk-NNWF7EKC.mjs.map} +2 -2
- package/dist/lib/browser/{compute-graph-registry-RC5L7RE4.mjs → compute-graph-registry-CGBTEI2T.mjs} +2 -2
- package/dist/lib/browser/index.mjs +20 -25
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{markdown-D2T2DOVX.mjs → markdown-SF55PRFI.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-YDOW72CN.mjs → operation-resolver-POWQIMRP.mjs} +5 -19
- package/dist/lib/browser/operation-resolver-POWQIMRP.mjs.map +7 -0
- package/dist/lib/browser/react-surface-U5IEDSN7.mjs +52 -0
- package/dist/lib/browser/react-surface-U5IEDSN7.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/RangeList-QFHOLKRE.mjs +54 -0
- package/dist/lib/node-esm/RangeList-QFHOLKRE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y4V6HVHO.mjs → SheetContainer-FDV55IZT.mjs} +578 -243
- package/dist/lib/node-esm/SheetContainer-FDV55IZT.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-OX5I2YOW.mjs → anchor-sort-TMYWWZGC.mjs} +5 -4
- package/dist/lib/node-esm/anchor-sort-TMYWWZGC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6J5L47IB.mjs → chunk-B3LMFENM.mjs} +11 -31
- package/dist/lib/node-esm/chunk-B3LMFENM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PPOYR7DK.mjs → chunk-M52YLLWU.mjs} +10 -10
- package/dist/lib/node-esm/{chunk-PPOYR7DK.mjs.map → chunk-M52YLLWU.mjs.map} +2 -2
- package/dist/lib/node-esm/{compute-graph-registry-ZGXVLVGD.mjs → compute-graph-registry-B7OXC4TD.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +20 -25
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{markdown-PTV72DLO.mjs → markdown-MMKSGCIC.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-Q63VQBVA.mjs → operation-resolver-XVNBVJVE.mjs} +5 -19
- package/dist/lib/node-esm/operation-resolver-XVNBVJVE.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-SWRZSZVR.mjs → react-surface-ZTRBZ53R.mjs} +22 -21
- package/dist/lib/node-esm/react-surface-ZTRBZ53R.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +3 -2
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +1 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +1 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +15 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/index.d.ts +2 -0
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +7 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/GridSheet.stories.d.ts → SheetContent/SheetContent.stories.d.ts} +5 -2
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/index.d.ts +2 -0
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
- package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +6 -4
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +7 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +6 -3
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/index.d.ts +3 -0
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/SheetContainer.stories.d.ts +2 -2
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +1 -1
- package/dist/types/src/types/Sheet.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -24
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -62
- package/src/SheetPlugin.tsx +11 -22
- package/src/capabilities/anchor-sort/anchor-sort.ts +3 -2
- package/src/capabilities/operation-resolver/operation-resolver.ts +4 -15
- package/src/capabilities/react-surface/react-surface.tsx +19 -13
- package/src/components/ComputeGraph/compute-graph.stories.tsx +2 -2
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +5 -5
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +12 -11
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +14 -11
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +3 -3
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +44 -36
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +19 -8
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +4 -4
- package/src/components/SheetToolbar/SheetToolbar.tsx +11 -10
- package/src/components/SheetToolbar/align.ts +9 -9
- package/src/components/SheetToolbar/style.ts +7 -7
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +9 -7
- package/src/containers/RangeList/index.ts +7 -0
- package/src/{components → containers}/SheetContainer/SheetContainer.stories.tsx +28 -33
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/{components → containers}/SheetContainer/index.ts +1 -1
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +12 -11
- package/src/extensions/editor/sheet-extension.ts +10 -10
- package/src/integrations/thread-ranges.ts +6 -9
- package/src/meta.ts +1 -1
- package/src/model/sheet-model.ts +36 -34
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/Sheet.ts +3 -1
- package/src/types/capabilities.ts +1 -1
- package/src/types/sheet-range-types.ts +3 -3
- package/src/types/types.ts +4 -20
- package/dist/lib/browser/SheetContainer-J72HS2FI.mjs +0 -397
- package/dist/lib/browser/SheetContainer-J72HS2FI.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-LLO7PZKF.mjs.map +0 -7
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +0 -7
- package/dist/lib/browser/chunk-S27QJYTN.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-YDOW72CN.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JIYVFH42.mjs +0 -51
- package/dist/lib/browser/react-surface-JIYVFH42.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-OGSSDOZU.mjs +0 -398
- package/dist/lib/node-esm/SheetContainer-OGSSDOZU.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-OX5I2YOW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y4V6HVHO.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-Q63VQBVA.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SWRZSZVR.mjs.map +0 -7
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/index.d.ts +0 -2
- package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/index.d.ts +0 -2
- package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -10
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/index.d.ts +0 -2
- package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
- package/src/components/SheetContainer/SheetContainer.tsx +0 -48
- package/src/components/SheetContext/index.ts +0 -5
- /package/dist/lib/browser/{compute-graph-registry-RC5L7RE4.mjs.map → compute-graph-registry-CGBTEI2T.mjs.map} +0 -0
- /package/dist/lib/browser/{markdown-D2T2DOVX.mjs.map → markdown-SF55PRFI.mjs.map} +0 -0
- /package/dist/lib/node-esm/{compute-graph-registry-ZGXVLVGD.mjs.map → compute-graph-registry-B7OXC4TD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{markdown-PTV72DLO.mjs.map → markdown-MMKSGCIC.mjs.map} +0 -0
- /package/dist/types/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +0 -0
- /package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +0 -0
- /package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts +0 -0
- /package/dist/types/src/{components → containers}/SheetContainer/index.d.ts +0 -0
|
@@ -11,7 +11,7 @@ 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
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
15
|
import { useTextEditor } from '@dxos/react-ui-editor';
|
|
16
16
|
import {
|
|
17
17
|
createBasicExtensions,
|
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
} from '@dxos/ui-editor';
|
|
23
23
|
import { isNonNullable } from '@dxos/util';
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { Sheet, useComputeGraph } from '../components';
|
|
26
26
|
import { useSheetModel } from '../model';
|
|
27
27
|
import { useTestSheet, withComputeGraphDecorator } from '../testing';
|
|
28
|
-
import { Sheet } from '../types';
|
|
28
|
+
import { Sheet as SheetType } from '../types';
|
|
29
29
|
|
|
30
30
|
import { compute, computeGraphFacet } from './compute';
|
|
31
31
|
|
|
@@ -63,7 +63,7 @@ const DefaultStory = ({ text }: EditorProps) => {
|
|
|
63
63
|
[computeGraph, themeMode],
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
return <div className='
|
|
66
|
+
return <div className='w-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
const Grid = () => {
|
|
@@ -87,10 +87,10 @@ const Grid = () => {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
|
-
<div className='flex
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
</
|
|
90
|
+
<div className='flex w-[40rem] overflow-hidden'>
|
|
91
|
+
<Sheet.Root graph={graph} sheet={sheet} attendableId='test'>
|
|
92
|
+
<Sheet.Content />
|
|
93
|
+
</Sheet.Root>
|
|
94
94
|
</div>
|
|
95
95
|
);
|
|
96
96
|
};
|
|
@@ -105,11 +105,12 @@ const GraphStory = (props: EditorProps) => {
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
const meta = {
|
|
108
|
-
title: 'plugins/plugin-sheet/extensions',
|
|
108
|
+
title: 'plugins/plugin-sheet/extensions/compute',
|
|
109
109
|
decorators: [
|
|
110
|
-
withTheme,
|
|
110
|
+
withTheme(),
|
|
111
|
+
withLayout({ layout: 'fullscreen' }),
|
|
111
112
|
withClientProvider({
|
|
112
|
-
types: [
|
|
113
|
+
types: [SheetType.Sheet],
|
|
113
114
|
createIdentity: true,
|
|
114
115
|
createSpace: true,
|
|
115
116
|
}),
|
|
@@ -33,30 +33,30 @@ const highlightStyles = HighlightStyle.define([
|
|
|
33
33
|
// Function.
|
|
34
34
|
{
|
|
35
35
|
tag: tags.name,
|
|
36
|
-
class: 'text-
|
|
36
|
+
class: 'text-accent-text',
|
|
37
37
|
},
|
|
38
38
|
// Range.
|
|
39
39
|
{
|
|
40
40
|
tag: tags.tagName,
|
|
41
|
-
class: 'text-
|
|
41
|
+
class: 'text-pink-text',
|
|
42
42
|
},
|
|
43
43
|
// Values.
|
|
44
44
|
{
|
|
45
45
|
tag: tags.number,
|
|
46
|
-
class: 'text-
|
|
46
|
+
class: 'text-teal-text',
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
tag: tags.bool,
|
|
50
|
-
class: 'text-
|
|
50
|
+
class: 'text-teal-text',
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
tag: tags.string,
|
|
54
|
-
class: 'text-
|
|
54
|
+
class: 'text-teal-text',
|
|
55
55
|
},
|
|
56
56
|
// Error.
|
|
57
57
|
{
|
|
58
58
|
tag: tags.invalid,
|
|
59
|
-
class: 'text-
|
|
59
|
+
class: 'text-un-accent',
|
|
60
60
|
},
|
|
61
61
|
]);
|
|
62
62
|
|
|
@@ -97,7 +97,7 @@ export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions)
|
|
|
97
97
|
|
|
98
98
|
const title = document.createElement('h2');
|
|
99
99
|
title.innerText = name;
|
|
100
|
-
title.className = 'text-lg font-mono text-
|
|
100
|
+
title.className = 'text-lg font-mono text-accent-text';
|
|
101
101
|
root.appendChild(title);
|
|
102
102
|
|
|
103
103
|
if (description) {
|
|
@@ -110,7 +110,7 @@ export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions)
|
|
|
110
110
|
if (syntax) {
|
|
111
111
|
const detail = document.createElement('pre');
|
|
112
112
|
detail.innerText = syntax;
|
|
113
|
-
detail.className = 'whitespace-pre-wrap text-
|
|
113
|
+
detail.className = 'whitespace-pre-wrap text-green-text';
|
|
114
114
|
root.appendChild(detail);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -169,8 +169,8 @@ export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions)
|
|
|
169
169
|
icons: false,
|
|
170
170
|
tooltipClass: () =>
|
|
171
171
|
mx(
|
|
172
|
-
'!-left-[1px] !top-[33px] !-m-0 border
|
|
173
|
-
'[&>ul>li[aria-selected]]:!bg-
|
|
172
|
+
'!-left-[1px] !top-[33px] !-m-0 border border-h-0! [&>ul]:!min-w-[198px]',
|
|
173
|
+
'[&>ul>li[aria-selected]]:!bg-accent-surface',
|
|
174
174
|
'border-separator',
|
|
175
175
|
),
|
|
176
176
|
}),
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useOperationInvoker, useOperationResolver } from '@dxos/app-framework/ui';
|
|
9
|
+
import { COMPANION_PREFIX, LayoutOperation } from '@dxos/app-toolkit';
|
|
10
10
|
import { debounce } from '@dxos/async';
|
|
11
11
|
import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
|
|
12
12
|
import { Obj, Relation } from '@dxos/echo';
|
|
13
13
|
import { OperationResolver } from '@dxos/operation';
|
|
14
|
-
import {
|
|
14
|
+
import { DeckOperation } from '@dxos/plugin-deck/types';
|
|
15
15
|
import { ThreadOperation } from '@dxos/plugin-thread/types';
|
|
16
16
|
import { Filter, Query, useQuery } from '@dxos/react-client/echo';
|
|
17
17
|
import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
|
|
@@ -38,13 +38,12 @@ export const parseThreadAnchorAsCellRange = (cursor: string): CompleteCellRange
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null) => {
|
|
41
|
-
const { model, setActiveRefs } = useSheetContext();
|
|
42
|
-
const sheetId = Obj.getDXN(model.sheet).toString();
|
|
41
|
+
const { attendableId: sheetId, model, setActiveRefs } = useSheetContext();
|
|
43
42
|
|
|
44
43
|
const scrollIntoViewHandler = useMemo(
|
|
45
44
|
() =>
|
|
46
45
|
OperationResolver.make({
|
|
47
|
-
operation:
|
|
46
|
+
operation: LayoutOperation.ScrollIntoView,
|
|
48
47
|
position: 'hoist',
|
|
49
48
|
filter: (input) => input.subject === sheetId && !!input.cursor,
|
|
50
49
|
handler: (input) =>
|
|
@@ -88,12 +87,10 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
88
87
|
});
|
|
89
88
|
|
|
90
89
|
if (closestThread) {
|
|
91
|
-
const primary = Obj.getDXN(model.sheet).toString();
|
|
92
90
|
void (async () => {
|
|
93
91
|
await invokePromise(ThreadOperation.Select, { current: Relation.getDXN(closestThread).toString() });
|
|
94
92
|
await invokePromise(DeckOperation.ChangeCompanion, {
|
|
95
|
-
|
|
96
|
-
companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments`,
|
|
93
|
+
companion: `${COMPANION_PREFIX}comments`,
|
|
97
94
|
});
|
|
98
95
|
})();
|
|
99
96
|
}
|
package/src/meta.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.sheet',
|
|
10
10
|
name: 'Sheet',
|
|
11
11
|
description: trim`
|
|
12
12
|
Full-featured spreadsheet application with over 400 built-in formulas for calculations and data analysis.
|
package/src/model/sheet-model.ts
CHANGED
|
@@ -122,8 +122,8 @@ export class SheetModel extends Resource {
|
|
|
122
122
|
*/
|
|
123
123
|
protected override async _open(): Promise<void> {
|
|
124
124
|
log('initialize', { id: this.id });
|
|
125
|
-
Obj.change(this._sheet, (
|
|
126
|
-
initialize(
|
|
125
|
+
Obj.change(this._sheet, (obj) => {
|
|
126
|
+
initialize(obj);
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
this._graph.update.on((event) => {
|
|
@@ -184,8 +184,8 @@ export class SheetModel extends Resource {
|
|
|
184
184
|
|
|
185
185
|
insertRows(i: number, n = 1): string[] {
|
|
186
186
|
let idx: string[] = [];
|
|
187
|
-
Obj.change(this._sheet, (
|
|
188
|
-
idx = insertIndices(
|
|
187
|
+
Obj.change(this._sheet, (obj) => {
|
|
188
|
+
idx = insertIndices(obj.rows, i, n, MAX_ROWS);
|
|
189
189
|
});
|
|
190
190
|
this.reset();
|
|
191
191
|
return idx;
|
|
@@ -193,8 +193,8 @@ export class SheetModel extends Resource {
|
|
|
193
193
|
|
|
194
194
|
insertColumns(i: number, n = 1): string[] {
|
|
195
195
|
let idx: string[] = [];
|
|
196
|
-
Obj.change(this._sheet, (
|
|
197
|
-
idx = insertIndices(
|
|
196
|
+
Obj.change(this._sheet, (obj) => {
|
|
197
|
+
idx = insertIndices(obj.columns, i, n, MAX_COLS);
|
|
198
198
|
});
|
|
199
199
|
this.reset();
|
|
200
200
|
return idx;
|
|
@@ -208,9 +208,9 @@ export class SheetModel extends Resource {
|
|
|
208
208
|
const values = this.getCellValues(range).flat();
|
|
209
209
|
const index = this._sheet.rows.indexOf(rowIndex);
|
|
210
210
|
this.clear(range);
|
|
211
|
-
Obj.change(this._sheet, (
|
|
212
|
-
|
|
213
|
-
delete
|
|
211
|
+
Obj.change(this._sheet, (obj) => {
|
|
212
|
+
obj.rows.splice(index, 1);
|
|
213
|
+
delete obj.rowMeta[rowIndex];
|
|
214
214
|
});
|
|
215
215
|
this.reset();
|
|
216
216
|
return { axis: 'row', index, axisIndex: rowIndex, axisMeta: this._sheet.rowMeta[rowIndex], values };
|
|
@@ -224,39 +224,41 @@ export class SheetModel extends Resource {
|
|
|
224
224
|
const values = this.getCellValues(range).flat();
|
|
225
225
|
const index = this._sheet.columns.indexOf(colIndex);
|
|
226
226
|
this.clear(range);
|
|
227
|
-
Obj.change(this._sheet, (
|
|
228
|
-
|
|
229
|
-
delete
|
|
227
|
+
Obj.change(this._sheet, (obj) => {
|
|
228
|
+
obj.columns.splice(index, 1);
|
|
229
|
+
delete obj.columnMeta[colIndex];
|
|
230
230
|
});
|
|
231
231
|
this.reset();
|
|
232
232
|
return { axis: 'col', index, axisIndex: colIndex, axisMeta: this._sheet.rowMeta[colIndex], values };
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
restoreRow({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
|
|
236
|
-
Obj.change(this._sheet, (
|
|
237
|
-
|
|
236
|
+
Obj.change(this._sheet, (obj) => {
|
|
237
|
+
obj.rows.splice(index, 0, axisIndex);
|
|
238
238
|
values.forEach((value, col) => {
|
|
239
239
|
if (value) {
|
|
240
|
-
|
|
240
|
+
obj.cells[`${obj.columns[col]}@${axisIndex}`] = { value };
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
|
+
|
|
243
244
|
if (axisMeta) {
|
|
244
|
-
|
|
245
|
+
obj.rowMeta[axisIndex] = axisMeta;
|
|
245
246
|
}
|
|
246
247
|
});
|
|
247
248
|
this.reset();
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
restoreColumn({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
|
|
251
|
-
Obj.change(this._sheet, (
|
|
252
|
-
|
|
252
|
+
Obj.change(this._sheet, (obj) => {
|
|
253
|
+
obj.columns.splice(index, 0, axisIndex);
|
|
253
254
|
values.forEach((value, row) => {
|
|
254
255
|
if (value) {
|
|
255
|
-
|
|
256
|
+
obj.cells[`${axisIndex}@${obj.rows[row]}`] = { value };
|
|
256
257
|
}
|
|
257
258
|
});
|
|
259
|
+
|
|
258
260
|
if (axisMeta) {
|
|
259
|
-
|
|
261
|
+
obj.columnMeta[axisIndex] = axisMeta;
|
|
260
262
|
}
|
|
261
263
|
});
|
|
262
264
|
this.reset();
|
|
@@ -275,10 +277,10 @@ export class SheetModel extends Resource {
|
|
|
275
277
|
const topLeft = getTopLeft(range);
|
|
276
278
|
const values = this._iterRange(range, () => null);
|
|
277
279
|
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
278
|
-
Obj.change(this._sheet, (
|
|
280
|
+
Obj.change(this._sheet, (obj) => {
|
|
279
281
|
this._iterRange(range, (cell) => {
|
|
280
282
|
const idx = addressToIndex(this._sheet, cell);
|
|
281
|
-
delete
|
|
283
|
+
delete obj.cells[idx];
|
|
282
284
|
});
|
|
283
285
|
});
|
|
284
286
|
}
|
|
@@ -286,10 +288,10 @@ export class SheetModel extends Resource {
|
|
|
286
288
|
cut(range: CellRange): void {
|
|
287
289
|
invariant(this._node);
|
|
288
290
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
289
|
-
Obj.change(this._sheet, (
|
|
291
|
+
Obj.change(this._sheet, (obj) => {
|
|
290
292
|
this._iterRange(range, (cell) => {
|
|
291
293
|
const idx = addressToIndex(this._sheet, cell);
|
|
292
|
-
delete
|
|
294
|
+
delete obj.cells[idx];
|
|
293
295
|
});
|
|
294
296
|
});
|
|
295
297
|
}
|
|
@@ -303,12 +305,12 @@ export class SheetModel extends Resource {
|
|
|
303
305
|
invariant(this._node);
|
|
304
306
|
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
305
307
|
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
306
|
-
Obj.change(this._sheet, (
|
|
308
|
+
Obj.change(this._sheet, (obj) => {
|
|
307
309
|
for (const change of changes) {
|
|
308
310
|
if (change instanceof ExportedCellChange) {
|
|
309
311
|
const { address, newValue } = change;
|
|
310
312
|
const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
|
|
311
|
-
|
|
313
|
+
obj.cells[idx] = { value: newValue };
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
316
|
});
|
|
@@ -402,14 +404,14 @@ export class SheetModel extends Resource {
|
|
|
402
404
|
// Reallocate if > current bounds.
|
|
403
405
|
let refresh = false;
|
|
404
406
|
if (cell.row >= this._sheet.rows.length) {
|
|
405
|
-
Obj.change(this._sheet, (
|
|
406
|
-
insertIndices(
|
|
407
|
+
Obj.change(this._sheet, (obj) => {
|
|
408
|
+
insertIndices(obj.rows, cell.row, 1, MAX_ROWS);
|
|
407
409
|
});
|
|
408
410
|
refresh = true;
|
|
409
411
|
}
|
|
410
412
|
if (cell.col >= this._sheet.columns.length) {
|
|
411
|
-
Obj.change(this._sheet, (
|
|
412
|
-
insertIndices(
|
|
413
|
+
Obj.change(this._sheet, (obj) => {
|
|
414
|
+
insertIndices(obj.columns, cell.col, 1, MAX_COLS);
|
|
413
415
|
});
|
|
414
416
|
refresh = true;
|
|
415
417
|
}
|
|
@@ -427,16 +429,16 @@ export class SheetModel extends Resource {
|
|
|
427
429
|
// Insert into sheet.
|
|
428
430
|
const idx = addressToIndex(this._sheet, cell);
|
|
429
431
|
if (value === undefined || value === null) {
|
|
430
|
-
Obj.change(this._sheet, (
|
|
431
|
-
delete
|
|
432
|
+
Obj.change(this._sheet, (obj) => {
|
|
433
|
+
delete obj.cells[idx];
|
|
432
434
|
});
|
|
433
435
|
} else {
|
|
434
436
|
if (isFormula(value)) {
|
|
435
437
|
value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
|
|
436
438
|
}
|
|
437
439
|
|
|
438
|
-
Obj.change(this._sheet, (
|
|
439
|
-
|
|
440
|
+
Obj.change(this._sheet, (obj) => {
|
|
441
|
+
obj.cells[idx] = { value };
|
|
440
442
|
});
|
|
441
443
|
}
|
|
442
444
|
}
|
|
@@ -10,7 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
...e2ePreset(import.meta.dirname),
|
|
11
11
|
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
12
12
|
webServer: {
|
|
13
|
-
command: '
|
|
13
|
+
command: 'pnpm storybook dev --ci --quiet --port=9005 --config-dir=.storybook',
|
|
14
14
|
port: 9005,
|
|
15
15
|
reuseExistingServer: false,
|
|
16
16
|
},
|
|
@@ -15,7 +15,7 @@ test.describe('plugin-sheet', () => {
|
|
|
15
15
|
|
|
16
16
|
test.beforeEach(async ({ browser }) => {
|
|
17
17
|
const setup = await setupPage(browser, {
|
|
18
|
-
url: storybookUrl('plugins-plugin-sheet-sheetcontainer--spec', 9005),
|
|
18
|
+
url: storybookUrl('plugins-plugin-sheet-containers-sheetcontainer--spec', 9005),
|
|
19
19
|
viewportSize: { width: 1280, height: 720 },
|
|
20
20
|
});
|
|
21
21
|
page = setup.page;
|
package/src/translations.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const translations = [
|
|
|
16
16
|
'typename label_one': 'Sheet',
|
|
17
17
|
'typename label_other': 'Sheets',
|
|
18
18
|
'object name placeholder': 'New sheet',
|
|
19
|
+
'add object label': 'Add sheet',
|
|
19
20
|
'rename object label': 'Rename sheet',
|
|
20
21
|
'delete object label': 'Delete sheet',
|
|
21
22
|
'object deleted label': 'Sheet deleted',
|
package/src/types/Sheet.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import * as Schema from 'effect/Schema';
|
|
6
8
|
|
|
7
9
|
import { addressFromA1Notation, isFormula } from '@dxos/compute';
|
|
@@ -62,7 +64,7 @@ export const Sheet = Schema.Struct({
|
|
|
62
64
|
ranges: Schema.Array(Range).pipe(FormInputAnnotation.set(false)),
|
|
63
65
|
}).pipe(
|
|
64
66
|
Type.object({
|
|
65
|
-
typename: 'dxos.
|
|
67
|
+
typename: 'org.dxos.type.sheet',
|
|
66
68
|
version: '0.1.0',
|
|
67
69
|
}),
|
|
68
70
|
);
|
|
@@ -34,14 +34,14 @@ export const cellClassNameForRange = ({ key, value }: Sheet.Sheet['ranges'][numb
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
case commentKey:
|
|
37
|
-
return 'bg-
|
|
37
|
+
return 'bg-grid-comment';
|
|
38
38
|
|
|
39
39
|
case styleKey:
|
|
40
40
|
switch (value) {
|
|
41
41
|
case 'highlight':
|
|
42
|
-
return '
|
|
42
|
+
return 'bg-grid-highlight!';
|
|
43
43
|
case 'softwrap':
|
|
44
|
-
return '
|
|
44
|
+
return 'whitespace-normal!';
|
|
45
45
|
default:
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
package/src/types/types.ts
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Capability } from '@dxos/app-framework';
|
|
8
7
|
import { Operation } from '@dxos/operation';
|
|
9
|
-
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
10
|
-
import { Collection } from '@dxos/schema';
|
|
11
8
|
|
|
12
9
|
import { meta } from '../meta';
|
|
13
10
|
|
|
@@ -28,27 +25,14 @@ export namespace SheetAction {
|
|
|
28
25
|
export type RestoreAxis = Schema.Schema.Type<typeof RestoreAxis>;
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
const SHEET_OPERATION = `${meta.id}
|
|
28
|
+
const SHEET_OPERATION = `${meta.id}.operation`;
|
|
32
29
|
|
|
33
30
|
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
34
31
|
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
35
32
|
|
|
36
33
|
export namespace SheetOperation {
|
|
37
|
-
export const OnCreateSpace = Operation.make({
|
|
38
|
-
meta: { key: `${SHEET_OPERATION}/on-create-space`, name: 'On Create Space' },
|
|
39
|
-
services: [Capability.Service],
|
|
40
|
-
schema: {
|
|
41
|
-
input: Schema.Struct({
|
|
42
|
-
space: SpaceSchema,
|
|
43
|
-
rootCollection: Collection.Collection,
|
|
44
|
-
isDefault: Schema.optional(Schema.Boolean),
|
|
45
|
-
}),
|
|
46
|
-
output: Schema.Void,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
34
|
export const InsertAxis = Operation.make({
|
|
51
|
-
meta: { key: `${SHEET_OPERATION}
|
|
35
|
+
meta: { key: `${SHEET_OPERATION}.axis-insert`, name: 'Insert Axis' },
|
|
52
36
|
schema: {
|
|
53
37
|
input: Schema.Struct({
|
|
54
38
|
model: Schema.Any,
|
|
@@ -71,7 +55,7 @@ export namespace SheetOperation {
|
|
|
71
55
|
export type DropAxisOutput = Schema.Schema.Type<typeof DropAxisOutput>;
|
|
72
56
|
|
|
73
57
|
export const DropAxis = Operation.make({
|
|
74
|
-
meta: { key: `${SHEET_OPERATION}
|
|
58
|
+
meta: { key: `${SHEET_OPERATION}.axis-drop`, name: 'Drop Axis' },
|
|
75
59
|
schema: {
|
|
76
60
|
input: Schema.Struct({
|
|
77
61
|
model: Schema.Any,
|
|
@@ -86,7 +70,7 @@ export namespace SheetOperation {
|
|
|
86
70
|
* Restore a dropped axis (inverse of DropAxis).
|
|
87
71
|
*/
|
|
88
72
|
export const RestoreAxis = Operation.make({
|
|
89
|
-
meta: { key: `${SHEET_OPERATION}
|
|
73
|
+
meta: { key: `${SHEET_OPERATION}.restore-axis`, name: 'Restore Axis' },
|
|
90
74
|
schema: {
|
|
91
75
|
input: Schema.Struct({
|
|
92
76
|
model: Schema.Any.annotations({ description: 'The sheet model.' }),
|