@dxos/plugin-sheet 0.6.10 → 0.6.11-staging.e6894a4
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-ISY6DUVE.mjs → SheetContainer-4XOKHKKZ.mjs} +40 -30
- package/dist/lib/browser/SheetContainer-4XOKHKKZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D3PUKBH6.mjs → chunk-FUAGSXA4.mjs} +1 -1
- package/dist/lib/browser/{chunk-D3PUKBH6.mjs.map → chunk-FUAGSXA4.mjs.map} +2 -2
- package/dist/lib/browser/chunk-FWGRE3EG.mjs +175 -0
- package/dist/lib/browser/chunk-FWGRE3EG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CBRBNG3R.mjs → chunk-P7SSL3EG.mjs} +115 -194
- package/dist/lib/browser/chunk-P7SSL3EG.mjs.map +7 -0
- package/dist/lib/browser/chunk-YPU3R7FA.mjs +8 -0
- package/dist/lib/browser/chunk-YPU3R7FA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +23 -68
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-ESRTE7A5.cjs → SheetContainer-IQT6TR4Z.cjs} +61 -52
- package/dist/lib/node/SheetContainer-IQT6TR4Z.cjs.map +7 -0
- package/dist/lib/node/chunk-5EPCDAZC.cjs +40 -0
- package/dist/lib/node/chunk-5EPCDAZC.cjs.map +7 -0
- package/dist/lib/node/chunk-727C6YNP.cjs +202 -0
- package/dist/lib/node/chunk-727C6YNP.cjs.map +7 -0
- package/dist/lib/node/{chunk-3R3J7IZR.cjs → chunk-DSYKOI4E.cjs} +4 -4
- package/dist/lib/node/{chunk-3R3J7IZR.cjs.map → chunk-DSYKOI4E.cjs.map} +2 -2
- package/dist/lib/node/{chunk-4EGEA3KL.cjs → chunk-SVAIIXWQ.cjs} +127 -206
- package/dist/lib/node/chunk-SVAIIXWQ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +24 -67
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +9 -9
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.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/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +38 -28
- package/src/SheetPlugin.tsx +18 -4
- package/src/components/CellEditor/extension.ts +16 -10
- package/src/components/ComputeGraph/edge-function.ts +6 -2
- package/src/components/ComputeGraph/graph-context.tsx +10 -1
- package/src/components/Sheet/Sheet.stories.tsx +3 -39
- package/src/components/Sheet/Sheet.tsx +12 -12
- package/src/components/Sheet/formatting.ts +1 -1
- package/src/components/SheetContainer.tsx +2 -1
- package/src/testing.ts +50 -0
- package/src/types.ts +2 -0
- package/dist/lib/browser/SheetContainer-ISY6DUVE.mjs.map +0 -7
- package/dist/lib/browser/chunk-CBRBNG3R.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-ESRTE7A5.cjs.map +0 -7
- package/dist/lib/node/chunk-4EGEA3KL.cjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-sheet",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.11-staging.e6894a4",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"types": "./dist/types/src/meta.d.ts"
|
|
23
23
|
},
|
|
24
|
+
"./testing": {
|
|
25
|
+
"browser": "./dist/lib/browser/testing.mjs",
|
|
26
|
+
"node": {
|
|
27
|
+
"default": "./dist/lib/node/testing.cjs"
|
|
28
|
+
},
|
|
29
|
+
"types": "./dist/types/src/testing.d.ts"
|
|
30
|
+
},
|
|
24
31
|
"./types": {
|
|
25
32
|
"browser": "./dist/lib/browser/types.mjs",
|
|
26
33
|
"node": {
|
|
@@ -35,6 +42,9 @@
|
|
|
35
42
|
"meta": [
|
|
36
43
|
"dist/types/src/meta.d.ts"
|
|
37
44
|
],
|
|
45
|
+
"testing": [
|
|
46
|
+
"dist/types/src/testing.d.ts"
|
|
47
|
+
],
|
|
38
48
|
"types": [
|
|
39
49
|
"dist/types/src/types.d.ts"
|
|
40
50
|
]
|
|
@@ -66,25 +76,25 @@
|
|
|
66
76
|
"re-resizable": "^6.9.17",
|
|
67
77
|
"react-markdown": "^8.0.5",
|
|
68
78
|
"react-resize-detector": "^11.0.1",
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/client": "0.6.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/plugin-client": "0.6.
|
|
80
|
-
"@dxos/plugin-
|
|
81
|
-
"@dxos/plugin-
|
|
82
|
-
"@dxos/plugin-
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/react-
|
|
85
|
-
"@dxos/
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/
|
|
79
|
+
"@dxos/async": "0.6.11-staging.e6894a4",
|
|
80
|
+
"@dxos/client": "0.6.11-staging.e6894a4",
|
|
81
|
+
"@dxos/context": "0.6.11-staging.e6894a4",
|
|
82
|
+
"@dxos/crypto": "0.6.11-staging.e6894a4",
|
|
83
|
+
"@dxos/app-framework": "0.6.11-staging.e6894a4",
|
|
84
|
+
"@dxos/debug": "0.6.11-staging.e6894a4",
|
|
85
|
+
"@dxos/echo-schema": "0.6.11-staging.e6894a4",
|
|
86
|
+
"@dxos/keys": "0.6.11-staging.e6894a4",
|
|
87
|
+
"@dxos/log": "0.6.11-staging.e6894a4",
|
|
88
|
+
"@dxos/invariant": "0.6.11-staging.e6894a4",
|
|
89
|
+
"@dxos/plugin-client": "0.6.11-staging.e6894a4",
|
|
90
|
+
"@dxos/plugin-graph": "0.6.11-staging.e6894a4",
|
|
91
|
+
"@dxos/plugin-script": "0.6.11-staging.e6894a4",
|
|
92
|
+
"@dxos/plugin-space": "0.6.11-staging.e6894a4",
|
|
93
|
+
"@dxos/react-client": "0.6.11-staging.e6894a4",
|
|
94
|
+
"@dxos/react-ui-attention": "0.6.11-staging.e6894a4",
|
|
95
|
+
"@dxos/plugin-stack": "0.6.11-staging.e6894a4",
|
|
96
|
+
"@dxos/util": "0.6.11-staging.e6894a4",
|
|
97
|
+
"@dxos/react-ui-editor": "0.6.11-staging.e6894a4"
|
|
88
98
|
},
|
|
89
99
|
"devDependencies": {
|
|
90
100
|
"@lezer/generator": "^1.7.1",
|
|
@@ -97,19 +107,19 @@
|
|
|
97
107
|
"react": "~18.2.0",
|
|
98
108
|
"react-dom": "~18.2.0",
|
|
99
109
|
"vite": "^5.3.4",
|
|
100
|
-
"@dxos/echo-generator": "0.6.
|
|
101
|
-
"@dxos/random": "0.6.
|
|
102
|
-
"@dxos/react-ui
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/react-ui": "0.6.
|
|
105
|
-
"@dxos/
|
|
110
|
+
"@dxos/echo-generator": "0.6.11-staging.e6894a4",
|
|
111
|
+
"@dxos/random": "0.6.11-staging.e6894a4",
|
|
112
|
+
"@dxos/react-ui": "0.6.11-staging.e6894a4",
|
|
113
|
+
"@dxos/storybook-utils": "0.6.11-staging.e6894a4",
|
|
114
|
+
"@dxos/react-ui-theme": "0.6.11-staging.e6894a4",
|
|
115
|
+
"@dxos/react-ui-types": "0.6.11-staging.e6894a4"
|
|
106
116
|
},
|
|
107
117
|
"optionalDependencies": {
|
|
108
118
|
"@phosphor-icons/react": "^2.1.5",
|
|
109
119
|
"react": "^18.0.0",
|
|
110
120
|
"react-dom": "^18.0.0",
|
|
111
|
-
"@dxos/react-ui": "0.6.
|
|
112
|
-
"@dxos/react-ui-theme": "0.6.
|
|
121
|
+
"@dxos/react-ui": "0.6.11-staging.e6894a4",
|
|
122
|
+
"@dxos/react-ui-theme": "0.6.11-staging.e6894a4"
|
|
113
123
|
},
|
|
114
124
|
"publishConfig": {
|
|
115
125
|
"access": "public"
|
package/src/SheetPlugin.tsx
CHANGED
|
@@ -19,7 +19,13 @@ import { FunctionType } from '@dxos/plugin-script/types';
|
|
|
19
19
|
import { SpaceAction } from '@dxos/plugin-space';
|
|
20
20
|
import { getSpace, isEchoObject } from '@dxos/react-client/echo';
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
createComputeGraph,
|
|
24
|
+
CustomPlugin,
|
|
25
|
+
CustomPluginTranslations,
|
|
26
|
+
SheetContainer,
|
|
27
|
+
type ComputeGraph,
|
|
28
|
+
} from './components';
|
|
23
29
|
// TODO(wittjosiah): Refactor. These are not exported from ./components due to depending on ECHO.
|
|
24
30
|
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './components/ComputeGraph/edge-function';
|
|
25
31
|
import { ComputeGraphContextProvider } from './components/ComputeGraph/graph-context';
|
|
@@ -61,6 +67,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
61
67
|
metadata: {
|
|
62
68
|
records: {
|
|
63
69
|
[SheetType.typename]: {
|
|
70
|
+
label: (object: any) => (object instanceof SheetType ? object.title : undefined),
|
|
64
71
|
placeholder: ['sheet title placeholder', { ns: SHEET_PLUGIN }],
|
|
65
72
|
icon: (props: IconProps) => <GridNine {...props} />,
|
|
66
73
|
iconSymbol: 'ph--grid-nine--regular',
|
|
@@ -120,11 +127,14 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
120
127
|
creators: [
|
|
121
128
|
{
|
|
122
129
|
id: 'create-stack-section-sheet',
|
|
123
|
-
testId: 'sheetPlugin.
|
|
130
|
+
testId: 'sheetPlugin.createSection',
|
|
124
131
|
type: ['plugin name', { ns: SHEET_PLUGIN }],
|
|
125
132
|
label: ['create sheet section label', { ns: SHEET_PLUGIN }],
|
|
126
133
|
icon: (props: any) => <GridNine {...props} />,
|
|
127
|
-
intent: {
|
|
134
|
+
intent: {
|
|
135
|
+
plugin: SHEET_PLUGIN,
|
|
136
|
+
action: SheetAction.CREATE,
|
|
137
|
+
},
|
|
128
138
|
},
|
|
129
139
|
],
|
|
130
140
|
},
|
|
@@ -155,7 +165,11 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
155
165
|
const graph =
|
|
156
166
|
graphs[space.id] ??
|
|
157
167
|
createComputeGraph(
|
|
158
|
-
[
|
|
168
|
+
[
|
|
169
|
+
{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },
|
|
170
|
+
// TODO(wittjosiah): Remove. Needed for current test sheet generated data.
|
|
171
|
+
{ plugin: CustomPlugin, translations: CustomPluginTranslations },
|
|
172
|
+
],
|
|
159
173
|
space,
|
|
160
174
|
{ remoteFunctionUrl },
|
|
161
175
|
);
|
|
@@ -32,30 +32,30 @@ const highlightStyles = HighlightStyle.define([
|
|
|
32
32
|
// Function.
|
|
33
33
|
{
|
|
34
34
|
tag: tags.name,
|
|
35
|
-
class: 'text-
|
|
35
|
+
class: 'text-accentText',
|
|
36
36
|
},
|
|
37
37
|
// Range.
|
|
38
38
|
{
|
|
39
39
|
tag: tags.tagName,
|
|
40
|
-
class: 'text-
|
|
40
|
+
class: 'text-pinkText',
|
|
41
41
|
},
|
|
42
42
|
// Values.
|
|
43
43
|
{
|
|
44
44
|
tag: tags.number,
|
|
45
|
-
class: 'text-
|
|
45
|
+
class: 'text-tealText',
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
tag: tags.bool,
|
|
49
|
-
class: 'text-
|
|
49
|
+
class: 'text-tealText',
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
tag: tags.string,
|
|
53
|
-
class: 'text-
|
|
53
|
+
class: 'text-tealText',
|
|
54
54
|
},
|
|
55
55
|
// Error.
|
|
56
56
|
{
|
|
57
57
|
tag: tags.invalid,
|
|
58
|
-
class: 'text-
|
|
58
|
+
class: 'text-unAccent',
|
|
59
59
|
},
|
|
60
60
|
]);
|
|
61
61
|
|
|
@@ -92,7 +92,7 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
|
|
|
92
92
|
|
|
93
93
|
const title = document.createElement('h2');
|
|
94
94
|
title.innerText = name;
|
|
95
|
-
title.className = 'text-lg font-mono text-
|
|
95
|
+
title.className = 'text-lg font-mono text-accentText';
|
|
96
96
|
root.appendChild(title);
|
|
97
97
|
|
|
98
98
|
if (description) {
|
|
@@ -105,7 +105,7 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
|
|
|
105
105
|
if (syntax) {
|
|
106
106
|
const detail = document.createElement('pre');
|
|
107
107
|
detail.innerText = syntax;
|
|
108
|
-
detail.className = 'whitespace-pre-wrap text-
|
|
108
|
+
detail.className = 'whitespace-pre-wrap text-greenText';
|
|
109
109
|
root.appendChild(detail);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -168,8 +168,8 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
|
|
|
168
168
|
// TODO(burdon): Factor out fragments.
|
|
169
169
|
// TODO(burdon): Size to make width same as column.
|
|
170
170
|
'!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]',
|
|
171
|
-
'[&>ul>li[aria-selected]]:!bg-
|
|
172
|
-
'border-
|
|
171
|
+
'[&>ul>li[aria-selected]]:!bg-accentSurface',
|
|
172
|
+
'border-separator',
|
|
173
173
|
),
|
|
174
174
|
}),
|
|
175
175
|
keymap.of([
|
|
@@ -242,6 +242,12 @@ export const rangeExtension = (onInit: (notifier: CellRangeNotifier) => void): E
|
|
|
242
242
|
break;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
case 'CloseParen': {
|
|
246
|
+
// Mark but keep looking.
|
|
247
|
+
activeRange = { from, to: from };
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
|
|
245
251
|
case 'RangeToken':
|
|
246
252
|
case 'CellToken':
|
|
247
253
|
activeRange = { from, to };
|
|
@@ -8,6 +8,7 @@ import { type InterpreterState } from 'hyperformula/typings/interpreter/Interpre
|
|
|
8
8
|
import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
9
9
|
|
|
10
10
|
import { Filter, getMeta } from '@dxos/client/echo';
|
|
11
|
+
import { log } from '@dxos/log';
|
|
11
12
|
import { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';
|
|
12
13
|
import { FunctionType } from '@dxos/plugin-script/types';
|
|
13
14
|
import { nonNullable } from '@dxos/util';
|
|
@@ -35,15 +36,18 @@ export class EdgeFunctionPlugin extends FunctionPluginAsync {
|
|
|
35
36
|
objects: [fn],
|
|
36
37
|
} = await space.db.query(Filter.schema(FunctionType, { binding })).run();
|
|
37
38
|
if (!fn) {
|
|
39
|
+
log.info('Function not found', { binding });
|
|
38
40
|
return new CellError(ErrorType.REF, 'Function not found');
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
if (subscribe) {
|
|
42
44
|
const unsubscribe = effect(() => {
|
|
45
|
+
log.info('function changed', { fn });
|
|
43
46
|
const _ = fn?.version;
|
|
44
47
|
|
|
45
|
-
//
|
|
46
|
-
|
|
48
|
+
// TODO(wittjosiah): `ttl` should be 0 to force a recalculation when a new version is deployed.
|
|
49
|
+
// This needs a ttl to prevent a binding change from causing the function not to be found.
|
|
50
|
+
this.runAsyncFunction(ast, state, handler(false), { ttl: EDGE_FUNCTION_TTL });
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
@@ -7,6 +7,7 @@ import React, { createContext, type PropsWithChildren, useContext, useEffect } f
|
|
|
7
7
|
import { type Space } from '@dxos/react-client/echo';
|
|
8
8
|
|
|
9
9
|
import { type FunctionContextOptions } from './async-function';
|
|
10
|
+
import { CustomPlugin, CustomPluginTranslations } from './custom';
|
|
10
11
|
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './edge-function';
|
|
11
12
|
import { createComputeGraph, type ComputeGraph } from './graph';
|
|
12
13
|
|
|
@@ -29,7 +30,15 @@ export const useComputeGraph = (space: Space, options?: Partial<FunctionContextO
|
|
|
29
30
|
const { graphs, setGraph } = useContext(ComputeGraphContext);
|
|
30
31
|
const graph =
|
|
31
32
|
graphs[space.id] ??
|
|
32
|
-
createComputeGraph(
|
|
33
|
+
createComputeGraph(
|
|
34
|
+
[
|
|
35
|
+
{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },
|
|
36
|
+
// TODO(wittjosiah): Remove. Needed for current test sheet generated data.
|
|
37
|
+
{ plugin: CustomPlugin, translations: CustomPluginTranslations },
|
|
38
|
+
],
|
|
39
|
+
space,
|
|
40
|
+
options,
|
|
41
|
+
);
|
|
33
42
|
|
|
34
43
|
useEffect(() => {
|
|
35
44
|
if (!graphs[space.id]) {
|
|
@@ -18,8 +18,8 @@ import { withTheme, withFullscreen } from '@dxos/storybook-utils';
|
|
|
18
18
|
import { Sheet } from './Sheet';
|
|
19
19
|
import { type SizeMap } from './grid';
|
|
20
20
|
import { useSheetContext } from './sheet-context';
|
|
21
|
-
import {
|
|
22
|
-
import { ValueTypeEnum,
|
|
21
|
+
import { createTestSheet, testSheetName } from '../../testing';
|
|
22
|
+
import { ValueTypeEnum, SheetType } from '../../types';
|
|
23
23
|
import { type ComputeGraph, createComputeGraph } from '../ComputeGraph';
|
|
24
24
|
// TODO(wittjosiah): Refactor. This is not exported from ./components due to depending on ECHO.
|
|
25
25
|
import { ComputeGraphContext, ComputeGraphContextProvider, useComputeGraph } from '../ComputeGraph/graph-context';
|
|
@@ -99,8 +99,6 @@ const SheetWithToolbar = ({ debug, space }: { debug?: boolean; space: Space }) =
|
|
|
99
99
|
);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const testSheetName = 'test';
|
|
103
|
-
|
|
104
102
|
const withGraphDecorator: Decorator = (Story) => {
|
|
105
103
|
const [graphs, setGraphs] = useState<Record<string, ComputeGraph>>({});
|
|
106
104
|
|
|
@@ -263,34 +261,6 @@ const Cell = ({ className, label }: { className?: string; label: string }) => (
|
|
|
263
261
|
<div className={mx('flex items-center justify-center border', className)}>{label}</div>
|
|
264
262
|
);
|
|
265
263
|
|
|
266
|
-
const createCells = (): Record<string, CellValue> => ({
|
|
267
|
-
B1: { value: 'Qty' },
|
|
268
|
-
B3: { value: 1 },
|
|
269
|
-
B4: { value: 2 },
|
|
270
|
-
B5: { value: 3 },
|
|
271
|
-
B7: { value: 'Total' },
|
|
272
|
-
|
|
273
|
-
C1: { value: 'Price' },
|
|
274
|
-
C3: { value: 2_000 },
|
|
275
|
-
C4: { value: 2_500 },
|
|
276
|
-
C5: { value: 3_000 },
|
|
277
|
-
C7: { value: '=SUMPRODUCT(B2:B6, C2:C6)' },
|
|
278
|
-
// C8: { value: '=C7*CRYPTO(D7)' },
|
|
279
|
-
C8: { value: '=C7*TEST()' },
|
|
280
|
-
|
|
281
|
-
D7: { value: 'USD' },
|
|
282
|
-
D8: { value: 'BTC' },
|
|
283
|
-
|
|
284
|
-
E3: { value: '=TODAY()' },
|
|
285
|
-
E4: { value: '=NOW()' },
|
|
286
|
-
|
|
287
|
-
F1: { value: `=${testSheetName}!A1` }, // Ref test sheet.
|
|
288
|
-
F3: { value: true },
|
|
289
|
-
F4: { value: false },
|
|
290
|
-
F5: { value: '8%' },
|
|
291
|
-
F6: { value: '$10000' },
|
|
292
|
-
});
|
|
293
|
-
|
|
294
264
|
const useTestSheet = () => {
|
|
295
265
|
const { graphs, setGraph } = useContext(ComputeGraphContext);
|
|
296
266
|
const [sheet, setSheet] = useState<EchoReactiveObject<SheetType>>();
|
|
@@ -307,13 +277,7 @@ const useTestSheet = () => {
|
|
|
307
277
|
setGraph(space.id, graph);
|
|
308
278
|
}
|
|
309
279
|
|
|
310
|
-
const sheet =
|
|
311
|
-
const model = new SheetModel(graph, sheet);
|
|
312
|
-
await model.initialize();
|
|
313
|
-
model.setValues(createCells());
|
|
314
|
-
model.sheet.columnMeta[model.sheet.columns[0]] = { size: 100 };
|
|
315
|
-
await model.destroy();
|
|
316
|
-
|
|
280
|
+
const sheet = await createTestSheet({ graph });
|
|
317
281
|
space.db.add(sheet);
|
|
318
282
|
setSheet(sheet);
|
|
319
283
|
});
|
|
@@ -114,11 +114,11 @@ import {
|
|
|
114
114
|
|
|
115
115
|
// TODO(burdon): Factor out fragments.
|
|
116
116
|
const fragments = {
|
|
117
|
-
axis: 'bg-
|
|
118
|
-
axisSelected: 'bg-
|
|
119
|
-
cell: '
|
|
120
|
-
cellSelected: 'bg-
|
|
121
|
-
border: 'border-
|
|
117
|
+
axis: 'bg-axisSurface text-axisText text-xs select-none',
|
|
118
|
+
axisSelected: 'bg-attention text-baseText',
|
|
119
|
+
cell: 'bg-gridCell',
|
|
120
|
+
cellSelected: 'bg-gridCellSelected text-baseText border !border-accentSurface',
|
|
121
|
+
border: 'border-gridLine',
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
//
|
|
@@ -345,7 +345,7 @@ const GridCorner = (props: { className?: string } & Pick<DOMAttributes<HTMLDivEl
|
|
|
345
345
|
|
|
346
346
|
const MovingOverlay = ({ label }: { label: string }) => {
|
|
347
347
|
return (
|
|
348
|
-
<div className='flex w-full h-full justify-center items-center text-sm p-1 bg-
|
|
348
|
+
<div className='flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer'>
|
|
349
349
|
{label}
|
|
350
350
|
</div>
|
|
351
351
|
);
|
|
@@ -532,11 +532,11 @@ const GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onRe
|
|
|
532
532
|
|
|
533
533
|
{/* Drop indicator. */}
|
|
534
534
|
{over?.id === idx && !isDragging && (
|
|
535
|
-
<div className='z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-
|
|
535
|
+
<div className='z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface' />
|
|
536
536
|
)}
|
|
537
537
|
|
|
538
538
|
{/* Resize indicator. */}
|
|
539
|
-
{resizing && <div className='z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-
|
|
539
|
+
{resizing && <div className='z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface' />}
|
|
540
540
|
</div>
|
|
541
541
|
</Resizable>
|
|
542
542
|
);
|
|
@@ -696,11 +696,11 @@ const GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, o
|
|
|
696
696
|
|
|
697
697
|
{/* Drop indicator. */}
|
|
698
698
|
{over?.id === idx && !isDragging && (
|
|
699
|
-
<div className='z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-
|
|
699
|
+
<div className='z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface' />
|
|
700
700
|
)}
|
|
701
701
|
|
|
702
702
|
{/* Resize indicator. */}
|
|
703
|
-
{resizing && <div className='z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-
|
|
703
|
+
{resizing && <div className='z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface' />}
|
|
704
704
|
</div>
|
|
705
705
|
</Resizable>
|
|
706
706
|
);
|
|
@@ -991,7 +991,7 @@ const SelectionOverlay = ({ root }: { root: HTMLDivElement }) => {
|
|
|
991
991
|
<div
|
|
992
992
|
role='none'
|
|
993
993
|
style={bounds}
|
|
994
|
-
className='z-10 absolute pointer-events-none bg-
|
|
994
|
+
className='z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay'
|
|
995
995
|
/>
|
|
996
996
|
);
|
|
997
997
|
};
|
|
@@ -1099,7 +1099,7 @@ const SheetStatusBar = () => {
|
|
|
1099
1099
|
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
1100
1100
|
</div>
|
|
1101
1101
|
<div className='flex gap-2 items-center'>
|
|
1102
|
-
<FunctionIcon className={mx('text-
|
|
1102
|
+
<FunctionIcon className={mx('text-greenText', isFormula ? 'visible' : 'invisible')} />
|
|
1103
1103
|
<span className='font-mono'>{value}</span>
|
|
1104
1104
|
</div>
|
|
1105
1105
|
</div>
|
|
@@ -51,7 +51,7 @@ export class FormattingModel {
|
|
|
51
51
|
case ValueTypeEnum.Boolean: {
|
|
52
52
|
return {
|
|
53
53
|
value: (value as boolean).toLocaleString().toUpperCase(),
|
|
54
|
-
classNames: [...classNames, value ? '!text-
|
|
54
|
+
classNames: [...classNames, value ? '!text-greenText' : '!text-orangeText'],
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -14,6 +14,7 @@ const SheetContainer = ({
|
|
|
14
14
|
space,
|
|
15
15
|
role,
|
|
16
16
|
coordinate = { part: 'main', entryId: '' },
|
|
17
|
+
remoteFunctionUrl,
|
|
17
18
|
}: SheetRootProps & { role?: string; coordinate?: LayoutCoordinate }) => {
|
|
18
19
|
return (
|
|
19
20
|
<div
|
|
@@ -25,7 +26,7 @@ const SheetContainer = ({
|
|
|
25
26
|
coordinate.part !== 'solo' && 'border-is border-separator',
|
|
26
27
|
)}
|
|
27
28
|
>
|
|
28
|
-
<Sheet.Root sheet={sheet} space={space}>
|
|
29
|
+
<Sheet.Root sheet={sheet} space={space} remoteFunctionUrl={remoteFunctionUrl}>
|
|
29
30
|
<Sheet.Main />
|
|
30
31
|
</Sheet.Root>
|
|
31
32
|
</div>
|
package/src/testing.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComputeGraph, createComputeGraph } from './components';
|
|
6
|
+
import { SheetModel } from './model';
|
|
7
|
+
import { createSheet, type CellValue } from './types';
|
|
8
|
+
|
|
9
|
+
export const testSheetName = 'test';
|
|
10
|
+
|
|
11
|
+
export const createCells = (): Record<string, CellValue> => ({
|
|
12
|
+
B1: { value: 'Qty' },
|
|
13
|
+
B3: { value: 1 },
|
|
14
|
+
B4: { value: 2 },
|
|
15
|
+
B5: { value: 3 },
|
|
16
|
+
B7: { value: 'Total' },
|
|
17
|
+
|
|
18
|
+
C1: { value: 'Price' },
|
|
19
|
+
C3: { value: 2_000 },
|
|
20
|
+
C4: { value: 2_500 },
|
|
21
|
+
C5: { value: 3_000 },
|
|
22
|
+
C7: { value: '=SUMPRODUCT(B2:B6, C2:C6)' },
|
|
23
|
+
// C8: { value: '=C7*CRYPTO(D7)' },
|
|
24
|
+
C8: { value: '=C7*TEST()' },
|
|
25
|
+
|
|
26
|
+
D7: { value: 'USD' },
|
|
27
|
+
D8: { value: 'BTC' },
|
|
28
|
+
|
|
29
|
+
E3: { value: '=TODAY()' },
|
|
30
|
+
E4: { value: '=NOW()' },
|
|
31
|
+
|
|
32
|
+
F1: { value: `=${testSheetName}!A1` }, // Ref test sheet.
|
|
33
|
+
F3: { value: true },
|
|
34
|
+
F4: { value: false },
|
|
35
|
+
F5: { value: '8%' },
|
|
36
|
+
F6: { value: '$10000' },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const createTestSheet = async ({
|
|
40
|
+
name,
|
|
41
|
+
graph = createComputeGraph(),
|
|
42
|
+
}: { name?: string; graph?: ComputeGraph } = {}) => {
|
|
43
|
+
const sheet = createSheet(name);
|
|
44
|
+
const model = new SheetModel(graph, sheet);
|
|
45
|
+
await model.initialize();
|
|
46
|
+
model.setValues(createCells());
|
|
47
|
+
model.sheet.columnMeta[model.sheet.columns[0]] = { size: 100 };
|
|
48
|
+
await model.destroy();
|
|
49
|
+
return sheet;
|
|
50
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -83,6 +83,8 @@ export const RowColumnMeta = S.Struct({
|
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.
|
|
86
|
+
// TODO(wittjosiah): Migrate typename to remove `Type` suffix.
|
|
87
|
+
// TODO(wittjosiah): Rename title to name to align with other schemas.
|
|
86
88
|
export class SheetType extends TypedObject({ typename: 'dxos.org/type/SheetType', version: '0.1.0' })({
|
|
87
89
|
title: S.optional(S.String),
|
|
88
90
|
|