@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.c4a728f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs +261 -0
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GNNVBNCX.mjs → chunk-6ZMQVB4Z.mjs} +358 -678
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-WUPTZUTX.mjs → browser/chunk-T3NJFTD4.mjs} +4 -14
- package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-U2JHW3L6.mjs} +819 -498
- package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +7 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs +21 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +58 -55
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs +279 -0
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZRQZFV5T.cjs → chunk-DD6FIXWC.cjs} +359 -679
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-OTTD7FBK.cjs} +875 -551
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +7 -0
- package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-Q3HBHPRL.cjs} +8 -19
- package/dist/lib/node/chunk-Q3HBHPRL.cjs.map +7 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs +43 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs.map +7 -0
- package/dist/lib/node/index.cjs +75 -64
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +262 -0
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +7 -0
- package/dist/lib/node-esm/{SheetContainer-Y7ZMFBAP.mjs → chunk-7HVSOTGA.mjs} +820 -498
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +7 -0
- package/dist/lib/{browser/chunk-WUPTZUTX.mjs → node-esm/chunk-BMNA27EX.mjs} +5 -14
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-D6KU5MI7.mjs} +359 -677
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JRL5LGCE.mjs → chunk-IU2L277A.mjs} +4 -5
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs +22 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +59 -55
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/types.mjs +5 -6
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +7 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/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 +4 -5
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/util.d.ts +8 -4
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +5 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph}/async-function.d.ts +1 -1
- package/dist/types/src/graph/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +81 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +19 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph/custom.d.ts → graph/custom-function.d.ts} +1 -1
- package/dist/types/src/graph/custom-function.d.ts.map +1 -0
- package/dist/types/src/graph/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +4 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -4
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +9 -48
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +9 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +12 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +41 -38
- package/src/SheetPlugin.tsx +39 -59
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -3
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +3 -3
- package/src/components/CellEditor/extension.ts +1 -3
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +35 -0
- package/src/components/GridSheet/GridSheet.tsx +153 -0
- package/src/components/GridSheet/util.ts +108 -0
- package/src/components/Sheet/Sheet.stories.tsx +41 -82
- package/src/components/Sheet/Sheet.tsx +12 -10
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +10 -80
- package/src/components/Sheet/threads.tsx +10 -6
- package/src/components/SheetContainer.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +7 -7
- package/src/{model → defs}/types.ts +23 -14
- package/src/{model → defs}/util.ts +49 -17
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +98 -0
- package/src/extensions/index.ts +5 -0
- package/src/{components/ComputeGraph → graph}/async-function.ts +3 -1
- package/src/graph/compute-graph.browser.test.ts +104 -0
- package/src/graph/compute-graph.stories.tsx +92 -0
- package/src/graph/compute-graph.ts +290 -0
- package/src/graph/compute-node.ts +51 -0
- package/src/{components/ComputeGraph/custom.ts → graph/custom-function.ts} +2 -6
- package/src/{components/ComputeGraph → graph}/edge-function.ts +2 -1
- package/src/graph/hyperformula.test.ts +15 -0
- package/src/graph/index.ts +7 -0
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +20 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +43 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -4
- package/src/model/{model.ts → sheet-model.ts} +67 -184
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +66 -0
- package/src/types.ts +14 -12
- package/dist/lib/browser/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/browser/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/browser/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/browser/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/browser/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-KEOKUKAQ.cjs.map +0 -7
- package/dist/lib/node/chunk-57PB2HPY.cjs +0 -40
- package/dist/lib/node/chunk-57PB2HPY.cjs.map +0 -7
- package/dist/lib/node/chunk-6LWBQAQZ.cjs +0 -202
- package/dist/lib/node/chunk-6LWBQAQZ.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-VJU3NPUJ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZRQZFV5T.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/node-esm/testing.mjs +0 -92
- package/dist/lib/node-esm/testing.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -49
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -99
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/ComputeGraph → graph}/edge-function.d.ts +0 -0
- /package/src/{model/functions.ts → graph/function-defs.ts} +0 -0
|
@@ -1,33 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-PGKZPKUD.mjs";
|
|
4
|
-
import {
|
|
5
|
-
SheetModel,
|
|
6
|
-
addressFromA1Notation,
|
|
7
|
-
addressFromIndex,
|
|
8
|
-
addressToA1Notation,
|
|
9
|
-
addressToIndex,
|
|
10
|
-
closest,
|
|
11
|
-
columnLetter,
|
|
12
|
-
defaultFunctions,
|
|
13
|
-
inRange,
|
|
14
|
-
posEquals,
|
|
15
|
-
rangeFromIndex,
|
|
16
|
-
rangeToA1Notation
|
|
17
|
-
} from "./chunk-GNNVBNCX.mjs";
|
|
18
|
-
import {
|
|
2
|
+
SheetType,
|
|
19
3
|
ValueTypeEnum
|
|
20
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-T3NJFTD4.mjs";
|
|
21
5
|
import {
|
|
22
6
|
SHEET_PLUGIN
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
28
|
-
import { fullyQualifiedId as fullyQualifiedId4 } from "@dxos/react-client/echo";
|
|
29
|
-
import { useIsDirectlyAttended } from "@dxos/react-ui-attention";
|
|
30
|
-
import { focusRing, mx as mx4 } from "@dxos/react-ui-theme";
|
|
7
|
+
} from "./chunk-QILRZNE5.mjs";
|
|
8
|
+
import {
|
|
9
|
+
createSheetName
|
|
10
|
+
} from "./chunk-6ZMQVB4Z.mjs";
|
|
31
11
|
|
|
32
12
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
33
13
|
import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
@@ -35,17 +15,175 @@ import { restrictToHorizontalAxis, restrictToVerticalAxis } from "@dnd-kit/modif
|
|
|
35
15
|
import { getEventCoordinates, useCombinedRefs } from "@dnd-kit/utilities";
|
|
36
16
|
import { Function as FunctionIcon } from "@phosphor-icons/react";
|
|
37
17
|
import { Resizable } from "re-resizable";
|
|
38
|
-
import
|
|
18
|
+
import React6, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo4, useRef, useState as useState5 } from "react";
|
|
39
19
|
import { createPortal } from "react-dom";
|
|
40
20
|
import { useResizeDetector } from "react-resize-detector";
|
|
41
21
|
import { debounce as debounce2 } from "@dxos/async";
|
|
42
|
-
import { fullyQualifiedId as
|
|
43
|
-
import { log } from "@dxos/log";
|
|
22
|
+
import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
|
|
23
|
+
import { log as log2 } from "@dxos/log";
|
|
44
24
|
import { createAttendableAttributes, useHasAttention } from "@dxos/react-ui-attention";
|
|
45
|
-
import { mx as
|
|
25
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
46
26
|
|
|
47
27
|
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
48
28
|
import { useEffect, useState } from "react";
|
|
29
|
+
|
|
30
|
+
// packages/plugins/plugin-sheet/src/defs/types.ts
|
|
31
|
+
import { invariant } from "@dxos/invariant";
|
|
32
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
33
|
+
var DEFAULT_ROWS = 50;
|
|
34
|
+
var DEFAULT_COLUMNS = 26;
|
|
35
|
+
var MAX_ROWS = 500;
|
|
36
|
+
var MAX_COLUMNS = 26 * 2;
|
|
37
|
+
var posEquals = (a, b) => {
|
|
38
|
+
return a?.col === b?.col && a?.row === b?.row;
|
|
39
|
+
};
|
|
40
|
+
var columnLetter = (col) => {
|
|
41
|
+
invariant(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
42
|
+
F: __dxlog_file,
|
|
43
|
+
L: 26,
|
|
44
|
+
S: void 0,
|
|
45
|
+
A: [
|
|
46
|
+
"col < MAX_COLUMNS",
|
|
47
|
+
"`Invalid column: ${col}`"
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
51
|
+
};
|
|
52
|
+
var addressToA1Notation = ({ col, row }) => {
|
|
53
|
+
return `${columnLetter(col)}${row + 1}`;
|
|
54
|
+
};
|
|
55
|
+
var addressFromA1Notation = (ref) => {
|
|
56
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
57
|
+
invariant(match, `Invalid notation: ${ref}`, {
|
|
58
|
+
F: __dxlog_file,
|
|
59
|
+
L: 39,
|
|
60
|
+
S: void 0,
|
|
61
|
+
A: [
|
|
62
|
+
"match",
|
|
63
|
+
"`Invalid notation: ${ref}`"
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
row: parseInt(match[2], 10) - 1,
|
|
68
|
+
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
var rangeToA1Notation = (range) => {
|
|
72
|
+
return [
|
|
73
|
+
range?.from && addressToA1Notation(range?.from),
|
|
74
|
+
range?.to && addressToA1Notation(range?.to)
|
|
75
|
+
].filter(Boolean).join(":");
|
|
76
|
+
};
|
|
77
|
+
var inRange = (range, cell) => {
|
|
78
|
+
if (!range) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const { from, to } = range;
|
|
82
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (!from || !to) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const { col: c1, row: r1 } = from;
|
|
89
|
+
const { col: c2, row: r2 } = to;
|
|
90
|
+
const cMin = Math.min(c1, c2);
|
|
91
|
+
const cMax = Math.max(c1, c2);
|
|
92
|
+
const rMin = Math.min(r1, r2);
|
|
93
|
+
const rMax = Math.max(r1, r2);
|
|
94
|
+
const { col, row } = cell;
|
|
95
|
+
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// packages/plugins/plugin-sheet/src/defs/util.ts
|
|
99
|
+
import { randomBytes } from "@dxos/crypto";
|
|
100
|
+
import { create } from "@dxos/echo-schema";
|
|
101
|
+
var ApiError = class extends Error {
|
|
102
|
+
};
|
|
103
|
+
var ReadonlyException = class extends ApiError {
|
|
104
|
+
};
|
|
105
|
+
var RangeException = class extends ApiError {
|
|
106
|
+
constructor(n) {
|
|
107
|
+
super();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var createIndex = (length = 8) => {
|
|
111
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
112
|
+
const charactersLength = characters.length;
|
|
113
|
+
const randomBuffer = randomBytes(length);
|
|
114
|
+
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
115
|
+
};
|
|
116
|
+
var createIndices = (length) => Array.from({
|
|
117
|
+
length
|
|
118
|
+
}).map(() => createIndex());
|
|
119
|
+
var insertIndices = (indices, i, n, max) => {
|
|
120
|
+
if (i + n > max) {
|
|
121
|
+
throw new RangeException(i + n);
|
|
122
|
+
}
|
|
123
|
+
const idx = createIndices(n);
|
|
124
|
+
indices.splice(i, 0, ...idx);
|
|
125
|
+
};
|
|
126
|
+
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
127
|
+
if (!sheet.rows.length) {
|
|
128
|
+
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
129
|
+
}
|
|
130
|
+
if (!sheet.columns.length) {
|
|
131
|
+
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var createSheet = ({ title, ...size } = {}) => {
|
|
135
|
+
const sheet = create(SheetType, {
|
|
136
|
+
title,
|
|
137
|
+
cells: {},
|
|
138
|
+
rows: [],
|
|
139
|
+
columns: [],
|
|
140
|
+
rowMeta: {},
|
|
141
|
+
columnMeta: {},
|
|
142
|
+
formatting: {}
|
|
143
|
+
});
|
|
144
|
+
initialize(sheet, size);
|
|
145
|
+
return sheet;
|
|
146
|
+
};
|
|
147
|
+
var addressToIndex = (sheet, cell) => {
|
|
148
|
+
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
149
|
+
};
|
|
150
|
+
var addressFromIndex = (sheet, idx) => {
|
|
151
|
+
const [column, row] = idx.split("@");
|
|
152
|
+
return {
|
|
153
|
+
col: sheet.columns.indexOf(column),
|
|
154
|
+
row: sheet.rows.indexOf(row)
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
var rangeFromIndex = (sheet, idx) => {
|
|
158
|
+
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
159
|
+
return {
|
|
160
|
+
from,
|
|
161
|
+
to
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
var closest = (cursor, cells) => {
|
|
165
|
+
let closestCell;
|
|
166
|
+
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
167
|
+
for (const cell of cells) {
|
|
168
|
+
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
169
|
+
if (distance < closestDistance) {
|
|
170
|
+
closestCell = cell;
|
|
171
|
+
closestDistance = distance;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return closestCell;
|
|
175
|
+
};
|
|
176
|
+
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
177
|
+
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
178
|
+
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
179
|
+
if (rowA !== rowB) {
|
|
180
|
+
return rowA - rowB;
|
|
181
|
+
} else {
|
|
182
|
+
return columnA - columnB;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
49
187
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
50
188
|
var axisHeight = 34;
|
|
51
189
|
var minWidth = 40;
|
|
@@ -87,7 +225,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
87
225
|
const left = x;
|
|
88
226
|
x += width2 - 1;
|
|
89
227
|
return {
|
|
90
|
-
|
|
228
|
+
col: i,
|
|
91
229
|
left,
|
|
92
230
|
width: width2
|
|
93
231
|
};
|
|
@@ -192,14 +330,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
192
330
|
break;
|
|
193
331
|
}
|
|
194
332
|
case "ArrowLeft": {
|
|
195
|
-
if (opposite.
|
|
196
|
-
opposite.
|
|
333
|
+
if (opposite.col > 0) {
|
|
334
|
+
opposite.col -= 1;
|
|
197
335
|
}
|
|
198
336
|
break;
|
|
199
337
|
}
|
|
200
338
|
case "ArrowRight": {
|
|
201
|
-
if (opposite.
|
|
202
|
-
opposite.
|
|
339
|
+
if (opposite.col < size.numCols - 1) {
|
|
340
|
+
opposite.col += 1;
|
|
203
341
|
}
|
|
204
342
|
break;
|
|
205
343
|
}
|
|
@@ -217,18 +355,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
217
355
|
cursor: next
|
|
218
356
|
};
|
|
219
357
|
};
|
|
220
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
358
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
221
359
|
switch (ev.key) {
|
|
222
360
|
case "ArrowUp":
|
|
223
361
|
if (cursor === void 0) {
|
|
224
362
|
return {
|
|
225
363
|
row: 0,
|
|
226
|
-
|
|
364
|
+
col: 0
|
|
227
365
|
};
|
|
228
366
|
} else if (cursor.row > 0) {
|
|
229
367
|
return {
|
|
230
368
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
231
|
-
|
|
369
|
+
col: cursor.col
|
|
232
370
|
};
|
|
233
371
|
}
|
|
234
372
|
break;
|
|
@@ -236,12 +374,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
236
374
|
if (cursor === void 0) {
|
|
237
375
|
return {
|
|
238
376
|
row: 0,
|
|
239
|
-
|
|
377
|
+
col: 0
|
|
240
378
|
};
|
|
241
379
|
} else if (cursor.row < numRows - 1) {
|
|
242
380
|
return {
|
|
243
381
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
244
|
-
|
|
382
|
+
col: cursor.col
|
|
245
383
|
};
|
|
246
384
|
}
|
|
247
385
|
break;
|
|
@@ -249,12 +387,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
249
387
|
if (cursor === void 0) {
|
|
250
388
|
return {
|
|
251
389
|
row: 0,
|
|
252
|
-
|
|
390
|
+
col: 0
|
|
253
391
|
};
|
|
254
|
-
} else if (cursor.
|
|
392
|
+
} else if (cursor.col > 0) {
|
|
255
393
|
return {
|
|
256
394
|
row: cursor.row,
|
|
257
|
-
|
|
395
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
258
396
|
};
|
|
259
397
|
}
|
|
260
398
|
break;
|
|
@@ -262,24 +400,24 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
262
400
|
if (cursor === void 0) {
|
|
263
401
|
return {
|
|
264
402
|
row: 0,
|
|
265
|
-
|
|
403
|
+
col: 0
|
|
266
404
|
};
|
|
267
|
-
} else if (cursor.
|
|
405
|
+
} else if (cursor.col < numCols - 1) {
|
|
268
406
|
return {
|
|
269
407
|
row: cursor.row,
|
|
270
|
-
|
|
408
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
271
409
|
};
|
|
272
410
|
}
|
|
273
411
|
break;
|
|
274
412
|
case "Home":
|
|
275
413
|
return {
|
|
276
414
|
row: 0,
|
|
277
|
-
|
|
415
|
+
col: 0
|
|
278
416
|
};
|
|
279
417
|
case "End":
|
|
280
418
|
return {
|
|
281
419
|
row: numRows - 1,
|
|
282
|
-
|
|
420
|
+
col: numCols - 1
|
|
283
421
|
};
|
|
284
422
|
}
|
|
285
423
|
};
|
|
@@ -336,14 +474,13 @@ var useRangeSelect = (cb) => {
|
|
|
336
474
|
};
|
|
337
475
|
|
|
338
476
|
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
339
|
-
import
|
|
340
|
-
import { invariant } from "@dxos/invariant";
|
|
341
|
-
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
477
|
+
import React3, { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useState as useState4 } from "react";
|
|
478
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
342
479
|
|
|
343
480
|
// packages/plugins/plugin-sheet/src/components/Sheet/decorations.ts
|
|
344
|
-
import { create } from "@dxos/echo-schema";
|
|
481
|
+
import { create as create2 } from "@dxos/echo-schema";
|
|
345
482
|
var createDecorations = () => {
|
|
346
|
-
const { decorations } =
|
|
483
|
+
const { decorations } = create2({
|
|
347
484
|
decorations: {}
|
|
348
485
|
});
|
|
349
486
|
const addDecoration = (cellIndex, decorator) => {
|
|
@@ -379,27 +516,61 @@ var createDecorations = () => {
|
|
|
379
516
|
};
|
|
380
517
|
};
|
|
381
518
|
|
|
382
|
-
// packages/plugins/plugin-sheet/src/
|
|
519
|
+
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
520
|
+
import { useContext } from "react";
|
|
521
|
+
import { raise } from "@dxos/debug";
|
|
522
|
+
import { useAsyncState } from "@dxos/react-hooks";
|
|
523
|
+
|
|
524
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
525
|
+
import React2 from "react";
|
|
526
|
+
|
|
527
|
+
// packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
528
|
+
import React, { createContext } from "react";
|
|
529
|
+
var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
|
|
530
|
+
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
531
|
+
return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
|
|
532
|
+
value: {
|
|
533
|
+
registry
|
|
534
|
+
}
|
|
535
|
+
}, children);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
539
|
+
var SheetContainer = React2.lazy(() => import("./SheetContainer-V4GCCZTX.mjs"));
|
|
540
|
+
|
|
541
|
+
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
542
|
+
var useComputeGraph = (space) => {
|
|
543
|
+
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
544
|
+
return useAsyncState(async () => space && registry.getOrCreateGraph(space), [
|
|
545
|
+
space,
|
|
546
|
+
registry
|
|
547
|
+
]);
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
551
|
+
import { useMemo } from "react";
|
|
552
|
+
|
|
553
|
+
// packages/plugins/plugin-sheet/src/model/formatting-model.ts
|
|
383
554
|
var FormattingModel = class {
|
|
384
|
-
constructor(
|
|
385
|
-
this.
|
|
555
|
+
constructor(_model) {
|
|
556
|
+
this._model = _model;
|
|
386
557
|
}
|
|
387
558
|
/**
|
|
388
559
|
* Get formatted string value and className for cell.
|
|
389
560
|
*/
|
|
390
561
|
getFormatting(cell) {
|
|
391
|
-
const value = this.
|
|
562
|
+
const value = this._model.getValue(cell);
|
|
392
563
|
if (value === void 0 || value === null) {
|
|
393
564
|
return {};
|
|
394
565
|
}
|
|
395
566
|
const locales = void 0;
|
|
396
|
-
const idx = addressToIndex(this.
|
|
397
|
-
let formatting = this.
|
|
567
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
568
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
398
569
|
const classNames = [
|
|
399
570
|
...formatting?.classNames ?? []
|
|
400
571
|
];
|
|
401
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
402
|
-
const range = rangeFromIndex(this.
|
|
572
|
+
for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
|
|
573
|
+
const range = rangeFromIndex(this._model.sheet, idx2);
|
|
403
574
|
if (inRange(range, cell)) {
|
|
404
575
|
if (_formatting.classNames) {
|
|
405
576
|
classNames.push(..._formatting.classNames);
|
|
@@ -410,7 +581,7 @@ var FormattingModel = class {
|
|
|
410
581
|
}
|
|
411
582
|
}
|
|
412
583
|
const defaultNumber = "justify-end font-mono";
|
|
413
|
-
const type = formatting?.type ?? this.
|
|
584
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
414
585
|
switch (type) {
|
|
415
586
|
case ValueTypeEnum.Boolean: {
|
|
416
587
|
return {
|
|
@@ -460,21 +631,21 @@ var FormattingModel = class {
|
|
|
460
631
|
// Dates.
|
|
461
632
|
//
|
|
462
633
|
case ValueTypeEnum.DateTime: {
|
|
463
|
-
const date = this.
|
|
634
|
+
const date = this._model.toLocalDate(value);
|
|
464
635
|
return {
|
|
465
636
|
value: date.toLocaleString(locales),
|
|
466
637
|
classNames
|
|
467
638
|
};
|
|
468
639
|
}
|
|
469
640
|
case ValueTypeEnum.Date: {
|
|
470
|
-
const date = this.
|
|
641
|
+
const date = this._model.toLocalDate(value);
|
|
471
642
|
return {
|
|
472
643
|
value: date.toLocaleDateString(locales),
|
|
473
644
|
classNames
|
|
474
645
|
};
|
|
475
646
|
}
|
|
476
647
|
case ValueTypeEnum.Time: {
|
|
477
|
-
const date = this.
|
|
648
|
+
const date = this._model.toLocalDate(value);
|
|
478
649
|
return {
|
|
479
650
|
value: date.toLocaleTimeString(locales),
|
|
480
651
|
classNames
|
|
@@ -490,85 +661,428 @@ var FormattingModel = class {
|
|
|
490
661
|
}
|
|
491
662
|
};
|
|
492
663
|
|
|
493
|
-
// packages/plugins/plugin-sheet/src/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
664
|
+
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
665
|
+
import { Event } from "@dxos/async";
|
|
666
|
+
import { Resource } from "@dxos/context";
|
|
667
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
668
|
+
import { PublicKey } from "@dxos/keys";
|
|
669
|
+
import { log } from "@dxos/log";
|
|
670
|
+
import { DetailedCellError, ExportedCellChange } from "#hyperformula";
|
|
671
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
672
|
+
var typeMap = {
|
|
673
|
+
BOOLEAN: ValueTypeEnum.Boolean,
|
|
674
|
+
NUMBER_RAW: ValueTypeEnum.Number,
|
|
675
|
+
NUMBER_PERCENT: ValueTypeEnum.Percent,
|
|
676
|
+
NUMBER_CURRENCY: ValueTypeEnum.Currency,
|
|
677
|
+
NUMBER_DATETIME: ValueTypeEnum.DateTime,
|
|
678
|
+
NUMBER_DATE: ValueTypeEnum.Date,
|
|
679
|
+
NUMBER_TIME: ValueTypeEnum.Time
|
|
509
680
|
};
|
|
510
|
-
var
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
681
|
+
var getTopLeft = (range) => {
|
|
682
|
+
const to = range.to ?? range.from;
|
|
683
|
+
return {
|
|
684
|
+
row: Math.min(range.from.row, to.row),
|
|
685
|
+
col: Math.min(range.from.col, to.col)
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
689
|
+
sheet,
|
|
690
|
+
row: cell.row,
|
|
691
|
+
col: cell.col
|
|
692
|
+
});
|
|
693
|
+
var toModelRange = (sheet, range) => ({
|
|
694
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
695
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
696
|
+
});
|
|
697
|
+
var SheetModel = class extends Resource {
|
|
698
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
699
|
+
super();
|
|
700
|
+
this._graph = _graph;
|
|
701
|
+
this._sheet = _sheet;
|
|
702
|
+
this._options = _options;
|
|
703
|
+
this.id = `model-${PublicKey.random().truncate()}`;
|
|
704
|
+
this.update = new Event();
|
|
705
|
+
this._node = this._graph.getOrCreateNode(createSheetName(this._sheet.id));
|
|
706
|
+
this.reset();
|
|
707
|
+
}
|
|
708
|
+
get graph() {
|
|
709
|
+
return this._graph;
|
|
710
|
+
}
|
|
711
|
+
get sheet() {
|
|
712
|
+
return this._sheet;
|
|
713
|
+
}
|
|
714
|
+
get readonly() {
|
|
715
|
+
return this._options.readonly;
|
|
716
|
+
}
|
|
717
|
+
get bounds() {
|
|
718
|
+
return {
|
|
719
|
+
rows: this._sheet.rows.length,
|
|
720
|
+
columns: this._sheet.columns.length
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Initialize sheet and engine.
|
|
725
|
+
*/
|
|
726
|
+
async _open() {
|
|
727
|
+
log("initialize", {
|
|
728
|
+
id: this.id
|
|
729
|
+
}, {
|
|
730
|
+
F: __dxlog_file2,
|
|
731
|
+
L: 105,
|
|
732
|
+
S: this,
|
|
733
|
+
C: (f, a) => f(...a)
|
|
734
|
+
});
|
|
735
|
+
initialize(this._sheet);
|
|
736
|
+
this.reset();
|
|
737
|
+
const unsubscribe = this._graph.update.on(() => this.update.emit());
|
|
738
|
+
this._ctx.onDispose(unsubscribe);
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Update engine.
|
|
742
|
+
* NOTE: This resets the undo history.
|
|
743
|
+
* @deprecated
|
|
744
|
+
*/
|
|
745
|
+
reset() {
|
|
746
|
+
this._node.hf.clearSheet(this._node.sheetId);
|
|
747
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
748
|
+
const { col, row } = addressFromIndex(this._sheet, key);
|
|
749
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
750
|
+
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
751
|
+
}
|
|
752
|
+
this._node.hf.setCellContents({
|
|
753
|
+
sheet: this._node.sheetId,
|
|
754
|
+
row,
|
|
755
|
+
col
|
|
756
|
+
}, value);
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Recalculate formulas.
|
|
761
|
+
* NOTE: This resets the undo history.
|
|
762
|
+
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
763
|
+
* @deprecated
|
|
764
|
+
*/
|
|
765
|
+
// TODO(burdon): Remove.
|
|
766
|
+
recalculate() {
|
|
767
|
+
this._node.hf.rebuildAndRecalculate();
|
|
768
|
+
}
|
|
769
|
+
insertRows(i, n = 1) {
|
|
770
|
+
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
771
|
+
this.reset();
|
|
772
|
+
}
|
|
773
|
+
insertColumns(i, n = 1) {
|
|
774
|
+
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
775
|
+
this.reset();
|
|
776
|
+
}
|
|
777
|
+
//
|
|
778
|
+
// Undoable actions.
|
|
779
|
+
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
780
|
+
//
|
|
781
|
+
/**
|
|
782
|
+
* Clear range of values.
|
|
783
|
+
*/
|
|
784
|
+
clear(range) {
|
|
785
|
+
const topLeft = getTopLeft(range);
|
|
786
|
+
const values = this._iterRange(range, () => null);
|
|
787
|
+
this._node.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
788
|
+
this._iterRange(range, (cell) => {
|
|
789
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
790
|
+
delete this._sheet.cells[idx];
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
cut(range) {
|
|
794
|
+
this._node.hf.cut(toModelRange(this._node.sheetId, range));
|
|
795
|
+
this._iterRange(range, (cell) => {
|
|
796
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
797
|
+
delete this._sheet.cells[idx];
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
copy(range) {
|
|
801
|
+
this._node.hf.copy(toModelRange(this._node.sheetId, range));
|
|
802
|
+
}
|
|
803
|
+
paste(cell) {
|
|
804
|
+
if (!this._node.hf.isClipboardEmpty()) {
|
|
805
|
+
const changes = this._node.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
806
|
+
for (const change of changes) {
|
|
807
|
+
if (change instanceof ExportedCellChange) {
|
|
808
|
+
const { address, newValue } = change;
|
|
809
|
+
const idx = addressToIndex(this._sheet, {
|
|
810
|
+
row: address.row,
|
|
811
|
+
col: address.col
|
|
812
|
+
});
|
|
813
|
+
this._sheet.cells[idx] = {
|
|
814
|
+
value: newValue
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
// TODO(burdon): Display undo/redo state.
|
|
821
|
+
undo() {
|
|
822
|
+
if (this._node.hf.isThereSomethingToUndo()) {
|
|
823
|
+
this._node.hf.undo();
|
|
824
|
+
this.update.emit();
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
redo() {
|
|
828
|
+
if (this._node.hf.isThereSomethingToRedo()) {
|
|
829
|
+
this._node.hf.redo();
|
|
830
|
+
this.update.emit();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Get value from sheet.
|
|
835
|
+
*/
|
|
836
|
+
getCellValue(cell) {
|
|
837
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
838
|
+
return this._sheet.cells[idx]?.value ?? null;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Get value as a string for editing.
|
|
842
|
+
*/
|
|
843
|
+
getCellText(cell) {
|
|
844
|
+
const value = this.getCellValue(cell);
|
|
845
|
+
if (value == null) {
|
|
846
|
+
return void 0;
|
|
514
847
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
return `${fullyQualifiedId(fn)}(${args})`;
|
|
848
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
849
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
518
850
|
} else {
|
|
519
|
-
return
|
|
851
|
+
return String(value);
|
|
520
852
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Get array of raw values from sheet.
|
|
856
|
+
*/
|
|
857
|
+
getCellValues(range) {
|
|
858
|
+
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Gets the regular or computed value from the engine.
|
|
862
|
+
*/
|
|
863
|
+
getValue(cell) {
|
|
864
|
+
const value = this._node.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
865
|
+
if (value instanceof DetailedCellError) {
|
|
866
|
+
return value.toString();
|
|
867
|
+
}
|
|
868
|
+
return value;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Get value type.
|
|
872
|
+
*/
|
|
873
|
+
getValueType(cell) {
|
|
874
|
+
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
875
|
+
const type = this._node.hf.getCellValueDetailedType(addr);
|
|
876
|
+
return typeMap[type];
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Sets the value, updating the sheet and engine.
|
|
880
|
+
*/
|
|
881
|
+
setValue(cell, value) {
|
|
882
|
+
if (this._options.readonly) {
|
|
883
|
+
throw new ReadonlyException();
|
|
884
|
+
}
|
|
885
|
+
let refresh = false;
|
|
886
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
887
|
+
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
888
|
+
refresh = true;
|
|
889
|
+
}
|
|
890
|
+
if (cell.col >= this._sheet.columns.length) {
|
|
891
|
+
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
892
|
+
refresh = true;
|
|
528
893
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
894
|
+
if (refresh) {
|
|
895
|
+
this.reset();
|
|
896
|
+
}
|
|
897
|
+
this._node.hf.setCellContents({
|
|
898
|
+
sheet: this._node.sheetId,
|
|
899
|
+
row: cell.row,
|
|
900
|
+
col: cell.col
|
|
901
|
+
}, [
|
|
902
|
+
[
|
|
903
|
+
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
904
|
+
]
|
|
905
|
+
]);
|
|
906
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
907
|
+
if (value === void 0 || value === null) {
|
|
908
|
+
delete this._sheet.cells[idx];
|
|
532
909
|
} else {
|
|
533
|
-
|
|
910
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
911
|
+
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
912
|
+
}
|
|
913
|
+
this._sheet.cells[idx] = {
|
|
914
|
+
value
|
|
915
|
+
};
|
|
534
916
|
}
|
|
535
|
-
}
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Sets values from a simple map.
|
|
920
|
+
*/
|
|
921
|
+
setValues(values) {
|
|
922
|
+
Object.entries(values).forEach(([key, { value }]) => {
|
|
923
|
+
this.setValue(addressFromA1Notation(key), value);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Iterate range.
|
|
928
|
+
*/
|
|
929
|
+
_iterRange(range, cb) {
|
|
930
|
+
const to = range.to ?? range.from;
|
|
931
|
+
const rowRange = [
|
|
932
|
+
Math.min(range.from.row, to.row),
|
|
933
|
+
Math.max(range.from.row, to.row)
|
|
934
|
+
];
|
|
935
|
+
const columnRange = [
|
|
936
|
+
Math.min(range.from.col, to.col),
|
|
937
|
+
Math.max(range.from.col, to.col)
|
|
938
|
+
];
|
|
939
|
+
const rows = [];
|
|
940
|
+
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
941
|
+
const rowCells = [];
|
|
942
|
+
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
943
|
+
const value = cb({
|
|
944
|
+
row,
|
|
945
|
+
col: column
|
|
946
|
+
});
|
|
947
|
+
if (value !== void 0) {
|
|
948
|
+
rowCells.push(value);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
rows.push(rowCells);
|
|
952
|
+
}
|
|
953
|
+
return rows;
|
|
954
|
+
}
|
|
955
|
+
// TODO(burdon): Delete index.
|
|
956
|
+
_deleteIndices(indices, i, n) {
|
|
957
|
+
throw new Error("Not implemented");
|
|
958
|
+
}
|
|
959
|
+
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
960
|
+
_moveIndices(indices, i, j, n) {
|
|
961
|
+
throw new Error("Not implemented");
|
|
962
|
+
}
|
|
963
|
+
//
|
|
964
|
+
// Indices.
|
|
965
|
+
//
|
|
966
|
+
/**
|
|
967
|
+
* Map from A1 notation to indices.
|
|
968
|
+
*/
|
|
969
|
+
mapFormulaRefsToIndices(formula) {
|
|
970
|
+
invariant2(formula.charAt(0) === "=", void 0, {
|
|
971
|
+
F: __dxlog_file2,
|
|
972
|
+
L: 358,
|
|
973
|
+
S: this,
|
|
974
|
+
A: [
|
|
975
|
+
"formula.charAt(0) === '='",
|
|
976
|
+
""
|
|
977
|
+
]
|
|
978
|
+
});
|
|
979
|
+
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
980
|
+
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Map from indices to A1 notation.
|
|
985
|
+
*/
|
|
986
|
+
mapFormulaIndicesToRefs(formula) {
|
|
987
|
+
invariant2(formula.charAt(0) === "=", void 0, {
|
|
988
|
+
F: __dxlog_file2,
|
|
989
|
+
L: 368,
|
|
990
|
+
S: this,
|
|
991
|
+
A: [
|
|
992
|
+
"formula.charAt(0) === '='",
|
|
993
|
+
""
|
|
994
|
+
]
|
|
995
|
+
});
|
|
996
|
+
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
997
|
+
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
//
|
|
1001
|
+
// Values
|
|
1002
|
+
//
|
|
1003
|
+
/**
|
|
1004
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1005
|
+
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1006
|
+
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1007
|
+
*/
|
|
1008
|
+
toLocalDate(num) {
|
|
1009
|
+
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1010
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1011
|
+
}
|
|
1012
|
+
toDateTime(num) {
|
|
1013
|
+
return this._node.hf.numberToDateTime(num);
|
|
1014
|
+
}
|
|
1015
|
+
toDate(num) {
|
|
1016
|
+
return this._node.hf.numberToDate(num);
|
|
1017
|
+
}
|
|
1018
|
+
toTime(num) {
|
|
1019
|
+
return this._node.hf.numberToTime(num);
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
1024
|
+
var useFormattingModel = (model) => {
|
|
1025
|
+
return useMemo(() => model && new FormattingModel(model), [
|
|
1026
|
+
model
|
|
1027
|
+
]);
|
|
536
1028
|
};
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
const
|
|
543
|
-
const [[model, formatting] = [], setModels] = useState3(void 0);
|
|
1029
|
+
|
|
1030
|
+
// packages/plugins/plugin-sheet/src/hooks/useSheetModel.ts
|
|
1031
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1032
|
+
var useSheetModel = (space, sheet, { readonly } = {}) => {
|
|
1033
|
+
const graph = useComputeGraph(space);
|
|
1034
|
+
const [model, setModel] = useState3();
|
|
544
1035
|
useEffect2(() => {
|
|
1036
|
+
if (!space || !graph || !sheet) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
545
1039
|
let model2;
|
|
546
|
-
let formatting2;
|
|
547
1040
|
const t = setTimeout(async () => {
|
|
548
|
-
model2 = new SheetModel(graph, sheet,
|
|
549
|
-
readonly
|
|
550
|
-
mapFormulaBindingToId,
|
|
551
|
-
mapFormulaBindingFromId
|
|
1041
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1042
|
+
readonly
|
|
552
1043
|
});
|
|
553
|
-
await model2.
|
|
554
|
-
|
|
555
|
-
setModels([
|
|
556
|
-
model2,
|
|
557
|
-
formatting2
|
|
558
|
-
]);
|
|
1044
|
+
await model2.open();
|
|
1045
|
+
setModel(model2);
|
|
559
1046
|
});
|
|
560
1047
|
return () => {
|
|
561
1048
|
clearTimeout(t);
|
|
562
|
-
void model2?.
|
|
1049
|
+
void model2?.close();
|
|
563
1050
|
};
|
|
564
1051
|
}, [
|
|
1052
|
+
space,
|
|
1053
|
+
sheet,
|
|
565
1054
|
graph,
|
|
566
1055
|
readonly
|
|
567
1056
|
]);
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
1057
|
+
return model;
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
1061
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1062
|
+
var SheetContext = /* @__PURE__ */ createContext2(null);
|
|
1063
|
+
var useSheetContext = () => {
|
|
1064
|
+
const context = useContext2(SheetContext);
|
|
1065
|
+
invariant3(context, void 0, {
|
|
1066
|
+
F: __dxlog_file3,
|
|
1067
|
+
L: 43,
|
|
1068
|
+
S: void 0,
|
|
1069
|
+
A: [
|
|
1070
|
+
"context",
|
|
1071
|
+
""
|
|
1072
|
+
]
|
|
1073
|
+
});
|
|
1074
|
+
return context;
|
|
1075
|
+
};
|
|
1076
|
+
var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
|
|
1077
|
+
const model = useSheetModel(space, sheet, {
|
|
1078
|
+
readonly
|
|
1079
|
+
});
|
|
1080
|
+
const formatting = useFormattingModel(model);
|
|
1081
|
+
const [cursor, setCursor] = useState4();
|
|
1082
|
+
const [range, setRange] = useState4();
|
|
1083
|
+
const [editing, setEditing] = useState4(false);
|
|
1084
|
+
const decorations = useMemo2(() => createDecorations(), []);
|
|
1085
|
+
return !model || !formatting ? null : /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
|
|
572
1086
|
value: {
|
|
573
1087
|
model,
|
|
574
1088
|
formatting,
|
|
@@ -587,23 +1101,22 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
587
1101
|
|
|
588
1102
|
// packages/plugins/plugin-sheet/src/components/Sheet/threads.tsx
|
|
589
1103
|
import { effect } from "@preact/signals-core";
|
|
590
|
-
import
|
|
1104
|
+
import React4, { useCallback, useEffect as useEffect3, useMemo as useMemo3 } from "react";
|
|
591
1105
|
import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
|
|
592
1106
|
import { debounce } from "@dxos/async";
|
|
593
|
-
import { fullyQualifiedId
|
|
1107
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
594
1108
|
import { Icon, useTranslation } from "@dxos/react-ui";
|
|
595
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
596
1109
|
var CommentIndicator = () => {
|
|
597
|
-
return /* @__PURE__ */
|
|
1110
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
598
1111
|
role: "none",
|
|
599
1112
|
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
600
1113
|
});
|
|
601
1114
|
};
|
|
602
1115
|
var ThreadedCellWrapper = ({ children }) => {
|
|
603
1116
|
const dispatch = useIntentDispatcher();
|
|
604
|
-
const [isHovered, setIsHovered] =
|
|
1117
|
+
const [isHovered, setIsHovered] = React4.useState(false);
|
|
605
1118
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
606
|
-
const handleClick =
|
|
1119
|
+
const handleClick = React4.useCallback((_event) => {
|
|
607
1120
|
void dispatch({
|
|
608
1121
|
action: LayoutAction.SET_LAYOUT,
|
|
609
1122
|
data: {
|
|
@@ -614,22 +1127,22 @@ var ThreadedCellWrapper = ({ children }) => {
|
|
|
614
1127
|
}, [
|
|
615
1128
|
dispatch
|
|
616
1129
|
]);
|
|
617
|
-
return /* @__PURE__ */
|
|
1130
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
618
1131
|
role: "none",
|
|
619
|
-
className:
|
|
1132
|
+
className: "relative h-full is-full",
|
|
620
1133
|
onMouseEnter: () => {
|
|
621
1134
|
setIsHovered(true);
|
|
622
1135
|
},
|
|
623
1136
|
onMouseLeave: () => {
|
|
624
1137
|
setIsHovered(false);
|
|
625
1138
|
}
|
|
626
|
-
}, /* @__PURE__ */
|
|
1139
|
+
}, /* @__PURE__ */ React4.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React4.createElement("div", {
|
|
627
1140
|
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
628
|
-
}, /* @__PURE__ */
|
|
1141
|
+
}, /* @__PURE__ */ React4.createElement("button", {
|
|
629
1142
|
className: "ch-button text-xs min-bs-0 p-1",
|
|
630
1143
|
onClick: handleClick,
|
|
631
1144
|
"aria-label": t("open comment for sheet cell")
|
|
632
|
-
}, /* @__PURE__ */
|
|
1145
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
633
1146
|
icon: "ph--chat--regular",
|
|
634
1147
|
"aria-hidden": true
|
|
635
1148
|
}))), children);
|
|
@@ -638,7 +1151,7 @@ var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
|
638
1151
|
return {
|
|
639
1152
|
type: "comment",
|
|
640
1153
|
cellIndex,
|
|
641
|
-
decorate: (props) => /* @__PURE__ */
|
|
1154
|
+
decorate: (props) => /* @__PURE__ */ React4.createElement(ThreadedCellWrapper, props)
|
|
642
1155
|
};
|
|
643
1156
|
};
|
|
644
1157
|
var useUpdateCursorOnThreadSelection = () => {
|
|
@@ -646,7 +1159,7 @@ var useUpdateCursorOnThreadSelection = () => {
|
|
|
646
1159
|
const handleScrollIntoView = useCallback(({ action, data }) => {
|
|
647
1160
|
switch (action) {
|
|
648
1161
|
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
649
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !==
|
|
1162
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId(model.sheet)) {
|
|
650
1163
|
return;
|
|
651
1164
|
}
|
|
652
1165
|
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
@@ -662,10 +1175,10 @@ var useUpdateCursorOnThreadSelection = () => {
|
|
|
662
1175
|
var useSelectThreadOnCursorChange = () => {
|
|
663
1176
|
const { cursor, model } = useSheetContext();
|
|
664
1177
|
const dispatch = useIntentDispatcher();
|
|
665
|
-
const activeThreads =
|
|
1178
|
+
const activeThreads = useMemo3(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
666
1179
|
JSON.stringify(model.sheet.threads)
|
|
667
1180
|
]);
|
|
668
|
-
const activeThreadAddresses =
|
|
1181
|
+
const activeThreadAddresses = useMemo3(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
669
1182
|
activeThreads,
|
|
670
1183
|
model.sheet
|
|
671
1184
|
]);
|
|
@@ -681,7 +1194,7 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
681
1194
|
{
|
|
682
1195
|
action: "dxos.org/plugin/thread/action/select",
|
|
683
1196
|
data: {
|
|
684
|
-
current:
|
|
1197
|
+
current: fullyQualifiedId(closestThread)
|
|
685
1198
|
}
|
|
686
1199
|
}
|
|
687
1200
|
]);
|
|
@@ -693,7 +1206,7 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
693
1206
|
activeThreadAddresses,
|
|
694
1207
|
model.sheet
|
|
695
1208
|
]);
|
|
696
|
-
const debounced =
|
|
1209
|
+
const debounced = useMemo3(() => {
|
|
697
1210
|
return debounce((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
698
1211
|
}, [
|
|
699
1212
|
selectClosestThread
|
|
@@ -710,10 +1223,10 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
710
1223
|
};
|
|
711
1224
|
var useThreadDecorations = () => {
|
|
712
1225
|
const { decorations, model } = useSheetContext();
|
|
713
|
-
const sheet =
|
|
1226
|
+
const sheet = useMemo3(() => model.sheet, [
|
|
714
1227
|
model.sheet
|
|
715
1228
|
]);
|
|
716
|
-
const sheetId =
|
|
1229
|
+
const sheetId = useMemo3(() => fullyQualifiedId(sheet), [
|
|
717
1230
|
sheet
|
|
718
1231
|
]);
|
|
719
1232
|
useEffect3(() => {
|
|
@@ -786,7 +1299,7 @@ var scrollIntoView = (scrollContainer, el) => {
|
|
|
786
1299
|
|
|
787
1300
|
// packages/plugins/plugin-sheet/src/components/CellEditor/CellEditor.tsx
|
|
788
1301
|
import { EditorView, keymap } from "@codemirror/view";
|
|
789
|
-
import
|
|
1302
|
+
import React5 from "react";
|
|
790
1303
|
import { useThemeContext } from "@dxos/react-ui";
|
|
791
1304
|
import { createBasicExtensions, createThemeExtensions, preventNewline, useTextEditor } from "@dxos/react-ui-editor";
|
|
792
1305
|
var editorKeys = ({ onNav, onClose }) => {
|
|
@@ -834,20 +1347,60 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
834
1347
|
{
|
|
835
1348
|
key: "Enter",
|
|
836
1349
|
run: (editor) => {
|
|
837
|
-
onClose(editor.state.doc.toString()
|
|
1350
|
+
onClose(editor.state.doc.toString(), {
|
|
1351
|
+
key: "Enter"
|
|
1352
|
+
});
|
|
1353
|
+
return true;
|
|
1354
|
+
},
|
|
1355
|
+
shift: (editor) => {
|
|
1356
|
+
onClose(editor.state.doc.toString(), {
|
|
1357
|
+
key: "Enter",
|
|
1358
|
+
shift: true
|
|
1359
|
+
});
|
|
1360
|
+
return true;
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
{
|
|
1364
|
+
key: "Tab",
|
|
1365
|
+
run: (editor) => {
|
|
1366
|
+
onClose(editor.state.doc.toString(), {
|
|
1367
|
+
key: "Tab"
|
|
1368
|
+
});
|
|
1369
|
+
return true;
|
|
1370
|
+
},
|
|
1371
|
+
shift: (editor) => {
|
|
1372
|
+
onClose(editor.state.doc.toString(), {
|
|
1373
|
+
key: "Tab",
|
|
1374
|
+
shift: true
|
|
1375
|
+
});
|
|
838
1376
|
return true;
|
|
839
1377
|
}
|
|
840
1378
|
},
|
|
841
1379
|
{
|
|
842
1380
|
key: "Escape",
|
|
843
1381
|
run: () => {
|
|
844
|
-
onClose(void 0
|
|
1382
|
+
onClose(void 0, {
|
|
1383
|
+
key: "Escape"
|
|
1384
|
+
});
|
|
845
1385
|
return true;
|
|
846
1386
|
}
|
|
847
1387
|
}
|
|
848
1388
|
]);
|
|
849
1389
|
};
|
|
850
|
-
var
|
|
1390
|
+
var editorVariants = {
|
|
1391
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
1392
|
+
legacy: {
|
|
1393
|
+
root: "flex w-full",
|
|
1394
|
+
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1395
|
+
content: "!px-2 !py-1"
|
|
1396
|
+
},
|
|
1397
|
+
grid: {
|
|
1398
|
+
root: "absolute z-[1]",
|
|
1399
|
+
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1400
|
+
content: "!border !border-transparent !p-0.5"
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
851
1404
|
const { themeMode } = useThemeContext();
|
|
852
1405
|
const { parentRef } = useTextEditor(() => {
|
|
853
1406
|
return {
|
|
@@ -874,21 +1427,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
874
1427
|
themeMode,
|
|
875
1428
|
slots: {
|
|
876
1429
|
editor: {
|
|
877
|
-
className:
|
|
1430
|
+
className: editorVariants[variant].editor
|
|
878
1431
|
},
|
|
879
1432
|
content: {
|
|
880
|
-
className:
|
|
1433
|
+
className: editorVariants[variant].content
|
|
881
1434
|
}
|
|
882
1435
|
}
|
|
883
1436
|
})
|
|
884
1437
|
]
|
|
885
1438
|
};
|
|
886
1439
|
}, [
|
|
887
|
-
extension
|
|
1440
|
+
extension,
|
|
1441
|
+
autoFocus,
|
|
1442
|
+
value,
|
|
1443
|
+
variant,
|
|
1444
|
+
onBlur
|
|
888
1445
|
]);
|
|
889
|
-
return /* @__PURE__ */
|
|
1446
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
890
1447
|
ref: parentRef,
|
|
891
|
-
className:
|
|
1448
|
+
className: editorVariants[variant].root,
|
|
1449
|
+
style: box,
|
|
1450
|
+
...gridId && {
|
|
1451
|
+
"data-grid": gridId
|
|
1452
|
+
}
|
|
892
1453
|
});
|
|
893
1454
|
};
|
|
894
1455
|
|
|
@@ -899,7 +1460,7 @@ import { Facet } from "@codemirror/state";
|
|
|
899
1460
|
import { ViewPlugin, keymap as keymap2 } from "@codemirror/view";
|
|
900
1461
|
import { tags } from "@lezer/highlight";
|
|
901
1462
|
import { spreadsheet } from "codemirror-lang-spreadsheet";
|
|
902
|
-
import { mx
|
|
1463
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
903
1464
|
var highlightStyles = HighlightStyle.define([
|
|
904
1465
|
// Function.
|
|
905
1466
|
{
|
|
@@ -1010,13 +1571,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1010
1571
|
// NOTE: Useful for debugging.
|
|
1011
1572
|
closeOnBlur: false,
|
|
1012
1573
|
icons: false,
|
|
1013
|
-
tooltipClass: () =>
|
|
1014
|
-
// TODO(burdon): Factor out fragments.
|
|
1015
|
-
// TODO(burdon): Size to make width same as column.
|
|
1016
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
1017
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
1018
|
-
"border-separator"
|
|
1019
|
-
)
|
|
1574
|
+
tooltipClass: () => mx("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
|
|
1020
1575
|
}),
|
|
1021
1576
|
keymap2.of([
|
|
1022
1577
|
{
|
|
@@ -1105,7 +1660,7 @@ var visitTree = (node, callback) => {
|
|
|
1105
1660
|
};
|
|
1106
1661
|
|
|
1107
1662
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
1108
|
-
var
|
|
1663
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1109
1664
|
var fragments = {
|
|
1110
1665
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1111
1666
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1113,16 +1668,16 @@ var fragments = {
|
|
|
1113
1668
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1114
1669
|
};
|
|
1115
1670
|
var SheetRoot = ({ children, ...props }) => {
|
|
1116
|
-
return /* @__PURE__ */
|
|
1671
|
+
return /* @__PURE__ */ React6.createElement(SheetContextProvider, props, children);
|
|
1117
1672
|
};
|
|
1118
|
-
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows,
|
|
1673
|
+
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
1119
1674
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1120
1675
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1121
1676
|
useThreads();
|
|
1122
|
-
const [rows, setRows] =
|
|
1677
|
+
const [rows, setRows] = useState5([
|
|
1123
1678
|
...model.sheet.rows
|
|
1124
1679
|
]);
|
|
1125
|
-
const [columns, setColumns] =
|
|
1680
|
+
const [columns, setColumns] = useState5([
|
|
1126
1681
|
...model.sheet.columns
|
|
1127
1682
|
]);
|
|
1128
1683
|
useEffect4(() => {
|
|
@@ -1178,8 +1733,8 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
|
|
|
1178
1733
|
...model.sheet.columns
|
|
1179
1734
|
]);
|
|
1180
1735
|
};
|
|
1181
|
-
const [rowSizes, setRowSizes] =
|
|
1182
|
-
const [columnSizes, setColumnSizes] =
|
|
1736
|
+
const [rowSizes, setRowSizes] = useState5();
|
|
1737
|
+
const [columnSizes, setColumnSizes] = useState5();
|
|
1183
1738
|
useEffect4(() => {
|
|
1184
1739
|
const rowAccessor = createDocAccessor(model.sheet, [
|
|
1185
1740
|
"rowMeta"
|
|
@@ -1229,48 +1784,48 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
|
|
|
1229
1784
|
}));
|
|
1230
1785
|
}
|
|
1231
1786
|
};
|
|
1232
|
-
return /* @__PURE__ */
|
|
1787
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1233
1788
|
role: "none",
|
|
1234
|
-
className:
|
|
1235
|
-
}, /* @__PURE__ */
|
|
1789
|
+
className: mx2("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1790
|
+
}, /* @__PURE__ */ React6.createElement(GridCorner, {
|
|
1236
1791
|
onClick: () => {
|
|
1237
1792
|
setCursor(void 0);
|
|
1238
1793
|
setRange(void 0);
|
|
1239
1794
|
setEditing(false);
|
|
1240
1795
|
}
|
|
1241
|
-
}), /* @__PURE__ */
|
|
1796
|
+
}), /* @__PURE__ */ React6.createElement(SheetColumns, {
|
|
1242
1797
|
ref: columnsRef,
|
|
1243
1798
|
columns,
|
|
1244
1799
|
sizes: columnSizes,
|
|
1245
|
-
selected: cursor?.
|
|
1246
|
-
onSelect: (
|
|
1800
|
+
selected: cursor?.col,
|
|
1801
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1247
1802
|
row: -1,
|
|
1248
|
-
|
|
1803
|
+
col
|
|
1249
1804
|
}),
|
|
1250
1805
|
onResize: handleResizeColumn,
|
|
1251
1806
|
onMove: handleMoveColumns
|
|
1252
|
-
}), /* @__PURE__ */
|
|
1807
|
+
}), /* @__PURE__ */ React6.createElement(SheetRows, {
|
|
1253
1808
|
ref: rowsRef,
|
|
1254
1809
|
rows,
|
|
1255
1810
|
sizes: rowSizes,
|
|
1256
1811
|
selected: cursor?.row,
|
|
1257
1812
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1258
1813
|
row,
|
|
1259
|
-
|
|
1814
|
+
col: -1
|
|
1260
1815
|
}),
|
|
1261
1816
|
onResize: handleResizeRow,
|
|
1262
1817
|
onMove: handleMoveRows
|
|
1263
|
-
}), /* @__PURE__ */
|
|
1818
|
+
}), /* @__PURE__ */ React6.createElement(SheetGrid, {
|
|
1264
1819
|
ref: contentRef,
|
|
1265
1820
|
size: {
|
|
1266
1821
|
numRows: numRows ?? rows.length,
|
|
1267
|
-
|
|
1822
|
+
numCols: numCols ?? columns.length
|
|
1268
1823
|
},
|
|
1269
1824
|
rows,
|
|
1270
1825
|
columns,
|
|
1271
1826
|
rowSizes,
|
|
1272
1827
|
columnSizes
|
|
1273
|
-
}), /* @__PURE__ */
|
|
1828
|
+
}), /* @__PURE__ */ React6.createElement(GridCorner, null), /* @__PURE__ */ React6.createElement(SheetStatusBar, null));
|
|
1274
1829
|
});
|
|
1275
1830
|
var useScrollHandlers = () => {
|
|
1276
1831
|
const rowsRef = useRef(null);
|
|
@@ -1313,13 +1868,13 @@ var useScrollHandlers = () => {
|
|
|
1313
1868
|
};
|
|
1314
1869
|
};
|
|
1315
1870
|
var GridCorner = (props) => {
|
|
1316
|
-
return /* @__PURE__ */
|
|
1871
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1317
1872
|
className: fragments.axis,
|
|
1318
1873
|
...props
|
|
1319
1874
|
});
|
|
1320
1875
|
};
|
|
1321
1876
|
var MovingOverlay = ({ label }) => {
|
|
1322
|
-
return /* @__PURE__ */
|
|
1877
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1323
1878
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1324
1879
|
}, label);
|
|
1325
1880
|
};
|
|
@@ -1339,7 +1894,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1339
1894
|
});
|
|
1340
1895
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
1341
1896
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
1342
|
-
const [active, setActive] =
|
|
1897
|
+
const [active, setActive] = useState5(null);
|
|
1343
1898
|
const handleDragStart = ({ active: active2 }) => {
|
|
1344
1899
|
setActive(active2);
|
|
1345
1900
|
};
|
|
@@ -1363,18 +1918,18 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1363
1918
|
}
|
|
1364
1919
|
return transform;
|
|
1365
1920
|
};
|
|
1366
|
-
return /* @__PURE__ */
|
|
1921
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1367
1922
|
className: "relative flex grow overflow-hidden"
|
|
1368
|
-
}, /* @__PURE__ */
|
|
1369
|
-
className:
|
|
1923
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1924
|
+
className: mx2("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1370
1925
|
style: {
|
|
1371
1926
|
width: axisWidth
|
|
1372
1927
|
}
|
|
1373
|
-
}), /* @__PURE__ */
|
|
1928
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1374
1929
|
ref: forwardRef2,
|
|
1375
1930
|
role: "rowheader",
|
|
1376
1931
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1377
|
-
}, /* @__PURE__ */
|
|
1932
|
+
}, /* @__PURE__ */ React6.createElement(DndContext, {
|
|
1378
1933
|
sensors,
|
|
1379
1934
|
modifiers: [
|
|
1380
1935
|
restrictToVerticalAxis,
|
|
@@ -1382,12 +1937,12 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1382
1937
|
],
|
|
1383
1938
|
onDragStart: handleDragStart,
|
|
1384
1939
|
onDragEnd: handleDragEnd
|
|
1385
|
-
}, /* @__PURE__ */
|
|
1940
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1386
1941
|
className: "flex flex-col",
|
|
1387
1942
|
style: {
|
|
1388
1943
|
width: axisWidth
|
|
1389
1944
|
}
|
|
1390
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1945
|
+
}, rows.map((idx, index) => /* @__PURE__ */ React6.createElement(GridRowCell, {
|
|
1391
1946
|
key: idx,
|
|
1392
1947
|
idx,
|
|
1393
1948
|
index,
|
|
@@ -1397,7 +1952,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1397
1952
|
selected: selected === index,
|
|
1398
1953
|
onResize,
|
|
1399
1954
|
onSelect
|
|
1400
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
1955
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
|
|
1401
1956
|
label: String(active.data.current.index + 1)
|
|
1402
1957
|
})), document.body))));
|
|
1403
1958
|
});
|
|
@@ -1415,8 +1970,8 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1415
1970
|
}
|
|
1416
1971
|
});
|
|
1417
1972
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
1418
|
-
const [initialSize, setInitialSize] =
|
|
1419
|
-
const [resizing, setResizing] =
|
|
1973
|
+
const [initialSize, setInitialSize] = useState5(size);
|
|
1974
|
+
const [resizing, setResizing] = useState5(false);
|
|
1420
1975
|
const scrollHandler = useRef();
|
|
1421
1976
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1422
1977
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
@@ -1438,7 +1993,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1438
1993
|
onResize?.(idx, initialSize + height, true);
|
|
1439
1994
|
setResizing(false);
|
|
1440
1995
|
};
|
|
1441
|
-
return /* @__PURE__ */
|
|
1996
|
+
return /* @__PURE__ */ React6.createElement(Resizable, {
|
|
1442
1997
|
enable: {
|
|
1443
1998
|
bottom: resize
|
|
1444
1999
|
},
|
|
@@ -1450,17 +2005,17 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1450
2005
|
onResizeStart: handleResizeStart,
|
|
1451
2006
|
onResize: handleResize,
|
|
1452
2007
|
onResizeStop: handleResizeStop
|
|
1453
|
-
}, /* @__PURE__ */
|
|
2008
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1454
2009
|
ref: setNodeRef,
|
|
1455
2010
|
...attributes,
|
|
1456
2011
|
...listeners,
|
|
1457
|
-
className:
|
|
2012
|
+
className: mx2("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1458
2013
|
onClick: () => onSelect?.(index)
|
|
1459
|
-
}, /* @__PURE__ */
|
|
2014
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
1460
2015
|
className: "flex w-full justify-center"
|
|
1461
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2016
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
|
|
1462
2017
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1463
|
-
}), resizing && /* @__PURE__ */
|
|
2018
|
+
}), resizing && /* @__PURE__ */ React6.createElement("div", {
|
|
1464
2019
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1465
2020
|
})));
|
|
1466
2021
|
};
|
|
@@ -1473,7 +2028,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1473
2028
|
});
|
|
1474
2029
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
1475
2030
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
1476
|
-
const [active, setActive] =
|
|
2031
|
+
const [active, setActive] = useState5(null);
|
|
1477
2032
|
const handleDragStart = ({ active: active2 }) => {
|
|
1478
2033
|
setActive(active2);
|
|
1479
2034
|
};
|
|
@@ -1497,18 +2052,18 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1497
2052
|
}
|
|
1498
2053
|
return transform;
|
|
1499
2054
|
};
|
|
1500
|
-
return /* @__PURE__ */
|
|
2055
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1501
2056
|
className: "relative flex grow overflow-hidden"
|
|
1502
|
-
}, /* @__PURE__ */
|
|
1503
|
-
className:
|
|
2057
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2058
|
+
className: mx2("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
1504
2059
|
style: {
|
|
1505
2060
|
height: axisHeight
|
|
1506
2061
|
}
|
|
1507
|
-
}), /* @__PURE__ */
|
|
2062
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1508
2063
|
ref: forwardRef2,
|
|
1509
2064
|
role: "columnheader",
|
|
1510
2065
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1511
|
-
}, /* @__PURE__ */
|
|
2066
|
+
}, /* @__PURE__ */ React6.createElement(DndContext, {
|
|
1512
2067
|
autoScroll: {
|
|
1513
2068
|
enabled: true
|
|
1514
2069
|
},
|
|
@@ -1519,12 +2074,12 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1519
2074
|
],
|
|
1520
2075
|
onDragStart: handleDragStart,
|
|
1521
2076
|
onDragEnd: handleDragEnd
|
|
1522
|
-
}, /* @__PURE__ */
|
|
2077
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1523
2078
|
className: "flex h-full",
|
|
1524
2079
|
style: {
|
|
1525
2080
|
height: axisHeight
|
|
1526
2081
|
}
|
|
1527
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2082
|
+
}, columns.map((idx, index) => /* @__PURE__ */ React6.createElement(GridColumnCell, {
|
|
1528
2083
|
key: idx,
|
|
1529
2084
|
idx,
|
|
1530
2085
|
index,
|
|
@@ -1534,7 +2089,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1534
2089
|
selected: selected === index,
|
|
1535
2090
|
onResize,
|
|
1536
2091
|
onSelect
|
|
1537
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2092
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
|
|
1538
2093
|
label: columnLetter(active.data.current.index)
|
|
1539
2094
|
})), document.body))));
|
|
1540
2095
|
});
|
|
@@ -1552,8 +2107,8 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1552
2107
|
}
|
|
1553
2108
|
});
|
|
1554
2109
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
1555
|
-
const [initialSize, setInitialSize] =
|
|
1556
|
-
const [resizing, setResizing] =
|
|
2110
|
+
const [initialSize, setInitialSize] = useState5(size);
|
|
2111
|
+
const [resizing, setResizing] = useState5(false);
|
|
1557
2112
|
const scrollHandler = useRef();
|
|
1558
2113
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1559
2114
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
@@ -1575,7 +2130,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1575
2130
|
onResize?.(idx, initialSize + width, true);
|
|
1576
2131
|
setResizing(false);
|
|
1577
2132
|
};
|
|
1578
|
-
return /* @__PURE__ */
|
|
2133
|
+
return /* @__PURE__ */ React6.createElement(Resizable, {
|
|
1579
2134
|
enable: {
|
|
1580
2135
|
right: resize
|
|
1581
2136
|
},
|
|
@@ -1587,17 +2142,17 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1587
2142
|
onResizeStart: handleResizeStart,
|
|
1588
2143
|
onResize: handleResize,
|
|
1589
2144
|
onResizeStop: handleResizeStop
|
|
1590
|
-
}, /* @__PURE__ */
|
|
2145
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1591
2146
|
ref: setNodeRef,
|
|
1592
2147
|
...attributes,
|
|
1593
2148
|
...listeners,
|
|
1594
|
-
className:
|
|
2149
|
+
className: mx2("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1595
2150
|
onClick: () => onSelect?.(index)
|
|
1596
|
-
}, /* @__PURE__ */
|
|
2151
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
1597
2152
|
className: "flex w-full justify-center"
|
|
1598
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2153
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
|
|
1599
2154
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1600
|
-
}), resizing && /* @__PURE__ */
|
|
2155
|
+
}), resizing && /* @__PURE__ */ React6.createElement("div", {
|
|
1601
2156
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1602
2157
|
})));
|
|
1603
2158
|
};
|
|
@@ -1610,13 +2165,13 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1610
2165
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1611
2166
|
const initialText = useRef();
|
|
1612
2167
|
const quickEdit = useRef(false);
|
|
1613
|
-
const [, forceUpdate] =
|
|
2168
|
+
const [, forceUpdate] = useState5({});
|
|
1614
2169
|
useEffect4(() => {
|
|
1615
2170
|
const unsubscribe = model.update.on(() => {
|
|
1616
|
-
|
|
2171
|
+
log2("updated", {
|
|
1617
2172
|
id: model.id
|
|
1618
2173
|
}, {
|
|
1619
|
-
F:
|
|
2174
|
+
F: __dxlog_file4,
|
|
1620
2175
|
L: 737,
|
|
1621
2176
|
S: void 0,
|
|
1622
2177
|
C: (f, a) => f(...a)
|
|
@@ -1734,19 +2289,19 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1734
2289
|
rowSizes,
|
|
1735
2290
|
columnSizes
|
|
1736
2291
|
});
|
|
1737
|
-
const id =
|
|
2292
|
+
const id = fullyQualifiedId2(model.sheet);
|
|
1738
2293
|
const attendableAttrs = createAttendableAttributes(id);
|
|
1739
2294
|
const hasAttention = useHasAttention(id);
|
|
1740
|
-
return /* @__PURE__ */
|
|
2295
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1741
2296
|
ref: containerRef,
|
|
1742
2297
|
role: "grid",
|
|
1743
2298
|
className: "relative flex grow overflow-hidden"
|
|
1744
|
-
}, /* @__PURE__ */
|
|
1745
|
-
className:
|
|
1746
|
-
}), /* @__PURE__ */
|
|
2299
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2300
|
+
className: mx2("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
2301
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1747
2302
|
ref: scrollerRef,
|
|
1748
|
-
className:
|
|
1749
|
-
}, /* @__PURE__ */
|
|
2303
|
+
className: mx2("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2304
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1750
2305
|
className: "relative select-none",
|
|
1751
2306
|
style: {
|
|
1752
2307
|
width,
|
|
@@ -1754,10 +2309,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1754
2309
|
},
|
|
1755
2310
|
onClick: () => inputRef.current?.focus(),
|
|
1756
2311
|
...handlers
|
|
1757
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2312
|
+
}, scrollerRef.current && /* @__PURE__ */ React6.createElement(SelectionOverlay, {
|
|
1758
2313
|
root: scrollerRef.current
|
|
1759
2314
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1760
|
-
return columnRange.map(({
|
|
2315
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1761
2316
|
const style = {
|
|
1762
2317
|
position: "absolute",
|
|
1763
2318
|
top,
|
|
@@ -1767,7 +2322,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1767
2322
|
};
|
|
1768
2323
|
const cell = {
|
|
1769
2324
|
row,
|
|
1770
|
-
|
|
2325
|
+
col
|
|
1771
2326
|
};
|
|
1772
2327
|
const id2 = addressToA1Notation(cell);
|
|
1773
2328
|
const idx = addressToIndex(model.sheet, cell);
|
|
@@ -1803,7 +2358,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1803
2358
|
inputRef.current?.focus();
|
|
1804
2359
|
setEditing(false);
|
|
1805
2360
|
};
|
|
1806
|
-
return /* @__PURE__ */
|
|
2361
|
+
return /* @__PURE__ */ React6.createElement(GridCellEditor, {
|
|
1807
2362
|
key: idx,
|
|
1808
2363
|
value,
|
|
1809
2364
|
style,
|
|
@@ -1811,7 +2366,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1811
2366
|
onClose: handleClose
|
|
1812
2367
|
});
|
|
1813
2368
|
}
|
|
1814
|
-
return /* @__PURE__ */
|
|
2369
|
+
return /* @__PURE__ */ React6.createElement(SheetCell, {
|
|
1815
2370
|
key: id2,
|
|
1816
2371
|
id: id2,
|
|
1817
2372
|
cell,
|
|
@@ -1823,7 +2378,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1823
2378
|
}
|
|
1824
2379
|
});
|
|
1825
2380
|
});
|
|
1826
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2381
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement("input", {
|
|
1827
2382
|
ref: inputRef,
|
|
1828
2383
|
autoFocus: true,
|
|
1829
2384
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -1844,7 +2399,7 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1844
2399
|
const b1 = getRelativeClientRect(root, c1);
|
|
1845
2400
|
const b2 = getRelativeClientRect(root, c2);
|
|
1846
2401
|
const bounds = getRectUnion(b1, b2);
|
|
1847
|
-
return /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1848
2403
|
role: "none",
|
|
1849
2404
|
style: bounds,
|
|
1850
2405
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
@@ -1854,7 +2409,7 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1854
2409
|
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1855
2410
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1856
2411
|
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
1857
|
-
const decorationAddedClasses =
|
|
2412
|
+
const decorationAddedClasses = useMemo4(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
1858
2413
|
decorationsForCell
|
|
1859
2414
|
]);
|
|
1860
2415
|
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
@@ -1862,16 +2417,16 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1862
2417
|
return children;
|
|
1863
2418
|
}
|
|
1864
2419
|
const DecoratorComponent = decorate;
|
|
1865
|
-
return /* @__PURE__ */
|
|
1866
|
-
}, /* @__PURE__ */
|
|
2420
|
+
return /* @__PURE__ */ React6.createElement(DecoratorComponent, null, children);
|
|
2421
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1867
2422
|
role: "none",
|
|
1868
|
-
className:
|
|
2423
|
+
className: mx2("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
1869
2424
|
}, value));
|
|
1870
|
-
return /* @__PURE__ */
|
|
2425
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1871
2426
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1872
2427
|
role: "cell",
|
|
1873
2428
|
style,
|
|
1874
|
-
className:
|
|
2429
|
+
className: mx2("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1875
2430
|
"z-20",
|
|
1876
2431
|
fragments.cellSelected
|
|
1877
2432
|
], classNames),
|
|
@@ -1897,24 +2452,24 @@ var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
|
1897
2452
|
}, [
|
|
1898
2453
|
range
|
|
1899
2454
|
]);
|
|
1900
|
-
const extension =
|
|
2455
|
+
const extension = useMemo4(() => [
|
|
1901
2456
|
editorKeys({
|
|
1902
2457
|
onNav,
|
|
1903
2458
|
onClose
|
|
1904
2459
|
}),
|
|
1905
2460
|
sheetExtension({
|
|
1906
|
-
functions: model.
|
|
2461
|
+
functions: model.graph.getFunctions()
|
|
1907
2462
|
}),
|
|
1908
2463
|
rangeExtension((fn) => notifier.current = fn)
|
|
1909
2464
|
], [
|
|
1910
2465
|
model
|
|
1911
2466
|
]);
|
|
1912
|
-
return /* @__PURE__ */
|
|
2467
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1913
2468
|
role: "cell",
|
|
1914
2469
|
style,
|
|
1915
|
-
className:
|
|
2470
|
+
className: mx2("z-20 flex", fragments.cellSelected),
|
|
1916
2471
|
onClick: (ev) => ev.stopPropagation()
|
|
1917
|
-
}, /* @__PURE__ */
|
|
2472
|
+
}, /* @__PURE__ */ React6.createElement(CellEditor, {
|
|
1918
2473
|
autoFocus: true,
|
|
1919
2474
|
value,
|
|
1920
2475
|
extension
|
|
@@ -1927,29 +2482,29 @@ var SheetStatusBar = () => {
|
|
|
1927
2482
|
if (cursor) {
|
|
1928
2483
|
value = model.getCellValue(cursor);
|
|
1929
2484
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1930
|
-
value = model.
|
|
2485
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1931
2486
|
isFormula = true;
|
|
1932
2487
|
} else if (value != null) {
|
|
1933
2488
|
value = String(value);
|
|
1934
2489
|
}
|
|
1935
2490
|
}
|
|
1936
|
-
return /* @__PURE__ */
|
|
1937
|
-
className:
|
|
1938
|
-
}, /* @__PURE__ */
|
|
2491
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
2492
|
+
className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
2493
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1939
2494
|
className: "flex gap-4 items-center"
|
|
1940
|
-
}, /* @__PURE__ */
|
|
2495
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1941
2496
|
className: "flex w-16 items-center font-mono"
|
|
1942
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */
|
|
2497
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React6.createElement("div", {
|
|
1943
2498
|
className: "flex gap-2 items-center"
|
|
1944
|
-
}, /* @__PURE__ */
|
|
1945
|
-
className:
|
|
1946
|
-
}), /* @__PURE__ */
|
|
2499
|
+
}, /* @__PURE__ */ React6.createElement(FunctionIcon, {
|
|
2500
|
+
className: mx2("text-greenText", isFormula ? "visible" : "invisible")
|
|
2501
|
+
}), /* @__PURE__ */ React6.createElement("span", {
|
|
1947
2502
|
className: "font-mono"
|
|
1948
2503
|
}, value))));
|
|
1949
2504
|
};
|
|
1950
2505
|
var SheetDebug = () => {
|
|
1951
2506
|
const { model, cursor, range } = useSheetContext();
|
|
1952
|
-
const [, forceUpdate] =
|
|
2507
|
+
const [, forceUpdate] = useState5({});
|
|
1953
2508
|
useEffect4(() => {
|
|
1954
2509
|
const accessor = createDocAccessor(model.sheet, []);
|
|
1955
2510
|
const handleUpdate = () => forceUpdate({});
|
|
@@ -1961,9 +2516,9 @@ var SheetDebug = () => {
|
|
|
1961
2516
|
}, [
|
|
1962
2517
|
model
|
|
1963
2518
|
]);
|
|
1964
|
-
return /* @__PURE__ */
|
|
1965
|
-
className:
|
|
1966
|
-
}, /* @__PURE__ */
|
|
2519
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
2520
|
+
className: mx2("z-20 absolute right-0 top-20 bottom-20 w-[30rem] overflow-auto scrollbar-thin", "border border-gridLine text-xs bg-neutral-50 dark:bg-black text-cyan-500 font-mono p-1 opacity-80")
|
|
2521
|
+
}, /* @__PURE__ */ React6.createElement("pre", {
|
|
1967
2522
|
className: "whitespace-pre-wrap"
|
|
1968
2523
|
}, JSON.stringify({
|
|
1969
2524
|
cursor,
|
|
@@ -1985,247 +2540,13 @@ var Sheet = {
|
|
|
1985
2540
|
Debug: SheetDebug
|
|
1986
2541
|
};
|
|
1987
2542
|
|
|
1988
|
-
// packages/plugins/plugin-sheet/src/components/Toolbar/Toolbar.tsx
|
|
1989
|
-
import { Calendar, ChatText, CurrencyDollar, Eraser, HighlighterCircle, TextAlignCenter, TextAlignLeft, TextAlignRight } from "@phosphor-icons/react";
|
|
1990
|
-
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
1991
|
-
import React6 from "react";
|
|
1992
|
-
import { DensityProvider, ElevationProvider, Toolbar as NaturalToolbar2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
1993
|
-
import { nonNullable } from "@dxos/util";
|
|
1994
|
-
|
|
1995
|
-
// packages/plugins/plugin-sheet/src/components/Toolbar/common.tsx
|
|
1996
|
-
import React5 from "react";
|
|
1997
|
-
import { Toolbar as NaturalToolbar, Tooltip } from "@dxos/react-ui";
|
|
1998
|
-
import { getSize } from "@dxos/react-ui-theme";
|
|
1999
|
-
var iconStyles = getSize(5);
|
|
2000
|
-
var buttonStyles = "min-bs-0 p-2";
|
|
2001
|
-
var tooltipProps = {
|
|
2002
|
-
side: "top",
|
|
2003
|
-
classNames: "z-10"
|
|
2004
|
-
};
|
|
2005
|
-
var ToolbarSeparator = () => /* @__PURE__ */ React5.createElement("div", {
|
|
2006
|
-
role: "separator",
|
|
2007
|
-
className: "grow"
|
|
2008
|
-
});
|
|
2009
|
-
var ToolbarButton = ({ Icon: Icon2, children, ...props }) => {
|
|
2010
|
-
return /* @__PURE__ */ React5.createElement(Tooltip.Root, null, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
|
|
2011
|
-
asChild: true
|
|
2012
|
-
}, /* @__PURE__ */ React5.createElement(NaturalToolbar.Button, {
|
|
2013
|
-
variant: "ghost",
|
|
2014
|
-
...props,
|
|
2015
|
-
classNames: buttonStyles
|
|
2016
|
-
}, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
2017
|
-
className: iconStyles
|
|
2018
|
-
}), /* @__PURE__ */ React5.createElement("span", {
|
|
2019
|
-
className: "sr-only"
|
|
2020
|
-
}, children))), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, tooltipProps, children, /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null))));
|
|
2021
|
-
};
|
|
2022
|
-
var ToolbarToggleButton = ({ Icon: Icon2, children, ...props }) => {
|
|
2023
|
-
return /* @__PURE__ */ React5.createElement(Tooltip.Root, null, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
|
|
2024
|
-
asChild: true
|
|
2025
|
-
}, /* @__PURE__ */ React5.createElement(NaturalToolbar.ToggleGroupItem, {
|
|
2026
|
-
variant: "ghost",
|
|
2027
|
-
...props,
|
|
2028
|
-
classNames: buttonStyles
|
|
2029
|
-
}, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
2030
|
-
className: iconStyles
|
|
2031
|
-
}), /* @__PURE__ */ React5.createElement("span", {
|
|
2032
|
-
className: "sr-only"
|
|
2033
|
-
}, children))), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, tooltipProps, children, /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null))));
|
|
2034
|
-
};
|
|
2035
|
-
|
|
2036
|
-
// packages/plugins/plugin-sheet/src/components/Toolbar/Toolbar.tsx
|
|
2037
|
-
var [ToolbarContextProvider, useToolbarContext] = createContext2("Toolbar");
|
|
2038
|
-
var ToolbarRoot = ({ children, onAction, classNames }) => {
|
|
2039
|
-
return /* @__PURE__ */ React6.createElement(ToolbarContextProvider, {
|
|
2040
|
-
onAction
|
|
2041
|
-
}, /* @__PURE__ */ React6.createElement(DensityProvider, {
|
|
2042
|
-
density: "fine"
|
|
2043
|
-
}, /* @__PURE__ */ React6.createElement(ElevationProvider, {
|
|
2044
|
-
elevation: "chrome"
|
|
2045
|
-
}, /* @__PURE__ */ React6.createElement(NaturalToolbar2.Root, {
|
|
2046
|
-
classNames: [
|
|
2047
|
-
"is-full shrink-0 overflow-x-auto overflow-y-hidden p-1",
|
|
2048
|
-
classNames
|
|
2049
|
-
]
|
|
2050
|
-
}, children))));
|
|
2051
|
-
};
|
|
2052
|
-
var formatOptions = [
|
|
2053
|
-
{
|
|
2054
|
-
type: "date",
|
|
2055
|
-
Icon: Calendar,
|
|
2056
|
-
getState: (state) => false
|
|
2057
|
-
},
|
|
2058
|
-
{
|
|
2059
|
-
type: "currency",
|
|
2060
|
-
Icon: CurrencyDollar,
|
|
2061
|
-
getState: (state) => false
|
|
2062
|
-
}
|
|
2063
|
-
];
|
|
2064
|
-
var Format = () => {
|
|
2065
|
-
const { onAction } = useToolbarContext("Format");
|
|
2066
|
-
const { t } = useTranslation2(SHEET_PLUGIN);
|
|
2067
|
-
return /* @__PURE__ */ React6.createElement(NaturalToolbar2.ToggleGroup, {
|
|
2068
|
-
type: "single"
|
|
2069
|
-
}, formatOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ React6.createElement(ToolbarToggleButton, {
|
|
2070
|
-
key: type,
|
|
2071
|
-
value: type,
|
|
2072
|
-
Icon: Icon2,
|
|
2073
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2074
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2075
|
-
onClick: () => onAction?.({
|
|
2076
|
-
type
|
|
2077
|
-
})
|
|
2078
|
-
}, t(`toolbar ${type} label`))));
|
|
2079
|
-
};
|
|
2080
|
-
var alignmentOptions = [
|
|
2081
|
-
{
|
|
2082
|
-
type: "left",
|
|
2083
|
-
Icon: TextAlignLeft,
|
|
2084
|
-
getState: (state) => false
|
|
2085
|
-
},
|
|
2086
|
-
{
|
|
2087
|
-
type: "center",
|
|
2088
|
-
Icon: TextAlignCenter,
|
|
2089
|
-
getState: (state) => false
|
|
2090
|
-
},
|
|
2091
|
-
{
|
|
2092
|
-
type: "right",
|
|
2093
|
-
Icon: TextAlignRight,
|
|
2094
|
-
getState: (state) => false
|
|
2095
|
-
}
|
|
2096
|
-
];
|
|
2097
|
-
var Alignment = () => {
|
|
2098
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
2099
|
-
const { t } = useTranslation2(SHEET_PLUGIN);
|
|
2100
|
-
return /* @__PURE__ */ React6.createElement(NaturalToolbar2.ToggleGroup, {
|
|
2101
|
-
type: "single"
|
|
2102
|
-
}, alignmentOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ React6.createElement(ToolbarToggleButton, {
|
|
2103
|
-
key: type,
|
|
2104
|
-
value: type,
|
|
2105
|
-
Icon: Icon2,
|
|
2106
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2107
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2108
|
-
onClick: () => onAction?.({
|
|
2109
|
-
type
|
|
2110
|
-
})
|
|
2111
|
-
}, t(`toolbar ${type} label`))));
|
|
2112
|
-
};
|
|
2113
|
-
var styleOptions = [
|
|
2114
|
-
{
|
|
2115
|
-
type: "clear",
|
|
2116
|
-
Icon: Eraser,
|
|
2117
|
-
getState: (state) => false
|
|
2118
|
-
},
|
|
2119
|
-
{
|
|
2120
|
-
type: "highlight",
|
|
2121
|
-
Icon: HighlighterCircle,
|
|
2122
|
-
getState: (state) => false
|
|
2123
|
-
}
|
|
2124
|
-
];
|
|
2125
|
-
var Styles = () => {
|
|
2126
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
2127
|
-
const { t } = useTranslation2(SHEET_PLUGIN);
|
|
2128
|
-
return /* @__PURE__ */ React6.createElement(NaturalToolbar2.ToggleGroup, {
|
|
2129
|
-
type: "single"
|
|
2130
|
-
}, styleOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ React6.createElement(ToolbarToggleButton, {
|
|
2131
|
-
key: type,
|
|
2132
|
-
value: type,
|
|
2133
|
-
Icon: Icon2,
|
|
2134
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2135
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2136
|
-
onClick: () => onAction?.({
|
|
2137
|
-
type
|
|
2138
|
-
})
|
|
2139
|
-
}, t(`toolbar ${type} label`))));
|
|
2140
|
-
};
|
|
2141
|
-
var Actions = () => {
|
|
2142
|
-
const { onAction } = useToolbarContext("Actions");
|
|
2143
|
-
const { cursor, range, model } = useSheetContext();
|
|
2144
|
-
const { t } = useTranslation2(SHEET_PLUGIN);
|
|
2145
|
-
const overlapsCommentAnchor = (model.sheet.threads ?? []).filter(nonNullable).filter((thread) => thread.status !== "resolved").some((thread) => {
|
|
2146
|
-
if (!cursor) {
|
|
2147
|
-
return false;
|
|
2148
|
-
}
|
|
2149
|
-
return addressToIndex(model.sheet, cursor) === thread.anchor;
|
|
2150
|
-
});
|
|
2151
|
-
const hasCursor = !!cursor;
|
|
2152
|
-
const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;
|
|
2153
|
-
const tooltipLabelKey = !hasCursor ? "no cursor label" : overlapsCommentAnchor ? "selection overlaps existing comment label" : range ? "comment ranges not supported label" : "comment label";
|
|
2154
|
-
return /* @__PURE__ */ React6.createElement(ToolbarButton, {
|
|
2155
|
-
value: "comment",
|
|
2156
|
-
Icon: ChatText,
|
|
2157
|
-
"data-testid": "editor.toolbar.comment",
|
|
2158
|
-
onClick: () => {
|
|
2159
|
-
if (!cursor) {
|
|
2160
|
-
return;
|
|
2161
|
-
}
|
|
2162
|
-
return onAction?.({
|
|
2163
|
-
type: "comment",
|
|
2164
|
-
anchor: addressToIndex(model.sheet, cursor),
|
|
2165
|
-
cellContent: model.getCellText(cursor)
|
|
2166
|
-
});
|
|
2167
|
-
},
|
|
2168
|
-
disabled: !cursorOnly || overlapsCommentAnchor
|
|
2169
|
-
}, t(tooltipLabelKey));
|
|
2170
|
-
};
|
|
2171
|
-
var Toolbar = {
|
|
2172
|
-
Root: ToolbarRoot,
|
|
2173
|
-
Separator: ToolbarSeparator,
|
|
2174
|
-
Alignment,
|
|
2175
|
-
Format,
|
|
2176
|
-
Styles,
|
|
2177
|
-
Actions
|
|
2178
|
-
};
|
|
2179
|
-
|
|
2180
|
-
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
2181
|
-
var attentionFragment = mx4("group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface", "group-focus-within/editor:border-separator");
|
|
2182
|
-
var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
|
|
2183
|
-
var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
|
|
2184
|
-
const dispatch = useIntentDispatcher2();
|
|
2185
|
-
const id = fullyQualifiedId4(sheet);
|
|
2186
|
-
const isDirectlyAttended = useIsDirectlyAttended(id);
|
|
2187
|
-
const handleAction = useCallback2((action) => {
|
|
2188
|
-
switch (action.type) {
|
|
2189
|
-
case "comment": {
|
|
2190
|
-
void dispatch({
|
|
2191
|
-
action: "dxos.org/plugin/thread/action/create",
|
|
2192
|
-
data: {
|
|
2193
|
-
cursor: action.anchor,
|
|
2194
|
-
name: action.cellContent,
|
|
2195
|
-
subject: sheet
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
}, [
|
|
2201
|
-
sheet,
|
|
2202
|
-
dispatch
|
|
2203
|
-
]);
|
|
2204
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
2205
|
-
role: "none",
|
|
2206
|
-
className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0
|
|
2207
|
-
}, /* @__PURE__ */ React7.createElement(Sheet.Root, {
|
|
2208
|
-
sheet,
|
|
2209
|
-
space,
|
|
2210
|
-
remoteFunctionUrl
|
|
2211
|
-
}, /* @__PURE__ */ React7.createElement("div", {
|
|
2212
|
-
role: "none",
|
|
2213
|
-
className: mx4("flex flex-0 justify-center overflow-x-auto")
|
|
2214
|
-
}, /* @__PURE__ */ React7.createElement(Toolbar.Root, {
|
|
2215
|
-
onAction: handleAction,
|
|
2216
|
-
classNames: mx4(role === "section" ? [
|
|
2217
|
-
"z-[2] group-focus-within/section:visible",
|
|
2218
|
-
!isDirectlyAttended && "invisible",
|
|
2219
|
-
sectionToolbarLayout
|
|
2220
|
-
] : "group-focus-within/editor:border-separator group-[[aria-current]]/editor:border-separator")
|
|
2221
|
-
}, /* @__PURE__ */ React7.createElement(Toolbar.Separator, null), /* @__PURE__ */ React7.createElement(Toolbar.Actions, null))), /* @__PURE__ */ React7.createElement("div", {
|
|
2222
|
-
role: "none",
|
|
2223
|
-
className: mx4(role === "section" && "aspect-square border-is border-bs border-be border-separator", role === "article" && "flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator", focusRing, attentionFragment)
|
|
2224
|
-
}, /* @__PURE__ */ React7.createElement(Sheet.Main, null))));
|
|
2225
|
-
};
|
|
2226
|
-
var SheetContainer_default = SheetContainer;
|
|
2227
2543
|
export {
|
|
2228
|
-
|
|
2229
|
-
|
|
2544
|
+
ComputeGraphContextProvider,
|
|
2545
|
+
createSheet,
|
|
2546
|
+
addressToIndex,
|
|
2547
|
+
compareIndexPositions,
|
|
2548
|
+
useSheetContext,
|
|
2549
|
+
Sheet,
|
|
2550
|
+
SheetContainer
|
|
2230
2551
|
};
|
|
2231
|
-
//# sourceMappingURL=
|
|
2552
|
+
//# sourceMappingURL=chunk-U2JHW3L6.mjs.map
|