@dxos/plugin-sheet 0.6.11 → 0.6.12-main.568932b
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-T2QWJOFD.mjs +262 -0
- package/dist/lib/browser/SheetContainer-T2QWJOFD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FUAGSXA4.mjs → chunk-5ZMVZYGB.mjs} +24 -19
- package/dist/lib/browser/chunk-5ZMVZYGB.mjs.map +7 -0
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +2966 -0
- 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/browser/{SheetContainer-U4H5D34A.mjs → chunk-ZL2V5UJR.mjs} +1182 -249
- package/dist/lib/browser/chunk-ZL2V5UJR.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 +96 -60
- 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-PV5ET4UJ.cjs +280 -0
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-AXQV3ZT5.cjs → chunk-2K53Z2TU.cjs} +1212 -287
- package/dist/lib/node/chunk-2K53Z2TU.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-5XPK2V4A.cjs} +418 -678
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-STAVQ2JE.cjs} +28 -24
- package/dist/lib/node/chunk-STAVQ2JE.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 +106 -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-FOZD2WLT.mjs +263 -0
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2HAM45RC.mjs +88 -0
- package/dist/lib/node-esm/chunk-2HAM45RC.mjs.map +7 -0
- package/dist/lib/{browser/chunk-D5AGLXJP.mjs → node-esm/chunk-5WPZCXNS.mjs} +411 -678
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +17 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QEUCIHIN.mjs +2706 -0
- package/dist/lib/node-esm/chunk-QEUCIHIN.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 +285 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +21 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +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/decorations.d.ts +24 -0
- package/dist/types/src/components/Sheet/decorations.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +8 -7
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts +2 -0
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +2 -3
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +19 -3
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +18 -13
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +43 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +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 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +10 -65
- 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/translations.d.ts +17 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +86 -5
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +55 -47
- package/src/SheetPlugin.tsx +50 -73
- package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +4 -6
- 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 +52 -88
- package/src/components/Sheet/Sheet.tsx +87 -32
- package/src/components/Sheet/decorations.ts +62 -0
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +18 -80
- package/src/components/Sheet/threads.tsx +205 -0
- package/src/components/SheetContainer.tsx +68 -16
- package/src/components/Toolbar/Toolbar.tsx +53 -12
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/{model → defs}/types.ts +24 -14
- package/src/defs/util.ts +151 -0
- 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 -3
- package/src/model/sheet-model.test.ts +57 -0
- package/src/model/sheet-model.ts +416 -0
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +68 -0
- package/src/translations.ts +6 -1
- package/src/types.ts +35 -10
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +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 +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
|
@@ -26,46 +26,230 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var chunk_2K53Z2TU_exports = {};
|
|
30
|
+
__export(chunk_2K53Z2TU_exports, {
|
|
31
|
+
ComputeGraphContextProvider: () => ComputeGraphContextProvider,
|
|
32
|
+
Sheet: () => Sheet,
|
|
33
|
+
SheetContainer: () => SheetContainer,
|
|
34
|
+
addressToIndex: () => addressToIndex,
|
|
35
|
+
compareIndexPositions: () => compareIndexPositions,
|
|
36
|
+
createSheet: () => createSheet,
|
|
37
|
+
useComputeGraph: () => useComputeGraph,
|
|
38
|
+
useSheetContext: () => useSheetContext
|
|
32
39
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
|
|
38
|
-
var import_react = __toESM(require("react"));
|
|
39
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
40
|
+
module.exports = __toCommonJS(chunk_2K53Z2TU_exports);
|
|
41
|
+
var import_chunk_STAVQ2JE = require("./chunk-STAVQ2JE.cjs");
|
|
42
|
+
var import_chunk_BNARJ5GM = require("./chunk-BNARJ5GM.cjs");
|
|
43
|
+
var import_chunk_5XPK2V4A = require("./chunk-5XPK2V4A.cjs");
|
|
40
44
|
var import_core = require("@dnd-kit/core");
|
|
41
45
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
42
46
|
var import_utilities = require("@dnd-kit/utilities");
|
|
43
|
-
var
|
|
47
|
+
var import_react = require("@phosphor-icons/react");
|
|
44
48
|
var import_re_resizable = require("re-resizable");
|
|
45
|
-
var
|
|
49
|
+
var import_react2 = __toESM(require("react"));
|
|
46
50
|
var import_react_dom = require("react-dom");
|
|
47
51
|
var import_react_resize_detector = require("react-resize-detector");
|
|
48
52
|
var import_async = require("@dxos/async");
|
|
49
53
|
var import_echo = require("@dxos/client/echo");
|
|
50
54
|
var import_log = require("@dxos/log");
|
|
51
55
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var import_react5 = require("react");
|
|
55
|
-
var import_react6 = __toESM(require("react"));
|
|
56
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
57
|
+
var import_react3 = require("react");
|
|
56
58
|
var import_invariant = require("@dxos/invariant");
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
+
var import_crypto = require("@dxos/crypto");
|
|
60
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
61
|
+
var import_react4 = require("react");
|
|
62
|
+
var import_react5 = __toESM(require("react"));
|
|
63
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
64
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
65
|
+
var import_react6 = require("react");
|
|
66
|
+
var import_debug = require("@dxos/debug");
|
|
67
|
+
var import_react_hooks = require("@dxos/react-hooks");
|
|
59
68
|
var import_react7 = __toESM(require("react"));
|
|
69
|
+
var import_react8 = __toESM(require("react"));
|
|
70
|
+
var import_react9 = require("react");
|
|
71
|
+
var import_async2 = require("@dxos/async");
|
|
72
|
+
var import_context = require("@dxos/context");
|
|
73
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
74
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
75
|
+
var import_keys = require("@dxos/keys");
|
|
76
|
+
var import_log2 = require("@dxos/log");
|
|
77
|
+
var import_hyperformula = require("#hyperformula");
|
|
78
|
+
var import_react10 = require("react");
|
|
79
|
+
var import_signals_core = require("@preact/signals-core");
|
|
80
|
+
var import_react11 = __toESM(require("react"));
|
|
81
|
+
var import_app_framework = require("@dxos/app-framework");
|
|
82
|
+
var import_async3 = require("@dxos/async");
|
|
83
|
+
var import_echo2 = require("@dxos/react-client/echo");
|
|
60
84
|
var import_react_ui = require("@dxos/react-ui");
|
|
85
|
+
var import_view = require("@codemirror/view");
|
|
86
|
+
var import_react12 = __toESM(require("react"));
|
|
87
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
61
88
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
62
89
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
63
90
|
var import_language = require("@codemirror/language");
|
|
64
|
-
var import_state = require("@codemirror/state");
|
|
65
91
|
var import_view2 = require("@codemirror/view");
|
|
66
92
|
var import_highlight = require("@lezer/highlight");
|
|
67
93
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
68
|
-
var
|
|
94
|
+
var import_state = require("@dxos/react-ui-editor/state");
|
|
95
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
96
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
97
|
+
var DEFAULT_ROWS = 50;
|
|
98
|
+
var DEFAULT_COLUMNS = 26;
|
|
99
|
+
var MAX_ROWS = 500;
|
|
100
|
+
var MAX_COLUMNS = 26 * 2;
|
|
101
|
+
var posEquals = (a, b) => {
|
|
102
|
+
return a?.col === b?.col && a?.row === b?.row;
|
|
103
|
+
};
|
|
104
|
+
var columnLetter = (col) => {
|
|
105
|
+
(0, import_invariant.invariant)(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
106
|
+
F: __dxlog_file,
|
|
107
|
+
L: 26,
|
|
108
|
+
S: void 0,
|
|
109
|
+
A: [
|
|
110
|
+
"col < MAX_COLUMNS",
|
|
111
|
+
"`Invalid column: ${col}`"
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
115
|
+
};
|
|
116
|
+
var addressToA1Notation = ({ col, row }) => {
|
|
117
|
+
return `${columnLetter(col)}${row + 1}`;
|
|
118
|
+
};
|
|
119
|
+
var addressFromA1Notation = (ref) => {
|
|
120
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
121
|
+
(0, import_invariant.invariant)(match, `Invalid notation: ${ref}`, {
|
|
122
|
+
F: __dxlog_file,
|
|
123
|
+
L: 40,
|
|
124
|
+
S: void 0,
|
|
125
|
+
A: [
|
|
126
|
+
"match",
|
|
127
|
+
"`Invalid notation: ${ref}`"
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
row: parseInt(match[2], 10) - 1,
|
|
132
|
+
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
var rangeToA1Notation = (range) => {
|
|
136
|
+
return [
|
|
137
|
+
range?.from && addressToA1Notation(range?.from),
|
|
138
|
+
range?.to && addressToA1Notation(range?.to)
|
|
139
|
+
].filter(Boolean).join(":");
|
|
140
|
+
};
|
|
141
|
+
var inRange = (range, cell) => {
|
|
142
|
+
if (!range) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
const { from, to } = range;
|
|
146
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (!from || !to) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const { col: c1, row: r1 } = from;
|
|
153
|
+
const { col: c2, row: r2 } = to;
|
|
154
|
+
const cMin = Math.min(c1, c2);
|
|
155
|
+
const cMax = Math.max(c1, c2);
|
|
156
|
+
const rMin = Math.min(r1, r2);
|
|
157
|
+
const rMax = Math.max(r1, r2);
|
|
158
|
+
const { col, row } = cell;
|
|
159
|
+
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
160
|
+
};
|
|
161
|
+
var ApiError = class extends Error {
|
|
162
|
+
};
|
|
163
|
+
var ReadonlyException = class extends ApiError {
|
|
164
|
+
};
|
|
165
|
+
var RangeException = class extends ApiError {
|
|
166
|
+
constructor(n) {
|
|
167
|
+
super();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var createIndex = (length = 8) => {
|
|
171
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
172
|
+
const charactersLength = characters.length;
|
|
173
|
+
const randomBuffer = (0, import_crypto.randomBytes)(length);
|
|
174
|
+
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
175
|
+
};
|
|
176
|
+
var createIndices = (length) => Array.from({
|
|
177
|
+
length
|
|
178
|
+
}).map(() => createIndex());
|
|
179
|
+
var insertIndices = (indices, i, n, max) => {
|
|
180
|
+
if (i + n > max) {
|
|
181
|
+
throw new RangeException(i + n);
|
|
182
|
+
}
|
|
183
|
+
const idx = createIndices(n);
|
|
184
|
+
indices.splice(i, 0, ...idx);
|
|
185
|
+
};
|
|
186
|
+
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
187
|
+
if (!sheet.rows.length) {
|
|
188
|
+
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
189
|
+
}
|
|
190
|
+
if (!sheet.columns.length) {
|
|
191
|
+
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var createSheet = ({ name, cells, ...size } = {}) => {
|
|
195
|
+
const sheet = (0, import_echo_schema.create)(import_chunk_STAVQ2JE.SheetType, {
|
|
196
|
+
name,
|
|
197
|
+
cells: {},
|
|
198
|
+
rows: [],
|
|
199
|
+
columns: [],
|
|
200
|
+
rowMeta: {},
|
|
201
|
+
columnMeta: {},
|
|
202
|
+
formatting: {}
|
|
203
|
+
});
|
|
204
|
+
initialize(sheet, size);
|
|
205
|
+
if (cells) {
|
|
206
|
+
Object.entries(cells).forEach(([key, { value }]) => {
|
|
207
|
+
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
208
|
+
sheet.cells[idx] = {
|
|
209
|
+
value
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return sheet;
|
|
214
|
+
};
|
|
215
|
+
var addressToIndex = (sheet, cell) => {
|
|
216
|
+
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
217
|
+
};
|
|
218
|
+
var addressFromIndex = (sheet, idx) => {
|
|
219
|
+
const [column, row] = idx.split("@");
|
|
220
|
+
return {
|
|
221
|
+
col: sheet.columns.indexOf(column),
|
|
222
|
+
row: sheet.rows.indexOf(row)
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
var rangeFromIndex = (sheet, idx) => {
|
|
226
|
+
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
227
|
+
return {
|
|
228
|
+
from,
|
|
229
|
+
to
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
var closest = (cursor, cells) => {
|
|
233
|
+
let closestCell;
|
|
234
|
+
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
235
|
+
for (const cell of cells) {
|
|
236
|
+
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
237
|
+
if (distance < closestDistance) {
|
|
238
|
+
closestCell = cell;
|
|
239
|
+
closestDistance = distance;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return closestCell;
|
|
243
|
+
};
|
|
244
|
+
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
245
|
+
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
246
|
+
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
247
|
+
if (rowA !== rowB) {
|
|
248
|
+
return rowA - rowB;
|
|
249
|
+
} else {
|
|
250
|
+
return columnA - columnB;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
69
253
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
70
254
|
var axisHeight = 34;
|
|
71
255
|
var minWidth = 40;
|
|
@@ -76,8 +260,8 @@ var defaultWidth = 200;
|
|
|
76
260
|
var defaultHeight = minHeight;
|
|
77
261
|
var CELL_DATA_KEY = "cell";
|
|
78
262
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
79
|
-
const [rowPositions, setRowPositions] = (0,
|
|
80
|
-
(0,
|
|
263
|
+
const [rowPositions, setRowPositions] = (0, import_react3.useState)([]);
|
|
264
|
+
(0, import_react3.useEffect)(() => {
|
|
81
265
|
if (!rowSizes) {
|
|
82
266
|
return;
|
|
83
267
|
}
|
|
@@ -96,8 +280,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
96
280
|
rows,
|
|
97
281
|
rowSizes
|
|
98
282
|
]);
|
|
99
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
100
|
-
(0,
|
|
283
|
+
const [columnPositions, setColumnPositions] = (0, import_react3.useState)([]);
|
|
284
|
+
(0, import_react3.useEffect)(() => {
|
|
101
285
|
if (!columns) {
|
|
102
286
|
return;
|
|
103
287
|
}
|
|
@@ -107,7 +291,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
107
291
|
const left = x;
|
|
108
292
|
x += width2 - 1;
|
|
109
293
|
return {
|
|
110
|
-
|
|
294
|
+
col: i,
|
|
111
295
|
left,
|
|
112
296
|
width: width2
|
|
113
297
|
};
|
|
@@ -118,11 +302,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
118
302
|
]);
|
|
119
303
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
120
304
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
121
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
305
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react3.useState)({
|
|
122
306
|
rowRange: [],
|
|
123
307
|
columnRange: []
|
|
124
308
|
});
|
|
125
|
-
(0,
|
|
309
|
+
(0, import_react3.useEffect)(() => {
|
|
126
310
|
const handleScroll = () => {
|
|
127
311
|
if (!scroller) {
|
|
128
312
|
return;
|
|
@@ -182,12 +366,12 @@ var getCellAtPointer = (event) => {
|
|
|
182
366
|
if (root) {
|
|
183
367
|
const value = root.dataset[CELL_DATA_KEY];
|
|
184
368
|
if (value) {
|
|
185
|
-
return
|
|
369
|
+
return addressFromA1Notation(value);
|
|
186
370
|
}
|
|
187
371
|
}
|
|
188
372
|
};
|
|
189
373
|
var getCellElement = (root, cell) => {
|
|
190
|
-
const pos =
|
|
374
|
+
const pos = addressToA1Notation(cell);
|
|
191
375
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
192
376
|
};
|
|
193
377
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -209,14 +393,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
209
393
|
break;
|
|
210
394
|
}
|
|
211
395
|
case "ArrowLeft": {
|
|
212
|
-
if (opposite.
|
|
213
|
-
opposite.
|
|
396
|
+
if (opposite.col > 0) {
|
|
397
|
+
opposite.col -= 1;
|
|
214
398
|
}
|
|
215
399
|
break;
|
|
216
400
|
}
|
|
217
401
|
case "ArrowRight": {
|
|
218
|
-
if (opposite.
|
|
219
|
-
opposite.
|
|
402
|
+
if (opposite.col < size.numCols - 1) {
|
|
403
|
+
opposite.col += 1;
|
|
220
404
|
}
|
|
221
405
|
break;
|
|
222
406
|
}
|
|
@@ -234,18 +418,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
234
418
|
cursor: next
|
|
235
419
|
};
|
|
236
420
|
};
|
|
237
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
421
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
238
422
|
switch (ev.key) {
|
|
239
423
|
case "ArrowUp":
|
|
240
424
|
if (cursor === void 0) {
|
|
241
425
|
return {
|
|
242
426
|
row: 0,
|
|
243
|
-
|
|
427
|
+
col: 0
|
|
244
428
|
};
|
|
245
429
|
} else if (cursor.row > 0) {
|
|
246
430
|
return {
|
|
247
431
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
248
|
-
|
|
432
|
+
col: cursor.col
|
|
249
433
|
};
|
|
250
434
|
}
|
|
251
435
|
break;
|
|
@@ -253,12 +437,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
253
437
|
if (cursor === void 0) {
|
|
254
438
|
return {
|
|
255
439
|
row: 0,
|
|
256
|
-
|
|
440
|
+
col: 0
|
|
257
441
|
};
|
|
258
442
|
} else if (cursor.row < numRows - 1) {
|
|
259
443
|
return {
|
|
260
444
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
261
|
-
|
|
445
|
+
col: cursor.col
|
|
262
446
|
};
|
|
263
447
|
}
|
|
264
448
|
break;
|
|
@@ -266,12 +450,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
266
450
|
if (cursor === void 0) {
|
|
267
451
|
return {
|
|
268
452
|
row: 0,
|
|
269
|
-
|
|
453
|
+
col: 0
|
|
270
454
|
};
|
|
271
|
-
} else if (cursor.
|
|
455
|
+
} else if (cursor.col > 0) {
|
|
272
456
|
return {
|
|
273
457
|
row: cursor.row,
|
|
274
|
-
|
|
458
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
275
459
|
};
|
|
276
460
|
}
|
|
277
461
|
break;
|
|
@@ -279,30 +463,30 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
279
463
|
if (cursor === void 0) {
|
|
280
464
|
return {
|
|
281
465
|
row: 0,
|
|
282
|
-
|
|
466
|
+
col: 0
|
|
283
467
|
};
|
|
284
|
-
} else if (cursor.
|
|
468
|
+
} else if (cursor.col < numCols - 1) {
|
|
285
469
|
return {
|
|
286
470
|
row: cursor.row,
|
|
287
|
-
|
|
471
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
288
472
|
};
|
|
289
473
|
}
|
|
290
474
|
break;
|
|
291
475
|
case "Home":
|
|
292
476
|
return {
|
|
293
477
|
row: 0,
|
|
294
|
-
|
|
478
|
+
col: 0
|
|
295
479
|
};
|
|
296
480
|
case "End":
|
|
297
481
|
return {
|
|
298
482
|
row: numRows - 1,
|
|
299
|
-
|
|
483
|
+
col: numCols - 1
|
|
300
484
|
};
|
|
301
485
|
}
|
|
302
486
|
};
|
|
303
487
|
var useRangeSelect = (cb) => {
|
|
304
|
-
const [from, setFrom] = (0,
|
|
305
|
-
const [to, setTo] = (0,
|
|
488
|
+
const [from, setFrom] = (0, import_react4.useState)();
|
|
489
|
+
const [to, setTo] = (0, import_react4.useState)();
|
|
306
490
|
const onMouseDown = (ev) => {
|
|
307
491
|
const current = getCellAtPointer(ev);
|
|
308
492
|
setFrom(current);
|
|
@@ -315,7 +499,7 @@ var useRangeSelect = (cb) => {
|
|
|
315
499
|
const onMouseMove = (ev) => {
|
|
316
500
|
if (from) {
|
|
317
501
|
let current = getCellAtPointer(ev);
|
|
318
|
-
if (
|
|
502
|
+
if (posEquals(current, from)) {
|
|
319
503
|
current = void 0;
|
|
320
504
|
}
|
|
321
505
|
setTo(current);
|
|
@@ -328,7 +512,7 @@ var useRangeSelect = (cb) => {
|
|
|
328
512
|
const onMouseUp = (ev) => {
|
|
329
513
|
if (from) {
|
|
330
514
|
let current = getCellAtPointer(ev);
|
|
331
|
-
if (
|
|
515
|
+
if (posEquals(current, from)) {
|
|
332
516
|
current = void 0;
|
|
333
517
|
}
|
|
334
518
|
setFrom(void 0);
|
|
@@ -351,27 +535,86 @@ var useRangeSelect = (cb) => {
|
|
|
351
535
|
}
|
|
352
536
|
};
|
|
353
537
|
};
|
|
538
|
+
var createDecorations = () => {
|
|
539
|
+
const { decorations } = (0, import_echo_schema2.create)({
|
|
540
|
+
decorations: {}
|
|
541
|
+
});
|
|
542
|
+
const addDecoration = (cellIndex, decorator) => {
|
|
543
|
+
decorations[cellIndex] = [
|
|
544
|
+
...decorations[cellIndex] || [],
|
|
545
|
+
decorator
|
|
546
|
+
];
|
|
547
|
+
};
|
|
548
|
+
const removeDecoration = (cellIndex, type) => {
|
|
549
|
+
if (type) {
|
|
550
|
+
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
551
|
+
} else {
|
|
552
|
+
delete decorations[cellIndex];
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const getDecorationsForCell = (cellIndex) => {
|
|
556
|
+
return decorations[cellIndex];
|
|
557
|
+
};
|
|
558
|
+
const getAllDecorations = () => {
|
|
559
|
+
const result = [];
|
|
560
|
+
for (const decoratorArray of Object.values(decorations)) {
|
|
561
|
+
for (const decorator of decoratorArray) {
|
|
562
|
+
result.push(decorator);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return result;
|
|
566
|
+
};
|
|
567
|
+
return {
|
|
568
|
+
addDecoration,
|
|
569
|
+
removeDecoration,
|
|
570
|
+
getDecorationsForCell,
|
|
571
|
+
getAllDecorations
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
var ComputeGraphContext = /* @__PURE__ */ (0, import_react8.createContext)(void 0);
|
|
575
|
+
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
576
|
+
return /* @__PURE__ */ import_react8.default.createElement(ComputeGraphContext.Provider, {
|
|
577
|
+
value: {
|
|
578
|
+
registry
|
|
579
|
+
}
|
|
580
|
+
}, children);
|
|
581
|
+
};
|
|
582
|
+
var SheetContainer = import_react7.default.lazy(() => import("./SheetContainer-PV5ET4UJ.cjs"));
|
|
583
|
+
var useComputeGraph = (space) => {
|
|
584
|
+
const { registry } = (0, import_react6.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
|
|
585
|
+
const [graph] = (0, import_react_hooks.useAsyncState)(async () => {
|
|
586
|
+
if (space) {
|
|
587
|
+
const graph2 = registry.getOrCreateGraph(space);
|
|
588
|
+
await graph2.open();
|
|
589
|
+
return graph2;
|
|
590
|
+
}
|
|
591
|
+
}, [
|
|
592
|
+
space,
|
|
593
|
+
registry
|
|
594
|
+
]);
|
|
595
|
+
return graph;
|
|
596
|
+
};
|
|
354
597
|
var FormattingModel = class {
|
|
355
|
-
constructor(
|
|
356
|
-
this.
|
|
598
|
+
constructor(_model) {
|
|
599
|
+
this._model = _model;
|
|
357
600
|
}
|
|
358
601
|
/**
|
|
359
602
|
* Get formatted string value and className for cell.
|
|
360
603
|
*/
|
|
361
604
|
getFormatting(cell) {
|
|
362
|
-
const value = this.
|
|
605
|
+
const value = this._model.getValue(cell);
|
|
363
606
|
if (value === void 0 || value === null) {
|
|
364
607
|
return {};
|
|
365
608
|
}
|
|
366
609
|
const locales = void 0;
|
|
367
|
-
const idx = this.
|
|
368
|
-
let formatting = this.
|
|
610
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
611
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
369
612
|
const classNames = [
|
|
370
613
|
...formatting?.classNames ?? []
|
|
371
614
|
];
|
|
372
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
373
|
-
const range = this.
|
|
374
|
-
if (
|
|
615
|
+
for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
|
|
616
|
+
const range = rangeFromIndex(this._model.sheet, idx2);
|
|
617
|
+
if (inRange(range, cell)) {
|
|
375
618
|
if (_formatting.classNames) {
|
|
376
619
|
classNames.push(..._formatting.classNames);
|
|
377
620
|
}
|
|
@@ -381,9 +624,9 @@ var FormattingModel = class {
|
|
|
381
624
|
}
|
|
382
625
|
}
|
|
383
626
|
const defaultNumber = "justify-end font-mono";
|
|
384
|
-
const type = formatting?.type ?? this.
|
|
627
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
385
628
|
switch (type) {
|
|
386
|
-
case
|
|
629
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Boolean: {
|
|
387
630
|
return {
|
|
388
631
|
value: value.toLocaleString().toUpperCase(),
|
|
389
632
|
classNames: [
|
|
@@ -395,7 +638,7 @@ var FormattingModel = class {
|
|
|
395
638
|
//
|
|
396
639
|
// Numbers.
|
|
397
640
|
//
|
|
398
|
-
case
|
|
641
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Number: {
|
|
399
642
|
return {
|
|
400
643
|
value: value.toLocaleString(locales),
|
|
401
644
|
classNames: [
|
|
@@ -404,7 +647,7 @@ var FormattingModel = class {
|
|
|
404
647
|
]
|
|
405
648
|
};
|
|
406
649
|
}
|
|
407
|
-
case
|
|
650
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Percent: {
|
|
408
651
|
return {
|
|
409
652
|
value: value * 100 + "%",
|
|
410
653
|
classNames: [
|
|
@@ -413,7 +656,7 @@ var FormattingModel = class {
|
|
|
413
656
|
]
|
|
414
657
|
};
|
|
415
658
|
}
|
|
416
|
-
case
|
|
659
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Currency: {
|
|
417
660
|
return {
|
|
418
661
|
value: value.toLocaleString(locales, {
|
|
419
662
|
style: "currency",
|
|
@@ -430,22 +673,22 @@ var FormattingModel = class {
|
|
|
430
673
|
//
|
|
431
674
|
// Dates.
|
|
432
675
|
//
|
|
433
|
-
case
|
|
434
|
-
const date = this.
|
|
676
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.DateTime: {
|
|
677
|
+
const date = this._model.toLocalDate(value);
|
|
435
678
|
return {
|
|
436
679
|
value: date.toLocaleString(locales),
|
|
437
680
|
classNames
|
|
438
681
|
};
|
|
439
682
|
}
|
|
440
|
-
case
|
|
441
|
-
const date = this.
|
|
683
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Date: {
|
|
684
|
+
const date = this._model.toLocalDate(value);
|
|
442
685
|
return {
|
|
443
686
|
value: date.toLocaleDateString(locales),
|
|
444
687
|
classNames
|
|
445
688
|
};
|
|
446
689
|
}
|
|
447
|
-
case
|
|
448
|
-
const date = this.
|
|
690
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Time: {
|
|
691
|
+
const date = this._model.toLocalDate(value);
|
|
449
692
|
return {
|
|
450
693
|
value: date.toLocaleTimeString(locales),
|
|
451
694
|
classNames
|
|
@@ -460,83 +703,539 @@ var FormattingModel = class {
|
|
|
460
703
|
}
|
|
461
704
|
}
|
|
462
705
|
};
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
706
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
707
|
+
var typeMap = {
|
|
708
|
+
BOOLEAN: import_chunk_STAVQ2JE.ValueTypeEnum.Boolean,
|
|
709
|
+
NUMBER_RAW: import_chunk_STAVQ2JE.ValueTypeEnum.Number,
|
|
710
|
+
NUMBER_PERCENT: import_chunk_STAVQ2JE.ValueTypeEnum.Percent,
|
|
711
|
+
NUMBER_CURRENCY: import_chunk_STAVQ2JE.ValueTypeEnum.Currency,
|
|
712
|
+
NUMBER_DATETIME: import_chunk_STAVQ2JE.ValueTypeEnum.DateTime,
|
|
713
|
+
NUMBER_DATE: import_chunk_STAVQ2JE.ValueTypeEnum.Date,
|
|
714
|
+
NUMBER_TIME: import_chunk_STAVQ2JE.ValueTypeEnum.Time
|
|
715
|
+
};
|
|
716
|
+
var getTopLeft = (range) => {
|
|
717
|
+
const to = range.to ?? range.from;
|
|
718
|
+
return {
|
|
719
|
+
row: Math.min(range.from.row, to.row),
|
|
720
|
+
col: Math.min(range.from.col, to.col)
|
|
721
|
+
};
|
|
478
722
|
};
|
|
479
|
-
var
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
723
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
724
|
+
sheet,
|
|
725
|
+
row: cell.row,
|
|
726
|
+
col: cell.col
|
|
727
|
+
});
|
|
728
|
+
var toModelRange = (sheet, range) => ({
|
|
729
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
730
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
731
|
+
});
|
|
732
|
+
var SheetModel = class extends import_context.Resource {
|
|
733
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
734
|
+
super();
|
|
735
|
+
this._graph = _graph;
|
|
736
|
+
this._sheet = _sheet;
|
|
737
|
+
this._options = _options;
|
|
738
|
+
this.id = `model-${import_keys.PublicKey.random().truncate()}`;
|
|
739
|
+
this.update = new import_async2.Event();
|
|
740
|
+
}
|
|
741
|
+
get graph() {
|
|
742
|
+
return this._graph;
|
|
743
|
+
}
|
|
744
|
+
get sheet() {
|
|
745
|
+
return this._sheet;
|
|
746
|
+
}
|
|
747
|
+
get readonly() {
|
|
748
|
+
return this._options.readonly;
|
|
749
|
+
}
|
|
750
|
+
get bounds() {
|
|
751
|
+
return {
|
|
752
|
+
rows: this._sheet.rows.length,
|
|
753
|
+
columns: this._sheet.columns.length
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Initialize sheet and engine.
|
|
758
|
+
*/
|
|
759
|
+
async _open() {
|
|
760
|
+
(0, import_log2.log)("initialize", {
|
|
761
|
+
id: this.id
|
|
762
|
+
}, {
|
|
763
|
+
F: __dxlog_file2,
|
|
764
|
+
L: 104,
|
|
765
|
+
S: this,
|
|
766
|
+
C: (f, a) => f(...a)
|
|
767
|
+
});
|
|
768
|
+
initialize(this._sheet);
|
|
769
|
+
this._node = this._graph.getOrCreateNode((0, import_chunk_5XPK2V4A.createSheetName)({
|
|
770
|
+
type: (0, import_echo_schema3.getTypename)(this._sheet),
|
|
771
|
+
id: this._sheet.id
|
|
772
|
+
}));
|
|
773
|
+
await this._node.open();
|
|
774
|
+
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
775
|
+
this._ctx.onDispose(unsubscribe);
|
|
776
|
+
this.reset();
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Update engine.
|
|
780
|
+
* NOTE: This resets the undo history.
|
|
781
|
+
* @deprecated
|
|
782
|
+
*/
|
|
783
|
+
reset() {
|
|
784
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
785
|
+
F: __dxlog_file2,
|
|
786
|
+
L: 124,
|
|
787
|
+
S: this,
|
|
788
|
+
A: [
|
|
789
|
+
"this._node",
|
|
790
|
+
""
|
|
791
|
+
]
|
|
792
|
+
});
|
|
793
|
+
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
794
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
795
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
796
|
+
F: __dxlog_file2,
|
|
797
|
+
L: 127,
|
|
798
|
+
S: this,
|
|
799
|
+
A: [
|
|
800
|
+
"this._node",
|
|
801
|
+
""
|
|
802
|
+
]
|
|
803
|
+
});
|
|
804
|
+
const { col, row } = addressFromIndex(this._sheet, key);
|
|
805
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
806
|
+
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
807
|
+
}
|
|
808
|
+
this._node.graph.hf.setCellContents({
|
|
809
|
+
sheet: this._node.sheetId,
|
|
810
|
+
row,
|
|
811
|
+
col
|
|
812
|
+
}, value);
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Recalculate formulas.
|
|
817
|
+
* NOTE: This resets the undo history.
|
|
818
|
+
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
819
|
+
* @deprecated
|
|
820
|
+
*/
|
|
821
|
+
// TODO(burdon): Remove.
|
|
822
|
+
recalculate() {
|
|
823
|
+
this._node?.graph.hf.rebuildAndRecalculate();
|
|
824
|
+
}
|
|
825
|
+
insertRows(i, n = 1) {
|
|
826
|
+
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
827
|
+
this.reset();
|
|
828
|
+
}
|
|
829
|
+
insertColumns(i, n = 1) {
|
|
830
|
+
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
831
|
+
this.reset();
|
|
832
|
+
}
|
|
833
|
+
//
|
|
834
|
+
// Undoable actions.
|
|
835
|
+
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
836
|
+
//
|
|
837
|
+
/**
|
|
838
|
+
* Clear range of values.
|
|
839
|
+
*/
|
|
840
|
+
clear(range) {
|
|
841
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
842
|
+
F: __dxlog_file2,
|
|
843
|
+
L: 169,
|
|
844
|
+
S: this,
|
|
845
|
+
A: [
|
|
846
|
+
"this._node",
|
|
847
|
+
""
|
|
848
|
+
]
|
|
849
|
+
});
|
|
850
|
+
const topLeft = getTopLeft(range);
|
|
851
|
+
const values = this._iterRange(range, () => null);
|
|
852
|
+
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
853
|
+
this._iterRange(range, (cell) => {
|
|
854
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
855
|
+
delete this._sheet.cells[idx];
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
cut(range) {
|
|
859
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
860
|
+
F: __dxlog_file2,
|
|
861
|
+
L: 180,
|
|
862
|
+
S: this,
|
|
863
|
+
A: [
|
|
864
|
+
"this._node",
|
|
865
|
+
""
|
|
866
|
+
]
|
|
867
|
+
});
|
|
868
|
+
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
869
|
+
this._iterRange(range, (cell) => {
|
|
870
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
871
|
+
delete this._sheet.cells[idx];
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
copy(range) {
|
|
875
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
876
|
+
F: __dxlog_file2,
|
|
877
|
+
L: 189,
|
|
878
|
+
S: this,
|
|
879
|
+
A: [
|
|
880
|
+
"this._node",
|
|
881
|
+
""
|
|
882
|
+
]
|
|
883
|
+
});
|
|
884
|
+
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
885
|
+
}
|
|
886
|
+
paste(cell) {
|
|
887
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
888
|
+
F: __dxlog_file2,
|
|
889
|
+
L: 194,
|
|
890
|
+
S: this,
|
|
891
|
+
A: [
|
|
892
|
+
"this._node",
|
|
893
|
+
""
|
|
894
|
+
]
|
|
895
|
+
});
|
|
896
|
+
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
897
|
+
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
898
|
+
for (const change of changes) {
|
|
899
|
+
if (change instanceof import_hyperformula.ExportedCellChange) {
|
|
900
|
+
const { address, newValue } = change;
|
|
901
|
+
const idx = addressToIndex(this._sheet, {
|
|
902
|
+
row: address.row,
|
|
903
|
+
col: address.col
|
|
904
|
+
});
|
|
905
|
+
this._sheet.cells[idx] = {
|
|
906
|
+
value: newValue
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
// TODO(burdon): Display undo/redo state.
|
|
913
|
+
undo() {
|
|
914
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
915
|
+
F: __dxlog_file2,
|
|
916
|
+
L: 209,
|
|
917
|
+
S: this,
|
|
918
|
+
A: [
|
|
919
|
+
"this._node",
|
|
920
|
+
""
|
|
921
|
+
]
|
|
922
|
+
});
|
|
923
|
+
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
924
|
+
this._node.graph.hf.undo();
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
redo() {
|
|
928
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
929
|
+
F: __dxlog_file2,
|
|
930
|
+
L: 217,
|
|
931
|
+
S: this,
|
|
932
|
+
A: [
|
|
933
|
+
"this._node",
|
|
934
|
+
""
|
|
935
|
+
]
|
|
936
|
+
});
|
|
937
|
+
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
938
|
+
this._node.graph.hf.redo();
|
|
483
939
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Get value from sheet.
|
|
943
|
+
*/
|
|
944
|
+
getCellValue(cell) {
|
|
945
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
946
|
+
return this._sheet.cells[idx]?.value ?? null;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Get value as a string for editing.
|
|
950
|
+
*/
|
|
951
|
+
getCellText(cell) {
|
|
952
|
+
const value = this.getCellValue(cell);
|
|
953
|
+
if (value == null) {
|
|
954
|
+
return void 0;
|
|
955
|
+
}
|
|
956
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
957
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
487
958
|
} else {
|
|
488
|
-
return
|
|
959
|
+
return String(value);
|
|
489
960
|
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Get array of raw values from sheet.
|
|
964
|
+
*/
|
|
965
|
+
getCellValues(range) {
|
|
966
|
+
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Gets the regular or computed value from the engine.
|
|
970
|
+
*/
|
|
971
|
+
getValue(cell) {
|
|
972
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
973
|
+
F: __dxlog_file2,
|
|
974
|
+
L: 260,
|
|
975
|
+
S: this,
|
|
976
|
+
A: [
|
|
977
|
+
"this._node",
|
|
978
|
+
""
|
|
979
|
+
]
|
|
980
|
+
});
|
|
981
|
+
const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
982
|
+
if (value instanceof import_hyperformula.DetailedCellError) {
|
|
983
|
+
return value.toString();
|
|
497
984
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
985
|
+
return value;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Get value type.
|
|
989
|
+
*/
|
|
990
|
+
getValueType(cell) {
|
|
991
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
992
|
+
F: __dxlog_file2,
|
|
993
|
+
L: 273,
|
|
994
|
+
S: this,
|
|
995
|
+
A: [
|
|
996
|
+
"this._node",
|
|
997
|
+
""
|
|
998
|
+
]
|
|
999
|
+
});
|
|
1000
|
+
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
1001
|
+
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
1002
|
+
return typeMap[type];
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Sets the value, updating the sheet and engine.
|
|
1006
|
+
*/
|
|
1007
|
+
setValue(cell, value) {
|
|
1008
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1009
|
+
F: __dxlog_file2,
|
|
1010
|
+
L: 283,
|
|
1011
|
+
S: this,
|
|
1012
|
+
A: [
|
|
1013
|
+
"this._node",
|
|
1014
|
+
""
|
|
1015
|
+
]
|
|
1016
|
+
});
|
|
1017
|
+
if (this._options.readonly) {
|
|
1018
|
+
throw new ReadonlyException();
|
|
1019
|
+
}
|
|
1020
|
+
let refresh = false;
|
|
1021
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
1022
|
+
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
1023
|
+
refresh = true;
|
|
1024
|
+
}
|
|
1025
|
+
if (cell.col >= this._sheet.columns.length) {
|
|
1026
|
+
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
1027
|
+
refresh = true;
|
|
1028
|
+
}
|
|
1029
|
+
if (refresh) {
|
|
1030
|
+
this.reset();
|
|
1031
|
+
}
|
|
1032
|
+
this._node.graph.hf.setCellContents({
|
|
1033
|
+
sheet: this._node.sheetId,
|
|
1034
|
+
row: cell.row,
|
|
1035
|
+
col: cell.col
|
|
1036
|
+
}, [
|
|
1037
|
+
[
|
|
1038
|
+
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
1039
|
+
]
|
|
1040
|
+
]);
|
|
1041
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
1042
|
+
if (value === void 0 || value === null) {
|
|
1043
|
+
delete this._sheet.cells[idx];
|
|
501
1044
|
} else {
|
|
502
|
-
|
|
1045
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1046
|
+
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1047
|
+
}
|
|
1048
|
+
this._sheet.cells[idx] = {
|
|
1049
|
+
value
|
|
1050
|
+
};
|
|
503
1051
|
}
|
|
504
|
-
}
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Sets values from a simple map.
|
|
1055
|
+
*/
|
|
1056
|
+
setValues(values) {
|
|
1057
|
+
Object.entries(values).forEach(([key, { value }]) => {
|
|
1058
|
+
this.setValue(addressFromA1Notation(key), value);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Iterate range.
|
|
1063
|
+
*/
|
|
1064
|
+
_iterRange(range, cb) {
|
|
1065
|
+
const to = range.to ?? range.from;
|
|
1066
|
+
const rowRange = [
|
|
1067
|
+
Math.min(range.from.row, to.row),
|
|
1068
|
+
Math.max(range.from.row, to.row)
|
|
1069
|
+
];
|
|
1070
|
+
const columnRange = [
|
|
1071
|
+
Math.min(range.from.col, to.col),
|
|
1072
|
+
Math.max(range.from.col, to.col)
|
|
1073
|
+
];
|
|
1074
|
+
const rows = [];
|
|
1075
|
+
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
1076
|
+
const rowCells = [];
|
|
1077
|
+
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
1078
|
+
const value = cb({
|
|
1079
|
+
row,
|
|
1080
|
+
col: column
|
|
1081
|
+
});
|
|
1082
|
+
if (value !== void 0) {
|
|
1083
|
+
rowCells.push(value);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
rows.push(rowCells);
|
|
1087
|
+
}
|
|
1088
|
+
return rows;
|
|
1089
|
+
}
|
|
1090
|
+
// TODO(burdon): Delete index.
|
|
1091
|
+
_deleteIndices(indices, i, n) {
|
|
1092
|
+
throw new Error("Not implemented");
|
|
1093
|
+
}
|
|
1094
|
+
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
1095
|
+
_moveIndices(indices, i, j, n) {
|
|
1096
|
+
throw new Error("Not implemented");
|
|
1097
|
+
}
|
|
1098
|
+
//
|
|
1099
|
+
// Indices.
|
|
1100
|
+
//
|
|
1101
|
+
/**
|
|
1102
|
+
* Map from A1 notation to indices.
|
|
1103
|
+
*/
|
|
1104
|
+
mapFormulaRefsToIndices(formula) {
|
|
1105
|
+
(0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
|
|
1106
|
+
F: __dxlog_file2,
|
|
1107
|
+
L: 372,
|
|
1108
|
+
S: this,
|
|
1109
|
+
A: [
|
|
1110
|
+
"formula.charAt(0) === '='",
|
|
1111
|
+
""
|
|
1112
|
+
]
|
|
1113
|
+
});
|
|
1114
|
+
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1115
|
+
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Map from indices to A1 notation.
|
|
1120
|
+
*/
|
|
1121
|
+
mapFormulaIndicesToRefs(formula) {
|
|
1122
|
+
(0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
|
|
1123
|
+
F: __dxlog_file2,
|
|
1124
|
+
L: 382,
|
|
1125
|
+
S: this,
|
|
1126
|
+
A: [
|
|
1127
|
+
"formula.charAt(0) === '='",
|
|
1128
|
+
""
|
|
1129
|
+
]
|
|
1130
|
+
});
|
|
1131
|
+
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1132
|
+
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
//
|
|
1136
|
+
// Values
|
|
1137
|
+
//
|
|
1138
|
+
/**
|
|
1139
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1140
|
+
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1141
|
+
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1142
|
+
*/
|
|
1143
|
+
toLocalDate(num) {
|
|
1144
|
+
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1145
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1146
|
+
}
|
|
1147
|
+
toDateTime(num) {
|
|
1148
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1149
|
+
F: __dxlog_file2,
|
|
1150
|
+
L: 403,
|
|
1151
|
+
S: this,
|
|
1152
|
+
A: [
|
|
1153
|
+
"this._node",
|
|
1154
|
+
""
|
|
1155
|
+
]
|
|
1156
|
+
});
|
|
1157
|
+
return this._node.graph.hf.numberToDateTime(num);
|
|
1158
|
+
}
|
|
1159
|
+
toDate(num) {
|
|
1160
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1161
|
+
F: __dxlog_file2,
|
|
1162
|
+
L: 408,
|
|
1163
|
+
S: this,
|
|
1164
|
+
A: [
|
|
1165
|
+
"this._node",
|
|
1166
|
+
""
|
|
1167
|
+
]
|
|
1168
|
+
});
|
|
1169
|
+
return this._node.graph.hf.numberToDate(num);
|
|
1170
|
+
}
|
|
1171
|
+
toTime(num) {
|
|
1172
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1173
|
+
F: __dxlog_file2,
|
|
1174
|
+
L: 413,
|
|
1175
|
+
S: this,
|
|
1176
|
+
A: [
|
|
1177
|
+
"this._node",
|
|
1178
|
+
""
|
|
1179
|
+
]
|
|
1180
|
+
});
|
|
1181
|
+
return this._node.graph.hf.numberToTime(num);
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
var useFormattingModel = (model) => {
|
|
1185
|
+
return (0, import_react9.useMemo)(() => model && new FormattingModel(model), [
|
|
1186
|
+
model
|
|
1187
|
+
]);
|
|
505
1188
|
};
|
|
506
|
-
var
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
(0, import_react6.useEffect)(() => {
|
|
1189
|
+
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1190
|
+
const [model, setModel] = (0, import_react10.useState)();
|
|
1191
|
+
(0, import_react10.useEffect)(() => {
|
|
1192
|
+
if (!graph || !sheet) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
513
1195
|
let model2;
|
|
514
|
-
let formatting2;
|
|
515
1196
|
const t = setTimeout(async () => {
|
|
516
|
-
model2 = new
|
|
517
|
-
readonly
|
|
518
|
-
mapFormulaBindingToId,
|
|
519
|
-
mapFormulaBindingFromId
|
|
1197
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1198
|
+
readonly
|
|
520
1199
|
});
|
|
521
|
-
await model2.
|
|
522
|
-
|
|
523
|
-
setModels([
|
|
524
|
-
model2,
|
|
525
|
-
formatting2
|
|
526
|
-
]);
|
|
1200
|
+
await model2.open();
|
|
1201
|
+
setModel(model2);
|
|
527
1202
|
});
|
|
528
1203
|
return () => {
|
|
529
1204
|
clearTimeout(t);
|
|
530
|
-
void model2?.
|
|
1205
|
+
void model2?.close();
|
|
531
1206
|
};
|
|
532
1207
|
}, [
|
|
533
1208
|
graph,
|
|
1209
|
+
sheet,
|
|
534
1210
|
readonly
|
|
535
1211
|
]);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
1212
|
+
return model;
|
|
1213
|
+
};
|
|
1214
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1215
|
+
var SheetContext = /* @__PURE__ */ (0, import_react5.createContext)(null);
|
|
1216
|
+
var useSheetContext = () => {
|
|
1217
|
+
const context = (0, import_react5.useContext)(SheetContext);
|
|
1218
|
+
(0, import_invariant2.invariant)(context, void 0, {
|
|
1219
|
+
F: __dxlog_file3,
|
|
1220
|
+
L: 43,
|
|
1221
|
+
S: void 0,
|
|
1222
|
+
A: [
|
|
1223
|
+
"context",
|
|
1224
|
+
""
|
|
1225
|
+
]
|
|
1226
|
+
});
|
|
1227
|
+
return context;
|
|
1228
|
+
};
|
|
1229
|
+
var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
1230
|
+
const model = useSheetModel(graph, sheet, {
|
|
1231
|
+
readonly
|
|
1232
|
+
});
|
|
1233
|
+
const formatting = useFormattingModel(model);
|
|
1234
|
+
const [cursor, setCursor] = (0, import_react5.useState)();
|
|
1235
|
+
const [range, setRange] = (0, import_react5.useState)();
|
|
1236
|
+
const [editing, setEditing] = (0, import_react5.useState)(false);
|
|
1237
|
+
const decorations = (0, import_react5.useMemo)(() => createDecorations(), []);
|
|
1238
|
+
return !model || !formatting ? null : /* @__PURE__ */ import_react5.default.createElement(SheetContext.Provider, {
|
|
540
1239
|
value: {
|
|
541
1240
|
model,
|
|
542
1241
|
formatting,
|
|
@@ -547,10 +1246,168 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
547
1246
|
editing,
|
|
548
1247
|
setEditing,
|
|
549
1248
|
// TODO(burdon): Change to event.
|
|
550
|
-
onInfo
|
|
1249
|
+
onInfo,
|
|
1250
|
+
decorations
|
|
551
1251
|
}
|
|
552
1252
|
}, children);
|
|
553
1253
|
};
|
|
1254
|
+
var CommentIndicator = () => {
|
|
1255
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1256
|
+
role: "none",
|
|
1257
|
+
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
1258
|
+
});
|
|
1259
|
+
};
|
|
1260
|
+
var ThreadedCellWrapper = ({ children }) => {
|
|
1261
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1262
|
+
const [isHovered, setIsHovered] = import_react11.default.useState(false);
|
|
1263
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_BNARJ5GM.SHEET_PLUGIN);
|
|
1264
|
+
const handleClick = import_react11.default.useCallback((_event) => {
|
|
1265
|
+
void dispatch({
|
|
1266
|
+
action: import_app_framework.LayoutAction.SET_LAYOUT,
|
|
1267
|
+
data: {
|
|
1268
|
+
element: "complementary",
|
|
1269
|
+
state: true
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
}, [
|
|
1273
|
+
dispatch
|
|
1274
|
+
]);
|
|
1275
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1276
|
+
role: "none",
|
|
1277
|
+
className: "relative h-full is-full",
|
|
1278
|
+
onMouseEnter: () => {
|
|
1279
|
+
setIsHovered(true);
|
|
1280
|
+
},
|
|
1281
|
+
onMouseLeave: () => {
|
|
1282
|
+
setIsHovered(false);
|
|
1283
|
+
}
|
|
1284
|
+
}, /* @__PURE__ */ import_react11.default.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1285
|
+
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
1286
|
+
}, /* @__PURE__ */ import_react11.default.createElement("button", {
|
|
1287
|
+
className: "ch-button text-xs min-bs-0 p-1",
|
|
1288
|
+
onClick: handleClick,
|
|
1289
|
+
"aria-label": t("open comment for sheet cell")
|
|
1290
|
+
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui.Icon, {
|
|
1291
|
+
icon: "ph--chat--regular",
|
|
1292
|
+
"aria-hidden": true
|
|
1293
|
+
}))), children);
|
|
1294
|
+
};
|
|
1295
|
+
var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
1296
|
+
return {
|
|
1297
|
+
type: "comment",
|
|
1298
|
+
cellIndex,
|
|
1299
|
+
decorate: (props) => /* @__PURE__ */ import_react11.default.createElement(ThreadedCellWrapper, props)
|
|
1300
|
+
};
|
|
1301
|
+
};
|
|
1302
|
+
var useUpdateCursorOnThreadSelection = () => {
|
|
1303
|
+
const { setCursor, model } = useSheetContext();
|
|
1304
|
+
const handleScrollIntoView = (0, import_react11.useCallback)(({ action, data }) => {
|
|
1305
|
+
switch (action) {
|
|
1306
|
+
case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
|
|
1307
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo2.fullyQualifiedId)(model.sheet)) {
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
1311
|
+
setCursor(cellAddress);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}, [
|
|
1315
|
+
model.sheet,
|
|
1316
|
+
setCursor
|
|
1317
|
+
]);
|
|
1318
|
+
(0, import_app_framework.useIntentResolver)(import_chunk_BNARJ5GM.SHEET_PLUGIN, handleScrollIntoView);
|
|
1319
|
+
};
|
|
1320
|
+
var useSelectThreadOnCursorChange = () => {
|
|
1321
|
+
const { cursor, model } = useSheetContext();
|
|
1322
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1323
|
+
const activeThreads = (0, import_react11.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
1324
|
+
JSON.stringify(model.sheet.threads)
|
|
1325
|
+
]);
|
|
1326
|
+
const activeThreadAddresses = (0, import_react11.useMemo)(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
1327
|
+
activeThreads,
|
|
1328
|
+
model.sheet
|
|
1329
|
+
]);
|
|
1330
|
+
const selectClosestThread = (0, import_react11.useCallback)((cellAddress) => {
|
|
1331
|
+
if (!cellAddress || !activeThreads) {
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
1335
|
+
if (closestThreadAnchor) {
|
|
1336
|
+
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
1337
|
+
if (closestThread) {
|
|
1338
|
+
void dispatch([
|
|
1339
|
+
{
|
|
1340
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
1341
|
+
data: {
|
|
1342
|
+
current: (0, import_echo2.fullyQualifiedId)(closestThread)
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
]);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}, [
|
|
1349
|
+
dispatch,
|
|
1350
|
+
activeThreads,
|
|
1351
|
+
activeThreadAddresses,
|
|
1352
|
+
model.sheet
|
|
1353
|
+
]);
|
|
1354
|
+
const debounced = (0, import_react11.useMemo)(() => {
|
|
1355
|
+
return (0, import_async3.debounce)((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
1356
|
+
}, [
|
|
1357
|
+
selectClosestThread
|
|
1358
|
+
]);
|
|
1359
|
+
(0, import_react11.useEffect)(() => {
|
|
1360
|
+
if (!cursor) {
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
debounced(cursor);
|
|
1364
|
+
}, [
|
|
1365
|
+
cursor,
|
|
1366
|
+
selectClosestThread
|
|
1367
|
+
]);
|
|
1368
|
+
};
|
|
1369
|
+
var useThreadDecorations = () => {
|
|
1370
|
+
const { decorations, model } = useSheetContext();
|
|
1371
|
+
const sheet = (0, import_react11.useMemo)(() => model.sheet, [
|
|
1372
|
+
model.sheet
|
|
1373
|
+
]);
|
|
1374
|
+
const sheetId = (0, import_react11.useMemo)(() => (0, import_echo2.fullyQualifiedId)(sheet), [
|
|
1375
|
+
sheet
|
|
1376
|
+
]);
|
|
1377
|
+
(0, import_react11.useEffect)(() => {
|
|
1378
|
+
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
1379
|
+
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
1380
|
+
if (!sheet.threads) {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
for (const thread of sheet.threads) {
|
|
1384
|
+
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
activeThreadAnchors.add(thread.anchor);
|
|
1388
|
+
const index = thread.anchor;
|
|
1389
|
+
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1390
|
+
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1391
|
+
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
for (const decoration of decorations.getAllDecorations()) {
|
|
1395
|
+
if (decoration.type !== "comment") {
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1399
|
+
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
return () => unsubscribe();
|
|
1404
|
+
});
|
|
1405
|
+
};
|
|
1406
|
+
var useThreads = () => {
|
|
1407
|
+
useUpdateCursorOnThreadSelection();
|
|
1408
|
+
useSelectThreadOnCursorChange();
|
|
1409
|
+
useThreadDecorations();
|
|
1410
|
+
};
|
|
554
1411
|
var getRelativeClientRect = (root, element) => {
|
|
555
1412
|
const rootRect = root.getBoundingClientRect();
|
|
556
1413
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -627,21 +1484,61 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
627
1484
|
{
|
|
628
1485
|
key: "Enter",
|
|
629
1486
|
run: (editor) => {
|
|
630
|
-
onClose(editor.state.doc.toString()
|
|
1487
|
+
onClose(editor.state.doc.toString(), {
|
|
1488
|
+
key: "Enter"
|
|
1489
|
+
});
|
|
1490
|
+
return true;
|
|
1491
|
+
},
|
|
1492
|
+
shift: (editor) => {
|
|
1493
|
+
onClose(editor.state.doc.toString(), {
|
|
1494
|
+
key: "Enter",
|
|
1495
|
+
shift: true
|
|
1496
|
+
});
|
|
1497
|
+
return true;
|
|
1498
|
+
}
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
key: "Tab",
|
|
1502
|
+
run: (editor) => {
|
|
1503
|
+
onClose(editor.state.doc.toString(), {
|
|
1504
|
+
key: "Tab"
|
|
1505
|
+
});
|
|
1506
|
+
return true;
|
|
1507
|
+
},
|
|
1508
|
+
shift: (editor) => {
|
|
1509
|
+
onClose(editor.state.doc.toString(), {
|
|
1510
|
+
key: "Tab",
|
|
1511
|
+
shift: true
|
|
1512
|
+
});
|
|
631
1513
|
return true;
|
|
632
1514
|
}
|
|
633
1515
|
},
|
|
634
1516
|
{
|
|
635
1517
|
key: "Escape",
|
|
636
1518
|
run: () => {
|
|
637
|
-
onClose(void 0
|
|
1519
|
+
onClose(void 0, {
|
|
1520
|
+
key: "Escape"
|
|
1521
|
+
});
|
|
638
1522
|
return true;
|
|
639
1523
|
}
|
|
640
1524
|
}
|
|
641
1525
|
]);
|
|
642
1526
|
};
|
|
643
|
-
var
|
|
644
|
-
|
|
1527
|
+
var editorVariants = {
|
|
1528
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
1529
|
+
legacy: {
|
|
1530
|
+
root: "flex w-full",
|
|
1531
|
+
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1532
|
+
content: "!px-2 !py-1"
|
|
1533
|
+
},
|
|
1534
|
+
grid: {
|
|
1535
|
+
root: "absolute z-[1]",
|
|
1536
|
+
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1537
|
+
content: "!border !border-transparent !p-0.5"
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
1541
|
+
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
645
1542
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
646
1543
|
return {
|
|
647
1544
|
autoFocus,
|
|
@@ -667,21 +1564,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
667
1564
|
themeMode,
|
|
668
1565
|
slots: {
|
|
669
1566
|
editor: {
|
|
670
|
-
className:
|
|
1567
|
+
className: editorVariants[variant].editor
|
|
671
1568
|
},
|
|
672
1569
|
content: {
|
|
673
|
-
className:
|
|
1570
|
+
className: editorVariants[variant].content
|
|
674
1571
|
}
|
|
675
1572
|
}
|
|
676
1573
|
})
|
|
677
1574
|
]
|
|
678
1575
|
};
|
|
679
1576
|
}, [
|
|
680
|
-
extension
|
|
1577
|
+
extension,
|
|
1578
|
+
autoFocus,
|
|
1579
|
+
value,
|
|
1580
|
+
variant,
|
|
1581
|
+
onBlur
|
|
681
1582
|
]);
|
|
682
|
-
return /* @__PURE__ */
|
|
1583
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
683
1584
|
ref: parentRef,
|
|
684
|
-
className:
|
|
1585
|
+
className: editorVariants[variant].root,
|
|
1586
|
+
style: box,
|
|
1587
|
+
...gridId && {
|
|
1588
|
+
"data-grid": gridId
|
|
1589
|
+
}
|
|
685
1590
|
});
|
|
686
1591
|
};
|
|
687
1592
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -714,7 +1619,7 @@ var highlightStyles = import_language.HighlightStyle.define([
|
|
|
714
1619
|
class: "text-unAccent"
|
|
715
1620
|
}
|
|
716
1621
|
]);
|
|
717
|
-
var languageFacet = import_state.
|
|
1622
|
+
var languageFacet = (0, import_state.singleValueFacet)();
|
|
718
1623
|
var sheetExtension = ({ functions = [] }) => {
|
|
719
1624
|
const { extension, language } = (0, import_codemirror_lang_spreadsheet.spreadsheet)({
|
|
720
1625
|
idiom: "en-US",
|
|
@@ -794,13 +1699,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
794
1699
|
// NOTE: Useful for debugging.
|
|
795
1700
|
closeOnBlur: false,
|
|
796
1701
|
icons: false,
|
|
797
|
-
tooltipClass: () => (0,
|
|
798
|
-
// TODO(burdon): Factor out fragments.
|
|
799
|
-
// TODO(burdon): Size to make width same as column.
|
|
800
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
801
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
802
|
-
"border-separator"
|
|
803
|
-
)
|
|
1702
|
+
tooltipClass: () => (0, import_react_ui_theme2.mx)("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
|
|
804
1703
|
}),
|
|
805
1704
|
import_view2.keymap.of([
|
|
806
1705
|
{
|
|
@@ -837,7 +1736,7 @@ var rangeExtension = (onInit) => {
|
|
|
837
1736
|
update(view2) {
|
|
838
1737
|
const { anchor } = view2.state.selection.ranges[0];
|
|
839
1738
|
activeRange = void 0;
|
|
840
|
-
const
|
|
1739
|
+
const language = view2.state.facet(languageFacet);
|
|
841
1740
|
const { topNode } = language.parser.parse(view2.state.doc.toString());
|
|
842
1741
|
visitTree(topNode, ({ type, from, to }) => {
|
|
843
1742
|
if (from <= anchor && to >= anchor) {
|
|
@@ -887,7 +1786,7 @@ var visitTree = (node, callback) => {
|
|
|
887
1786
|
}
|
|
888
1787
|
return false;
|
|
889
1788
|
};
|
|
890
|
-
var
|
|
1789
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
891
1790
|
var fragments = {
|
|
892
1791
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
893
1792
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -895,18 +1794,19 @@ var fragments = {
|
|
|
895
1794
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
896
1795
|
};
|
|
897
1796
|
var SheetRoot = ({ children, ...props }) => {
|
|
898
|
-
return /* @__PURE__ */
|
|
1797
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContextProvider, props, children);
|
|
899
1798
|
};
|
|
900
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
1799
|
+
var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
901
1800
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
902
1801
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
903
|
-
|
|
1802
|
+
useThreads();
|
|
1803
|
+
const [rows, setRows] = (0, import_react2.useState)([
|
|
904
1804
|
...model.sheet.rows
|
|
905
1805
|
]);
|
|
906
|
-
const [columns, setColumns] = (0,
|
|
1806
|
+
const [columns, setColumns] = (0, import_react2.useState)([
|
|
907
1807
|
...model.sheet.columns
|
|
908
1808
|
]);
|
|
909
|
-
(0,
|
|
1809
|
+
(0, import_react2.useEffect)(() => {
|
|
910
1810
|
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
911
1811
|
"rows"
|
|
912
1812
|
]);
|
|
@@ -931,37 +1831,37 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
931
1831
|
}, [
|
|
932
1832
|
model
|
|
933
1833
|
]);
|
|
934
|
-
(0,
|
|
1834
|
+
(0, import_react2.useEffect)(() => {
|
|
935
1835
|
model.reset();
|
|
936
1836
|
}, [
|
|
937
1837
|
rows,
|
|
938
1838
|
columns
|
|
939
1839
|
]);
|
|
940
1840
|
const handleMoveRows = (from, to, num = 1) => {
|
|
941
|
-
const cursorIdx = cursor ? model.
|
|
1841
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
942
1842
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
943
1843
|
model.sheet.rows.splice(to, 0, rows2);
|
|
944
1844
|
if (cursorIdx) {
|
|
945
|
-
setCursor(model.
|
|
1845
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
946
1846
|
}
|
|
947
1847
|
setRows([
|
|
948
1848
|
...model.sheet.rows
|
|
949
1849
|
]);
|
|
950
1850
|
};
|
|
951
1851
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
952
|
-
const cursorIdx = cursor ? model.
|
|
1852
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
953
1853
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
954
1854
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
955
1855
|
if (cursorIdx) {
|
|
956
|
-
setCursor(model.
|
|
1856
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
957
1857
|
}
|
|
958
1858
|
setColumns([
|
|
959
1859
|
...model.sheet.columns
|
|
960
1860
|
]);
|
|
961
1861
|
};
|
|
962
|
-
const [rowSizes, setRowSizes] = (0,
|
|
963
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
964
|
-
(0,
|
|
1862
|
+
const [rowSizes, setRowSizes] = (0, import_react2.useState)();
|
|
1863
|
+
const [columnSizes, setColumnSizes] = (0, import_react2.useState)();
|
|
1864
|
+
(0, import_react2.useEffect)(() => {
|
|
965
1865
|
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
966
1866
|
"rowMeta"
|
|
967
1867
|
]);
|
|
@@ -1010,54 +1910,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1010
1910
|
}));
|
|
1011
1911
|
}
|
|
1012
1912
|
};
|
|
1013
|
-
return /* @__PURE__ */
|
|
1913
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1014
1914
|
role: "none",
|
|
1015
|
-
className: (0,
|
|
1016
|
-
}, /* @__PURE__ */
|
|
1915
|
+
className: (0, import_react_ui_theme.mx)("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1916
|
+
}, /* @__PURE__ */ import_react2.default.createElement(GridCorner, {
|
|
1017
1917
|
onClick: () => {
|
|
1018
1918
|
setCursor(void 0);
|
|
1019
1919
|
setRange(void 0);
|
|
1020
1920
|
setEditing(false);
|
|
1021
1921
|
}
|
|
1022
|
-
}), /* @__PURE__ */
|
|
1922
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetColumns, {
|
|
1023
1923
|
ref: columnsRef,
|
|
1024
1924
|
columns,
|
|
1025
1925
|
sizes: columnSizes,
|
|
1026
|
-
selected: cursor?.
|
|
1027
|
-
onSelect: (
|
|
1926
|
+
selected: cursor?.col,
|
|
1927
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1028
1928
|
row: -1,
|
|
1029
|
-
|
|
1929
|
+
col
|
|
1030
1930
|
}),
|
|
1031
1931
|
onResize: handleResizeColumn,
|
|
1032
1932
|
onMove: handleMoveColumns
|
|
1033
|
-
}), /* @__PURE__ */
|
|
1933
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetRows, {
|
|
1034
1934
|
ref: rowsRef,
|
|
1035
1935
|
rows,
|
|
1036
1936
|
sizes: rowSizes,
|
|
1037
1937
|
selected: cursor?.row,
|
|
1038
1938
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1039
1939
|
row,
|
|
1040
|
-
|
|
1940
|
+
col: -1
|
|
1041
1941
|
}),
|
|
1042
1942
|
onResize: handleResizeRow,
|
|
1043
1943
|
onMove: handleMoveRows
|
|
1044
|
-
}), /* @__PURE__ */
|
|
1944
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetGrid, {
|
|
1045
1945
|
ref: contentRef,
|
|
1046
1946
|
size: {
|
|
1047
1947
|
numRows: numRows ?? rows.length,
|
|
1048
|
-
|
|
1948
|
+
numCols: numCols ?? columns.length
|
|
1049
1949
|
},
|
|
1050
1950
|
rows,
|
|
1051
1951
|
columns,
|
|
1052
1952
|
rowSizes,
|
|
1053
1953
|
columnSizes
|
|
1054
|
-
}), /* @__PURE__ */
|
|
1954
|
+
}), /* @__PURE__ */ import_react2.default.createElement(GridCorner, null), /* @__PURE__ */ import_react2.default.createElement(SheetStatusBar, null));
|
|
1055
1955
|
});
|
|
1056
1956
|
var useScrollHandlers = () => {
|
|
1057
|
-
const rowsRef = (0,
|
|
1058
|
-
const columnsRef = (0,
|
|
1059
|
-
const contentRef = (0,
|
|
1060
|
-
(0,
|
|
1957
|
+
const rowsRef = (0, import_react2.useRef)(null);
|
|
1958
|
+
const columnsRef = (0, import_react2.useRef)(null);
|
|
1959
|
+
const contentRef = (0, import_react2.useRef)(null);
|
|
1960
|
+
(0, import_react2.useEffect)(() => {
|
|
1061
1961
|
const handleRowsScroll = (ev) => {
|
|
1062
1962
|
const { scrollTop } = ev.target;
|
|
1063
1963
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1094,13 +1994,13 @@ var useScrollHandlers = () => {
|
|
|
1094
1994
|
};
|
|
1095
1995
|
};
|
|
1096
1996
|
var GridCorner = (props) => {
|
|
1097
|
-
return /* @__PURE__ */
|
|
1997
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1098
1998
|
className: fragments.axis,
|
|
1099
1999
|
...props
|
|
1100
2000
|
});
|
|
1101
2001
|
};
|
|
1102
2002
|
var MovingOverlay = ({ label }) => {
|
|
1103
|
-
return /* @__PURE__ */
|
|
2003
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1104
2004
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1105
2005
|
}, label);
|
|
1106
2006
|
};
|
|
@@ -1111,7 +2011,7 @@ var touchConstraints = {
|
|
|
1111
2011
|
delay: 250,
|
|
1112
2012
|
tolerance: 5
|
|
1113
2013
|
};
|
|
1114
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
2014
|
+
var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1115
2015
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1116
2016
|
activationConstraint: mouseConstraints
|
|
1117
2017
|
});
|
|
@@ -1120,7 +2020,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1120
2020
|
});
|
|
1121
2021
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1122
2022
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1123
|
-
const [active, setActive] = (0,
|
|
2023
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1124
2024
|
const handleDragStart = ({ active: active2 }) => {
|
|
1125
2025
|
setActive(active2);
|
|
1126
2026
|
};
|
|
@@ -1144,18 +2044,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1144
2044
|
}
|
|
1145
2045
|
return transform;
|
|
1146
2046
|
};
|
|
1147
|
-
return /* @__PURE__ */
|
|
2047
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1148
2048
|
className: "relative flex grow overflow-hidden"
|
|
1149
|
-
}, /* @__PURE__ */
|
|
1150
|
-
className: (0,
|
|
2049
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2050
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1151
2051
|
style: {
|
|
1152
2052
|
width: axisWidth
|
|
1153
2053
|
}
|
|
1154
|
-
}), /* @__PURE__ */
|
|
2054
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1155
2055
|
ref: forwardRef2,
|
|
1156
2056
|
role: "rowheader",
|
|
1157
2057
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1158
|
-
}, /* @__PURE__ */
|
|
2058
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1159
2059
|
sensors,
|
|
1160
2060
|
modifiers: [
|
|
1161
2061
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1163,12 +2063,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1163
2063
|
],
|
|
1164
2064
|
onDragStart: handleDragStart,
|
|
1165
2065
|
onDragEnd: handleDragEnd
|
|
1166
|
-
}, /* @__PURE__ */
|
|
2066
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1167
2067
|
className: "flex flex-col",
|
|
1168
2068
|
style: {
|
|
1169
2069
|
width: axisWidth
|
|
1170
2070
|
}
|
|
1171
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
2071
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridRowCell, {
|
|
1172
2072
|
key: idx,
|
|
1173
2073
|
idx,
|
|
1174
2074
|
index,
|
|
@@ -1178,7 +2078,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1178
2078
|
selected: selected === index,
|
|
1179
2079
|
onResize,
|
|
1180
2080
|
onSelect
|
|
1181
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2081
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react2.default.createElement(MovingOverlay, {
|
|
1182
2082
|
label: String(active.data.current.index + 1)
|
|
1183
2083
|
})), document.body))));
|
|
1184
2084
|
});
|
|
@@ -1196,9 +2096,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1196
2096
|
}
|
|
1197
2097
|
});
|
|
1198
2098
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1199
|
-
const [initialSize, setInitialSize] = (0,
|
|
1200
|
-
const [resizing, setResizing] = (0,
|
|
1201
|
-
const scrollHandler = (0,
|
|
2099
|
+
const [initialSize, setInitialSize] = (0, import_react2.useState)(size);
|
|
2100
|
+
const [resizing, setResizing] = (0, import_react2.useState)(false);
|
|
2101
|
+
const scrollHandler = (0, import_react2.useRef)();
|
|
1202
2102
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1203
2103
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1204
2104
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1219,7 +2119,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1219
2119
|
onResize?.(idx, initialSize + height, true);
|
|
1220
2120
|
setResizing(false);
|
|
1221
2121
|
};
|
|
1222
|
-
return /* @__PURE__ */
|
|
2122
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1223
2123
|
enable: {
|
|
1224
2124
|
bottom: resize
|
|
1225
2125
|
},
|
|
@@ -1231,21 +2131,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1231
2131
|
onResizeStart: handleResizeStart,
|
|
1232
2132
|
onResize: handleResize,
|
|
1233
2133
|
onResizeStop: handleResizeStop
|
|
1234
|
-
}, /* @__PURE__ */
|
|
2134
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1235
2135
|
ref: setNodeRef,
|
|
1236
2136
|
...attributes,
|
|
1237
2137
|
...listeners,
|
|
1238
|
-
className: (0,
|
|
2138
|
+
className: (0, import_react_ui_theme.mx)("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),
|
|
1239
2139
|
onClick: () => onSelect?.(index)
|
|
1240
|
-
}, /* @__PURE__ */
|
|
2140
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1241
2141
|
className: "flex w-full justify-center"
|
|
1242
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2142
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1243
2143
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1244
|
-
}), resizing && /* @__PURE__ */
|
|
2144
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1245
2145
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1246
2146
|
})));
|
|
1247
2147
|
};
|
|
1248
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
2148
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1249
2149
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1250
2150
|
activationConstraint: mouseConstraints
|
|
1251
2151
|
});
|
|
@@ -1254,7 +2154,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1254
2154
|
});
|
|
1255
2155
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1256
2156
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1257
|
-
const [active, setActive] = (0,
|
|
2157
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1258
2158
|
const handleDragStart = ({ active: active2 }) => {
|
|
1259
2159
|
setActive(active2);
|
|
1260
2160
|
};
|
|
@@ -1278,18 +2178,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1278
2178
|
}
|
|
1279
2179
|
return transform;
|
|
1280
2180
|
};
|
|
1281
|
-
return /* @__PURE__ */
|
|
2181
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1282
2182
|
className: "relative flex grow overflow-hidden"
|
|
1283
|
-
}, /* @__PURE__ */
|
|
1284
|
-
className: (0,
|
|
2183
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2184
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
1285
2185
|
style: {
|
|
1286
2186
|
height: axisHeight
|
|
1287
2187
|
}
|
|
1288
|
-
}), /* @__PURE__ */
|
|
2188
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1289
2189
|
ref: forwardRef2,
|
|
1290
2190
|
role: "columnheader",
|
|
1291
2191
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1292
|
-
}, /* @__PURE__ */
|
|
2192
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1293
2193
|
autoScroll: {
|
|
1294
2194
|
enabled: true
|
|
1295
2195
|
},
|
|
@@ -1300,23 +2200,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1300
2200
|
],
|
|
1301
2201
|
onDragStart: handleDragStart,
|
|
1302
2202
|
onDragEnd: handleDragEnd
|
|
1303
|
-
}, /* @__PURE__ */
|
|
2203
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1304
2204
|
className: "flex h-full",
|
|
1305
2205
|
style: {
|
|
1306
2206
|
height: axisHeight
|
|
1307
2207
|
}
|
|
1308
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2208
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridColumnCell, {
|
|
1309
2209
|
key: idx,
|
|
1310
2210
|
idx,
|
|
1311
2211
|
index,
|
|
1312
|
-
label:
|
|
2212
|
+
label: columnLetter(index),
|
|
1313
2213
|
size: sizes?.[idx] ?? defaultWidth,
|
|
1314
2214
|
resize: index < columns.length - 1,
|
|
1315
2215
|
selected: selected === index,
|
|
1316
2216
|
onResize,
|
|
1317
2217
|
onSelect
|
|
1318
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1319
|
-
label:
|
|
2218
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react2.default.createElement(MovingOverlay, {
|
|
2219
|
+
label: columnLetter(active.data.current.index)
|
|
1320
2220
|
})), document.body))));
|
|
1321
2221
|
});
|
|
1322
2222
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -1333,9 +2233,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1333
2233
|
}
|
|
1334
2234
|
});
|
|
1335
2235
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1336
|
-
const [initialSize, setInitialSize] = (0,
|
|
1337
|
-
const [resizing, setResizing] = (0,
|
|
1338
|
-
const scrollHandler = (0,
|
|
2236
|
+
const [initialSize, setInitialSize] = (0, import_react2.useState)(size);
|
|
2237
|
+
const [resizing, setResizing] = (0, import_react2.useState)(false);
|
|
2238
|
+
const scrollHandler = (0, import_react2.useRef)();
|
|
1339
2239
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1340
2240
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
1341
2241
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -1356,7 +2256,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1356
2256
|
onResize?.(idx, initialSize + width, true);
|
|
1357
2257
|
setResizing(false);
|
|
1358
2258
|
};
|
|
1359
|
-
return /* @__PURE__ */
|
|
2259
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1360
2260
|
enable: {
|
|
1361
2261
|
right: resize
|
|
1362
2262
|
},
|
|
@@ -1368,37 +2268,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1368
2268
|
onResizeStart: handleResizeStart,
|
|
1369
2269
|
onResize: handleResize,
|
|
1370
2270
|
onResizeStop: handleResizeStop
|
|
1371
|
-
}, /* @__PURE__ */
|
|
2271
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1372
2272
|
ref: setNodeRef,
|
|
1373
2273
|
...attributes,
|
|
1374
2274
|
...listeners,
|
|
1375
|
-
className: (0,
|
|
2275
|
+
className: (0, import_react_ui_theme.mx)("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),
|
|
1376
2276
|
onClick: () => onSelect?.(index)
|
|
1377
|
-
}, /* @__PURE__ */
|
|
2277
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1378
2278
|
className: "flex w-full justify-center"
|
|
1379
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2279
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1380
2280
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1381
|
-
}), resizing && /* @__PURE__ */
|
|
2281
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1382
2282
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1383
2283
|
})));
|
|
1384
2284
|
};
|
|
1385
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
2285
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
1386
2286
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
1387
2287
|
refreshRate: 200
|
|
1388
2288
|
});
|
|
1389
|
-
const scrollerRef = (0,
|
|
1390
|
-
(0,
|
|
2289
|
+
const scrollerRef = (0, import_react2.useRef)(null);
|
|
2290
|
+
(0, import_react2.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
1391
2291
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1392
|
-
const initialText = (0,
|
|
1393
|
-
const quickEdit = (0,
|
|
1394
|
-
const [, forceUpdate] = (0,
|
|
1395
|
-
(0,
|
|
2292
|
+
const initialText = (0, import_react2.useRef)();
|
|
2293
|
+
const quickEdit = (0, import_react2.useRef)(false);
|
|
2294
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2295
|
+
(0, import_react2.useEffect)(() => {
|
|
1396
2296
|
const unsubscribe = model.update.on(() => {
|
|
1397
2297
|
(0, import_log.log)("updated", {
|
|
1398
2298
|
id: model.id
|
|
1399
2299
|
}, {
|
|
1400
|
-
F:
|
|
1401
|
-
L:
|
|
2300
|
+
F: __dxlog_file4,
|
|
2301
|
+
L: 738,
|
|
1402
2302
|
S: void 0,
|
|
1403
2303
|
C: (f, a) => f(...a)
|
|
1404
2304
|
});
|
|
@@ -1410,7 +2310,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1410
2310
|
}, [
|
|
1411
2311
|
model
|
|
1412
2312
|
]);
|
|
1413
|
-
const inputRef = (0,
|
|
2313
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
1414
2314
|
const handleKeyDown = (ev) => {
|
|
1415
2315
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
1416
2316
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -1516,18 +2416,17 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1516
2416
|
columnSizes
|
|
1517
2417
|
});
|
|
1518
2418
|
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
1519
|
-
const
|
|
1520
|
-
|
|
1521
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2419
|
+
const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
|
|
2420
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1522
2421
|
ref: containerRef,
|
|
1523
2422
|
role: "grid",
|
|
1524
2423
|
className: "relative flex grow overflow-hidden"
|
|
1525
|
-
}, /* @__PURE__ */
|
|
1526
|
-
className: (0,
|
|
1527
|
-
}), /* @__PURE__ */
|
|
2424
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2425
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
2426
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1528
2427
|
ref: scrollerRef,
|
|
1529
|
-
className: (0,
|
|
1530
|
-
}, /* @__PURE__ */
|
|
2428
|
+
className: (0, import_react_ui_theme.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2429
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1531
2430
|
className: "relative select-none",
|
|
1532
2431
|
style: {
|
|
1533
2432
|
width,
|
|
@@ -1535,10 +2434,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1535
2434
|
},
|
|
1536
2435
|
onClick: () => inputRef.current?.focus(),
|
|
1537
2436
|
...handlers
|
|
1538
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2437
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react2.default.createElement(SelectionOverlay, {
|
|
1539
2438
|
root: scrollerRef.current
|
|
1540
2439
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1541
|
-
return columnRange.map(({
|
|
2440
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1542
2441
|
const style = {
|
|
1543
2442
|
position: "absolute",
|
|
1544
2443
|
top,
|
|
@@ -1548,11 +2447,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1548
2447
|
};
|
|
1549
2448
|
const cell = {
|
|
1550
2449
|
row,
|
|
1551
|
-
|
|
2450
|
+
col
|
|
1552
2451
|
};
|
|
1553
|
-
const id2 =
|
|
1554
|
-
const idx = model.
|
|
1555
|
-
const active =
|
|
2452
|
+
const id2 = addressToA1Notation(cell);
|
|
2453
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
2454
|
+
const active = posEquals(cursor, cell);
|
|
1556
2455
|
if (active && editing) {
|
|
1557
2456
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
1558
2457
|
const handleClose = (value2) => {
|
|
@@ -1584,7 +2483,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1584
2483
|
inputRef.current?.focus();
|
|
1585
2484
|
setEditing(false);
|
|
1586
2485
|
};
|
|
1587
|
-
return /* @__PURE__ */
|
|
2486
|
+
return /* @__PURE__ */ import_react2.default.createElement(GridCellEditor, {
|
|
1588
2487
|
key: idx,
|
|
1589
2488
|
value,
|
|
1590
2489
|
style,
|
|
@@ -1592,7 +2491,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1592
2491
|
onClose: handleClose
|
|
1593
2492
|
});
|
|
1594
2493
|
}
|
|
1595
|
-
return /* @__PURE__ */
|
|
2494
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetCell, {
|
|
1596
2495
|
key: id2,
|
|
1597
2496
|
id: id2,
|
|
1598
2497
|
cell,
|
|
@@ -1604,13 +2503,25 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1604
2503
|
}
|
|
1605
2504
|
});
|
|
1606
2505
|
});
|
|
1607
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2506
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(SheetInput, {
|
|
1608
2507
|
ref: inputRef,
|
|
1609
|
-
|
|
2508
|
+
id,
|
|
2509
|
+
onKeyDown: handleKeyDown
|
|
2510
|
+
}), document.body));
|
|
2511
|
+
});
|
|
2512
|
+
var SheetInput = /* @__PURE__ */ (0, import_react2.forwardRef)(({ id, onKeyDown }, forwardedRef) => {
|
|
2513
|
+
const path = (0, import_react_ui_attention.useAttentionPath)();
|
|
2514
|
+
const attendableAttrs = (0, import_react_ui_attention.useAttendableAttributes)(id);
|
|
2515
|
+
return path.toReversed().reduce((acc, part) => {
|
|
2516
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2517
|
+
[import_react_ui_attention.ATTENABLE_ATTRIBUTE]: part
|
|
2518
|
+
}, acc);
|
|
2519
|
+
}, /* @__PURE__ */ import_react2.default.createElement("input", {
|
|
2520
|
+
ref: forwardedRef,
|
|
1610
2521
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
1611
|
-
onKeyDown
|
|
2522
|
+
onKeyDown,
|
|
1612
2523
|
...attendableAttrs
|
|
1613
|
-
})
|
|
2524
|
+
}));
|
|
1614
2525
|
});
|
|
1615
2526
|
var SelectionOverlay = ({ root }) => {
|
|
1616
2527
|
const { range } = useSheetContext();
|
|
@@ -1625,20 +2536,34 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1625
2536
|
const b1 = getRelativeClientRect(root, c1);
|
|
1626
2537
|
const b2 = getRelativeClientRect(root, c2);
|
|
1627
2538
|
const bounds = getRectUnion(b1, b2);
|
|
1628
|
-
return /* @__PURE__ */
|
|
2539
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1629
2540
|
role: "none",
|
|
1630
2541
|
style: bounds,
|
|
1631
2542
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
1632
2543
|
});
|
|
1633
2544
|
};
|
|
1634
2545
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1635
|
-
const { formatting, editing, setRange } = useSheetContext();
|
|
2546
|
+
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1636
2547
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1637
|
-
|
|
2548
|
+
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
2549
|
+
const decorationAddedClasses = (0, import_react2.useMemo)(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
2550
|
+
decorationsForCell
|
|
2551
|
+
]);
|
|
2552
|
+
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
2553
|
+
if (!decorate) {
|
|
2554
|
+
return children;
|
|
2555
|
+
}
|
|
2556
|
+
const DecoratorComponent = decorate;
|
|
2557
|
+
return /* @__PURE__ */ import_react2.default.createElement(DecoratorComponent, null, children);
|
|
2558
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2559
|
+
role: "none",
|
|
2560
|
+
className: (0, import_react_ui_theme.mx)("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
2561
|
+
}, value));
|
|
2562
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1638
2563
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1639
2564
|
role: "cell",
|
|
1640
2565
|
style,
|
|
1641
|
-
className: (0,
|
|
2566
|
+
className: (0, import_react_ui_theme.mx)("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1642
2567
|
"z-20",
|
|
1643
2568
|
fragments.cellSelected
|
|
1644
2569
|
], classNames),
|
|
@@ -1652,36 +2577,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1652
2577
|
}
|
|
1653
2578
|
},
|
|
1654
2579
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
1655
|
-
},
|
|
2580
|
+
}, decoratedContent);
|
|
1656
2581
|
};
|
|
1657
2582
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1658
2583
|
const { model, range } = useSheetContext();
|
|
1659
|
-
const notifier = (0,
|
|
1660
|
-
(0,
|
|
2584
|
+
const notifier = (0, import_react2.useRef)();
|
|
2585
|
+
(0, import_react2.useEffect)(() => {
|
|
1661
2586
|
if (range) {
|
|
1662
|
-
notifier.current?.(
|
|
2587
|
+
notifier.current?.(rangeToA1Notation(range));
|
|
1663
2588
|
}
|
|
1664
2589
|
}, [
|
|
1665
2590
|
range
|
|
1666
2591
|
]);
|
|
1667
|
-
const extension = (0,
|
|
2592
|
+
const extension = (0, import_react2.useMemo)(() => [
|
|
1668
2593
|
editorKeys({
|
|
1669
2594
|
onNav,
|
|
1670
2595
|
onClose
|
|
1671
2596
|
}),
|
|
1672
2597
|
sheetExtension({
|
|
1673
|
-
functions: model.
|
|
2598
|
+
functions: model.graph.getFunctions()
|
|
1674
2599
|
}),
|
|
1675
2600
|
rangeExtension((fn) => notifier.current = fn)
|
|
1676
2601
|
], [
|
|
1677
2602
|
model
|
|
1678
2603
|
]);
|
|
1679
|
-
return /* @__PURE__ */
|
|
2604
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1680
2605
|
role: "cell",
|
|
1681
2606
|
style,
|
|
1682
|
-
className: (0,
|
|
2607
|
+
className: (0, import_react_ui_theme.mx)("z-20 flex", fragments.cellSelected),
|
|
1683
2608
|
onClick: (ev) => ev.stopPropagation()
|
|
1684
|
-
}, /* @__PURE__ */
|
|
2609
|
+
}, /* @__PURE__ */ import_react2.default.createElement(CellEditor, {
|
|
1685
2610
|
autoFocus: true,
|
|
1686
2611
|
value,
|
|
1687
2612
|
extension
|
|
@@ -1694,30 +2619,30 @@ var SheetStatusBar = () => {
|
|
|
1694
2619
|
if (cursor) {
|
|
1695
2620
|
value = model.getCellValue(cursor);
|
|
1696
2621
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1697
|
-
value = model.
|
|
2622
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1698
2623
|
isFormula = true;
|
|
1699
2624
|
} else if (value != null) {
|
|
1700
2625
|
value = String(value);
|
|
1701
2626
|
}
|
|
1702
2627
|
}
|
|
1703
|
-
return /* @__PURE__ */
|
|
1704
|
-
className: (0,
|
|
1705
|
-
}, /* @__PURE__ */
|
|
2628
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2629
|
+
className: (0, import_react_ui_theme.mx)("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
2630
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1706
2631
|
className: "flex gap-4 items-center"
|
|
1707
|
-
}, /* @__PURE__ */
|
|
2632
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1708
2633
|
className: "flex w-16 items-center font-mono"
|
|
1709
|
-
}, range &&
|
|
2634
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1710
2635
|
className: "flex gap-2 items-center"
|
|
1711
|
-
}, /* @__PURE__ */
|
|
1712
|
-
className: (0,
|
|
1713
|
-
}), /* @__PURE__ */
|
|
2636
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_react.Function, {
|
|
2637
|
+
className: (0, import_react_ui_theme.mx)("text-greenText", isFormula ? "visible" : "invisible")
|
|
2638
|
+
}), /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1714
2639
|
className: "font-mono"
|
|
1715
2640
|
}, value))));
|
|
1716
2641
|
};
|
|
1717
2642
|
var SheetDebug = () => {
|
|
1718
2643
|
const { model, cursor, range } = useSheetContext();
|
|
1719
|
-
const [, forceUpdate] = (0,
|
|
1720
|
-
(0,
|
|
2644
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2645
|
+
(0, import_react2.useEffect)(() => {
|
|
1721
2646
|
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
1722
2647
|
const handleUpdate = () => forceUpdate({});
|
|
1723
2648
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -1728,9 +2653,9 @@ var SheetDebug = () => {
|
|
|
1728
2653
|
}, [
|
|
1729
2654
|
model
|
|
1730
2655
|
]);
|
|
1731
|
-
return /* @__PURE__ */
|
|
1732
|
-
className: (0,
|
|
1733
|
-
}, /* @__PURE__ */
|
|
2656
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2657
|
+
className: (0, import_react_ui_theme.mx)("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")
|
|
2658
|
+
}, /* @__PURE__ */ import_react2.default.createElement("pre", {
|
|
1734
2659
|
className: "whitespace-pre-wrap"
|
|
1735
2660
|
}, JSON.stringify({
|
|
1736
2661
|
cursor,
|
|
@@ -1751,15 +2676,15 @@ var Sheet = {
|
|
|
1751
2676
|
StatusBar: SheetStatusBar,
|
|
1752
2677
|
Debug: SheetDebug
|
|
1753
2678
|
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
//# sourceMappingURL=
|
|
2679
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2680
|
+
0 && (module.exports = {
|
|
2681
|
+
ComputeGraphContextProvider,
|
|
2682
|
+
Sheet,
|
|
2683
|
+
SheetContainer,
|
|
2684
|
+
addressToIndex,
|
|
2685
|
+
compareIndexPositions,
|
|
2686
|
+
createSheet,
|
|
2687
|
+
useComputeGraph,
|
|
2688
|
+
useSheetContext
|
|
2689
|
+
});
|
|
2690
|
+
//# sourceMappingURL=chunk-2K53Z2TU.cjs.map
|