@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-main.8b352a0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{SheetContainer-AKWROARP.mjs → SheetContainer-R65IDJHN.mjs} +54 -58
- package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-5KVQ5IPW.mjs} +3 -12
- package/dist/lib/browser/chunk-5KVQ5IPW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-I2DKJ72A.mjs} +570 -669
- package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-KCYJSOFB.mjs} +252 -33
- package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-SJT67236.mjs} +4 -2
- package/dist/lib/browser/index.mjs +62 -20
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-6BO4C5X2.cjs} +52 -62
- package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-2XJ5I4UF.cjs} +6 -15
- package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-DEPJHN47.cjs} +534 -646
- package/dist/lib/node/chunk-DEPJHN47.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-JF5XNTF3.cjs} +257 -28
- package/dist/lib/node/chunk-JF5XNTF3.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-AQBDL7HO.cjs} +21 -19
- package/dist/lib/node/compute-graph-AQBDL7HO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +70 -31
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +6 -6
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-MJXC5E3P.mjs} +54 -58
- package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-25V7WY4R.mjs} +570 -669
- package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-5TXLF6PL.mjs} +3 -12
- package/dist/lib/node-esm/chunk-5TXLF6PL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-XBEHKYO7.mjs} +251 -33
- package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-FRCKXEYK.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +62 -20
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -2
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/index.d.ts +2 -0
- package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -3
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +7 -5
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/{graph → compute-graph}/compute-graph.d.ts +1 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/compute-graph/util.d.ts.map +1 -0
- package/dist/types/src/defs/index.d.ts +1 -1
- package/dist/types/src/defs/index.d.ts.map +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/defs/types.d.ts +6 -0
- package/dist/types/src/defs/types.d.ts.map +1 -1
- package/dist/types/src/defs/util.d.ts +2 -6
- package/dist/types/src/defs/util.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +23 -3
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/index.d.ts +2 -0
- package/dist/types/src/integrations/index.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +1 -1
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/{hooks → model}/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +4 -0
- package/dist/types/src/serializer.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +13 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -30
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +43 -50
- package/src/SheetPlugin.tsx +25 -12
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +5 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
- package/src/components/GridSheet/GridSheet.tsx +118 -22
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +24 -14
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +3 -3
- package/src/components/SheetContainer/SheetContainer.tsx +10 -4
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +44 -41
- package/src/components/index.ts +1 -0
- package/src/{graph → compute-graph}/compute-graph.stories.tsx +2 -1
- package/src/{graph → compute-graph}/compute-graph.ts +5 -2
- package/src/{graph → compute-graph}/compute-node.ts +2 -3
- package/src/defs/index.ts +1 -1
- package/src/defs/sheet-range-types.ts +5 -4
- package/src/defs/types.ts +6 -1
- package/src/defs/util.ts +3 -19
- package/src/extensions/compute.stories.tsx +2 -2
- package/src/extensions/compute.ts +2 -2
- package/src/extensions/editor/extension.test.ts +1 -1
- package/src/extensions/editor/extension.ts +48 -23
- package/src/index.ts +2 -2
- package/src/integrations/index.ts +5 -0
- package/src/integrations/thread-ranges.ts +101 -0
- package/src/model/index.ts +1 -1
- package/src/model/sheet-model.test.ts +1 -1
- package/src/model/sheet-model.ts +13 -8
- package/src/{hooks → model}/useSheetModel.ts +1 -1
- package/src/serializer.ts +27 -0
- package/src/testing/testing.tsx +1 -1
- package/src/translations.ts +13 -3
- package/src/types.ts +4 -2
- package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +0 -7
- package/dist/lib/node/chunk-53BMSUIK.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -6
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -26
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/src/hooks/hooks.stories.tsx +0 -53
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/model/decorations.ts +0 -66
- /package/dist/lib/browser/{graph-M4IQ76QX.mjs.map → compute-graph-SJT67236.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-FRCKXEYK.mjs.map} +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph-registry.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.stories.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-node.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/async-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/edge-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/function-defs.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/hyperformula.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-builder.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-plugin.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/util.d.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph-registry.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph.test.ts +0 -0
- /package/src/{graph → compute-graph}/functions/async-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/edge-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/function-defs.ts +0 -0
- /package/src/{graph → compute-graph}/functions/index.ts +0 -0
- /package/src/{graph → compute-graph}/hyperformula.test.ts +0 -0
- /package/src/{graph → compute-graph}/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-builder.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-plugin.ts +0 -0
- /package/src/{graph → compute-graph}/util.ts +0 -0
|
@@ -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-XBEHKYO7.mjs";
|
|
22
|
+
import {
|
|
23
|
+
Range
|
|
24
|
+
} from "./chunk-5TXLF6PL.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,392 @@ 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 useCallback4, useMemo as useMemo2, useRef, useState as useState4 } from "react";
|
|
872
|
+
import { DropdownMenu, Icon, useTranslation as useTranslation2 } 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, 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 useCallback3, 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, { useCallback as useCallback2 } from "react";
|
|
894
|
+
import { S } from "@dxos/echo-schema";
|
|
895
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
896
|
+
import { List } from "@dxos/react-ui-list";
|
|
897
|
+
import { ghostHover } from "@dxos/react-ui-theme";
|
|
898
|
+
var RangeList = ({ sheet }) => {
|
|
899
|
+
const { t } = useTranslation(SHEET_PLUGIN);
|
|
900
|
+
const handleSelectRange = (range) => {
|
|
901
|
+
};
|
|
902
|
+
const handleDeleteRange = useCallback2((range) => {
|
|
903
|
+
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
904
|
+
sheet.ranges.splice(index, 1);
|
|
905
|
+
}, [
|
|
906
|
+
sheet
|
|
907
|
+
]);
|
|
908
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("h2", {
|
|
909
|
+
className: "p-2 text-sm font-semibold"
|
|
910
|
+
}, t("range list heading")), /* @__PURE__ */ React3.createElement(List.Root, {
|
|
911
|
+
items: sheet.ranges,
|
|
912
|
+
isItem: S.is(Range)
|
|
913
|
+
}, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ React3.createElement(List.Item, {
|
|
914
|
+
key: i,
|
|
915
|
+
item: range,
|
|
916
|
+
classNames: [
|
|
917
|
+
"p-2",
|
|
918
|
+
ghostHover
|
|
919
|
+
]
|
|
920
|
+
}, /* @__PURE__ */ React3.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React3.createElement(List.ItemTitle, {
|
|
921
|
+
onClick: () => handleSelectRange(range)
|
|
922
|
+
}, t("range title", {
|
|
923
|
+
position: rangeToA1Notation(rangeFromIndex(sheet, range.range)),
|
|
924
|
+
key: t(`range key ${range.key} label`),
|
|
925
|
+
value: t(`range value ${range.value} label`)
|
|
926
|
+
})), /* @__PURE__ */ React3.createElement(List.ItemDeleteButton, {
|
|
927
|
+
onClick: () => handleDeleteRange(range)
|
|
928
|
+
})))));
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
932
|
+
var SheetContainer = lazy(() => import("./SheetContainer-MJXC5E3P.mjs"));
|
|
933
|
+
|
|
934
|
+
// packages/plugins/plugin-sheet/src/integrations/thread-ranges.ts
|
|
935
|
+
var completeCellRangeToThreadCursor = (range) => {
|
|
936
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
937
|
+
};
|
|
938
|
+
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
939
|
+
const coords = cursor.split(",");
|
|
940
|
+
if (coords.length !== 4) {
|
|
941
|
+
return null;
|
|
942
|
+
} else {
|
|
943
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
944
|
+
return {
|
|
945
|
+
from: {
|
|
946
|
+
col: parseInt(fromCol),
|
|
947
|
+
row: parseInt(fromRow)
|
|
948
|
+
},
|
|
949
|
+
to: {
|
|
950
|
+
col: parseInt(toCol),
|
|
951
|
+
row: parseInt(toRow)
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
957
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
958
|
+
const handleScrollIntoView = useCallback3(({ action, data }) => {
|
|
1161
959
|
switch (action) {
|
|
1162
960
|
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
1163
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !==
|
|
961
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId2(model.sheet)) {
|
|
1164
962
|
return;
|
|
1165
963
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
964
|
+
setActiveRefs(data.thread);
|
|
965
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
966
|
+
range && grid?.setFocus({
|
|
967
|
+
...range.to,
|
|
1169
968
|
plane: "grid"
|
|
1170
969
|
}, true);
|
|
1171
970
|
}
|
|
1172
971
|
}
|
|
1173
972
|
}, [
|
|
1174
|
-
model.sheet
|
|
973
|
+
model.sheet,
|
|
974
|
+
setActiveRefs
|
|
1175
975
|
]);
|
|
1176
976
|
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
1177
977
|
};
|
|
1178
|
-
var useSelectThreadOnCellFocus = (
|
|
978
|
+
var useSelectThreadOnCellFocus = () => {
|
|
979
|
+
const { model, cursor } = useSheetContext();
|
|
1179
980
|
const dispatch = useIntentDispatcher();
|
|
1180
|
-
const
|
|
981
|
+
const threads = useMemo(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
|
|
1181
982
|
// TODO(thure): Surely we can find a better dependency for this…
|
|
1182
983
|
JSON.stringify(model.sheet.threads)
|
|
1183
984
|
]);
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1186
|
-
model.sheet
|
|
1187
|
-
]);
|
|
1188
|
-
const selectClosestThread = useCallback((cellAddress) => {
|
|
1189
|
-
if (!cellAddress || !activeThreads) {
|
|
985
|
+
const selectClosestThread = useCallback3((cellAddress) => {
|
|
986
|
+
if (!cellAddress || !threads) {
|
|
1190
987
|
return;
|
|
1191
988
|
}
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
action: "dxos.org/plugin/thread/action/select",
|
|
1199
|
-
data: {
|
|
1200
|
-
current: fullyQualifiedId(closestThread)
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
]);
|
|
989
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
990
|
+
if (anchor) {
|
|
991
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
992
|
+
return range ? inRange(range, cellAddress) : false;
|
|
993
|
+
} else {
|
|
994
|
+
return false;
|
|
1204
995
|
}
|
|
996
|
+
});
|
|
997
|
+
if (closestThread) {
|
|
998
|
+
void dispatch([
|
|
999
|
+
{
|
|
1000
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
1001
|
+
data: {
|
|
1002
|
+
current: fullyQualifiedId2(closestThread)
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
]);
|
|
1205
1006
|
}
|
|
1206
1007
|
}, [
|
|
1207
1008
|
dispatch,
|
|
1208
|
-
|
|
1209
|
-
activeThreadAddresses,
|
|
1210
|
-
model.sheet
|
|
1009
|
+
threads
|
|
1211
1010
|
]);
|
|
1212
1011
|
const debounced = useMemo(() => {
|
|
1213
1012
|
return debounce2((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
1214
1013
|
}, [
|
|
1215
1014
|
selectClosestThread
|
|
1216
1015
|
]);
|
|
1217
|
-
|
|
1016
|
+
useEffect2(() => {
|
|
1218
1017
|
if (!cursor) {
|
|
1219
1018
|
return;
|
|
1220
1019
|
}
|
|
1221
1020
|
debounced(cursor);
|
|
1222
1021
|
}, [
|
|
1223
1022
|
cursor,
|
|
1224
|
-
|
|
1023
|
+
debounced
|
|
1225
1024
|
]);
|
|
1226
1025
|
};
|
|
1227
|
-
|
|
1026
|
+
|
|
1027
|
+
// packages/plugins/plugin-sheet/src/components/GridSheet/util.ts
|
|
1028
|
+
var dxGridCellIndexToSheetCellAddress = (index) => {
|
|
1029
|
+
const [colStr, rowStr] = index.split(",");
|
|
1228
1030
|
return {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
"bg-greenFill"
|
|
1232
|
-
],
|
|
1233
|
-
cellIndex
|
|
1031
|
+
col: parseInt(colStr),
|
|
1032
|
+
row: parseInt(rowStr)
|
|
1234
1033
|
};
|
|
1235
1034
|
};
|
|
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();
|
|
1035
|
+
var createDxGridColumns = (model) => {
|
|
1036
|
+
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
1037
|
+
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
1038
|
+
acc.grid[numericIndex] = {
|
|
1039
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
1040
|
+
resizeable: true
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
return acc;
|
|
1044
|
+
}, {
|
|
1045
|
+
grid: {}
|
|
1270
1046
|
});
|
|
1271
1047
|
};
|
|
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
|
-
]
|
|
1048
|
+
var createDxGridRows = (model) => {
|
|
1049
|
+
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
1050
|
+
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
1051
|
+
acc.grid[numericIndex] = {
|
|
1052
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
1053
|
+
resizeable: true
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
return acc;
|
|
1057
|
+
}, {
|
|
1058
|
+
grid: {}
|
|
1290
1059
|
});
|
|
1291
|
-
return context;
|
|
1292
1060
|
};
|
|
1293
|
-
var
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1061
|
+
var projectCellProps = (model, col, row) => {
|
|
1062
|
+
const address = {
|
|
1063
|
+
col,
|
|
1064
|
+
row
|
|
1065
|
+
};
|
|
1066
|
+
const rawValue = model.getValue(address);
|
|
1067
|
+
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(rangeFromIndex(model.sheet, range), address));
|
|
1068
|
+
const threadRefs = model.sheet.threads?.filter((thread) => {
|
|
1069
|
+
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
|
|
1070
|
+
return thread && range ? inRange(range, address) : false;
|
|
1071
|
+
}).map((thread) => fullyQualifiedId3(thread)).join(" ");
|
|
1072
|
+
const type = model.getValueType(address);
|
|
1073
|
+
const classNames = ranges?.map(cellClassNameForRange).reverse();
|
|
1074
|
+
return {
|
|
1075
|
+
value: parseValue(type, rawValue),
|
|
1076
|
+
className: mx2(cellClassesForFieldType(type), threadRefs && commentedClassName, classNames),
|
|
1077
|
+
dataRefs: threadRefs
|
|
1078
|
+
};
|
|
1079
|
+
};
|
|
1080
|
+
var gridCellGetter = (model) => {
|
|
1081
|
+
const cachedGridCells = {};
|
|
1082
|
+
return (nextBounds) => {
|
|
1083
|
+
[
|
|
1084
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1085
|
+
].forEach((_, c0) => {
|
|
1086
|
+
return [
|
|
1087
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1088
|
+
].forEach((_2, r0) => {
|
|
1089
|
+
const col = nextBounds.start.col + c0;
|
|
1090
|
+
const row = nextBounds.start.row + r0;
|
|
1091
|
+
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
1092
|
+
});
|
|
1093
|
+
});
|
|
1094
|
+
return cachedGridCells;
|
|
1095
|
+
};
|
|
1096
|
+
};
|
|
1097
|
+
var rowLabelCell = (row) => ({
|
|
1098
|
+
value: rowToA1Notation(row),
|
|
1099
|
+
className: "text-end !pie-1",
|
|
1100
|
+
resizeHandle: "row"
|
|
1101
|
+
});
|
|
1102
|
+
var colLabelCell = (col) => ({
|
|
1103
|
+
value: colToA1Notation(col),
|
|
1104
|
+
resizeHandle: "col"
|
|
1105
|
+
});
|
|
1106
|
+
var cellGetter = (model) => {
|
|
1107
|
+
const getGridCells = gridCellGetter(model);
|
|
1108
|
+
return (nextBounds, plane) => {
|
|
1109
|
+
switch (plane) {
|
|
1110
|
+
case "grid":
|
|
1111
|
+
return getGridCells(nextBounds);
|
|
1112
|
+
case "frozenColsStart":
|
|
1113
|
+
return [
|
|
1114
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1115
|
+
].reduce((acc, _, r0) => {
|
|
1116
|
+
const r = nextBounds.start.row + r0;
|
|
1117
|
+
acc[`0,${r}`] = rowLabelCell(r);
|
|
1118
|
+
return acc;
|
|
1119
|
+
}, {});
|
|
1120
|
+
case "frozenRowsStart":
|
|
1121
|
+
return [
|
|
1122
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1123
|
+
].reduce((acc, _, c0) => {
|
|
1124
|
+
const c = nextBounds.start.col + c0;
|
|
1125
|
+
acc[`${c},0`] = colLabelCell(c);
|
|
1126
|
+
return acc;
|
|
1127
|
+
}, {});
|
|
1128
|
+
default:
|
|
1129
|
+
return {};
|
|
1313
1130
|
}
|
|
1314
|
-
}
|
|
1131
|
+
};
|
|
1315
1132
|
};
|
|
1316
|
-
var
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1133
|
+
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1134
|
+
const [columns, setColumns] = useState3(createDxGridColumns(model));
|
|
1135
|
+
const [rows, setRows] = useState3(createDxGridColumns(model));
|
|
1136
|
+
useEffect3(() => {
|
|
1137
|
+
const cellsAccessor = createDocAccessor(model.sheet, [
|
|
1138
|
+
"cells"
|
|
1139
|
+
]);
|
|
1140
|
+
if (dxGrid) {
|
|
1141
|
+
dxGrid.getCells = cellGetter(model);
|
|
1142
|
+
}
|
|
1143
|
+
const handleCellsUpdate = () => {
|
|
1144
|
+
dxGrid?.requestUpdate("initialCells");
|
|
1145
|
+
};
|
|
1146
|
+
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1147
|
+
return () => cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1148
|
+
}, [
|
|
1323
1149
|
model,
|
|
1324
|
-
|
|
1325
|
-
|
|
1150
|
+
dxGrid
|
|
1151
|
+
]);
|
|
1152
|
+
useEffect3(() => {
|
|
1153
|
+
const columnMetaAccessor = createDocAccessor(model.sheet, [
|
|
1154
|
+
"columnMeta"
|
|
1155
|
+
]);
|
|
1156
|
+
const rowMetaAccessor = createDocAccessor(model.sheet, [
|
|
1157
|
+
"rowMeta"
|
|
1158
|
+
]);
|
|
1159
|
+
const handleColumnMetaUpdate = () => {
|
|
1160
|
+
setColumns(createDxGridColumns(model));
|
|
1161
|
+
};
|
|
1162
|
+
const handleRowMetaUpdate = () => {
|
|
1163
|
+
setRows(createDxGridRows(model));
|
|
1164
|
+
};
|
|
1165
|
+
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1166
|
+
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1167
|
+
return () => {
|
|
1168
|
+
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1169
|
+
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1170
|
+
};
|
|
1171
|
+
}, [
|
|
1172
|
+
model
|
|
1173
|
+
]);
|
|
1174
|
+
return {
|
|
1175
|
+
columns,
|
|
1176
|
+
rows
|
|
1177
|
+
};
|
|
1326
1178
|
};
|
|
1327
1179
|
|
|
1328
1180
|
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
1181
|
+
var inertPosition = {
|
|
1182
|
+
plane: "grid",
|
|
1183
|
+
col: 0,
|
|
1184
|
+
row: 0
|
|
1185
|
+
};
|
|
1329
1186
|
var initialCells = {
|
|
1330
1187
|
grid: {},
|
|
1331
1188
|
frozenColsStart: [
|
|
@@ -1366,11 +1223,12 @@ var sheetColDefault = {
|
|
|
1366
1223
|
}
|
|
1367
1224
|
};
|
|
1368
1225
|
var GridSheet = () => {
|
|
1369
|
-
const {
|
|
1370
|
-
const
|
|
1371
|
-
const
|
|
1226
|
+
const { t } = useTranslation2(SHEET_PLUGIN);
|
|
1227
|
+
const { id, model, editing, setEditing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
|
|
1228
|
+
const [dxGrid, setDxGrid] = useState4(null);
|
|
1229
|
+
const rangeController = useRef();
|
|
1372
1230
|
const { hasAttention } = useAttention(id);
|
|
1373
|
-
const handleFocus =
|
|
1231
|
+
const handleFocus = useCallback4((event) => {
|
|
1374
1232
|
if (!editing) {
|
|
1375
1233
|
const cell = closestCell(event.target);
|
|
1376
1234
|
if (cell && cell.plane === "grid") {
|
|
@@ -1383,7 +1241,7 @@ var GridSheet = () => {
|
|
|
1383
1241
|
}, [
|
|
1384
1242
|
editing
|
|
1385
1243
|
]);
|
|
1386
|
-
const handleClose =
|
|
1244
|
+
const handleClose = useCallback4((value, { key, shift }) => {
|
|
1387
1245
|
if (value !== void 0) {
|
|
1388
1246
|
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1389
1247
|
}
|
|
@@ -1401,13 +1259,22 @@ var GridSheet = () => {
|
|
|
1401
1259
|
"ArrowUp",
|
|
1402
1260
|
"ArrowLeft"
|
|
1403
1261
|
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1404
|
-
dxGrid
|
|
1262
|
+
dxGrid?.refocus(axis, delta);
|
|
1405
1263
|
}, [
|
|
1406
1264
|
model,
|
|
1407
1265
|
editing,
|
|
1408
|
-
|
|
1266
|
+
dxGrid
|
|
1267
|
+
]);
|
|
1268
|
+
const handleBlur = useCallback4((value) => {
|
|
1269
|
+
if (value !== void 0) {
|
|
1270
|
+
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1271
|
+
}
|
|
1272
|
+
setEditing(null);
|
|
1273
|
+
}, [
|
|
1274
|
+
model,
|
|
1275
|
+
editing
|
|
1409
1276
|
]);
|
|
1410
|
-
const handleAxisResize =
|
|
1277
|
+
const handleAxisResize = useCallback4(({ axis, size, index: numericIndex }) => {
|
|
1411
1278
|
if (axis === "row") {
|
|
1412
1279
|
const rowId = model.sheet.rows[parseInt(numericIndex)];
|
|
1413
1280
|
model.sheet.rowMeta[rowId] ??= {};
|
|
@@ -1420,39 +1287,35 @@ var GridSheet = () => {
|
|
|
1420
1287
|
}, [
|
|
1421
1288
|
model
|
|
1422
1289
|
]);
|
|
1423
|
-
const handleSelect =
|
|
1424
|
-
const
|
|
1290
|
+
const handleSelect = useCallback4(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1291
|
+
const range = {
|
|
1425
1292
|
from: {
|
|
1426
1293
|
col: minCol,
|
|
1427
1294
|
row: minRow
|
|
1428
1295
|
}
|
|
1429
1296
|
};
|
|
1430
1297
|
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1431
|
-
|
|
1298
|
+
range.to = {
|
|
1432
1299
|
col: maxCol,
|
|
1433
1300
|
row: maxRow
|
|
1434
1301
|
};
|
|
1435
1302
|
}
|
|
1436
1303
|
if (editing) {
|
|
1437
|
-
|
|
1304
|
+
rangeController.current?.setRange(rangeToA1Notation(range));
|
|
1438
1305
|
} else {
|
|
1439
|
-
setRange(
|
|
1306
|
+
setRange(range.to ? range : void 0);
|
|
1440
1307
|
}
|
|
1441
1308
|
}, [
|
|
1442
1309
|
editing
|
|
1443
1310
|
]);
|
|
1444
|
-
const handleWheel =
|
|
1311
|
+
const handleWheel = useCallback4((event) => {
|
|
1445
1312
|
if (!hasAttention) {
|
|
1446
1313
|
event.stopPropagation();
|
|
1447
1314
|
}
|
|
1448
1315
|
}, [
|
|
1449
1316
|
hasAttention
|
|
1450
1317
|
]);
|
|
1451
|
-
const handleKeyDown =
|
|
1452
|
-
const cursorFallbackRange = range ?? cursor ? {
|
|
1453
|
-
from: cursor,
|
|
1454
|
-
to: cursor
|
|
1455
|
-
} : null;
|
|
1318
|
+
const handleKeyDown = useCallback4((event) => {
|
|
1456
1319
|
switch (event.key) {
|
|
1457
1320
|
case "Backspace":
|
|
1458
1321
|
case "Delete":
|
|
@@ -1483,12 +1346,36 @@ var GridSheet = () => {
|
|
|
1483
1346
|
}
|
|
1484
1347
|
}
|
|
1485
1348
|
}, [
|
|
1486
|
-
|
|
1349
|
+
cursorFallbackRange,
|
|
1487
1350
|
model,
|
|
1488
1351
|
cursor
|
|
1489
1352
|
]);
|
|
1353
|
+
const contextMenuAnchorRef = useRef(null);
|
|
1354
|
+
const [contextMenuOpen, setContextMenuOpen] = useState4(null);
|
|
1355
|
+
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1356
|
+
const handleContextMenu = useCallback4((event) => {
|
|
1357
|
+
const cell = closestCell(event.target);
|
|
1358
|
+
if (cell && cell.plane.startsWith("frozen")) {
|
|
1359
|
+
event.preventDefault();
|
|
1360
|
+
contextMenuAnchorRef.current = event.target;
|
|
1361
|
+
setContextMenuOpen(cell);
|
|
1362
|
+
}
|
|
1363
|
+
}, []);
|
|
1364
|
+
const handleAxisMenuAction = useCallback4((operation) => {
|
|
1365
|
+
switch (operation) {
|
|
1366
|
+
case "add-before":
|
|
1367
|
+
case "add-after":
|
|
1368
|
+
model[contextMenuAxis === "col" ? "insertColumns" : "insertRows"](contextMenuOpen[contextMenuAxis] + (operation === "add-before" ? 0 : 1), 1);
|
|
1369
|
+
break;
|
|
1370
|
+
case "remove":
|
|
1371
|
+
}
|
|
1372
|
+
}, [
|
|
1373
|
+
contextMenuAxis,
|
|
1374
|
+
contextMenuOpen,
|
|
1375
|
+
model
|
|
1376
|
+
]);
|
|
1490
1377
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1491
|
-
const extension =
|
|
1378
|
+
const extension = useMemo2(() => [
|
|
1492
1379
|
editorKeys({
|
|
1493
1380
|
onClose: handleClose,
|
|
1494
1381
|
...editing?.initialContent && {
|
|
@@ -1498,23 +1385,32 @@ var GridSheet = () => {
|
|
|
1498
1385
|
sheetExtension({
|
|
1499
1386
|
functions: model.graph.getFunctions()
|
|
1500
1387
|
}),
|
|
1501
|
-
rangeExtension(
|
|
1388
|
+
rangeExtension({
|
|
1389
|
+
onInit: (fn) => rangeController.current = fn,
|
|
1390
|
+
onStateChange: (state) => {
|
|
1391
|
+
if (dxGrid) {
|
|
1392
|
+
dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
})
|
|
1502
1396
|
], [
|
|
1503
1397
|
model,
|
|
1504
1398
|
handleClose,
|
|
1505
1399
|
editing
|
|
1506
1400
|
]);
|
|
1507
|
-
const getCellContent =
|
|
1401
|
+
const getCellContent = useCallback4((index) => {
|
|
1508
1402
|
const cell = dxGridCellIndexToSheetCellAddress(index);
|
|
1509
1403
|
return model.getCellText(cell);
|
|
1510
1404
|
}, [
|
|
1511
1405
|
model
|
|
1512
1406
|
]);
|
|
1513
|
-
useUpdateFocusedCellOnThreadSelection(
|
|
1514
|
-
|
|
1407
|
+
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1408
|
+
useSelectThreadOnCellFocus();
|
|
1409
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(GridCellEditor, {
|
|
1515
1410
|
getCellContent,
|
|
1516
|
-
extension
|
|
1517
|
-
|
|
1411
|
+
extension,
|
|
1412
|
+
onBlur: handleBlur
|
|
1413
|
+
}), /* @__PURE__ */ React4.createElement(Grid2.Content, {
|
|
1518
1414
|
initialCells,
|
|
1519
1415
|
limitColumns: DEFAULT_COLUMNS,
|
|
1520
1416
|
limitRows: DEFAULT_ROWS,
|
|
@@ -1528,44 +1424,49 @@ var GridSheet = () => {
|
|
|
1528
1424
|
onFocus: handleFocus,
|
|
1529
1425
|
onWheelCapture: handleWheel,
|
|
1530
1426
|
onKeyDown: handleKeyDown,
|
|
1427
|
+
onContextMenu: handleContextMenu,
|
|
1531
1428
|
overscroll: "inline",
|
|
1532
1429
|
className: "[--dx-grid-base:var(--surface-bg)]",
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1430
|
+
activeRefs,
|
|
1431
|
+
ref: setDxGrid
|
|
1432
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
|
|
1433
|
+
modal: false,
|
|
1434
|
+
open: !!contextMenuOpen,
|
|
1435
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1436
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.VirtualTrigger, {
|
|
1437
|
+
virtualRef: contextMenuAnchorRef
|
|
1438
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu.Content, {
|
|
1439
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1440
|
+
sideOffset: 4,
|
|
1441
|
+
collisionPadding: 8
|
|
1442
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
1443
|
+
onClick: () => handleAxisMenuAction("add-before")
|
|
1444
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1445
|
+
size: 5,
|
|
1446
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1447
|
+
}), /* @__PURE__ */ React4.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
1448
|
+
onClick: () => handleAxisMenuAction("add-after")
|
|
1449
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1450
|
+
size: 5,
|
|
1451
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1452
|
+
}), /* @__PURE__ */ React4.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
1453
|
+
disabled: true,
|
|
1454
|
+
onClick: () => handleAxisMenuAction("remove")
|
|
1455
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1456
|
+
size: 5,
|
|
1457
|
+
icon: "ph--backspace--regular"
|
|
1458
|
+
}), /* @__PURE__ */ React4.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
|
|
1554
1459
|
};
|
|
1555
1460
|
|
|
1556
1461
|
export {
|
|
1557
1462
|
ComputeGraphContextProvider,
|
|
1558
|
-
addressToA1Notation,
|
|
1559
|
-
rangeToA1Notation,
|
|
1560
|
-
inRange,
|
|
1561
|
-
createSheet,
|
|
1562
|
-
addressToIndex,
|
|
1563
|
-
compareIndexPositions,
|
|
1564
|
-
computeGraphFacet,
|
|
1565
1463
|
useComputeGraph,
|
|
1464
|
+
completeCellRangeToThreadCursor,
|
|
1465
|
+
computeGraphFacet,
|
|
1566
1466
|
useSheetContext,
|
|
1567
1467
|
SheetProvider,
|
|
1568
1468
|
GridSheet,
|
|
1469
|
+
RangeList,
|
|
1569
1470
|
SheetContainer
|
|
1570
1471
|
};
|
|
1571
|
-
//# sourceMappingURL=chunk-
|
|
1472
|
+
//# sourceMappingURL=chunk-25V7WY4R.mjs.map
|