@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.89e9959
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-LG77O4RM.mjs +262 -0
- package/dist/lib/browser/SheetContainer-LG77O4RM.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-CHQAW4F4.mjs} +982 -508
- package/dist/lib/browser/chunk-CHQAW4F4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GNNVBNCX.mjs → chunk-GSV5QNLD.mjs} +409 -686
- package/dist/lib/browser/chunk-GSV5QNLD.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-WZMOZKQZ.mjs} +5 -15
- package/dist/lib/browser/chunk-WZMOZKQZ.mjs.map +7 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +86 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- 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-OZ7DHH4L.cjs +280 -0
- package/dist/lib/node/SheetContainer-OZ7DHH4L.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-5FTFZL5W.cjs} +1036 -558
- package/dist/lib/node/chunk-5FTFZL5W.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZRQZFV5T.cjs → chunk-5XPK2V4A.cjs} +418 -691
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
- package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-AOP42UAA.cjs} +9 -20
- package/dist/lib/node/chunk-AOP42UAA.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/graph-Q3N2X26H.cjs +55 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +7 -0
- package/dist/lib/node/index.cjs +98 -66
- package/dist/lib/node/index.cjs.map +4 -4
- 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-4XS2G25Z.mjs +263 -0
- package/dist/lib/node-esm/SheetContainer-4XS2G25Z.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-5WPZCXNS.mjs} +411 -686
- package/dist/lib/node-esm/chunk-5WPZCXNS.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/{SheetContainer-Y7ZMFBAP.mjs → chunk-KK3XL37M.mjs} +983 -508
- package/dist/lib/node-esm/chunk-KK3XL37M.mjs.map +7 -0
- package/dist/lib/{browser/chunk-WUPTZUTX.mjs → node-esm/chunk-RR2AO4SM.mjs} +6 -15
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs.map +7 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +87 -59
- package/dist/lib/node-esm/index.mjs.map +4 -4
- 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 +16 -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 +6 -7
- 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 +6 -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/graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +64 -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-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +26 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/functions/index.d.ts +4 -0
- package/dist/types/src/graph/functions/index.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 +5 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +3 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/graph/testing/test-plugin.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} +10 -49
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.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 +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +15 -4
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +48 -44
- package/src/SheetPlugin.tsx +46 -62
- package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +3 -4
- package/src/components/CellEditor/extension.ts +5 -6
- 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 +171 -0
- package/src/components/GridSheet/util.ts +148 -0
- package/src/components/Sheet/Sheet.stories.tsx +48 -88
- package/src/components/Sheet/Sheet.tsx +42 -24
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +12 -82
- package/src/components/Sheet/threads.tsx +10 -6
- package/src/components/SheetContainer.tsx +13 -15
- 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 +24 -14
- package/src/{model → defs}/util.ts +65 -17
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +147 -0
- package/src/extensions/index.ts +5 -0
- package/src/graph/compute-graph-registry.ts +90 -0
- package/src/graph/compute-graph.stories.tsx +93 -0
- package/src/graph/compute-graph.test.ts +87 -0
- package/src/graph/compute-graph.ts +242 -0
- package/src/graph/compute-node.ts +63 -0
- package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
- package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
- package/src/graph/functions/index.ts +7 -0
- package/src/graph/hyperformula.test.ts +14 -0
- package/src/graph/index.ts +8 -0
- package/src/graph/testing/index.ts +6 -0
- package/src/graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
- 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 +28 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +40 -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/sheet-model.test.ts +59 -0
- package/src/model/{model.ts → sheet-model.ts} +88 -188
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +68 -0
- package/src/types.ts +15 -13
- 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 +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- 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/src/{model/functions.ts → graph/functions/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-RR2AO4SM.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-5WPZCXNS.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,183 @@ 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";
|
|
44
|
-
import {
|
|
45
|
-
import { mx as
|
|
23
|
+
import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
|
|
24
|
+
import { log as log2 } from "@dxos/log";
|
|
25
|
+
import { ATTENABLE_ATTRIBUTE, useAttendableAttributes, useAttention, useAttentionPath } from "@dxos/react-ui-attention";
|
|
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: 40,
|
|
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 = ({ name, cells, ...size } = {}) => {
|
|
136
|
+
const sheet = create(SheetType, {
|
|
137
|
+
name,
|
|
138
|
+
cells: {},
|
|
139
|
+
rows: [],
|
|
140
|
+
columns: [],
|
|
141
|
+
rowMeta: {},
|
|
142
|
+
columnMeta: {},
|
|
143
|
+
formatting: {}
|
|
144
|
+
});
|
|
145
|
+
initialize(sheet, size);
|
|
146
|
+
if (cells) {
|
|
147
|
+
Object.entries(cells).forEach(([key, { value }]) => {
|
|
148
|
+
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
149
|
+
sheet.cells[idx] = {
|
|
150
|
+
value
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return sheet;
|
|
155
|
+
};
|
|
156
|
+
var addressToIndex = (sheet, cell) => {
|
|
157
|
+
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
158
|
+
};
|
|
159
|
+
var addressFromIndex = (sheet, idx) => {
|
|
160
|
+
const [column, row] = idx.split("@");
|
|
161
|
+
return {
|
|
162
|
+
col: sheet.columns.indexOf(column),
|
|
163
|
+
row: sheet.rows.indexOf(row)
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
var rangeFromIndex = (sheet, idx) => {
|
|
167
|
+
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
168
|
+
return {
|
|
169
|
+
from,
|
|
170
|
+
to
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
var closest = (cursor, cells) => {
|
|
174
|
+
let closestCell;
|
|
175
|
+
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
176
|
+
for (const cell of cells) {
|
|
177
|
+
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
178
|
+
if (distance < closestDistance) {
|
|
179
|
+
closestCell = cell;
|
|
180
|
+
closestDistance = distance;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return closestCell;
|
|
184
|
+
};
|
|
185
|
+
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
186
|
+
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
187
|
+
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
188
|
+
if (rowA !== rowB) {
|
|
189
|
+
return rowA - rowB;
|
|
190
|
+
} else {
|
|
191
|
+
return columnA - columnB;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
49
196
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
50
197
|
var axisHeight = 34;
|
|
51
198
|
var minWidth = 40;
|
|
@@ -87,7 +234,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
87
234
|
const left = x;
|
|
88
235
|
x += width2 - 1;
|
|
89
236
|
return {
|
|
90
|
-
|
|
237
|
+
col: i,
|
|
91
238
|
left,
|
|
92
239
|
width: width2
|
|
93
240
|
};
|
|
@@ -192,14 +339,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
192
339
|
break;
|
|
193
340
|
}
|
|
194
341
|
case "ArrowLeft": {
|
|
195
|
-
if (opposite.
|
|
196
|
-
opposite.
|
|
342
|
+
if (opposite.col > 0) {
|
|
343
|
+
opposite.col -= 1;
|
|
197
344
|
}
|
|
198
345
|
break;
|
|
199
346
|
}
|
|
200
347
|
case "ArrowRight": {
|
|
201
|
-
if (opposite.
|
|
202
|
-
opposite.
|
|
348
|
+
if (opposite.col < size.numCols - 1) {
|
|
349
|
+
opposite.col += 1;
|
|
203
350
|
}
|
|
204
351
|
break;
|
|
205
352
|
}
|
|
@@ -217,18 +364,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
217
364
|
cursor: next
|
|
218
365
|
};
|
|
219
366
|
};
|
|
220
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
367
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
221
368
|
switch (ev.key) {
|
|
222
369
|
case "ArrowUp":
|
|
223
370
|
if (cursor === void 0) {
|
|
224
371
|
return {
|
|
225
372
|
row: 0,
|
|
226
|
-
|
|
373
|
+
col: 0
|
|
227
374
|
};
|
|
228
375
|
} else if (cursor.row > 0) {
|
|
229
376
|
return {
|
|
230
377
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
231
|
-
|
|
378
|
+
col: cursor.col
|
|
232
379
|
};
|
|
233
380
|
}
|
|
234
381
|
break;
|
|
@@ -236,12 +383,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
236
383
|
if (cursor === void 0) {
|
|
237
384
|
return {
|
|
238
385
|
row: 0,
|
|
239
|
-
|
|
386
|
+
col: 0
|
|
240
387
|
};
|
|
241
388
|
} else if (cursor.row < numRows - 1) {
|
|
242
389
|
return {
|
|
243
390
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
244
|
-
|
|
391
|
+
col: cursor.col
|
|
245
392
|
};
|
|
246
393
|
}
|
|
247
394
|
break;
|
|
@@ -249,12 +396,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
249
396
|
if (cursor === void 0) {
|
|
250
397
|
return {
|
|
251
398
|
row: 0,
|
|
252
|
-
|
|
399
|
+
col: 0
|
|
253
400
|
};
|
|
254
|
-
} else if (cursor.
|
|
401
|
+
} else if (cursor.col > 0) {
|
|
255
402
|
return {
|
|
256
403
|
row: cursor.row,
|
|
257
|
-
|
|
404
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
258
405
|
};
|
|
259
406
|
}
|
|
260
407
|
break;
|
|
@@ -262,24 +409,24 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
262
409
|
if (cursor === void 0) {
|
|
263
410
|
return {
|
|
264
411
|
row: 0,
|
|
265
|
-
|
|
412
|
+
col: 0
|
|
266
413
|
};
|
|
267
|
-
} else if (cursor.
|
|
414
|
+
} else if (cursor.col < numCols - 1) {
|
|
268
415
|
return {
|
|
269
416
|
row: cursor.row,
|
|
270
|
-
|
|
417
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
271
418
|
};
|
|
272
419
|
}
|
|
273
420
|
break;
|
|
274
421
|
case "Home":
|
|
275
422
|
return {
|
|
276
423
|
row: 0,
|
|
277
|
-
|
|
424
|
+
col: 0
|
|
278
425
|
};
|
|
279
426
|
case "End":
|
|
280
427
|
return {
|
|
281
428
|
row: numRows - 1,
|
|
282
|
-
|
|
429
|
+
col: numCols - 1
|
|
283
430
|
};
|
|
284
431
|
}
|
|
285
432
|
};
|
|
@@ -336,14 +483,13 @@ var useRangeSelect = (cb) => {
|
|
|
336
483
|
};
|
|
337
484
|
|
|
338
485
|
// 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";
|
|
486
|
+
import React3, { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useState as useState4 } from "react";
|
|
487
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
342
488
|
|
|
343
489
|
// packages/plugins/plugin-sheet/src/components/Sheet/decorations.ts
|
|
344
|
-
import { create } from "@dxos/echo-schema";
|
|
490
|
+
import { create as create2 } from "@dxos/echo-schema";
|
|
345
491
|
var createDecorations = () => {
|
|
346
|
-
const { decorations } =
|
|
492
|
+
const { decorations } = create2({
|
|
347
493
|
decorations: {}
|
|
348
494
|
});
|
|
349
495
|
const addDecoration = (cellIndex, decorator) => {
|
|
@@ -379,27 +525,68 @@ var createDecorations = () => {
|
|
|
379
525
|
};
|
|
380
526
|
};
|
|
381
527
|
|
|
382
|
-
// packages/plugins/plugin-sheet/src/
|
|
528
|
+
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
529
|
+
import { useContext } from "react";
|
|
530
|
+
import { raise } from "@dxos/debug";
|
|
531
|
+
import { useAsyncState } from "@dxos/react-hooks";
|
|
532
|
+
|
|
533
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
534
|
+
import React2 from "react";
|
|
535
|
+
|
|
536
|
+
// packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
|
|
537
|
+
import React, { createContext } from "react";
|
|
538
|
+
var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
|
|
539
|
+
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
540
|
+
return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
|
|
541
|
+
value: {
|
|
542
|
+
registry
|
|
543
|
+
}
|
|
544
|
+
}, children);
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
548
|
+
var SheetContainer = React2.lazy(() => import("./SheetContainer-4XS2G25Z.mjs"));
|
|
549
|
+
|
|
550
|
+
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
551
|
+
var useComputeGraph = (space) => {
|
|
552
|
+
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
553
|
+
const [graph] = useAsyncState(async () => {
|
|
554
|
+
if (space) {
|
|
555
|
+
const graph2 = registry.getOrCreateGraph(space);
|
|
556
|
+
await graph2.open();
|
|
557
|
+
return graph2;
|
|
558
|
+
}
|
|
559
|
+
}, [
|
|
560
|
+
space,
|
|
561
|
+
registry
|
|
562
|
+
]);
|
|
563
|
+
return graph;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
567
|
+
import { useMemo } from "react";
|
|
568
|
+
|
|
569
|
+
// packages/plugins/plugin-sheet/src/model/formatting-model.ts
|
|
383
570
|
var FormattingModel = class {
|
|
384
|
-
constructor(
|
|
385
|
-
this.
|
|
571
|
+
constructor(_model) {
|
|
572
|
+
this._model = _model;
|
|
386
573
|
}
|
|
387
574
|
/**
|
|
388
575
|
* Get formatted string value and className for cell.
|
|
389
576
|
*/
|
|
390
577
|
getFormatting(cell) {
|
|
391
|
-
const value = this.
|
|
578
|
+
const value = this._model.getValue(cell);
|
|
392
579
|
if (value === void 0 || value === null) {
|
|
393
580
|
return {};
|
|
394
581
|
}
|
|
395
582
|
const locales = void 0;
|
|
396
|
-
const idx = addressToIndex(this.
|
|
397
|
-
let formatting = this.
|
|
583
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
584
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
398
585
|
const classNames = [
|
|
399
586
|
...formatting?.classNames ?? []
|
|
400
587
|
];
|
|
401
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
402
|
-
const range = rangeFromIndex(this.
|
|
588
|
+
for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
|
|
589
|
+
const range = rangeFromIndex(this._model.sheet, idx2);
|
|
403
590
|
if (inRange(range, cell)) {
|
|
404
591
|
if (_formatting.classNames) {
|
|
405
592
|
classNames.push(..._formatting.classNames);
|
|
@@ -410,7 +597,7 @@ var FormattingModel = class {
|
|
|
410
597
|
}
|
|
411
598
|
}
|
|
412
599
|
const defaultNumber = "justify-end font-mono";
|
|
413
|
-
const type = formatting?.type ?? this.
|
|
600
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
414
601
|
switch (type) {
|
|
415
602
|
case ValueTypeEnum.Boolean: {
|
|
416
603
|
return {
|
|
@@ -460,21 +647,21 @@ var FormattingModel = class {
|
|
|
460
647
|
// Dates.
|
|
461
648
|
//
|
|
462
649
|
case ValueTypeEnum.DateTime: {
|
|
463
|
-
const date = this.
|
|
650
|
+
const date = this._model.toLocalDate(value);
|
|
464
651
|
return {
|
|
465
652
|
value: date.toLocaleString(locales),
|
|
466
653
|
classNames
|
|
467
654
|
};
|
|
468
655
|
}
|
|
469
656
|
case ValueTypeEnum.Date: {
|
|
470
|
-
const date = this.
|
|
657
|
+
const date = this._model.toLocalDate(value);
|
|
471
658
|
return {
|
|
472
659
|
value: date.toLocaleDateString(locales),
|
|
473
660
|
classNames
|
|
474
661
|
};
|
|
475
662
|
}
|
|
476
663
|
case ValueTypeEnum.Time: {
|
|
477
|
-
const date = this.
|
|
664
|
+
const date = this._model.toLocalDate(value);
|
|
478
665
|
return {
|
|
479
666
|
value: date.toLocaleTimeString(locales),
|
|
480
667
|
classNames
|
|
@@ -490,85 +677,554 @@ var FormattingModel = class {
|
|
|
490
677
|
}
|
|
491
678
|
};
|
|
492
679
|
|
|
493
|
-
// packages/plugins/plugin-sheet/src/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
680
|
+
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
681
|
+
import { Event } from "@dxos/async";
|
|
682
|
+
import { Resource } from "@dxos/context";
|
|
683
|
+
import { getTypename } from "@dxos/echo-schema";
|
|
684
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
685
|
+
import { PublicKey } from "@dxos/keys";
|
|
686
|
+
import { log } from "@dxos/log";
|
|
687
|
+
import { DetailedCellError, ExportedCellChange } from "#hyperformula";
|
|
688
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
689
|
+
var typeMap = {
|
|
690
|
+
BOOLEAN: ValueTypeEnum.Boolean,
|
|
691
|
+
NUMBER_RAW: ValueTypeEnum.Number,
|
|
692
|
+
NUMBER_PERCENT: ValueTypeEnum.Percent,
|
|
693
|
+
NUMBER_CURRENCY: ValueTypeEnum.Currency,
|
|
694
|
+
NUMBER_DATETIME: ValueTypeEnum.DateTime,
|
|
695
|
+
NUMBER_DATE: ValueTypeEnum.Date,
|
|
696
|
+
NUMBER_TIME: ValueTypeEnum.Time
|
|
509
697
|
};
|
|
510
|
-
var
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
698
|
+
var getTopLeft = (range) => {
|
|
699
|
+
const to = range.to ?? range.from;
|
|
700
|
+
return {
|
|
701
|
+
row: Math.min(range.from.row, to.row),
|
|
702
|
+
col: Math.min(range.from.col, to.col)
|
|
703
|
+
};
|
|
704
|
+
};
|
|
705
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
706
|
+
sheet,
|
|
707
|
+
row: cell.row,
|
|
708
|
+
col: cell.col
|
|
709
|
+
});
|
|
710
|
+
var toModelRange = (sheet, range) => ({
|
|
711
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
712
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
713
|
+
});
|
|
714
|
+
var SheetModel = class extends Resource {
|
|
715
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
716
|
+
super();
|
|
717
|
+
this._graph = _graph;
|
|
718
|
+
this._sheet = _sheet;
|
|
719
|
+
this._options = _options;
|
|
720
|
+
this.id = `model-${PublicKey.random().truncate()}`;
|
|
721
|
+
this.update = new Event();
|
|
722
|
+
}
|
|
723
|
+
get graph() {
|
|
724
|
+
return this._graph;
|
|
725
|
+
}
|
|
726
|
+
get sheet() {
|
|
727
|
+
return this._sheet;
|
|
728
|
+
}
|
|
729
|
+
get readonly() {
|
|
730
|
+
return this._options.readonly;
|
|
731
|
+
}
|
|
732
|
+
get bounds() {
|
|
733
|
+
return {
|
|
734
|
+
rows: this._sheet.rows.length,
|
|
735
|
+
columns: this._sheet.columns.length
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Initialize sheet and engine.
|
|
740
|
+
*/
|
|
741
|
+
async _open() {
|
|
742
|
+
log("initialize", {
|
|
743
|
+
id: this.id
|
|
744
|
+
}, {
|
|
745
|
+
F: __dxlog_file2,
|
|
746
|
+
L: 104,
|
|
747
|
+
S: this,
|
|
748
|
+
C: (f, a) => f(...a)
|
|
749
|
+
});
|
|
750
|
+
initialize(this._sheet);
|
|
751
|
+
this._node = this._graph.getOrCreateNode(createSheetName({
|
|
752
|
+
type: getTypename(this._sheet),
|
|
753
|
+
id: this._sheet.id
|
|
754
|
+
}));
|
|
755
|
+
await this._node.open();
|
|
756
|
+
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
757
|
+
this._ctx.onDispose(unsubscribe);
|
|
758
|
+
this.reset();
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Update engine.
|
|
762
|
+
* NOTE: This resets the undo history.
|
|
763
|
+
* @deprecated
|
|
764
|
+
*/
|
|
765
|
+
reset() {
|
|
766
|
+
invariant2(this._node, void 0, {
|
|
767
|
+
F: __dxlog_file2,
|
|
768
|
+
L: 124,
|
|
769
|
+
S: this,
|
|
770
|
+
A: [
|
|
771
|
+
"this._node",
|
|
772
|
+
""
|
|
773
|
+
]
|
|
774
|
+
});
|
|
775
|
+
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
776
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
777
|
+
invariant2(this._node, void 0, {
|
|
778
|
+
F: __dxlog_file2,
|
|
779
|
+
L: 127,
|
|
780
|
+
S: this,
|
|
781
|
+
A: [
|
|
782
|
+
"this._node",
|
|
783
|
+
""
|
|
784
|
+
]
|
|
785
|
+
});
|
|
786
|
+
const { col, row } = addressFromIndex(this._sheet, key);
|
|
787
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
788
|
+
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
789
|
+
}
|
|
790
|
+
this._node.graph.hf.setCellContents({
|
|
791
|
+
sheet: this._node.sheetId,
|
|
792
|
+
row,
|
|
793
|
+
col
|
|
794
|
+
}, value);
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Recalculate formulas.
|
|
799
|
+
* NOTE: This resets the undo history.
|
|
800
|
+
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
801
|
+
* @deprecated
|
|
802
|
+
*/
|
|
803
|
+
// TODO(burdon): Remove.
|
|
804
|
+
recalculate() {
|
|
805
|
+
this._node?.graph.hf.rebuildAndRecalculate();
|
|
806
|
+
}
|
|
807
|
+
insertRows(i, n = 1) {
|
|
808
|
+
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
809
|
+
this.reset();
|
|
810
|
+
}
|
|
811
|
+
insertColumns(i, n = 1) {
|
|
812
|
+
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
813
|
+
this.reset();
|
|
814
|
+
}
|
|
815
|
+
//
|
|
816
|
+
// Undoable actions.
|
|
817
|
+
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
818
|
+
//
|
|
819
|
+
/**
|
|
820
|
+
* Clear range of values.
|
|
821
|
+
*/
|
|
822
|
+
clear(range) {
|
|
823
|
+
invariant2(this._node, void 0, {
|
|
824
|
+
F: __dxlog_file2,
|
|
825
|
+
L: 169,
|
|
826
|
+
S: this,
|
|
827
|
+
A: [
|
|
828
|
+
"this._node",
|
|
829
|
+
""
|
|
830
|
+
]
|
|
831
|
+
});
|
|
832
|
+
const topLeft = getTopLeft(range);
|
|
833
|
+
const values = this._iterRange(range, () => null);
|
|
834
|
+
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
835
|
+
this._iterRange(range, (cell) => {
|
|
836
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
837
|
+
delete this._sheet.cells[idx];
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
cut(range) {
|
|
841
|
+
invariant2(this._node, void 0, {
|
|
842
|
+
F: __dxlog_file2,
|
|
843
|
+
L: 180,
|
|
844
|
+
S: this,
|
|
845
|
+
A: [
|
|
846
|
+
"this._node",
|
|
847
|
+
""
|
|
848
|
+
]
|
|
849
|
+
});
|
|
850
|
+
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
851
|
+
this._iterRange(range, (cell) => {
|
|
852
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
853
|
+
delete this._sheet.cells[idx];
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
copy(range) {
|
|
857
|
+
invariant2(this._node, void 0, {
|
|
858
|
+
F: __dxlog_file2,
|
|
859
|
+
L: 189,
|
|
860
|
+
S: this,
|
|
861
|
+
A: [
|
|
862
|
+
"this._node",
|
|
863
|
+
""
|
|
864
|
+
]
|
|
865
|
+
});
|
|
866
|
+
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
867
|
+
}
|
|
868
|
+
paste(cell) {
|
|
869
|
+
invariant2(this._node, void 0, {
|
|
870
|
+
F: __dxlog_file2,
|
|
871
|
+
L: 194,
|
|
872
|
+
S: this,
|
|
873
|
+
A: [
|
|
874
|
+
"this._node",
|
|
875
|
+
""
|
|
876
|
+
]
|
|
877
|
+
});
|
|
878
|
+
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
879
|
+
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
880
|
+
for (const change of changes) {
|
|
881
|
+
if (change instanceof ExportedCellChange) {
|
|
882
|
+
const { address, newValue } = change;
|
|
883
|
+
const idx = addressToIndex(this._sheet, {
|
|
884
|
+
row: address.row,
|
|
885
|
+
col: address.col
|
|
886
|
+
});
|
|
887
|
+
this._sheet.cells[idx] = {
|
|
888
|
+
value: newValue
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
// TODO(burdon): Display undo/redo state.
|
|
895
|
+
undo() {
|
|
896
|
+
invariant2(this._node, void 0, {
|
|
897
|
+
F: __dxlog_file2,
|
|
898
|
+
L: 209,
|
|
899
|
+
S: this,
|
|
900
|
+
A: [
|
|
901
|
+
"this._node",
|
|
902
|
+
""
|
|
903
|
+
]
|
|
904
|
+
});
|
|
905
|
+
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
906
|
+
this._node.graph.hf.undo();
|
|
514
907
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
908
|
+
}
|
|
909
|
+
redo() {
|
|
910
|
+
invariant2(this._node, void 0, {
|
|
911
|
+
F: __dxlog_file2,
|
|
912
|
+
L: 217,
|
|
913
|
+
S: this,
|
|
914
|
+
A: [
|
|
915
|
+
"this._node",
|
|
916
|
+
""
|
|
917
|
+
]
|
|
918
|
+
});
|
|
919
|
+
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
920
|
+
this._node.graph.hf.redo();
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Get value from sheet.
|
|
925
|
+
*/
|
|
926
|
+
getCellValue(cell) {
|
|
927
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
928
|
+
return this._sheet.cells[idx]?.value ?? null;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Get value as a string for editing.
|
|
932
|
+
*/
|
|
933
|
+
getCellText(cell) {
|
|
934
|
+
const value = this.getCellValue(cell);
|
|
935
|
+
if (value == null) {
|
|
936
|
+
return void 0;
|
|
937
|
+
}
|
|
938
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
939
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
518
940
|
} else {
|
|
519
|
-
return
|
|
941
|
+
return String(value);
|
|
520
942
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Get array of raw values from sheet.
|
|
946
|
+
*/
|
|
947
|
+
getCellValues(range) {
|
|
948
|
+
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Gets the regular or computed value from the engine.
|
|
952
|
+
*/
|
|
953
|
+
getValue(cell) {
|
|
954
|
+
invariant2(this._node, void 0, {
|
|
955
|
+
F: __dxlog_file2,
|
|
956
|
+
L: 260,
|
|
957
|
+
S: this,
|
|
958
|
+
A: [
|
|
959
|
+
"this._node",
|
|
960
|
+
""
|
|
961
|
+
]
|
|
962
|
+
});
|
|
963
|
+
const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
964
|
+
if (value instanceof DetailedCellError) {
|
|
965
|
+
return value.toString();
|
|
966
|
+
}
|
|
967
|
+
return value;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Get value type.
|
|
971
|
+
*/
|
|
972
|
+
getValueType(cell) {
|
|
973
|
+
invariant2(this._node, void 0, {
|
|
974
|
+
F: __dxlog_file2,
|
|
975
|
+
L: 273,
|
|
976
|
+
S: this,
|
|
977
|
+
A: [
|
|
978
|
+
"this._node",
|
|
979
|
+
""
|
|
980
|
+
]
|
|
981
|
+
});
|
|
982
|
+
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
983
|
+
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
984
|
+
return typeMap[type];
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Sets the value, updating the sheet and engine.
|
|
988
|
+
*/
|
|
989
|
+
setValue(cell, value) {
|
|
990
|
+
invariant2(this._node, void 0, {
|
|
991
|
+
F: __dxlog_file2,
|
|
992
|
+
L: 283,
|
|
993
|
+
S: this,
|
|
994
|
+
A: [
|
|
995
|
+
"this._node",
|
|
996
|
+
""
|
|
997
|
+
]
|
|
998
|
+
});
|
|
999
|
+
if (this._options.readonly) {
|
|
1000
|
+
throw new ReadonlyException();
|
|
1001
|
+
}
|
|
1002
|
+
let refresh = false;
|
|
1003
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
1004
|
+
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
1005
|
+
refresh = true;
|
|
1006
|
+
}
|
|
1007
|
+
if (cell.col >= this._sheet.columns.length) {
|
|
1008
|
+
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
1009
|
+
refresh = true;
|
|
528
1010
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
1011
|
+
if (refresh) {
|
|
1012
|
+
this.reset();
|
|
1013
|
+
}
|
|
1014
|
+
this._node.graph.hf.setCellContents({
|
|
1015
|
+
sheet: this._node.sheetId,
|
|
1016
|
+
row: cell.row,
|
|
1017
|
+
col: cell.col
|
|
1018
|
+
}, [
|
|
1019
|
+
[
|
|
1020
|
+
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
1021
|
+
]
|
|
1022
|
+
]);
|
|
1023
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
1024
|
+
if (value === void 0 || value === null) {
|
|
1025
|
+
delete this._sheet.cells[idx];
|
|
532
1026
|
} else {
|
|
533
|
-
|
|
1027
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1028
|
+
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1029
|
+
}
|
|
1030
|
+
this._sheet.cells[idx] = {
|
|
1031
|
+
value
|
|
1032
|
+
};
|
|
534
1033
|
}
|
|
535
|
-
}
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Sets values from a simple map.
|
|
1037
|
+
*/
|
|
1038
|
+
setValues(values) {
|
|
1039
|
+
Object.entries(values).forEach(([key, { value }]) => {
|
|
1040
|
+
this.setValue(addressFromA1Notation(key), value);
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Iterate range.
|
|
1045
|
+
*/
|
|
1046
|
+
_iterRange(range, cb) {
|
|
1047
|
+
const to = range.to ?? range.from;
|
|
1048
|
+
const rowRange = [
|
|
1049
|
+
Math.min(range.from.row, to.row),
|
|
1050
|
+
Math.max(range.from.row, to.row)
|
|
1051
|
+
];
|
|
1052
|
+
const columnRange = [
|
|
1053
|
+
Math.min(range.from.col, to.col),
|
|
1054
|
+
Math.max(range.from.col, to.col)
|
|
1055
|
+
];
|
|
1056
|
+
const rows = [];
|
|
1057
|
+
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
1058
|
+
const rowCells = [];
|
|
1059
|
+
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
1060
|
+
const value = cb({
|
|
1061
|
+
row,
|
|
1062
|
+
col: column
|
|
1063
|
+
});
|
|
1064
|
+
if (value !== void 0) {
|
|
1065
|
+
rowCells.push(value);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
rows.push(rowCells);
|
|
1069
|
+
}
|
|
1070
|
+
return rows;
|
|
1071
|
+
}
|
|
1072
|
+
// TODO(burdon): Delete index.
|
|
1073
|
+
_deleteIndices(indices, i, n) {
|
|
1074
|
+
throw new Error("Not implemented");
|
|
1075
|
+
}
|
|
1076
|
+
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
1077
|
+
_moveIndices(indices, i, j, n) {
|
|
1078
|
+
throw new Error("Not implemented");
|
|
1079
|
+
}
|
|
1080
|
+
//
|
|
1081
|
+
// Indices.
|
|
1082
|
+
//
|
|
1083
|
+
/**
|
|
1084
|
+
* Map from A1 notation to indices.
|
|
1085
|
+
*/
|
|
1086
|
+
mapFormulaRefsToIndices(formula) {
|
|
1087
|
+
invariant2(formula.charAt(0) === "=", void 0, {
|
|
1088
|
+
F: __dxlog_file2,
|
|
1089
|
+
L: 372,
|
|
1090
|
+
S: this,
|
|
1091
|
+
A: [
|
|
1092
|
+
"formula.charAt(0) === '='",
|
|
1093
|
+
""
|
|
1094
|
+
]
|
|
1095
|
+
});
|
|
1096
|
+
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1097
|
+
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Map from indices to A1 notation.
|
|
1102
|
+
*/
|
|
1103
|
+
mapFormulaIndicesToRefs(formula) {
|
|
1104
|
+
invariant2(formula.charAt(0) === "=", void 0, {
|
|
1105
|
+
F: __dxlog_file2,
|
|
1106
|
+
L: 382,
|
|
1107
|
+
S: this,
|
|
1108
|
+
A: [
|
|
1109
|
+
"formula.charAt(0) === '='",
|
|
1110
|
+
""
|
|
1111
|
+
]
|
|
1112
|
+
});
|
|
1113
|
+
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1114
|
+
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
//
|
|
1118
|
+
// Values
|
|
1119
|
+
//
|
|
1120
|
+
/**
|
|
1121
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1122
|
+
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1123
|
+
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1124
|
+
*/
|
|
1125
|
+
toLocalDate(num) {
|
|
1126
|
+
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1127
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1128
|
+
}
|
|
1129
|
+
toDateTime(num) {
|
|
1130
|
+
invariant2(this._node, void 0, {
|
|
1131
|
+
F: __dxlog_file2,
|
|
1132
|
+
L: 403,
|
|
1133
|
+
S: this,
|
|
1134
|
+
A: [
|
|
1135
|
+
"this._node",
|
|
1136
|
+
""
|
|
1137
|
+
]
|
|
1138
|
+
});
|
|
1139
|
+
return this._node.graph.hf.numberToDateTime(num);
|
|
1140
|
+
}
|
|
1141
|
+
toDate(num) {
|
|
1142
|
+
invariant2(this._node, void 0, {
|
|
1143
|
+
F: __dxlog_file2,
|
|
1144
|
+
L: 408,
|
|
1145
|
+
S: this,
|
|
1146
|
+
A: [
|
|
1147
|
+
"this._node",
|
|
1148
|
+
""
|
|
1149
|
+
]
|
|
1150
|
+
});
|
|
1151
|
+
return this._node.graph.hf.numberToDate(num);
|
|
1152
|
+
}
|
|
1153
|
+
toTime(num) {
|
|
1154
|
+
invariant2(this._node, void 0, {
|
|
1155
|
+
F: __dxlog_file2,
|
|
1156
|
+
L: 413,
|
|
1157
|
+
S: this,
|
|
1158
|
+
A: [
|
|
1159
|
+
"this._node",
|
|
1160
|
+
""
|
|
1161
|
+
]
|
|
1162
|
+
});
|
|
1163
|
+
return this._node.graph.hf.numberToTime(num);
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
// packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
|
|
1168
|
+
var useFormattingModel = (model) => {
|
|
1169
|
+
return useMemo(() => model && new FormattingModel(model), [
|
|
1170
|
+
model
|
|
1171
|
+
]);
|
|
536
1172
|
};
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const [
|
|
542
|
-
const decorations = useMemo(() => createDecorations(), []);
|
|
543
|
-
const [[model, formatting] = [], setModels] = useState3(void 0);
|
|
1173
|
+
|
|
1174
|
+
// packages/plugins/plugin-sheet/src/hooks/useSheetModel.ts
|
|
1175
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1176
|
+
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1177
|
+
const [model, setModel] = useState3();
|
|
544
1178
|
useEffect2(() => {
|
|
1179
|
+
if (!graph || !sheet) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
545
1182
|
let model2;
|
|
546
|
-
let formatting2;
|
|
547
1183
|
const t = setTimeout(async () => {
|
|
548
|
-
model2 = new SheetModel(graph, sheet,
|
|
549
|
-
readonly
|
|
550
|
-
mapFormulaBindingToId,
|
|
551
|
-
mapFormulaBindingFromId
|
|
1184
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1185
|
+
readonly
|
|
552
1186
|
});
|
|
553
|
-
await model2.
|
|
554
|
-
|
|
555
|
-
setModels([
|
|
556
|
-
model2,
|
|
557
|
-
formatting2
|
|
558
|
-
]);
|
|
1187
|
+
await model2.open();
|
|
1188
|
+
setModel(model2);
|
|
559
1189
|
});
|
|
560
1190
|
return () => {
|
|
561
1191
|
clearTimeout(t);
|
|
562
|
-
void model2?.
|
|
1192
|
+
void model2?.close();
|
|
563
1193
|
};
|
|
564
1194
|
}, [
|
|
565
1195
|
graph,
|
|
1196
|
+
sheet,
|
|
566
1197
|
readonly
|
|
567
1198
|
]);
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
1199
|
+
return model;
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
// packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
|
|
1203
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1204
|
+
var SheetContext = /* @__PURE__ */ createContext2(null);
|
|
1205
|
+
var useSheetContext = () => {
|
|
1206
|
+
const context = useContext2(SheetContext);
|
|
1207
|
+
invariant3(context, void 0, {
|
|
1208
|
+
F: __dxlog_file3,
|
|
1209
|
+
L: 43,
|
|
1210
|
+
S: void 0,
|
|
1211
|
+
A: [
|
|
1212
|
+
"context",
|
|
1213
|
+
""
|
|
1214
|
+
]
|
|
1215
|
+
});
|
|
1216
|
+
return context;
|
|
1217
|
+
};
|
|
1218
|
+
var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
1219
|
+
const model = useSheetModel(graph, sheet, {
|
|
1220
|
+
readonly
|
|
1221
|
+
});
|
|
1222
|
+
const formatting = useFormattingModel(model);
|
|
1223
|
+
const [cursor, setCursor] = useState4();
|
|
1224
|
+
const [range, setRange] = useState4();
|
|
1225
|
+
const [editing, setEditing] = useState4(false);
|
|
1226
|
+
const decorations = useMemo2(() => createDecorations(), []);
|
|
1227
|
+
return !model || !formatting ? null : /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
|
|
572
1228
|
value: {
|
|
573
1229
|
model,
|
|
574
1230
|
formatting,
|
|
@@ -587,23 +1243,22 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
587
1243
|
|
|
588
1244
|
// packages/plugins/plugin-sheet/src/components/Sheet/threads.tsx
|
|
589
1245
|
import { effect } from "@preact/signals-core";
|
|
590
|
-
import
|
|
1246
|
+
import React4, { useCallback, useEffect as useEffect3, useMemo as useMemo3 } from "react";
|
|
591
1247
|
import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
|
|
592
1248
|
import { debounce } from "@dxos/async";
|
|
593
|
-
import { fullyQualifiedId
|
|
1249
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
594
1250
|
import { Icon, useTranslation } from "@dxos/react-ui";
|
|
595
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
596
1251
|
var CommentIndicator = () => {
|
|
597
|
-
return /* @__PURE__ */
|
|
1252
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
598
1253
|
role: "none",
|
|
599
1254
|
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
600
1255
|
});
|
|
601
1256
|
};
|
|
602
1257
|
var ThreadedCellWrapper = ({ children }) => {
|
|
603
1258
|
const dispatch = useIntentDispatcher();
|
|
604
|
-
const [isHovered, setIsHovered] =
|
|
1259
|
+
const [isHovered, setIsHovered] = React4.useState(false);
|
|
605
1260
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
606
|
-
const handleClick =
|
|
1261
|
+
const handleClick = React4.useCallback((_event) => {
|
|
607
1262
|
void dispatch({
|
|
608
1263
|
action: LayoutAction.SET_LAYOUT,
|
|
609
1264
|
data: {
|
|
@@ -614,22 +1269,22 @@ var ThreadedCellWrapper = ({ children }) => {
|
|
|
614
1269
|
}, [
|
|
615
1270
|
dispatch
|
|
616
1271
|
]);
|
|
617
|
-
return /* @__PURE__ */
|
|
1272
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
618
1273
|
role: "none",
|
|
619
|
-
className:
|
|
1274
|
+
className: "relative h-full is-full",
|
|
620
1275
|
onMouseEnter: () => {
|
|
621
1276
|
setIsHovered(true);
|
|
622
1277
|
},
|
|
623
1278
|
onMouseLeave: () => {
|
|
624
1279
|
setIsHovered(false);
|
|
625
1280
|
}
|
|
626
|
-
}, /* @__PURE__ */
|
|
1281
|
+
}, /* @__PURE__ */ React4.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React4.createElement("div", {
|
|
627
1282
|
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
628
|
-
}, /* @__PURE__ */
|
|
1283
|
+
}, /* @__PURE__ */ React4.createElement("button", {
|
|
629
1284
|
className: "ch-button text-xs min-bs-0 p-1",
|
|
630
1285
|
onClick: handleClick,
|
|
631
1286
|
"aria-label": t("open comment for sheet cell")
|
|
632
|
-
}, /* @__PURE__ */
|
|
1287
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
633
1288
|
icon: "ph--chat--regular",
|
|
634
1289
|
"aria-hidden": true
|
|
635
1290
|
}))), children);
|
|
@@ -638,7 +1293,7 @@ var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
|
638
1293
|
return {
|
|
639
1294
|
type: "comment",
|
|
640
1295
|
cellIndex,
|
|
641
|
-
decorate: (props) => /* @__PURE__ */
|
|
1296
|
+
decorate: (props) => /* @__PURE__ */ React4.createElement(ThreadedCellWrapper, props)
|
|
642
1297
|
};
|
|
643
1298
|
};
|
|
644
1299
|
var useUpdateCursorOnThreadSelection = () => {
|
|
@@ -646,7 +1301,7 @@ var useUpdateCursorOnThreadSelection = () => {
|
|
|
646
1301
|
const handleScrollIntoView = useCallback(({ action, data }) => {
|
|
647
1302
|
switch (action) {
|
|
648
1303
|
case LayoutAction.SCROLL_INTO_VIEW: {
|
|
649
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !==
|
|
1304
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId(model.sheet)) {
|
|
650
1305
|
return;
|
|
651
1306
|
}
|
|
652
1307
|
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
@@ -662,10 +1317,10 @@ var useUpdateCursorOnThreadSelection = () => {
|
|
|
662
1317
|
var useSelectThreadOnCursorChange = () => {
|
|
663
1318
|
const { cursor, model } = useSheetContext();
|
|
664
1319
|
const dispatch = useIntentDispatcher();
|
|
665
|
-
const activeThreads =
|
|
1320
|
+
const activeThreads = useMemo3(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
666
1321
|
JSON.stringify(model.sheet.threads)
|
|
667
1322
|
]);
|
|
668
|
-
const activeThreadAddresses =
|
|
1323
|
+
const activeThreadAddresses = useMemo3(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
669
1324
|
activeThreads,
|
|
670
1325
|
model.sheet
|
|
671
1326
|
]);
|
|
@@ -681,7 +1336,7 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
681
1336
|
{
|
|
682
1337
|
action: "dxos.org/plugin/thread/action/select",
|
|
683
1338
|
data: {
|
|
684
|
-
current:
|
|
1339
|
+
current: fullyQualifiedId(closestThread)
|
|
685
1340
|
}
|
|
686
1341
|
}
|
|
687
1342
|
]);
|
|
@@ -693,7 +1348,7 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
693
1348
|
activeThreadAddresses,
|
|
694
1349
|
model.sheet
|
|
695
1350
|
]);
|
|
696
|
-
const debounced =
|
|
1351
|
+
const debounced = useMemo3(() => {
|
|
697
1352
|
return debounce((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
698
1353
|
}, [
|
|
699
1354
|
selectClosestThread
|
|
@@ -710,10 +1365,10 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
710
1365
|
};
|
|
711
1366
|
var useThreadDecorations = () => {
|
|
712
1367
|
const { decorations, model } = useSheetContext();
|
|
713
|
-
const sheet =
|
|
1368
|
+
const sheet = useMemo3(() => model.sheet, [
|
|
714
1369
|
model.sheet
|
|
715
1370
|
]);
|
|
716
|
-
const sheetId =
|
|
1371
|
+
const sheetId = useMemo3(() => fullyQualifiedId(sheet), [
|
|
717
1372
|
sheet
|
|
718
1373
|
]);
|
|
719
1374
|
useEffect3(() => {
|
|
@@ -786,7 +1441,7 @@ var scrollIntoView = (scrollContainer, el) => {
|
|
|
786
1441
|
|
|
787
1442
|
// packages/plugins/plugin-sheet/src/components/CellEditor/CellEditor.tsx
|
|
788
1443
|
import { EditorView, keymap } from "@codemirror/view";
|
|
789
|
-
import
|
|
1444
|
+
import React5 from "react";
|
|
790
1445
|
import { useThemeContext } from "@dxos/react-ui";
|
|
791
1446
|
import { createBasicExtensions, createThemeExtensions, preventNewline, useTextEditor } from "@dxos/react-ui-editor";
|
|
792
1447
|
var editorKeys = ({ onNav, onClose }) => {
|
|
@@ -834,20 +1489,60 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
834
1489
|
{
|
|
835
1490
|
key: "Enter",
|
|
836
1491
|
run: (editor) => {
|
|
837
|
-
onClose(editor.state.doc.toString()
|
|
1492
|
+
onClose(editor.state.doc.toString(), {
|
|
1493
|
+
key: "Enter"
|
|
1494
|
+
});
|
|
1495
|
+
return true;
|
|
1496
|
+
},
|
|
1497
|
+
shift: (editor) => {
|
|
1498
|
+
onClose(editor.state.doc.toString(), {
|
|
1499
|
+
key: "Enter",
|
|
1500
|
+
shift: true
|
|
1501
|
+
});
|
|
1502
|
+
return true;
|
|
1503
|
+
}
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
key: "Tab",
|
|
1507
|
+
run: (editor) => {
|
|
1508
|
+
onClose(editor.state.doc.toString(), {
|
|
1509
|
+
key: "Tab"
|
|
1510
|
+
});
|
|
1511
|
+
return true;
|
|
1512
|
+
},
|
|
1513
|
+
shift: (editor) => {
|
|
1514
|
+
onClose(editor.state.doc.toString(), {
|
|
1515
|
+
key: "Tab",
|
|
1516
|
+
shift: true
|
|
1517
|
+
});
|
|
838
1518
|
return true;
|
|
839
1519
|
}
|
|
840
1520
|
},
|
|
841
1521
|
{
|
|
842
1522
|
key: "Escape",
|
|
843
1523
|
run: () => {
|
|
844
|
-
onClose(void 0
|
|
1524
|
+
onClose(void 0, {
|
|
1525
|
+
key: "Escape"
|
|
1526
|
+
});
|
|
845
1527
|
return true;
|
|
846
1528
|
}
|
|
847
1529
|
}
|
|
848
1530
|
]);
|
|
849
1531
|
};
|
|
850
|
-
var
|
|
1532
|
+
var editorVariants = {
|
|
1533
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
1534
|
+
legacy: {
|
|
1535
|
+
root: "flex w-full",
|
|
1536
|
+
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1537
|
+
content: "!px-2 !py-1"
|
|
1538
|
+
},
|
|
1539
|
+
grid: {
|
|
1540
|
+
root: "absolute z-[1]",
|
|
1541
|
+
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1542
|
+
content: "!border !border-transparent !p-0.5"
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
851
1546
|
const { themeMode } = useThemeContext();
|
|
852
1547
|
const { parentRef } = useTextEditor(() => {
|
|
853
1548
|
return {
|
|
@@ -874,32 +1569,40 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
874
1569
|
themeMode,
|
|
875
1570
|
slots: {
|
|
876
1571
|
editor: {
|
|
877
|
-
className:
|
|
1572
|
+
className: editorVariants[variant].editor
|
|
878
1573
|
},
|
|
879
1574
|
content: {
|
|
880
|
-
className:
|
|
1575
|
+
className: editorVariants[variant].content
|
|
881
1576
|
}
|
|
882
1577
|
}
|
|
883
1578
|
})
|
|
884
1579
|
]
|
|
885
1580
|
};
|
|
886
1581
|
}, [
|
|
887
|
-
extension
|
|
1582
|
+
extension,
|
|
1583
|
+
autoFocus,
|
|
1584
|
+
value,
|
|
1585
|
+
variant,
|
|
1586
|
+
onBlur
|
|
888
1587
|
]);
|
|
889
|
-
return /* @__PURE__ */
|
|
1588
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
890
1589
|
ref: parentRef,
|
|
891
|
-
className:
|
|
1590
|
+
className: editorVariants[variant].root,
|
|
1591
|
+
style: box,
|
|
1592
|
+
...gridId && {
|
|
1593
|
+
"data-grid": gridId
|
|
1594
|
+
}
|
|
892
1595
|
});
|
|
893
1596
|
};
|
|
894
1597
|
|
|
895
1598
|
// packages/plugins/plugin-sheet/src/components/CellEditor/extension.ts
|
|
896
1599
|
import { acceptCompletion, autocompletion, completionStatus, startCompletion } from "@codemirror/autocomplete";
|
|
897
1600
|
import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
898
|
-
import { Facet } from "@codemirror/state";
|
|
899
1601
|
import { ViewPlugin, keymap as keymap2 } from "@codemirror/view";
|
|
900
1602
|
import { tags } from "@lezer/highlight";
|
|
901
1603
|
import { spreadsheet } from "codemirror-lang-spreadsheet";
|
|
902
|
-
import {
|
|
1604
|
+
import { singleValueFacet } from "@dxos/react-ui-editor/state";
|
|
1605
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
903
1606
|
var highlightStyles = HighlightStyle.define([
|
|
904
1607
|
// Function.
|
|
905
1608
|
{
|
|
@@ -930,7 +1633,7 @@ var highlightStyles = HighlightStyle.define([
|
|
|
930
1633
|
class: "text-unAccent"
|
|
931
1634
|
}
|
|
932
1635
|
]);
|
|
933
|
-
var languageFacet =
|
|
1636
|
+
var languageFacet = singleValueFacet();
|
|
934
1637
|
var sheetExtension = ({ functions = [] }) => {
|
|
935
1638
|
const { extension, language } = spreadsheet({
|
|
936
1639
|
idiom: "en-US",
|
|
@@ -1010,13 +1713,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1010
1713
|
// NOTE: Useful for debugging.
|
|
1011
1714
|
closeOnBlur: false,
|
|
1012
1715
|
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
|
-
)
|
|
1716
|
+
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
1717
|
}),
|
|
1021
1718
|
keymap2.of([
|
|
1022
1719
|
{
|
|
@@ -1053,7 +1750,7 @@ var rangeExtension = (onInit) => {
|
|
|
1053
1750
|
update(view2) {
|
|
1054
1751
|
const { anchor } = view2.state.selection.ranges[0];
|
|
1055
1752
|
activeRange = void 0;
|
|
1056
|
-
const
|
|
1753
|
+
const language = view2.state.facet(languageFacet);
|
|
1057
1754
|
const { topNode } = language.parser.parse(view2.state.doc.toString());
|
|
1058
1755
|
visitTree(topNode, ({ type, from, to }) => {
|
|
1059
1756
|
if (from <= anchor && to >= anchor) {
|
|
@@ -1105,7 +1802,7 @@ var visitTree = (node, callback) => {
|
|
|
1105
1802
|
};
|
|
1106
1803
|
|
|
1107
1804
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
1108
|
-
var
|
|
1805
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1109
1806
|
var fragments = {
|
|
1110
1807
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1111
1808
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1113,16 +1810,16 @@ var fragments = {
|
|
|
1113
1810
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1114
1811
|
};
|
|
1115
1812
|
var SheetRoot = ({ children, ...props }) => {
|
|
1116
|
-
return /* @__PURE__ */
|
|
1813
|
+
return /* @__PURE__ */ React6.createElement(SheetContextProvider, props, children);
|
|
1117
1814
|
};
|
|
1118
|
-
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows,
|
|
1815
|
+
var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
1119
1816
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1120
1817
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1121
1818
|
useThreads();
|
|
1122
|
-
const [rows, setRows] =
|
|
1819
|
+
const [rows, setRows] = useState5([
|
|
1123
1820
|
...model.sheet.rows
|
|
1124
1821
|
]);
|
|
1125
|
-
const [columns, setColumns] =
|
|
1822
|
+
const [columns, setColumns] = useState5([
|
|
1126
1823
|
...model.sheet.columns
|
|
1127
1824
|
]);
|
|
1128
1825
|
useEffect4(() => {
|
|
@@ -1178,8 +1875,8 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
|
|
|
1178
1875
|
...model.sheet.columns
|
|
1179
1876
|
]);
|
|
1180
1877
|
};
|
|
1181
|
-
const [rowSizes, setRowSizes] =
|
|
1182
|
-
const [columnSizes, setColumnSizes] =
|
|
1878
|
+
const [rowSizes, setRowSizes] = useState5();
|
|
1879
|
+
const [columnSizes, setColumnSizes] = useState5();
|
|
1183
1880
|
useEffect4(() => {
|
|
1184
1881
|
const rowAccessor = createDocAccessor(model.sheet, [
|
|
1185
1882
|
"rowMeta"
|
|
@@ -1229,48 +1926,48 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
|
|
|
1229
1926
|
}));
|
|
1230
1927
|
}
|
|
1231
1928
|
};
|
|
1232
|
-
return /* @__PURE__ */
|
|
1929
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1233
1930
|
role: "none",
|
|
1234
|
-
className:
|
|
1235
|
-
}, /* @__PURE__ */
|
|
1931
|
+
className: mx2("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1932
|
+
}, /* @__PURE__ */ React6.createElement(GridCorner, {
|
|
1236
1933
|
onClick: () => {
|
|
1237
1934
|
setCursor(void 0);
|
|
1238
1935
|
setRange(void 0);
|
|
1239
1936
|
setEditing(false);
|
|
1240
1937
|
}
|
|
1241
|
-
}), /* @__PURE__ */
|
|
1938
|
+
}), /* @__PURE__ */ React6.createElement(SheetColumns, {
|
|
1242
1939
|
ref: columnsRef,
|
|
1243
1940
|
columns,
|
|
1244
1941
|
sizes: columnSizes,
|
|
1245
|
-
selected: cursor?.
|
|
1246
|
-
onSelect: (
|
|
1942
|
+
selected: cursor?.col,
|
|
1943
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1247
1944
|
row: -1,
|
|
1248
|
-
|
|
1945
|
+
col
|
|
1249
1946
|
}),
|
|
1250
1947
|
onResize: handleResizeColumn,
|
|
1251
1948
|
onMove: handleMoveColumns
|
|
1252
|
-
}), /* @__PURE__ */
|
|
1949
|
+
}), /* @__PURE__ */ React6.createElement(SheetRows, {
|
|
1253
1950
|
ref: rowsRef,
|
|
1254
1951
|
rows,
|
|
1255
1952
|
sizes: rowSizes,
|
|
1256
1953
|
selected: cursor?.row,
|
|
1257
1954
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1258
1955
|
row,
|
|
1259
|
-
|
|
1956
|
+
col: -1
|
|
1260
1957
|
}),
|
|
1261
1958
|
onResize: handleResizeRow,
|
|
1262
1959
|
onMove: handleMoveRows
|
|
1263
|
-
}), /* @__PURE__ */
|
|
1960
|
+
}), /* @__PURE__ */ React6.createElement(SheetGrid, {
|
|
1264
1961
|
ref: contentRef,
|
|
1265
1962
|
size: {
|
|
1266
1963
|
numRows: numRows ?? rows.length,
|
|
1267
|
-
|
|
1964
|
+
numCols: numCols ?? columns.length
|
|
1268
1965
|
},
|
|
1269
1966
|
rows,
|
|
1270
1967
|
columns,
|
|
1271
1968
|
rowSizes,
|
|
1272
1969
|
columnSizes
|
|
1273
|
-
}), /* @__PURE__ */
|
|
1970
|
+
}), /* @__PURE__ */ React6.createElement(GridCorner, null), /* @__PURE__ */ React6.createElement(SheetStatusBar, null));
|
|
1274
1971
|
});
|
|
1275
1972
|
var useScrollHandlers = () => {
|
|
1276
1973
|
const rowsRef = useRef(null);
|
|
@@ -1313,13 +2010,13 @@ var useScrollHandlers = () => {
|
|
|
1313
2010
|
};
|
|
1314
2011
|
};
|
|
1315
2012
|
var GridCorner = (props) => {
|
|
1316
|
-
return /* @__PURE__ */
|
|
2013
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1317
2014
|
className: fragments.axis,
|
|
1318
2015
|
...props
|
|
1319
2016
|
});
|
|
1320
2017
|
};
|
|
1321
2018
|
var MovingOverlay = ({ label }) => {
|
|
1322
|
-
return /* @__PURE__ */
|
|
2019
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1323
2020
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1324
2021
|
}, label);
|
|
1325
2022
|
};
|
|
@@ -1339,7 +2036,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1339
2036
|
});
|
|
1340
2037
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
1341
2038
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
1342
|
-
const [active, setActive] =
|
|
2039
|
+
const [active, setActive] = useState5(null);
|
|
1343
2040
|
const handleDragStart = ({ active: active2 }) => {
|
|
1344
2041
|
setActive(active2);
|
|
1345
2042
|
};
|
|
@@ -1363,18 +2060,18 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1363
2060
|
}
|
|
1364
2061
|
return transform;
|
|
1365
2062
|
};
|
|
1366
|
-
return /* @__PURE__ */
|
|
2063
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1367
2064
|
className: "relative flex grow overflow-hidden"
|
|
1368
|
-
}, /* @__PURE__ */
|
|
1369
|
-
className:
|
|
2065
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2066
|
+
className: mx2("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1370
2067
|
style: {
|
|
1371
2068
|
width: axisWidth
|
|
1372
2069
|
}
|
|
1373
|
-
}), /* @__PURE__ */
|
|
2070
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1374
2071
|
ref: forwardRef2,
|
|
1375
2072
|
role: "rowheader",
|
|
1376
2073
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1377
|
-
}, /* @__PURE__ */
|
|
2074
|
+
}, /* @__PURE__ */ React6.createElement(DndContext, {
|
|
1378
2075
|
sensors,
|
|
1379
2076
|
modifiers: [
|
|
1380
2077
|
restrictToVerticalAxis,
|
|
@@ -1382,12 +2079,12 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1382
2079
|
],
|
|
1383
2080
|
onDragStart: handleDragStart,
|
|
1384
2081
|
onDragEnd: handleDragEnd
|
|
1385
|
-
}, /* @__PURE__ */
|
|
2082
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1386
2083
|
className: "flex flex-col",
|
|
1387
2084
|
style: {
|
|
1388
2085
|
width: axisWidth
|
|
1389
2086
|
}
|
|
1390
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
2087
|
+
}, rows.map((idx, index) => /* @__PURE__ */ React6.createElement(GridRowCell, {
|
|
1391
2088
|
key: idx,
|
|
1392
2089
|
idx,
|
|
1393
2090
|
index,
|
|
@@ -1397,7 +2094,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
|
|
|
1397
2094
|
selected: selected === index,
|
|
1398
2095
|
onResize,
|
|
1399
2096
|
onSelect
|
|
1400
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2097
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
|
|
1401
2098
|
label: String(active.data.current.index + 1)
|
|
1402
2099
|
})), document.body))));
|
|
1403
2100
|
});
|
|
@@ -1415,8 +2112,8 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1415
2112
|
}
|
|
1416
2113
|
});
|
|
1417
2114
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
1418
|
-
const [initialSize, setInitialSize] =
|
|
1419
|
-
const [resizing, setResizing] =
|
|
2115
|
+
const [initialSize, setInitialSize] = useState5(size);
|
|
2116
|
+
const [resizing, setResizing] = useState5(false);
|
|
1420
2117
|
const scrollHandler = useRef();
|
|
1421
2118
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1422
2119
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
@@ -1438,7 +2135,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1438
2135
|
onResize?.(idx, initialSize + height, true);
|
|
1439
2136
|
setResizing(false);
|
|
1440
2137
|
};
|
|
1441
|
-
return /* @__PURE__ */
|
|
2138
|
+
return /* @__PURE__ */ React6.createElement(Resizable, {
|
|
1442
2139
|
enable: {
|
|
1443
2140
|
bottom: resize
|
|
1444
2141
|
},
|
|
@@ -1450,17 +2147,17 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1450
2147
|
onResizeStart: handleResizeStart,
|
|
1451
2148
|
onResize: handleResize,
|
|
1452
2149
|
onResizeStop: handleResizeStop
|
|
1453
|
-
}, /* @__PURE__ */
|
|
2150
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1454
2151
|
ref: setNodeRef,
|
|
1455
2152
|
...attributes,
|
|
1456
2153
|
...listeners,
|
|
1457
|
-
className:
|
|
2154
|
+
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
2155
|
onClick: () => onSelect?.(index)
|
|
1459
|
-
}, /* @__PURE__ */
|
|
2156
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
1460
2157
|
className: "flex w-full justify-center"
|
|
1461
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2158
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
|
|
1462
2159
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1463
|
-
}), resizing && /* @__PURE__ */
|
|
2160
|
+
}), resizing && /* @__PURE__ */ React6.createElement("div", {
|
|
1464
2161
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1465
2162
|
})));
|
|
1466
2163
|
};
|
|
@@ -1473,7 +2170,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1473
2170
|
});
|
|
1474
2171
|
const keyboardSensor = useSensor(KeyboardSensor, {});
|
|
1475
2172
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
|
|
1476
|
-
const [active, setActive] =
|
|
2173
|
+
const [active, setActive] = useState5(null);
|
|
1477
2174
|
const handleDragStart = ({ active: active2 }) => {
|
|
1478
2175
|
setActive(active2);
|
|
1479
2176
|
};
|
|
@@ -1497,18 +2194,18 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1497
2194
|
}
|
|
1498
2195
|
return transform;
|
|
1499
2196
|
};
|
|
1500
|
-
return /* @__PURE__ */
|
|
2197
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1501
2198
|
className: "relative flex grow overflow-hidden"
|
|
1502
|
-
}, /* @__PURE__ */
|
|
1503
|
-
className:
|
|
2199
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2200
|
+
className: mx2("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
1504
2201
|
style: {
|
|
1505
2202
|
height: axisHeight
|
|
1506
2203
|
}
|
|
1507
|
-
}), /* @__PURE__ */
|
|
2204
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1508
2205
|
ref: forwardRef2,
|
|
1509
2206
|
role: "columnheader",
|
|
1510
2207
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1511
|
-
}, /* @__PURE__ */
|
|
2208
|
+
}, /* @__PURE__ */ React6.createElement(DndContext, {
|
|
1512
2209
|
autoScroll: {
|
|
1513
2210
|
enabled: true
|
|
1514
2211
|
},
|
|
@@ -1519,12 +2216,12 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1519
2216
|
],
|
|
1520
2217
|
onDragStart: handleDragStart,
|
|
1521
2218
|
onDragEnd: handleDragEnd
|
|
1522
|
-
}, /* @__PURE__ */
|
|
2219
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1523
2220
|
className: "flex h-full",
|
|
1524
2221
|
style: {
|
|
1525
2222
|
height: axisHeight
|
|
1526
2223
|
}
|
|
1527
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2224
|
+
}, columns.map((idx, index) => /* @__PURE__ */ React6.createElement(GridColumnCell, {
|
|
1528
2225
|
key: idx,
|
|
1529
2226
|
idx,
|
|
1530
2227
|
index,
|
|
@@ -1534,7 +2231,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
|
|
|
1534
2231
|
selected: selected === index,
|
|
1535
2232
|
onResize,
|
|
1536
2233
|
onSelect
|
|
1537
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2234
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
|
|
1538
2235
|
label: columnLetter(active.data.current.index)
|
|
1539
2236
|
})), document.body))));
|
|
1540
2237
|
});
|
|
@@ -1552,8 +2249,8 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1552
2249
|
}
|
|
1553
2250
|
});
|
|
1554
2251
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
1555
|
-
const [initialSize, setInitialSize] =
|
|
1556
|
-
const [resizing, setResizing] =
|
|
2252
|
+
const [initialSize, setInitialSize] = useState5(size);
|
|
2253
|
+
const [resizing, setResizing] = useState5(false);
|
|
1557
2254
|
const scrollHandler = useRef();
|
|
1558
2255
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1559
2256
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
@@ -1575,7 +2272,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1575
2272
|
onResize?.(idx, initialSize + width, true);
|
|
1576
2273
|
setResizing(false);
|
|
1577
2274
|
};
|
|
1578
|
-
return /* @__PURE__ */
|
|
2275
|
+
return /* @__PURE__ */ React6.createElement(Resizable, {
|
|
1579
2276
|
enable: {
|
|
1580
2277
|
right: resize
|
|
1581
2278
|
},
|
|
@@ -1587,17 +2284,17 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1587
2284
|
onResizeStart: handleResizeStart,
|
|
1588
2285
|
onResize: handleResize,
|
|
1589
2286
|
onResizeStop: handleResizeStop
|
|
1590
|
-
}, /* @__PURE__ */
|
|
2287
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1591
2288
|
ref: setNodeRef,
|
|
1592
2289
|
...attributes,
|
|
1593
2290
|
...listeners,
|
|
1594
|
-
className:
|
|
2291
|
+
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
2292
|
onClick: () => onSelect?.(index)
|
|
1596
|
-
}, /* @__PURE__ */
|
|
2293
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
1597
2294
|
className: "flex w-full justify-center"
|
|
1598
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2295
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
|
|
1599
2296
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1600
|
-
}), resizing && /* @__PURE__ */
|
|
2297
|
+
}), resizing && /* @__PURE__ */ React6.createElement("div", {
|
|
1601
2298
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1602
2299
|
})));
|
|
1603
2300
|
};
|
|
@@ -1610,14 +2307,14 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1610
2307
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1611
2308
|
const initialText = useRef();
|
|
1612
2309
|
const quickEdit = useRef(false);
|
|
1613
|
-
const [, forceUpdate] =
|
|
2310
|
+
const [, forceUpdate] = useState5({});
|
|
1614
2311
|
useEffect4(() => {
|
|
1615
2312
|
const unsubscribe = model.update.on(() => {
|
|
1616
|
-
|
|
2313
|
+
log2("updated", {
|
|
1617
2314
|
id: model.id
|
|
1618
2315
|
}, {
|
|
1619
|
-
F:
|
|
1620
|
-
L:
|
|
2316
|
+
F: __dxlog_file4,
|
|
2317
|
+
L: 738,
|
|
1621
2318
|
S: void 0,
|
|
1622
2319
|
C: (f, a) => f(...a)
|
|
1623
2320
|
});
|
|
@@ -1734,19 +2431,18 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1734
2431
|
rowSizes,
|
|
1735
2432
|
columnSizes
|
|
1736
2433
|
});
|
|
1737
|
-
const id =
|
|
1738
|
-
const
|
|
1739
|
-
|
|
1740
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
2434
|
+
const id = fullyQualifiedId2(model.sheet);
|
|
2435
|
+
const { hasAttention } = useAttention(id);
|
|
2436
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1741
2437
|
ref: containerRef,
|
|
1742
2438
|
role: "grid",
|
|
1743
2439
|
className: "relative flex grow overflow-hidden"
|
|
1744
|
-
}, /* @__PURE__ */
|
|
1745
|
-
className:
|
|
1746
|
-
}), /* @__PURE__ */
|
|
2440
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
2441
|
+
className: mx2("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
2442
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
1747
2443
|
ref: scrollerRef,
|
|
1748
|
-
className:
|
|
1749
|
-
}, /* @__PURE__ */
|
|
2444
|
+
className: mx2("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2445
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1750
2446
|
className: "relative select-none",
|
|
1751
2447
|
style: {
|
|
1752
2448
|
width,
|
|
@@ -1754,10 +2450,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1754
2450
|
},
|
|
1755
2451
|
onClick: () => inputRef.current?.focus(),
|
|
1756
2452
|
...handlers
|
|
1757
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2453
|
+
}, scrollerRef.current && /* @__PURE__ */ React6.createElement(SelectionOverlay, {
|
|
1758
2454
|
root: scrollerRef.current
|
|
1759
2455
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1760
|
-
return columnRange.map(({
|
|
2456
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1761
2457
|
const style = {
|
|
1762
2458
|
position: "absolute",
|
|
1763
2459
|
top,
|
|
@@ -1767,7 +2463,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1767
2463
|
};
|
|
1768
2464
|
const cell = {
|
|
1769
2465
|
row,
|
|
1770
|
-
|
|
2466
|
+
col
|
|
1771
2467
|
};
|
|
1772
2468
|
const id2 = addressToA1Notation(cell);
|
|
1773
2469
|
const idx = addressToIndex(model.sheet, cell);
|
|
@@ -1803,7 +2499,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1803
2499
|
inputRef.current?.focus();
|
|
1804
2500
|
setEditing(false);
|
|
1805
2501
|
};
|
|
1806
|
-
return /* @__PURE__ */
|
|
2502
|
+
return /* @__PURE__ */ React6.createElement(GridCellEditor, {
|
|
1807
2503
|
key: idx,
|
|
1808
2504
|
value,
|
|
1809
2505
|
style,
|
|
@@ -1811,7 +2507,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1811
2507
|
onClose: handleClose
|
|
1812
2508
|
});
|
|
1813
2509
|
}
|
|
1814
|
-
return /* @__PURE__ */
|
|
2510
|
+
return /* @__PURE__ */ React6.createElement(SheetCell, {
|
|
1815
2511
|
key: id2,
|
|
1816
2512
|
id: id2,
|
|
1817
2513
|
cell,
|
|
@@ -1823,13 +2519,25 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
1823
2519
|
}
|
|
1824
2520
|
});
|
|
1825
2521
|
});
|
|
1826
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
2522
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(SheetInput, {
|
|
1827
2523
|
ref: inputRef,
|
|
1828
|
-
|
|
2524
|
+
id,
|
|
2525
|
+
onKeyDown: handleKeyDown
|
|
2526
|
+
}), document.body));
|
|
2527
|
+
});
|
|
2528
|
+
var SheetInput = /* @__PURE__ */ forwardRef(({ id, onKeyDown }, forwardedRef) => {
|
|
2529
|
+
const path = useAttentionPath();
|
|
2530
|
+
const attendableAttrs = useAttendableAttributes(id);
|
|
2531
|
+
return path.toReversed().reduce((acc, part) => {
|
|
2532
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
2533
|
+
[ATTENABLE_ATTRIBUTE]: part
|
|
2534
|
+
}, acc);
|
|
2535
|
+
}, /* @__PURE__ */ React6.createElement("input", {
|
|
2536
|
+
ref: forwardedRef,
|
|
1829
2537
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
1830
|
-
onKeyDown
|
|
2538
|
+
onKeyDown,
|
|
1831
2539
|
...attendableAttrs
|
|
1832
|
-
})
|
|
2540
|
+
}));
|
|
1833
2541
|
});
|
|
1834
2542
|
var SelectionOverlay = ({ root }) => {
|
|
1835
2543
|
const { range } = useSheetContext();
|
|
@@ -1844,7 +2552,7 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1844
2552
|
const b1 = getRelativeClientRect(root, c1);
|
|
1845
2553
|
const b2 = getRelativeClientRect(root, c2);
|
|
1846
2554
|
const bounds = getRectUnion(b1, b2);
|
|
1847
|
-
return /* @__PURE__ */
|
|
2555
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1848
2556
|
role: "none",
|
|
1849
2557
|
style: bounds,
|
|
1850
2558
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
@@ -1854,7 +2562,7 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1854
2562
|
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1855
2563
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1856
2564
|
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
1857
|
-
const decorationAddedClasses =
|
|
2565
|
+
const decorationAddedClasses = useMemo4(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
1858
2566
|
decorationsForCell
|
|
1859
2567
|
]);
|
|
1860
2568
|
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
@@ -1862,16 +2570,16 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1862
2570
|
return children;
|
|
1863
2571
|
}
|
|
1864
2572
|
const DecoratorComponent = decorate;
|
|
1865
|
-
return /* @__PURE__ */
|
|
1866
|
-
}, /* @__PURE__ */
|
|
2573
|
+
return /* @__PURE__ */ React6.createElement(DecoratorComponent, null, children);
|
|
2574
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1867
2575
|
role: "none",
|
|
1868
|
-
className:
|
|
2576
|
+
className: mx2("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
1869
2577
|
}, value));
|
|
1870
|
-
return /* @__PURE__ */
|
|
2578
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1871
2579
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1872
2580
|
role: "cell",
|
|
1873
2581
|
style,
|
|
1874
|
-
className:
|
|
2582
|
+
className: mx2("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1875
2583
|
"z-20",
|
|
1876
2584
|
fragments.cellSelected
|
|
1877
2585
|
], classNames),
|
|
@@ -1897,24 +2605,24 @@ var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
|
1897
2605
|
}, [
|
|
1898
2606
|
range
|
|
1899
2607
|
]);
|
|
1900
|
-
const extension =
|
|
2608
|
+
const extension = useMemo4(() => [
|
|
1901
2609
|
editorKeys({
|
|
1902
2610
|
onNav,
|
|
1903
2611
|
onClose
|
|
1904
2612
|
}),
|
|
1905
2613
|
sheetExtension({
|
|
1906
|
-
functions: model.
|
|
2614
|
+
functions: model.graph.getFunctions()
|
|
1907
2615
|
}),
|
|
1908
2616
|
rangeExtension((fn) => notifier.current = fn)
|
|
1909
2617
|
], [
|
|
1910
2618
|
model
|
|
1911
2619
|
]);
|
|
1912
|
-
return /* @__PURE__ */
|
|
2620
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1913
2621
|
role: "cell",
|
|
1914
2622
|
style,
|
|
1915
|
-
className:
|
|
2623
|
+
className: mx2("z-20 flex", fragments.cellSelected),
|
|
1916
2624
|
onClick: (ev) => ev.stopPropagation()
|
|
1917
|
-
}, /* @__PURE__ */
|
|
2625
|
+
}, /* @__PURE__ */ React6.createElement(CellEditor, {
|
|
1918
2626
|
autoFocus: true,
|
|
1919
2627
|
value,
|
|
1920
2628
|
extension
|
|
@@ -1927,29 +2635,29 @@ var SheetStatusBar = () => {
|
|
|
1927
2635
|
if (cursor) {
|
|
1928
2636
|
value = model.getCellValue(cursor);
|
|
1929
2637
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1930
|
-
value = model.
|
|
2638
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1931
2639
|
isFormula = true;
|
|
1932
2640
|
} else if (value != null) {
|
|
1933
2641
|
value = String(value);
|
|
1934
2642
|
}
|
|
1935
2643
|
}
|
|
1936
|
-
return /* @__PURE__ */
|
|
1937
|
-
className:
|
|
1938
|
-
}, /* @__PURE__ */
|
|
2644
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
2645
|
+
className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
2646
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1939
2647
|
className: "flex gap-4 items-center"
|
|
1940
|
-
}, /* @__PURE__ */
|
|
2648
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1941
2649
|
className: "flex w-16 items-center font-mono"
|
|
1942
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */
|
|
2650
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React6.createElement("div", {
|
|
1943
2651
|
className: "flex gap-2 items-center"
|
|
1944
|
-
}, /* @__PURE__ */
|
|
1945
|
-
className:
|
|
1946
|
-
}), /* @__PURE__ */
|
|
2652
|
+
}, /* @__PURE__ */ React6.createElement(FunctionIcon, {
|
|
2653
|
+
className: mx2("text-greenText", isFormula ? "visible" : "invisible")
|
|
2654
|
+
}), /* @__PURE__ */ React6.createElement("span", {
|
|
1947
2655
|
className: "font-mono"
|
|
1948
2656
|
}, value))));
|
|
1949
2657
|
};
|
|
1950
2658
|
var SheetDebug = () => {
|
|
1951
2659
|
const { model, cursor, range } = useSheetContext();
|
|
1952
|
-
const [, forceUpdate] =
|
|
2660
|
+
const [, forceUpdate] = useState5({});
|
|
1953
2661
|
useEffect4(() => {
|
|
1954
2662
|
const accessor = createDocAccessor(model.sheet, []);
|
|
1955
2663
|
const handleUpdate = () => forceUpdate({});
|
|
@@ -1961,9 +2669,9 @@ var SheetDebug = () => {
|
|
|
1961
2669
|
}, [
|
|
1962
2670
|
model
|
|
1963
2671
|
]);
|
|
1964
|
-
return /* @__PURE__ */
|
|
1965
|
-
className:
|
|
1966
|
-
}, /* @__PURE__ */
|
|
2672
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
2673
|
+
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")
|
|
2674
|
+
}, /* @__PURE__ */ React6.createElement("pre", {
|
|
1967
2675
|
className: "whitespace-pre-wrap"
|
|
1968
2676
|
}, JSON.stringify({
|
|
1969
2677
|
cursor,
|
|
@@ -1985,247 +2693,14 @@ var Sheet = {
|
|
|
1985
2693
|
Debug: SheetDebug
|
|
1986
2694
|
};
|
|
1987
2695
|
|
|
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
2696
|
export {
|
|
2228
|
-
|
|
2229
|
-
|
|
2697
|
+
ComputeGraphContextProvider,
|
|
2698
|
+
createSheet,
|
|
2699
|
+
addressToIndex,
|
|
2700
|
+
compareIndexPositions,
|
|
2701
|
+
useComputeGraph,
|
|
2702
|
+
useSheetContext,
|
|
2703
|
+
Sheet,
|
|
2704
|
+
SheetContainer
|
|
2230
2705
|
};
|
|
2231
|
-
//# sourceMappingURL=
|
|
2706
|
+
//# sourceMappingURL=chunk-KK3XL37M.mjs.map
|