@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-main.8b352a0
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-AKWROARP.mjs → SheetContainer-R65IDJHN.mjs} +54 -58
- package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-5KVQ5IPW.mjs} +3 -12
- package/dist/lib/browser/chunk-5KVQ5IPW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-I2DKJ72A.mjs} +570 -669
- package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-KCYJSOFB.mjs} +252 -33
- package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-SJT67236.mjs} +4 -2
- package/dist/lib/browser/index.mjs +62 -20
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-6BO4C5X2.cjs} +52 -62
- package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-2XJ5I4UF.cjs} +6 -15
- package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-DEPJHN47.cjs} +534 -646
- package/dist/lib/node/chunk-DEPJHN47.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-JF5XNTF3.cjs} +257 -28
- package/dist/lib/node/chunk-JF5XNTF3.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-AQBDL7HO.cjs} +21 -19
- package/dist/lib/node/compute-graph-AQBDL7HO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +70 -31
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +6 -6
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-MJXC5E3P.mjs} +54 -58
- package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-25V7WY4R.mjs} +570 -669
- package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-5TXLF6PL.mjs} +3 -12
- package/dist/lib/node-esm/chunk-5TXLF6PL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-XBEHKYO7.mjs} +251 -33
- package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-FRCKXEYK.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +62 -20
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -2
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/index.d.ts +2 -0
- package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -3
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +7 -5
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/{graph → compute-graph}/compute-graph.d.ts +1 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/compute-graph/util.d.ts.map +1 -0
- package/dist/types/src/defs/index.d.ts +1 -1
- package/dist/types/src/defs/index.d.ts.map +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/defs/types.d.ts +6 -0
- package/dist/types/src/defs/types.d.ts.map +1 -1
- package/dist/types/src/defs/util.d.ts +2 -6
- package/dist/types/src/defs/util.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +23 -3
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/index.d.ts +2 -0
- package/dist/types/src/integrations/index.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +1 -1
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/{hooks → model}/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +4 -0
- package/dist/types/src/serializer.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +13 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -30
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +43 -50
- package/src/SheetPlugin.tsx +25 -12
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +5 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
- package/src/components/GridSheet/GridSheet.tsx +118 -22
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +24 -14
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +3 -3
- package/src/components/SheetContainer/SheetContainer.tsx +10 -4
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +44 -41
- package/src/components/index.ts +1 -0
- package/src/{graph → compute-graph}/compute-graph.stories.tsx +2 -1
- package/src/{graph → compute-graph}/compute-graph.ts +5 -2
- package/src/{graph → compute-graph}/compute-node.ts +2 -3
- package/src/defs/index.ts +1 -1
- package/src/defs/sheet-range-types.ts +5 -4
- package/src/defs/types.ts +6 -1
- package/src/defs/util.ts +3 -19
- package/src/extensions/compute.stories.tsx +2 -2
- package/src/extensions/compute.ts +2 -2
- package/src/extensions/editor/extension.test.ts +1 -1
- package/src/extensions/editor/extension.ts +48 -23
- package/src/index.ts +2 -2
- package/src/integrations/index.ts +5 -0
- package/src/integrations/thread-ranges.ts +101 -0
- package/src/model/index.ts +1 -1
- package/src/model/sheet-model.test.ts +1 -1
- package/src/model/sheet-model.ts +13 -8
- package/src/{hooks → model}/useSheetModel.ts +1 -1
- package/src/serializer.ts +27 -0
- package/src/testing/testing.tsx +1 -1
- package/src/translations.ts +13 -3
- package/src/types.ts +4 -2
- package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +0 -7
- package/dist/lib/node/chunk-53BMSUIK.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- 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.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.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -6
- 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/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.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/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -26
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/src/hooks/hooks.stories.tsx +0 -53
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/model/decorations.ts +0 -66
- /package/dist/lib/browser/{graph-M4IQ76QX.mjs.map → compute-graph-SJT67236.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-FRCKXEYK.mjs.map} +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph-registry.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.stories.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-node.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/async-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/edge-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/function-defs.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/hyperformula.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-builder.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-plugin.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/util.d.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph-registry.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph.test.ts +0 -0
- /package/src/{graph → compute-graph}/functions/async-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/edge-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/function-defs.ts +0 -0
- /package/src/{graph → compute-graph}/functions/index.ts +0 -0
- /package/src/{graph → compute-graph}/hyperformula.test.ts +0 -0
- /package/src/{graph → compute-graph}/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-builder.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-plugin.ts +0 -0
- /package/src/{graph → compute-graph}/util.ts +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type IntentResolver, LayoutAction, useIntentDispatcher, useIntentResolver } from '@dxos/app-framework';
|
|
8
|
+
import { debounce } from '@dxos/async';
|
|
9
|
+
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
|
+
import { type DxGridElement, type DxGridPosition } from '@dxos/react-ui-grid';
|
|
11
|
+
|
|
12
|
+
import { useSheetContext } from '../components';
|
|
13
|
+
import { type CellAddress, type CompleteCellRange, inRange } from '../defs';
|
|
14
|
+
import { SHEET_PLUGIN } from '../meta';
|
|
15
|
+
|
|
16
|
+
export const completeCellRangeToThreadCursor = (range: CompleteCellRange): string => {
|
|
17
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const parseThreadAnchorAsCellRange = (cursor: string): CompleteCellRange | null => {
|
|
21
|
+
const coords = cursor.split(',');
|
|
22
|
+
if (coords.length !== 4) {
|
|
23
|
+
return null;
|
|
24
|
+
} else {
|
|
25
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
26
|
+
return {
|
|
27
|
+
from: { col: parseInt(fromCol), row: parseInt(fromRow) },
|
|
28
|
+
to: { col: parseInt(toCol), row: parseInt(toRow) },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null) => {
|
|
34
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
35
|
+
const handleScrollIntoView: IntentResolver = useCallback(
|
|
36
|
+
({ action, data }) => {
|
|
37
|
+
switch (action) {
|
|
38
|
+
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
39
|
+
if (!data?.id || data?.cursor === undefined || data?.id !== fullyQualifiedId(model.sheet)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setActiveRefs(data.thread);
|
|
43
|
+
// TODO(Zan): Everywhere we refer to the cursor in a thread context should change to `anchor`.
|
|
44
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
45
|
+
range && grid?.setFocus({ ...range.to, plane: 'grid' }, true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
[model.sheet, setActiveRefs],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const useSelectThreadOnCellFocus = () => {
|
|
56
|
+
const { model, cursor } = useSheetContext();
|
|
57
|
+
const dispatch = useIntentDispatcher();
|
|
58
|
+
|
|
59
|
+
const threads = useMemo(
|
|
60
|
+
() => model.sheet.threads?.filter((thread): thread is NonNullable<typeof thread> => !!thread) ?? [],
|
|
61
|
+
[
|
|
62
|
+
// TODO(thure): Surely we can find a better dependency for this…
|
|
63
|
+
JSON.stringify(model.sheet.threads),
|
|
64
|
+
],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const selectClosestThread = useCallback(
|
|
68
|
+
(cellAddress: CellAddress) => {
|
|
69
|
+
if (!cellAddress || !threads) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
74
|
+
if (anchor) {
|
|
75
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
76
|
+
return range ? inRange(range, cellAddress) : false;
|
|
77
|
+
} else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (closestThread) {
|
|
83
|
+
void dispatch([
|
|
84
|
+
{ action: 'dxos.org/plugin/thread/action/select', data: { current: fullyQualifiedId(closestThread) } },
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[dispatch, threads],
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const debounced = useMemo(() => {
|
|
92
|
+
return debounce((cellCoords: DxGridPosition) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
93
|
+
}, [selectClosestThread]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!cursor) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
debounced(cursor);
|
|
100
|
+
}, [cursor, debounced]);
|
|
101
|
+
};
|
package/src/model/index.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { Trigger } from '@dxos/async';
|
|
|
8
8
|
import { FunctionType } from '@dxos/plugin-script/types';
|
|
9
9
|
|
|
10
10
|
import { SheetModel } from './sheet-model';
|
|
11
|
+
import { TestBuilder, testFunctionPlugins } from '../compute-graph/testing';
|
|
11
12
|
import { addressFromA1Notation, createSheet } from '../defs';
|
|
12
|
-
import { TestBuilder, testFunctionPlugins } from '../graph/testing';
|
|
13
13
|
import { type CellScalarValue } from '../types';
|
|
14
14
|
|
|
15
15
|
describe('SheetModel', () => {
|
package/src/model/sheet-model.ts
CHANGED
|
@@ -15,16 +15,21 @@ import { log } from '@dxos/log';
|
|
|
15
15
|
import { FieldValueType } from '@dxos/schema';
|
|
16
16
|
|
|
17
17
|
import { DetailedCellError, ExportedCellChange } from '#hyperformula';
|
|
18
|
+
import { type ComputeGraph, type ComputeNode, type ComputeNodeEvent, createSheetName } from '../compute-graph';
|
|
18
19
|
import {
|
|
19
20
|
addressFromA1Notation,
|
|
21
|
+
addressFromIndex,
|
|
20
22
|
addressToA1Notation,
|
|
23
|
+
addressToIndex,
|
|
21
24
|
type CellAddress,
|
|
22
25
|
type CellRange,
|
|
26
|
+
initialize,
|
|
27
|
+
insertIndices,
|
|
28
|
+
isFormula,
|
|
23
29
|
MAX_COLUMNS,
|
|
24
30
|
MAX_ROWS,
|
|
31
|
+
ReadonlyException,
|
|
25
32
|
} from '../defs';
|
|
26
|
-
import { addressFromIndex, addressToIndex, initialize, insertIndices, ReadonlyException } from '../defs';
|
|
27
|
-
import { type ComputeNode, type ComputeGraph, createSheetName, type ComputeNodeEvent } from '../graph';
|
|
28
33
|
import { type CellScalarValue, type CellValue, type SheetType } from '../types';
|
|
29
34
|
|
|
30
35
|
// Map sheet types to system types.
|
|
@@ -128,7 +133,7 @@ export class SheetModel extends Resource {
|
|
|
128
133
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
129
134
|
invariant(this._node);
|
|
130
135
|
const { col, row } = addressFromIndex(this._sheet, key);
|
|
131
|
-
if (
|
|
136
|
+
if (isFormula(value)) {
|
|
132
137
|
value = this._graph.mapFormulaToNative(
|
|
133
138
|
this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)),
|
|
134
139
|
);
|
|
@@ -240,7 +245,7 @@ export class SheetModel extends Resource {
|
|
|
240
245
|
return undefined;
|
|
241
246
|
}
|
|
242
247
|
|
|
243
|
-
if (
|
|
248
|
+
if (isFormula(value)) {
|
|
244
249
|
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
245
250
|
} else {
|
|
246
251
|
return String(value);
|
|
@@ -305,7 +310,7 @@ export class SheetModel extends Resource {
|
|
|
305
310
|
|
|
306
311
|
// Insert into engine.
|
|
307
312
|
this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row: cell.row, col: cell.col }, [
|
|
308
|
-
[
|
|
313
|
+
[isFormula(value) ? this._graph.mapFormulaToNative(value) : value],
|
|
309
314
|
]);
|
|
310
315
|
|
|
311
316
|
// Insert into sheet.
|
|
@@ -313,7 +318,7 @@ export class SheetModel extends Resource {
|
|
|
313
318
|
if (value === undefined || value === null) {
|
|
314
319
|
delete this._sheet.cells[idx];
|
|
315
320
|
} else {
|
|
316
|
-
if (
|
|
321
|
+
if (isFormula(value)) {
|
|
317
322
|
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
318
323
|
}
|
|
319
324
|
|
|
@@ -371,7 +376,7 @@ export class SheetModel extends Resource {
|
|
|
371
376
|
* Map from A1 notation to indices.
|
|
372
377
|
*/
|
|
373
378
|
mapFormulaRefsToIndices(formula: string): string {
|
|
374
|
-
invariant(formula
|
|
379
|
+
invariant(isFormula(formula));
|
|
375
380
|
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
376
381
|
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
377
382
|
});
|
|
@@ -381,7 +386,7 @@ export class SheetModel extends Resource {
|
|
|
381
386
|
* Map from indices to A1 notation.
|
|
382
387
|
*/
|
|
383
388
|
mapFormulaIndicesToRefs(formula: string): string {
|
|
384
|
-
invariant(formula
|
|
389
|
+
invariant(isFormula(formula));
|
|
385
390
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
386
391
|
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
387
392
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
|
|
6
|
+
import { create, getObjectCore } from '@dxos/react-client/echo';
|
|
7
|
+
|
|
8
|
+
import { SheetType } from './types';
|
|
9
|
+
|
|
10
|
+
export const serializer: TypedObjectSerializer<SheetType> = {
|
|
11
|
+
serialize: async ({ object }): Promise<string> => {
|
|
12
|
+
const { threads: _threads, ...sheet } = object;
|
|
13
|
+
return JSON.stringify(sheet, null, 2);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
deserialize: async ({ content, newId }) => {
|
|
17
|
+
const { id, ...parsed } = JSON.parse(content);
|
|
18
|
+
const sheet = create(SheetType, parsed);
|
|
19
|
+
|
|
20
|
+
if (!newId) {
|
|
21
|
+
const core = getObjectCore(sheet);
|
|
22
|
+
core.id = id;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return sheet;
|
|
26
|
+
},
|
|
27
|
+
};
|
package/src/testing/testing.tsx
CHANGED
|
@@ -9,8 +9,8 @@ import { type Space } from '@dxos/react-client/echo';
|
|
|
9
9
|
import { useAsyncState } from '@dxos/react-hooks';
|
|
10
10
|
|
|
11
11
|
import { ComputeGraphContextProvider } from '../components';
|
|
12
|
+
import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph';
|
|
12
13
|
import { createSheet } from '../defs';
|
|
13
|
-
import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '../graph';
|
|
14
14
|
import { type CellValue, type CreateSheetOptions } from '../types';
|
|
15
15
|
|
|
16
16
|
const testSheetName = 'test';
|
package/src/translations.ts
CHANGED
|
@@ -13,14 +13,24 @@ export default [
|
|
|
13
13
|
'create sheet label': 'Create sheet',
|
|
14
14
|
'create sheet section label': 'Create sheet',
|
|
15
15
|
'cell placeholder': 'Cell value...',
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
16
|
+
'range key alignment label': 'Align',
|
|
17
|
+
'range value start label': 'left',
|
|
18
|
+
'range value center label': 'center',
|
|
19
|
+
'range value end label': 'right',
|
|
20
|
+
'toolbar action label': '{{key}} {{value}}',
|
|
19
21
|
'selection overlaps existing comment label': 'Selected cell already has a comment',
|
|
20
22
|
'comment label': 'Add comment',
|
|
21
23
|
'comment ranges not supported label': 'Commenting on ranges is not yet supported',
|
|
22
24
|
'no cursor label': 'Select a cell to comment',
|
|
23
25
|
'open comment for sheet cell': 'View comments for cell',
|
|
26
|
+
'add col before label': 'Add column before',
|
|
27
|
+
'add col after label': 'Add column after',
|
|
28
|
+
'delete col label': 'Delete column',
|
|
29
|
+
'add row before label': 'Add row before',
|
|
30
|
+
'add row after label': 'Add row after',
|
|
31
|
+
'delete row label': 'Delete row',
|
|
32
|
+
'range list heading': 'Ranges',
|
|
33
|
+
'range title': '{{position}} — {{key}}: {{value}}',
|
|
24
34
|
},
|
|
25
35
|
},
|
|
26
36
|
},
|
package/src/types.ts
CHANGED
|
@@ -58,18 +58,20 @@ export type CellValue = S.Schema.Type<typeof CellValue>;
|
|
|
58
58
|
|
|
59
59
|
// TODO(burdon): IMPORTANT: Reconcile with Field definition.
|
|
60
60
|
export const Range = S.Struct({
|
|
61
|
-
range: S.
|
|
61
|
+
range: S.String,
|
|
62
62
|
key: S.String,
|
|
63
63
|
value: S.String,
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
export type Range = S.Schema.Type<typeof Range>;
|
|
67
|
+
|
|
66
68
|
// TODO(burdon): Visibility, locked, frozen, etc.
|
|
67
69
|
export const RowColumnMeta = S.Struct({
|
|
68
70
|
size: S.optional(S.Number),
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.
|
|
72
|
-
export class SheetType extends TypedObject({ typename: 'dxos.org/type/
|
|
74
|
+
export class SheetType extends TypedObject({ typename: 'dxos.org/type/Sheet', version: '0.1.0' })({
|
|
73
75
|
name: S.optional(S.String),
|
|
74
76
|
|
|
75
77
|
// Sparse map of cells referenced by index.
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/SheetContainer/SheetContainer.tsx", "../../../src/components/FunctionEditor/FunctionEditor.tsx", "../../../src/components/Toolbar/Toolbar.tsx", "../../../src/components/SheetContainer/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { FunctionEditor } from '../FunctionEditor';\nimport { GridSheet } from '../GridSheet';\nimport { SheetProvider, type SheetProviderProps } from '../SheetContext';\nimport { Toolbar } from '../Toolbar';\n\nexport const SheetContainer = ({ graph, sheet, role }: SheetProviderProps & { role?: string }) => {\n return (\n <SheetProvider sheet={sheet} graph={graph}>\n <Toolbar.Root role={role}>\n <Toolbar.Styles />\n <Toolbar.Alignment />\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n <div role='none' className='border-bs border-separator grid cols-1 rows-[1fr_min-content] min-bs-0'>\n <GridSheet />\n <FunctionEditor />\n </div>\n </SheetProvider>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Icon } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { addressToA1Notation, rangeToA1Notation } from '../../defs';\nimport { useSheetContext } from '../SheetContext';\n\nexport const FunctionEditor = () => {\n const { model, cursor, range } = useSheetContext();\n\n let value;\n let isFormula = false;\n if (cursor) {\n value = model.getCellValue(cursor);\n if (typeof value === 'string' && value.charAt(0) === '=') {\n value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));\n isFormula = true;\n } else if (value != null) {\n value = String(value);\n }\n }\n\n return (\n <div\n className={mx(\n 'flex shrink-0 justify-between items-center px-4 py-1 text-sm border-bs !border-separator attention-surface',\n )}\n >\n <div className='flex gap-4 items-center'>\n <div className='flex w-16 items-center font-mono'>\n {(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}\n </div>\n <div className='flex gap-2 items-center'>\n <Icon icon='ph--function--regular' classNames={['text-greenText', isFormula ? 'visible' : 'invisible']} />\n <span className='font-mono'>{value}</span>\n </div>\n </div>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren, useCallback, useMemo } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport {\n Icon,\n Toolbar as NaturalToolbar,\n useTranslation,\n Tooltip,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleProps as NaturalToolbarToggleProps,\n type ThemedClassName,\n} from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { nonNullable } from '@dxos/util';\n\nimport {\n addressToIndex,\n type AlignKey,\n type AlignValue,\n type CommentKey,\n type CommentValue,\n inRange,\n type StyleKey,\n type StyleValue,\n} from '../../defs';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type SheetType } from '../../types';\nimport { useSheetContext } from '../SheetContext';\n\n//\n// Buttons\n//\n\nconst buttonStyles = 'min-bs-0 p-2';\nconst tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };\n\nconst ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarItem\n//\n\ntype ToolbarItemProps =\n | (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })\n | (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })\n | (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });\n\nexport const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {\n const Invoker =\n itemType === 'toggleGroupItem'\n ? NaturalToolbar.ToggleGroupItem\n : itemType === 'toggle'\n ? NaturalToolbar.Toggle\n : NaturalToolbar.Button;\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n {/* TODO(thure): type the props spread better. */}\n <Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>\n <Icon icon={icon} size={5} />\n <span className='sr-only'>{children}</span>\n </Invoker>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n\n//\n// Root\n//\n\ntype AlignAction = { key: AlignKey; value: AlignValue };\ntype CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };\ntype StyleAction = { key: StyleKey; value: StyleValue };\n\nexport type ToolbarAction = StyleAction | AlignAction | CommentAction;\n\nexport type ToolbarActionType = ToolbarAction['key'];\n\nexport type ToolbarActionHandler = (action: ToolbarAction) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n role?: string;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<{ onAction: (action: ToolbarAction) => void }>(\n 'Toolbar',\n);\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nconst sectionToolbarLayout =\n 'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';\n\ntype Range = SheetType['ranges'][number];\n\nconst ToolbarRoot = ({ children, role, classNames }: ToolbarProps) => {\n const { id, model, range, cursor } = useSheetContext();\n const { hasAttention } = useAttention(id);\n const dispatch = useIntentDispatcher();\n\n // TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.\n const handleAction = useCallback(\n (action: ToolbarAction) => {\n switch (action.key) {\n case 'align':\n if (cursor) {\n const index = model.sheet.ranges?.findIndex(\n (range) => range.key === action.key && inRange(range.range, cursor),\n );\n const nextRange = range ? { from: range.from, to: range.to ?? range.from } : { from: cursor, to: cursor };\n const nextRangeEntity = {\n range: nextRange as Range['range'],\n key: action.key,\n value: action.value,\n };\n if (index < 0) {\n model.sheet.ranges?.push(nextRangeEntity);\n } else {\n model.sheet.ranges?.splice(index, 1, nextRangeEntity);\n }\n }\n break;\n case 'style':\n if (action.value === 'unset') {\n const index = model.sheet.ranges?.findIndex((range) => range.key === action.key);\n if (index >= 0) {\n model.sheet.ranges?.splice(index, 1);\n }\n } else if (range || cursor) {\n const nextRange = range ? { from: range.from, to: range.to ?? range.from } : { from: cursor, to: cursor };\n model.sheet.ranges?.push({\n range: nextRange as Range['range'],\n key: action.key,\n value: action.value,\n });\n }\n break;\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: action.value,\n name: action.cellContent,\n subject: model.sheet,\n },\n });\n }\n }\n },\n [model.sheet, range, cursor, dispatch],\n );\n\n return (\n <ToolbarContextProvider onAction={handleAction}>\n <NaturalToolbar.Root\n classNames={[\n ...(role === 'section'\n ? ['z-[2] group-focus-within/section:visible', !hasAttention && 'invisible', sectionToolbarLayout]\n : ['attention-surface']),\n classNames,\n ]}\n >\n {children}\n </NaturalToolbar.Root>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps<T> = {\n value: T;\n icon: string;\n disabled?: (state: Range) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst alignmentOptions: ButtonProps<AlignValue>[] = [\n { value: 'start', icon: 'ph--text-align-left--regular' },\n { value: 'center', icon: 'ph--text-align-center--regular' },\n { value: 'end', icon: 'ph--text-align-right--regular' },\n];\n\nconst Alignment = () => {\n const { cursor, model } = useSheetContext();\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const value = useMemo(\n () =>\n cursor\n ? model.sheet.ranges?.find(({ range, key }) => key === 'alignment' && inRange(range, cursor))?.value\n : undefined,\n [cursor, model.sheet.ranges],\n );\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n value={value}\n onValueChange={(value: AlignValue) => onAction?.({ key: 'align', value })}\n >\n {alignmentOptions.map(({ value, icon }) => (\n <ToolbarItem itemType='toggleGroupItem' key={value} value={value} icon={icon}>\n {t(`toolbar ${value} label`)}\n </ToolbarItem>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps<StyleValue>[] = [{ value: 'highlight', icon: 'ph--highlighter--regular' }];\n\nconst Styles = () => {\n const { cursor, model } = useSheetContext();\n const { onAction } = useToolbarContext('Styles');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const activeValues = useMemo(\n () =>\n cursor\n ? model.sheet.ranges\n ?.filter(({ range, key }) => key === 'style' && inRange(range, cursor))\n .reduce((acc, { value }) => {\n acc.add(value);\n return acc;\n }, new Set())\n : undefined,\n [cursor, model.sheet.ranges],\n );\n\n return (\n <>\n {styleOptions.map(({ value, icon }) => (\n <ToolbarItem\n itemType='toggle'\n key={value}\n pressed={activeValues?.has(value)}\n onPressedChange={(nextPressed: boolean) => onAction?.({ key: 'style', value: nextPressed ? value : 'unset' })}\n icon={icon}\n >\n {t(`toolbar ${value} label`)}\n </ToolbarItem>\n ))}\n </>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursor, range, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursor) {\n return false;\n }\n return addressToIndex(model.sheet, cursor) === thread.anchor;\n });\n\n const hasCursor = !!cursor;\n const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;\n\n const tooltipLabelKey = !hasCursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : range\n ? 'comment ranges not supported label'\n : 'comment label';\n\n return (\n <ToolbarItem\n itemType='button'\n value='comment'\n icon='ph--chat-text--regular'\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursor) {\n return;\n }\n return onAction?.({\n key: 'comment',\n value: addressToIndex(model.sheet, cursor),\n cellContent: model.getCellText(cursor),\n });\n }}\n disabled={!cursorOnly || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarItem>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SheetContainer } from './SheetContainer';\n\nexport default SheetContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAIA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAElB,SAASC,YAAY;AACrB,SAASC,UAAU;AAKZ,IAAMC,iBAAiB,MAAA;AAC5B,QAAM,EAAEC,OAAOC,QAAQC,MAAK,IAAKC,gBAAAA;AAEjC,MAAIC;AACJ,MAAIC,YAAY;AAChB,MAAIJ,QAAQ;AACVG,YAAQJ,MAAMM,aAAaL,MAAAA;AAC3B,QAAI,OAAOG,UAAU,YAAYA,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WAAWtG;EACX8D;EACAY;EACAW;AACF;;;AF1TO,IAAMkB,iBAAiB,CAAC,EAAEC,OAAOC,OAAOC,KAAI,MAA0C;AAC3F,SACE,gBAAAC,OAAA,cAACC,eAAAA;IAAcH;IAAcD;KAC3B,gBAAAG,OAAA,cAACE,QAAQC,MAAI;IAACJ;KACZ,gBAAAC,OAAA,cAACE,QAAQE,QAAM,IAAA,GACf,gBAAAJ,OAAA,cAACE,QAAQG,WAAS,IAAA,GAClB,gBAAAL,OAAA,cAACE,QAAQI,WAAS,IAAA,GAClB,gBAAAN,OAAA,cAACE,QAAQK,SAAO,IAAA,CAAA,GAElB,gBAAAP,OAAA,cAACQ,OAAAA;IAAIT,MAAK;IAAOU,WAAU;KACzB,gBAAAT,OAAA,cAACU,WAAAA,IAAAA,GACD,gBAAAV,OAAA,cAACW,gBAAAA,IAAAA,CAAAA,CAAAA;AAIT;;;AGpBA,IAAA,yBAAeC;",
|
|
6
|
-
"names": ["React", "React", "Icon", "mx", "FunctionEditor", "model", "cursor", "range", "useSheetContext", "value", "isFormula", "getCellValue", "charAt", "graph", "mapFunctionBindingFromId", "mapFormulaIndicesToRefs", "String", "div", "className", "mx", "rangeToA1Notation", "addressToA1Notation", "Icon", "icon", "classNames", "span", "createContext", "React", "useCallback", "useMemo", "useIntentDispatcher", "Icon", "Toolbar", "NaturalToolbar", "useTranslation", "Tooltip", "useAttention", "nonNullable", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "React", "div", "role", "className", "ToolbarItem", "itemType", "icon", "children", "props", "Invoker", "NaturalToolbar", "ToggleGroupItem", "Toggle", "Button", "Tooltip", "Root", "Trigger", "asChild", "variant", "Icon", "size", "span", "Portal", "Content", "Arrow", "ToolbarContextProvider", "useToolbarContext", "createContext", "sectionToolbarLayout", "ToolbarRoot", "id", "model", "range", "cursor", "useSheetContext", "hasAttention", "useAttention", "dispatch", "useIntentDispatcher", "handleAction", "useCallback", "action", "key", "index", "sheet", "ranges", "findIndex", "inRange", "nextRange", "from", "to", "nextRangeEntity", "value", "push", "splice", "data", "name", "cellContent", "subject", "onAction", "alignmentOptions", "Alignment", "t", "useTranslation", "SHEET_PLUGIN", "useMemo", "find", "undefined", "ToggleGroup", "type", "onValueChange", "map", "styleOptions", "Styles", "activeValues", "filter", "reduce", "acc", "add", "Set", "pressed", "has", "onPressedChange", "nextPressed", "Actions", "overlapsCommentAnchor", "threads", "nonNullable", "thread", "status", "some", "addressToIndex", "anchor", "hasCursor", "cursorOnly", "tooltipLabelKey", "data-testid", "onClick", "getCellText", "disabled", "Toolbar", "Separator", "SheetContainer", "graph", "sheet", "role", "React", "SheetProvider", "Toolbar", "Root", "Styles", "Alignment", "Separator", "Actions", "div", "className", "GridSheet", "FunctionEditor", "SheetContainer"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type MarkdownExtensionProvides } from '@dxos/plugin-markdown';\nimport { type SpaceInitProvides } from '@dxos/plugin-space';\nimport { ThreadType } from '@dxos/plugin-space/types';\nimport { type StackProvides } from '@dxos/plugin-stack';\n\nimport { SHEET_PLUGIN } from './meta';\n\nconst SHEET_ACTION = `${SHEET_PLUGIN}/action`;\n\nexport enum SheetAction {\n CREATE = `${SHEET_ACTION}/create`,\n}\n\n// TODO(Zan): Move this to the plugin-space plugin or another common location\n// when we implement comments in sheets.\n// This is currently duplicated in a few places.\ntype ThreadProvides<T> = {\n thread: {\n predicate: (obj: any) => obj is T;\n createSort: (obj: T) => (anchorA: string | undefined, anchorB: string | undefined) => number;\n };\n};\n\nexport type SheetPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MarkdownExtensionProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n SchemaProvides &\n SpaceInitProvides &\n StackProvides &\n ThreadProvides<SheetType>;\n\nexport type CellScalarValue = number | string | boolean | null;\n\nexport const CellValue = S.Struct({\n // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.\n // Consider import/export; natural access for other plugins. Special handling for currency (precision).\n // TODO(burdon): Automerge (long string) or short string or number.\n value: S.Any,\n});\n\nexport type CellValue = S.Schema.Type<typeof CellValue>;\n\n// TODO(burdon): IMPORTANT: Reconcile with Field definition.\nexport const Range = S.Struct({\n range: S.Struct({ from: S.Struct({ col: S.Number, row: S.Number }), to: S.Struct({ col: S.Number, row: S.Number }) }),\n key: S.String,\n value: S.String,\n});\n\n// TODO(burdon): Visibility, locked, frozen, etc.\nexport const RowColumnMeta = S.Struct({\n size: S.optional(S.Number),\n});\n\n// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.\nexport class SheetType extends TypedObject({ typename: 'dxos.org/type/SheetType', version: '0.1.0' })({\n name: S.optional(S.String),\n\n // Sparse map of cells referenced by index.\n cells: S.mutable(S.Record({ key: S.String, value: S.mutable(CellValue) })),\n\n // Ordered row indices.\n rows: S.mutable(S.Array(S.String)),\n\n // Ordered column indices.\n columns: S.mutable(S.Array(S.String)),\n\n // Row metadata referenced by index.\n rowMeta: S.mutable(S.Record({ key: S.String, value: S.mutable(RowColumnMeta) })),\n\n // Column metadata referenced by index.\n columnMeta: S.mutable(S.Record({ key: S.String, value: S.mutable(RowColumnMeta) })),\n\n // Cell formatting referenced by indexed range.\n ranges: S.mutable(S.Array(Range)),\n\n // Threads associated with the sheet\n threads: S.optional(S.mutable(S.Array(ref(ThreadType)))),\n}) {}\n\nexport type SheetSize = {\n rows: number;\n columns: number;\n};\n\nexport type CreateSheetOptions = {\n name?: string;\n cells?: Record<string, CellValue>;\n} & Partial<Sheet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QtB,EAAEuB,OAAO;IAAEZ,KAAKX,EAAEY;IAAQV,OAAOF,EAAEsB,QAAQT,aAAAA;EAAe,CAAA,CAAA;;EAGhFgB,QAAQ7B,EAAEsB,QAAQtB,EAAEyB,MAAMrB,KAAAA,CAAAA;;EAG1B0B,SAAS9B,EAAEe,SAASf,EAAEsB,QAAQtB,EAAEyB,MAAMM,IAAIC,UAAAA,CAAAA,CAAAA,CAAAA;AAC5C,CAAA,EAAA;AAAI;",
|
|
6
|
-
"names": ["ref", "S", "TypedObject", "ThreadType", "SHEET_ACTION", "SHEET_PLUGIN", "SheetAction", "CellValue", "S", "Struct", "value", "Any", "Range", "range", "from", "col", "Number", "row", "to", "key", "String", "RowColumnMeta", "size", "optional", "SheetType", "TypedObject", "typename", "version", "name", "cells", "mutable", "Record", "rows", "Array", "columns", "rowMeta", "columnMeta", "ranges", "threads", "ref", "ThreadType"]
|
|
7
|
-
}
|