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