@dxos/plugin-sheet 0.6.11 → 0.6.12-main.15a606f
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-V4GCCZTX.mjs +261 -0
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-6ZMQVB4Z.mjs} +359 -671
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FUAGSXA4.mjs → chunk-T3NJFTD4.mjs} +8 -15
- package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-U4H5D34A.mjs → chunk-U2JHW3L6.mjs} +1020 -240
- package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +7 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs +21 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +68 -56
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs +279 -0
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-DD6FIXWC.cjs} +360 -667
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-AXQV3ZT5.cjs → chunk-OTTD7FBK.cjs} +1050 -279
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-Q3HBHPRL.cjs} +12 -20
- package/dist/lib/node/chunk-Q3HBHPRL.cjs.map +7 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs +43 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs.map +7 -0
- package/dist/lib/node/index.cjs +83 -64
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +262 -0
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs +2553 -0
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs +76 -0
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs +2925 -0
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +17 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs +22 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +261 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +21 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +6 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +24 -0
- package/dist/types/src/components/Sheet/decorations.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +6 -5
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts +2 -0
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +2 -3
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +19 -3
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +18 -13
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +43 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +5 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph}/async-function.d.ts +1 -1
- package/dist/types/src/graph/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +81 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +19 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph/custom.d.ts → graph/custom-function.d.ts} +1 -1
- package/dist/types/src/graph/custom-function.d.ts.map +1 -0
- package/dist/types/src/graph/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +4 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +9 -64
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +9 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +83 -3
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +48 -41
- package/src/SheetPlugin.tsx +43 -70
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -3
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +4 -5
- package/src/components/CellEditor/extension.ts +1 -3
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +35 -0
- package/src/components/GridSheet/GridSheet.tsx +153 -0
- package/src/components/GridSheet/util.ts +89 -0
- package/src/components/Sheet/Sheet.stories.tsx +45 -82
- package/src/components/Sheet/Sheet.tsx +57 -18
- package/src/components/Sheet/decorations.ts +62 -0
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +16 -78
- package/src/components/Sheet/threads.tsx +205 -0
- package/src/components/SheetContainer.tsx +73 -19
- package/src/components/Toolbar/Toolbar.tsx +53 -12
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/{model → defs}/types.ts +23 -14
- package/src/defs/util.ts +135 -0
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +98 -0
- package/src/extensions/index.ts +5 -0
- package/src/{components/ComputeGraph → graph}/async-function.ts +3 -1
- package/src/graph/compute-graph.browser.test.ts +104 -0
- package/src/graph/compute-graph.stories.tsx +92 -0
- package/src/graph/compute-graph.ts +290 -0
- package/src/graph/compute-node.ts +51 -0
- package/src/{components/ComputeGraph/custom.ts → graph/custom-function.ts} +2 -6
- package/src/{components/ComputeGraph → graph}/edge-function.ts +2 -1
- package/src/graph/hyperformula.test.ts +15 -0
- package/src/graph/index.ts +7 -0
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +20 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +43 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -3
- package/src/model/sheet-model.ts +399 -0
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +66 -0
- package/src/translations.ts +6 -1
- package/src/types.ts +30 -5
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/ComputeGraph → graph}/edge-function.d.ts +0 -0
- /package/src/{model/functions.ts → graph/function-defs.ts} +0 -0
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
SheetType,
|
|
3
|
+
ValueTypeEnum
|
|
4
|
+
} from "./chunk-T3NJFTD4.mjs";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
addressToA1Notation,
|
|
8
|
-
columnLetter,
|
|
9
|
-
defaultFunctions,
|
|
10
|
-
inRange,
|
|
11
|
-
posEquals,
|
|
12
|
-
rangeToA1Notation
|
|
13
|
-
} from "./chunk-D5AGLXJP.mjs";
|
|
6
|
+
SHEET_PLUGIN
|
|
7
|
+
} from "./chunk-QILRZNE5.mjs";
|
|
14
8
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-JRL5LGCE.mjs";
|
|
18
|
-
|
|
19
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
20
|
-
import React4 from "react";
|
|
21
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
9
|
+
createSheetName
|
|
10
|
+
} from "./chunk-6ZMQVB4Z.mjs";
|
|
22
11
|
|
|
23
12
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
24
13
|
import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
@@ -26,17 +15,175 @@ import { restrictToHorizontalAxis, restrictToVerticalAxis } from "@dnd-kit/modif
|
|
|
26
15
|
import { getEventCoordinates, useCombinedRefs } from "@dnd-kit/utilities";
|
|
27
16
|
import { Function as FunctionIcon } from "@phosphor-icons/react";
|
|
28
17
|
import { Resizable } from "re-resizable";
|
|
29
|
-
import
|
|
18
|
+
import React6, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo4, useRef, useState as useState5 } from "react";
|
|
30
19
|
import { createPortal } from "react-dom";
|
|
31
20
|
import { useResizeDetector } from "react-resize-detector";
|
|
32
|
-
import { debounce } from "@dxos/async";
|
|
21
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
33
22
|
import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
|
|
34
|
-
import { log } from "@dxos/log";
|
|
23
|
+
import { log as log2 } from "@dxos/log";
|
|
35
24
|
import { createAttendableAttributes, useHasAttention } from "@dxos/react-ui-attention";
|
|
36
25
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
37
26
|
|
|
38
27
|
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
39
28
|
import { useEffect, useState } from "react";
|
|
29
|
+
|
|
30
|
+
// packages/plugins/plugin-sheet/src/defs/types.ts
|
|
31
|
+
import { invariant } from "@dxos/invariant";
|
|
32
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
33
|
+
var DEFAULT_ROWS = 50;
|
|
34
|
+
var DEFAULT_COLUMNS = 26;
|
|
35
|
+
var MAX_ROWS = 500;
|
|
36
|
+
var MAX_COLUMNS = 26 * 2;
|
|
37
|
+
var posEquals = (a, b) => {
|
|
38
|
+
return a?.col === b?.col && a?.row === b?.row;
|
|
39
|
+
};
|
|
40
|
+
var columnLetter = (col) => {
|
|
41
|
+
invariant(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
42
|
+
F: __dxlog_file,
|
|
43
|
+
L: 26,
|
|
44
|
+
S: void 0,
|
|
45
|
+
A: [
|
|
46
|
+
"col < MAX_COLUMNS",
|
|
47
|
+
"`Invalid column: ${col}`"
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
51
|
+
};
|
|
52
|
+
var addressToA1Notation = ({ col, row }) => {
|
|
53
|
+
return `${columnLetter(col)}${row + 1}`;
|
|
54
|
+
};
|
|
55
|
+
var addressFromA1Notation = (ref) => {
|
|
56
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
57
|
+
invariant(match, `Invalid notation: ${ref}`, {
|
|
58
|
+
F: __dxlog_file,
|
|
59
|
+
L: 39,
|
|
60
|
+
S: void 0,
|
|
61
|
+
A: [
|
|
62
|
+
"match",
|
|
63
|
+
"`Invalid notation: ${ref}`"
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
row: parseInt(match[2], 10) - 1,
|
|
68
|
+
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
var rangeToA1Notation = (range) => {
|
|
72
|
+
return [
|
|
73
|
+
range?.from && addressToA1Notation(range?.from),
|
|
74
|
+
range?.to && addressToA1Notation(range?.to)
|
|
75
|
+
].filter(Boolean).join(":");
|
|
76
|
+
};
|
|
77
|
+
var inRange = (range, cell) => {
|
|
78
|
+
if (!range) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const { from, to } = range;
|
|
82
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (!from || !to) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const { col: c1, row: r1 } = from;
|
|
89
|
+
const { col: c2, row: r2 } = to;
|
|
90
|
+
const cMin = Math.min(c1, c2);
|
|
91
|
+
const cMax = Math.max(c1, c2);
|
|
92
|
+
const rMin = Math.min(r1, r2);
|
|
93
|
+
const rMax = Math.max(r1, r2);
|
|
94
|
+
const { col, row } = cell;
|
|
95
|
+
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// packages/plugins/plugin-sheet/src/defs/util.ts
|
|
99
|
+
import { randomBytes } from "@dxos/crypto";
|
|
100
|
+
import { create } from "@dxos/echo-schema";
|
|
101
|
+
var ApiError = class extends Error {
|
|
102
|
+
};
|
|
103
|
+
var ReadonlyException = class extends ApiError {
|
|
104
|
+
};
|
|
105
|
+
var RangeException = class extends ApiError {
|
|
106
|
+
constructor(n) {
|
|
107
|
+
super();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var createIndex = (length = 8) => {
|
|
111
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
112
|
+
const charactersLength = characters.length;
|
|
113
|
+
const randomBuffer = randomBytes(length);
|
|
114
|
+
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
115
|
+
};
|
|
116
|
+
var createIndices = (length) => Array.from({
|
|
117
|
+
length
|
|
118
|
+
}).map(() => createIndex());
|
|
119
|
+
var insertIndices = (indices, i, n, max) => {
|
|
120
|
+
if (i + n > max) {
|
|
121
|
+
throw new RangeException(i + n);
|
|
122
|
+
}
|
|
123
|
+
const idx = createIndices(n);
|
|
124
|
+
indices.splice(i, 0, ...idx);
|
|
125
|
+
};
|
|
126
|
+
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
127
|
+
if (!sheet.rows.length) {
|
|
128
|
+
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
129
|
+
}
|
|
130
|
+
if (!sheet.columns.length) {
|
|
131
|
+
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var createSheet = ({ title, ...size } = {}) => {
|
|
135
|
+
const sheet = create(SheetType, {
|
|
136
|
+
title,
|
|
137
|
+
cells: {},
|
|
138
|
+
rows: [],
|
|
139
|
+
columns: [],
|
|
140
|
+
rowMeta: {},
|
|
141
|
+
columnMeta: {},
|
|
142
|
+
formatting: {}
|
|
143
|
+
});
|
|
144
|
+
initialize(sheet, size);
|
|
145
|
+
return sheet;
|
|
146
|
+
};
|
|
147
|
+
var addressToIndex = (sheet, cell) => {
|
|
148
|
+
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
149
|
+
};
|
|
150
|
+
var addressFromIndex = (sheet, idx) => {
|
|
151
|
+
const [column, row] = idx.split("@");
|
|
152
|
+
return {
|
|
153
|
+
col: sheet.columns.indexOf(column),
|
|
154
|
+
row: sheet.rows.indexOf(row)
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
var rangeFromIndex = (sheet, idx) => {
|
|
158
|
+
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
159
|
+
return {
|
|
160
|
+
from,
|
|
161
|
+
to
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
var closest = (cursor, cells) => {
|
|
165
|
+
let closestCell;
|
|
166
|
+
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
167
|
+
for (const cell of cells) {
|
|
168
|
+
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
169
|
+
if (distance < closestDistance) {
|
|
170
|
+
closestCell = cell;
|
|
171
|
+
closestDistance = distance;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return closestCell;
|
|
175
|
+
};
|
|
176
|
+
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
177
|
+
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
178
|
+
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
179
|
+
if (rowA !== rowB) {
|
|
180
|
+
return rowA - rowB;
|
|
181
|
+
} else {
|
|
182
|
+
return columnA - columnB;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
40
187
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
41
188
|
var axisHeight = 34;
|
|
42
189
|
var minWidth = 40;
|
|
@@ -78,7 +225,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
78
225
|
const left = x;
|
|
79
226
|
x += width2 - 1;
|
|
80
227
|
return {
|
|
81
|
-
|
|
228
|
+
col: i,
|
|
82
229
|
left,
|
|
83
230
|
width: width2
|
|
84
231
|
};
|
|
@@ -183,14 +330,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
183
330
|
break;
|
|
184
331
|
}
|
|
185
332
|
case "ArrowLeft": {
|
|
186
|
-
if (opposite.
|
|
187
|
-
opposite.
|
|
333
|
+
if (opposite.col > 0) {
|
|
334
|
+
opposite.col -= 1;
|
|
188
335
|
}
|
|
189
336
|
break;
|
|
190
337
|
}
|
|
191
338
|
case "ArrowRight": {
|
|
192
|
-
if (opposite.
|
|
193
|
-
opposite.
|
|
339
|
+
if (opposite.col < size.numCols - 1) {
|
|
340
|
+
opposite.col += 1;
|
|
194
341
|
}
|
|
195
342
|
break;
|
|
196
343
|
}
|
|
@@ -208,18 +355,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
208
355
|
cursor: next
|
|
209
356
|
};
|
|
210
357
|
};
|
|
211
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
358
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
212
359
|
switch (ev.key) {
|
|
213
360
|
case "ArrowUp":
|
|
214
361
|
if (cursor === void 0) {
|
|
215
362
|
return {
|
|
216
363
|
row: 0,
|
|
217
|
-
|
|
364
|
+
col: 0
|
|
218
365
|
};
|
|
219
366
|
} else if (cursor.row > 0) {
|
|
220
367
|
return {
|
|
221
368
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
222
|
-
|
|
369
|
+
col: cursor.col
|
|
223
370
|
};
|
|
224
371
|
}
|
|
225
372
|
break;
|
|
@@ -227,12 +374,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
227
374
|
if (cursor === void 0) {
|
|
228
375
|
return {
|
|
229
376
|
row: 0,
|
|
230
|
-
|
|
377
|
+
col: 0
|
|
231
378
|
};
|
|
232
379
|
} else if (cursor.row < numRows - 1) {
|
|
233
380
|
return {
|
|
234
381
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
235
|
-
|
|
382
|
+
col: cursor.col
|
|
236
383
|
};
|
|
237
384
|
}
|
|
238
385
|
break;
|
|
@@ -240,12 +387,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
240
387
|
if (cursor === void 0) {
|
|
241
388
|
return {
|
|
242
389
|
row: 0,
|
|
243
|
-
|
|
390
|
+
col: 0
|
|
244
391
|
};
|
|
245
|
-
} else if (cursor.
|
|
392
|
+
} else if (cursor.col > 0) {
|
|
246
393
|
return {
|
|
247
394
|
row: cursor.row,
|
|
248
|
-
|
|
395
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
249
396
|
};
|
|
250
397
|
}
|
|
251
398
|
break;
|
|
@@ -253,24 +400,24 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
253
400
|
if (cursor === void 0) {
|
|
254
401
|
return {
|
|
255
402
|
row: 0,
|
|
256
|
-
|
|
403
|
+
col: 0
|
|
257
404
|
};
|
|
258
|
-
} else if (cursor.
|
|
405
|
+
} else if (cursor.col < numCols - 1) {
|
|
259
406
|
return {
|
|
260
407
|
row: cursor.row,
|
|
261
|
-
|
|
408
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
262
409
|
};
|
|
263
410
|
}
|
|
264
411
|
break;
|
|
265
412
|
case "Home":
|
|
266
413
|
return {
|
|
267
414
|
row: 0,
|
|
268
|
-
|
|
415
|
+
col: 0
|
|
269
416
|
};
|
|
270
417
|
case "End":
|
|
271
418
|
return {
|
|
272
419
|
row: numRows - 1,
|
|
273
|
-
|
|
420
|
+
col: numCols - 1
|
|
274
421
|
};
|
|
275
422
|
}
|
|
276
423
|
};
|
|
@@ -327,31 +474,103 @@ var useRangeSelect = (cb) => {
|
|
|
327
474
|
};
|
|
328
475
|
|
|
329
476
|
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
330
|
-
import
|
|
331
|
-
import { invariant } from "@dxos/invariant";
|
|
332
|
-
|
|
477
|
+
import React3, { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useState as useState4 } from "react";
|
|
478
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
479
|
+
|
|
480
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/decorations.ts
|
|
481
|
+
import { create as create2 } from "@dxos/echo-schema";
|
|
482
|
+
var createDecorations = () => {
|
|
483
|
+
const { decorations } = create2({
|
|
484
|
+
decorations: {}
|
|
485
|
+
});
|
|
486
|
+
const addDecoration = (cellIndex, decorator) => {
|
|
487
|
+
decorations[cellIndex] = [
|
|
488
|
+
...decorations[cellIndex] || [],
|
|
489
|
+
decorator
|
|
490
|
+
];
|
|
491
|
+
};
|
|
492
|
+
const removeDecoration = (cellIndex, type) => {
|
|
493
|
+
if (type) {
|
|
494
|
+
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
495
|
+
} else {
|
|
496
|
+
delete decorations[cellIndex];
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
const getDecorationsForCell = (cellIndex) => {
|
|
500
|
+
return decorations[cellIndex];
|
|
501
|
+
};
|
|
502
|
+
const getAllDecorations = () => {
|
|
503
|
+
const result = [];
|
|
504
|
+
for (const decoratorArray of Object.values(decorations)) {
|
|
505
|
+
for (const decorator of decoratorArray) {
|
|
506
|
+
result.push(decorator);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return result;
|
|
510
|
+
};
|
|
511
|
+
return {
|
|
512
|
+
addDecoration,
|
|
513
|
+
removeDecoration,
|
|
514
|
+
getDecorationsForCell,
|
|
515
|
+
getAllDecorations
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
520
|
+
import { useContext } from "react";
|
|
521
|
+
import { raise } from "@dxos/debug";
|
|
522
|
+
import { useAsyncState } from "@dxos/react-hooks";
|
|
523
|
+
|
|
524
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
525
|
+
import React2 from "react";
|
|
526
|
+
|
|
527
|
+
// packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
528
|
+
import React, { createContext } from "react";
|
|
529
|
+
var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
|
|
530
|
+
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
531
|
+
return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
|
|
532
|
+
value: {
|
|
533
|
+
registry
|
|
534
|
+
}
|
|
535
|
+
}, children);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
539
|
+
var SheetContainer = React2.lazy(() => import("./SheetContainer-V4GCCZTX.mjs"));
|
|
333
540
|
|
|
334
|
-
// packages/plugins/plugin-sheet/src/
|
|
541
|
+
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
542
|
+
var useComputeGraph = (space) => {
|
|
543
|
+
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
544
|
+
return useAsyncState(async () => space && registry.getOrCreateGraph(space), [
|
|
545
|
+
space,
|
|
546
|
+
registry
|
|
547
|
+
]);
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
551
|
+
import { useMemo } from "react";
|
|
552
|
+
|
|
553
|
+
// packages/plugins/plugin-sheet/src/model/formatting-model.ts
|
|
335
554
|
var FormattingModel = class {
|
|
336
|
-
constructor(
|
|
337
|
-
this.
|
|
555
|
+
constructor(_model) {
|
|
556
|
+
this._model = _model;
|
|
338
557
|
}
|
|
339
558
|
/**
|
|
340
559
|
* Get formatted string value and className for cell.
|
|
341
560
|
*/
|
|
342
561
|
getFormatting(cell) {
|
|
343
|
-
const value = this.
|
|
562
|
+
const value = this._model.getValue(cell);
|
|
344
563
|
if (value === void 0 || value === null) {
|
|
345
564
|
return {};
|
|
346
565
|
}
|
|
347
566
|
const locales = void 0;
|
|
348
|
-
const idx = this.
|
|
349
|
-
let formatting = this.
|
|
567
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
568
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
350
569
|
const classNames = [
|
|
351
570
|
...formatting?.classNames ?? []
|
|
352
571
|
];
|
|
353
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
354
|
-
const range = this.
|
|
572
|
+
for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
|
|
573
|
+
const range = rangeFromIndex(this._model.sheet, idx2);
|
|
355
574
|
if (inRange(range, cell)) {
|
|
356
575
|
if (_formatting.classNames) {
|
|
357
576
|
classNames.push(..._formatting.classNames);
|
|
@@ -362,7 +581,7 @@ var FormattingModel = class {
|
|
|
362
581
|
}
|
|
363
582
|
}
|
|
364
583
|
const defaultNumber = "justify-end font-mono";
|
|
365
|
-
const type = formatting?.type ?? this.
|
|
584
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
366
585
|
switch (type) {
|
|
367
586
|
case ValueTypeEnum.Boolean: {
|
|
368
587
|
return {
|
|
@@ -412,21 +631,21 @@ var FormattingModel = class {
|
|
|
412
631
|
// Dates.
|
|
413
632
|
//
|
|
414
633
|
case ValueTypeEnum.DateTime: {
|
|
415
|
-
const date = this.
|
|
634
|
+
const date = this._model.toLocalDate(value);
|
|
416
635
|
return {
|
|
417
636
|
value: date.toLocaleString(locales),
|
|
418
637
|
classNames
|
|
419
638
|
};
|
|
420
639
|
}
|
|
421
640
|
case ValueTypeEnum.Date: {
|
|
422
|
-
const date = this.
|
|
641
|
+
const date = this._model.toLocalDate(value);
|
|
423
642
|
return {
|
|
424
643
|
value: date.toLocaleDateString(locales),
|
|
425
644
|
classNames
|
|
426
645
|
};
|
|
427
646
|
}
|
|
428
647
|
case ValueTypeEnum.Time: {
|
|
429
|
-
const date = this.
|
|
648
|
+
const date = this._model.toLocalDate(value);
|
|
430
649
|
return {
|
|
431
650
|
value: date.toLocaleTimeString(locales),
|
|
432
651
|
classNames
|
|
@@ -442,84 +661,428 @@ var FormattingModel = class {
|
|
|
442
661
|
}
|
|
443
662
|
};
|
|
444
663
|
|
|
445
|
-
// packages/plugins/plugin-sheet/src/
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
664
|
+
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
665
|
+
import { Event } from "@dxos/async";
|
|
666
|
+
import { Resource } from "@dxos/context";
|
|
667
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
668
|
+
import { PublicKey } from "@dxos/keys";
|
|
669
|
+
import { log } from "@dxos/log";
|
|
670
|
+
import { DetailedCellError, ExportedCellChange } from "#hyperformula";
|
|
671
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
672
|
+
var typeMap = {
|
|
673
|
+
BOOLEAN: ValueTypeEnum.Boolean,
|
|
674
|
+
NUMBER_RAW: ValueTypeEnum.Number,
|
|
675
|
+
NUMBER_PERCENT: ValueTypeEnum.Percent,
|
|
676
|
+
NUMBER_CURRENCY: ValueTypeEnum.Currency,
|
|
677
|
+
NUMBER_DATETIME: ValueTypeEnum.DateTime,
|
|
678
|
+
NUMBER_DATE: ValueTypeEnum.Date,
|
|
679
|
+
NUMBER_TIME: ValueTypeEnum.Time
|
|
461
680
|
};
|
|
462
|
-
var
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
681
|
+
var getTopLeft = (range) => {
|
|
682
|
+
const to = range.to ?? range.from;
|
|
683
|
+
return {
|
|
684
|
+
row: Math.min(range.from.row, to.row),
|
|
685
|
+
col: Math.min(range.from.col, to.col)
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
689
|
+
sheet,
|
|
690
|
+
row: cell.row,
|
|
691
|
+
col: cell.col
|
|
692
|
+
});
|
|
693
|
+
var toModelRange = (sheet, range) => ({
|
|
694
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
695
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
696
|
+
});
|
|
697
|
+
var SheetModel = class extends Resource {
|
|
698
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
699
|
+
super();
|
|
700
|
+
this._graph = _graph;
|
|
701
|
+
this._sheet = _sheet;
|
|
702
|
+
this._options = _options;
|
|
703
|
+
this.id = `model-${PublicKey.random().truncate()}`;
|
|
704
|
+
this.update = new Event();
|
|
705
|
+
this._node = this._graph.getOrCreateNode(createSheetName(this._sheet.id));
|
|
706
|
+
this.reset();
|
|
707
|
+
}
|
|
708
|
+
get graph() {
|
|
709
|
+
return this._graph;
|
|
710
|
+
}
|
|
711
|
+
get sheet() {
|
|
712
|
+
return this._sheet;
|
|
713
|
+
}
|
|
714
|
+
get readonly() {
|
|
715
|
+
return this._options.readonly;
|
|
716
|
+
}
|
|
717
|
+
get bounds() {
|
|
718
|
+
return {
|
|
719
|
+
rows: this._sheet.rows.length,
|
|
720
|
+
columns: this._sheet.columns.length
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Initialize sheet and engine.
|
|
725
|
+
*/
|
|
726
|
+
async _open() {
|
|
727
|
+
log("initialize", {
|
|
728
|
+
id: this.id
|
|
729
|
+
}, {
|
|
730
|
+
F: __dxlog_file2,
|
|
731
|
+
L: 105,
|
|
732
|
+
S: this,
|
|
733
|
+
C: (f, a) => f(...a)
|
|
734
|
+
});
|
|
735
|
+
initialize(this._sheet);
|
|
736
|
+
this.reset();
|
|
737
|
+
const unsubscribe = this._graph.update.on(() => this.update.emit());
|
|
738
|
+
this._ctx.onDispose(unsubscribe);
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Update engine.
|
|
742
|
+
* NOTE: This resets the undo history.
|
|
743
|
+
* @deprecated
|
|
744
|
+
*/
|
|
745
|
+
reset() {
|
|
746
|
+
this._node.hf.clearSheet(this._node.sheetId);
|
|
747
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
748
|
+
const { col, row } = addressFromIndex(this._sheet, key);
|
|
749
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
750
|
+
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
751
|
+
}
|
|
752
|
+
this._node.hf.setCellContents({
|
|
753
|
+
sheet: this._node.sheetId,
|
|
754
|
+
row,
|
|
755
|
+
col
|
|
756
|
+
}, value);
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Recalculate formulas.
|
|
761
|
+
* NOTE: This resets the undo history.
|
|
762
|
+
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
763
|
+
* @deprecated
|
|
764
|
+
*/
|
|
765
|
+
// TODO(burdon): Remove.
|
|
766
|
+
recalculate() {
|
|
767
|
+
this._node.hf.rebuildAndRecalculate();
|
|
768
|
+
}
|
|
769
|
+
insertRows(i, n = 1) {
|
|
770
|
+
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
771
|
+
this.reset();
|
|
772
|
+
}
|
|
773
|
+
insertColumns(i, n = 1) {
|
|
774
|
+
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
775
|
+
this.reset();
|
|
776
|
+
}
|
|
777
|
+
//
|
|
778
|
+
// Undoable actions.
|
|
779
|
+
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
780
|
+
//
|
|
781
|
+
/**
|
|
782
|
+
* Clear range of values.
|
|
783
|
+
*/
|
|
784
|
+
clear(range) {
|
|
785
|
+
const topLeft = getTopLeft(range);
|
|
786
|
+
const values = this._iterRange(range, () => null);
|
|
787
|
+
this._node.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
788
|
+
this._iterRange(range, (cell) => {
|
|
789
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
790
|
+
delete this._sheet.cells[idx];
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
cut(range) {
|
|
794
|
+
this._node.hf.cut(toModelRange(this._node.sheetId, range));
|
|
795
|
+
this._iterRange(range, (cell) => {
|
|
796
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
797
|
+
delete this._sheet.cells[idx];
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
copy(range) {
|
|
801
|
+
this._node.hf.copy(toModelRange(this._node.sheetId, range));
|
|
802
|
+
}
|
|
803
|
+
paste(cell) {
|
|
804
|
+
if (!this._node.hf.isClipboardEmpty()) {
|
|
805
|
+
const changes = this._node.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
806
|
+
for (const change of changes) {
|
|
807
|
+
if (change instanceof ExportedCellChange) {
|
|
808
|
+
const { address, newValue } = change;
|
|
809
|
+
const idx = addressToIndex(this._sheet, {
|
|
810
|
+
row: address.row,
|
|
811
|
+
col: address.col
|
|
812
|
+
});
|
|
813
|
+
this._sheet.cells[idx] = {
|
|
814
|
+
value: newValue
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
// TODO(burdon): Display undo/redo state.
|
|
821
|
+
undo() {
|
|
822
|
+
if (this._node.hf.isThereSomethingToUndo()) {
|
|
823
|
+
this._node.hf.undo();
|
|
824
|
+
this.update.emit();
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
redo() {
|
|
828
|
+
if (this._node.hf.isThereSomethingToRedo()) {
|
|
829
|
+
this._node.hf.redo();
|
|
830
|
+
this.update.emit();
|
|
466
831
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Get value from sheet.
|
|
835
|
+
*/
|
|
836
|
+
getCellValue(cell) {
|
|
837
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
838
|
+
return this._sheet.cells[idx]?.value ?? null;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Get value as a string for editing.
|
|
842
|
+
*/
|
|
843
|
+
getCellText(cell) {
|
|
844
|
+
const value = this.getCellValue(cell);
|
|
845
|
+
if (value == null) {
|
|
846
|
+
return void 0;
|
|
847
|
+
}
|
|
848
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
849
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
470
850
|
} else {
|
|
471
|
-
return
|
|
851
|
+
return String(value);
|
|
472
852
|
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Get array of raw values from sheet.
|
|
856
|
+
*/
|
|
857
|
+
getCellValues(range) {
|
|
858
|
+
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Gets the regular or computed value from the engine.
|
|
862
|
+
*/
|
|
863
|
+
getValue(cell) {
|
|
864
|
+
const value = this._node.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
865
|
+
if (value instanceof DetailedCellError) {
|
|
866
|
+
return value.toString();
|
|
867
|
+
}
|
|
868
|
+
return value;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Get value type.
|
|
872
|
+
*/
|
|
873
|
+
getValueType(cell) {
|
|
874
|
+
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
875
|
+
const type = this._node.hf.getCellValueDetailedType(addr);
|
|
876
|
+
return typeMap[type];
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Sets the value, updating the sheet and engine.
|
|
880
|
+
*/
|
|
881
|
+
setValue(cell, value) {
|
|
882
|
+
if (this._options.readonly) {
|
|
883
|
+
throw new ReadonlyException();
|
|
884
|
+
}
|
|
885
|
+
let refresh = false;
|
|
886
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
887
|
+
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
888
|
+
refresh = true;
|
|
889
|
+
}
|
|
890
|
+
if (cell.col >= this._sheet.columns.length) {
|
|
891
|
+
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
892
|
+
refresh = true;
|
|
480
893
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
894
|
+
if (refresh) {
|
|
895
|
+
this.reset();
|
|
896
|
+
}
|
|
897
|
+
this._node.hf.setCellContents({
|
|
898
|
+
sheet: this._node.sheetId,
|
|
899
|
+
row: cell.row,
|
|
900
|
+
col: cell.col
|
|
901
|
+
}, [
|
|
902
|
+
[
|
|
903
|
+
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
904
|
+
]
|
|
905
|
+
]);
|
|
906
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
907
|
+
if (value === void 0 || value === null) {
|
|
908
|
+
delete this._sheet.cells[idx];
|
|
484
909
|
} else {
|
|
485
|
-
|
|
910
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
911
|
+
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
912
|
+
}
|
|
913
|
+
this._sheet.cells[idx] = {
|
|
914
|
+
value
|
|
915
|
+
};
|
|
486
916
|
}
|
|
487
|
-
}
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Sets values from a simple map.
|
|
920
|
+
*/
|
|
921
|
+
setValues(values) {
|
|
922
|
+
Object.entries(values).forEach(([key, { value }]) => {
|
|
923
|
+
this.setValue(addressFromA1Notation(key), value);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Iterate range.
|
|
928
|
+
*/
|
|
929
|
+
_iterRange(range, cb) {
|
|
930
|
+
const to = range.to ?? range.from;
|
|
931
|
+
const rowRange = [
|
|
932
|
+
Math.min(range.from.row, to.row),
|
|
933
|
+
Math.max(range.from.row, to.row)
|
|
934
|
+
];
|
|
935
|
+
const columnRange = [
|
|
936
|
+
Math.min(range.from.col, to.col),
|
|
937
|
+
Math.max(range.from.col, to.col)
|
|
938
|
+
];
|
|
939
|
+
const rows = [];
|
|
940
|
+
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
941
|
+
const rowCells = [];
|
|
942
|
+
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
943
|
+
const value = cb({
|
|
944
|
+
row,
|
|
945
|
+
col: column
|
|
946
|
+
});
|
|
947
|
+
if (value !== void 0) {
|
|
948
|
+
rowCells.push(value);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
rows.push(rowCells);
|
|
952
|
+
}
|
|
953
|
+
return rows;
|
|
954
|
+
}
|
|
955
|
+
// TODO(burdon): Delete index.
|
|
956
|
+
_deleteIndices(indices, i, n) {
|
|
957
|
+
throw new Error("Not implemented");
|
|
958
|
+
}
|
|
959
|
+
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
960
|
+
_moveIndices(indices, i, j, n) {
|
|
961
|
+
throw new Error("Not implemented");
|
|
962
|
+
}
|
|
963
|
+
//
|
|
964
|
+
// Indices.
|
|
965
|
+
//
|
|
966
|
+
/**
|
|
967
|
+
* Map from A1 notation to indices.
|
|
968
|
+
*/
|
|
969
|
+
mapFormulaRefsToIndices(formula) {
|
|
970
|
+
invariant2(formula.charAt(0) === "=", void 0, {
|
|
971
|
+
F: __dxlog_file2,
|
|
972
|
+
L: 358,
|
|
973
|
+
S: this,
|
|
974
|
+
A: [
|
|
975
|
+
"formula.charAt(0) === '='",
|
|
976
|
+
""
|
|
977
|
+
]
|
|
978
|
+
});
|
|
979
|
+
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
980
|
+
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Map from indices to A1 notation.
|
|
985
|
+
*/
|
|
986
|
+
mapFormulaIndicesToRefs(formula) {
|
|
987
|
+
invariant2(formula.charAt(0) === "=", void 0, {
|
|
988
|
+
F: __dxlog_file2,
|
|
989
|
+
L: 368,
|
|
990
|
+
S: this,
|
|
991
|
+
A: [
|
|
992
|
+
"formula.charAt(0) === '='",
|
|
993
|
+
""
|
|
994
|
+
]
|
|
995
|
+
});
|
|
996
|
+
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
997
|
+
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
//
|
|
1001
|
+
// Values
|
|
1002
|
+
//
|
|
1003
|
+
/**
|
|
1004
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1005
|
+
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1006
|
+
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1007
|
+
*/
|
|
1008
|
+
toLocalDate(num) {
|
|
1009
|
+
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1010
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1011
|
+
}
|
|
1012
|
+
toDateTime(num) {
|
|
1013
|
+
return this._node.hf.numberToDateTime(num);
|
|
1014
|
+
}
|
|
1015
|
+
toDate(num) {
|
|
1016
|
+
return this._node.hf.numberToDate(num);
|
|
1017
|
+
}
|
|
1018
|
+
toTime(num) {
|
|
1019
|
+
return this._node.hf.numberToTime(num);
|
|
1020
|
+
}
|
|
488
1021
|
};
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
1022
|
+
|
|
1023
|
+
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
1024
|
+
var useFormattingModel = (model) => {
|
|
1025
|
+
return useMemo(() => model && new FormattingModel(model), [
|
|
1026
|
+
model
|
|
1027
|
+
]);
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
// packages/plugins/plugin-sheet/src/hooks/useSheetModel.ts
|
|
1031
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1032
|
+
var useSheetModel = (space, sheet, { readonly } = {}) => {
|
|
1033
|
+
const graph = useComputeGraph(space);
|
|
1034
|
+
const [model, setModel] = useState3();
|
|
495
1035
|
useEffect2(() => {
|
|
1036
|
+
if (!space || !graph || !sheet) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
496
1039
|
let model2;
|
|
497
|
-
let formatting2;
|
|
498
1040
|
const t = setTimeout(async () => {
|
|
499
|
-
model2 = new SheetModel(graph, sheet,
|
|
500
|
-
readonly
|
|
501
|
-
mapFormulaBindingToId,
|
|
502
|
-
mapFormulaBindingFromId
|
|
1041
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1042
|
+
readonly
|
|
503
1043
|
});
|
|
504
|
-
await model2.
|
|
505
|
-
|
|
506
|
-
setModels([
|
|
507
|
-
model2,
|
|
508
|
-
formatting2
|
|
509
|
-
]);
|
|
1044
|
+
await model2.open();
|
|
1045
|
+
setModel(model2);
|
|
510
1046
|
});
|
|
511
1047
|
return () => {
|
|
512
1048
|
clearTimeout(t);
|
|
513
|
-
void model2?.
|
|
1049
|
+
void model2?.close();
|
|
514
1050
|
};
|
|
515
1051
|
}, [
|
|
1052
|
+
space,
|
|
1053
|
+
sheet,
|
|
516
1054
|
graph,
|
|
517
1055
|
readonly
|
|
518
1056
|
]);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
1057
|
+
return model;
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
1061
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1062
|
+
var SheetContext = /* @__PURE__ */ createContext2(null);
|
|
1063
|
+
var useSheetContext = () => {
|
|
1064
|
+
const context = useContext2(SheetContext);
|
|
1065
|
+
invariant3(context, void 0, {
|
|
1066
|
+
F: __dxlog_file3,
|
|
1067
|
+
L: 43,
|
|
1068
|
+
S: void 0,
|
|
1069
|
+
A: [
|
|
1070
|
+
"context",
|
|
1071
|
+
""
|
|
1072
|
+
]
|
|
1073
|
+
});
|
|
1074
|
+
return context;
|
|
1075
|
+
};
|
|
1076
|
+
var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
|
|
1077
|
+
const model = useSheetModel(space, sheet, {
|
|
1078
|
+
readonly
|
|
1079
|
+
});
|
|
1080
|
+
const formatting = useFormattingModel(model);
|
|
1081
|
+
const [cursor, setCursor] = useState4();
|
|
1082
|
+
const [range, setRange] = useState4();
|
|
1083
|
+
const [editing, setEditing] = useState4(false);
|
|
1084
|
+
const decorations = useMemo2(() => createDecorations(), []);
|
|
1085
|
+
return !model || !formatting ? null : /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
|
|
523
1086
|
value: {
|
|
524
1087
|
model,
|
|
525
1088
|
formatting,
|
|
@@ -530,11 +1093,177 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
530
1093
|
editing,
|
|
531
1094
|
setEditing,
|
|
532
1095
|
// TODO(burdon): Change to event.
|
|
533
|
-
onInfo
|
|
1096
|
+
onInfo,
|
|
1097
|
+
decorations
|
|
534
1098
|
}
|
|
535
1099
|
}, children);
|
|
536
1100
|
};
|
|
537
1101
|
|
|
1102
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/threads.tsx
|
|
1103
|
+
import { effect } from "@preact/signals-core";
|
|
1104
|
+
import React4, { useCallback, useEffect as useEffect3, useMemo as useMemo3 } from "react";
|
|
1105
|
+
import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
|
|
1106
|
+
import { debounce } from "@dxos/async";
|
|
1107
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
1108
|
+
import { Icon, useTranslation } from "@dxos/react-ui";
|
|
1109
|
+
var CommentIndicator = () => {
|
|
1110
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1111
|
+
role: "none",
|
|
1112
|
+
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
1113
|
+
});
|
|
1114
|
+
};
|
|
1115
|
+
var ThreadedCellWrapper = ({ children }) => {
|
|
1116
|
+
const dispatch = useIntentDispatcher();
|
|
1117
|
+
const [isHovered, setIsHovered] = React4.useState(false);
|
|
1118
|
+
const { t } = useTranslation(SHEET_PLUGIN);
|
|
1119
|
+
const handleClick = React4.useCallback((_event) => {
|
|
1120
|
+
void dispatch({
|
|
1121
|
+
action: LayoutAction.SET_LAYOUT,
|
|
1122
|
+
data: {
|
|
1123
|
+
element: "complementary",
|
|
1124
|
+
state: true
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
}, [
|
|
1128
|
+
dispatch
|
|
1129
|
+
]);
|
|
1130
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1131
|
+
role: "none",
|
|
1132
|
+
className: "relative h-full is-full",
|
|
1133
|
+
onMouseEnter: () => {
|
|
1134
|
+
setIsHovered(true);
|
|
1135
|
+
},
|
|
1136
|
+
onMouseLeave: () => {
|
|
1137
|
+
setIsHovered(false);
|
|
1138
|
+
}
|
|
1139
|
+
}, /* @__PURE__ */ React4.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React4.createElement("div", {
|
|
1140
|
+
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
1141
|
+
}, /* @__PURE__ */ React4.createElement("button", {
|
|
1142
|
+
className: "ch-button text-xs min-bs-0 p-1",
|
|
1143
|
+
onClick: handleClick,
|
|
1144
|
+
"aria-label": t("open comment for sheet cell")
|
|
1145
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1146
|
+
icon: "ph--chat--regular",
|
|
1147
|
+
"aria-hidden": true
|
|
1148
|
+
}))), children);
|
|
1149
|
+
};
|
|
1150
|
+
var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
1151
|
+
return {
|
|
1152
|
+
type: "comment",
|
|
1153
|
+
cellIndex,
|
|
1154
|
+
decorate: (props) => /* @__PURE__ */ React4.createElement(ThreadedCellWrapper, props)
|
|
1155
|
+
};
|
|
1156
|
+
};
|
|
1157
|
+
var useUpdateCursorOnThreadSelection = () => {
|
|
1158
|
+
const { setCursor, model } = useSheetContext();
|
|
1159
|
+
const handleScrollIntoView = useCallback(({ action, data }) => {
|
|
1160
|
+
switch (action) {
|
|
1161
|
+
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
1162
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId(model.sheet)) {
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
1166
|
+
setCursor(cellAddress);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}, [
|
|
1170
|
+
model.sheet,
|
|
1171
|
+
setCursor
|
|
1172
|
+
]);
|
|
1173
|
+
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
1174
|
+
};
|
|
1175
|
+
var useSelectThreadOnCursorChange = () => {
|
|
1176
|
+
const { cursor, model } = useSheetContext();
|
|
1177
|
+
const dispatch = useIntentDispatcher();
|
|
1178
|
+
const activeThreads = useMemo3(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
1179
|
+
JSON.stringify(model.sheet.threads)
|
|
1180
|
+
]);
|
|
1181
|
+
const activeThreadAddresses = useMemo3(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
1182
|
+
activeThreads,
|
|
1183
|
+
model.sheet
|
|
1184
|
+
]);
|
|
1185
|
+
const selectClosestThread = useCallback((cellAddress) => {
|
|
1186
|
+
if (!cellAddress || !activeThreads) {
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
1190
|
+
if (closestThreadAnchor) {
|
|
1191
|
+
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
1192
|
+
if (closestThread) {
|
|
1193
|
+
void dispatch([
|
|
1194
|
+
{
|
|
1195
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
1196
|
+
data: {
|
|
1197
|
+
current: fullyQualifiedId(closestThread)
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
]);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}, [
|
|
1204
|
+
dispatch,
|
|
1205
|
+
activeThreads,
|
|
1206
|
+
activeThreadAddresses,
|
|
1207
|
+
model.sheet
|
|
1208
|
+
]);
|
|
1209
|
+
const debounced = useMemo3(() => {
|
|
1210
|
+
return debounce((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
1211
|
+
}, [
|
|
1212
|
+
selectClosestThread
|
|
1213
|
+
]);
|
|
1214
|
+
useEffect3(() => {
|
|
1215
|
+
if (!cursor) {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
debounced(cursor);
|
|
1219
|
+
}, [
|
|
1220
|
+
cursor,
|
|
1221
|
+
selectClosestThread
|
|
1222
|
+
]);
|
|
1223
|
+
};
|
|
1224
|
+
var useThreadDecorations = () => {
|
|
1225
|
+
const { decorations, model } = useSheetContext();
|
|
1226
|
+
const sheet = useMemo3(() => model.sheet, [
|
|
1227
|
+
model.sheet
|
|
1228
|
+
]);
|
|
1229
|
+
const sheetId = useMemo3(() => fullyQualifiedId(sheet), [
|
|
1230
|
+
sheet
|
|
1231
|
+
]);
|
|
1232
|
+
useEffect3(() => {
|
|
1233
|
+
const unsubscribe = effect(() => {
|
|
1234
|
+
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
1235
|
+
if (!sheet.threads) {
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
for (const thread of sheet.threads) {
|
|
1239
|
+
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1240
|
+
continue;
|
|
1241
|
+
}
|
|
1242
|
+
activeThreadAnchors.add(thread.anchor);
|
|
1243
|
+
const index = thread.anchor;
|
|
1244
|
+
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1245
|
+
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1246
|
+
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
for (const decoration of decorations.getAllDecorations()) {
|
|
1250
|
+
if (decoration.type !== "comment") {
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1254
|
+
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
return () => unsubscribe();
|
|
1259
|
+
});
|
|
1260
|
+
};
|
|
1261
|
+
var useThreads = () => {
|
|
1262
|
+
useUpdateCursorOnThreadSelection();
|
|
1263
|
+
useSelectThreadOnCursorChange();
|
|
1264
|
+
useThreadDecorations();
|
|
1265
|
+
};
|
|
1266
|
+
|
|
538
1267
|
// packages/plugins/plugin-sheet/src/components/Sheet/util.ts
|
|
539
1268
|
var getRelativeClientRect = (root, element) => {
|
|
540
1269
|
const rootRect = root.getBoundingClientRect();
|
|
@@ -570,7 +1299,7 @@ var scrollIntoView = (scrollContainer, el) => {
|
|
|
570
1299
|
|
|
571
1300
|
// packages/plugins/plugin-sheet/src/components/CellEditor/CellEditor.tsx
|
|
572
1301
|
import { EditorView, keymap } from "@codemirror/view";
|
|
573
|
-
import
|
|
1302
|
+
import React5 from "react";
|
|
574
1303
|
import { useThemeContext } from "@dxos/react-ui";
|
|
575
1304
|
import { createBasicExtensions, createThemeExtensions, preventNewline, useTextEditor } from "@dxos/react-ui-editor";
|
|
576
1305
|
var editorKeys = ({ onNav, onClose }) => {
|
|
@@ -618,20 +1347,60 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
618
1347
|
{
|
|
619
1348
|
key: "Enter",
|
|
620
1349
|
run: (editor) => {
|
|
621
|
-
onClose(editor.state.doc.toString()
|
|
1350
|
+
onClose(editor.state.doc.toString(), {
|
|
1351
|
+
key: "Enter"
|
|
1352
|
+
});
|
|
1353
|
+
return true;
|
|
1354
|
+
},
|
|
1355
|
+
shift: (editor) => {
|
|
1356
|
+
onClose(editor.state.doc.toString(), {
|
|
1357
|
+
key: "Enter",
|
|
1358
|
+
shift: true
|
|
1359
|
+
});
|
|
1360
|
+
return true;
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
{
|
|
1364
|
+
key: "Tab",
|
|
1365
|
+
run: (editor) => {
|
|
1366
|
+
onClose(editor.state.doc.toString(), {
|
|
1367
|
+
key: "Tab"
|
|
1368
|
+
});
|
|
1369
|
+
return true;
|
|
1370
|
+
},
|
|
1371
|
+
shift: (editor) => {
|
|
1372
|
+
onClose(editor.state.doc.toString(), {
|
|
1373
|
+
key: "Tab",
|
|
1374
|
+
shift: true
|
|
1375
|
+
});
|
|
622
1376
|
return true;
|
|
623
1377
|
}
|
|
624
1378
|
},
|
|
625
1379
|
{
|
|
626
1380
|
key: "Escape",
|
|
627
1381
|
run: () => {
|
|
628
|
-
onClose(void 0
|
|
1382
|
+
onClose(void 0, {
|
|
1383
|
+
key: "Escape"
|
|
1384
|
+
});
|
|
629
1385
|
return true;
|
|
630
1386
|
}
|
|
631
1387
|
}
|
|
632
1388
|
]);
|
|
633
1389
|
};
|
|
634
|
-
var
|
|
1390
|
+
var editorVariants = {
|
|
1391
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
1392
|
+
legacy: {
|
|
1393
|
+
root: "flex w-full",
|
|
1394
|
+
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1395
|
+
content: "!px-2 !py-1"
|
|
1396
|
+
},
|
|
1397
|
+
grid: {
|
|
1398
|
+
root: "absolute z-[1]",
|
|
1399
|
+
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1400
|
+
content: "!border !border-transparent !p-0.5"
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
635
1404
|
const { themeMode } = useThemeContext();
|
|
636
1405
|
const { parentRef } = useTextEditor(() => {
|
|
637
1406
|
return {
|
|
@@ -658,21 +1427,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
658
1427
|
themeMode,
|
|
659
1428
|
slots: {
|
|
660
1429
|
editor: {
|
|
661
|
-
className:
|
|
1430
|
+
className: editorVariants[variant].editor
|
|
662
1431
|
},
|
|
663
1432
|
content: {
|
|
664
|
-
className:
|
|
1433
|
+
className: editorVariants[variant].content
|
|
665
1434
|
}
|
|
666
1435
|
}
|
|
667
1436
|
})
|
|
668
1437
|
]
|
|
669
1438
|
};
|
|
670
1439
|
}, [
|
|
671
|
-
extension
|
|
1440
|
+
extension,
|
|
1441
|
+
autoFocus,
|
|
1442
|
+
value,
|
|
1443
|
+
variant,
|
|
1444
|
+
onBlur
|
|
672
1445
|
]);
|
|
673
|
-
return /* @__PURE__ */
|
|
1446
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
674
1447
|
ref: parentRef,
|
|
675
|
-
className:
|
|
1448
|
+
className: editorVariants[variant].root,
|
|
1449
|
+
style: box,
|
|
1450
|
+
...gridId && {
|
|
1451
|
+
"data-grid": gridId
|
|
1452
|
+
}
|
|
676
1453
|
});
|
|
677
1454
|
};
|
|
678
1455
|
|
|
@@ -794,13 +1571,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
794
1571
|
// NOTE: Useful for debugging.
|
|
795
1572
|
closeOnBlur: false,
|
|
796
1573
|
icons: false,
|
|
797
|
-
tooltipClass: () => mx(
|
|
798
|
-
// TODO(burdon): Factor out fragments.
|
|
799
|
-
// TODO(burdon): Size to make width same as column.
|
|
800
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
801
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
802
|
-
"border-separator"
|
|
803
|
-
)
|
|
1574
|
+
tooltipClass: () => mx("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
|
|
804
1575
|
}),
|
|
805
1576
|
keymap2.of([
|
|
806
1577
|
{
|
|
@@ -889,7 +1660,7 @@ var visitTree = (node, callback) => {
|
|
|
889
1660
|
};
|
|
890
1661
|
|
|
891
1662
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
892
|
-
var
|
|
1663
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
893
1664
|
var fragments = {
|
|
894
1665
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
895
1666
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -897,25 +1668,26 @@ var fragments = {
|
|
|
897
1668
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
898
1669
|
};
|
|
899
1670
|
var SheetRoot = ({ children, ...props }) => {
|
|
900
|
-
return /* @__PURE__ */
|
|
1671
|
+
return /* @__PURE__ */ React6.createElement(SheetContextProvider, props, children);
|
|
901
1672
|
};
|
|
902
|
-
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows,
|
|
1673
|
+
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
903
1674
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
904
1675
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
905
|
-
|
|
1676
|
+
useThreads();
|
|
1677
|
+
const [rows, setRows] = useState5([
|
|
906
1678
|
...model.sheet.rows
|
|
907
1679
|
]);
|
|
908
|
-
const [columns, setColumns] =
|
|
1680
|
+
const [columns, setColumns] = useState5([
|
|
909
1681
|
...model.sheet.columns
|
|
910
1682
|
]);
|
|
911
|
-
|
|
1683
|
+
useEffect4(() => {
|
|
912
1684
|
const rowsAccessor = createDocAccessor(model.sheet, [
|
|
913
1685
|
"rows"
|
|
914
1686
|
]);
|
|
915
1687
|
const columnsAccessor = createDocAccessor(model.sheet, [
|
|
916
1688
|
"columns"
|
|
917
1689
|
]);
|
|
918
|
-
const handleUpdate =
|
|
1690
|
+
const handleUpdate = debounce2(() => {
|
|
919
1691
|
setRows([
|
|
920
1692
|
...model.sheet.rows
|
|
921
1693
|
]);
|
|
@@ -933,44 +1705,44 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
|
|
|
933
1705
|
}, [
|
|
934
1706
|
model
|
|
935
1707
|
]);
|
|
936
|
-
|
|
1708
|
+
useEffect4(() => {
|
|
937
1709
|
model.reset();
|
|
938
1710
|
}, [
|
|
939
1711
|
rows,
|
|
940
1712
|
columns
|
|
941
1713
|
]);
|
|
942
1714
|
const handleMoveRows = (from, to, num = 1) => {
|
|
943
|
-
const cursorIdx = cursor ? model.
|
|
1715
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
944
1716
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
945
1717
|
model.sheet.rows.splice(to, 0, rows2);
|
|
946
1718
|
if (cursorIdx) {
|
|
947
|
-
setCursor(model.
|
|
1719
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
948
1720
|
}
|
|
949
1721
|
setRows([
|
|
950
1722
|
...model.sheet.rows
|
|
951
1723
|
]);
|
|
952
1724
|
};
|
|
953
1725
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
954
|
-
const cursorIdx = cursor ? model.
|
|
1726
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
955
1727
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
956
1728
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
957
1729
|
if (cursorIdx) {
|
|
958
|
-
setCursor(model.
|
|
1730
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
959
1731
|
}
|
|
960
1732
|
setColumns([
|
|
961
1733
|
...model.sheet.columns
|
|
962
1734
|
]);
|
|
963
1735
|
};
|
|
964
|
-
const [rowSizes, setRowSizes] =
|
|
965
|
-
const [columnSizes, setColumnSizes] =
|
|
966
|
-
|
|
1736
|
+
const [rowSizes, setRowSizes] = useState5();
|
|
1737
|
+
const [columnSizes, setColumnSizes] = useState5();
|
|
1738
|
+
useEffect4(() => {
|
|
967
1739
|
const rowAccessor = createDocAccessor(model.sheet, [
|
|
968
1740
|
"rowMeta"
|
|
969
1741
|
]);
|
|
970
1742
|
const columnAccessor = createDocAccessor(model.sheet, [
|
|
971
1743
|
"columnMeta"
|
|
972
1744
|
]);
|
|
973
|
-
const handleUpdate =
|
|
1745
|
+
const handleUpdate = debounce2(() => {
|
|
974
1746
|
const mapSizes = (values) => values.reduce((map, [idx, meta]) => {
|
|
975
1747
|
if (meta.size) {
|
|
976
1748
|
map[idx] = meta.size;
|
|
@@ -1012,54 +1784,54 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
|
|
|
1012
1784
|
}));
|
|
1013
1785
|
}
|
|
1014
1786
|
};
|
|
1015
|
-
return /* @__PURE__ */
|
|
1787
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1016
1788
|
role: "none",
|
|
1017
1789
|
className: mx2("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1018
|
-
}, /* @__PURE__ */
|
|
1790
|
+
}, /* @__PURE__ */ React6.createElement(GridCorner, {
|
|
1019
1791
|
onClick: () => {
|
|
1020
1792
|
setCursor(void 0);
|
|
1021
1793
|
setRange(void 0);
|
|
1022
1794
|
setEditing(false);
|
|
1023
1795
|
}
|
|
1024
|
-
}), /* @__PURE__ */
|
|
1796
|
+
}), /* @__PURE__ */ React6.createElement(SheetColumns, {
|
|
1025
1797
|
ref: columnsRef,
|
|
1026
1798
|
columns,
|
|
1027
1799
|
sizes: columnSizes,
|
|
1028
|
-
selected: cursor?.
|
|
1029
|
-
onSelect: (
|
|
1800
|
+
selected: cursor?.col,
|
|
1801
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1030
1802
|
row: -1,
|
|
1031
|
-
|
|
1803
|
+
col
|
|
1032
1804
|
}),
|
|
1033
1805
|
onResize: handleResizeColumn,
|
|
1034
1806
|
onMove: handleMoveColumns
|
|
1035
|
-
}), /* @__PURE__ */
|
|
1807
|
+
}), /* @__PURE__ */ React6.createElement(SheetRows, {
|
|
1036
1808
|
ref: rowsRef,
|
|
1037
1809
|
rows,
|
|
1038
1810
|
sizes: rowSizes,
|
|
1039
1811
|
selected: cursor?.row,
|
|
1040
1812
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1041
1813
|
row,
|
|
1042
|
-
|
|
1814
|
+
col: -1
|
|
1043
1815
|
}),
|
|
1044
1816
|
onResize: handleResizeRow,
|
|
1045
1817
|
onMove: handleMoveRows
|
|
1046
|
-
}), /* @__PURE__ */
|
|
1818
|
+
}), /* @__PURE__ */ React6.createElement(SheetGrid, {
|
|
1047
1819
|
ref: contentRef,
|
|
1048
1820
|
size: {
|
|
1049
1821
|
numRows: numRows ?? rows.length,
|
|
1050
|
-
|
|
1822
|
+
numCols: numCols ?? columns.length
|
|
1051
1823
|
},
|
|
1052
1824
|
rows,
|
|
1053
1825
|
columns,
|
|
1054
1826
|
rowSizes,
|
|
1055
1827
|
columnSizes
|
|
1056
|
-
}), /* @__PURE__ */
|
|
1828
|
+
}), /* @__PURE__ */ React6.createElement(GridCorner, null), /* @__PURE__ */ React6.createElement(SheetStatusBar, null));
|
|
1057
1829
|
});
|
|
1058
1830
|
var useScrollHandlers = () => {
|
|
1059
1831
|
const rowsRef = useRef(null);
|
|
1060
1832
|
const columnsRef = useRef(null);
|
|
1061
1833
|
const contentRef = useRef(null);
|
|
1062
|
-
|
|
1834
|
+
useEffect4(() => {
|
|
1063
1835
|
const handleRowsScroll = (ev) => {
|
|
1064
1836
|
const { scrollTop } = ev.target;
|
|
1065
1837
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1096,13 +1868,13 @@ var useScrollHandlers = () => {
|
|
|
1096
1868
|
};
|
|
1097
1869
|
};
|
|
1098
1870
|
var GridCorner = (props) => {
|
|
1099
|
-
return /* @__PURE__ */
|
|
1871
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1100
1872
|
className: fragments.axis,
|
|
1101
1873
|
...props
|
|
1102
1874
|
});
|
|
1103
1875
|
};
|
|
1104
1876
|
var MovingOverlay = ({ label }) => {
|
|
1105
|
-
return /* @__PURE__ */
|
|
1877
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1106
1878
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1107
1879
|
}, label);
|
|
1108
1880
|
};
|
|
@@ -1122,7 +1894,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1122
1894
|
});
|
|
1123
1895
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
1124
1896
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
1125
|
-
const [active, setActive] =
|
|
1897
|
+
const [active, setActive] = useState5(null);
|
|
1126
1898
|
const handleDragStart = ({ active: active2 }) => {
|
|
1127
1899
|
setActive(active2);
|
|
1128
1900
|
};
|
|
@@ -1146,18 +1918,18 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1146
1918
|
}
|
|
1147
1919
|
return transform;
|
|
1148
1920
|
};
|
|
1149
|
-
return /* @__PURE__ */
|
|
1921
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1150
1922
|
className: "relative flex grow overflow-hidden"
|
|
1151
|
-
}, /* @__PURE__ */
|
|
1923
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1152
1924
|
className: mx2("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1153
1925
|
style: {
|
|
1154
1926
|
width: axisWidth
|
|
1155
1927
|
}
|
|
1156
|
-
}), /* @__PURE__ */
|
|
1928
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1157
1929
|
ref: forwardRef2,
|
|
1158
1930
|
role: "rowheader",
|
|
1159
1931
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1160
|
-
}, /* @__PURE__ */
|
|
1932
|
+
}, /* @__PURE__ */ React6.createElement(DndContext, {
|
|
1161
1933
|
sensors,
|
|
1162
1934
|
modifiers: [
|
|
1163
1935
|
restrictToVerticalAxis,
|
|
@@ -1165,12 +1937,12 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1165
1937
|
],
|
|
1166
1938
|
onDragStart: handleDragStart,
|
|
1167
1939
|
onDragEnd: handleDragEnd
|
|
1168
|
-
}, /* @__PURE__ */
|
|
1940
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1169
1941
|
className: "flex flex-col",
|
|
1170
1942
|
style: {
|
|
1171
1943
|
width: axisWidth
|
|
1172
1944
|
}
|
|
1173
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1945
|
+
}, rows.map((idx, index) => /* @__PURE__ */ React6.createElement(GridRowCell, {
|
|
1174
1946
|
key: idx,
|
|
1175
1947
|
idx,
|
|
1176
1948
|
index,
|
|
@@ -1180,7 +1952,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1180
1952
|
selected: selected === index,
|
|
1181
1953
|
onResize,
|
|
1182
1954
|
onSelect
|
|
1183
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
1955
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
|
|
1184
1956
|
label: String(active.data.current.index + 1)
|
|
1185
1957
|
})), document.body))));
|
|
1186
1958
|
});
|
|
@@ -1198,8 +1970,8 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1198
1970
|
}
|
|
1199
1971
|
});
|
|
1200
1972
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
1201
|
-
const [initialSize, setInitialSize] =
|
|
1202
|
-
const [resizing, setResizing] =
|
|
1973
|
+
const [initialSize, setInitialSize] = useState5(size);
|
|
1974
|
+
const [resizing, setResizing] = useState5(false);
|
|
1203
1975
|
const scrollHandler = useRef();
|
|
1204
1976
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1205
1977
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
@@ -1221,7 +1993,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1221
1993
|
onResize?.(idx, initialSize + height, true);
|
|
1222
1994
|
setResizing(false);
|
|
1223
1995
|
};
|
|
1224
|
-
return /* @__PURE__ */
|
|
1996
|
+
return /* @__PURE__ */ React6.createElement(Resizable, {
|
|
1225
1997
|
enable: {
|
|
1226
1998
|
bottom: resize
|
|
1227
1999
|
},
|
|
@@ -1233,17 +2005,17 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1233
2005
|
onResizeStart: handleResizeStart,
|
|
1234
2006
|
onResize: handleResize,
|
|
1235
2007
|
onResizeStop: handleResizeStop
|
|
1236
|
-
}, /* @__PURE__ */
|
|
2008
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1237
2009
|
ref: setNodeRef,
|
|
1238
2010
|
...attributes,
|
|
1239
2011
|
...listeners,
|
|
1240
2012
|
className: mx2("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1241
2013
|
onClick: () => onSelect?.(index)
|
|
1242
|
-
}, /* @__PURE__ */
|
|
2014
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
1243
2015
|
className: "flex w-full justify-center"
|
|
1244
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2016
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
|
|
1245
2017
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1246
|
-
}), resizing && /* @__PURE__ */
|
|
2018
|
+
}), resizing && /* @__PURE__ */ React6.createElement("div", {
|
|
1247
2019
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1248
2020
|
})));
|
|
1249
2021
|
};
|
|
@@ -1256,7 +2028,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1256
2028
|
});
|
|
1257
2029
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
1258
2030
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
1259
|
-
const [active, setActive] =
|
|
2031
|
+
const [active, setActive] = useState5(null);
|
|
1260
2032
|
const handleDragStart = ({ active: active2 }) => {
|
|
1261
2033
|
setActive(active2);
|
|
1262
2034
|
};
|
|
@@ -1280,18 +2052,18 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1280
2052
|
}
|
|
1281
2053
|
return transform;
|
|
1282
2054
|
};
|
|
1283
|
-
return /* @__PURE__ */
|
|
2055
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1284
2056
|
className: "relative flex grow overflow-hidden"
|
|
1285
|
-
}, /* @__PURE__ */
|
|
2057
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1286
2058
|
className: mx2("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
1287
2059
|
style: {
|
|
1288
2060
|
height: axisHeight
|
|
1289
2061
|
}
|
|
1290
|
-
}), /* @__PURE__ */
|
|
2062
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1291
2063
|
ref: forwardRef2,
|
|
1292
2064
|
role: "columnheader",
|
|
1293
2065
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1294
|
-
}, /* @__PURE__ */
|
|
2066
|
+
}, /* @__PURE__ */ React6.createElement(DndContext, {
|
|
1295
2067
|
autoScroll: {
|
|
1296
2068
|
enabled: true
|
|
1297
2069
|
},
|
|
@@ -1302,12 +2074,12 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1302
2074
|
],
|
|
1303
2075
|
onDragStart: handleDragStart,
|
|
1304
2076
|
onDragEnd: handleDragEnd
|
|
1305
|
-
}, /* @__PURE__ */
|
|
2077
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1306
2078
|
className: "flex h-full",
|
|
1307
2079
|
style: {
|
|
1308
2080
|
height: axisHeight
|
|
1309
2081
|
}
|
|
1310
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2082
|
+
}, columns.map((idx, index) => /* @__PURE__ */ React6.createElement(GridColumnCell, {
|
|
1311
2083
|
key: idx,
|
|
1312
2084
|
idx,
|
|
1313
2085
|
index,
|
|
@@ -1317,7 +2089,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1317
2089
|
selected: selected === index,
|
|
1318
2090
|
onResize,
|
|
1319
2091
|
onSelect
|
|
1320
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2092
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
|
|
1321
2093
|
label: columnLetter(active.data.current.index)
|
|
1322
2094
|
})), document.body))));
|
|
1323
2095
|
});
|
|
@@ -1335,8 +2107,8 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1335
2107
|
}
|
|
1336
2108
|
});
|
|
1337
2109
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
1338
|
-
const [initialSize, setInitialSize] =
|
|
1339
|
-
const [resizing, setResizing] =
|
|
2110
|
+
const [initialSize, setInitialSize] = useState5(size);
|
|
2111
|
+
const [resizing, setResizing] = useState5(false);
|
|
1340
2112
|
const scrollHandler = useRef();
|
|
1341
2113
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1342
2114
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
@@ -1358,7 +2130,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1358
2130
|
onResize?.(idx, initialSize + width, true);
|
|
1359
2131
|
setResizing(false);
|
|
1360
2132
|
};
|
|
1361
|
-
return /* @__PURE__ */
|
|
2133
|
+
return /* @__PURE__ */ React6.createElement(Resizable, {
|
|
1362
2134
|
enable: {
|
|
1363
2135
|
right: resize
|
|
1364
2136
|
},
|
|
@@ -1370,17 +2142,17 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1370
2142
|
onResizeStart: handleResizeStart,
|
|
1371
2143
|
onResize: handleResize,
|
|
1372
2144
|
onResizeStop: handleResizeStop
|
|
1373
|
-
}, /* @__PURE__ */
|
|
2145
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1374
2146
|
ref: setNodeRef,
|
|
1375
2147
|
...attributes,
|
|
1376
2148
|
...listeners,
|
|
1377
2149
|
className: mx2("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1378
2150
|
onClick: () => onSelect?.(index)
|
|
1379
|
-
}, /* @__PURE__ */
|
|
2151
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
1380
2152
|
className: "flex w-full justify-center"
|
|
1381
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2153
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
|
|
1382
2154
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1383
|
-
}), resizing && /* @__PURE__ */
|
|
2155
|
+
}), resizing && /* @__PURE__ */ React6.createElement("div", {
|
|
1384
2156
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1385
2157
|
})));
|
|
1386
2158
|
};
|
|
@@ -1393,14 +2165,14 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1393
2165
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1394
2166
|
const initialText = useRef();
|
|
1395
2167
|
const quickEdit = useRef(false);
|
|
1396
|
-
const [, forceUpdate] =
|
|
1397
|
-
|
|
2168
|
+
const [, forceUpdate] = useState5({});
|
|
2169
|
+
useEffect4(() => {
|
|
1398
2170
|
const unsubscribe = model.update.on(() => {
|
|
1399
|
-
|
|
2171
|
+
log2("updated", {
|
|
1400
2172
|
id: model.id
|
|
1401
2173
|
}, {
|
|
1402
|
-
F:
|
|
1403
|
-
L:
|
|
2174
|
+
F: __dxlog_file4,
|
|
2175
|
+
L: 737,
|
|
1404
2176
|
S: void 0,
|
|
1405
2177
|
C: (f, a) => f(...a)
|
|
1406
2178
|
});
|
|
@@ -1520,16 +2292,16 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1520
2292
|
const id = fullyQualifiedId2(model.sheet);
|
|
1521
2293
|
const attendableAttrs = createAttendableAttributes(id);
|
|
1522
2294
|
const hasAttention = useHasAttention(id);
|
|
1523
|
-
return /* @__PURE__ */
|
|
2295
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1524
2296
|
ref: containerRef,
|
|
1525
2297
|
role: "grid",
|
|
1526
2298
|
className: "relative flex grow overflow-hidden"
|
|
1527
|
-
}, /* @__PURE__ */
|
|
2299
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1528
2300
|
className: mx2("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
1529
|
-
}), /* @__PURE__ */
|
|
2301
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1530
2302
|
ref: scrollerRef,
|
|
1531
2303
|
className: mx2("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
1532
|
-
}, /* @__PURE__ */
|
|
2304
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1533
2305
|
className: "relative select-none",
|
|
1534
2306
|
style: {
|
|
1535
2307
|
width,
|
|
@@ -1537,10 +2309,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1537
2309
|
},
|
|
1538
2310
|
onClick: () => inputRef.current?.focus(),
|
|
1539
2311
|
...handlers
|
|
1540
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2312
|
+
}, scrollerRef.current && /* @__PURE__ */ React6.createElement(SelectionOverlay, {
|
|
1541
2313
|
root: scrollerRef.current
|
|
1542
2314
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1543
|
-
return columnRange.map(({
|
|
2315
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1544
2316
|
const style = {
|
|
1545
2317
|
position: "absolute",
|
|
1546
2318
|
top,
|
|
@@ -1550,10 +2322,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1550
2322
|
};
|
|
1551
2323
|
const cell = {
|
|
1552
2324
|
row,
|
|
1553
|
-
|
|
2325
|
+
col
|
|
1554
2326
|
};
|
|
1555
2327
|
const id2 = addressToA1Notation(cell);
|
|
1556
|
-
const idx = model.
|
|
2328
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
1557
2329
|
const active = posEquals(cursor, cell);
|
|
1558
2330
|
if (active && editing) {
|
|
1559
2331
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
@@ -1586,7 +2358,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1586
2358
|
inputRef.current?.focus();
|
|
1587
2359
|
setEditing(false);
|
|
1588
2360
|
};
|
|
1589
|
-
return /* @__PURE__ */
|
|
2361
|
+
return /* @__PURE__ */ React6.createElement(GridCellEditor, {
|
|
1590
2362
|
key: idx,
|
|
1591
2363
|
value,
|
|
1592
2364
|
style,
|
|
@@ -1594,7 +2366,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1594
2366
|
onClose: handleClose
|
|
1595
2367
|
});
|
|
1596
2368
|
}
|
|
1597
|
-
return /* @__PURE__ */
|
|
2369
|
+
return /* @__PURE__ */ React6.createElement(SheetCell, {
|
|
1598
2370
|
key: id2,
|
|
1599
2371
|
id: id2,
|
|
1600
2372
|
cell,
|
|
@@ -1606,7 +2378,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1606
2378
|
}
|
|
1607
2379
|
});
|
|
1608
2380
|
});
|
|
1609
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2381
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement("input", {
|
|
1610
2382
|
ref: inputRef,
|
|
1611
2383
|
autoFocus: true,
|
|
1612
2384
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -1627,20 +2399,34 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1627
2399
|
const b1 = getRelativeClientRect(root, c1);
|
|
1628
2400
|
const b2 = getRelativeClientRect(root, c2);
|
|
1629
2401
|
const bounds = getRectUnion(b1, b2);
|
|
1630
|
-
return /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1631
2403
|
role: "none",
|
|
1632
2404
|
style: bounds,
|
|
1633
2405
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
1634
2406
|
});
|
|
1635
2407
|
};
|
|
1636
2408
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1637
|
-
const { formatting, editing, setRange } = useSheetContext();
|
|
2409
|
+
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1638
2410
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1639
|
-
|
|
2411
|
+
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
2412
|
+
const decorationAddedClasses = useMemo4(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
2413
|
+
decorationsForCell
|
|
2414
|
+
]);
|
|
2415
|
+
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
2416
|
+
if (!decorate) {
|
|
2417
|
+
return children;
|
|
2418
|
+
}
|
|
2419
|
+
const DecoratorComponent = decorate;
|
|
2420
|
+
return /* @__PURE__ */ React6.createElement(DecoratorComponent, null, children);
|
|
2421
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2422
|
+
role: "none",
|
|
2423
|
+
className: mx2("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
2424
|
+
}, value));
|
|
2425
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1640
2426
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1641
2427
|
role: "cell",
|
|
1642
2428
|
style,
|
|
1643
|
-
className: mx2("
|
|
2429
|
+
className: mx2("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1644
2430
|
"z-20",
|
|
1645
2431
|
fragments.cellSelected
|
|
1646
2432
|
], classNames),
|
|
@@ -1654,36 +2440,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1654
2440
|
}
|
|
1655
2441
|
},
|
|
1656
2442
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
1657
|
-
},
|
|
2443
|
+
}, decoratedContent);
|
|
1658
2444
|
};
|
|
1659
2445
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1660
2446
|
const { model, range } = useSheetContext();
|
|
1661
2447
|
const notifier = useRef();
|
|
1662
|
-
|
|
2448
|
+
useEffect4(() => {
|
|
1663
2449
|
if (range) {
|
|
1664
2450
|
notifier.current?.(rangeToA1Notation(range));
|
|
1665
2451
|
}
|
|
1666
2452
|
}, [
|
|
1667
2453
|
range
|
|
1668
2454
|
]);
|
|
1669
|
-
const extension =
|
|
2455
|
+
const extension = useMemo4(() => [
|
|
1670
2456
|
editorKeys({
|
|
1671
2457
|
onNav,
|
|
1672
2458
|
onClose
|
|
1673
2459
|
}),
|
|
1674
2460
|
sheetExtension({
|
|
1675
|
-
functions: model.
|
|
2461
|
+
functions: model.graph.getFunctions()
|
|
1676
2462
|
}),
|
|
1677
2463
|
rangeExtension((fn) => notifier.current = fn)
|
|
1678
2464
|
], [
|
|
1679
2465
|
model
|
|
1680
2466
|
]);
|
|
1681
|
-
return /* @__PURE__ */
|
|
2467
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1682
2468
|
role: "cell",
|
|
1683
2469
|
style,
|
|
1684
2470
|
className: mx2("z-20 flex", fragments.cellSelected),
|
|
1685
2471
|
onClick: (ev) => ev.stopPropagation()
|
|
1686
|
-
}, /* @__PURE__ */
|
|
2472
|
+
}, /* @__PURE__ */ React6.createElement(CellEditor, {
|
|
1687
2473
|
autoFocus: true,
|
|
1688
2474
|
value,
|
|
1689
2475
|
extension
|
|
@@ -1696,30 +2482,30 @@ var SheetStatusBar = () => {
|
|
|
1696
2482
|
if (cursor) {
|
|
1697
2483
|
value = model.getCellValue(cursor);
|
|
1698
2484
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1699
|
-
value = model.
|
|
2485
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1700
2486
|
isFormula = true;
|
|
1701
2487
|
} else if (value != null) {
|
|
1702
2488
|
value = String(value);
|
|
1703
2489
|
}
|
|
1704
2490
|
}
|
|
1705
|
-
return /* @__PURE__ */
|
|
2491
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1706
2492
|
className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
1707
|
-
}, /* @__PURE__ */
|
|
2493
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1708
2494
|
className: "flex gap-4 items-center"
|
|
1709
|
-
}, /* @__PURE__ */
|
|
2495
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1710
2496
|
className: "flex w-16 items-center font-mono"
|
|
1711
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */
|
|
2497
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React6.createElement("div", {
|
|
1712
2498
|
className: "flex gap-2 items-center"
|
|
1713
|
-
}, /* @__PURE__ */
|
|
2499
|
+
}, /* @__PURE__ */ React6.createElement(FunctionIcon, {
|
|
1714
2500
|
className: mx2("text-greenText", isFormula ? "visible" : "invisible")
|
|
1715
|
-
}), /* @__PURE__ */
|
|
2501
|
+
}), /* @__PURE__ */ React6.createElement("span", {
|
|
1716
2502
|
className: "font-mono"
|
|
1717
2503
|
}, value))));
|
|
1718
2504
|
};
|
|
1719
2505
|
var SheetDebug = () => {
|
|
1720
2506
|
const { model, cursor, range } = useSheetContext();
|
|
1721
|
-
const [, forceUpdate] =
|
|
1722
|
-
|
|
2507
|
+
const [, forceUpdate] = useState5({});
|
|
2508
|
+
useEffect4(() => {
|
|
1723
2509
|
const accessor = createDocAccessor(model.sheet, []);
|
|
1724
2510
|
const handleUpdate = () => forceUpdate({});
|
|
1725
2511
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -1730,9 +2516,9 @@ var SheetDebug = () => {
|
|
|
1730
2516
|
}, [
|
|
1731
2517
|
model
|
|
1732
2518
|
]);
|
|
1733
|
-
return /* @__PURE__ */
|
|
2519
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1734
2520
|
className: mx2("z-20 absolute right-0 top-20 bottom-20 w-[30rem] overflow-auto scrollbar-thin", "border border-gridLine text-xs bg-neutral-50 dark:bg-black text-cyan-500 font-mono p-1 opacity-80")
|
|
1735
|
-
}, /* @__PURE__ */
|
|
2521
|
+
}, /* @__PURE__ */ React6.createElement("pre", {
|
|
1736
2522
|
className: "whitespace-pre-wrap"
|
|
1737
2523
|
}, JSON.stringify({
|
|
1738
2524
|
cursor,
|
|
@@ -1754,19 +2540,13 @@ var Sheet = {
|
|
|
1754
2540
|
Debug: SheetDebug
|
|
1755
2541
|
};
|
|
1756
2542
|
|
|
1757
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
1758
|
-
var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
|
|
1759
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
1760
|
-
role: "none",
|
|
1761
|
-
className: mx3("flex", role === "article" && "row-span-2", role === "section" && "aspect-square border-y border-is border-separator")
|
|
1762
|
-
}, /* @__PURE__ */ React4.createElement(Sheet.Root, {
|
|
1763
|
-
sheet,
|
|
1764
|
-
space,
|
|
1765
|
-
remoteFunctionUrl
|
|
1766
|
-
}, /* @__PURE__ */ React4.createElement(Sheet.Main, null)));
|
|
1767
|
-
};
|
|
1768
|
-
var SheetContainer_default = SheetContainer;
|
|
1769
2543
|
export {
|
|
1770
|
-
|
|
2544
|
+
ComputeGraphContextProvider,
|
|
2545
|
+
createSheet,
|
|
2546
|
+
addressToIndex,
|
|
2547
|
+
compareIndexPositions,
|
|
2548
|
+
useSheetContext,
|
|
2549
|
+
Sheet,
|
|
2550
|
+
SheetContainer
|
|
1771
2551
|
};
|
|
1772
|
-
//# sourceMappingURL=
|
|
2552
|
+
//# sourceMappingURL=chunk-U2JHW3L6.mjs.map
|