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