@dxos/plugin-sheet 0.8.2-main.5885341 → 0.8.2-main.600d381
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-7DK3ZZUT.mjs → SheetContainer-O4WVY7Y4.mjs} +87 -85
- package/dist/lib/browser/SheetContainer-O4WVY7Y4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HRTIOTK7.mjs → chunk-N2FOQHUH.mjs} +49 -48
- package/dist/lib/browser/chunk-N2FOQHUH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IE42HBFC.mjs → chunk-RSBJNX7L.mjs} +7 -8
- package/dist/lib/browser/chunk-RSBJNX7L.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -4
- package/dist/lib/browser/{intent-resolver-OMXW6BDZ.mjs → intent-resolver-DN7JXDAV.mjs} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-RTQDRQ4X.mjs → react-surface-JNDDTM6K.mjs} +3 -3
- package/dist/lib/browser/{thread-HV32Z27A.mjs → thread-WU64QL2A.mjs} +2 -2
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{SheetContainer-6RPY4P7E.cjs → SheetContainer-2CFOIYBF.cjs} +105 -101
- package/dist/lib/node/SheetContainer-2CFOIYBF.cjs.map +7 -0
- package/dist/lib/node/{chunk-UXSU6W7E.cjs → chunk-3QKD6C7X.cjs} +19 -20
- package/dist/lib/node/chunk-3QKD6C7X.cjs.map +7 -0
- package/dist/lib/node/{chunk-C3Q4GSES.cjs → chunk-HLSQVT3C.cjs} +65 -64
- package/dist/lib/node/chunk-HLSQVT3C.cjs.map +7 -0
- package/dist/lib/node/index.cjs +10 -10
- package/dist/lib/node/{intent-resolver-KI5DG7LR.cjs → intent-resolver-OPF56TAL.cjs} +9 -9
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-ZDOTWZ4Q.cjs → react-surface-ZTKJM4TA.cjs} +11 -11
- package/dist/lib/node/{thread-NVEWN3H2.cjs → thread-E7YPGR5T.cjs} +7 -7
- package/dist/lib/node/types/index.cjs +29 -29
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-QQUB22WF.mjs → SheetContainer-W3DQ7UFO.mjs} +87 -85
- package/dist/lib/node-esm/SheetContainer-W3DQ7UFO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JSVXC3QP.mjs → chunk-A5PYXQL6.mjs} +7 -8
- package/dist/lib/node-esm/chunk-A5PYXQL6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SWRUEW6J.mjs → chunk-LYZV4Q4C.mjs} +49 -48
- package/dist/lib/node-esm/chunk-LYZV4Q4C.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +4 -4
- package/dist/lib/node-esm/{intent-resolver-3FVOBB3K.mjs → intent-resolver-7AN5CN4R.mjs} +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-T4OVUZY2.mjs → react-surface-M6VLLWMY.mjs} +3 -3
- package/dist/lib/node-esm/{thread-DTWGGMW4.mjs → thread-ULESW6IX.mjs} +2 -2
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.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.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +4 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/comment.d.ts +3 -1
- package/dist/types/src/components/SheetToolbar/comment.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +3 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -54
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +145 -150
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +36 -36
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -47
- package/src/components/ComputeGraph/compute-graph.stories.tsx +1 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +1 -1
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +2 -2
- package/src/components/RangeList/RangeList.tsx +2 -2
- package/src/components/SheetContainer/SheetContainer.stories.tsx +1 -5
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +1 -1
- package/src/components/SheetToolbar/SheetToolbar.tsx +33 -8
- package/src/components/SheetToolbar/align.ts +44 -14
- package/src/components/SheetToolbar/comment.ts +39 -11
- package/src/components/SheetToolbar/style.ts +48 -12
- package/src/integrations/thread-ranges.ts +2 -3
- package/src/model/sheet-model.test.ts +1 -1
- package/src/sanity.test.ts +1 -1
- package/src/types/schema.ts +21 -19
- package/src/types/types.ts +25 -25
- package/dist/lib/browser/SheetContainer-7DK3ZZUT.mjs.map +0 -7
- package/dist/lib/browser/chunk-HRTIOTK7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IE42HBFC.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-6RPY4P7E.cjs.map +0 -7
- package/dist/lib/node/chunk-C3Q4GSES.cjs.map +0 -7
- package/dist/lib/node/chunk-UXSU6W7E.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-QQUB22WF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JSVXC3QP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SWRUEW6J.mjs.map +0 -7
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +0 -8
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +0 -1
- package/src/components/SheetToolbar/useToolbarAction.ts +0 -87
- /package/dist/lib/browser/{intent-resolver-OMXW6BDZ.mjs.map → intent-resolver-DN7JXDAV.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-RTQDRQ4X.mjs.map → react-surface-JNDDTM6K.mjs.map} +0 -0
- /package/dist/lib/browser/{thread-HV32Z27A.mjs.map → thread-WU64QL2A.mjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-KI5DG7LR.cjs.map → intent-resolver-OPF56TAL.cjs.map} +0 -0
- /package/dist/lib/node/{react-surface-ZDOTWZ4Q.cjs.map → react-surface-ZTKJM4TA.cjs.map} +0 -0
- /package/dist/lib/node/{thread-NVEWN3H2.cjs.map → thread-E7YPGR5T.cjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-3FVOBB3K.mjs.map → intent-resolver-7AN5CN4R.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-T4OVUZY2.mjs.map → react-surface-M6VLLWMY.mjs.map} +0 -0
- /package/dist/lib/node-esm/{thread-DTWGGMW4.mjs.map → thread-ULESW6IX.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-sheet",
|
|
3
|
-
"version": "0.8.2-main.
|
|
3
|
+
"version": "0.8.2-main.600d381",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -49,43 +49,44 @@
|
|
|
49
49
|
"@radix-ui/react-context": "1.1.1",
|
|
50
50
|
"codemirror-lang-spreadsheet": "^1.3.0",
|
|
51
51
|
"date-fns": "^3.3.1",
|
|
52
|
+
"effect": "^3.13.3",
|
|
52
53
|
"lodash.defaultsdeep": "^4.6.1",
|
|
53
54
|
"re-resizable": "^6.9.17",
|
|
54
55
|
"react-markdown": "^8.0.5",
|
|
55
56
|
"react-resize-detector": "^11.0.1",
|
|
56
|
-
"@dxos/app-framework": "0.8.2-main.
|
|
57
|
-
"@dxos/client": "0.8.2-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/echo-schema": "0.8.2-main.
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/plugin-
|
|
71
|
-
"@dxos/plugin-deck": "0.8.2-main.
|
|
72
|
-
"@dxos/plugin-
|
|
73
|
-
"@dxos/plugin-
|
|
74
|
-
"@dxos/plugin-
|
|
75
|
-
"@dxos/plugin-graph": "0.8.2-main.
|
|
76
|
-
"@dxos/plugin-thread": "0.8.2-main.
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/react-
|
|
80
|
-
"@dxos/react-
|
|
81
|
-
"@dxos/react-
|
|
82
|
-
"@dxos/react-ui-
|
|
83
|
-
"@dxos/react-ui-
|
|
84
|
-
"@dxos/react-ui-
|
|
85
|
-
"@dxos/react-ui-
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
57
|
+
"@dxos/app-framework": "0.8.2-main.600d381",
|
|
58
|
+
"@dxos/client": "0.8.2-main.600d381",
|
|
59
|
+
"@dxos/context": "0.8.2-main.600d381",
|
|
60
|
+
"@dxos/debug": "0.8.2-main.600d381",
|
|
61
|
+
"@dxos/async": "0.8.2-main.600d381",
|
|
62
|
+
"@dxos/crypto": "0.8.2-main.600d381",
|
|
63
|
+
"@dxos/echo-schema": "0.8.2-main.600d381",
|
|
64
|
+
"@dxos/compute": "0.8.2-main.600d381",
|
|
65
|
+
"@dxos/functions": "0.8.2-main.600d381",
|
|
66
|
+
"@dxos/invariant": "0.8.2-main.600d381",
|
|
67
|
+
"@dxos/live-object": "0.8.2-main.600d381",
|
|
68
|
+
"@dxos/keys": "0.8.2-main.600d381",
|
|
69
|
+
"@dxos/log": "0.8.2-main.600d381",
|
|
70
|
+
"@dxos/plugin-client": "0.8.2-main.600d381",
|
|
71
|
+
"@dxos/plugin-attention": "0.8.2-main.600d381",
|
|
72
|
+
"@dxos/plugin-deck": "0.8.2-main.600d381",
|
|
73
|
+
"@dxos/plugin-markdown": "0.8.2-main.600d381",
|
|
74
|
+
"@dxos/plugin-script": "0.8.2-main.600d381",
|
|
75
|
+
"@dxos/plugin-space": "0.8.2-main.600d381",
|
|
76
|
+
"@dxos/plugin-graph": "0.8.2-main.600d381",
|
|
77
|
+
"@dxos/plugin-thread": "0.8.2-main.600d381",
|
|
78
|
+
"@dxos/plugin-stack": "0.8.2-main.600d381",
|
|
79
|
+
"@dxos/react-ui-editor": "0.8.2-main.600d381",
|
|
80
|
+
"@dxos/react-client": "0.8.2-main.600d381",
|
|
81
|
+
"@dxos/react-ui-attention": "0.8.2-main.600d381",
|
|
82
|
+
"@dxos/react-hooks": "0.8.2-main.600d381",
|
|
83
|
+
"@dxos/react-ui-grid": "0.8.2-main.600d381",
|
|
84
|
+
"@dxos/react-ui-form": "0.8.2-main.600d381",
|
|
85
|
+
"@dxos/react-ui-list": "0.8.2-main.600d381",
|
|
86
|
+
"@dxos/react-ui-menu": "0.8.2-main.600d381",
|
|
87
|
+
"@dxos/react-ui-stack": "0.8.2-main.600d381",
|
|
88
|
+
"@dxos/util": "0.8.2-main.600d381",
|
|
89
|
+
"@dxos/schema": "0.8.2-main.600d381"
|
|
89
90
|
},
|
|
90
91
|
"devDependencies": {
|
|
91
92
|
"@lezer/generator": "^1.7.1",
|
|
@@ -94,26 +95,25 @@
|
|
|
94
95
|
"@types/react": "~18.2.0",
|
|
95
96
|
"@types/react-dom": "~18.2.0",
|
|
96
97
|
"@types/react-window": "^1.8.8",
|
|
97
|
-
"effect": "3.14.21",
|
|
98
98
|
"react": "~18.2.0",
|
|
99
99
|
"react-dom": "~18.2.0",
|
|
100
100
|
"vite": "5.4.7",
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/
|
|
105
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.2-main.
|
|
106
|
-
"@dxos/react-ui
|
|
107
|
-
"@dxos/
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/test-utils": "0.8.2-main.
|
|
101
|
+
"@dxos/lit-grid": "0.8.2-main.600d381",
|
|
102
|
+
"@dxos/random": "0.8.2-main.600d381",
|
|
103
|
+
"@dxos/echo-generator": "0.8.2-main.600d381",
|
|
104
|
+
"@dxos/react-ui-theme": "0.8.2-main.600d381",
|
|
105
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.2-main.600d381",
|
|
106
|
+
"@dxos/react-ui": "0.8.2-main.600d381",
|
|
107
|
+
"@dxos/react-ui-types": "0.8.2-main.600d381",
|
|
108
|
+
"@dxos/storybook-utils": "0.8.2-main.600d381",
|
|
109
|
+
"@dxos/test-utils": "0.8.2-main.600d381"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
|
-
"effect": "3.13.3",
|
|
112
|
+
"effect": "^3.13.3",
|
|
113
113
|
"react": "~18.2.0",
|
|
114
114
|
"react-dom": "~18.2.0",
|
|
115
|
-
"@dxos/react-ui": "0.8.2-main.
|
|
116
|
-
"@dxos/react-ui-theme": "0.8.2-main.
|
|
115
|
+
"@dxos/react-ui": "0.8.2-main.600d381",
|
|
116
|
+
"@dxos/react-ui-theme": "0.8.2-main.600d381"
|
|
117
117
|
},
|
|
118
118
|
"publishConfig": {
|
|
119
119
|
"access": "public"
|
|
@@ -8,7 +8,7 @@ import { type Meta } from '@storybook/react';
|
|
|
8
8
|
import React, { useEffect, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
11
|
-
import { FunctionType } from '@dxos/functions
|
|
11
|
+
import { FunctionType } from '@dxos/functions';
|
|
12
12
|
import { live, useSpace, Filter } from '@dxos/react-client/echo';
|
|
13
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { Toolbar, Button, Input } from '@dxos/react-ui';
|
|
@@ -41,7 +41,7 @@ const meta: Meta = {
|
|
|
41
41
|
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
42
42
|
withComputeGraphDecorator(),
|
|
43
43
|
withTheme,
|
|
44
|
-
withLayout({ fullscreen: true,
|
|
44
|
+
withLayout({ fullscreen: true, classNames: 'grid' }),
|
|
45
45
|
withPluginManager(),
|
|
46
46
|
],
|
|
47
47
|
parameters: { translations },
|
|
@@ -8,7 +8,7 @@ import { type Meta } from '@storybook/react';
|
|
|
8
8
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { Client } from '@dxos/client';
|
|
11
|
-
import { createDocAccessor, type
|
|
11
|
+
import { createDocAccessor, type AnyLiveObject } from '@dxos/client/echo';
|
|
12
12
|
import { defaultFunctions } from '@dxos/compute';
|
|
13
13
|
import { getRegisteredFunctionNames } from '@dxos/compute/testing';
|
|
14
14
|
import { automerge } from '@dxos/react-ui-editor';
|
|
@@ -32,7 +32,7 @@ const Story = ({ value, ...props }: StoryProps) => {
|
|
|
32
32
|
|
|
33
33
|
const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
34
34
|
const cell = 'A1';
|
|
35
|
-
const [object, setObject] = useState<
|
|
35
|
+
const [object, setObject] = useState<AnyLiveObject<SheetType>>();
|
|
36
36
|
useEffect(() => {
|
|
37
37
|
setTimeout(async () => {
|
|
38
38
|
const client = new Client({ types: [SheetType] });
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
import React, { useCallback } from 'react';
|
|
6
7
|
|
|
7
8
|
import { rangeToA1Notation } from '@dxos/compute';
|
|
8
|
-
import { S } from '@dxos/echo-schema';
|
|
9
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { List } from '@dxos/react-ui-list';
|
|
11
11
|
import { ghostHover } from '@dxos/react-ui-theme';
|
|
@@ -32,7 +32,7 @@ export const RangeList = ({ sheet }: RangeListProps) => {
|
|
|
32
32
|
return (
|
|
33
33
|
<>
|
|
34
34
|
<h2 className='p-2 text-sm font-semibold'>{t('range list heading')}</h2>
|
|
35
|
-
<List.Root<Range> items={sheet.ranges} isItem={
|
|
35
|
+
<List.Root<Range> items={sheet.ranges} isItem={Schema.is(Range)}>
|
|
36
36
|
{({ items: ranges }) =>
|
|
37
37
|
ranges.map((range, i) => (
|
|
38
38
|
<List.Item key={i} item={range} classNames={['p-2', ghostHover]}>
|
|
@@ -64,11 +64,7 @@ const meta: Meta = {
|
|
|
64
64
|
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
65
65
|
withComputeGraphDecorator(),
|
|
66
66
|
withTheme,
|
|
67
|
-
withLayout({
|
|
68
|
-
fullscreen: true,
|
|
69
|
-
tooltips: true,
|
|
70
|
-
classNames: 'grid',
|
|
71
|
-
}),
|
|
67
|
+
withLayout({ fullscreen: true, classNames: 'grid' }),
|
|
72
68
|
withAttention,
|
|
73
69
|
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
74
70
|
withPluginManager({
|
|
@@ -23,7 +23,7 @@ const meta: Meta = {
|
|
|
23
23
|
title: 'plugins/plugin-sheet/Toolbar',
|
|
24
24
|
component: SheetToolbar,
|
|
25
25
|
render: DefaultStory,
|
|
26
|
-
decorators: [withTheme, withLayout(
|
|
26
|
+
decorators: [withTheme, withLayout()],
|
|
27
27
|
parameters: { translations, layout: 'fullscreen' },
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -4,14 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, useCallback } from 'react';
|
|
6
6
|
|
|
7
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { type CompleteCellRange } from '@dxos/compute';
|
|
9
|
+
import { ThreadAction } from '@dxos/plugin-thread/types';
|
|
7
10
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
11
|
import { createGapSeparator, MenuProvider, ToolbarMenu, useMenuActions } from '@dxos/react-ui-menu';
|
|
9
12
|
|
|
10
13
|
import { createAlign, useAlignState } from './align';
|
|
11
14
|
import { createComment, useCommentState } from './comment';
|
|
12
15
|
import { createStyle, useStyleState } from './style';
|
|
13
|
-
import { useToolbarAction } from './useToolbarAction';
|
|
14
16
|
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
17
|
+
import { type SheetModel } from '../../model';
|
|
18
|
+
import { useSheetContext } from '../SheetContext';
|
|
15
19
|
|
|
16
20
|
//
|
|
17
21
|
// Root
|
|
@@ -19,11 +23,16 @@ import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
|
19
23
|
|
|
20
24
|
export type SheetToolbarProps = ThemedClassName<PropsWithChildren<{ attendableId?: string }>>;
|
|
21
25
|
|
|
22
|
-
const createToolbarActions = (
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
const createToolbarActions = (
|
|
27
|
+
model: SheetModel,
|
|
28
|
+
state: ToolbarState,
|
|
29
|
+
onComment: (cellContent: string, cursor: string) => void,
|
|
30
|
+
cursorFallbackRange?: CompleteCellRange,
|
|
31
|
+
) => {
|
|
32
|
+
const align = createAlign(model, state, cursorFallbackRange);
|
|
33
|
+
const style = createStyle(model, state, cursorFallbackRange);
|
|
25
34
|
const gap = createGapSeparator();
|
|
26
|
-
const comment = createComment(state);
|
|
35
|
+
const comment = createComment(model, state, onComment, cursorFallbackRange);
|
|
27
36
|
return {
|
|
28
37
|
nodes: [...align.nodes, ...style.nodes, ...gap.nodes, ...comment.nodes],
|
|
29
38
|
edges: [...align.edges, ...style.edges, ...gap.edges, ...comment.edges],
|
|
@@ -31,17 +40,33 @@ const createToolbarActions = (state: ToolbarState) => {
|
|
|
31
40
|
};
|
|
32
41
|
|
|
33
42
|
export const SheetToolbar = ({ attendableId, classNames }: SheetToolbarProps) => {
|
|
43
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
44
|
+
const { model, cursorFallbackRange } = useSheetContext();
|
|
34
45
|
const state = useToolbarState({});
|
|
35
46
|
useAlignState(state);
|
|
36
47
|
useStyleState(state);
|
|
37
48
|
useCommentState(state);
|
|
38
49
|
|
|
39
|
-
const
|
|
50
|
+
const handleComment = useCallback(
|
|
51
|
+
(name: string, cursor: string) =>
|
|
52
|
+
dispatch(
|
|
53
|
+
createIntent(ThreadAction.Create, {
|
|
54
|
+
cursor,
|
|
55
|
+
name,
|
|
56
|
+
subject: model.sheet,
|
|
57
|
+
}),
|
|
58
|
+
),
|
|
59
|
+
[model.sheet, dispatch],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const actionsCreator = useCallback(
|
|
63
|
+
() => createToolbarActions(model, state, handleComment, cursorFallbackRange),
|
|
64
|
+
[model, state, handleComment, cursorFallbackRange],
|
|
65
|
+
);
|
|
40
66
|
const menu = useMenuActions(actionsCreator);
|
|
41
|
-
const handleAction = useToolbarAction(state);
|
|
42
67
|
|
|
43
68
|
return (
|
|
44
|
-
<MenuProvider {...menu} attendableId={attendableId}
|
|
69
|
+
<MenuProvider {...menu} attendableId={attendableId}>
|
|
45
70
|
<ToolbarMenu classNames={classNames} />
|
|
46
71
|
</MenuProvider>
|
|
47
72
|
);
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import { inRange } from '@dxos/compute';
|
|
7
|
+
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
8
|
import { createMenuAction, createMenuItemGroup, type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
|
+
import { type ToolbarState } from './useToolbarState';
|
|
10
11
|
import { SHEET_PLUGIN } from '../../meta';
|
|
11
|
-
import { type
|
|
12
|
+
import { type SheetModel } from '../../model';
|
|
13
|
+
import { type AlignKey, alignKey, type AlignValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
12
14
|
import { useSheetContext } from '../SheetContext';
|
|
13
15
|
|
|
14
16
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
@@ -43,21 +45,49 @@ const createAlignGroupAction = (value?: AlignValue) =>
|
|
|
43
45
|
value: `${alignKey}--${value}`,
|
|
44
46
|
} as ToolbarMenuActionGroupProperties);
|
|
45
47
|
|
|
46
|
-
const createAlignActions = (
|
|
48
|
+
const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallbackRange?: CompleteCellRange) =>
|
|
47
49
|
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
48
|
-
return createMenuAction<AlignAction>(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
return createMenuAction<AlignAction>(
|
|
51
|
+
`${alignKey}--${alignValue}`,
|
|
52
|
+
() => {
|
|
53
|
+
if (!cursorFallbackRange) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const index =
|
|
57
|
+
model.sheet.ranges?.findIndex(
|
|
58
|
+
(range) =>
|
|
59
|
+
range.key === alignKey && inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),
|
|
60
|
+
) ?? -1;
|
|
61
|
+
const nextRangeEntity = {
|
|
62
|
+
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
63
|
+
key: alignKey,
|
|
64
|
+
value: alignValue as AlignValue,
|
|
65
|
+
};
|
|
66
|
+
if (index < 0) {
|
|
67
|
+
model.sheet.ranges?.push(nextRangeEntity);
|
|
68
|
+
state[alignKey] = nextRangeEntity.value;
|
|
69
|
+
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
70
|
+
model.sheet.ranges?.splice(index, 1);
|
|
71
|
+
state[alignKey] = undefined;
|
|
72
|
+
} else {
|
|
73
|
+
model.sheet.ranges?.splice(index, 1, nextRangeEntity);
|
|
74
|
+
state[alignKey] = nextRangeEntity.value;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: alignKey,
|
|
79
|
+
value: alignValue as AlignValue,
|
|
80
|
+
checked: state[alignKey] === alignValue,
|
|
81
|
+
label: [`range value ${alignValue} label`, { ns: SHEET_PLUGIN }],
|
|
82
|
+
icon,
|
|
83
|
+
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
84
|
+
},
|
|
85
|
+
);
|
|
56
86
|
});
|
|
57
87
|
|
|
58
|
-
export const createAlign = (
|
|
59
|
-
const alignGroup = createAlignGroupAction(
|
|
60
|
-
const alignActions = createAlignActions(
|
|
88
|
+
export const createAlign = (model: SheetModel, state: ToolbarState, cursorFallbackRange?: CompleteCellRange) => {
|
|
89
|
+
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
90
|
+
const alignActions = createAlignActions(model, state, cursorFallbackRange);
|
|
61
91
|
return {
|
|
62
92
|
nodes: [alignGroup, ...alignActions],
|
|
63
93
|
edges: [
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type CompleteCellRange } from '@dxos/compute';
|
|
7
8
|
import { RefArray } from '@dxos/live-object';
|
|
8
9
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
9
10
|
|
|
11
|
+
import { completeCellRangeToThreadCursor } from '../../integrations/thread-ranges';
|
|
10
12
|
import { SHEET_PLUGIN } from '../../meta';
|
|
13
|
+
import { type SheetModel } from '../../model';
|
|
11
14
|
import { commentKey, type CommentKey, type CommentValue, rangeToIndex } from '../../types';
|
|
12
15
|
import { useSheetContext } from '../SheetContext';
|
|
13
16
|
|
|
@@ -41,16 +44,41 @@ export const useCommentState = (state: Partial<CommentState>) => {
|
|
|
41
44
|
}, [overlapsCommentAnchor, cursorFallbackRange]);
|
|
42
45
|
};
|
|
43
46
|
|
|
44
|
-
const createCommentAction = (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const createCommentAction = (
|
|
48
|
+
model: SheetModel,
|
|
49
|
+
state: Partial<CommentState>,
|
|
50
|
+
onComment: (cellContent: string, cursor: string) => void,
|
|
51
|
+
cursorFallbackRange?: CompleteCellRange,
|
|
52
|
+
) =>
|
|
53
|
+
createMenuAction<Pick<CommentAction, 'key'>>(
|
|
54
|
+
'comment',
|
|
55
|
+
() => {
|
|
56
|
+
if (!cursorFallbackRange) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const cellContent = model.getCellText(cursorFallbackRange.from);
|
|
61
|
+
if (!cellContent) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onComment(cellContent, completeCellRangeToThreadCursor(cursorFallbackRange));
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: commentKey,
|
|
69
|
+
testId: 'editor.toolbar.comment',
|
|
70
|
+
icon: 'ph--chat-text--regular',
|
|
71
|
+
label: [`${state.commentEnabled} label`, { ns: SHEET_PLUGIN }],
|
|
72
|
+
disabled: state.commentEnabled !== 'comment',
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export const createComment = (
|
|
77
|
+
model: SheetModel,
|
|
78
|
+
state: Partial<CommentState>,
|
|
79
|
+
onComment: (cellContent: string, cursor: string) => void,
|
|
80
|
+
cursorFallbackRange?: CompleteCellRange,
|
|
81
|
+
) => ({
|
|
82
|
+
nodes: [createCommentAction(model, state, onComment, cursorFallbackRange)],
|
|
55
83
|
edges: [{ source: 'root', target: 'comment' }],
|
|
56
84
|
});
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import { inRange } from '@dxos/compute';
|
|
7
|
+
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
8
|
import { createMenuAction, createMenuItemGroup, type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
10
|
import { SHEET_PLUGIN } from '../../meta';
|
|
11
|
-
import {
|
|
11
|
+
import { type SheetModel } from '../../model';
|
|
12
|
+
import { rangeFromIndex, rangeToIndex, type StyleKey, type StyleValue } from '../../types';
|
|
12
13
|
import { useSheetContext } from '../SheetContext';
|
|
13
14
|
|
|
14
15
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
@@ -48,20 +49,55 @@ const createStyleGroup = (state: StyleState) => {
|
|
|
48
49
|
} as ToolbarMenuActionGroupProperties);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
const createStyleActions = (state: StyleState) =>
|
|
52
|
+
const createStyleActions = (model: SheetModel, state: StyleState, cursorFallbackRange?: CompleteCellRange) =>
|
|
52
53
|
Object.entries(styles).map(([styleValue, icon]) => {
|
|
53
|
-
return createMenuAction<StyleAction>(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
return createMenuAction<StyleAction>(
|
|
55
|
+
`style--${styleValue}`,
|
|
56
|
+
() => {
|
|
57
|
+
if (!cursorFallbackRange) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const index =
|
|
61
|
+
model.sheet.ranges?.findIndex(
|
|
62
|
+
(range) =>
|
|
63
|
+
range.key === 'style' && inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),
|
|
64
|
+
) ?? -1;
|
|
65
|
+
const nextRangeEntity = {
|
|
66
|
+
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
67
|
+
key: 'style',
|
|
68
|
+
value: styleValue as StyleValue,
|
|
69
|
+
};
|
|
70
|
+
if (
|
|
71
|
+
model.sheet.ranges
|
|
72
|
+
.filter(
|
|
73
|
+
({ range, key: rangeKey }) =>
|
|
74
|
+
rangeKey === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
75
|
+
)
|
|
76
|
+
.some(({ value: rangeValue }) => rangeValue === styleValue)
|
|
77
|
+
) {
|
|
78
|
+
// this value should be unset
|
|
79
|
+
if (index >= 0) {
|
|
80
|
+
model.sheet.ranges?.splice(index, 1);
|
|
81
|
+
}
|
|
82
|
+
state[nextRangeEntity.value] = false;
|
|
83
|
+
} else {
|
|
84
|
+
model.sheet.ranges?.push(nextRangeEntity);
|
|
85
|
+
state[nextRangeEntity.value] = true;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: 'style',
|
|
90
|
+
value: styleValue as StyleValue,
|
|
91
|
+
icon,
|
|
92
|
+
label: [`range value ${styleValue} label`, { ns: SHEET_PLUGIN }],
|
|
93
|
+
checked: !!state[styleValue as StyleValue],
|
|
94
|
+
},
|
|
95
|
+
);
|
|
60
96
|
});
|
|
61
97
|
|
|
62
|
-
export const createStyle = (state: StyleState) => {
|
|
98
|
+
export const createStyle = (model: SheetModel, state: StyleState, cursorFallbackRange?: CompleteCellRange) => {
|
|
63
99
|
const styleGroupAction = createStyleGroup(state);
|
|
64
|
-
const styleActions = createStyleActions(state);
|
|
100
|
+
const styleActions = createStyleActions(model, state, cursorFallbackRange);
|
|
65
101
|
return {
|
|
66
102
|
nodes: [styleGroupAction, ...styleActions],
|
|
67
103
|
edges: [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { pipe } from 'effect';
|
|
5
|
+
import { Schema, pipe } from 'effect';
|
|
6
6
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import {
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
} from '@dxos/app-framework';
|
|
16
16
|
import { debounce } from '@dxos/async';
|
|
17
17
|
import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
|
|
18
|
-
import { S } from '@dxos/echo-schema';
|
|
19
18
|
import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
|
|
20
19
|
import { ThreadAction } from '@dxos/plugin-thread/types';
|
|
21
20
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
@@ -55,7 +54,7 @@ export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null
|
|
|
55
54
|
subject: string;
|
|
56
55
|
options: { cursor: string; ref: GridContentProps['activeRefs'] };
|
|
57
56
|
} => {
|
|
58
|
-
if (!
|
|
57
|
+
if (!Schema.is(LayoutAction.ScrollIntoView.fields.input)(data)) {
|
|
59
58
|
return false;
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -7,7 +7,7 @@ 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 { FunctionType } from '@dxos/functions
|
|
10
|
+
import { FunctionType } from '@dxos/functions';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
|
|
13
13
|
import { SheetModel } from './sheet-model';
|
package/src/sanity.test.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { describe, test, expect } from 'vitest';
|
|
|
12
12
|
|
|
13
13
|
import { Client } from '@dxos/client';
|
|
14
14
|
import { live } from '@dxos/client/echo';
|
|
15
|
-
import { FunctionType } from '@dxos/functions
|
|
15
|
+
import { FunctionType } from '@dxos/functions';
|
|
16
16
|
|
|
17
17
|
// TODO(burdon): Fix test infrastructure:
|
|
18
18
|
// - Need docs? esp. needed for config. need pristine example package?
|
package/src/types/schema.ts
CHANGED
|
@@ -2,55 +2,57 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Ref, TypedObject } from '@dxos/echo-schema';
|
|
6
8
|
import { ThreadType } from '@dxos/plugin-space/types';
|
|
7
9
|
|
|
8
|
-
export const CellValue =
|
|
10
|
+
export const CellValue = Schema.Struct({
|
|
9
11
|
// TODO(burdon): How to store dates (datetime, date, time), percentages, etc.
|
|
10
12
|
// Consider import/export; natural access for other plugins. Special handling for currency (precision).
|
|
11
13
|
// TODO(burdon): Automerge (long string) or short string or number.
|
|
12
|
-
value:
|
|
14
|
+
value: Schema.Any,
|
|
13
15
|
});
|
|
14
16
|
|
|
15
|
-
export type CellValue =
|
|
17
|
+
export type CellValue = Schema.Schema.Type<typeof CellValue>;
|
|
16
18
|
|
|
17
19
|
// TODO(burdon): IMPORTANT: Reconcile with Field definition.
|
|
18
|
-
export const Range =
|
|
19
|
-
range:
|
|
20
|
-
key:
|
|
21
|
-
value:
|
|
20
|
+
export const Range = Schema.Struct({
|
|
21
|
+
range: Schema.String,
|
|
22
|
+
key: Schema.String,
|
|
23
|
+
value: Schema.String,
|
|
22
24
|
});
|
|
23
25
|
|
|
24
|
-
export type Range =
|
|
26
|
+
export type Range = Schema.Schema.Type<typeof Range>;
|
|
25
27
|
|
|
26
28
|
// TODO(burdon): Visibility, locked, frozen, etc.
|
|
27
|
-
export const RowColumnMeta =
|
|
28
|
-
size:
|
|
29
|
+
export const RowColumnMeta = Schema.Struct({
|
|
30
|
+
size: Schema.optional(Schema.Number),
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
// TODO(burdon): Reconcile col/column (across packages).
|
|
32
34
|
// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.
|
|
33
35
|
export class SheetType extends TypedObject({ typename: 'dxos.org/type/Sheet', version: '0.1.0' })({
|
|
34
|
-
name:
|
|
36
|
+
name: Schema.optional(Schema.String),
|
|
35
37
|
|
|
36
38
|
// Sparse map of cells referenced by index.
|
|
37
|
-
cells:
|
|
39
|
+
cells: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(CellValue) })),
|
|
38
40
|
|
|
39
41
|
// Ordered row indices.
|
|
40
|
-
rows:
|
|
42
|
+
rows: Schema.mutable(Schema.Array(Schema.String)),
|
|
41
43
|
|
|
42
44
|
// Ordered column indices.
|
|
43
|
-
columns:
|
|
45
|
+
columns: Schema.mutable(Schema.Array(Schema.String)),
|
|
44
46
|
|
|
45
47
|
// Row metadata referenced by index.
|
|
46
|
-
rowMeta:
|
|
48
|
+
rowMeta: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(RowColumnMeta) })),
|
|
47
49
|
|
|
48
50
|
// Column metadata referenced by index.
|
|
49
|
-
columnMeta:
|
|
51
|
+
columnMeta: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(RowColumnMeta) })),
|
|
50
52
|
|
|
51
53
|
// Cell formatting referenced by indexed range.
|
|
52
|
-
ranges:
|
|
54
|
+
ranges: Schema.mutable(Schema.Array(Range)),
|
|
53
55
|
|
|
54
56
|
// Threads associated with the sheet
|
|
55
|
-
threads:
|
|
57
|
+
threads: Schema.optional(Schema.mutable(Schema.Array(Ref(ThreadType)))),
|
|
56
58
|
}) {}
|