@dxos/plugin-sheet 0.6.12-main.f9d0246 → 0.6.12-staging.0b4bb48
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/{chunk-ZLJ2GRE2.mjs → SheetContainer-U4H5D34A.mjs} +240 -1151
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-Z2XOOC2R.mjs → chunk-D5AGLXJP.mjs} +678 -385
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WZMOZKQZ.mjs → chunk-FUAGSXA4.mjs} +16 -9
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-IU2L277A.mjs → browser/chunk-JRL5LGCE.mjs} +5 -4
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -74
- 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/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{chunk-6DQABRGJ.cjs → SheetContainer-AXQV3ZT5.cjs} +279 -1182
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-P5QYYEHQ.cjs → chunk-5KKJ4NPP.cjs} +676 -388
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-BJ6ZD7MN.cjs} +18 -5
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-AOP42UAA.cjs → chunk-DSYKOI4E.cjs} +21 -13
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +66 -86
- 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/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +12 -10
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +3 -23
- 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/{graph → components/ComputeGraph}/async-function.d.ts +2 -8
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/{graph/testing/custom-function.d.ts → components/ComputeGraph/custom.d.ts} +2 -4
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- 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 +6 -5
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.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 +7 -8
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +3 -2
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +3 -19
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +13 -18
- 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/meta.d.ts +4 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +65 -10
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -86
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +41 -48
- package/src/SheetPlugin.tsx +73 -48
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -5
- package/src/components/CellEditor/CellEditor.tsx +9 -59
- package/src/components/CellEditor/extension.test.ts +5 -4
- package/src/components/CellEditor/extension.ts +3 -1
- package/src/{graph → components/ComputeGraph}/async-function.ts +6 -15
- package/src/{graph/testing/custom-function.ts → components/ComputeGraph/custom.ts} +7 -11
- package/src/{graph → components/ComputeGraph}/edge-function.ts +3 -3
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +88 -52
- package/src/components/Sheet/Sheet.tsx +18 -57
- package/src/{model/formatting-model.ts → components/Sheet/formatting.ts} +13 -20
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +80 -18
- package/src/components/SheetContainer.tsx +19 -73
- package/src/components/Toolbar/Toolbar.tsx +12 -53
- package/src/components/index.ts +0 -1
- package/src/meta.tsx +5 -1
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -24
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +6 -31
- package/dist/lib/browser/SheetContainer-VISF3VUB.mjs +0 -261
- package/dist/lib/browser/SheetContainer-VISF3VUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-QILRZNE5.mjs +0 -15
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
- package/dist/lib/browser/chunk-WZMOZKQZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +0 -7
- package/dist/lib/browser/graph-4XFKIHRL.mjs +0 -21
- package/dist/lib/browser/graph-4XFKIHRL.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-2MEALQWW.cjs +0 -279
- package/dist/lib/node/SheetContainer-2MEALQWW.cjs.map +0 -7
- package/dist/lib/node/chunk-6DQABRGJ.cjs.map +0 -7
- package/dist/lib/node/chunk-AOP42UAA.cjs.map +0 -7
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
- package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +0 -7
- package/dist/lib/node/graph-2LRDUXBZ.cjs +0 -43
- package/dist/lib/node/graph-2LRDUXBZ.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs +0 -262
- package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs +0 -2944
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs +0 -2684
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs +0 -76
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs.map +0 -7
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs +0 -22
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -263
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -21
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -10
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts +0 -7
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +0 -24
- package/dist/types/src/components/Sheet/decorations.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/threads.d.ts +0 -2
- package/dist/types/src/components/Sheet/threads.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts +0 -3
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -9
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -2
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -84
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -26
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -4
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/custom-function.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts +0 -2
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- 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/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useFormattingModel.d.ts +0 -3
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/formatting-model.d.ts +0 -16
- package/dist/types/src/model/formatting-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -8
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -36
- package/src/components/GridSheet/GridSheet.tsx +0 -153
- package/src/components/GridSheet/util.ts +0 -108
- package/src/components/Sheet/decorations.ts +0 -62
- package/src/components/Sheet/threads.tsx +0 -205
- package/src/defs/index.ts +0 -6
- package/src/defs/util.ts +0 -151
- package/src/extensions/compute.stories.tsx +0 -153
- package/src/extensions/compute.ts +0 -131
- package/src/extensions/index.ts +0 -5
- package/src/graph/compute-graph.stories.tsx +0 -93
- package/src/graph/compute-graph.test.ts +0 -127
- package/src/graph/compute-graph.ts +0 -313
- package/src/graph/compute-node.ts +0 -62
- package/src/graph/hyperformula.test.ts +0 -15
- package/src/graph/index.ts +0 -7
- package/src/graph/testing/index.ts +0 -5
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useComputeGraph.ts +0 -21
- package/src/hooks/useFormattingModel.ts +0 -11
- package/src/hooks/useSheetModel.ts +0 -40
- package/src/model/sheet-model.ts +0 -414
- package/src/sanity.test.ts +0 -40
- package/src/testing/index.ts +0 -5
- package/src/testing/testing.tsx +0 -68
- /package/dist/types/src/{graph → components/ComputeGraph}/edge-function.d.ts +0 -0
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/function-defs.ts → model/functions.ts} +0 -0
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-WZMOZKQZ.mjs";
|
|
2
|
+
useComputeGraph
|
|
3
|
+
} from "./chunk-APHOLYUB.mjs";
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
SheetModel,
|
|
6
|
+
addressFromA1Notation,
|
|
7
|
+
addressToA1Notation,
|
|
8
|
+
columnLetter,
|
|
9
|
+
defaultFunctions,
|
|
10
|
+
inRange,
|
|
11
|
+
posEquals,
|
|
12
|
+
rangeToA1Notation
|
|
13
|
+
} from "./chunk-D5AGLXJP.mjs";
|
|
8
14
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
15
|
+
ValueTypeEnum
|
|
16
|
+
} from "./chunk-FUAGSXA4.mjs";
|
|
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";
|
|
11
22
|
|
|
12
23
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
13
24
|
import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
@@ -15,183 +26,17 @@ import { restrictToHorizontalAxis, restrictToVerticalAxis } from "@dnd-kit/modif
|
|
|
15
26
|
import { getEventCoordinates, useCombinedRefs } from "@dnd-kit/utilities";
|
|
16
27
|
import { Function as FunctionIcon } from "@phosphor-icons/react";
|
|
17
28
|
import { Resizable } from "re-resizable";
|
|
18
|
-
import
|
|
29
|
+
import React3, { forwardRef, useEffect as useEffect3, useImperativeHandle, useMemo, useRef, useState as useState4 } from "react";
|
|
19
30
|
import { createPortal } from "react-dom";
|
|
20
31
|
import { useResizeDetector } from "react-resize-detector";
|
|
21
|
-
import { debounce
|
|
32
|
+
import { debounce } from "@dxos/async";
|
|
22
33
|
import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
|
|
23
|
-
import { log
|
|
34
|
+
import { log } from "@dxos/log";
|
|
24
35
|
import { createAttendableAttributes, useHasAttention } from "@dxos/react-ui-attention";
|
|
25
36
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
26
37
|
|
|
27
38
|
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
28
39
|
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: 40,
|
|
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 = ({ name, cells, ...size } = {}) => {
|
|
135
|
-
const sheet = create(SheetType, {
|
|
136
|
-
name,
|
|
137
|
-
cells: {},
|
|
138
|
-
rows: [],
|
|
139
|
-
columns: [],
|
|
140
|
-
rowMeta: {},
|
|
141
|
-
columnMeta: {},
|
|
142
|
-
formatting: {}
|
|
143
|
-
});
|
|
144
|
-
initialize(sheet, size);
|
|
145
|
-
if (cells) {
|
|
146
|
-
Object.entries(cells).forEach(([key, { value }]) => {
|
|
147
|
-
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
148
|
-
sheet.cells[idx] = {
|
|
149
|
-
value
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return sheet;
|
|
154
|
-
};
|
|
155
|
-
var addressToIndex = (sheet, cell) => {
|
|
156
|
-
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
157
|
-
};
|
|
158
|
-
var addressFromIndex = (sheet, idx) => {
|
|
159
|
-
const [column, row] = idx.split("@");
|
|
160
|
-
return {
|
|
161
|
-
col: sheet.columns.indexOf(column),
|
|
162
|
-
row: sheet.rows.indexOf(row)
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
var rangeFromIndex = (sheet, idx) => {
|
|
166
|
-
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
167
|
-
return {
|
|
168
|
-
from,
|
|
169
|
-
to
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
var closest = (cursor, cells) => {
|
|
173
|
-
let closestCell;
|
|
174
|
-
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
175
|
-
for (const cell of cells) {
|
|
176
|
-
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
177
|
-
if (distance < closestDistance) {
|
|
178
|
-
closestCell = cell;
|
|
179
|
-
closestDistance = distance;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return closestCell;
|
|
183
|
-
};
|
|
184
|
-
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
185
|
-
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
186
|
-
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
187
|
-
if (rowA !== rowB) {
|
|
188
|
-
return rowA - rowB;
|
|
189
|
-
} else {
|
|
190
|
-
return columnA - columnB;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
195
40
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
196
41
|
var axisHeight = 34;
|
|
197
42
|
var minWidth = 40;
|
|
@@ -233,7 +78,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
233
78
|
const left = x;
|
|
234
79
|
x += width2 - 1;
|
|
235
80
|
return {
|
|
236
|
-
|
|
81
|
+
column: i,
|
|
237
82
|
left,
|
|
238
83
|
width: width2
|
|
239
84
|
};
|
|
@@ -338,14 +183,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
338
183
|
break;
|
|
339
184
|
}
|
|
340
185
|
case "ArrowLeft": {
|
|
341
|
-
if (opposite.
|
|
342
|
-
opposite.
|
|
186
|
+
if (opposite.column > 0) {
|
|
187
|
+
opposite.column -= 1;
|
|
343
188
|
}
|
|
344
189
|
break;
|
|
345
190
|
}
|
|
346
191
|
case "ArrowRight": {
|
|
347
|
-
if (opposite.
|
|
348
|
-
opposite.
|
|
192
|
+
if (opposite.column < size.numColumns - 1) {
|
|
193
|
+
opposite.column += 1;
|
|
349
194
|
}
|
|
350
195
|
break;
|
|
351
196
|
}
|
|
@@ -363,18 +208,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
363
208
|
cursor: next
|
|
364
209
|
};
|
|
365
210
|
};
|
|
366
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
211
|
+
var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
367
212
|
switch (ev.key) {
|
|
368
213
|
case "ArrowUp":
|
|
369
214
|
if (cursor === void 0) {
|
|
370
215
|
return {
|
|
371
216
|
row: 0,
|
|
372
|
-
|
|
217
|
+
column: 0
|
|
373
218
|
};
|
|
374
219
|
} else if (cursor.row > 0) {
|
|
375
220
|
return {
|
|
376
221
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
377
|
-
|
|
222
|
+
column: cursor.column
|
|
378
223
|
};
|
|
379
224
|
}
|
|
380
225
|
break;
|
|
@@ -382,12 +227,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
382
227
|
if (cursor === void 0) {
|
|
383
228
|
return {
|
|
384
229
|
row: 0,
|
|
385
|
-
|
|
230
|
+
column: 0
|
|
386
231
|
};
|
|
387
232
|
} else if (cursor.row < numRows - 1) {
|
|
388
233
|
return {
|
|
389
234
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
390
|
-
|
|
235
|
+
column: cursor.column
|
|
391
236
|
};
|
|
392
237
|
}
|
|
393
238
|
break;
|
|
@@ -395,12 +240,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
395
240
|
if (cursor === void 0) {
|
|
396
241
|
return {
|
|
397
242
|
row: 0,
|
|
398
|
-
|
|
243
|
+
column: 0
|
|
399
244
|
};
|
|
400
|
-
} else if (cursor.
|
|
245
|
+
} else if (cursor.column > 0) {
|
|
401
246
|
return {
|
|
402
247
|
row: cursor.row,
|
|
403
|
-
|
|
248
|
+
column: ev.metaKey ? 0 : cursor.column - 1
|
|
404
249
|
};
|
|
405
250
|
}
|
|
406
251
|
break;
|
|
@@ -408,24 +253,24 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
408
253
|
if (cursor === void 0) {
|
|
409
254
|
return {
|
|
410
255
|
row: 0,
|
|
411
|
-
|
|
256
|
+
column: 0
|
|
412
257
|
};
|
|
413
|
-
} else if (cursor.
|
|
258
|
+
} else if (cursor.column < numColumns - 1) {
|
|
414
259
|
return {
|
|
415
260
|
row: cursor.row,
|
|
416
|
-
|
|
261
|
+
column: ev.metaKey ? numColumns - 1 : cursor.column + 1
|
|
417
262
|
};
|
|
418
263
|
}
|
|
419
264
|
break;
|
|
420
265
|
case "Home":
|
|
421
266
|
return {
|
|
422
267
|
row: 0,
|
|
423
|
-
|
|
268
|
+
column: 0
|
|
424
269
|
};
|
|
425
270
|
case "End":
|
|
426
271
|
return {
|
|
427
272
|
row: numRows - 1,
|
|
428
|
-
|
|
273
|
+
column: numColumns - 1
|
|
429
274
|
};
|
|
430
275
|
}
|
|
431
276
|
};
|
|
@@ -482,104 +327,31 @@ var useRangeSelect = (cb) => {
|
|
|
482
327
|
};
|
|
483
328
|
|
|
484
329
|
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
485
|
-
import
|
|
486
|
-
import { invariant
|
|
487
|
-
|
|
488
|
-
// packages/plugins/plugin-sheet/src/components/Sheet/decorations.ts
|
|
489
|
-
import { create as create2 } from "@dxos/echo-schema";
|
|
490
|
-
var createDecorations = () => {
|
|
491
|
-
const { decorations } = create2({
|
|
492
|
-
decorations: {}
|
|
493
|
-
});
|
|
494
|
-
const addDecoration = (cellIndex, decorator) => {
|
|
495
|
-
decorations[cellIndex] = [
|
|
496
|
-
...decorations[cellIndex] || [],
|
|
497
|
-
decorator
|
|
498
|
-
];
|
|
499
|
-
};
|
|
500
|
-
const removeDecoration = (cellIndex, type) => {
|
|
501
|
-
if (type) {
|
|
502
|
-
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
503
|
-
} else {
|
|
504
|
-
delete decorations[cellIndex];
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
const getDecorationsForCell = (cellIndex) => {
|
|
508
|
-
return decorations[cellIndex];
|
|
509
|
-
};
|
|
510
|
-
const getAllDecorations = () => {
|
|
511
|
-
const result = [];
|
|
512
|
-
for (const decoratorArray of Object.values(decorations)) {
|
|
513
|
-
for (const decorator of decoratorArray) {
|
|
514
|
-
result.push(decorator);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return result;
|
|
518
|
-
};
|
|
519
|
-
return {
|
|
520
|
-
addDecoration,
|
|
521
|
-
removeDecoration,
|
|
522
|
-
getDecorationsForCell,
|
|
523
|
-
getAllDecorations
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
528
|
-
import { useContext } from "react";
|
|
529
|
-
import { raise } from "@dxos/debug";
|
|
530
|
-
import { useAsyncState } from "@dxos/react-hooks";
|
|
531
|
-
|
|
532
|
-
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
533
|
-
import React2 from "react";
|
|
534
|
-
|
|
535
|
-
// packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
536
|
-
import React, { createContext } from "react";
|
|
537
|
-
var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
|
|
538
|
-
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
539
|
-
return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
|
|
540
|
-
value: {
|
|
541
|
-
registry
|
|
542
|
-
}
|
|
543
|
-
}, children);
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
547
|
-
var SheetContainer = React2.lazy(() => import("./SheetContainer-VISF3VUB.mjs"));
|
|
548
|
-
|
|
549
|
-
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
550
|
-
var useComputeGraph = (space) => {
|
|
551
|
-
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
552
|
-
const [graph] = useAsyncState(async () => space && registry.getOrCreateGraph(space), [
|
|
553
|
-
space,
|
|
554
|
-
registry
|
|
555
|
-
]);
|
|
556
|
-
return graph;
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
560
|
-
import { useMemo } from "react";
|
|
330
|
+
import React, { createContext, useContext, useState as useState3, useEffect as useEffect2 } from "react";
|
|
331
|
+
import { invariant } from "@dxos/invariant";
|
|
332
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
561
333
|
|
|
562
|
-
// packages/plugins/plugin-sheet/src/
|
|
334
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/formatting.ts
|
|
563
335
|
var FormattingModel = class {
|
|
564
|
-
constructor(
|
|
565
|
-
this.
|
|
336
|
+
constructor(model) {
|
|
337
|
+
this.model = model;
|
|
566
338
|
}
|
|
567
339
|
/**
|
|
568
340
|
* Get formatted string value and className for cell.
|
|
569
341
|
*/
|
|
570
342
|
getFormatting(cell) {
|
|
571
|
-
const value = this.
|
|
343
|
+
const value = this.model.getValue(cell);
|
|
572
344
|
if (value === void 0 || value === null) {
|
|
573
345
|
return {};
|
|
574
346
|
}
|
|
575
347
|
const locales = void 0;
|
|
576
|
-
const idx =
|
|
577
|
-
let formatting = this.
|
|
348
|
+
const idx = this.model.addressToIndex(cell);
|
|
349
|
+
let formatting = this.model.sheet.formatting?.[idx] ?? {};
|
|
578
350
|
const classNames = [
|
|
579
351
|
...formatting?.classNames ?? []
|
|
580
352
|
];
|
|
581
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
582
|
-
const range =
|
|
353
|
+
for (const [idx2, _formatting] of Object.entries(this.model.sheet.formatting)) {
|
|
354
|
+
const range = this.model.rangeFromIndex(idx2);
|
|
583
355
|
if (inRange(range, cell)) {
|
|
584
356
|
if (_formatting.classNames) {
|
|
585
357
|
classNames.push(..._formatting.classNames);
|
|
@@ -590,7 +362,7 @@ var FormattingModel = class {
|
|
|
590
362
|
}
|
|
591
363
|
}
|
|
592
364
|
const defaultNumber = "justify-end font-mono";
|
|
593
|
-
const type = formatting?.type ?? this.
|
|
365
|
+
const type = formatting?.type ?? this.model.getValueType(cell);
|
|
594
366
|
switch (type) {
|
|
595
367
|
case ValueTypeEnum.Boolean: {
|
|
596
368
|
return {
|
|
@@ -640,21 +412,21 @@ var FormattingModel = class {
|
|
|
640
412
|
// Dates.
|
|
641
413
|
//
|
|
642
414
|
case ValueTypeEnum.DateTime: {
|
|
643
|
-
const date = this.
|
|
415
|
+
const date = this.model.toLocalDate(value);
|
|
644
416
|
return {
|
|
645
417
|
value: date.toLocaleString(locales),
|
|
646
418
|
classNames
|
|
647
419
|
};
|
|
648
420
|
}
|
|
649
421
|
case ValueTypeEnum.Date: {
|
|
650
|
-
const date = this.
|
|
422
|
+
const date = this.model.toLocalDate(value);
|
|
651
423
|
return {
|
|
652
424
|
value: date.toLocaleDateString(locales),
|
|
653
425
|
classNames
|
|
654
426
|
};
|
|
655
427
|
}
|
|
656
428
|
case ValueTypeEnum.Time: {
|
|
657
|
-
const date = this.
|
|
429
|
+
const date = this.model.toLocalDate(value);
|
|
658
430
|
return {
|
|
659
431
|
value: date.toLocaleTimeString(locales),
|
|
660
432
|
classNames
|
|
@@ -670,549 +442,84 @@ var FormattingModel = class {
|
|
|
670
442
|
}
|
|
671
443
|
};
|
|
672
444
|
|
|
673
|
-
// packages/plugins/plugin-sheet/src/
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
};
|
|
690
|
-
var getTopLeft = (range) => {
|
|
691
|
-
const to = range.to ?? range.from;
|
|
692
|
-
return {
|
|
693
|
-
row: Math.min(range.from.row, to.row),
|
|
694
|
-
col: Math.min(range.from.col, to.col)
|
|
695
|
-
};
|
|
445
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
446
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
447
|
+
var OBJECT_ID_LENGTH = 60;
|
|
448
|
+
var SheetContext = /* @__PURE__ */ createContext(null);
|
|
449
|
+
var useSheetContext = () => {
|
|
450
|
+
const context = useContext(SheetContext);
|
|
451
|
+
invariant(context, void 0, {
|
|
452
|
+
F: __dxlog_file,
|
|
453
|
+
L: 45,
|
|
454
|
+
S: void 0,
|
|
455
|
+
A: [
|
|
456
|
+
"context",
|
|
457
|
+
""
|
|
458
|
+
]
|
|
459
|
+
});
|
|
460
|
+
return context;
|
|
696
461
|
};
|
|
697
|
-
var
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
});
|
|
702
|
-
var toModelRange = (sheet, range) => ({
|
|
703
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
704
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
705
|
-
});
|
|
706
|
-
var SheetModel = class extends Resource {
|
|
707
|
-
constructor(_graph, _sheet, _options = {}) {
|
|
708
|
-
super();
|
|
709
|
-
this._graph = _graph;
|
|
710
|
-
this._sheet = _sheet;
|
|
711
|
-
this._options = _options;
|
|
712
|
-
this.id = `model-${PublicKey.random().truncate()}`;
|
|
713
|
-
this.update = new Event();
|
|
714
|
-
}
|
|
715
|
-
get graph() {
|
|
716
|
-
return this._graph;
|
|
717
|
-
}
|
|
718
|
-
get sheet() {
|
|
719
|
-
return this._sheet;
|
|
720
|
-
}
|
|
721
|
-
get readonly() {
|
|
722
|
-
return this._options.readonly;
|
|
723
|
-
}
|
|
724
|
-
get bounds() {
|
|
725
|
-
return {
|
|
726
|
-
rows: this._sheet.rows.length,
|
|
727
|
-
columns: this._sheet.columns.length
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Initialize sheet and engine.
|
|
732
|
-
*/
|
|
733
|
-
async _open() {
|
|
734
|
-
log("initialize", {
|
|
735
|
-
id: this.id
|
|
736
|
-
}, {
|
|
737
|
-
F: __dxlog_file2,
|
|
738
|
-
L: 103,
|
|
739
|
-
S: this,
|
|
740
|
-
C: (f, a) => f(...a)
|
|
741
|
-
});
|
|
742
|
-
initialize(this._sheet);
|
|
743
|
-
this._node = await this._graph.getOrCreateNode(createSheetName(this._sheet.id));
|
|
744
|
-
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
745
|
-
this._ctx.onDispose(unsubscribe);
|
|
746
|
-
this.reset();
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Update engine.
|
|
750
|
-
* NOTE: This resets the undo history.
|
|
751
|
-
* @deprecated
|
|
752
|
-
*/
|
|
753
|
-
reset() {
|
|
754
|
-
invariant2(this._node, void 0, {
|
|
755
|
-
F: __dxlog_file2,
|
|
756
|
-
L: 122,
|
|
757
|
-
S: this,
|
|
758
|
-
A: [
|
|
759
|
-
"this._node",
|
|
760
|
-
""
|
|
761
|
-
]
|
|
762
|
-
});
|
|
763
|
-
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
764
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
765
|
-
invariant2(this._node, void 0, {
|
|
766
|
-
F: __dxlog_file2,
|
|
767
|
-
L: 125,
|
|
768
|
-
S: this,
|
|
769
|
-
A: [
|
|
770
|
-
"this._node",
|
|
771
|
-
""
|
|
772
|
-
]
|
|
773
|
-
});
|
|
774
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
775
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
776
|
-
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
777
|
-
}
|
|
778
|
-
this._node.graph.hf.setCellContents({
|
|
779
|
-
sheet: this._node.sheetId,
|
|
780
|
-
row,
|
|
781
|
-
col
|
|
782
|
-
}, value);
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* Recalculate formulas.
|
|
787
|
-
* NOTE: This resets the undo history.
|
|
788
|
-
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
789
|
-
* @deprecated
|
|
790
|
-
*/
|
|
791
|
-
// TODO(burdon): Remove.
|
|
792
|
-
recalculate() {
|
|
793
|
-
this._node?.graph.hf.rebuildAndRecalculate();
|
|
794
|
-
}
|
|
795
|
-
insertRows(i, n = 1) {
|
|
796
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
797
|
-
this.reset();
|
|
798
|
-
}
|
|
799
|
-
insertColumns(i, n = 1) {
|
|
800
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
801
|
-
this.reset();
|
|
802
|
-
}
|
|
803
|
-
//
|
|
804
|
-
// Undoable actions.
|
|
805
|
-
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
806
|
-
//
|
|
807
|
-
/**
|
|
808
|
-
* Clear range of values.
|
|
809
|
-
*/
|
|
810
|
-
clear(range) {
|
|
811
|
-
invariant2(this._node, void 0, {
|
|
812
|
-
F: __dxlog_file2,
|
|
813
|
-
L: 167,
|
|
814
|
-
S: this,
|
|
815
|
-
A: [
|
|
816
|
-
"this._node",
|
|
817
|
-
""
|
|
818
|
-
]
|
|
819
|
-
});
|
|
820
|
-
const topLeft = getTopLeft(range);
|
|
821
|
-
const values = this._iterRange(range, () => null);
|
|
822
|
-
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
823
|
-
this._iterRange(range, (cell) => {
|
|
824
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
825
|
-
delete this._sheet.cells[idx];
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
cut(range) {
|
|
829
|
-
invariant2(this._node, void 0, {
|
|
830
|
-
F: __dxlog_file2,
|
|
831
|
-
L: 178,
|
|
832
|
-
S: this,
|
|
833
|
-
A: [
|
|
834
|
-
"this._node",
|
|
835
|
-
""
|
|
836
|
-
]
|
|
837
|
-
});
|
|
838
|
-
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
839
|
-
this._iterRange(range, (cell) => {
|
|
840
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
841
|
-
delete this._sheet.cells[idx];
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
copy(range) {
|
|
845
|
-
invariant2(this._node, void 0, {
|
|
846
|
-
F: __dxlog_file2,
|
|
847
|
-
L: 187,
|
|
848
|
-
S: this,
|
|
849
|
-
A: [
|
|
850
|
-
"this._node",
|
|
851
|
-
""
|
|
852
|
-
]
|
|
853
|
-
});
|
|
854
|
-
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
855
|
-
}
|
|
856
|
-
paste(cell) {
|
|
857
|
-
invariant2(this._node, void 0, {
|
|
858
|
-
F: __dxlog_file2,
|
|
859
|
-
L: 192,
|
|
860
|
-
S: this,
|
|
861
|
-
A: [
|
|
862
|
-
"this._node",
|
|
863
|
-
""
|
|
864
|
-
]
|
|
865
|
-
});
|
|
866
|
-
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
867
|
-
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
868
|
-
for (const change of changes) {
|
|
869
|
-
if (change instanceof ExportedCellChange) {
|
|
870
|
-
const { address, newValue } = change;
|
|
871
|
-
const idx = addressToIndex(this._sheet, {
|
|
872
|
-
row: address.row,
|
|
873
|
-
col: address.col
|
|
874
|
-
});
|
|
875
|
-
this._sheet.cells[idx] = {
|
|
876
|
-
value: newValue
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
}
|
|
462
|
+
var mapFormulaBindingToId = (functions) => (formula) => {
|
|
463
|
+
return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
|
|
464
|
+
if (defaultFunctions.find((fn2) => fn2.name === binding) || binding === "EDGE") {
|
|
465
|
+
return match;
|
|
880
466
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
invariant2(this._node, void 0, {
|
|
885
|
-
F: __dxlog_file2,
|
|
886
|
-
L: 207,
|
|
887
|
-
S: this,
|
|
888
|
-
A: [
|
|
889
|
-
"this._node",
|
|
890
|
-
""
|
|
891
|
-
]
|
|
892
|
-
});
|
|
893
|
-
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
894
|
-
this._node.graph.hf.undo();
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
redo() {
|
|
898
|
-
invariant2(this._node, void 0, {
|
|
899
|
-
F: __dxlog_file2,
|
|
900
|
-
L: 215,
|
|
901
|
-
S: this,
|
|
902
|
-
A: [
|
|
903
|
-
"this._node",
|
|
904
|
-
""
|
|
905
|
-
]
|
|
906
|
-
});
|
|
907
|
-
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
908
|
-
this._node.graph.hf.redo();
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Get value from sheet.
|
|
913
|
-
*/
|
|
914
|
-
getCellValue(cell) {
|
|
915
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
916
|
-
return this._sheet.cells[idx]?.value ?? null;
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Get value as a string for editing.
|
|
920
|
-
*/
|
|
921
|
-
getCellText(cell) {
|
|
922
|
-
const value = this.getCellValue(cell);
|
|
923
|
-
if (value == null) {
|
|
924
|
-
return void 0;
|
|
925
|
-
}
|
|
926
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
927
|
-
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
467
|
+
const fn = functions.find((fn2) => fn2.binding === binding);
|
|
468
|
+
if (fn) {
|
|
469
|
+
return `${fullyQualifiedId(fn)}(${args})`;
|
|
928
470
|
} else {
|
|
929
|
-
return
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Get array of raw values from sheet.
|
|
934
|
-
*/
|
|
935
|
-
getCellValues(range) {
|
|
936
|
-
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
937
|
-
}
|
|
938
|
-
/**
|
|
939
|
-
* Gets the regular or computed value from the engine.
|
|
940
|
-
*/
|
|
941
|
-
getValue(cell) {
|
|
942
|
-
invariant2(this._node, void 0, {
|
|
943
|
-
F: __dxlog_file2,
|
|
944
|
-
L: 258,
|
|
945
|
-
S: this,
|
|
946
|
-
A: [
|
|
947
|
-
"this._node",
|
|
948
|
-
""
|
|
949
|
-
]
|
|
950
|
-
});
|
|
951
|
-
const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
952
|
-
if (value instanceof DetailedCellError) {
|
|
953
|
-
return value.toString();
|
|
954
|
-
}
|
|
955
|
-
return value;
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* Get value type.
|
|
959
|
-
*/
|
|
960
|
-
getValueType(cell) {
|
|
961
|
-
invariant2(this._node, void 0, {
|
|
962
|
-
F: __dxlog_file2,
|
|
963
|
-
L: 271,
|
|
964
|
-
S: this,
|
|
965
|
-
A: [
|
|
966
|
-
"this._node",
|
|
967
|
-
""
|
|
968
|
-
]
|
|
969
|
-
});
|
|
970
|
-
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
971
|
-
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
972
|
-
return typeMap[type];
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* Sets the value, updating the sheet and engine.
|
|
976
|
-
*/
|
|
977
|
-
setValue(cell, value) {
|
|
978
|
-
invariant2(this._node, void 0, {
|
|
979
|
-
F: __dxlog_file2,
|
|
980
|
-
L: 281,
|
|
981
|
-
S: this,
|
|
982
|
-
A: [
|
|
983
|
-
"this._node",
|
|
984
|
-
""
|
|
985
|
-
]
|
|
986
|
-
});
|
|
987
|
-
if (this._options.readonly) {
|
|
988
|
-
throw new ReadonlyException();
|
|
989
|
-
}
|
|
990
|
-
let refresh = false;
|
|
991
|
-
if (cell.row >= this._sheet.rows.length) {
|
|
992
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
993
|
-
refresh = true;
|
|
994
|
-
}
|
|
995
|
-
if (cell.col >= this._sheet.columns.length) {
|
|
996
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
997
|
-
refresh = true;
|
|
471
|
+
return match;
|
|
998
472
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
473
|
+
});
|
|
474
|
+
};
|
|
475
|
+
var mapFormulaBindingFromId = (functions) => (formula) => {
|
|
476
|
+
return formula.replace(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
|
|
477
|
+
const id = `${spaceId}:${objectId}`;
|
|
478
|
+
if (id.length !== OBJECT_ID_LENGTH) {
|
|
479
|
+
return match;
|
|
1001
480
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
col: cell.col
|
|
1006
|
-
}, [
|
|
1007
|
-
[
|
|
1008
|
-
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
1009
|
-
]
|
|
1010
|
-
]);
|
|
1011
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
1012
|
-
if (value === void 0 || value === null) {
|
|
1013
|
-
delete this._sheet.cells[idx];
|
|
481
|
+
const fn = functions.find((fn2) => fullyQualifiedId(fn2) === id);
|
|
482
|
+
if (fn?.binding) {
|
|
483
|
+
return `${fn.binding}(${args})`;
|
|
1014
484
|
} else {
|
|
1015
|
-
|
|
1016
|
-
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1017
|
-
}
|
|
1018
|
-
this._sheet.cells[idx] = {
|
|
1019
|
-
value
|
|
1020
|
-
};
|
|
485
|
+
return match;
|
|
1021
486
|
}
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* Sets values from a simple map.
|
|
1025
|
-
*/
|
|
1026
|
-
setValues(values) {
|
|
1027
|
-
Object.entries(values).forEach(([key, { value }]) => {
|
|
1028
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Iterate range.
|
|
1033
|
-
*/
|
|
1034
|
-
_iterRange(range, cb) {
|
|
1035
|
-
const to = range.to ?? range.from;
|
|
1036
|
-
const rowRange = [
|
|
1037
|
-
Math.min(range.from.row, to.row),
|
|
1038
|
-
Math.max(range.from.row, to.row)
|
|
1039
|
-
];
|
|
1040
|
-
const columnRange = [
|
|
1041
|
-
Math.min(range.from.col, to.col),
|
|
1042
|
-
Math.max(range.from.col, to.col)
|
|
1043
|
-
];
|
|
1044
|
-
const rows = [];
|
|
1045
|
-
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
1046
|
-
const rowCells = [];
|
|
1047
|
-
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
1048
|
-
const value = cb({
|
|
1049
|
-
row,
|
|
1050
|
-
col: column
|
|
1051
|
-
});
|
|
1052
|
-
if (value !== void 0) {
|
|
1053
|
-
rowCells.push(value);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
rows.push(rowCells);
|
|
1057
|
-
}
|
|
1058
|
-
return rows;
|
|
1059
|
-
}
|
|
1060
|
-
// TODO(burdon): Delete index.
|
|
1061
|
-
_deleteIndices(indices, i, n) {
|
|
1062
|
-
throw new Error("Not implemented");
|
|
1063
|
-
}
|
|
1064
|
-
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
1065
|
-
_moveIndices(indices, i, j, n) {
|
|
1066
|
-
throw new Error("Not implemented");
|
|
1067
|
-
}
|
|
1068
|
-
//
|
|
1069
|
-
// Indices.
|
|
1070
|
-
//
|
|
1071
|
-
/**
|
|
1072
|
-
* Map from A1 notation to indices.
|
|
1073
|
-
*/
|
|
1074
|
-
mapFormulaRefsToIndices(formula) {
|
|
1075
|
-
invariant2(formula.charAt(0) === "=", void 0, {
|
|
1076
|
-
F: __dxlog_file2,
|
|
1077
|
-
L: 370,
|
|
1078
|
-
S: this,
|
|
1079
|
-
A: [
|
|
1080
|
-
"formula.charAt(0) === '='",
|
|
1081
|
-
""
|
|
1082
|
-
]
|
|
1083
|
-
});
|
|
1084
|
-
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1085
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Map from indices to A1 notation.
|
|
1090
|
-
*/
|
|
1091
|
-
mapFormulaIndicesToRefs(formula) {
|
|
1092
|
-
invariant2(formula.charAt(0) === "=", void 0, {
|
|
1093
|
-
F: __dxlog_file2,
|
|
1094
|
-
L: 380,
|
|
1095
|
-
S: this,
|
|
1096
|
-
A: [
|
|
1097
|
-
"formula.charAt(0) === '='",
|
|
1098
|
-
""
|
|
1099
|
-
]
|
|
1100
|
-
});
|
|
1101
|
-
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1102
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
|
-
//
|
|
1106
|
-
// Values
|
|
1107
|
-
//
|
|
1108
|
-
/**
|
|
1109
|
-
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1110
|
-
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1111
|
-
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1112
|
-
*/
|
|
1113
|
-
toLocalDate(num) {
|
|
1114
|
-
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1115
|
-
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1116
|
-
}
|
|
1117
|
-
toDateTime(num) {
|
|
1118
|
-
invariant2(this._node, void 0, {
|
|
1119
|
-
F: __dxlog_file2,
|
|
1120
|
-
L: 401,
|
|
1121
|
-
S: this,
|
|
1122
|
-
A: [
|
|
1123
|
-
"this._node",
|
|
1124
|
-
""
|
|
1125
|
-
]
|
|
1126
|
-
});
|
|
1127
|
-
return this._node.graph.hf.numberToDateTime(num);
|
|
1128
|
-
}
|
|
1129
|
-
toDate(num) {
|
|
1130
|
-
invariant2(this._node, void 0, {
|
|
1131
|
-
F: __dxlog_file2,
|
|
1132
|
-
L: 406,
|
|
1133
|
-
S: this,
|
|
1134
|
-
A: [
|
|
1135
|
-
"this._node",
|
|
1136
|
-
""
|
|
1137
|
-
]
|
|
1138
|
-
});
|
|
1139
|
-
return this._node.graph.hf.numberToDate(num);
|
|
1140
|
-
}
|
|
1141
|
-
toTime(num) {
|
|
1142
|
-
invariant2(this._node, void 0, {
|
|
1143
|
-
F: __dxlog_file2,
|
|
1144
|
-
L: 411,
|
|
1145
|
-
S: this,
|
|
1146
|
-
A: [
|
|
1147
|
-
"this._node",
|
|
1148
|
-
""
|
|
1149
|
-
]
|
|
1150
|
-
});
|
|
1151
|
-
return this._node.graph.hf.numberToTime(num);
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
1156
|
-
var useFormattingModel = (model) => {
|
|
1157
|
-
return useMemo(() => model && new FormattingModel(model), [
|
|
1158
|
-
model
|
|
1159
|
-
]);
|
|
487
|
+
});
|
|
1160
488
|
};
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
const [
|
|
489
|
+
var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...options }) => {
|
|
490
|
+
const graph = useComputeGraph(space, options);
|
|
491
|
+
const [cursor, setCursor] = useState3();
|
|
492
|
+
const [range, setRange] = useState3();
|
|
493
|
+
const [editing, setEditing] = useState3(false);
|
|
494
|
+
const [[model, formatting] = [], setModels] = useState3(void 0);
|
|
1166
495
|
useEffect2(() => {
|
|
1167
|
-
if (!graph || !sheet) {
|
|
1168
|
-
return;
|
|
1169
|
-
}
|
|
1170
496
|
let model2;
|
|
497
|
+
let formatting2;
|
|
1171
498
|
const t = setTimeout(async () => {
|
|
1172
|
-
model2 = new SheetModel(graph, sheet, {
|
|
1173
|
-
readonly
|
|
499
|
+
model2 = new SheetModel(graph, sheet, space, {
|
|
500
|
+
readonly,
|
|
501
|
+
mapFormulaBindingToId,
|
|
502
|
+
mapFormulaBindingFromId
|
|
1174
503
|
});
|
|
1175
|
-
await model2.
|
|
1176
|
-
|
|
504
|
+
await model2.initialize();
|
|
505
|
+
formatting2 = new FormattingModel(model2);
|
|
506
|
+
setModels([
|
|
507
|
+
model2,
|
|
508
|
+
formatting2
|
|
509
|
+
]);
|
|
1177
510
|
});
|
|
1178
511
|
return () => {
|
|
1179
512
|
clearTimeout(t);
|
|
1180
|
-
void model2?.
|
|
513
|
+
void model2?.destroy();
|
|
1181
514
|
};
|
|
1182
515
|
}, [
|
|
1183
516
|
graph,
|
|
1184
|
-
sheet,
|
|
1185
517
|
readonly
|
|
1186
518
|
]);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1192
|
-
var SheetContext = /* @__PURE__ */ createContext2(null);
|
|
1193
|
-
var useSheetContext = () => {
|
|
1194
|
-
const context = useContext2(SheetContext);
|
|
1195
|
-
invariant3(context, void 0, {
|
|
1196
|
-
F: __dxlog_file3,
|
|
1197
|
-
L: 43,
|
|
1198
|
-
S: void 0,
|
|
1199
|
-
A: [
|
|
1200
|
-
"context",
|
|
1201
|
-
""
|
|
1202
|
-
]
|
|
1203
|
-
});
|
|
1204
|
-
return context;
|
|
1205
|
-
};
|
|
1206
|
-
var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
1207
|
-
const model = useSheetModel(graph, sheet, {
|
|
1208
|
-
readonly
|
|
1209
|
-
});
|
|
1210
|
-
const formatting = useFormattingModel(model);
|
|
1211
|
-
const [cursor, setCursor] = useState4();
|
|
1212
|
-
const [range, setRange] = useState4();
|
|
1213
|
-
const [editing, setEditing] = useState4(false);
|
|
1214
|
-
const decorations = useMemo2(() => createDecorations(), []);
|
|
1215
|
-
return !model || !formatting ? null : /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
|
|
519
|
+
if (!model || !formatting) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
return /* @__PURE__ */ React.createElement(SheetContext.Provider, {
|
|
1216
523
|
value: {
|
|
1217
524
|
model,
|
|
1218
525
|
formatting,
|
|
@@ -1223,177 +530,11 @@ var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
|
1223
530
|
editing,
|
|
1224
531
|
setEditing,
|
|
1225
532
|
// TODO(burdon): Change to event.
|
|
1226
|
-
onInfo
|
|
1227
|
-
decorations
|
|
533
|
+
onInfo
|
|
1228
534
|
}
|
|
1229
535
|
}, children);
|
|
1230
536
|
};
|
|
1231
537
|
|
|
1232
|
-
// packages/plugins/plugin-sheet/src/components/Sheet/threads.tsx
|
|
1233
|
-
import { effect } from "@preact/signals-core";
|
|
1234
|
-
import React4, { useCallback, useEffect as useEffect3, useMemo as useMemo3 } from "react";
|
|
1235
|
-
import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
|
|
1236
|
-
import { debounce } from "@dxos/async";
|
|
1237
|
-
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
1238
|
-
import { Icon, useTranslation } from "@dxos/react-ui";
|
|
1239
|
-
var CommentIndicator = () => {
|
|
1240
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
1241
|
-
role: "none",
|
|
1242
|
-
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
1243
|
-
});
|
|
1244
|
-
};
|
|
1245
|
-
var ThreadedCellWrapper = ({ children }) => {
|
|
1246
|
-
const dispatch = useIntentDispatcher();
|
|
1247
|
-
const [isHovered, setIsHovered] = React4.useState(false);
|
|
1248
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
1249
|
-
const handleClick = React4.useCallback((_event) => {
|
|
1250
|
-
void dispatch({
|
|
1251
|
-
action: LayoutAction.SET_LAYOUT,
|
|
1252
|
-
data: {
|
|
1253
|
-
element: "complementary",
|
|
1254
|
-
state: true
|
|
1255
|
-
}
|
|
1256
|
-
});
|
|
1257
|
-
}, [
|
|
1258
|
-
dispatch
|
|
1259
|
-
]);
|
|
1260
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
1261
|
-
role: "none",
|
|
1262
|
-
className: "relative h-full is-full",
|
|
1263
|
-
onMouseEnter: () => {
|
|
1264
|
-
setIsHovered(true);
|
|
1265
|
-
},
|
|
1266
|
-
onMouseLeave: () => {
|
|
1267
|
-
setIsHovered(false);
|
|
1268
|
-
}
|
|
1269
|
-
}, /* @__PURE__ */ React4.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React4.createElement("div", {
|
|
1270
|
-
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
1271
|
-
}, /* @__PURE__ */ React4.createElement("button", {
|
|
1272
|
-
className: "ch-button text-xs min-bs-0 p-1",
|
|
1273
|
-
onClick: handleClick,
|
|
1274
|
-
"aria-label": t("open comment for sheet cell")
|
|
1275
|
-
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
1276
|
-
icon: "ph--chat--regular",
|
|
1277
|
-
"aria-hidden": true
|
|
1278
|
-
}))), children);
|
|
1279
|
-
};
|
|
1280
|
-
var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
1281
|
-
return {
|
|
1282
|
-
type: "comment",
|
|
1283
|
-
cellIndex,
|
|
1284
|
-
decorate: (props) => /* @__PURE__ */ React4.createElement(ThreadedCellWrapper, props)
|
|
1285
|
-
};
|
|
1286
|
-
};
|
|
1287
|
-
var useUpdateCursorOnThreadSelection = () => {
|
|
1288
|
-
const { setCursor, model } = useSheetContext();
|
|
1289
|
-
const handleScrollIntoView = useCallback(({ action, data }) => {
|
|
1290
|
-
switch (action) {
|
|
1291
|
-
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
1292
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId(model.sheet)) {
|
|
1293
|
-
return;
|
|
1294
|
-
}
|
|
1295
|
-
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
1296
|
-
setCursor(cellAddress);
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
}, [
|
|
1300
|
-
model.sheet,
|
|
1301
|
-
setCursor
|
|
1302
|
-
]);
|
|
1303
|
-
useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
|
|
1304
|
-
};
|
|
1305
|
-
var useSelectThreadOnCursorChange = () => {
|
|
1306
|
-
const { cursor, model } = useSheetContext();
|
|
1307
|
-
const dispatch = useIntentDispatcher();
|
|
1308
|
-
const activeThreads = useMemo3(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
1309
|
-
JSON.stringify(model.sheet.threads)
|
|
1310
|
-
]);
|
|
1311
|
-
const activeThreadAddresses = useMemo3(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
1312
|
-
activeThreads,
|
|
1313
|
-
model.sheet
|
|
1314
|
-
]);
|
|
1315
|
-
const selectClosestThread = useCallback((cellAddress) => {
|
|
1316
|
-
if (!cellAddress || !activeThreads) {
|
|
1317
|
-
return;
|
|
1318
|
-
}
|
|
1319
|
-
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
1320
|
-
if (closestThreadAnchor) {
|
|
1321
|
-
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
1322
|
-
if (closestThread) {
|
|
1323
|
-
void dispatch([
|
|
1324
|
-
{
|
|
1325
|
-
action: "dxos.org/plugin/thread/action/select",
|
|
1326
|
-
data: {
|
|
1327
|
-
current: fullyQualifiedId(closestThread)
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
]);
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
}, [
|
|
1334
|
-
dispatch,
|
|
1335
|
-
activeThreads,
|
|
1336
|
-
activeThreadAddresses,
|
|
1337
|
-
model.sheet
|
|
1338
|
-
]);
|
|
1339
|
-
const debounced = useMemo3(() => {
|
|
1340
|
-
return debounce((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
1341
|
-
}, [
|
|
1342
|
-
selectClosestThread
|
|
1343
|
-
]);
|
|
1344
|
-
useEffect3(() => {
|
|
1345
|
-
if (!cursor) {
|
|
1346
|
-
return;
|
|
1347
|
-
}
|
|
1348
|
-
debounced(cursor);
|
|
1349
|
-
}, [
|
|
1350
|
-
cursor,
|
|
1351
|
-
selectClosestThread
|
|
1352
|
-
]);
|
|
1353
|
-
};
|
|
1354
|
-
var useThreadDecorations = () => {
|
|
1355
|
-
const { decorations, model } = useSheetContext();
|
|
1356
|
-
const sheet = useMemo3(() => model.sheet, [
|
|
1357
|
-
model.sheet
|
|
1358
|
-
]);
|
|
1359
|
-
const sheetId = useMemo3(() => fullyQualifiedId(sheet), [
|
|
1360
|
-
sheet
|
|
1361
|
-
]);
|
|
1362
|
-
useEffect3(() => {
|
|
1363
|
-
const unsubscribe = effect(() => {
|
|
1364
|
-
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
1365
|
-
if (!sheet.threads) {
|
|
1366
|
-
return;
|
|
1367
|
-
}
|
|
1368
|
-
for (const thread of sheet.threads) {
|
|
1369
|
-
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1370
|
-
continue;
|
|
1371
|
-
}
|
|
1372
|
-
activeThreadAnchors.add(thread.anchor);
|
|
1373
|
-
const index = thread.anchor;
|
|
1374
|
-
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1375
|
-
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1376
|
-
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
for (const decoration of decorations.getAllDecorations()) {
|
|
1380
|
-
if (decoration.type !== "comment") {
|
|
1381
|
-
continue;
|
|
1382
|
-
}
|
|
1383
|
-
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1384
|
-
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
});
|
|
1388
|
-
return () => unsubscribe();
|
|
1389
|
-
});
|
|
1390
|
-
};
|
|
1391
|
-
var useThreads = () => {
|
|
1392
|
-
useUpdateCursorOnThreadSelection();
|
|
1393
|
-
useSelectThreadOnCursorChange();
|
|
1394
|
-
useThreadDecorations();
|
|
1395
|
-
};
|
|
1396
|
-
|
|
1397
538
|
// packages/plugins/plugin-sheet/src/components/Sheet/util.ts
|
|
1398
539
|
var getRelativeClientRect = (root, element) => {
|
|
1399
540
|
const rootRect = root.getBoundingClientRect();
|
|
@@ -1429,7 +570,7 @@ var scrollIntoView = (scrollContainer, el) => {
|
|
|
1429
570
|
|
|
1430
571
|
// packages/plugins/plugin-sheet/src/components/CellEditor/CellEditor.tsx
|
|
1431
572
|
import { EditorView, keymap } from "@codemirror/view";
|
|
1432
|
-
import
|
|
573
|
+
import React2 from "react";
|
|
1433
574
|
import { useThemeContext } from "@dxos/react-ui";
|
|
1434
575
|
import { createBasicExtensions, createThemeExtensions, preventNewline, useTextEditor } from "@dxos/react-ui-editor";
|
|
1435
576
|
var editorKeys = ({ onNav, onClose }) => {
|
|
@@ -1477,60 +618,20 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
1477
618
|
{
|
|
1478
619
|
key: "Enter",
|
|
1479
620
|
run: (editor) => {
|
|
1480
|
-
onClose(editor.state.doc.toString()
|
|
1481
|
-
key: "Enter"
|
|
1482
|
-
});
|
|
1483
|
-
return true;
|
|
1484
|
-
},
|
|
1485
|
-
shift: (editor) => {
|
|
1486
|
-
onClose(editor.state.doc.toString(), {
|
|
1487
|
-
key: "Enter",
|
|
1488
|
-
shift: true
|
|
1489
|
-
});
|
|
1490
|
-
return true;
|
|
1491
|
-
}
|
|
1492
|
-
},
|
|
1493
|
-
{
|
|
1494
|
-
key: "Tab",
|
|
1495
|
-
run: (editor) => {
|
|
1496
|
-
onClose(editor.state.doc.toString(), {
|
|
1497
|
-
key: "Tab"
|
|
1498
|
-
});
|
|
1499
|
-
return true;
|
|
1500
|
-
},
|
|
1501
|
-
shift: (editor) => {
|
|
1502
|
-
onClose(editor.state.doc.toString(), {
|
|
1503
|
-
key: "Tab",
|
|
1504
|
-
shift: true
|
|
1505
|
-
});
|
|
621
|
+
onClose(editor.state.doc.toString());
|
|
1506
622
|
return true;
|
|
1507
623
|
}
|
|
1508
624
|
},
|
|
1509
625
|
{
|
|
1510
626
|
key: "Escape",
|
|
1511
627
|
run: () => {
|
|
1512
|
-
onClose(void 0
|
|
1513
|
-
key: "Escape"
|
|
1514
|
-
});
|
|
628
|
+
onClose(void 0);
|
|
1515
629
|
return true;
|
|
1516
630
|
}
|
|
1517
631
|
}
|
|
1518
632
|
]);
|
|
1519
633
|
};
|
|
1520
|
-
var
|
|
1521
|
-
// TODO(thure): remove when legacy is no longer used.
|
|
1522
|
-
legacy: {
|
|
1523
|
-
root: "flex w-full",
|
|
1524
|
-
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1525
|
-
content: "!px-2 !py-1"
|
|
1526
|
-
},
|
|
1527
|
-
grid: {
|
|
1528
|
-
root: "absolute z-[1]",
|
|
1529
|
-
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1530
|
-
content: "!border !border-transparent !p-0.5"
|
|
1531
|
-
}
|
|
1532
|
-
};
|
|
1533
|
-
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
634
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
1534
635
|
const { themeMode } = useThemeContext();
|
|
1535
636
|
const { parentRef } = useTextEditor(() => {
|
|
1536
637
|
return {
|
|
@@ -1557,29 +658,21 @@ var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box
|
|
|
1557
658
|
themeMode,
|
|
1558
659
|
slots: {
|
|
1559
660
|
editor: {
|
|
1560
|
-
className:
|
|
661
|
+
className: "flex w-full [&>.cm-scroller]:scrollbar-none"
|
|
1561
662
|
},
|
|
1562
663
|
content: {
|
|
1563
|
-
className:
|
|
664
|
+
className: "!px-2 !py-1"
|
|
1564
665
|
}
|
|
1565
666
|
}
|
|
1566
667
|
})
|
|
1567
668
|
]
|
|
1568
669
|
};
|
|
1569
670
|
}, [
|
|
1570
|
-
extension
|
|
1571
|
-
autoFocus,
|
|
1572
|
-
value,
|
|
1573
|
-
variant,
|
|
1574
|
-
onBlur
|
|
671
|
+
extension
|
|
1575
672
|
]);
|
|
1576
|
-
return /* @__PURE__ */
|
|
673
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
1577
674
|
ref: parentRef,
|
|
1578
|
-
className:
|
|
1579
|
-
style: box,
|
|
1580
|
-
...gridId && {
|
|
1581
|
-
"data-grid": gridId
|
|
1582
|
-
}
|
|
675
|
+
className: "flex w-full"
|
|
1583
676
|
});
|
|
1584
677
|
};
|
|
1585
678
|
|
|
@@ -1701,7 +794,13 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1701
794
|
// NOTE: Useful for debugging.
|
|
1702
795
|
closeOnBlur: false,
|
|
1703
796
|
icons: false,
|
|
1704
|
-
tooltipClass: () => mx(
|
|
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
|
+
)
|
|
1705
804
|
}),
|
|
1706
805
|
keymap2.of([
|
|
1707
806
|
{
|
|
@@ -1790,7 +889,7 @@ var visitTree = (node, callback) => {
|
|
|
1790
889
|
};
|
|
1791
890
|
|
|
1792
891
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
1793
|
-
var
|
|
892
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1794
893
|
var fragments = {
|
|
1795
894
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1796
895
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1798,26 +897,25 @@ var fragments = {
|
|
|
1798
897
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1799
898
|
};
|
|
1800
899
|
var SheetRoot = ({ children, ...props }) => {
|
|
1801
|
-
return /* @__PURE__ */
|
|
900
|
+
return /* @__PURE__ */ React3.createElement(SheetContextProvider, props, children);
|
|
1802
901
|
};
|
|
1803
|
-
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows,
|
|
902
|
+
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns }, forwardRef2) => {
|
|
1804
903
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1805
904
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1806
|
-
|
|
1807
|
-
const [rows, setRows] = useState5([
|
|
905
|
+
const [rows, setRows] = useState4([
|
|
1808
906
|
...model.sheet.rows
|
|
1809
907
|
]);
|
|
1810
|
-
const [columns, setColumns] =
|
|
908
|
+
const [columns, setColumns] = useState4([
|
|
1811
909
|
...model.sheet.columns
|
|
1812
910
|
]);
|
|
1813
|
-
|
|
911
|
+
useEffect3(() => {
|
|
1814
912
|
const rowsAccessor = createDocAccessor(model.sheet, [
|
|
1815
913
|
"rows"
|
|
1816
914
|
]);
|
|
1817
915
|
const columnsAccessor = createDocAccessor(model.sheet, [
|
|
1818
916
|
"columns"
|
|
1819
917
|
]);
|
|
1820
|
-
const handleUpdate =
|
|
918
|
+
const handleUpdate = debounce(() => {
|
|
1821
919
|
setRows([
|
|
1822
920
|
...model.sheet.rows
|
|
1823
921
|
]);
|
|
@@ -1835,44 +933,44 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, fo
|
|
|
1835
933
|
}, [
|
|
1836
934
|
model
|
|
1837
935
|
]);
|
|
1838
|
-
|
|
936
|
+
useEffect3(() => {
|
|
1839
937
|
model.reset();
|
|
1840
938
|
}, [
|
|
1841
939
|
rows,
|
|
1842
940
|
columns
|
|
1843
941
|
]);
|
|
1844
942
|
const handleMoveRows = (from, to, num = 1) => {
|
|
1845
|
-
const cursorIdx = cursor ? addressToIndex(
|
|
943
|
+
const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
|
|
1846
944
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
1847
945
|
model.sheet.rows.splice(to, 0, rows2);
|
|
1848
946
|
if (cursorIdx) {
|
|
1849
|
-
setCursor(addressFromIndex(
|
|
947
|
+
setCursor(model.addressFromIndex(cursorIdx));
|
|
1850
948
|
}
|
|
1851
949
|
setRows([
|
|
1852
950
|
...model.sheet.rows
|
|
1853
951
|
]);
|
|
1854
952
|
};
|
|
1855
953
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
1856
|
-
const cursorIdx = cursor ? addressToIndex(
|
|
954
|
+
const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
|
|
1857
955
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
1858
956
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
1859
957
|
if (cursorIdx) {
|
|
1860
|
-
setCursor(addressFromIndex(
|
|
958
|
+
setCursor(model.addressFromIndex(cursorIdx));
|
|
1861
959
|
}
|
|
1862
960
|
setColumns([
|
|
1863
961
|
...model.sheet.columns
|
|
1864
962
|
]);
|
|
1865
963
|
};
|
|
1866
|
-
const [rowSizes, setRowSizes] =
|
|
1867
|
-
const [columnSizes, setColumnSizes] =
|
|
1868
|
-
|
|
964
|
+
const [rowSizes, setRowSizes] = useState4();
|
|
965
|
+
const [columnSizes, setColumnSizes] = useState4();
|
|
966
|
+
useEffect3(() => {
|
|
1869
967
|
const rowAccessor = createDocAccessor(model.sheet, [
|
|
1870
968
|
"rowMeta"
|
|
1871
969
|
]);
|
|
1872
970
|
const columnAccessor = createDocAccessor(model.sheet, [
|
|
1873
971
|
"columnMeta"
|
|
1874
972
|
]);
|
|
1875
|
-
const handleUpdate =
|
|
973
|
+
const handleUpdate = debounce(() => {
|
|
1876
974
|
const mapSizes = (values) => values.reduce((map, [idx, meta]) => {
|
|
1877
975
|
if (meta.size) {
|
|
1878
976
|
map[idx] = meta.size;
|
|
@@ -1914,54 +1012,54 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, fo
|
|
|
1914
1012
|
}));
|
|
1915
1013
|
}
|
|
1916
1014
|
};
|
|
1917
|
-
return /* @__PURE__ */
|
|
1015
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1918
1016
|
role: "none",
|
|
1919
1017
|
className: mx2("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1920
|
-
}, /* @__PURE__ */
|
|
1018
|
+
}, /* @__PURE__ */ React3.createElement(GridCorner, {
|
|
1921
1019
|
onClick: () => {
|
|
1922
1020
|
setCursor(void 0);
|
|
1923
1021
|
setRange(void 0);
|
|
1924
1022
|
setEditing(false);
|
|
1925
1023
|
}
|
|
1926
|
-
}), /* @__PURE__ */
|
|
1024
|
+
}), /* @__PURE__ */ React3.createElement(SheetColumns, {
|
|
1927
1025
|
ref: columnsRef,
|
|
1928
1026
|
columns,
|
|
1929
1027
|
sizes: columnSizes,
|
|
1930
|
-
selected: cursor?.
|
|
1931
|
-
onSelect: (
|
|
1028
|
+
selected: cursor?.column,
|
|
1029
|
+
onSelect: (column) => setCursor(cursor?.column === column ? void 0 : {
|
|
1932
1030
|
row: -1,
|
|
1933
|
-
|
|
1031
|
+
column
|
|
1934
1032
|
}),
|
|
1935
1033
|
onResize: handleResizeColumn,
|
|
1936
1034
|
onMove: handleMoveColumns
|
|
1937
|
-
}), /* @__PURE__ */
|
|
1035
|
+
}), /* @__PURE__ */ React3.createElement(SheetRows, {
|
|
1938
1036
|
ref: rowsRef,
|
|
1939
1037
|
rows,
|
|
1940
1038
|
sizes: rowSizes,
|
|
1941
1039
|
selected: cursor?.row,
|
|
1942
1040
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1943
1041
|
row,
|
|
1944
|
-
|
|
1042
|
+
column: -1
|
|
1945
1043
|
}),
|
|
1946
1044
|
onResize: handleResizeRow,
|
|
1947
1045
|
onMove: handleMoveRows
|
|
1948
|
-
}), /* @__PURE__ */
|
|
1046
|
+
}), /* @__PURE__ */ React3.createElement(SheetGrid, {
|
|
1949
1047
|
ref: contentRef,
|
|
1950
1048
|
size: {
|
|
1951
1049
|
numRows: numRows ?? rows.length,
|
|
1952
|
-
|
|
1050
|
+
numColumns: numColumns ?? columns.length
|
|
1953
1051
|
},
|
|
1954
1052
|
rows,
|
|
1955
1053
|
columns,
|
|
1956
1054
|
rowSizes,
|
|
1957
1055
|
columnSizes
|
|
1958
|
-
}), /* @__PURE__ */
|
|
1056
|
+
}), /* @__PURE__ */ React3.createElement(GridCorner, null), /* @__PURE__ */ React3.createElement(SheetStatusBar, null));
|
|
1959
1057
|
});
|
|
1960
1058
|
var useScrollHandlers = () => {
|
|
1961
1059
|
const rowsRef = useRef(null);
|
|
1962
1060
|
const columnsRef = useRef(null);
|
|
1963
1061
|
const contentRef = useRef(null);
|
|
1964
|
-
|
|
1062
|
+
useEffect3(() => {
|
|
1965
1063
|
const handleRowsScroll = (ev) => {
|
|
1966
1064
|
const { scrollTop } = ev.target;
|
|
1967
1065
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1998,13 +1096,13 @@ var useScrollHandlers = () => {
|
|
|
1998
1096
|
};
|
|
1999
1097
|
};
|
|
2000
1098
|
var GridCorner = (props) => {
|
|
2001
|
-
return /* @__PURE__ */
|
|
1099
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2002
1100
|
className: fragments.axis,
|
|
2003
1101
|
...props
|
|
2004
1102
|
});
|
|
2005
1103
|
};
|
|
2006
1104
|
var MovingOverlay = ({ label }) => {
|
|
2007
|
-
return /* @__PURE__ */
|
|
1105
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2008
1106
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
2009
1107
|
}, label);
|
|
2010
1108
|
};
|
|
@@ -2024,7 +1122,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
2024
1122
|
});
|
|
2025
1123
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
2026
1124
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
2027
|
-
const [active, setActive] =
|
|
1125
|
+
const [active, setActive] = useState4(null);
|
|
2028
1126
|
const handleDragStart = ({ active: active2 }) => {
|
|
2029
1127
|
setActive(active2);
|
|
2030
1128
|
};
|
|
@@ -2048,18 +1146,18 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
2048
1146
|
}
|
|
2049
1147
|
return transform;
|
|
2050
1148
|
};
|
|
2051
|
-
return /* @__PURE__ */
|
|
1149
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2052
1150
|
className: "relative flex grow overflow-hidden"
|
|
2053
|
-
}, /* @__PURE__ */
|
|
1151
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2054
1152
|
className: mx2("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
2055
1153
|
style: {
|
|
2056
1154
|
width: axisWidth
|
|
2057
1155
|
}
|
|
2058
|
-
}), /* @__PURE__ */
|
|
1156
|
+
}), /* @__PURE__ */ React3.createElement("div", {
|
|
2059
1157
|
ref: forwardRef2,
|
|
2060
1158
|
role: "rowheader",
|
|
2061
1159
|
className: "grow overflow-y-auto scrollbar-none"
|
|
2062
|
-
}, /* @__PURE__ */
|
|
1160
|
+
}, /* @__PURE__ */ React3.createElement(DndContext, {
|
|
2063
1161
|
sensors,
|
|
2064
1162
|
modifiers: [
|
|
2065
1163
|
restrictToVerticalAxis,
|
|
@@ -2067,12 +1165,12 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
2067
1165
|
],
|
|
2068
1166
|
onDragStart: handleDragStart,
|
|
2069
1167
|
onDragEnd: handleDragEnd
|
|
2070
|
-
}, /* @__PURE__ */
|
|
1168
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2071
1169
|
className: "flex flex-col",
|
|
2072
1170
|
style: {
|
|
2073
1171
|
width: axisWidth
|
|
2074
1172
|
}
|
|
2075
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1173
|
+
}, rows.map((idx, index) => /* @__PURE__ */ React3.createElement(GridRowCell, {
|
|
2076
1174
|
key: idx,
|
|
2077
1175
|
idx,
|
|
2078
1176
|
index,
|
|
@@ -2082,7 +1180,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
2082
1180
|
selected: selected === index,
|
|
2083
1181
|
onResize,
|
|
2084
1182
|
onSelect
|
|
2085
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
1183
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement(DragOverlay, null, active && /* @__PURE__ */ React3.createElement(MovingOverlay, {
|
|
2086
1184
|
label: String(active.data.current.index + 1)
|
|
2087
1185
|
})), document.body))));
|
|
2088
1186
|
});
|
|
@@ -2100,8 +1198,8 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
2100
1198
|
}
|
|
2101
1199
|
});
|
|
2102
1200
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
2103
|
-
const [initialSize, setInitialSize] =
|
|
2104
|
-
const [resizing, setResizing] =
|
|
1201
|
+
const [initialSize, setInitialSize] = useState4(size);
|
|
1202
|
+
const [resizing, setResizing] = useState4(false);
|
|
2105
1203
|
const scrollHandler = useRef();
|
|
2106
1204
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
2107
1205
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
@@ -2123,7 +1221,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
2123
1221
|
onResize?.(idx, initialSize + height, true);
|
|
2124
1222
|
setResizing(false);
|
|
2125
1223
|
};
|
|
2126
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ React3.createElement(Resizable, {
|
|
2127
1225
|
enable: {
|
|
2128
1226
|
bottom: resize
|
|
2129
1227
|
},
|
|
@@ -2135,17 +1233,17 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
2135
1233
|
onResizeStart: handleResizeStart,
|
|
2136
1234
|
onResize: handleResize,
|
|
2137
1235
|
onResizeStop: handleResizeStop
|
|
2138
|
-
}, /* @__PURE__ */
|
|
1236
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2139
1237
|
ref: setNodeRef,
|
|
2140
1238
|
...attributes,
|
|
2141
1239
|
...listeners,
|
|
2142
1240
|
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),
|
|
2143
1241
|
onClick: () => onSelect?.(index)
|
|
2144
|
-
}, /* @__PURE__ */
|
|
1242
|
+
}, /* @__PURE__ */ React3.createElement("span", {
|
|
2145
1243
|
className: "flex w-full justify-center"
|
|
2146
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
1244
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React3.createElement("div", {
|
|
2147
1245
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
2148
|
-
}), resizing && /* @__PURE__ */
|
|
1246
|
+
}), resizing && /* @__PURE__ */ React3.createElement("div", {
|
|
2149
1247
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
2150
1248
|
})));
|
|
2151
1249
|
};
|
|
@@ -2158,7 +1256,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
2158
1256
|
});
|
|
2159
1257
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
2160
1258
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
2161
|
-
const [active, setActive] =
|
|
1259
|
+
const [active, setActive] = useState4(null);
|
|
2162
1260
|
const handleDragStart = ({ active: active2 }) => {
|
|
2163
1261
|
setActive(active2);
|
|
2164
1262
|
};
|
|
@@ -2182,18 +1280,18 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
2182
1280
|
}
|
|
2183
1281
|
return transform;
|
|
2184
1282
|
};
|
|
2185
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2186
1284
|
className: "relative flex grow overflow-hidden"
|
|
2187
|
-
}, /* @__PURE__ */
|
|
1285
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2188
1286
|
className: mx2("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
2189
1287
|
style: {
|
|
2190
1288
|
height: axisHeight
|
|
2191
1289
|
}
|
|
2192
|
-
}), /* @__PURE__ */
|
|
1290
|
+
}), /* @__PURE__ */ React3.createElement("div", {
|
|
2193
1291
|
ref: forwardRef2,
|
|
2194
1292
|
role: "columnheader",
|
|
2195
1293
|
className: "grow overflow-x-auto scrollbar-none"
|
|
2196
|
-
}, /* @__PURE__ */
|
|
1294
|
+
}, /* @__PURE__ */ React3.createElement(DndContext, {
|
|
2197
1295
|
autoScroll: {
|
|
2198
1296
|
enabled: true
|
|
2199
1297
|
},
|
|
@@ -2204,12 +1302,12 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
2204
1302
|
],
|
|
2205
1303
|
onDragStart: handleDragStart,
|
|
2206
1304
|
onDragEnd: handleDragEnd
|
|
2207
|
-
}, /* @__PURE__ */
|
|
1305
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2208
1306
|
className: "flex h-full",
|
|
2209
1307
|
style: {
|
|
2210
1308
|
height: axisHeight
|
|
2211
1309
|
}
|
|
2212
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
1310
|
+
}, columns.map((idx, index) => /* @__PURE__ */ React3.createElement(GridColumnCell, {
|
|
2213
1311
|
key: idx,
|
|
2214
1312
|
idx,
|
|
2215
1313
|
index,
|
|
@@ -2219,7 +1317,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
2219
1317
|
selected: selected === index,
|
|
2220
1318
|
onResize,
|
|
2221
1319
|
onSelect
|
|
2222
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
1320
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement(DragOverlay, null, active && /* @__PURE__ */ React3.createElement(MovingOverlay, {
|
|
2223
1321
|
label: columnLetter(active.data.current.index)
|
|
2224
1322
|
})), document.body))));
|
|
2225
1323
|
});
|
|
@@ -2237,8 +1335,8 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2237
1335
|
}
|
|
2238
1336
|
});
|
|
2239
1337
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
2240
|
-
const [initialSize, setInitialSize] =
|
|
2241
|
-
const [resizing, setResizing] =
|
|
1338
|
+
const [initialSize, setInitialSize] = useState4(size);
|
|
1339
|
+
const [resizing, setResizing] = useState4(false);
|
|
2242
1340
|
const scrollHandler = useRef();
|
|
2243
1341
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
2244
1342
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
@@ -2260,7 +1358,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2260
1358
|
onResize?.(idx, initialSize + width, true);
|
|
2261
1359
|
setResizing(false);
|
|
2262
1360
|
};
|
|
2263
|
-
return /* @__PURE__ */
|
|
1361
|
+
return /* @__PURE__ */ React3.createElement(Resizable, {
|
|
2264
1362
|
enable: {
|
|
2265
1363
|
right: resize
|
|
2266
1364
|
},
|
|
@@ -2272,17 +1370,17 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2272
1370
|
onResizeStart: handleResizeStart,
|
|
2273
1371
|
onResize: handleResize,
|
|
2274
1372
|
onResizeStop: handleResizeStop
|
|
2275
|
-
}, /* @__PURE__ */
|
|
1373
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2276
1374
|
ref: setNodeRef,
|
|
2277
1375
|
...attributes,
|
|
2278
1376
|
...listeners,
|
|
2279
1377
|
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),
|
|
2280
1378
|
onClick: () => onSelect?.(index)
|
|
2281
|
-
}, /* @__PURE__ */
|
|
1379
|
+
}, /* @__PURE__ */ React3.createElement("span", {
|
|
2282
1380
|
className: "flex w-full justify-center"
|
|
2283
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
1381
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React3.createElement("div", {
|
|
2284
1382
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
2285
|
-
}), resizing && /* @__PURE__ */
|
|
1383
|
+
}), resizing && /* @__PURE__ */ React3.createElement("div", {
|
|
2286
1384
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
2287
1385
|
})));
|
|
2288
1386
|
};
|
|
@@ -2295,14 +1393,14 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2295
1393
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
2296
1394
|
const initialText = useRef();
|
|
2297
1395
|
const quickEdit = useRef(false);
|
|
2298
|
-
const [, forceUpdate] =
|
|
2299
|
-
|
|
1396
|
+
const [, forceUpdate] = useState4({});
|
|
1397
|
+
useEffect3(() => {
|
|
2300
1398
|
const unsubscribe = model.update.on(() => {
|
|
2301
|
-
|
|
1399
|
+
log("updated", {
|
|
2302
1400
|
id: model.id
|
|
2303
1401
|
}, {
|
|
2304
|
-
F:
|
|
2305
|
-
L:
|
|
1402
|
+
F: __dxlog_file2,
|
|
1403
|
+
L: 730,
|
|
2306
1404
|
S: void 0,
|
|
2307
1405
|
C: (f, a) => f(...a)
|
|
2308
1406
|
});
|
|
@@ -2422,16 +1520,16 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2422
1520
|
const id = fullyQualifiedId2(model.sheet);
|
|
2423
1521
|
const attendableAttrs = createAttendableAttributes(id);
|
|
2424
1522
|
const hasAttention = useHasAttention(id);
|
|
2425
|
-
return /* @__PURE__ */
|
|
1523
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2426
1524
|
ref: containerRef,
|
|
2427
1525
|
role: "grid",
|
|
2428
1526
|
className: "relative flex grow overflow-hidden"
|
|
2429
|
-
}, /* @__PURE__ */
|
|
1527
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2430
1528
|
className: mx2("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
2431
|
-
}), /* @__PURE__ */
|
|
1529
|
+
}), /* @__PURE__ */ React3.createElement("div", {
|
|
2432
1530
|
ref: scrollerRef,
|
|
2433
1531
|
className: mx2("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2434
|
-
}, /* @__PURE__ */
|
|
1532
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2435
1533
|
className: "relative select-none",
|
|
2436
1534
|
style: {
|
|
2437
1535
|
width,
|
|
@@ -2439,10 +1537,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2439
1537
|
},
|
|
2440
1538
|
onClick: () => inputRef.current?.focus(),
|
|
2441
1539
|
...handlers
|
|
2442
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
1540
|
+
}, scrollerRef.current && /* @__PURE__ */ React3.createElement(SelectionOverlay, {
|
|
2443
1541
|
root: scrollerRef.current
|
|
2444
1542
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
2445
|
-
return columnRange.map(({
|
|
1543
|
+
return columnRange.map(({ column, left, width: width2 }) => {
|
|
2446
1544
|
const style = {
|
|
2447
1545
|
position: "absolute",
|
|
2448
1546
|
top,
|
|
@@ -2452,10 +1550,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2452
1550
|
};
|
|
2453
1551
|
const cell = {
|
|
2454
1552
|
row,
|
|
2455
|
-
|
|
1553
|
+
column
|
|
2456
1554
|
};
|
|
2457
1555
|
const id2 = addressToA1Notation(cell);
|
|
2458
|
-
const idx = addressToIndex(
|
|
1556
|
+
const idx = model.addressToIndex(cell);
|
|
2459
1557
|
const active = posEquals(cursor, cell);
|
|
2460
1558
|
if (active && editing) {
|
|
2461
1559
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
@@ -2488,7 +1586,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2488
1586
|
inputRef.current?.focus();
|
|
2489
1587
|
setEditing(false);
|
|
2490
1588
|
};
|
|
2491
|
-
return /* @__PURE__ */
|
|
1589
|
+
return /* @__PURE__ */ React3.createElement(GridCellEditor, {
|
|
2492
1590
|
key: idx,
|
|
2493
1591
|
value,
|
|
2494
1592
|
style,
|
|
@@ -2496,7 +1594,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2496
1594
|
onClose: handleClose
|
|
2497
1595
|
});
|
|
2498
1596
|
}
|
|
2499
|
-
return /* @__PURE__ */
|
|
1597
|
+
return /* @__PURE__ */ React3.createElement(SheetCell, {
|
|
2500
1598
|
key: id2,
|
|
2501
1599
|
id: id2,
|
|
2502
1600
|
cell,
|
|
@@ -2508,7 +1606,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2508
1606
|
}
|
|
2509
1607
|
});
|
|
2510
1608
|
});
|
|
2511
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
1609
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement("input", {
|
|
2512
1610
|
ref: inputRef,
|
|
2513
1611
|
autoFocus: true,
|
|
2514
1612
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -2529,34 +1627,20 @@ var SelectionOverlay = ({ root }) => {
|
|
|
2529
1627
|
const b1 = getRelativeClientRect(root, c1);
|
|
2530
1628
|
const b2 = getRelativeClientRect(root, c2);
|
|
2531
1629
|
const bounds = getRectUnion(b1, b2);
|
|
2532
|
-
return /* @__PURE__ */
|
|
1630
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2533
1631
|
role: "none",
|
|
2534
1632
|
style: bounds,
|
|
2535
1633
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
2536
1634
|
});
|
|
2537
1635
|
};
|
|
2538
1636
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
2539
|
-
const { formatting, editing, setRange
|
|
1637
|
+
const { formatting, editing, setRange } = useSheetContext();
|
|
2540
1638
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
2541
|
-
|
|
2542
|
-
const decorationAddedClasses = useMemo4(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
2543
|
-
decorationsForCell
|
|
2544
|
-
]);
|
|
2545
|
-
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
2546
|
-
if (!decorate) {
|
|
2547
|
-
return children;
|
|
2548
|
-
}
|
|
2549
|
-
const DecoratorComponent = decorate;
|
|
2550
|
-
return /* @__PURE__ */ React6.createElement(DecoratorComponent, null, children);
|
|
2551
|
-
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2552
|
-
role: "none",
|
|
2553
|
-
className: mx2("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
2554
|
-
}, value));
|
|
2555
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
1639
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2556
1640
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
2557
1641
|
role: "cell",
|
|
2558
1642
|
style,
|
|
2559
|
-
className: mx2("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1643
|
+
className: mx2("flex w-full h-full px-2 py-1 truncate items-center border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
2560
1644
|
"z-20",
|
|
2561
1645
|
fragments.cellSelected
|
|
2562
1646
|
], classNames),
|
|
@@ -2570,36 +1654,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
2570
1654
|
}
|
|
2571
1655
|
},
|
|
2572
1656
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
2573
|
-
},
|
|
1657
|
+
}, value);
|
|
2574
1658
|
};
|
|
2575
1659
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
2576
1660
|
const { model, range } = useSheetContext();
|
|
2577
1661
|
const notifier = useRef();
|
|
2578
|
-
|
|
1662
|
+
useEffect3(() => {
|
|
2579
1663
|
if (range) {
|
|
2580
1664
|
notifier.current?.(rangeToA1Notation(range));
|
|
2581
1665
|
}
|
|
2582
1666
|
}, [
|
|
2583
1667
|
range
|
|
2584
1668
|
]);
|
|
2585
|
-
const extension =
|
|
1669
|
+
const extension = useMemo(() => [
|
|
2586
1670
|
editorKeys({
|
|
2587
1671
|
onNav,
|
|
2588
1672
|
onClose
|
|
2589
1673
|
}),
|
|
2590
1674
|
sheetExtension({
|
|
2591
|
-
functions: model.
|
|
1675
|
+
functions: model.functions
|
|
2592
1676
|
}),
|
|
2593
1677
|
rangeExtension((fn) => notifier.current = fn)
|
|
2594
1678
|
], [
|
|
2595
1679
|
model
|
|
2596
1680
|
]);
|
|
2597
|
-
return /* @__PURE__ */
|
|
1681
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2598
1682
|
role: "cell",
|
|
2599
1683
|
style,
|
|
2600
1684
|
className: mx2("z-20 flex", fragments.cellSelected),
|
|
2601
1685
|
onClick: (ev) => ev.stopPropagation()
|
|
2602
|
-
}, /* @__PURE__ */
|
|
1686
|
+
}, /* @__PURE__ */ React3.createElement(CellEditor, {
|
|
2603
1687
|
autoFocus: true,
|
|
2604
1688
|
value,
|
|
2605
1689
|
extension
|
|
@@ -2612,30 +1696,30 @@ var SheetStatusBar = () => {
|
|
|
2612
1696
|
if (cursor) {
|
|
2613
1697
|
value = model.getCellValue(cursor);
|
|
2614
1698
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2615
|
-
value = model.
|
|
1699
|
+
value = model.mapFormulaBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
2616
1700
|
isFormula = true;
|
|
2617
1701
|
} else if (value != null) {
|
|
2618
1702
|
value = String(value);
|
|
2619
1703
|
}
|
|
2620
1704
|
}
|
|
2621
|
-
return /* @__PURE__ */
|
|
1705
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2622
1706
|
className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
2623
|
-
}, /* @__PURE__ */
|
|
1707
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2624
1708
|
className: "flex gap-4 items-center"
|
|
2625
|
-
}, /* @__PURE__ */
|
|
1709
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
2626
1710
|
className: "flex w-16 items-center font-mono"
|
|
2627
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */
|
|
1711
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React3.createElement("div", {
|
|
2628
1712
|
className: "flex gap-2 items-center"
|
|
2629
|
-
}, /* @__PURE__ */
|
|
1713
|
+
}, /* @__PURE__ */ React3.createElement(FunctionIcon, {
|
|
2630
1714
|
className: mx2("text-greenText", isFormula ? "visible" : "invisible")
|
|
2631
|
-
}), /* @__PURE__ */
|
|
1715
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
2632
1716
|
className: "font-mono"
|
|
2633
1717
|
}, value))));
|
|
2634
1718
|
};
|
|
2635
1719
|
var SheetDebug = () => {
|
|
2636
1720
|
const { model, cursor, range } = useSheetContext();
|
|
2637
|
-
const [, forceUpdate] =
|
|
2638
|
-
|
|
1721
|
+
const [, forceUpdate] = useState4({});
|
|
1722
|
+
useEffect3(() => {
|
|
2639
1723
|
const accessor = createDocAccessor(model.sheet, []);
|
|
2640
1724
|
const handleUpdate = () => forceUpdate({});
|
|
2641
1725
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -2646,9 +1730,9 @@ var SheetDebug = () => {
|
|
|
2646
1730
|
}, [
|
|
2647
1731
|
model
|
|
2648
1732
|
]);
|
|
2649
|
-
return /* @__PURE__ */
|
|
1733
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
2650
1734
|
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")
|
|
2651
|
-
}, /* @__PURE__ */
|
|
1735
|
+
}, /* @__PURE__ */ React3.createElement("pre", {
|
|
2652
1736
|
className: "whitespace-pre-wrap"
|
|
2653
1737
|
}, JSON.stringify({
|
|
2654
1738
|
cursor,
|
|
@@ -2670,14 +1754,19 @@ var Sheet = {
|
|
|
2670
1754
|
Debug: SheetDebug
|
|
2671
1755
|
};
|
|
2672
1756
|
|
|
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;
|
|
2673
1769
|
export {
|
|
2674
|
-
|
|
2675
|
-
createSheet,
|
|
2676
|
-
addressToIndex,
|
|
2677
|
-
compareIndexPositions,
|
|
2678
|
-
useComputeGraph,
|
|
2679
|
-
useSheetContext,
|
|
2680
|
-
Sheet,
|
|
2681
|
-
SheetContainer
|
|
1770
|
+
SheetContainer_default as default
|
|
2682
1771
|
};
|
|
2683
|
-
//# sourceMappingURL=
|
|
1772
|
+
//# sourceMappingURL=SheetContainer-U4H5D34A.mjs.map
|