@dxos/plugin-sheet 0.6.12-staging.e11e696 → 0.6.12
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/{chunk-CHQAW4F4.mjs → SheetContainer-U4H5D34A.mjs} +249 -1182
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-5WPZCXNS.mjs → browser/chunk-D5AGLXJP.mjs} +678 -411
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WZMOZKQZ.mjs → chunk-FUAGSXA4.mjs} +16 -9
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QILRZNE5.mjs → chunk-JRL5LGCE.mjs} +5 -2
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -96
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +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 +6 -4
- package/dist/lib/node/{chunk-5FTFZL5W.cjs → SheetContainer-AXQV3ZT5.cjs} +287 -1212
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-5KKJ4NPP.cjs} +678 -418
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-BJ6ZD7MN.cjs} +18 -5
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-AOP42UAA.cjs → chunk-DSYKOI4E.cjs} +21 -13
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +66 -106
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- 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 +12 -10
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +3 -23
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/{graph/functions → components/ComputeGraph}/async-function.d.ts +5 -14
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts +21 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +20 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +6 -5
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +7 -8
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +3 -2
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +3 -19
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +13 -18
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +4 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/functions/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +65 -10
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -86
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +47 -55
- package/src/SheetPlugin.tsx +73 -50
- package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
- package/src/components/CellEditor/CellEditor.tsx +9 -59
- package/src/components/CellEditor/extension.test.ts +6 -4
- package/src/components/CellEditor/extension.ts +6 -5
- package/src/{graph/functions → components/ComputeGraph}/async-function.ts +15 -25
- package/src/{graph/testing/test-plugin.ts → components/ComputeGraph/custom.ts} +14 -44
- package/src/{graph/functions → components/ComputeGraph}/edge-function.ts +14 -16
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +88 -52
- package/src/components/Sheet/Sheet.tsx +32 -87
- package/src/{model/formatting-model.ts → components/Sheet/formatting.ts} +13 -20
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +80 -18
- package/src/components/SheetContainer.tsx +16 -68
- package/src/components/Toolbar/Toolbar.tsx +12 -53
- package/src/components/index.ts +0 -1
- package/src/meta.tsx +5 -1
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -24
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +6 -31
- package/dist/lib/browser/SheetContainer-LG77O4RM.mjs +0 -262
- package/dist/lib/browser/SheetContainer-LG77O4RM.mjs.map +0 -7
- package/dist/lib/browser/chunk-CHQAW4F4.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +0 -2966
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
- package/dist/lib/browser/chunk-WZMOZKQZ.mjs.map +0 -7
- package/dist/lib/browser/graph-M4IQ76QX.mjs +0 -33
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-OZ7DHH4L.cjs +0 -280
- package/dist/lib/node/SheetContainer-OZ7DHH4L.cjs.map +0 -7
- package/dist/lib/node/chunk-5FTFZL5W.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-AOP42UAA.cjs.map +0 -7
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs +0 -55
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-4XS2G25Z.mjs +0 -263
- package/dist/lib/node-esm/SheetContainer-4XS2G25Z.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +0 -17
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KK3XL37M.mjs +0 -2706
- package/dist/lib/node-esm/chunk-KK3XL37M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs +0 -76
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs.map +0 -7
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +0 -34
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -285
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -21
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -10
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts +0 -7
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +0 -24
- package/dist/types/src/components/Sheet/decorations.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/threads.d.ts +0 -2
- package/dist/types/src/components/Sheet/threads.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts +0 -3
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -6
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -2
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -64
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -26
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts +0 -4
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -5
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts +0 -3
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useFormattingModel.d.ts +0 -3
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/formatting-model.d.ts +0 -16
- package/dist/types/src/model/formatting-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.test.d.ts +0 -2
- package/dist/types/src/model/sheet-model.test.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -8
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -36
- package/src/components/GridSheet/GridSheet.tsx +0 -153
- package/src/components/GridSheet/util.ts +0 -108
- package/src/components/Sheet/decorations.ts +0 -62
- package/src/components/Sheet/threads.tsx +0 -205
- package/src/defs/index.ts +0 -6
- package/src/defs/util.ts +0 -151
- package/src/extensions/compute.stories.tsx +0 -151
- package/src/extensions/compute.ts +0 -147
- package/src/extensions/index.ts +0 -5
- package/src/graph/compute-graph-registry.ts +0 -90
- package/src/graph/compute-graph.stories.tsx +0 -93
- package/src/graph/compute-graph.test.ts +0 -87
- package/src/graph/compute-graph.ts +0 -242
- package/src/graph/compute-node.ts +0 -63
- package/src/graph/functions/index.ts +0 -7
- package/src/graph/hyperformula.test.ts +0 -14
- package/src/graph/index.ts +0 -8
- package/src/graph/testing/index.ts +0 -6
- package/src/graph/testing/test-builder.ts +0 -54
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/hooks/useFormattingModel.ts +0 -11
- package/src/hooks/useSheetModel.ts +0 -40
- package/src/model/sheet-model.test.ts +0 -59
- package/src/model/sheet-model.ts +0 -416
- package/src/sanity.test.ts +0 -40
- package/src/testing/index.ts +0 -5
- package/src/testing/testing.tsx +0 -68
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/functions/function-defs.ts → model/functions.ts} +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { Trigger } from '@dxos/async';
|
|
8
|
-
import { FunctionType } from '@dxos/plugin-script/types';
|
|
9
|
-
|
|
10
|
-
import { SheetModel } from './sheet-model';
|
|
11
|
-
import { createSheet, addressFromA1Notation } from '../defs';
|
|
12
|
-
import { TestBuilder, testFunctionPlugins } from '../graph/testing';
|
|
13
|
-
import { type CellScalarValue } from '../types';
|
|
14
|
-
|
|
15
|
-
// TODO(burdon): GPT("prompt", inputs); e.g., with large text cells.
|
|
16
|
-
|
|
17
|
-
describe('SheetModel', () => {
|
|
18
|
-
let testBuilder: TestBuilder;
|
|
19
|
-
beforeEach(async () => {
|
|
20
|
-
testBuilder = new TestBuilder({ types: [FunctionType], plugins: testFunctionPlugins });
|
|
21
|
-
await testBuilder.open();
|
|
22
|
-
});
|
|
23
|
-
afterEach(async () => {
|
|
24
|
-
await testBuilder.close();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('async function', async () => {
|
|
28
|
-
const space = await testBuilder.client.spaces.create();
|
|
29
|
-
const graph = testBuilder.registry.createGraph(space);
|
|
30
|
-
await graph.open();
|
|
31
|
-
|
|
32
|
-
// TODO(burdon): Create via factory.
|
|
33
|
-
const sheet = createSheet({ rows: 5, columns: 5 });
|
|
34
|
-
const model = new SheetModel(graph, sheet);
|
|
35
|
-
await model.open();
|
|
36
|
-
testBuilder.ctx.onDispose(() => model.close());
|
|
37
|
-
|
|
38
|
-
// Trigger waits for function invocation.
|
|
39
|
-
const trigger = new Trigger<CellScalarValue>();
|
|
40
|
-
model.setValue(addressFromA1Notation('A1'), '=TEST(100)');
|
|
41
|
-
model.update.once((update) => {
|
|
42
|
-
const { type } = update;
|
|
43
|
-
if (type === 'valuesUpdated') {
|
|
44
|
-
const value = model.getValue(addressFromA1Notation('A1'));
|
|
45
|
-
trigger.wake(value);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Initial value will be null.
|
|
50
|
-
const v1 = model.getValue(addressFromA1Notation('A1'));
|
|
51
|
-
expect(v1).to.be.null;
|
|
52
|
-
expect(graph.context.info.invocations.TEST).not.to.exist;
|
|
53
|
-
|
|
54
|
-
// Wait until async update triggered.
|
|
55
|
-
const v2 = await trigger.wait();
|
|
56
|
-
expect(v2).to.eq(100);
|
|
57
|
-
expect(graph.context.info.invocations.TEST).to.eq(1);
|
|
58
|
-
});
|
|
59
|
-
});
|
package/src/model/sheet-model.ts
DELETED
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type SimpleCellRange } from 'hyperformula/typings/AbsoluteCellRange';
|
|
6
|
-
import { type SimpleCellAddress } from 'hyperformula/typings/Cell';
|
|
7
|
-
import { type SimpleDate, type SimpleDateTime } from 'hyperformula/typings/DateTimeHelper';
|
|
8
|
-
|
|
9
|
-
import { Event } from '@dxos/async';
|
|
10
|
-
import { Resource } from '@dxos/context';
|
|
11
|
-
import { getTypename } from '@dxos/echo-schema';
|
|
12
|
-
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import { PublicKey } from '@dxos/keys';
|
|
14
|
-
import { log } from '@dxos/log';
|
|
15
|
-
|
|
16
|
-
import { DetailedCellError, ExportedCellChange } from '#hyperformula';
|
|
17
|
-
import {
|
|
18
|
-
addressFromA1Notation,
|
|
19
|
-
addressToA1Notation,
|
|
20
|
-
type CellAddress,
|
|
21
|
-
type CellRange,
|
|
22
|
-
MAX_COLUMNS,
|
|
23
|
-
MAX_ROWS,
|
|
24
|
-
} from '../defs';
|
|
25
|
-
import { addressFromIndex, addressToIndex, initialize, insertIndices, ReadonlyException } from '../defs';
|
|
26
|
-
import { type ComputeNode, type ComputeGraph, createSheetName, type ComputeNodeEvent } from '../graph';
|
|
27
|
-
import { type CellScalarValue, type CellValue, type SheetType, ValueTypeEnum } from '../types';
|
|
28
|
-
|
|
29
|
-
const typeMap: Record<string, ValueTypeEnum> = {
|
|
30
|
-
BOOLEAN: ValueTypeEnum.Boolean,
|
|
31
|
-
NUMBER_RAW: ValueTypeEnum.Number,
|
|
32
|
-
NUMBER_PERCENT: ValueTypeEnum.Percent,
|
|
33
|
-
NUMBER_CURRENCY: ValueTypeEnum.Currency,
|
|
34
|
-
NUMBER_DATETIME: ValueTypeEnum.DateTime,
|
|
35
|
-
NUMBER_DATE: ValueTypeEnum.Date,
|
|
36
|
-
NUMBER_TIME: ValueTypeEnum.Time,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getTopLeft = (range: CellRange): CellAddress => {
|
|
40
|
-
const to = range.to ?? range.from;
|
|
41
|
-
return { row: Math.min(range.from.row, to.row), col: Math.min(range.from.col, to.col) };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const toSimpleCellAddress = (sheet: number, cell: CellAddress): SimpleCellAddress => ({
|
|
45
|
-
sheet,
|
|
46
|
-
row: cell.row,
|
|
47
|
-
col: cell.col,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const toModelRange = (sheet: number, range: CellRange): SimpleCellRange => ({
|
|
51
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
52
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export type SheetModelOptions = {
|
|
56
|
-
readonly?: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Spreadsheet data model.
|
|
61
|
-
*
|
|
62
|
-
* [ComputeGraphContext] > [SheetContext]:[SheetModel] > [Sheet.Root]
|
|
63
|
-
*/
|
|
64
|
-
// TODO(burdon): Factor out commonality with ComputeNode. Factor out HF.
|
|
65
|
-
export class SheetModel extends Resource {
|
|
66
|
-
public readonly id = `model-${PublicKey.random().truncate()}`;
|
|
67
|
-
|
|
68
|
-
// Wraps compute node.
|
|
69
|
-
public readonly update = new Event<ComputeNodeEvent>();
|
|
70
|
-
|
|
71
|
-
private _node?: ComputeNode;
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
74
|
-
private readonly _graph: ComputeGraph,
|
|
75
|
-
private readonly _sheet: SheetType,
|
|
76
|
-
private readonly _options: SheetModelOptions = {},
|
|
77
|
-
) {
|
|
78
|
-
super();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get graph() {
|
|
82
|
-
return this._graph;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
get sheet() {
|
|
86
|
-
return this._sheet;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get readonly() {
|
|
90
|
-
return this._options.readonly;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get bounds() {
|
|
94
|
-
return {
|
|
95
|
-
rows: this._sheet.rows.length,
|
|
96
|
-
columns: this._sheet.columns.length,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Initialize sheet and engine.
|
|
102
|
-
*/
|
|
103
|
-
protected override async _open() {
|
|
104
|
-
log('initialize', { id: this.id });
|
|
105
|
-
initialize(this._sheet);
|
|
106
|
-
|
|
107
|
-
// TODO(burdon): SheetModel should extend ComputeNode and be constructed via the graph.
|
|
108
|
-
this._node = this._graph.getOrCreateNode(createSheetName({ type: getTypename(this._sheet)!, id: this._sheet.id }));
|
|
109
|
-
await this._node.open();
|
|
110
|
-
|
|
111
|
-
// Listen for model updates (e.g., async calculations).
|
|
112
|
-
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
113
|
-
this._ctx.onDispose(unsubscribe);
|
|
114
|
-
|
|
115
|
-
this.reset();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Update engine.
|
|
120
|
-
* NOTE: This resets the undo history.
|
|
121
|
-
* @deprecated
|
|
122
|
-
*/
|
|
123
|
-
reset() {
|
|
124
|
-
invariant(this._node);
|
|
125
|
-
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
126
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
127
|
-
invariant(this._node);
|
|
128
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
129
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
130
|
-
value = this._graph.mapFormulaToNative(
|
|
131
|
-
this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)),
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row, col }, value);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Recalculate formulas.
|
|
141
|
-
* NOTE: This resets the undo history.
|
|
142
|
-
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
143
|
-
* @deprecated
|
|
144
|
-
*/
|
|
145
|
-
// TODO(burdon): Remove.
|
|
146
|
-
recalculate() {
|
|
147
|
-
this._node?.graph.hf.rebuildAndRecalculate();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
insertRows(i: number, n = 1) {
|
|
151
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
152
|
-
this.reset();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
insertColumns(i: number, n = 1) {
|
|
156
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
157
|
-
this.reset();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
//
|
|
161
|
-
// Undoable actions.
|
|
162
|
-
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Clear range of values.
|
|
167
|
-
*/
|
|
168
|
-
clear(range: CellRange) {
|
|
169
|
-
invariant(this._node);
|
|
170
|
-
const topLeft = getTopLeft(range);
|
|
171
|
-
const values = this._iterRange(range, () => null);
|
|
172
|
-
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
173
|
-
this._iterRange(range, (cell) => {
|
|
174
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
175
|
-
delete this._sheet.cells[idx];
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
cut(range: CellRange) {
|
|
180
|
-
invariant(this._node);
|
|
181
|
-
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
182
|
-
this._iterRange(range, (cell) => {
|
|
183
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
184
|
-
delete this._sheet.cells[idx];
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
copy(range: CellRange) {
|
|
189
|
-
invariant(this._node);
|
|
190
|
-
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
paste(cell: CellAddress) {
|
|
194
|
-
invariant(this._node);
|
|
195
|
-
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
196
|
-
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
197
|
-
for (const change of changes) {
|
|
198
|
-
if (change instanceof ExportedCellChange) {
|
|
199
|
-
const { address, newValue } = change;
|
|
200
|
-
const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
|
|
201
|
-
this._sheet.cells[idx] = { value: newValue };
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// TODO(burdon): Display undo/redo state.
|
|
208
|
-
undo() {
|
|
209
|
-
invariant(this._node);
|
|
210
|
-
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
211
|
-
this._node.graph.hf.undo();
|
|
212
|
-
// this.update.emit();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
redo() {
|
|
217
|
-
invariant(this._node);
|
|
218
|
-
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
219
|
-
this._node.graph.hf.redo();
|
|
220
|
-
// this.update.emit();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Get value from sheet.
|
|
226
|
-
*/
|
|
227
|
-
getCellValue(cell: CellAddress): CellScalarValue {
|
|
228
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
229
|
-
return this._sheet.cells[idx]?.value ?? null;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Get value as a string for editing.
|
|
234
|
-
*/
|
|
235
|
-
getCellText(cell: CellAddress): string | undefined {
|
|
236
|
-
const value = this.getCellValue(cell);
|
|
237
|
-
if (value == null) {
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
242
|
-
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
243
|
-
} else {
|
|
244
|
-
return String(value);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Get array of raw values from sheet.
|
|
250
|
-
*/
|
|
251
|
-
getCellValues(range: CellRange): CellScalarValue[][] {
|
|
252
|
-
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Gets the regular or computed value from the engine.
|
|
257
|
-
*/
|
|
258
|
-
getValue(cell: CellAddress): CellScalarValue {
|
|
259
|
-
// Applies rounding and post-processing.
|
|
260
|
-
invariant(this._node);
|
|
261
|
-
const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
262
|
-
if (value instanceof DetailedCellError) {
|
|
263
|
-
return value.toString();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return value;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Get value type.
|
|
271
|
-
*/
|
|
272
|
-
getValueType(cell: CellAddress): ValueTypeEnum {
|
|
273
|
-
invariant(this._node);
|
|
274
|
-
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
275
|
-
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
276
|
-
return typeMap[type];
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Sets the value, updating the sheet and engine.
|
|
281
|
-
*/
|
|
282
|
-
setValue(cell: CellAddress, value: CellScalarValue) {
|
|
283
|
-
invariant(this._node);
|
|
284
|
-
if (this._options.readonly) {
|
|
285
|
-
throw new ReadonlyException();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Reallocate if > current bounds.
|
|
289
|
-
let refresh = false;
|
|
290
|
-
if (cell.row >= this._sheet.rows.length) {
|
|
291
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
292
|
-
refresh = true;
|
|
293
|
-
}
|
|
294
|
-
if (cell.col >= this._sheet.columns.length) {
|
|
295
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
296
|
-
refresh = true;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (refresh) {
|
|
300
|
-
// TODO(burdon): Remove.
|
|
301
|
-
this.reset();
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Insert into engine.
|
|
305
|
-
this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row: cell.row, col: cell.col }, [
|
|
306
|
-
[typeof value === 'string' && value.charAt(0) === '=' ? this._graph.mapFormulaToNative(value) : value],
|
|
307
|
-
]);
|
|
308
|
-
|
|
309
|
-
// Insert into sheet.
|
|
310
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
311
|
-
if (value === undefined || value === null) {
|
|
312
|
-
delete this._sheet.cells[idx];
|
|
313
|
-
} else {
|
|
314
|
-
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
315
|
-
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
this._sheet.cells[idx] = { value };
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Sets values from a simple map.
|
|
324
|
-
*/
|
|
325
|
-
setValues(values: Record<string, CellValue>) {
|
|
326
|
-
Object.entries(values).forEach(([key, { value }]) => {
|
|
327
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Iterate range.
|
|
333
|
-
*/
|
|
334
|
-
private _iterRange(range: CellRange, cb: (cell: CellAddress) => CellScalarValue | void): CellScalarValue[][] {
|
|
335
|
-
const to = range.to ?? range.from;
|
|
336
|
-
const rowRange = [Math.min(range.from.row, to.row), Math.max(range.from.row, to.row)];
|
|
337
|
-
const columnRange = [Math.min(range.from.col, to.col), Math.max(range.from.col, to.col)];
|
|
338
|
-
const rows: CellScalarValue[][] = [];
|
|
339
|
-
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
340
|
-
const rowCells: CellScalarValue[] = [];
|
|
341
|
-
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
342
|
-
const value = cb({ row, col: column });
|
|
343
|
-
if (value !== undefined) {
|
|
344
|
-
rowCells.push(value);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
rows.push(rowCells);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return rows;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// TODO(burdon): Delete index.
|
|
355
|
-
private _deleteIndices(indices: string[], i: number, n: number) {
|
|
356
|
-
throw new Error('Not implemented');
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
360
|
-
private _moveIndices(indices: string[], i: number, j: number, n: number) {
|
|
361
|
-
throw new Error('Not implemented');
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
//
|
|
365
|
-
// Indices.
|
|
366
|
-
//
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Map from A1 notation to indices.
|
|
370
|
-
*/
|
|
371
|
-
mapFormulaRefsToIndices(formula: string): string {
|
|
372
|
-
invariant(formula.charAt(0) === '=');
|
|
373
|
-
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
374
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Map from indices to A1 notation.
|
|
380
|
-
*/
|
|
381
|
-
mapFormulaIndicesToRefs(formula: string): string {
|
|
382
|
-
invariant(formula.charAt(0) === '=');
|
|
383
|
-
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
384
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
//
|
|
389
|
-
// Values
|
|
390
|
-
//
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
394
|
-
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
395
|
-
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
396
|
-
*/
|
|
397
|
-
toLocalDate(num: number): Date {
|
|
398
|
-
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
399
|
-
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
toDateTime(num: number): SimpleDateTime {
|
|
403
|
-
invariant(this._node);
|
|
404
|
-
return this._node.graph.hf.numberToDateTime(num) as SimpleDateTime;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
toDate(num: number): SimpleDate {
|
|
408
|
-
invariant(this._node);
|
|
409
|
-
return this._node.graph.hf.numberToDate(num) as SimpleDate;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
toTime(num: number): SimpleDate {
|
|
413
|
-
invariant(this._node);
|
|
414
|
-
return this._node.graph.hf.numberToTime(num) as SimpleDate;
|
|
415
|
-
}
|
|
416
|
-
}
|
package/src/sanity.test.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, test, expect } from 'vitest';
|
|
6
|
-
|
|
7
|
-
// Part 2.
|
|
8
|
-
// TODO(burdon): Cannot test outside of browser.
|
|
9
|
-
// - Cannot test Hyperformula
|
|
10
|
-
// - throws "Cannot convert undefined or null to object" in vitest (no browser).
|
|
11
|
-
// - throws "process.nextTick is not a function" (if browser)
|
|
12
|
-
|
|
13
|
-
import { Client } from '@dxos/client';
|
|
14
|
-
import { create } from '@dxos/client/echo';
|
|
15
|
-
import { FunctionType } from '@dxos/plugin-script/types';
|
|
16
|
-
|
|
17
|
-
// TODO(burdon): Fix test infrastructure:
|
|
18
|
-
// - Need docs? esp. needed for config. need pristine example package?
|
|
19
|
-
// - NOTE for non browser tests, import types from x-plugin/types (otherwise will bring in react deps).
|
|
20
|
-
// - Can't add flags to our tools?
|
|
21
|
-
// - .only / .skip ignored (have to comment out tests)
|
|
22
|
-
|
|
23
|
-
describe('test', () => {
|
|
24
|
-
test('test', async () => {
|
|
25
|
-
const client = new Client();
|
|
26
|
-
client.addTypes([FunctionType]);
|
|
27
|
-
await client.initialize();
|
|
28
|
-
await client.halo.createIdentity();
|
|
29
|
-
|
|
30
|
-
// Part 1.
|
|
31
|
-
// Create script.
|
|
32
|
-
// VITEST_ENV=chromium p test
|
|
33
|
-
// TODO(burdon): Test after initialize.
|
|
34
|
-
// - ERROR "process.nextTick is not a function"
|
|
35
|
-
// - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
|
|
36
|
-
const space = await client.spaces.create();
|
|
37
|
-
const fn = space.db.add(create(FunctionType, { version: 1, binding: 'HELLO' }));
|
|
38
|
-
expect(fn).to.exist;
|
|
39
|
-
});
|
|
40
|
-
});
|
package/src/testing/index.ts
DELETED
package/src/testing/testing.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Decorator } from '@storybook/react';
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
9
|
-
import { useAsyncState } from '@dxos/react-hooks';
|
|
10
|
-
|
|
11
|
-
import { ComputeGraphContextProvider } from '../components';
|
|
12
|
-
import { createSheet } from '../defs';
|
|
13
|
-
import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '../graph';
|
|
14
|
-
import { type CellValue, type CreateSheetOptions } from '../types';
|
|
15
|
-
|
|
16
|
-
const testSheetName = 'test';
|
|
17
|
-
|
|
18
|
-
export const createTestCells = (): Record<string, CellValue> => ({
|
|
19
|
-
B1: { value: 'Qty2' },
|
|
20
|
-
B3: { value: 1 },
|
|
21
|
-
B4: { value: 2 },
|
|
22
|
-
B5: { value: 3 },
|
|
23
|
-
B7: { value: 'Total' },
|
|
24
|
-
|
|
25
|
-
C1: { value: 'Price' },
|
|
26
|
-
C3: { value: 2_000 },
|
|
27
|
-
C4: { value: 2_500 },
|
|
28
|
-
C5: { value: 3_000 },
|
|
29
|
-
C7: { value: '=SUMPRODUCT(B2:B6, C2:C6)' },
|
|
30
|
-
// C8: { value: '=C7*CRYPTO(D7)' },
|
|
31
|
-
C8: { value: '=C7*TEST()' },
|
|
32
|
-
|
|
33
|
-
D7: { value: 'USD' },
|
|
34
|
-
D8: { value: 'BTC' },
|
|
35
|
-
|
|
36
|
-
E3: { value: '=TODAY()' },
|
|
37
|
-
E4: { value: '=NOW()' },
|
|
38
|
-
|
|
39
|
-
F1: { value: `=${testSheetName}!A1` }, // Ref test sheet.
|
|
40
|
-
F3: { value: true },
|
|
41
|
-
F4: { value: false },
|
|
42
|
-
F5: { value: '8%' },
|
|
43
|
-
F6: { value: '$10000' },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: CreateSheetOptions) => {
|
|
47
|
-
const [sheet] = useAsyncState(async () => {
|
|
48
|
-
if (!space || !graph) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const sheet = createSheet(options);
|
|
53
|
-
space.db.add(sheet);
|
|
54
|
-
return sheet;
|
|
55
|
-
}, [space, graph]);
|
|
56
|
-
return sheet;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const withComputeGraphDecorator =
|
|
60
|
-
(options?: ComputeGraphOptions): Decorator =>
|
|
61
|
-
(Story) => {
|
|
62
|
-
const [registry] = useState(new ComputeGraphRegistry(options));
|
|
63
|
-
return (
|
|
64
|
-
<ComputeGraphContextProvider registry={registry}>
|
|
65
|
-
<Story />
|
|
66
|
-
</ComputeGraphContextProvider>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
File without changes
|
|
File without changes
|