@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-staging.0f558a0
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-P3NF5KEI.mjs} +90 -88
- package/dist/lib/browser/SheetContainer-P3NF5KEI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-4LKIURJA.mjs} +917 -817
- package/dist/lib/browser/chunk-4LKIURJA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-BVUN7SHF.mjs} +6 -13
- package/dist/lib/browser/chunk-BVUN7SHF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D3QTX46O.mjs → chunk-RABELMEQ.mjs} +3 -2
- package/dist/lib/browser/{chunk-D3QTX46O.mjs.map → chunk-RABELMEQ.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-VMSX6Z4X.mjs} +297 -44
- package/dist/lib/browser/chunk-VMSX6Z4X.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-GGWUX644.mjs} +4 -2
- package/dist/lib/browser/index.mjs +91 -21
- 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/types.mjs +2 -2
- package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-MPFKXY26.cjs} +88 -93
- package/dist/lib/node/SheetContainer-MPFKXY26.cjs.map +7 -0
- package/dist/lib/node/{chunk-QIFIGEKV.cjs → chunk-2ZVZI2KJ.cjs} +6 -5
- package/dist/lib/node/{chunk-QIFIGEKV.cjs.map → chunk-2ZVZI2KJ.cjs.map} +3 -3
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-AWKOWDMI.cjs} +10 -17
- package/dist/lib/node/chunk-AWKOWDMI.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-O7XR4R7Y.cjs} +306 -42
- package/dist/lib/node/chunk-O7XR4R7Y.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-OO24XJBV.cjs} +853 -767
- package/dist/lib/node/chunk-OO24XJBV.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-KGWA2QLE.cjs} +21 -19
- package/dist/lib/node/compute-graph-KGWA2QLE.cjs.map +7 -0
- package/dist/lib/node/index.cjs +109 -42
- 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/types.cjs +7 -7
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-22IOAW3B.mjs} +90 -88
- package/dist/lib/node-esm/SheetContainer-22IOAW3B.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VCYJWE3O.mjs → chunk-BM2Q3FFC.mjs} +3 -2
- package/dist/lib/node-esm/{chunk-VCYJWE3O.mjs.map → chunk-BM2Q3FFC.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-BW36PM2Y.mjs} +917 -817
- package/dist/lib/node-esm/chunk-BW36PM2Y.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-CR4K75EL.mjs} +296 -44
- package/dist/lib/node-esm/chunk-CR4K75EL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-UIBWRHW7.mjs} +6 -13
- package/dist/lib/node-esm/chunk-UIBWRHW7.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-2SCZT7N5.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +91 -21
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/types.mjs +2 -2
- 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/FunctionEditor/FunctionEditor.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 +2 -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/SheetContainer/SheetContainer.stories.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 +6 -3
- 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 +3 -3
- 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 +2 -2
- 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 +3 -7
- 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/meta.d.ts +1 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- 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 +13 -6
- 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 +18 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +37 -33
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +44 -50
- package/src/SheetPlugin.tsx +45 -12
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +6 -10
- package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
- package/src/components/GridSheet/GridSheet.tsx +196 -36
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +41 -21
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +5 -3
- package/src/components/SheetContainer/SheetContainer.tsx +19 -12
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +98 -86
- 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 +27 -9
- package/src/{graph → compute-graph}/compute-node.ts +2 -3
- package/src/{graph → compute-graph}/functions/async-function.ts +1 -0
- package/src/{graph → compute-graph}/functions/edge-function.ts +5 -3
- package/src/defs/index.ts +1 -1
- package/src/defs/sheet-range-types.ts +9 -6
- package/src/defs/types.ts +6 -1
- package/src/defs/util.ts +4 -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/meta.ts +1 -0
- package/src/model/index.ts +1 -1
- package/src/model/sheet-model.test.ts +6 -4
- package/src/model/sheet-model.ts +103 -26
- 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 +18 -3
- package/src/types.ts +24 -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-GGWUX644.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-2SCZT7N5.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/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
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
DEFAULT_COLUMNS,
|
|
3
|
+
DEFAULT_ROWS,
|
|
4
|
+
MAX_COLUMNS,
|
|
5
|
+
MAX_ROWS,
|
|
6
|
+
RANGE_NOTATION,
|
|
7
|
+
ReadonlyException,
|
|
8
|
+
addressFromA1Notation,
|
|
9
|
+
addressFromIndex,
|
|
10
|
+
addressToA1Notation,
|
|
11
|
+
addressToIndex,
|
|
12
|
+
cellClassNameForRange,
|
|
13
|
+
createSheetName,
|
|
14
|
+
inRange,
|
|
15
|
+
initialize,
|
|
16
|
+
insertIndices,
|
|
17
|
+
isFormula,
|
|
18
|
+
rangeFromIndex,
|
|
19
|
+
rangeToA1Notation
|
|
20
|
+
} from "./chunk-VMSX6Z4X.mjs";
|
|
4
21
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
22
|
+
Range,
|
|
23
|
+
SheetAction
|
|
24
|
+
} from "./chunk-BVUN7SHF.mjs";
|
|
7
25
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
26
|
+
SHEET_PLUGIN
|
|
27
|
+
} from "./chunk-RABELMEQ.mjs";
|
|
10
28
|
|
|
11
29
|
// packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
12
|
-
import React, { createContext } from "react";
|
|
30
|
+
import React, { createContext, useContext } from "react";
|
|
31
|
+
import { raise } from "@dxos/debug";
|
|
32
|
+
import { useAsyncState } from "@dxos/react-hooks";
|
|
13
33
|
var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
|
|
14
34
|
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
15
35
|
return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
|
|
@@ -18,192 +38,19 @@ var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
|
18
38
|
}
|
|
19
39
|
}, children);
|
|
20
40
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
29
|
-
var DEFAULT_ROWS = 50;
|
|
30
|
-
var DEFAULT_COLUMNS = 26;
|
|
31
|
-
var MAX_ROWS = 500;
|
|
32
|
-
var MAX_COLUMNS = 26 * 2;
|
|
33
|
-
var posEquals = (a, b) => {
|
|
34
|
-
return a?.col === b?.col && a?.row === b?.row;
|
|
35
|
-
};
|
|
36
|
-
var columnLetter = (col) => {
|
|
37
|
-
invariant(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
38
|
-
F: __dxlog_file,
|
|
39
|
-
L: 26,
|
|
40
|
-
S: void 0,
|
|
41
|
-
A: [
|
|
42
|
-
"col < MAX_COLUMNS",
|
|
43
|
-
"`Invalid column: ${col}`"
|
|
44
|
-
]
|
|
45
|
-
});
|
|
46
|
-
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
47
|
-
};
|
|
48
|
-
var addressToA1Notation = ({ col, row }) => {
|
|
49
|
-
return `${columnLetter(col)}${row + 1}`;
|
|
50
|
-
};
|
|
51
|
-
var addressFromA1Notation = (ref) => {
|
|
52
|
-
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
53
|
-
invariant(match, `Invalid notation: ${ref}`, {
|
|
54
|
-
F: __dxlog_file,
|
|
55
|
-
L: 40,
|
|
56
|
-
S: void 0,
|
|
57
|
-
A: [
|
|
58
|
-
"match",
|
|
59
|
-
"`Invalid notation: ${ref}`"
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
row: parseInt(match[2], 10) - 1,
|
|
64
|
-
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
var rangeToA1Notation = (range) => {
|
|
68
|
-
return [
|
|
69
|
-
range?.from && addressToA1Notation(range?.from),
|
|
70
|
-
range?.to && addressToA1Notation(range?.to)
|
|
71
|
-
].filter(Boolean).join(":");
|
|
72
|
-
};
|
|
73
|
-
var inRange = (range, cell) => {
|
|
74
|
-
if (!range) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
const { from, to } = range;
|
|
78
|
-
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
if (!from || !to) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
const { col: c1, row: r1 } = from;
|
|
85
|
-
const { col: c2, row: r2 } = to;
|
|
86
|
-
const cMin = Math.min(c1, c2);
|
|
87
|
-
const cMax = Math.max(c1, c2);
|
|
88
|
-
const rMin = Math.min(r1, r2);
|
|
89
|
-
const rMax = Math.max(r1, r2);
|
|
90
|
-
const { col, row } = cell;
|
|
91
|
-
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// packages/plugins/plugin-sheet/src/defs/util.ts
|
|
95
|
-
var ApiError = class extends Error {
|
|
96
|
-
};
|
|
97
|
-
var ReadonlyException = class extends ApiError {
|
|
98
|
-
};
|
|
99
|
-
var RangeException = class extends ApiError {
|
|
100
|
-
constructor(n) {
|
|
101
|
-
super();
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
var createIndex = (length = 8) => {
|
|
105
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
106
|
-
const charactersLength = characters.length;
|
|
107
|
-
const randomBuffer = randomBytes(length);
|
|
108
|
-
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
109
|
-
};
|
|
110
|
-
var createIndices = (length) => Array.from({
|
|
111
|
-
length
|
|
112
|
-
}).map(() => createIndex());
|
|
113
|
-
var insertIndices = (indices, i, n, max) => {
|
|
114
|
-
if (i + n > max) {
|
|
115
|
-
throw new RangeException(i + n);
|
|
116
|
-
}
|
|
117
|
-
const idx = createIndices(n);
|
|
118
|
-
indices.splice(i, 0, ...idx);
|
|
119
|
-
};
|
|
120
|
-
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
121
|
-
if (!sheet.rows.length) {
|
|
122
|
-
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
123
|
-
}
|
|
124
|
-
if (!sheet.columns.length) {
|
|
125
|
-
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
var createSheet = ({ name, cells, ...size } = {}) => {
|
|
129
|
-
const sheet = create(SheetType, {
|
|
130
|
-
name,
|
|
131
|
-
cells: {},
|
|
132
|
-
rows: [],
|
|
133
|
-
columns: [],
|
|
134
|
-
rowMeta: {},
|
|
135
|
-
columnMeta: {},
|
|
136
|
-
ranges: []
|
|
137
|
-
});
|
|
138
|
-
initialize(sheet, size);
|
|
139
|
-
if (cells) {
|
|
140
|
-
Object.entries(cells).forEach(([key, { value }]) => {
|
|
141
|
-
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
142
|
-
sheet.cells[idx] = {
|
|
143
|
-
value
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return sheet;
|
|
148
|
-
};
|
|
149
|
-
var addressToIndex = (sheet, cell) => {
|
|
150
|
-
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
151
|
-
};
|
|
152
|
-
var addressFromIndex = (sheet, idx) => {
|
|
153
|
-
const [column, row] = idx.split("@");
|
|
154
|
-
return {
|
|
155
|
-
col: sheet.columns.indexOf(column),
|
|
156
|
-
row: sheet.rows.indexOf(row)
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
var closest = (cursor, cells) => {
|
|
160
|
-
let closestCell2;
|
|
161
|
-
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
162
|
-
for (const cell of cells) {
|
|
163
|
-
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
164
|
-
if (distance < closestDistance) {
|
|
165
|
-
closestCell2 = cell;
|
|
166
|
-
closestDistance = distance;
|
|
41
|
+
var useComputeGraph = (space) => {
|
|
42
|
+
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
43
|
+
const [graph] = useAsyncState(async () => {
|
|
44
|
+
if (space) {
|
|
45
|
+
const graph2 = registry.getOrCreateGraph(space);
|
|
46
|
+
await graph2.open();
|
|
47
|
+
return graph2;
|
|
167
48
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
174
|
-
if (rowA !== rowB) {
|
|
175
|
-
return rowA - rowB;
|
|
176
|
-
} else {
|
|
177
|
-
return columnA - columnB;
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// packages/plugins/plugin-sheet/src/defs/sheet-range-types.ts
|
|
182
|
-
var cellClassNameForRange = ({ key, value }) => {
|
|
183
|
-
switch (key) {
|
|
184
|
-
case "align":
|
|
185
|
-
switch (value) {
|
|
186
|
-
case "start":
|
|
187
|
-
return "text-start";
|
|
188
|
-
case "center":
|
|
189
|
-
return "text-center";
|
|
190
|
-
case "end":
|
|
191
|
-
return "text-end";
|
|
192
|
-
default:
|
|
193
|
-
return void 0;
|
|
194
|
-
}
|
|
195
|
-
case "comment":
|
|
196
|
-
return "bg-gridComment";
|
|
197
|
-
case "style":
|
|
198
|
-
switch (value) {
|
|
199
|
-
case "highlight":
|
|
200
|
-
return "bg-gridHighlight";
|
|
201
|
-
default:
|
|
202
|
-
return void 0;
|
|
203
|
-
}
|
|
204
|
-
default:
|
|
205
|
-
return void 0;
|
|
206
|
-
}
|
|
49
|
+
}, [
|
|
50
|
+
space,
|
|
51
|
+
registry
|
|
52
|
+
]);
|
|
53
|
+
return graph;
|
|
207
54
|
};
|
|
208
55
|
|
|
209
56
|
// packages/plugins/plugin-sheet/src/extensions/compute.ts
|
|
@@ -211,8 +58,8 @@ import { syntaxTree } from "@codemirror/language";
|
|
|
211
58
|
import { RangeSetBuilder, StateEffect, StateField } from "@codemirror/state";
|
|
212
59
|
import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
|
|
213
60
|
import { debounce } from "@dxos/async";
|
|
214
|
-
import { invariant
|
|
215
|
-
import { documentId, singleValueFacet } from "@dxos/react-ui-editor
|
|
61
|
+
import { invariant } from "@dxos/invariant";
|
|
62
|
+
import { documentId, singleValueFacet } from "@dxos/react-ui-editor";
|
|
216
63
|
var updateAllDecorations = StateEffect.define();
|
|
217
64
|
var computeGraphFacet = singleValueFacet();
|
|
218
65
|
|
|
@@ -222,7 +69,7 @@ import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
|
222
69
|
import { ViewPlugin as ViewPlugin2, keymap } from "@codemirror/view";
|
|
223
70
|
import { tags } from "@lezer/highlight";
|
|
224
71
|
import { spreadsheet } from "codemirror-lang-spreadsheet";
|
|
225
|
-
import { singleValueFacet as singleValueFacet2 } from "@dxos/react-ui-editor
|
|
72
|
+
import { singleValueFacet as singleValueFacet2 } from "@dxos/react-ui-editor";
|
|
226
73
|
import { mx } from "@dxos/react-ui-theme";
|
|
227
74
|
var highlightStyles = HighlightStyle.define([
|
|
228
75
|
// Function.
|
|
@@ -346,27 +193,29 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
346
193
|
])
|
|
347
194
|
];
|
|
348
195
|
};
|
|
349
|
-
var rangeExtension = (onInit) => {
|
|
196
|
+
var rangeExtension = ({ onInit, onStateChange }) => {
|
|
350
197
|
let view;
|
|
351
198
|
let activeRange;
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
199
|
+
const notifier = {
|
|
200
|
+
setRange: (range) => {
|
|
201
|
+
if (activeRange) {
|
|
202
|
+
view.dispatch(view.state.update({
|
|
203
|
+
changes: {
|
|
204
|
+
...activeRange,
|
|
205
|
+
insert: range.toString()
|
|
206
|
+
},
|
|
207
|
+
selection: {
|
|
208
|
+
anchor: activeRange.from + range.length
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
view.focus();
|
|
363
213
|
}
|
|
364
|
-
view.focus();
|
|
365
214
|
};
|
|
366
215
|
return ViewPlugin2.fromClass(class {
|
|
367
216
|
constructor(_view) {
|
|
368
217
|
view = _view;
|
|
369
|
-
onInit(
|
|
218
|
+
onInit?.(notifier);
|
|
370
219
|
}
|
|
371
220
|
update(view2) {
|
|
372
221
|
const { anchor } = view2.state.selection.ranges[0];
|
|
@@ -376,20 +225,18 @@ var rangeExtension = (onInit) => {
|
|
|
376
225
|
visitTree(topNode, ({ type, from, to }) => {
|
|
377
226
|
if (from <= anchor && to >= anchor) {
|
|
378
227
|
switch (type.name) {
|
|
379
|
-
case "Function":
|
|
228
|
+
case "Function":
|
|
380
229
|
activeRange = {
|
|
381
230
|
from: to,
|
|
382
231
|
to
|
|
383
232
|
};
|
|
384
233
|
break;
|
|
385
|
-
|
|
386
|
-
case "CloseParen": {
|
|
234
|
+
case "CloseParen":
|
|
387
235
|
activeRange = {
|
|
388
236
|
from,
|
|
389
237
|
to: from
|
|
390
238
|
};
|
|
391
239
|
break;
|
|
392
|
-
}
|
|
393
240
|
case "RangeToken":
|
|
394
241
|
case "CellToken":
|
|
395
242
|
activeRange = {
|
|
@@ -402,11 +249,17 @@ var rangeExtension = (onInit) => {
|
|
|
402
249
|
return false;
|
|
403
250
|
});
|
|
404
251
|
if (!activeRange && view2.state.doc.toString()[0] === "=") {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
252
|
+
const str = view2.state.doc.sliceString(1);
|
|
253
|
+
if (RANGE_NOTATION.test(str)) {
|
|
254
|
+
activeRange = {
|
|
255
|
+
from: 1,
|
|
256
|
+
to: str.length + 1
|
|
257
|
+
};
|
|
258
|
+
}
|
|
409
259
|
}
|
|
260
|
+
onStateChange?.({
|
|
261
|
+
activeRange: activeRange ? view2.state.doc.sliceString(activeRange.from, activeRange.to) : void 0
|
|
262
|
+
});
|
|
410
263
|
}
|
|
411
264
|
});
|
|
412
265
|
};
|
|
@@ -422,334 +275,156 @@ var visitTree = (node, callback) => {
|
|
|
422
275
|
return false;
|
|
423
276
|
};
|
|
424
277
|
|
|
425
|
-
// packages/plugins/plugin-sheet/src/
|
|
426
|
-
import { useContext as useContext2 } from "react";
|
|
427
|
-
import {
|
|
428
|
-
import {
|
|
429
|
-
|
|
430
|
-
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
431
|
-
import { lazy } from "react";
|
|
432
|
-
|
|
433
|
-
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
434
|
-
import React3, { useCallback as useCallback2, useMemo as useMemo3, useRef } from "react";
|
|
435
|
-
import { useAttention } from "@dxos/react-ui-attention";
|
|
436
|
-
import { Grid as Grid2, editorKeys, GridCellEditor, closestCell } from "@dxos/react-ui-grid";
|
|
278
|
+
// packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx
|
|
279
|
+
import React2, { createContext as createContext2, useCallback, useContext as useContext2, useState as useState2 } from "react";
|
|
280
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
281
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
282
|
+
import { Grid, useGridContext } from "@dxos/react-ui-grid";
|
|
437
283
|
|
|
438
|
-
// packages/plugins/plugin-sheet/src/
|
|
439
|
-
import {
|
|
440
|
-
import {
|
|
441
|
-
import {
|
|
442
|
-
import {
|
|
443
|
-
import {
|
|
444
|
-
|
|
445
|
-
|
|
284
|
+
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
285
|
+
import { Event } from "@dxos/async";
|
|
286
|
+
import { Resource } from "@dxos/context";
|
|
287
|
+
import { getTypename, FormatEnum, TypeEnum } from "@dxos/echo-schema";
|
|
288
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
289
|
+
import { PublicKey } from "@dxos/keys";
|
|
290
|
+
import { log } from "@dxos/log";
|
|
291
|
+
import { DetailedCellError, ExportedCellChange } from "#hyperformula";
|
|
292
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
293
|
+
var typeMap = {
|
|
294
|
+
BOOLEAN: {
|
|
295
|
+
type: TypeEnum.Boolean
|
|
296
|
+
},
|
|
297
|
+
NUMBER_RAW: {
|
|
298
|
+
type: TypeEnum.Number
|
|
299
|
+
},
|
|
300
|
+
NUMBER_PERCENT: {
|
|
301
|
+
type: TypeEnum.Number,
|
|
302
|
+
format: FormatEnum.Percent
|
|
303
|
+
},
|
|
304
|
+
NUMBER_CURRENCY: {
|
|
305
|
+
type: TypeEnum.Number,
|
|
306
|
+
format: FormatEnum.Currency
|
|
307
|
+
},
|
|
308
|
+
NUMBER_DATETIME: {
|
|
309
|
+
type: TypeEnum.String,
|
|
310
|
+
format: FormatEnum.DateTime
|
|
311
|
+
},
|
|
312
|
+
NUMBER_DATE: {
|
|
313
|
+
type: TypeEnum.String,
|
|
314
|
+
format: FormatEnum.Date
|
|
315
|
+
},
|
|
316
|
+
NUMBER_TIME: {
|
|
317
|
+
type: TypeEnum.String,
|
|
318
|
+
format: FormatEnum.Time
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var getTopLeft = (range) => {
|
|
322
|
+
const to = range.to ?? range.from;
|
|
446
323
|
return {
|
|
447
|
-
|
|
448
|
-
|
|
324
|
+
row: Math.min(range.from.row, to.row),
|
|
325
|
+
col: Math.min(range.from.col, to.col)
|
|
449
326
|
};
|
|
450
327
|
};
|
|
451
|
-
var
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
col,
|
|
480
|
-
row
|
|
481
|
-
};
|
|
482
|
-
const rawValue = model.getValue(address);
|
|
483
|
-
if (rawValue === void 0 || rawValue === null) {
|
|
328
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
329
|
+
sheet,
|
|
330
|
+
row: cell.row,
|
|
331
|
+
col: cell.col
|
|
332
|
+
});
|
|
333
|
+
var toModelRange = (sheet, range) => ({
|
|
334
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
335
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
336
|
+
});
|
|
337
|
+
var SheetModel = class extends Resource {
|
|
338
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
339
|
+
super();
|
|
340
|
+
this._graph = _graph;
|
|
341
|
+
this._sheet = _sheet;
|
|
342
|
+
this._options = _options;
|
|
343
|
+
this.id = `model-${PublicKey.random().truncate()}`;
|
|
344
|
+
this.update = new Event();
|
|
345
|
+
}
|
|
346
|
+
get graph() {
|
|
347
|
+
return this._graph;
|
|
348
|
+
}
|
|
349
|
+
get sheet() {
|
|
350
|
+
return this._sheet;
|
|
351
|
+
}
|
|
352
|
+
get readonly() {
|
|
353
|
+
return this._options.readonly;
|
|
354
|
+
}
|
|
355
|
+
get bounds() {
|
|
484
356
|
return {
|
|
485
|
-
|
|
357
|
+
rows: this._sheet.rows.length,
|
|
358
|
+
columns: this._sheet.columns.length
|
|
486
359
|
};
|
|
487
360
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
361
|
+
/**
|
|
362
|
+
* Initialize sheet and engine.
|
|
363
|
+
*/
|
|
364
|
+
async _open() {
|
|
365
|
+
log("initialize", {
|
|
366
|
+
id: this.id
|
|
367
|
+
}, {
|
|
368
|
+
F: __dxlog_file,
|
|
369
|
+
L: 113,
|
|
370
|
+
S: this,
|
|
371
|
+
C: (f, a) => f(...a)
|
|
372
|
+
});
|
|
373
|
+
initialize(this._sheet);
|
|
374
|
+
this._graph.update.on((event) => {
|
|
375
|
+
if (event.type === "functionsUpdated") {
|
|
376
|
+
this.reset();
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
this._node = this._graph.getOrCreateNode(createSheetName({
|
|
380
|
+
type: getTypename(this._sheet),
|
|
381
|
+
id: this._sheet.id
|
|
382
|
+
}));
|
|
383
|
+
await this._node.open();
|
|
384
|
+
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
385
|
+
this._ctx.onDispose(unsubscribe);
|
|
386
|
+
this.reset();
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Update engine.
|
|
390
|
+
* NOTE: This resets the undo history.
|
|
391
|
+
* @deprecated
|
|
392
|
+
*/
|
|
393
|
+
reset() {
|
|
394
|
+
invariant2(this._node, void 0, {
|
|
395
|
+
F: __dxlog_file,
|
|
396
|
+
L: 139,
|
|
397
|
+
S: this,
|
|
398
|
+
A: [
|
|
399
|
+
"this._node",
|
|
400
|
+
""
|
|
401
|
+
]
|
|
402
|
+
});
|
|
403
|
+
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
404
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
405
|
+
invariant2(this._node, void 0, {
|
|
406
|
+
F: __dxlog_file,
|
|
407
|
+
L: 142,
|
|
408
|
+
S: this,
|
|
409
|
+
A: [
|
|
410
|
+
"this._node",
|
|
411
|
+
""
|
|
412
|
+
]
|
|
508
413
|
});
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const getGridCells = gridCellGetter(model);
|
|
524
|
-
return (nextBounds, plane) => {
|
|
525
|
-
switch (plane) {
|
|
526
|
-
case "grid":
|
|
527
|
-
return getGridCells(nextBounds);
|
|
528
|
-
case "frozenColsStart":
|
|
529
|
-
return [
|
|
530
|
-
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
531
|
-
].reduce((acc, _, r0) => {
|
|
532
|
-
const r = nextBounds.start.row + r0;
|
|
533
|
-
acc[`0,${r}`] = rowLabelCell(r);
|
|
534
|
-
return acc;
|
|
535
|
-
}, {});
|
|
536
|
-
case "frozenRowsStart":
|
|
537
|
-
return [
|
|
538
|
-
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
539
|
-
].reduce((acc, _, c0) => {
|
|
540
|
-
const c = nextBounds.start.col + c0;
|
|
541
|
-
acc[`${c},0`] = colLabelCell(c);
|
|
542
|
-
return acc;
|
|
543
|
-
}, {});
|
|
544
|
-
default:
|
|
545
|
-
return {};
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
};
|
|
549
|
-
var useSheetModelDxGridProps = (dxGridRef, model) => {
|
|
550
|
-
const [columns, setColumns] = useState(createDxGridColumns(model));
|
|
551
|
-
const [rows, setRows] = useState(createDxGridColumns(model));
|
|
552
|
-
useLayoutEffect(() => {
|
|
553
|
-
const cellsAccessor = createDocAccessor(model.sheet, [
|
|
554
|
-
"cells"
|
|
555
|
-
]);
|
|
556
|
-
if (dxGridRef.current) {
|
|
557
|
-
dxGridRef.current.getCells = cellGetter(model);
|
|
558
|
-
}
|
|
559
|
-
const handleCellsUpdate = () => {
|
|
560
|
-
dxGridRef.current?.requestUpdate("initialCells");
|
|
561
|
-
};
|
|
562
|
-
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
563
|
-
return () => cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
564
|
-
}, [
|
|
565
|
-
model
|
|
566
|
-
]);
|
|
567
|
-
useEffect(() => {
|
|
568
|
-
const columnMetaAccessor = createDocAccessor(model.sheet, [
|
|
569
|
-
"columnMeta"
|
|
570
|
-
]);
|
|
571
|
-
const rowMetaAccessor = createDocAccessor(model.sheet, [
|
|
572
|
-
"rowMeta"
|
|
573
|
-
]);
|
|
574
|
-
const handleColumnMetaUpdate = () => {
|
|
575
|
-
setColumns(createDxGridColumns(model));
|
|
576
|
-
};
|
|
577
|
-
const handleRowMetaUpdate = () => {
|
|
578
|
-
setRows(createDxGridRows(model));
|
|
579
|
-
};
|
|
580
|
-
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
581
|
-
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
582
|
-
return () => {
|
|
583
|
-
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
584
|
-
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
585
|
-
};
|
|
586
|
-
}, [
|
|
587
|
-
model
|
|
588
|
-
]);
|
|
589
|
-
return {
|
|
590
|
-
columns,
|
|
591
|
-
rows
|
|
592
|
-
};
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
// packages/plugins/plugin-sheet/src/hooks/useSheetModel.ts
|
|
596
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
597
|
-
|
|
598
|
-
// packages/plugins/plugin-sheet/src/model/decorations.ts
|
|
599
|
-
import { create as create2 } from "@dxos/echo-schema";
|
|
600
|
-
var createDecorations = () => {
|
|
601
|
-
const { decorations } = create2({
|
|
602
|
-
decorations: {}
|
|
603
|
-
});
|
|
604
|
-
const addDecoration = (cellIndex, decorator) => {
|
|
605
|
-
decorations[cellIndex] = [
|
|
606
|
-
...decorations[cellIndex] || [],
|
|
607
|
-
decorator
|
|
608
|
-
];
|
|
609
|
-
};
|
|
610
|
-
const removeDecoration = (cellIndex, type) => {
|
|
611
|
-
if (type) {
|
|
612
|
-
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
613
|
-
} else {
|
|
614
|
-
delete decorations[cellIndex];
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
const getDecorationsForCell = (cellIndex) => {
|
|
618
|
-
return decorations[cellIndex];
|
|
619
|
-
};
|
|
620
|
-
const getAllDecorations = () => {
|
|
621
|
-
const result = [];
|
|
622
|
-
for (const decoratorArray of Object.values(decorations)) {
|
|
623
|
-
for (const decorator of decoratorArray) {
|
|
624
|
-
result.push(decorator);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
return result;
|
|
628
|
-
};
|
|
629
|
-
return {
|
|
630
|
-
addDecoration,
|
|
631
|
-
removeDecoration,
|
|
632
|
-
getDecorationsForCell,
|
|
633
|
-
getAllDecorations
|
|
634
|
-
};
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
638
|
-
import { Event } from "@dxos/async";
|
|
639
|
-
import { Resource } from "@dxos/context";
|
|
640
|
-
import { getTypename } from "@dxos/echo-schema";
|
|
641
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
642
|
-
import { PublicKey } from "@dxos/keys";
|
|
643
|
-
import { log } from "@dxos/log";
|
|
644
|
-
import { FieldValueType } from "@dxos/schema";
|
|
645
|
-
import { DetailedCellError, ExportedCellChange } from "#hyperformula";
|
|
646
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
647
|
-
var typeMap = {
|
|
648
|
-
BOOLEAN: FieldValueType.Boolean,
|
|
649
|
-
NUMBER_RAW: FieldValueType.Number,
|
|
650
|
-
NUMBER_PERCENT: FieldValueType.Percent,
|
|
651
|
-
NUMBER_CURRENCY: FieldValueType.Currency,
|
|
652
|
-
NUMBER_DATETIME: FieldValueType.DateTime,
|
|
653
|
-
NUMBER_DATE: FieldValueType.Date,
|
|
654
|
-
NUMBER_TIME: FieldValueType.Time
|
|
655
|
-
};
|
|
656
|
-
var getTopLeft = (range) => {
|
|
657
|
-
const to = range.to ?? range.from;
|
|
658
|
-
return {
|
|
659
|
-
row: Math.min(range.from.row, to.row),
|
|
660
|
-
col: Math.min(range.from.col, to.col)
|
|
661
|
-
};
|
|
662
|
-
};
|
|
663
|
-
var toSimpleCellAddress = (sheet, cell) => ({
|
|
664
|
-
sheet,
|
|
665
|
-
row: cell.row,
|
|
666
|
-
col: cell.col
|
|
667
|
-
});
|
|
668
|
-
var toModelRange = (sheet, range) => ({
|
|
669
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
670
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
671
|
-
});
|
|
672
|
-
var SheetModel = class extends Resource {
|
|
673
|
-
constructor(_graph, _sheet, _options = {}) {
|
|
674
|
-
super();
|
|
675
|
-
this._graph = _graph;
|
|
676
|
-
this._sheet = _sheet;
|
|
677
|
-
this._options = _options;
|
|
678
|
-
this.id = `model-${PublicKey.random().truncate()}`;
|
|
679
|
-
this.update = new Event();
|
|
680
|
-
}
|
|
681
|
-
get graph() {
|
|
682
|
-
return this._graph;
|
|
683
|
-
}
|
|
684
|
-
get sheet() {
|
|
685
|
-
return this._sheet;
|
|
686
|
-
}
|
|
687
|
-
get readonly() {
|
|
688
|
-
return this._options.readonly;
|
|
689
|
-
}
|
|
690
|
-
get bounds() {
|
|
691
|
-
return {
|
|
692
|
-
rows: this._sheet.rows.length,
|
|
693
|
-
columns: this._sheet.columns.length
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Initialize sheet and engine.
|
|
698
|
-
*/
|
|
699
|
-
async _open() {
|
|
700
|
-
log("initialize", {
|
|
701
|
-
id: this.id
|
|
702
|
-
}, {
|
|
703
|
-
F: __dxlog_file2,
|
|
704
|
-
L: 106,
|
|
705
|
-
S: this,
|
|
706
|
-
C: (f, a) => f(...a)
|
|
707
|
-
});
|
|
708
|
-
initialize(this._sheet);
|
|
709
|
-
this._node = this._graph.getOrCreateNode(createSheetName({
|
|
710
|
-
type: getTypename(this._sheet),
|
|
711
|
-
id: this._sheet.id
|
|
712
|
-
}));
|
|
713
|
-
await this._node.open();
|
|
714
|
-
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
715
|
-
this._ctx.onDispose(unsubscribe);
|
|
716
|
-
this.reset();
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Update engine.
|
|
720
|
-
* NOTE: This resets the undo history.
|
|
721
|
-
* @deprecated
|
|
722
|
-
*/
|
|
723
|
-
reset() {
|
|
724
|
-
invariant3(this._node, void 0, {
|
|
725
|
-
F: __dxlog_file2,
|
|
726
|
-
L: 126,
|
|
727
|
-
S: this,
|
|
728
|
-
A: [
|
|
729
|
-
"this._node",
|
|
730
|
-
""
|
|
731
|
-
]
|
|
732
|
-
});
|
|
733
|
-
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
734
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
735
|
-
invariant3(this._node, void 0, {
|
|
736
|
-
F: __dxlog_file2,
|
|
737
|
-
L: 129,
|
|
738
|
-
S: this,
|
|
739
|
-
A: [
|
|
740
|
-
"this._node",
|
|
741
|
-
""
|
|
742
|
-
]
|
|
743
|
-
});
|
|
744
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
745
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
746
|
-
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
747
|
-
}
|
|
748
|
-
this._node.graph.hf.setCellContents({
|
|
749
|
-
sheet: this._node.sheetId,
|
|
750
|
-
row,
|
|
751
|
-
col
|
|
752
|
-
}, value);
|
|
414
|
+
const { col, row } = addressFromIndex(this._sheet, key);
|
|
415
|
+
if (isFormula(value)) {
|
|
416
|
+
const binding = this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
417
|
+
if (binding) {
|
|
418
|
+
value = this._graph.mapFormulaToNative(binding);
|
|
419
|
+
} else {
|
|
420
|
+
value = "";
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
this._node.graph.hf.setCellContents({
|
|
424
|
+
sheet: this._node.sheetId,
|
|
425
|
+
row,
|
|
426
|
+
col
|
|
427
|
+
}, value);
|
|
753
428
|
});
|
|
754
429
|
}
|
|
755
430
|
/**
|
|
@@ -763,11 +438,79 @@ var SheetModel = class extends Resource {
|
|
|
763
438
|
this._node?.graph.hf.rebuildAndRecalculate();
|
|
764
439
|
}
|
|
765
440
|
insertRows(i, n = 1) {
|
|
766
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
441
|
+
const idx = insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
767
442
|
this.reset();
|
|
443
|
+
return idx;
|
|
768
444
|
}
|
|
769
445
|
insertColumns(i, n = 1) {
|
|
770
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
446
|
+
const idx = insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
447
|
+
this.reset();
|
|
448
|
+
return idx;
|
|
449
|
+
}
|
|
450
|
+
dropRow(rowIndex) {
|
|
451
|
+
const range = {
|
|
452
|
+
from: addressFromIndex(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
|
|
453
|
+
to: addressFromIndex(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
|
|
454
|
+
};
|
|
455
|
+
const values = this.getCellValues(range).flat();
|
|
456
|
+
const index = this._sheet.rows.indexOf(rowIndex);
|
|
457
|
+
this.clear(range);
|
|
458
|
+
this._sheet.rows.splice(index, 1);
|
|
459
|
+
delete this._sheet.rowMeta[rowIndex];
|
|
460
|
+
this.reset();
|
|
461
|
+
return {
|
|
462
|
+
axis: "row",
|
|
463
|
+
index,
|
|
464
|
+
axisIndex: rowIndex,
|
|
465
|
+
axisMeta: this._sheet.rowMeta[rowIndex],
|
|
466
|
+
values
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
dropColumn(colIndex) {
|
|
470
|
+
const range = {
|
|
471
|
+
from: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
|
|
472
|
+
to: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
|
|
473
|
+
};
|
|
474
|
+
const values = this.getCellValues(range).flat();
|
|
475
|
+
const index = this._sheet.columns.indexOf(colIndex);
|
|
476
|
+
this.clear(range);
|
|
477
|
+
this._sheet.columns.splice(index, 1);
|
|
478
|
+
delete this._sheet.columnMeta[colIndex];
|
|
479
|
+
this.reset();
|
|
480
|
+
return {
|
|
481
|
+
axis: "col",
|
|
482
|
+
index,
|
|
483
|
+
axisIndex: colIndex,
|
|
484
|
+
axisMeta: this._sheet.rowMeta[colIndex],
|
|
485
|
+
values
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
restoreRow({ index, axisIndex, axisMeta, values }) {
|
|
489
|
+
this._sheet.rows.splice(index, 0, axisIndex);
|
|
490
|
+
values.forEach((value, col) => {
|
|
491
|
+
if (value) {
|
|
492
|
+
this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
|
|
493
|
+
value
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
if (axisMeta) {
|
|
498
|
+
this._sheet.rowMeta[axisIndex] = axisMeta;
|
|
499
|
+
}
|
|
500
|
+
this.reset();
|
|
501
|
+
}
|
|
502
|
+
restoreColumn({ index, axisIndex, axisMeta, values }) {
|
|
503
|
+
this._sheet.columns.splice(index, 0, axisIndex);
|
|
504
|
+
values.forEach((value, row) => {
|
|
505
|
+
if (value) {
|
|
506
|
+
this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
|
|
507
|
+
value
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
if (axisMeta) {
|
|
512
|
+
this._sheet.columnMeta[axisIndex] = axisMeta;
|
|
513
|
+
}
|
|
771
514
|
this.reset();
|
|
772
515
|
}
|
|
773
516
|
//
|
|
@@ -778,9 +521,9 @@ var SheetModel = class extends Resource {
|
|
|
778
521
|
* Clear range of values.
|
|
779
522
|
*/
|
|
780
523
|
clear(range) {
|
|
781
|
-
|
|
782
|
-
F:
|
|
783
|
-
L:
|
|
524
|
+
invariant2(this._node, void 0, {
|
|
525
|
+
F: __dxlog_file,
|
|
526
|
+
L: 245,
|
|
784
527
|
S: this,
|
|
785
528
|
A: [
|
|
786
529
|
"this._node",
|
|
@@ -796,9 +539,9 @@ var SheetModel = class extends Resource {
|
|
|
796
539
|
});
|
|
797
540
|
}
|
|
798
541
|
cut(range) {
|
|
799
|
-
|
|
800
|
-
F:
|
|
801
|
-
L:
|
|
542
|
+
invariant2(this._node, void 0, {
|
|
543
|
+
F: __dxlog_file,
|
|
544
|
+
L: 256,
|
|
802
545
|
S: this,
|
|
803
546
|
A: [
|
|
804
547
|
"this._node",
|
|
@@ -812,9 +555,9 @@ var SheetModel = class extends Resource {
|
|
|
812
555
|
});
|
|
813
556
|
}
|
|
814
557
|
copy(range) {
|
|
815
|
-
|
|
816
|
-
F:
|
|
817
|
-
L:
|
|
558
|
+
invariant2(this._node, void 0, {
|
|
559
|
+
F: __dxlog_file,
|
|
560
|
+
L: 265,
|
|
818
561
|
S: this,
|
|
819
562
|
A: [
|
|
820
563
|
"this._node",
|
|
@@ -824,9 +567,9 @@ var SheetModel = class extends Resource {
|
|
|
824
567
|
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
825
568
|
}
|
|
826
569
|
paste(cell) {
|
|
827
|
-
|
|
828
|
-
F:
|
|
829
|
-
L:
|
|
570
|
+
invariant2(this._node, void 0, {
|
|
571
|
+
F: __dxlog_file,
|
|
572
|
+
L: 270,
|
|
830
573
|
S: this,
|
|
831
574
|
A: [
|
|
832
575
|
"this._node",
|
|
@@ -851,9 +594,9 @@ var SheetModel = class extends Resource {
|
|
|
851
594
|
}
|
|
852
595
|
// TODO(burdon): Display undo/redo state.
|
|
853
596
|
undo() {
|
|
854
|
-
|
|
855
|
-
F:
|
|
856
|
-
L:
|
|
597
|
+
invariant2(this._node, void 0, {
|
|
598
|
+
F: __dxlog_file,
|
|
599
|
+
L: 285,
|
|
857
600
|
S: this,
|
|
858
601
|
A: [
|
|
859
602
|
"this._node",
|
|
@@ -865,9 +608,9 @@ var SheetModel = class extends Resource {
|
|
|
865
608
|
}
|
|
866
609
|
}
|
|
867
610
|
redo() {
|
|
868
|
-
|
|
869
|
-
F:
|
|
870
|
-
L:
|
|
611
|
+
invariant2(this._node, void 0, {
|
|
612
|
+
F: __dxlog_file,
|
|
613
|
+
L: 293,
|
|
871
614
|
S: this,
|
|
872
615
|
A: [
|
|
873
616
|
"this._node",
|
|
@@ -893,7 +636,7 @@ var SheetModel = class extends Resource {
|
|
|
893
636
|
if (value == null) {
|
|
894
637
|
return void 0;
|
|
895
638
|
}
|
|
896
|
-
if (
|
|
639
|
+
if (isFormula(value)) {
|
|
897
640
|
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
898
641
|
} else {
|
|
899
642
|
return String(value);
|
|
@@ -909,17 +652,27 @@ var SheetModel = class extends Resource {
|
|
|
909
652
|
* Gets the regular or computed value from the engine.
|
|
910
653
|
*/
|
|
911
654
|
getValue(cell) {
|
|
912
|
-
|
|
913
|
-
F:
|
|
914
|
-
L:
|
|
655
|
+
invariant2(this._node, void 0, {
|
|
656
|
+
F: __dxlog_file,
|
|
657
|
+
L: 336,
|
|
915
658
|
S: this,
|
|
916
659
|
A: [
|
|
917
660
|
"this._node",
|
|
918
661
|
""
|
|
919
662
|
]
|
|
920
663
|
});
|
|
921
|
-
const
|
|
664
|
+
const address = toSimpleCellAddress(this._node.sheetId, cell);
|
|
665
|
+
const value = this._node.graph.hf.getCellValue(address);
|
|
922
666
|
if (value instanceof DetailedCellError) {
|
|
667
|
+
log.info("cell error", {
|
|
668
|
+
cell,
|
|
669
|
+
error: value
|
|
670
|
+
}, {
|
|
671
|
+
F: __dxlog_file,
|
|
672
|
+
L: 341,
|
|
673
|
+
S: this,
|
|
674
|
+
C: (f, a) => f(...a)
|
|
675
|
+
});
|
|
923
676
|
return value.toString();
|
|
924
677
|
}
|
|
925
678
|
return value;
|
|
@@ -927,10 +680,10 @@ var SheetModel = class extends Resource {
|
|
|
927
680
|
/**
|
|
928
681
|
* Get value type.
|
|
929
682
|
*/
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
F:
|
|
933
|
-
L:
|
|
683
|
+
getValueDescription(cell) {
|
|
684
|
+
invariant2(this._node, void 0, {
|
|
685
|
+
F: __dxlog_file,
|
|
686
|
+
L: 352,
|
|
934
687
|
S: this,
|
|
935
688
|
A: [
|
|
936
689
|
"this._node",
|
|
@@ -945,9 +698,9 @@ var SheetModel = class extends Resource {
|
|
|
945
698
|
* Sets the value, updating the sheet and engine.
|
|
946
699
|
*/
|
|
947
700
|
setValue(cell, value) {
|
|
948
|
-
|
|
949
|
-
F:
|
|
950
|
-
L:
|
|
701
|
+
invariant2(this._node, void 0, {
|
|
702
|
+
F: __dxlog_file,
|
|
703
|
+
L: 362,
|
|
951
704
|
S: this,
|
|
952
705
|
A: [
|
|
953
706
|
"this._node",
|
|
@@ -975,14 +728,14 @@ var SheetModel = class extends Resource {
|
|
|
975
728
|
col: cell.col
|
|
976
729
|
}, [
|
|
977
730
|
[
|
|
978
|
-
|
|
731
|
+
isFormula(value) ? this._graph.mapFormulaToNative(value) : value
|
|
979
732
|
]
|
|
980
733
|
]);
|
|
981
734
|
const idx = addressToIndex(this._sheet, cell);
|
|
982
735
|
if (value === void 0 || value === null) {
|
|
983
736
|
delete this._sheet.cells[idx];
|
|
984
737
|
} else {
|
|
985
|
-
if (
|
|
738
|
+
if (isFormula(value)) {
|
|
986
739
|
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
987
740
|
}
|
|
988
741
|
this._sheet.cells[idx] = {
|
|
@@ -1042,12 +795,12 @@ var SheetModel = class extends Resource {
|
|
|
1042
795
|
* Map from A1 notation to indices.
|
|
1043
796
|
*/
|
|
1044
797
|
mapFormulaRefsToIndices(formula) {
|
|
1045
|
-
|
|
1046
|
-
F:
|
|
1047
|
-
L:
|
|
798
|
+
invariant2(isFormula(formula), void 0, {
|
|
799
|
+
F: __dxlog_file,
|
|
800
|
+
L: 451,
|
|
1048
801
|
S: this,
|
|
1049
802
|
A: [
|
|
1050
|
-
"formula
|
|
803
|
+
"isFormula(formula)",
|
|
1051
804
|
""
|
|
1052
805
|
]
|
|
1053
806
|
});
|
|
@@ -1059,12 +812,12 @@ var SheetModel = class extends Resource {
|
|
|
1059
812
|
* Map from indices to A1 notation.
|
|
1060
813
|
*/
|
|
1061
814
|
mapFormulaIndicesToRefs(formula) {
|
|
1062
|
-
|
|
1063
|
-
F:
|
|
1064
|
-
L:
|
|
815
|
+
invariant2(isFormula(formula), void 0, {
|
|
816
|
+
F: __dxlog_file,
|
|
817
|
+
L: 461,
|
|
1065
818
|
S: this,
|
|
1066
819
|
A: [
|
|
1067
|
-
"formula
|
|
820
|
+
"isFormula(formula)",
|
|
1068
821
|
""
|
|
1069
822
|
]
|
|
1070
823
|
});
|
|
@@ -1085,9 +838,9 @@ var SheetModel = class extends Resource {
|
|
|
1085
838
|
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1086
839
|
}
|
|
1087
840
|
toDateTime(num) {
|
|
1088
|
-
|
|
1089
|
-
F:
|
|
1090
|
-
L:
|
|
841
|
+
invariant2(this._node, void 0, {
|
|
842
|
+
F: __dxlog_file,
|
|
843
|
+
L: 482,
|
|
1091
844
|
S: this,
|
|
1092
845
|
A: [
|
|
1093
846
|
"this._node",
|
|
@@ -1097,9 +850,9 @@ var SheetModel = class extends Resource {
|
|
|
1097
850
|
return this._node.graph.hf.numberToDateTime(num);
|
|
1098
851
|
}
|
|
1099
852
|
toDate(num) {
|
|
1100
|
-
|
|
1101
|
-
F:
|
|
1102
|
-
L:
|
|
853
|
+
invariant2(this._node, void 0, {
|
|
854
|
+
F: __dxlog_file,
|
|
855
|
+
L: 487,
|
|
1103
856
|
S: this,
|
|
1104
857
|
A: [
|
|
1105
858
|
"this._node",
|
|
@@ -1109,9 +862,9 @@ var SheetModel = class extends Resource {
|
|
|
1109
862
|
return this._node.graph.hf.numberToDate(num);
|
|
1110
863
|
}
|
|
1111
864
|
toTime(num) {
|
|
1112
|
-
|
|
1113
|
-
F:
|
|
1114
|
-
L:
|
|
865
|
+
invariant2(this._node, void 0, {
|
|
866
|
+
F: __dxlog_file,
|
|
867
|
+
L: 492,
|
|
1115
868
|
S: this,
|
|
1116
869
|
A: [
|
|
1117
870
|
"this._node",
|
|
@@ -1122,10 +875,11 @@ var SheetModel = class extends Resource {
|
|
|
1122
875
|
}
|
|
1123
876
|
};
|
|
1124
877
|
|
|
1125
|
-
// packages/plugins/plugin-sheet/src/
|
|
878
|
+
// packages/plugins/plugin-sheet/src/model/useSheetModel.ts
|
|
879
|
+
import { useEffect, useState } from "react";
|
|
1126
880
|
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1127
|
-
const [model, setModel] =
|
|
1128
|
-
|
|
881
|
+
const [model, setModel] = useState();
|
|
882
|
+
useEffect(() => {
|
|
1129
883
|
if (!graph || !sheet) {
|
|
1130
884
|
return;
|
|
1131
885
|
}
|
|
@@ -1149,153 +903,46 @@ var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
|
1149
903
|
return model;
|
|
1150
904
|
};
|
|
1151
905
|
|
|
1152
|
-
// packages/plugins/plugin-sheet/src/
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
...cellAddress,
|
|
1168
|
-
plane: "grid"
|
|
1169
|
-
}, true);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
}, [
|
|
1173
|
-
model.sheet
|
|
1174
|
-
]);
|
|
1175
|
-
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
906
|
+
// packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx
|
|
907
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
908
|
+
var SheetContext = /* @__PURE__ */ createContext2(void 0);
|
|
909
|
+
var useSheetContext = () => {
|
|
910
|
+
const context = useContext2(SheetContext);
|
|
911
|
+
invariant3(context, void 0, {
|
|
912
|
+
F: __dxlog_file2,
|
|
913
|
+
L: 52,
|
|
914
|
+
S: void 0,
|
|
915
|
+
A: [
|
|
916
|
+
"context",
|
|
917
|
+
""
|
|
918
|
+
]
|
|
919
|
+
});
|
|
920
|
+
return context;
|
|
1176
921
|
};
|
|
1177
|
-
var
|
|
1178
|
-
const
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
]);
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
1192
|
-
if (closestThreadAnchor) {
|
|
1193
|
-
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
1194
|
-
if (closestThread) {
|
|
1195
|
-
void dispatch([
|
|
1196
|
-
{
|
|
1197
|
-
action: "dxos.org/plugin/thread/action/select",
|
|
1198
|
-
data: {
|
|
1199
|
-
current: fullyQualifiedId(closestThread)
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
]);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
922
|
+
var SheetProviderImpl = ({ model, onInfo, children, __gridScope }) => {
|
|
923
|
+
const { id, editing, setEditing } = useGridContext("SheetProvider", __gridScope);
|
|
924
|
+
const [cursor, setCursorInternal] = useState2();
|
|
925
|
+
const [range, setRangeInternal] = useState2();
|
|
926
|
+
const [cursorFallbackRange, setCursorFallbackRange] = useState2();
|
|
927
|
+
const [activeRefs, setActiveRefs] = useState2("");
|
|
928
|
+
const setCursor = useCallback((nextCursor) => {
|
|
929
|
+
setCursorInternal(nextCursor);
|
|
930
|
+
setCursorFallbackRange(range?.to ? range : nextCursor ? {
|
|
931
|
+
from: nextCursor,
|
|
932
|
+
to: nextCursor
|
|
933
|
+
} : void 0);
|
|
1205
934
|
}, [
|
|
1206
|
-
|
|
1207
|
-
activeThreads,
|
|
1208
|
-
activeThreadAddresses,
|
|
1209
|
-
model.sheet
|
|
935
|
+
range
|
|
1210
936
|
]);
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
if (!cursor) {
|
|
1218
|
-
return;
|
|
1219
|
-
}
|
|
1220
|
-
debounced(cursor);
|
|
937
|
+
const setRange = useCallback((nextRange) => {
|
|
938
|
+
setRangeInternal(nextRange);
|
|
939
|
+
setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
|
|
940
|
+
from: cursor,
|
|
941
|
+
to: cursor
|
|
942
|
+
} : void 0);
|
|
1221
943
|
}, [
|
|
1222
|
-
cursor
|
|
1223
|
-
selectClosestThread
|
|
1224
|
-
]);
|
|
1225
|
-
};
|
|
1226
|
-
var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
1227
|
-
return {
|
|
1228
|
-
type: "comment",
|
|
1229
|
-
classNames: [
|
|
1230
|
-
"bg-greenFill"
|
|
1231
|
-
],
|
|
1232
|
-
cellIndex
|
|
1233
|
-
};
|
|
1234
|
-
};
|
|
1235
|
-
var useThreadDecorations = (model, decorations) => {
|
|
1236
|
-
const sheet = useMemo(() => model.sheet, [
|
|
1237
|
-
model.sheet
|
|
1238
|
-
]);
|
|
1239
|
-
const sheetId = useMemo(() => fullyQualifiedId(sheet), [
|
|
1240
|
-
sheet
|
|
944
|
+
cursor
|
|
1241
945
|
]);
|
|
1242
|
-
useEffect3(() => {
|
|
1243
|
-
const unsubscribe = effect(() => {
|
|
1244
|
-
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
1245
|
-
if (!sheet.threads) {
|
|
1246
|
-
return;
|
|
1247
|
-
}
|
|
1248
|
-
for (const thread of sheet.threads) {
|
|
1249
|
-
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1250
|
-
continue;
|
|
1251
|
-
}
|
|
1252
|
-
activeThreadAnchors.add(thread.anchor);
|
|
1253
|
-
const index = thread.anchor;
|
|
1254
|
-
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1255
|
-
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1256
|
-
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
for (const decoration of decorations.getAllDecorations()) {
|
|
1260
|
-
if (decoration.type !== "comment") {
|
|
1261
|
-
continue;
|
|
1262
|
-
}
|
|
1263
|
-
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1264
|
-
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
});
|
|
1268
|
-
return () => unsubscribe();
|
|
1269
|
-
});
|
|
1270
|
-
};
|
|
1271
|
-
|
|
1272
|
-
// packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx
|
|
1273
|
-
import React2, { createContext as createContext2, useContext, useMemo as useMemo2, useState as useState3 } from "react";
|
|
1274
|
-
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1275
|
-
import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
|
|
1276
|
-
import { Grid, useGridContext } from "@dxos/react-ui-grid";
|
|
1277
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
1278
|
-
var SheetContext = /* @__PURE__ */ createContext2(void 0);
|
|
1279
|
-
var useSheetContext = () => {
|
|
1280
|
-
const context = useContext(SheetContext);
|
|
1281
|
-
invariant4(context, void 0, {
|
|
1282
|
-
F: __dxlog_file3,
|
|
1283
|
-
L: 45,
|
|
1284
|
-
S: void 0,
|
|
1285
|
-
A: [
|
|
1286
|
-
"context",
|
|
1287
|
-
""
|
|
1288
|
-
]
|
|
1289
|
-
});
|
|
1290
|
-
return context;
|
|
1291
|
-
};
|
|
1292
|
-
var SheetProviderImpl = ({ model, onInfo, children, __gridScope }) => {
|
|
1293
|
-
const { id, editing, setEditing } = useGridContext("SheetProvider", __gridScope);
|
|
1294
|
-
const decorations = useMemo2(() => createDecorations(), []);
|
|
1295
|
-
const [cursor, setCursor] = useState3();
|
|
1296
|
-
const [range, setRange] = useState3();
|
|
1297
|
-
useSelectThreadOnCellFocus(model, cursor);
|
|
1298
|
-
useThreadDecorations(model, decorations);
|
|
1299
946
|
return /* @__PURE__ */ React2.createElement(SheetContext.Provider, {
|
|
1300
947
|
value: {
|
|
1301
948
|
id,
|
|
@@ -1306,9 +953,11 @@ var SheetProviderImpl = ({ model, onInfo, children, __gridScope }) => {
|
|
|
1306
953
|
setCursor,
|
|
1307
954
|
range,
|
|
1308
955
|
setRange,
|
|
956
|
+
cursorFallbackRange,
|
|
957
|
+
activeRefs,
|
|
958
|
+
setActiveRefs,
|
|
1309
959
|
// TODO(burdon): Change to event.
|
|
1310
|
-
onInfo
|
|
1311
|
-
decorations
|
|
960
|
+
onInfo
|
|
1312
961
|
}
|
|
1313
962
|
}, children);
|
|
1314
963
|
};
|
|
@@ -1317,7 +966,7 @@ var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
|
1317
966
|
readonly
|
|
1318
967
|
});
|
|
1319
968
|
return !model ? null : /* @__PURE__ */ React2.createElement(Grid.Root, {
|
|
1320
|
-
id:
|
|
969
|
+
id: fullyQualifiedId(sheet)
|
|
1321
970
|
}, /* @__PURE__ */ React2.createElement(SheetProviderImpl, {
|
|
1322
971
|
model,
|
|
1323
972
|
onInfo
|
|
@@ -1325,6 +974,337 @@ var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
|
1325
974
|
};
|
|
1326
975
|
|
|
1327
976
|
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
977
|
+
import React4, { useCallback as useCallback4, useMemo as useMemo2, useRef, useState as useState4 } from "react";
|
|
978
|
+
import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
979
|
+
import { DropdownMenu, Icon, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
980
|
+
import { useAttention } from "@dxos/react-ui-attention";
|
|
981
|
+
import { closestCell, defaultSizeRow, editorKeys, Grid as Grid2, GridCellEditor } from "@dxos/react-ui-grid";
|
|
982
|
+
|
|
983
|
+
// packages/plugins/plugin-sheet/src/components/GridSheet/util.ts
|
|
984
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
985
|
+
import { createDocAccessor, fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
|
|
986
|
+
import { parseValue, cellClassesForFieldType } from "@dxos/react-ui-data";
|
|
987
|
+
import { colToA1Notation, rowToA1Notation, commentedClassName } from "@dxos/react-ui-grid";
|
|
988
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
989
|
+
|
|
990
|
+
// packages/plugins/plugin-sheet/src/integrations/thread-ranges.ts
|
|
991
|
+
import { useCallback as useCallback3, useEffect as useEffect2, useMemo } from "react";
|
|
992
|
+
import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
|
|
993
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
994
|
+
import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
|
|
995
|
+
|
|
996
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
997
|
+
import { lazy } from "react";
|
|
998
|
+
|
|
999
|
+
// packages/plugins/plugin-sheet/src/components/RangeList/RangeList.tsx
|
|
1000
|
+
import React3, { useCallback as useCallback2 } from "react";
|
|
1001
|
+
import { S } from "@dxos/echo-schema";
|
|
1002
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
1003
|
+
import { List } from "@dxos/react-ui-list";
|
|
1004
|
+
import { ghostHover } from "@dxos/react-ui-theme";
|
|
1005
|
+
var RangeList = ({ sheet }) => {
|
|
1006
|
+
const { t } = useTranslation(SHEET_PLUGIN);
|
|
1007
|
+
const handleSelectRange = (range) => {
|
|
1008
|
+
};
|
|
1009
|
+
const handleDeleteRange = useCallback2((range) => {
|
|
1010
|
+
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
1011
|
+
sheet.ranges.splice(index, 1);
|
|
1012
|
+
}, [
|
|
1013
|
+
sheet
|
|
1014
|
+
]);
|
|
1015
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("h2", {
|
|
1016
|
+
className: "p-2 text-sm font-semibold"
|
|
1017
|
+
}, t("range list heading")), /* @__PURE__ */ React3.createElement(List.Root, {
|
|
1018
|
+
items: sheet.ranges,
|
|
1019
|
+
isItem: S.is(Range)
|
|
1020
|
+
}, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ React3.createElement(List.Item, {
|
|
1021
|
+
key: i,
|
|
1022
|
+
item: range,
|
|
1023
|
+
classNames: [
|
|
1024
|
+
"p-2",
|
|
1025
|
+
ghostHover
|
|
1026
|
+
]
|
|
1027
|
+
}, /* @__PURE__ */ React3.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React3.createElement(List.ItemTitle, {
|
|
1028
|
+
onClick: () => handleSelectRange(range)
|
|
1029
|
+
}, t("range title", {
|
|
1030
|
+
position: rangeToA1Notation(rangeFromIndex(sheet, range.range)),
|
|
1031
|
+
key: t(`range key ${range.key} label`),
|
|
1032
|
+
value: t(`range value ${range.value} label`)
|
|
1033
|
+
})), /* @__PURE__ */ React3.createElement(List.ItemDeleteButton, {
|
|
1034
|
+
onClick: () => handleDeleteRange(range)
|
|
1035
|
+
})))));
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
1039
|
+
var SheetContainer = lazy(() => import("./SheetContainer-P3NF5KEI.mjs"));
|
|
1040
|
+
|
|
1041
|
+
// packages/plugins/plugin-sheet/src/integrations/thread-ranges.ts
|
|
1042
|
+
var completeCellRangeToThreadCursor = (range) => {
|
|
1043
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
1044
|
+
};
|
|
1045
|
+
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
1046
|
+
const coords = cursor.split(",");
|
|
1047
|
+
if (coords.length !== 4) {
|
|
1048
|
+
return null;
|
|
1049
|
+
} else {
|
|
1050
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
1051
|
+
return {
|
|
1052
|
+
from: {
|
|
1053
|
+
col: parseInt(fromCol),
|
|
1054
|
+
row: parseInt(fromRow)
|
|
1055
|
+
},
|
|
1056
|
+
to: {
|
|
1057
|
+
col: parseInt(toCol),
|
|
1058
|
+
row: parseInt(toRow)
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
1064
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
1065
|
+
const handleScrollIntoView = useCallback3(({ action, data }) => {
|
|
1066
|
+
switch (action) {
|
|
1067
|
+
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
1068
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId2(model.sheet)) {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
setActiveRefs(data.thread);
|
|
1072
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
1073
|
+
range && grid?.setFocus({
|
|
1074
|
+
...range.to,
|
|
1075
|
+
plane: "grid"
|
|
1076
|
+
}, true);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}, [
|
|
1080
|
+
model.sheet,
|
|
1081
|
+
setActiveRefs
|
|
1082
|
+
]);
|
|
1083
|
+
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
1084
|
+
};
|
|
1085
|
+
var useSelectThreadOnCellFocus = () => {
|
|
1086
|
+
const { model, cursor } = useSheetContext();
|
|
1087
|
+
const dispatch = useIntentDispatcher();
|
|
1088
|
+
const threads = useMemo(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
|
|
1089
|
+
// TODO(thure): Surely we can find a better dependency for this…
|
|
1090
|
+
JSON.stringify(model.sheet.threads)
|
|
1091
|
+
]);
|
|
1092
|
+
const selectClosestThread = useCallback3((cellAddress) => {
|
|
1093
|
+
if (!cellAddress || !threads) {
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
1097
|
+
if (anchor) {
|
|
1098
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
1099
|
+
return range ? inRange(range, cellAddress) : false;
|
|
1100
|
+
} else {
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
if (closestThread) {
|
|
1105
|
+
void dispatch([
|
|
1106
|
+
{
|
|
1107
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
1108
|
+
data: {
|
|
1109
|
+
current: fullyQualifiedId2(closestThread)
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
]);
|
|
1113
|
+
}
|
|
1114
|
+
}, [
|
|
1115
|
+
dispatch,
|
|
1116
|
+
threads
|
|
1117
|
+
]);
|
|
1118
|
+
const debounced = useMemo(() => {
|
|
1119
|
+
return debounce2((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
1120
|
+
}, [
|
|
1121
|
+
selectClosestThread
|
|
1122
|
+
]);
|
|
1123
|
+
useEffect2(() => {
|
|
1124
|
+
if (!cursor) {
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
debounced(cursor);
|
|
1128
|
+
}, [
|
|
1129
|
+
cursor,
|
|
1130
|
+
debounced
|
|
1131
|
+
]);
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
// packages/plugins/plugin-sheet/src/components/GridSheet/util.ts
|
|
1135
|
+
var dxGridCellIndexToSheetCellAddress = (index) => {
|
|
1136
|
+
const [colStr, rowStr] = index.split(",");
|
|
1137
|
+
return {
|
|
1138
|
+
col: parseInt(colStr),
|
|
1139
|
+
row: parseInt(rowStr)
|
|
1140
|
+
};
|
|
1141
|
+
};
|
|
1142
|
+
var createDxGridColumns = (model) => {
|
|
1143
|
+
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
1144
|
+
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
1145
|
+
acc.grid[numericIndex] = {
|
|
1146
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
1147
|
+
resizeable: true
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
return acc;
|
|
1151
|
+
}, {
|
|
1152
|
+
grid: {}
|
|
1153
|
+
});
|
|
1154
|
+
};
|
|
1155
|
+
var createDxGridRows = (model) => {
|
|
1156
|
+
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
1157
|
+
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
1158
|
+
acc.grid[numericIndex] = {
|
|
1159
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
1160
|
+
resizeable: true
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
return acc;
|
|
1164
|
+
}, {
|
|
1165
|
+
grid: {}
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
var projectCellProps = (model, col, row) => {
|
|
1169
|
+
const address = {
|
|
1170
|
+
col,
|
|
1171
|
+
row
|
|
1172
|
+
};
|
|
1173
|
+
const rawValue = model.getValue(address);
|
|
1174
|
+
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(rangeFromIndex(model.sheet, range), address));
|
|
1175
|
+
const threadRefs = model.sheet.threads?.filter((thread) => {
|
|
1176
|
+
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
|
|
1177
|
+
return thread && range ? inRange(range, address) : false;
|
|
1178
|
+
}).map((thread) => fullyQualifiedId3(thread)).join(" ");
|
|
1179
|
+
const description = model.getValueDescription(address);
|
|
1180
|
+
const type = description?.type;
|
|
1181
|
+
const format = description?.format;
|
|
1182
|
+
const classNames = ranges?.map(cellClassNameForRange).reverse();
|
|
1183
|
+
return {
|
|
1184
|
+
value: parseValue({
|
|
1185
|
+
type,
|
|
1186
|
+
format,
|
|
1187
|
+
value: rawValue
|
|
1188
|
+
}),
|
|
1189
|
+
className: mx2(cellClassesForFieldType({
|
|
1190
|
+
type,
|
|
1191
|
+
format
|
|
1192
|
+
}), threadRefs && commentedClassName, classNames),
|
|
1193
|
+
dataRefs: threadRefs
|
|
1194
|
+
};
|
|
1195
|
+
};
|
|
1196
|
+
var gridCellGetter = (model) => {
|
|
1197
|
+
const cachedGridCells = {};
|
|
1198
|
+
return (nextBounds) => {
|
|
1199
|
+
[
|
|
1200
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1201
|
+
].forEach((_, c0) => {
|
|
1202
|
+
return [
|
|
1203
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1204
|
+
].forEach((_2, r0) => {
|
|
1205
|
+
const col = nextBounds.start.col + c0;
|
|
1206
|
+
const row = nextBounds.start.row + r0;
|
|
1207
|
+
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
1208
|
+
});
|
|
1209
|
+
});
|
|
1210
|
+
return cachedGridCells;
|
|
1211
|
+
};
|
|
1212
|
+
};
|
|
1213
|
+
var rowLabelCell = (row) => ({
|
|
1214
|
+
value: rowToA1Notation(row),
|
|
1215
|
+
className: "text-end !pie-1 text-subdued",
|
|
1216
|
+
resizeHandle: "row"
|
|
1217
|
+
});
|
|
1218
|
+
var colLabelCell = (col) => ({
|
|
1219
|
+
value: colToA1Notation(col),
|
|
1220
|
+
className: "text-subdued",
|
|
1221
|
+
resizeHandle: "col"
|
|
1222
|
+
});
|
|
1223
|
+
var cellGetter = (model) => {
|
|
1224
|
+
const getGridCells = gridCellGetter(model);
|
|
1225
|
+
return (nextBounds, plane) => {
|
|
1226
|
+
switch (plane) {
|
|
1227
|
+
case "grid":
|
|
1228
|
+
return getGridCells(nextBounds);
|
|
1229
|
+
case "frozenColsStart":
|
|
1230
|
+
return [
|
|
1231
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1232
|
+
].reduce((acc, _, r0) => {
|
|
1233
|
+
const r = nextBounds.start.row + r0;
|
|
1234
|
+
acc[`0,${r}`] = rowLabelCell(r);
|
|
1235
|
+
return acc;
|
|
1236
|
+
}, {});
|
|
1237
|
+
case "frozenRowsStart":
|
|
1238
|
+
return [
|
|
1239
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1240
|
+
].reduce((acc, _, c0) => {
|
|
1241
|
+
const c = nextBounds.start.col + c0;
|
|
1242
|
+
acc[`${c},0`] = colLabelCell(c);
|
|
1243
|
+
return acc;
|
|
1244
|
+
}, {});
|
|
1245
|
+
default:
|
|
1246
|
+
return {};
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
};
|
|
1250
|
+
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1251
|
+
const [columns, setColumns] = useState3(createDxGridColumns(model));
|
|
1252
|
+
const [rows, setRows] = useState3(createDxGridRows(model));
|
|
1253
|
+
useEffect3(() => {
|
|
1254
|
+
const cellsAccessor = createDocAccessor(model.sheet, [
|
|
1255
|
+
"cells"
|
|
1256
|
+
]);
|
|
1257
|
+
if (dxGrid) {
|
|
1258
|
+
dxGrid.getCells = cellGetter(model);
|
|
1259
|
+
}
|
|
1260
|
+
const handleCellsUpdate = () => {
|
|
1261
|
+
dxGrid?.requestUpdate("initialCells");
|
|
1262
|
+
};
|
|
1263
|
+
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1264
|
+
const unsubscribe = model.graph.update.on(handleCellsUpdate);
|
|
1265
|
+
return () => {
|
|
1266
|
+
cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1267
|
+
unsubscribe();
|
|
1268
|
+
};
|
|
1269
|
+
}, [
|
|
1270
|
+
model,
|
|
1271
|
+
dxGrid
|
|
1272
|
+
]);
|
|
1273
|
+
useEffect3(() => {
|
|
1274
|
+
const columnMetaAccessor = createDocAccessor(model.sheet, [
|
|
1275
|
+
"columnMeta"
|
|
1276
|
+
]);
|
|
1277
|
+
const rowMetaAccessor = createDocAccessor(model.sheet, [
|
|
1278
|
+
"rowMeta"
|
|
1279
|
+
]);
|
|
1280
|
+
const handleColumnMetaUpdate = () => {
|
|
1281
|
+
setColumns(createDxGridColumns(model));
|
|
1282
|
+
};
|
|
1283
|
+
const handleRowMetaUpdate = () => {
|
|
1284
|
+
setRows(createDxGridRows(model));
|
|
1285
|
+
};
|
|
1286
|
+
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1287
|
+
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1288
|
+
return () => {
|
|
1289
|
+
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1290
|
+
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1291
|
+
};
|
|
1292
|
+
}, [
|
|
1293
|
+
model,
|
|
1294
|
+
dxGrid
|
|
1295
|
+
]);
|
|
1296
|
+
return {
|
|
1297
|
+
columns,
|
|
1298
|
+
rows
|
|
1299
|
+
};
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
1303
|
+
var inertPosition = {
|
|
1304
|
+
plane: "grid",
|
|
1305
|
+
col: 0,
|
|
1306
|
+
row: 0
|
|
1307
|
+
};
|
|
1328
1308
|
var initialCells = {
|
|
1329
1309
|
grid: {},
|
|
1330
1310
|
frozenColsStart: [
|
|
@@ -1346,11 +1326,11 @@ var frozen = {
|
|
|
1346
1326
|
};
|
|
1347
1327
|
var sheetRowDefault = {
|
|
1348
1328
|
frozenRowsStart: {
|
|
1349
|
-
size:
|
|
1329
|
+
size: defaultSizeRow,
|
|
1350
1330
|
readonly: true
|
|
1351
1331
|
},
|
|
1352
1332
|
grid: {
|
|
1353
|
-
size:
|
|
1333
|
+
size: defaultSizeRow,
|
|
1354
1334
|
resizeable: true
|
|
1355
1335
|
}
|
|
1356
1336
|
};
|
|
@@ -1365,48 +1345,65 @@ var sheetColDefault = {
|
|
|
1365
1345
|
}
|
|
1366
1346
|
};
|
|
1367
1347
|
var GridSheet = () => {
|
|
1368
|
-
const {
|
|
1369
|
-
const
|
|
1370
|
-
const
|
|
1348
|
+
const { t } = useTranslation2(SHEET_PLUGIN);
|
|
1349
|
+
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
|
|
1350
|
+
const [dxGrid, setDxGrid] = useState4(null);
|
|
1351
|
+
const [extraplanarFocus, setExtraplanarFocus] = useState4(null);
|
|
1352
|
+
const dispatch = useIntentDispatcher2();
|
|
1353
|
+
const rangeController = useRef();
|
|
1371
1354
|
const { hasAttention } = useAttention(id);
|
|
1372
|
-
const handleFocus =
|
|
1355
|
+
const handleFocus = useCallback4((event) => {
|
|
1373
1356
|
if (!editing) {
|
|
1374
1357
|
const cell = closestCell(event.target);
|
|
1375
|
-
if (cell
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1358
|
+
if (cell) {
|
|
1359
|
+
if (cell.plane === "grid") {
|
|
1360
|
+
setCursor({
|
|
1361
|
+
col: cell.col,
|
|
1362
|
+
row: cell.row
|
|
1363
|
+
});
|
|
1364
|
+
setExtraplanarFocus(null);
|
|
1365
|
+
} else {
|
|
1366
|
+
setExtraplanarFocus(cell);
|
|
1367
|
+
}
|
|
1368
|
+
} else {
|
|
1369
|
+
setExtraplanarFocus(null);
|
|
1380
1370
|
}
|
|
1381
1371
|
}
|
|
1382
1372
|
}, [
|
|
1383
1373
|
editing
|
|
1384
1374
|
]);
|
|
1385
|
-
const handleClose =
|
|
1375
|
+
const handleClose = useCallback4((_value, event) => {
|
|
1376
|
+
if (event) {
|
|
1377
|
+
const { key, shift } = event;
|
|
1378
|
+
const axis = [
|
|
1379
|
+
"Enter",
|
|
1380
|
+
"ArrowUp",
|
|
1381
|
+
"ArrowDown"
|
|
1382
|
+
].includes(key) ? "row" : [
|
|
1383
|
+
"Tab",
|
|
1384
|
+
"ArrowLeft",
|
|
1385
|
+
"ArrowRight"
|
|
1386
|
+
].includes(key) ? "col" : void 0;
|
|
1387
|
+
const delta = key.startsWith("Arrow") ? [
|
|
1388
|
+
"ArrowUp",
|
|
1389
|
+
"ArrowLeft"
|
|
1390
|
+
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1391
|
+
dxGrid?.refocus(axis, delta);
|
|
1392
|
+
}
|
|
1393
|
+
}, [
|
|
1394
|
+
model,
|
|
1395
|
+
editing,
|
|
1396
|
+
dxGrid
|
|
1397
|
+
]);
|
|
1398
|
+
const handleBlur = useCallback4((value) => {
|
|
1386
1399
|
if (value !== void 0) {
|
|
1387
1400
|
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1388
1401
|
}
|
|
1389
|
-
setEditing(null);
|
|
1390
|
-
const axis = [
|
|
1391
|
-
"Enter",
|
|
1392
|
-
"ArrowUp",
|
|
1393
|
-
"ArrowDown"
|
|
1394
|
-
].includes(key) ? "row" : [
|
|
1395
|
-
"Tab",
|
|
1396
|
-
"ArrowLeft",
|
|
1397
|
-
"ArrowRight"
|
|
1398
|
-
].includes(key) ? "col" : void 0;
|
|
1399
|
-
const delta = key.startsWith("Arrow") ? [
|
|
1400
|
-
"ArrowUp",
|
|
1401
|
-
"ArrowLeft"
|
|
1402
|
-
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1403
|
-
dxGrid.current?.refocus(axis, delta);
|
|
1404
1402
|
}, [
|
|
1405
1403
|
model,
|
|
1406
|
-
editing
|
|
1407
|
-
setEditing
|
|
1404
|
+
editing
|
|
1408
1405
|
]);
|
|
1409
|
-
const handleAxisResize =
|
|
1406
|
+
const handleAxisResize = useCallback4(({ axis, size, index: numericIndex }) => {
|
|
1410
1407
|
if (axis === "row") {
|
|
1411
1408
|
const rowId = model.sheet.rows[parseInt(numericIndex)];
|
|
1412
1409
|
model.sheet.rowMeta[rowId] ??= {};
|
|
@@ -1419,44 +1416,91 @@ var GridSheet = () => {
|
|
|
1419
1416
|
}, [
|
|
1420
1417
|
model
|
|
1421
1418
|
]);
|
|
1422
|
-
const handleSelect =
|
|
1423
|
-
const
|
|
1419
|
+
const handleSelect = useCallback4(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1420
|
+
const range = {
|
|
1424
1421
|
from: {
|
|
1425
1422
|
col: minCol,
|
|
1426
1423
|
row: minRow
|
|
1427
1424
|
}
|
|
1428
1425
|
};
|
|
1429
1426
|
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1430
|
-
|
|
1427
|
+
range.to = {
|
|
1431
1428
|
col: maxCol,
|
|
1432
1429
|
row: maxRow
|
|
1433
1430
|
};
|
|
1434
1431
|
}
|
|
1435
1432
|
if (editing) {
|
|
1436
|
-
|
|
1433
|
+
rangeController.current?.setRange(rangeToA1Notation(range));
|
|
1437
1434
|
} else {
|
|
1438
|
-
setRange(
|
|
1435
|
+
setRange(range.to ? range : void 0);
|
|
1439
1436
|
}
|
|
1440
1437
|
}, [
|
|
1441
1438
|
editing
|
|
1442
1439
|
]);
|
|
1443
|
-
const handleWheel =
|
|
1440
|
+
const handleWheel = useCallback4((event) => {
|
|
1444
1441
|
if (!hasAttention) {
|
|
1445
1442
|
event.stopPropagation();
|
|
1446
1443
|
}
|
|
1447
1444
|
}, [
|
|
1448
1445
|
hasAttention
|
|
1449
1446
|
]);
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1447
|
+
const selectEntireAxis = useCallback4((pos) => {
|
|
1448
|
+
switch (pos.plane) {
|
|
1449
|
+
case "frozenRowsStart":
|
|
1450
|
+
return dxGrid?.setSelection({
|
|
1451
|
+
start: {
|
|
1452
|
+
col: pos.col,
|
|
1453
|
+
row: 0,
|
|
1454
|
+
plane: "grid"
|
|
1455
|
+
},
|
|
1456
|
+
end: {
|
|
1457
|
+
col: pos.col,
|
|
1458
|
+
row: model.sheet.rows.length - 1,
|
|
1459
|
+
plane: "grid"
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
case "frozenColsStart":
|
|
1463
|
+
return dxGrid?.setSelection({
|
|
1464
|
+
start: {
|
|
1465
|
+
row: pos.row,
|
|
1466
|
+
col: 0,
|
|
1467
|
+
plane: "grid"
|
|
1468
|
+
},
|
|
1469
|
+
end: {
|
|
1470
|
+
row: pos.row,
|
|
1471
|
+
col: model.sheet.columns.length - 1,
|
|
1472
|
+
plane: "grid"
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
}, [
|
|
1477
|
+
dxGrid,
|
|
1478
|
+
model.sheet
|
|
1479
|
+
]);
|
|
1480
|
+
const handleClick = useCallback4((event) => {
|
|
1481
|
+
const cell = closestCell(event.target);
|
|
1482
|
+
if (cell) {
|
|
1483
|
+
selectEntireAxis(cell);
|
|
1484
|
+
}
|
|
1485
|
+
}, [
|
|
1486
|
+
selectEntireAxis
|
|
1487
|
+
]);
|
|
1488
|
+
const handleKeyDown = useCallback4((event) => {
|
|
1455
1489
|
switch (event.key) {
|
|
1456
1490
|
case "Backspace":
|
|
1457
1491
|
case "Delete":
|
|
1458
1492
|
event.preventDefault();
|
|
1459
1493
|
return cursorFallbackRange && model.clear(cursorFallbackRange);
|
|
1494
|
+
case "Enter":
|
|
1495
|
+
case "Space":
|
|
1496
|
+
if (dxGrid && extraplanarFocus) {
|
|
1497
|
+
switch (extraplanarFocus.plane) {
|
|
1498
|
+
case "frozenRowsStart":
|
|
1499
|
+
case "frozenColsStart":
|
|
1500
|
+
event.preventDefault();
|
|
1501
|
+
return selectEntireAxis(extraplanarFocus);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1460
1504
|
}
|
|
1461
1505
|
if (event.metaKey || event.ctrlKey) {
|
|
1462
1506
|
switch (event.key) {
|
|
@@ -1482,12 +1526,54 @@ var GridSheet = () => {
|
|
|
1482
1526
|
}
|
|
1483
1527
|
}
|
|
1484
1528
|
}, [
|
|
1485
|
-
|
|
1529
|
+
cursorFallbackRange,
|
|
1486
1530
|
model,
|
|
1487
|
-
cursor
|
|
1531
|
+
cursor,
|
|
1532
|
+
extraplanarFocus,
|
|
1533
|
+
selectEntireAxis
|
|
1534
|
+
]);
|
|
1535
|
+
const contextMenuAnchorRef = useRef(null);
|
|
1536
|
+
const [contextMenuOpen, setContextMenuOpen] = useState4(null);
|
|
1537
|
+
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1538
|
+
const handleContextMenu = useCallback4((event) => {
|
|
1539
|
+
const cell = closestCell(event.target);
|
|
1540
|
+
if (cell && cell.plane.startsWith("frozen")) {
|
|
1541
|
+
event.preventDefault();
|
|
1542
|
+
contextMenuAnchorRef.current = event.target;
|
|
1543
|
+
setContextMenuOpen(cell);
|
|
1544
|
+
}
|
|
1545
|
+
}, []);
|
|
1546
|
+
const handleAxisMenuAction = useCallback4((operation) => {
|
|
1547
|
+
switch (operation) {
|
|
1548
|
+
case "insert-before":
|
|
1549
|
+
case "insert-after":
|
|
1550
|
+
return dispatch({
|
|
1551
|
+
action: SheetAction.INSERT_AXIS,
|
|
1552
|
+
data: {
|
|
1553
|
+
model,
|
|
1554
|
+
axis: contextMenuAxis,
|
|
1555
|
+
index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
break;
|
|
1559
|
+
case "drop":
|
|
1560
|
+
return dispatch({
|
|
1561
|
+
action: SheetAction.DROP_AXIS,
|
|
1562
|
+
data: {
|
|
1563
|
+
model,
|
|
1564
|
+
axis: contextMenuAxis,
|
|
1565
|
+
axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
}, [
|
|
1570
|
+
contextMenuAxis,
|
|
1571
|
+
contextMenuOpen,
|
|
1572
|
+
model,
|
|
1573
|
+
dispatch
|
|
1488
1574
|
]);
|
|
1489
1575
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1490
|
-
const extension =
|
|
1576
|
+
const extension = useMemo2(() => [
|
|
1491
1577
|
editorKeys({
|
|
1492
1578
|
onClose: handleClose,
|
|
1493
1579
|
...editing?.initialContent && {
|
|
@@ -1497,23 +1583,32 @@ var GridSheet = () => {
|
|
|
1497
1583
|
sheetExtension({
|
|
1498
1584
|
functions: model.graph.getFunctions()
|
|
1499
1585
|
}),
|
|
1500
|
-
rangeExtension(
|
|
1586
|
+
rangeExtension({
|
|
1587
|
+
onInit: (fn) => rangeController.current = fn,
|
|
1588
|
+
onStateChange: (state) => {
|
|
1589
|
+
if (dxGrid) {
|
|
1590
|
+
dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
})
|
|
1501
1594
|
], [
|
|
1502
1595
|
model,
|
|
1503
1596
|
handleClose,
|
|
1504
1597
|
editing
|
|
1505
1598
|
]);
|
|
1506
|
-
const getCellContent =
|
|
1599
|
+
const getCellContent = useCallback4((index) => {
|
|
1507
1600
|
const cell = dxGridCellIndexToSheetCellAddress(index);
|
|
1508
1601
|
return model.getCellText(cell);
|
|
1509
1602
|
}, [
|
|
1510
1603
|
model
|
|
1511
1604
|
]);
|
|
1512
|
-
useUpdateFocusedCellOnThreadSelection(
|
|
1513
|
-
|
|
1605
|
+
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1606
|
+
useSelectThreadOnCellFocus();
|
|
1607
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(GridCellEditor, {
|
|
1514
1608
|
getCellContent,
|
|
1515
|
-
extension
|
|
1516
|
-
|
|
1609
|
+
extension,
|
|
1610
|
+
onBlur: handleBlur
|
|
1611
|
+
}), /* @__PURE__ */ React4.createElement(Grid2.Content, {
|
|
1517
1612
|
initialCells,
|
|
1518
1613
|
limitColumns: DEFAULT_COLUMNS,
|
|
1519
1614
|
limitRows: DEFAULT_ROWS,
|
|
@@ -1527,44 +1622,49 @@ var GridSheet = () => {
|
|
|
1527
1622
|
onFocus: handleFocus,
|
|
1528
1623
|
onWheelCapture: handleWheel,
|
|
1529
1624
|
onKeyDown: handleKeyDown,
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
},
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1625
|
+
onContextMenu: handleContextMenu,
|
|
1626
|
+
onClick: handleClick,
|
|
1627
|
+
overscroll: "trap",
|
|
1628
|
+
className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:border-separator",
|
|
1629
|
+
activeRefs,
|
|
1630
|
+
ref: setDxGrid
|
|
1631
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
|
|
1632
|
+
modal: false,
|
|
1633
|
+
open: !!contextMenuOpen,
|
|
1634
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1635
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.VirtualTrigger, {
|
|
1636
|
+
virtualRef: contextMenuAnchorRef
|
|
1637
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu.Content, {
|
|
1638
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1639
|
+
sideOffset: 4,
|
|
1640
|
+
collisionPadding: 8
|
|
1641
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
1642
|
+
onClick: () => handleAxisMenuAction("insert-before")
|
|
1643
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1644
|
+
size: 5,
|
|
1645
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1646
|
+
}), /* @__PURE__ */ React4.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
1647
|
+
onClick: () => handleAxisMenuAction("insert-after")
|
|
1648
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1649
|
+
size: 5,
|
|
1650
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1651
|
+
}), /* @__PURE__ */ React4.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
1652
|
+
onClick: () => handleAxisMenuAction("drop")
|
|
1653
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1654
|
+
size: 5,
|
|
1655
|
+
icon: "ph--backspace--regular"
|
|
1656
|
+
}), /* @__PURE__ */ React4.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
|
|
1553
1657
|
};
|
|
1554
1658
|
|
|
1555
1659
|
export {
|
|
1556
1660
|
ComputeGraphContextProvider,
|
|
1557
|
-
addressToA1Notation,
|
|
1558
|
-
rangeToA1Notation,
|
|
1559
|
-
inRange,
|
|
1560
|
-
createSheet,
|
|
1561
|
-
addressToIndex,
|
|
1562
|
-
compareIndexPositions,
|
|
1563
|
-
computeGraphFacet,
|
|
1564
1661
|
useComputeGraph,
|
|
1662
|
+
completeCellRangeToThreadCursor,
|
|
1663
|
+
computeGraphFacet,
|
|
1565
1664
|
useSheetContext,
|
|
1566
1665
|
SheetProvider,
|
|
1567
1666
|
GridSheet,
|
|
1667
|
+
RangeList,
|
|
1568
1668
|
SheetContainer
|
|
1569
1669
|
};
|
|
1570
|
-
//# sourceMappingURL=chunk-
|
|
1670
|
+
//# sourceMappingURL=chunk-4LKIURJA.mjs.map
|