@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.7907542
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-WUPTZUTX.mjs → chunk-5ZMVZYGB.mjs} +21 -19
- package/dist/lib/browser/chunk-5ZMVZYGB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GNNVBNCX.mjs → chunk-GSV5QNLD.mjs} +409 -686
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-ZL2V5UJR.mjs} +982 -508
- 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 +86 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs +280 -0
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-2K53Z2TU.cjs} +1036 -558
- package/dist/lib/node/chunk-2K53Z2TU.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZRQZFV5T.cjs → chunk-5XPK2V4A.cjs} +418 -691
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-STAVQ2JE.cjs} +25 -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 +98 -66
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs +263 -0
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WUPTZUTX.mjs → chunk-2HAM45RC.mjs} +22 -19
- package/dist/lib/node-esm/chunk-2HAM45RC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-5WPZCXNS.mjs} +411 -686
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JRL5LGCE.mjs → chunk-IU2L277A.mjs} +4 -5
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/{SheetContainer-Y7ZMFBAP.mjs → chunk-QEUCIHIN.mjs} +983 -508
- 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 +87 -59
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/types.mjs +5 -6
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +16 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +6 -7
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/util.d.ts +8 -4
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +6 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +64 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +26 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/functions/index.d.ts +4 -0
- package/dist/types/src/graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +5 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +3 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -4
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +10 -49
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +15 -4
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +48 -44
- package/src/SheetPlugin.tsx +46 -62
- package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +3 -4
- package/src/components/CellEditor/extension.ts +5 -6
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +36 -0
- package/src/components/GridSheet/GridSheet.tsx +171 -0
- package/src/components/GridSheet/util.ts +148 -0
- package/src/components/Sheet/Sheet.stories.tsx +48 -88
- package/src/components/Sheet/Sheet.tsx +42 -24
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +12 -82
- package/src/components/Sheet/threads.tsx +10 -6
- package/src/components/SheetContainer.tsx +13 -15
- package/src/components/Toolbar/Toolbar.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +7 -7
- package/src/{model → defs}/types.ts +24 -14
- package/src/{model → defs}/util.ts +65 -17
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +147 -0
- package/src/extensions/index.ts +5 -0
- package/src/graph/compute-graph-registry.ts +90 -0
- package/src/graph/compute-graph.stories.tsx +93 -0
- package/src/graph/compute-graph.test.ts +87 -0
- package/src/graph/compute-graph.ts +242 -0
- package/src/graph/compute-node.ts +63 -0
- package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
- package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
- package/src/graph/functions/index.ts +7 -0
- package/src/graph/hyperformula.test.ts +14 -0
- package/src/graph/index.ts +8 -0
- package/src/graph/testing/index.ts +6 -0
- package/src/graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +28 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +40 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -4
- package/src/model/sheet-model.test.ts +57 -0
- package/src/model/{model.ts → sheet-model.ts} +88 -188
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +68 -0
- package/src/types.ts +19 -17
- package/dist/lib/browser/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/browser/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/browser/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/browser/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/browser/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-KEOKUKAQ.cjs.map +0 -7
- package/dist/lib/node/chunk-57PB2HPY.cjs +0 -40
- package/dist/lib/node/chunk-57PB2HPY.cjs.map +0 -7
- package/dist/lib/node/chunk-6LWBQAQZ.cjs +0 -202
- package/dist/lib/node/chunk-6LWBQAQZ.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-VJU3NPUJ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZRQZFV5T.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/node-esm/testing.mjs +0 -92
- package/dist/lib/node-esm/testing.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -49
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -99
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
|
@@ -26,66 +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
|
-
|
|
32
|
-
|
|
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
|
|
33
39
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
|
|
39
|
-
var import_react = __toESM(require("react"));
|
|
40
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
41
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
42
|
-
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
43
|
-
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");
|
|
44
44
|
var import_core = require("@dnd-kit/core");
|
|
45
45
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
46
46
|
var import_utilities = require("@dnd-kit/utilities");
|
|
47
|
-
var
|
|
47
|
+
var import_react = require("@phosphor-icons/react");
|
|
48
48
|
var import_re_resizable = require("re-resizable");
|
|
49
|
-
var
|
|
49
|
+
var import_react2 = __toESM(require("react"));
|
|
50
50
|
var import_react_dom = require("react-dom");
|
|
51
51
|
var import_react_resize_detector = require("react-resize-detector");
|
|
52
52
|
var import_async = require("@dxos/async");
|
|
53
|
-
var
|
|
53
|
+
var import_echo = require("@dxos/client/echo");
|
|
54
54
|
var import_log = require("@dxos/log");
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var import_react5 = require("react");
|
|
59
|
-
var import_react6 = __toESM(require("react"));
|
|
55
|
+
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
56
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
57
|
+
var import_react3 = require("react");
|
|
60
58
|
var import_invariant = require("@dxos/invariant");
|
|
61
|
-
var
|
|
59
|
+
var import_crypto = require("@dxos/crypto");
|
|
62
60
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
63
|
-
var
|
|
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");
|
|
64
68
|
var import_react7 = __toESM(require("react"));
|
|
65
|
-
var
|
|
69
|
+
var import_react8 = __toESM(require("react"));
|
|
70
|
+
var import_react9 = require("react");
|
|
66
71
|
var import_async2 = require("@dxos/async");
|
|
67
|
-
var
|
|
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");
|
|
68
84
|
var import_react_ui = require("@dxos/react-ui");
|
|
69
|
-
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
70
85
|
var import_view = require("@codemirror/view");
|
|
71
|
-
var
|
|
86
|
+
var import_react12 = __toESM(require("react"));
|
|
72
87
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
73
88
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
74
89
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
75
90
|
var import_language = require("@codemirror/language");
|
|
76
|
-
var import_state = require("@codemirror/state");
|
|
77
91
|
var import_view2 = require("@codemirror/view");
|
|
78
92
|
var import_highlight = require("@lezer/highlight");
|
|
79
93
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
|
|
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
|
+
};
|
|
89
253
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
90
254
|
var axisHeight = 34;
|
|
91
255
|
var minWidth = 40;
|
|
@@ -96,8 +260,8 @@ var defaultWidth = 200;
|
|
|
96
260
|
var defaultHeight = minHeight;
|
|
97
261
|
var CELL_DATA_KEY = "cell";
|
|
98
262
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
99
|
-
const [rowPositions, setRowPositions] = (0,
|
|
100
|
-
(0,
|
|
263
|
+
const [rowPositions, setRowPositions] = (0, import_react3.useState)([]);
|
|
264
|
+
(0, import_react3.useEffect)(() => {
|
|
101
265
|
if (!rowSizes) {
|
|
102
266
|
return;
|
|
103
267
|
}
|
|
@@ -116,8 +280,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
116
280
|
rows,
|
|
117
281
|
rowSizes
|
|
118
282
|
]);
|
|
119
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
120
|
-
(0,
|
|
283
|
+
const [columnPositions, setColumnPositions] = (0, import_react3.useState)([]);
|
|
284
|
+
(0, import_react3.useEffect)(() => {
|
|
121
285
|
if (!columns) {
|
|
122
286
|
return;
|
|
123
287
|
}
|
|
@@ -127,7 +291,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
127
291
|
const left = x;
|
|
128
292
|
x += width2 - 1;
|
|
129
293
|
return {
|
|
130
|
-
|
|
294
|
+
col: i,
|
|
131
295
|
left,
|
|
132
296
|
width: width2
|
|
133
297
|
};
|
|
@@ -138,11 +302,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
138
302
|
]);
|
|
139
303
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
140
304
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
141
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
305
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react3.useState)({
|
|
142
306
|
rowRange: [],
|
|
143
307
|
columnRange: []
|
|
144
308
|
});
|
|
145
|
-
(0,
|
|
309
|
+
(0, import_react3.useEffect)(() => {
|
|
146
310
|
const handleScroll = () => {
|
|
147
311
|
if (!scroller) {
|
|
148
312
|
return;
|
|
@@ -202,12 +366,12 @@ var getCellAtPointer = (event) => {
|
|
|
202
366
|
if (root) {
|
|
203
367
|
const value = root.dataset[CELL_DATA_KEY];
|
|
204
368
|
if (value) {
|
|
205
|
-
return
|
|
369
|
+
return addressFromA1Notation(value);
|
|
206
370
|
}
|
|
207
371
|
}
|
|
208
372
|
};
|
|
209
373
|
var getCellElement = (root, cell) => {
|
|
210
|
-
const pos =
|
|
374
|
+
const pos = addressToA1Notation(cell);
|
|
211
375
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
212
376
|
};
|
|
213
377
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -229,14 +393,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
229
393
|
break;
|
|
230
394
|
}
|
|
231
395
|
case "ArrowLeft": {
|
|
232
|
-
if (opposite.
|
|
233
|
-
opposite.
|
|
396
|
+
if (opposite.col > 0) {
|
|
397
|
+
opposite.col -= 1;
|
|
234
398
|
}
|
|
235
399
|
break;
|
|
236
400
|
}
|
|
237
401
|
case "ArrowRight": {
|
|
238
|
-
if (opposite.
|
|
239
|
-
opposite.
|
|
402
|
+
if (opposite.col < size.numCols - 1) {
|
|
403
|
+
opposite.col += 1;
|
|
240
404
|
}
|
|
241
405
|
break;
|
|
242
406
|
}
|
|
@@ -254,18 +418,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
254
418
|
cursor: next
|
|
255
419
|
};
|
|
256
420
|
};
|
|
257
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
421
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
258
422
|
switch (ev.key) {
|
|
259
423
|
case "ArrowUp":
|
|
260
424
|
if (cursor === void 0) {
|
|
261
425
|
return {
|
|
262
426
|
row: 0,
|
|
263
|
-
|
|
427
|
+
col: 0
|
|
264
428
|
};
|
|
265
429
|
} else if (cursor.row > 0) {
|
|
266
430
|
return {
|
|
267
431
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
268
|
-
|
|
432
|
+
col: cursor.col
|
|
269
433
|
};
|
|
270
434
|
}
|
|
271
435
|
break;
|
|
@@ -273,12 +437,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
273
437
|
if (cursor === void 0) {
|
|
274
438
|
return {
|
|
275
439
|
row: 0,
|
|
276
|
-
|
|
440
|
+
col: 0
|
|
277
441
|
};
|
|
278
442
|
} else if (cursor.row < numRows - 1) {
|
|
279
443
|
return {
|
|
280
444
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
281
|
-
|
|
445
|
+
col: cursor.col
|
|
282
446
|
};
|
|
283
447
|
}
|
|
284
448
|
break;
|
|
@@ -286,12 +450,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
286
450
|
if (cursor === void 0) {
|
|
287
451
|
return {
|
|
288
452
|
row: 0,
|
|
289
|
-
|
|
453
|
+
col: 0
|
|
290
454
|
};
|
|
291
|
-
} else if (cursor.
|
|
455
|
+
} else if (cursor.col > 0) {
|
|
292
456
|
return {
|
|
293
457
|
row: cursor.row,
|
|
294
|
-
|
|
458
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
295
459
|
};
|
|
296
460
|
}
|
|
297
461
|
break;
|
|
@@ -299,30 +463,30 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
299
463
|
if (cursor === void 0) {
|
|
300
464
|
return {
|
|
301
465
|
row: 0,
|
|
302
|
-
|
|
466
|
+
col: 0
|
|
303
467
|
};
|
|
304
|
-
} else if (cursor.
|
|
468
|
+
} else if (cursor.col < numCols - 1) {
|
|
305
469
|
return {
|
|
306
470
|
row: cursor.row,
|
|
307
|
-
|
|
471
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
308
472
|
};
|
|
309
473
|
}
|
|
310
474
|
break;
|
|
311
475
|
case "Home":
|
|
312
476
|
return {
|
|
313
477
|
row: 0,
|
|
314
|
-
|
|
478
|
+
col: 0
|
|
315
479
|
};
|
|
316
480
|
case "End":
|
|
317
481
|
return {
|
|
318
482
|
row: numRows - 1,
|
|
319
|
-
|
|
483
|
+
col: numCols - 1
|
|
320
484
|
};
|
|
321
485
|
}
|
|
322
486
|
};
|
|
323
487
|
var useRangeSelect = (cb) => {
|
|
324
|
-
const [from, setFrom] = (0,
|
|
325
|
-
const [to, setTo] = (0,
|
|
488
|
+
const [from, setFrom] = (0, import_react4.useState)();
|
|
489
|
+
const [to, setTo] = (0, import_react4.useState)();
|
|
326
490
|
const onMouseDown = (ev) => {
|
|
327
491
|
const current = getCellAtPointer(ev);
|
|
328
492
|
setFrom(current);
|
|
@@ -335,7 +499,7 @@ var useRangeSelect = (cb) => {
|
|
|
335
499
|
const onMouseMove = (ev) => {
|
|
336
500
|
if (from) {
|
|
337
501
|
let current = getCellAtPointer(ev);
|
|
338
|
-
if (
|
|
502
|
+
if (posEquals(current, from)) {
|
|
339
503
|
current = void 0;
|
|
340
504
|
}
|
|
341
505
|
setTo(current);
|
|
@@ -348,7 +512,7 @@ var useRangeSelect = (cb) => {
|
|
|
348
512
|
const onMouseUp = (ev) => {
|
|
349
513
|
if (from) {
|
|
350
514
|
let current = getCellAtPointer(ev);
|
|
351
|
-
if (
|
|
515
|
+
if (posEquals(current, from)) {
|
|
352
516
|
current = void 0;
|
|
353
517
|
}
|
|
354
518
|
setFrom(void 0);
|
|
@@ -372,7 +536,7 @@ var useRangeSelect = (cb) => {
|
|
|
372
536
|
};
|
|
373
537
|
};
|
|
374
538
|
var createDecorations = () => {
|
|
375
|
-
const { decorations } = (0,
|
|
539
|
+
const { decorations } = (0, import_echo_schema2.create)({
|
|
376
540
|
decorations: {}
|
|
377
541
|
});
|
|
378
542
|
const addDecoration = (cellIndex, decorator) => {
|
|
@@ -407,27 +571,50 @@ var createDecorations = () => {
|
|
|
407
571
|
getAllDecorations
|
|
408
572
|
};
|
|
409
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
|
+
};
|
|
410
597
|
var FormattingModel = class {
|
|
411
|
-
constructor(
|
|
412
|
-
this.
|
|
598
|
+
constructor(_model) {
|
|
599
|
+
this._model = _model;
|
|
413
600
|
}
|
|
414
601
|
/**
|
|
415
602
|
* Get formatted string value and className for cell.
|
|
416
603
|
*/
|
|
417
604
|
getFormatting(cell) {
|
|
418
|
-
const value = this.
|
|
605
|
+
const value = this._model.getValue(cell);
|
|
419
606
|
if (value === void 0 || value === null) {
|
|
420
607
|
return {};
|
|
421
608
|
}
|
|
422
609
|
const locales = void 0;
|
|
423
|
-
const idx =
|
|
424
|
-
let formatting = this.
|
|
610
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
611
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
425
612
|
const classNames = [
|
|
426
613
|
...formatting?.classNames ?? []
|
|
427
614
|
];
|
|
428
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
429
|
-
const range =
|
|
430
|
-
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)) {
|
|
431
618
|
if (_formatting.classNames) {
|
|
432
619
|
classNames.push(..._formatting.classNames);
|
|
433
620
|
}
|
|
@@ -437,9 +624,9 @@ var FormattingModel = class {
|
|
|
437
624
|
}
|
|
438
625
|
}
|
|
439
626
|
const defaultNumber = "justify-end font-mono";
|
|
440
|
-
const type = formatting?.type ?? this.
|
|
627
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
441
628
|
switch (type) {
|
|
442
|
-
case
|
|
629
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Boolean: {
|
|
443
630
|
return {
|
|
444
631
|
value: value.toLocaleString().toUpperCase(),
|
|
445
632
|
classNames: [
|
|
@@ -451,7 +638,7 @@ var FormattingModel = class {
|
|
|
451
638
|
//
|
|
452
639
|
// Numbers.
|
|
453
640
|
//
|
|
454
|
-
case
|
|
641
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Number: {
|
|
455
642
|
return {
|
|
456
643
|
value: value.toLocaleString(locales),
|
|
457
644
|
classNames: [
|
|
@@ -460,7 +647,7 @@ var FormattingModel = class {
|
|
|
460
647
|
]
|
|
461
648
|
};
|
|
462
649
|
}
|
|
463
|
-
case
|
|
650
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Percent: {
|
|
464
651
|
return {
|
|
465
652
|
value: value * 100 + "%",
|
|
466
653
|
classNames: [
|
|
@@ -469,7 +656,7 @@ var FormattingModel = class {
|
|
|
469
656
|
]
|
|
470
657
|
};
|
|
471
658
|
}
|
|
472
|
-
case
|
|
659
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Currency: {
|
|
473
660
|
return {
|
|
474
661
|
value: value.toLocaleString(locales, {
|
|
475
662
|
style: "currency",
|
|
@@ -486,22 +673,22 @@ var FormattingModel = class {
|
|
|
486
673
|
//
|
|
487
674
|
// Dates.
|
|
488
675
|
//
|
|
489
|
-
case
|
|
490
|
-
const date = this.
|
|
676
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.DateTime: {
|
|
677
|
+
const date = this._model.toLocalDate(value);
|
|
491
678
|
return {
|
|
492
679
|
value: date.toLocaleString(locales),
|
|
493
680
|
classNames
|
|
494
681
|
};
|
|
495
682
|
}
|
|
496
|
-
case
|
|
497
|
-
const date = this.
|
|
683
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Date: {
|
|
684
|
+
const date = this._model.toLocalDate(value);
|
|
498
685
|
return {
|
|
499
686
|
value: date.toLocaleDateString(locales),
|
|
500
687
|
classNames
|
|
501
688
|
};
|
|
502
689
|
}
|
|
503
|
-
case
|
|
504
|
-
const date = this.
|
|
690
|
+
case import_chunk_STAVQ2JE.ValueTypeEnum.Time: {
|
|
691
|
+
const date = this._model.toLocalDate(value);
|
|
505
692
|
return {
|
|
506
693
|
value: date.toLocaleTimeString(locales),
|
|
507
694
|
classNames
|
|
@@ -516,84 +703,539 @@ var FormattingModel = class {
|
|
|
516
703
|
}
|
|
517
704
|
}
|
|
518
705
|
};
|
|
519
|
-
var
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
+
};
|
|
534
722
|
};
|
|
535
|
-
var
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
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();
|
|
939
|
+
}
|
|
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;
|
|
539
955
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return `${(0, import_echo3.fullyQualifiedId)(fn)}(${args})`;
|
|
956
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
957
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
543
958
|
} else {
|
|
544
|
-
return
|
|
959
|
+
return String(value);
|
|
545
960
|
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
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();
|
|
553
984
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
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];
|
|
557
1044
|
} else {
|
|
558
|
-
|
|
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
|
+
};
|
|
559
1051
|
}
|
|
560
|
-
}
|
|
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
|
+
]);
|
|
561
1188
|
};
|
|
562
|
-
var
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const [[model, formatting] = [], setModels] = (0, import_react6.useState)(void 0);
|
|
569
|
-
(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
|
+
}
|
|
570
1195
|
let model2;
|
|
571
|
-
let formatting2;
|
|
572
1196
|
const t = setTimeout(async () => {
|
|
573
|
-
model2 = new
|
|
574
|
-
readonly
|
|
575
|
-
mapFormulaBindingToId,
|
|
576
|
-
mapFormulaBindingFromId
|
|
1197
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1198
|
+
readonly
|
|
577
1199
|
});
|
|
578
|
-
await model2.
|
|
579
|
-
|
|
580
|
-
setModels([
|
|
581
|
-
model2,
|
|
582
|
-
formatting2
|
|
583
|
-
]);
|
|
1200
|
+
await model2.open();
|
|
1201
|
+
setModel(model2);
|
|
584
1202
|
});
|
|
585
1203
|
return () => {
|
|
586
1204
|
clearTimeout(t);
|
|
587
|
-
void model2?.
|
|
1205
|
+
void model2?.close();
|
|
588
1206
|
};
|
|
589
1207
|
}, [
|
|
590
1208
|
graph,
|
|
1209
|
+
sheet,
|
|
591
1210
|
readonly
|
|
592
1211
|
]);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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, {
|
|
597
1239
|
value: {
|
|
598
1240
|
model,
|
|
599
1241
|
formatting,
|
|
@@ -610,18 +1252,18 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
610
1252
|
}, children);
|
|
611
1253
|
};
|
|
612
1254
|
var CommentIndicator = () => {
|
|
613
|
-
return /* @__PURE__ */
|
|
1255
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
614
1256
|
role: "none",
|
|
615
1257
|
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
616
1258
|
});
|
|
617
1259
|
};
|
|
618
1260
|
var ThreadedCellWrapper = ({ children }) => {
|
|
619
|
-
const dispatch = (0,
|
|
620
|
-
const [isHovered, setIsHovered] =
|
|
621
|
-
const { t } = (0, import_react_ui.useTranslation)(
|
|
622
|
-
const handleClick =
|
|
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) => {
|
|
623
1265
|
void dispatch({
|
|
624
|
-
action:
|
|
1266
|
+
action: import_app_framework.LayoutAction.SET_LAYOUT,
|
|
625
1267
|
data: {
|
|
626
1268
|
element: "complementary",
|
|
627
1269
|
state: true
|
|
@@ -630,22 +1272,22 @@ var ThreadedCellWrapper = ({ children }) => {
|
|
|
630
1272
|
}, [
|
|
631
1273
|
dispatch
|
|
632
1274
|
]);
|
|
633
|
-
return /* @__PURE__ */
|
|
1275
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
634
1276
|
role: "none",
|
|
635
|
-
className:
|
|
1277
|
+
className: "relative h-full is-full",
|
|
636
1278
|
onMouseEnter: () => {
|
|
637
1279
|
setIsHovered(true);
|
|
638
1280
|
},
|
|
639
1281
|
onMouseLeave: () => {
|
|
640
1282
|
setIsHovered(false);
|
|
641
1283
|
}
|
|
642
|
-
}, /* @__PURE__ */
|
|
1284
|
+
}, /* @__PURE__ */ import_react11.default.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
643
1285
|
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
644
|
-
}, /* @__PURE__ */
|
|
1286
|
+
}, /* @__PURE__ */ import_react11.default.createElement("button", {
|
|
645
1287
|
className: "ch-button text-xs min-bs-0 p-1",
|
|
646
1288
|
onClick: handleClick,
|
|
647
1289
|
"aria-label": t("open comment for sheet cell")
|
|
648
|
-
}, /* @__PURE__ */
|
|
1290
|
+
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui.Icon, {
|
|
649
1291
|
icon: "ph--chat--regular",
|
|
650
1292
|
"aria-hidden": true
|
|
651
1293
|
}))), children);
|
|
@@ -654,18 +1296,18 @@ var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
|
654
1296
|
return {
|
|
655
1297
|
type: "comment",
|
|
656
1298
|
cellIndex,
|
|
657
|
-
decorate: (props) => /* @__PURE__ */
|
|
1299
|
+
decorate: (props) => /* @__PURE__ */ import_react11.default.createElement(ThreadedCellWrapper, props)
|
|
658
1300
|
};
|
|
659
1301
|
};
|
|
660
1302
|
var useUpdateCursorOnThreadSelection = () => {
|
|
661
1303
|
const { setCursor, model } = useSheetContext();
|
|
662
|
-
const handleScrollIntoView = (0,
|
|
1304
|
+
const handleScrollIntoView = (0, import_react11.useCallback)(({ action, data }) => {
|
|
663
1305
|
switch (action) {
|
|
664
|
-
case
|
|
665
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== (0,
|
|
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)) {
|
|
666
1308
|
return;
|
|
667
1309
|
}
|
|
668
|
-
const cellAddress =
|
|
1310
|
+
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
669
1311
|
setCursor(cellAddress);
|
|
670
1312
|
}
|
|
671
1313
|
}
|
|
@@ -673,31 +1315,31 @@ var useUpdateCursorOnThreadSelection = () => {
|
|
|
673
1315
|
model.sheet,
|
|
674
1316
|
setCursor
|
|
675
1317
|
]);
|
|
676
|
-
(0,
|
|
1318
|
+
(0, import_app_framework.useIntentResolver)(import_chunk_BNARJ5GM.SHEET_PLUGIN, handleScrollIntoView);
|
|
677
1319
|
};
|
|
678
1320
|
var useSelectThreadOnCursorChange = () => {
|
|
679
1321
|
const { cursor, model } = useSheetContext();
|
|
680
|
-
const dispatch = (0,
|
|
681
|
-
const activeThreads = (0,
|
|
1322
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1323
|
+
const activeThreads = (0, import_react11.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
682
1324
|
JSON.stringify(model.sheet.threads)
|
|
683
1325
|
]);
|
|
684
|
-
const activeThreadAddresses = (0,
|
|
1326
|
+
const activeThreadAddresses = (0, import_react11.useMemo)(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
685
1327
|
activeThreads,
|
|
686
1328
|
model.sheet
|
|
687
1329
|
]);
|
|
688
|
-
const selectClosestThread = (0,
|
|
1330
|
+
const selectClosestThread = (0, import_react11.useCallback)((cellAddress) => {
|
|
689
1331
|
if (!cellAddress || !activeThreads) {
|
|
690
1332
|
return;
|
|
691
1333
|
}
|
|
692
|
-
const closestThreadAnchor =
|
|
1334
|
+
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
693
1335
|
if (closestThreadAnchor) {
|
|
694
|
-
const closestThread = activeThreads.find((thread) => thread && thread.anchor ===
|
|
1336
|
+
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
695
1337
|
if (closestThread) {
|
|
696
1338
|
void dispatch([
|
|
697
1339
|
{
|
|
698
1340
|
action: "dxos.org/plugin/thread/action/select",
|
|
699
1341
|
data: {
|
|
700
|
-
current: (0,
|
|
1342
|
+
current: (0, import_echo2.fullyQualifiedId)(closestThread)
|
|
701
1343
|
}
|
|
702
1344
|
}
|
|
703
1345
|
]);
|
|
@@ -709,12 +1351,12 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
709
1351
|
activeThreadAddresses,
|
|
710
1352
|
model.sheet
|
|
711
1353
|
]);
|
|
712
|
-
const debounced = (0,
|
|
713
|
-
return (0,
|
|
1354
|
+
const debounced = (0, import_react11.useMemo)(() => {
|
|
1355
|
+
return (0, import_async3.debounce)((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
714
1356
|
}, [
|
|
715
1357
|
selectClosestThread
|
|
716
1358
|
]);
|
|
717
|
-
(0,
|
|
1359
|
+
(0, import_react11.useEffect)(() => {
|
|
718
1360
|
if (!cursor) {
|
|
719
1361
|
return;
|
|
720
1362
|
}
|
|
@@ -726,13 +1368,13 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
726
1368
|
};
|
|
727
1369
|
var useThreadDecorations = () => {
|
|
728
1370
|
const { decorations, model } = useSheetContext();
|
|
729
|
-
const sheet = (0,
|
|
1371
|
+
const sheet = (0, import_react11.useMemo)(() => model.sheet, [
|
|
730
1372
|
model.sheet
|
|
731
1373
|
]);
|
|
732
|
-
const sheetId = (0,
|
|
1374
|
+
const sheetId = (0, import_react11.useMemo)(() => (0, import_echo2.fullyQualifiedId)(sheet), [
|
|
733
1375
|
sheet
|
|
734
1376
|
]);
|
|
735
|
-
(0,
|
|
1377
|
+
(0, import_react11.useEffect)(() => {
|
|
736
1378
|
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
737
1379
|
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
738
1380
|
if (!sheet.threads) {
|
|
@@ -842,20 +1484,60 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
842
1484
|
{
|
|
843
1485
|
key: "Enter",
|
|
844
1486
|
run: (editor) => {
|
|
845
|
-
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
|
+
});
|
|
846
1513
|
return true;
|
|
847
1514
|
}
|
|
848
1515
|
},
|
|
849
1516
|
{
|
|
850
1517
|
key: "Escape",
|
|
851
1518
|
run: () => {
|
|
852
|
-
onClose(void 0
|
|
1519
|
+
onClose(void 0, {
|
|
1520
|
+
key: "Escape"
|
|
1521
|
+
});
|
|
853
1522
|
return true;
|
|
854
1523
|
}
|
|
855
1524
|
}
|
|
856
1525
|
]);
|
|
857
1526
|
};
|
|
858
|
-
var
|
|
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 }) => {
|
|
859
1541
|
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
860
1542
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
861
1543
|
return {
|
|
@@ -882,21 +1564,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
882
1564
|
themeMode,
|
|
883
1565
|
slots: {
|
|
884
1566
|
editor: {
|
|
885
|
-
className:
|
|
1567
|
+
className: editorVariants[variant].editor
|
|
886
1568
|
},
|
|
887
1569
|
content: {
|
|
888
|
-
className:
|
|
1570
|
+
className: editorVariants[variant].content
|
|
889
1571
|
}
|
|
890
1572
|
}
|
|
891
1573
|
})
|
|
892
1574
|
]
|
|
893
1575
|
};
|
|
894
1576
|
}, [
|
|
895
|
-
extension
|
|
1577
|
+
extension,
|
|
1578
|
+
autoFocus,
|
|
1579
|
+
value,
|
|
1580
|
+
variant,
|
|
1581
|
+
onBlur
|
|
896
1582
|
]);
|
|
897
|
-
return /* @__PURE__ */
|
|
1583
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
898
1584
|
ref: parentRef,
|
|
899
|
-
className:
|
|
1585
|
+
className: editorVariants[variant].root,
|
|
1586
|
+
style: box,
|
|
1587
|
+
...gridId && {
|
|
1588
|
+
"data-grid": gridId
|
|
1589
|
+
}
|
|
900
1590
|
});
|
|
901
1591
|
};
|
|
902
1592
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -929,7 +1619,7 @@ var highlightStyles = import_language.HighlightStyle.define([
|
|
|
929
1619
|
class: "text-unAccent"
|
|
930
1620
|
}
|
|
931
1621
|
]);
|
|
932
|
-
var languageFacet = import_state.
|
|
1622
|
+
var languageFacet = (0, import_state.singleValueFacet)();
|
|
933
1623
|
var sheetExtension = ({ functions = [] }) => {
|
|
934
1624
|
const { extension, language } = (0, import_codemirror_lang_spreadsheet.spreadsheet)({
|
|
935
1625
|
idiom: "en-US",
|
|
@@ -1009,13 +1699,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1009
1699
|
// NOTE: Useful for debugging.
|
|
1010
1700
|
closeOnBlur: false,
|
|
1011
1701
|
icons: false,
|
|
1012
|
-
tooltipClass: () => (0,
|
|
1013
|
-
// TODO(burdon): Factor out fragments.
|
|
1014
|
-
// TODO(burdon): Size to make width same as column.
|
|
1015
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
1016
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
1017
|
-
"border-separator"
|
|
1018
|
-
)
|
|
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")
|
|
1019
1703
|
}),
|
|
1020
1704
|
import_view2.keymap.of([
|
|
1021
1705
|
{
|
|
@@ -1052,7 +1736,7 @@ var rangeExtension = (onInit) => {
|
|
|
1052
1736
|
update(view2) {
|
|
1053
1737
|
const { anchor } = view2.state.selection.ranges[0];
|
|
1054
1738
|
activeRange = void 0;
|
|
1055
|
-
const
|
|
1739
|
+
const language = view2.state.facet(languageFacet);
|
|
1056
1740
|
const { topNode } = language.parser.parse(view2.state.doc.toString());
|
|
1057
1741
|
visitTree(topNode, ({ type, from, to }) => {
|
|
1058
1742
|
if (from <= anchor && to >= anchor) {
|
|
@@ -1102,7 +1786,7 @@ var visitTree = (node, callback) => {
|
|
|
1102
1786
|
}
|
|
1103
1787
|
return false;
|
|
1104
1788
|
};
|
|
1105
|
-
var
|
|
1789
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1106
1790
|
var fragments = {
|
|
1107
1791
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1108
1792
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1110,23 +1794,23 @@ var fragments = {
|
|
|
1110
1794
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1111
1795
|
};
|
|
1112
1796
|
var SheetRoot = ({ children, ...props }) => {
|
|
1113
|
-
return /* @__PURE__ */
|
|
1797
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContextProvider, props, children);
|
|
1114
1798
|
};
|
|
1115
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
1799
|
+
var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
1116
1800
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1117
1801
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1118
1802
|
useThreads();
|
|
1119
|
-
const [rows, setRows] = (0,
|
|
1803
|
+
const [rows, setRows] = (0, import_react2.useState)([
|
|
1120
1804
|
...model.sheet.rows
|
|
1121
1805
|
]);
|
|
1122
|
-
const [columns, setColumns] = (0,
|
|
1806
|
+
const [columns, setColumns] = (0, import_react2.useState)([
|
|
1123
1807
|
...model.sheet.columns
|
|
1124
1808
|
]);
|
|
1125
|
-
(0,
|
|
1126
|
-
const rowsAccessor = (0,
|
|
1809
|
+
(0, import_react2.useEffect)(() => {
|
|
1810
|
+
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1127
1811
|
"rows"
|
|
1128
1812
|
]);
|
|
1129
|
-
const columnsAccessor = (0,
|
|
1813
|
+
const columnsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1130
1814
|
"columns"
|
|
1131
1815
|
]);
|
|
1132
1816
|
const handleUpdate = (0, import_async.debounce)(() => {
|
|
@@ -1147,41 +1831,41 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1147
1831
|
}, [
|
|
1148
1832
|
model
|
|
1149
1833
|
]);
|
|
1150
|
-
(0,
|
|
1834
|
+
(0, import_react2.useEffect)(() => {
|
|
1151
1835
|
model.reset();
|
|
1152
1836
|
}, [
|
|
1153
1837
|
rows,
|
|
1154
1838
|
columns
|
|
1155
1839
|
]);
|
|
1156
1840
|
const handleMoveRows = (from, to, num = 1) => {
|
|
1157
|
-
const cursorIdx = cursor ?
|
|
1841
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
1158
1842
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
1159
1843
|
model.sheet.rows.splice(to, 0, rows2);
|
|
1160
1844
|
if (cursorIdx) {
|
|
1161
|
-
setCursor(
|
|
1845
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
1162
1846
|
}
|
|
1163
1847
|
setRows([
|
|
1164
1848
|
...model.sheet.rows
|
|
1165
1849
|
]);
|
|
1166
1850
|
};
|
|
1167
1851
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
1168
|
-
const cursorIdx = cursor ?
|
|
1852
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
1169
1853
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
1170
1854
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
1171
1855
|
if (cursorIdx) {
|
|
1172
|
-
setCursor(
|
|
1856
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
1173
1857
|
}
|
|
1174
1858
|
setColumns([
|
|
1175
1859
|
...model.sheet.columns
|
|
1176
1860
|
]);
|
|
1177
1861
|
};
|
|
1178
|
-
const [rowSizes, setRowSizes] = (0,
|
|
1179
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
1180
|
-
(0,
|
|
1181
|
-
const rowAccessor = (0,
|
|
1862
|
+
const [rowSizes, setRowSizes] = (0, import_react2.useState)();
|
|
1863
|
+
const [columnSizes, setColumnSizes] = (0, import_react2.useState)();
|
|
1864
|
+
(0, import_react2.useEffect)(() => {
|
|
1865
|
+
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1182
1866
|
"rowMeta"
|
|
1183
1867
|
]);
|
|
1184
|
-
const columnAccessor = (0,
|
|
1868
|
+
const columnAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1185
1869
|
"columnMeta"
|
|
1186
1870
|
]);
|
|
1187
1871
|
const handleUpdate = (0, import_async.debounce)(() => {
|
|
@@ -1226,54 +1910,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1226
1910
|
}));
|
|
1227
1911
|
}
|
|
1228
1912
|
};
|
|
1229
|
-
return /* @__PURE__ */
|
|
1913
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1230
1914
|
role: "none",
|
|
1231
|
-
className: (0,
|
|
1232
|
-
}, /* @__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, {
|
|
1233
1917
|
onClick: () => {
|
|
1234
1918
|
setCursor(void 0);
|
|
1235
1919
|
setRange(void 0);
|
|
1236
1920
|
setEditing(false);
|
|
1237
1921
|
}
|
|
1238
|
-
}), /* @__PURE__ */
|
|
1922
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetColumns, {
|
|
1239
1923
|
ref: columnsRef,
|
|
1240
1924
|
columns,
|
|
1241
1925
|
sizes: columnSizes,
|
|
1242
|
-
selected: cursor?.
|
|
1243
|
-
onSelect: (
|
|
1926
|
+
selected: cursor?.col,
|
|
1927
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1244
1928
|
row: -1,
|
|
1245
|
-
|
|
1929
|
+
col
|
|
1246
1930
|
}),
|
|
1247
1931
|
onResize: handleResizeColumn,
|
|
1248
1932
|
onMove: handleMoveColumns
|
|
1249
|
-
}), /* @__PURE__ */
|
|
1933
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetRows, {
|
|
1250
1934
|
ref: rowsRef,
|
|
1251
1935
|
rows,
|
|
1252
1936
|
sizes: rowSizes,
|
|
1253
1937
|
selected: cursor?.row,
|
|
1254
1938
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1255
1939
|
row,
|
|
1256
|
-
|
|
1940
|
+
col: -1
|
|
1257
1941
|
}),
|
|
1258
1942
|
onResize: handleResizeRow,
|
|
1259
1943
|
onMove: handleMoveRows
|
|
1260
|
-
}), /* @__PURE__ */
|
|
1944
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetGrid, {
|
|
1261
1945
|
ref: contentRef,
|
|
1262
1946
|
size: {
|
|
1263
1947
|
numRows: numRows ?? rows.length,
|
|
1264
|
-
|
|
1948
|
+
numCols: numCols ?? columns.length
|
|
1265
1949
|
},
|
|
1266
1950
|
rows,
|
|
1267
1951
|
columns,
|
|
1268
1952
|
rowSizes,
|
|
1269
1953
|
columnSizes
|
|
1270
|
-
}), /* @__PURE__ */
|
|
1954
|
+
}), /* @__PURE__ */ import_react2.default.createElement(GridCorner, null), /* @__PURE__ */ import_react2.default.createElement(SheetStatusBar, null));
|
|
1271
1955
|
});
|
|
1272
1956
|
var useScrollHandlers = () => {
|
|
1273
|
-
const rowsRef = (0,
|
|
1274
|
-
const columnsRef = (0,
|
|
1275
|
-
const contentRef = (0,
|
|
1276
|
-
(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)(() => {
|
|
1277
1961
|
const handleRowsScroll = (ev) => {
|
|
1278
1962
|
const { scrollTop } = ev.target;
|
|
1279
1963
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1310,13 +1994,13 @@ var useScrollHandlers = () => {
|
|
|
1310
1994
|
};
|
|
1311
1995
|
};
|
|
1312
1996
|
var GridCorner = (props) => {
|
|
1313
|
-
return /* @__PURE__ */
|
|
1997
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1314
1998
|
className: fragments.axis,
|
|
1315
1999
|
...props
|
|
1316
2000
|
});
|
|
1317
2001
|
};
|
|
1318
2002
|
var MovingOverlay = ({ label }) => {
|
|
1319
|
-
return /* @__PURE__ */
|
|
2003
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1320
2004
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1321
2005
|
}, label);
|
|
1322
2006
|
};
|
|
@@ -1327,7 +2011,7 @@ var touchConstraints = {
|
|
|
1327
2011
|
delay: 250,
|
|
1328
2012
|
tolerance: 5
|
|
1329
2013
|
};
|
|
1330
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
2014
|
+
var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1331
2015
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1332
2016
|
activationConstraint: mouseConstraints
|
|
1333
2017
|
});
|
|
@@ -1336,7 +2020,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1336
2020
|
});
|
|
1337
2021
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1338
2022
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1339
|
-
const [active, setActive] = (0,
|
|
2023
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1340
2024
|
const handleDragStart = ({ active: active2 }) => {
|
|
1341
2025
|
setActive(active2);
|
|
1342
2026
|
};
|
|
@@ -1360,18 +2044,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1360
2044
|
}
|
|
1361
2045
|
return transform;
|
|
1362
2046
|
};
|
|
1363
|
-
return /* @__PURE__ */
|
|
2047
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1364
2048
|
className: "relative flex grow overflow-hidden"
|
|
1365
|
-
}, /* @__PURE__ */
|
|
1366
|
-
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"),
|
|
1367
2051
|
style: {
|
|
1368
2052
|
width: axisWidth
|
|
1369
2053
|
}
|
|
1370
|
-
}), /* @__PURE__ */
|
|
2054
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1371
2055
|
ref: forwardRef2,
|
|
1372
2056
|
role: "rowheader",
|
|
1373
2057
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1374
|
-
}, /* @__PURE__ */
|
|
2058
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1375
2059
|
sensors,
|
|
1376
2060
|
modifiers: [
|
|
1377
2061
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1379,12 +2063,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1379
2063
|
],
|
|
1380
2064
|
onDragStart: handleDragStart,
|
|
1381
2065
|
onDragEnd: handleDragEnd
|
|
1382
|
-
}, /* @__PURE__ */
|
|
2066
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1383
2067
|
className: "flex flex-col",
|
|
1384
2068
|
style: {
|
|
1385
2069
|
width: axisWidth
|
|
1386
2070
|
}
|
|
1387
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
2071
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridRowCell, {
|
|
1388
2072
|
key: idx,
|
|
1389
2073
|
idx,
|
|
1390
2074
|
index,
|
|
@@ -1394,7 +2078,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1394
2078
|
selected: selected === index,
|
|
1395
2079
|
onResize,
|
|
1396
2080
|
onSelect
|
|
1397
|
-
}))), /* @__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, {
|
|
1398
2082
|
label: String(active.data.current.index + 1)
|
|
1399
2083
|
})), document.body))));
|
|
1400
2084
|
});
|
|
@@ -1412,9 +2096,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1412
2096
|
}
|
|
1413
2097
|
});
|
|
1414
2098
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1415
|
-
const [initialSize, setInitialSize] = (0,
|
|
1416
|
-
const [resizing, setResizing] = (0,
|
|
1417
|
-
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)();
|
|
1418
2102
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1419
2103
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1420
2104
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1435,7 +2119,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1435
2119
|
onResize?.(idx, initialSize + height, true);
|
|
1436
2120
|
setResizing(false);
|
|
1437
2121
|
};
|
|
1438
|
-
return /* @__PURE__ */
|
|
2122
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1439
2123
|
enable: {
|
|
1440
2124
|
bottom: resize
|
|
1441
2125
|
},
|
|
@@ -1447,21 +2131,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1447
2131
|
onResizeStart: handleResizeStart,
|
|
1448
2132
|
onResize: handleResize,
|
|
1449
2133
|
onResizeStop: handleResizeStop
|
|
1450
|
-
}, /* @__PURE__ */
|
|
2134
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1451
2135
|
ref: setNodeRef,
|
|
1452
2136
|
...attributes,
|
|
1453
2137
|
...listeners,
|
|
1454
|
-
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),
|
|
1455
2139
|
onClick: () => onSelect?.(index)
|
|
1456
|
-
}, /* @__PURE__ */
|
|
2140
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1457
2141
|
className: "flex w-full justify-center"
|
|
1458
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2142
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1459
2143
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1460
|
-
}), resizing && /* @__PURE__ */
|
|
2144
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1461
2145
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1462
2146
|
})));
|
|
1463
2147
|
};
|
|
1464
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
2148
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1465
2149
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1466
2150
|
activationConstraint: mouseConstraints
|
|
1467
2151
|
});
|
|
@@ -1470,7 +2154,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1470
2154
|
});
|
|
1471
2155
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1472
2156
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1473
|
-
const [active, setActive] = (0,
|
|
2157
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1474
2158
|
const handleDragStart = ({ active: active2 }) => {
|
|
1475
2159
|
setActive(active2);
|
|
1476
2160
|
};
|
|
@@ -1494,18 +2178,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1494
2178
|
}
|
|
1495
2179
|
return transform;
|
|
1496
2180
|
};
|
|
1497
|
-
return /* @__PURE__ */
|
|
2181
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1498
2182
|
className: "relative flex grow overflow-hidden"
|
|
1499
|
-
}, /* @__PURE__ */
|
|
1500
|
-
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"),
|
|
1501
2185
|
style: {
|
|
1502
2186
|
height: axisHeight
|
|
1503
2187
|
}
|
|
1504
|
-
}), /* @__PURE__ */
|
|
2188
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1505
2189
|
ref: forwardRef2,
|
|
1506
2190
|
role: "columnheader",
|
|
1507
2191
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1508
|
-
}, /* @__PURE__ */
|
|
2192
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1509
2193
|
autoScroll: {
|
|
1510
2194
|
enabled: true
|
|
1511
2195
|
},
|
|
@@ -1516,23 +2200,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1516
2200
|
],
|
|
1517
2201
|
onDragStart: handleDragStart,
|
|
1518
2202
|
onDragEnd: handleDragEnd
|
|
1519
|
-
}, /* @__PURE__ */
|
|
2203
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1520
2204
|
className: "flex h-full",
|
|
1521
2205
|
style: {
|
|
1522
2206
|
height: axisHeight
|
|
1523
2207
|
}
|
|
1524
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2208
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridColumnCell, {
|
|
1525
2209
|
key: idx,
|
|
1526
2210
|
idx,
|
|
1527
2211
|
index,
|
|
1528
|
-
label:
|
|
2212
|
+
label: columnLetter(index),
|
|
1529
2213
|
size: sizes?.[idx] ?? defaultWidth,
|
|
1530
2214
|
resize: index < columns.length - 1,
|
|
1531
2215
|
selected: selected === index,
|
|
1532
2216
|
onResize,
|
|
1533
2217
|
onSelect
|
|
1534
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1535
|
-
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)
|
|
1536
2220
|
})), document.body))));
|
|
1537
2221
|
});
|
|
1538
2222
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -1549,9 +2233,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1549
2233
|
}
|
|
1550
2234
|
});
|
|
1551
2235
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1552
|
-
const [initialSize, setInitialSize] = (0,
|
|
1553
|
-
const [resizing, setResizing] = (0,
|
|
1554
|
-
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)();
|
|
1555
2239
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1556
2240
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
1557
2241
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -1572,7 +2256,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1572
2256
|
onResize?.(idx, initialSize + width, true);
|
|
1573
2257
|
setResizing(false);
|
|
1574
2258
|
};
|
|
1575
|
-
return /* @__PURE__ */
|
|
2259
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1576
2260
|
enable: {
|
|
1577
2261
|
right: resize
|
|
1578
2262
|
},
|
|
@@ -1584,37 +2268,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1584
2268
|
onResizeStart: handleResizeStart,
|
|
1585
2269
|
onResize: handleResize,
|
|
1586
2270
|
onResizeStop: handleResizeStop
|
|
1587
|
-
}, /* @__PURE__ */
|
|
2271
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1588
2272
|
ref: setNodeRef,
|
|
1589
2273
|
...attributes,
|
|
1590
2274
|
...listeners,
|
|
1591
|
-
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),
|
|
1592
2276
|
onClick: () => onSelect?.(index)
|
|
1593
|
-
}, /* @__PURE__ */
|
|
2277
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1594
2278
|
className: "flex w-full justify-center"
|
|
1595
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2279
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1596
2280
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1597
|
-
}), resizing && /* @__PURE__ */
|
|
2281
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1598
2282
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1599
2283
|
})));
|
|
1600
2284
|
};
|
|
1601
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
2285
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
1602
2286
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
1603
2287
|
refreshRate: 200
|
|
1604
2288
|
});
|
|
1605
|
-
const scrollerRef = (0,
|
|
1606
|
-
(0,
|
|
2289
|
+
const scrollerRef = (0, import_react2.useRef)(null);
|
|
2290
|
+
(0, import_react2.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
1607
2291
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1608
|
-
const initialText = (0,
|
|
1609
|
-
const quickEdit = (0,
|
|
1610
|
-
const [, forceUpdate] = (0,
|
|
1611
|
-
(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)(() => {
|
|
1612
2296
|
const unsubscribe = model.update.on(() => {
|
|
1613
2297
|
(0, import_log.log)("updated", {
|
|
1614
2298
|
id: model.id
|
|
1615
2299
|
}, {
|
|
1616
|
-
F:
|
|
1617
|
-
L:
|
|
2300
|
+
F: __dxlog_file4,
|
|
2301
|
+
L: 738,
|
|
1618
2302
|
S: void 0,
|
|
1619
2303
|
C: (f, a) => f(...a)
|
|
1620
2304
|
});
|
|
@@ -1626,7 +2310,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1626
2310
|
}, [
|
|
1627
2311
|
model
|
|
1628
2312
|
]);
|
|
1629
|
-
const inputRef = (0,
|
|
2313
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
1630
2314
|
const handleKeyDown = (ev) => {
|
|
1631
2315
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
1632
2316
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -1731,19 +2415,18 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1731
2415
|
rowSizes,
|
|
1732
2416
|
columnSizes
|
|
1733
2417
|
});
|
|
1734
|
-
const id = (0,
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1737
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2418
|
+
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
2419
|
+
const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
|
|
2420
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1738
2421
|
ref: containerRef,
|
|
1739
2422
|
role: "grid",
|
|
1740
2423
|
className: "relative flex grow overflow-hidden"
|
|
1741
|
-
}, /* @__PURE__ */
|
|
1742
|
-
className: (0,
|
|
1743
|
-
}), /* @__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", {
|
|
1744
2427
|
ref: scrollerRef,
|
|
1745
|
-
className: (0,
|
|
1746
|
-
}, /* @__PURE__ */
|
|
2428
|
+
className: (0, import_react_ui_theme.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2429
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1747
2430
|
className: "relative select-none",
|
|
1748
2431
|
style: {
|
|
1749
2432
|
width,
|
|
@@ -1751,10 +2434,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1751
2434
|
},
|
|
1752
2435
|
onClick: () => inputRef.current?.focus(),
|
|
1753
2436
|
...handlers
|
|
1754
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2437
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react2.default.createElement(SelectionOverlay, {
|
|
1755
2438
|
root: scrollerRef.current
|
|
1756
2439
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1757
|
-
return columnRange.map(({
|
|
2440
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1758
2441
|
const style = {
|
|
1759
2442
|
position: "absolute",
|
|
1760
2443
|
top,
|
|
@@ -1764,11 +2447,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1764
2447
|
};
|
|
1765
2448
|
const cell = {
|
|
1766
2449
|
row,
|
|
1767
|
-
|
|
2450
|
+
col
|
|
1768
2451
|
};
|
|
1769
|
-
const id2 =
|
|
1770
|
-
const idx =
|
|
1771
|
-
const active =
|
|
2452
|
+
const id2 = addressToA1Notation(cell);
|
|
2453
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
2454
|
+
const active = posEquals(cursor, cell);
|
|
1772
2455
|
if (active && editing) {
|
|
1773
2456
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
1774
2457
|
const handleClose = (value2) => {
|
|
@@ -1800,7 +2483,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1800
2483
|
inputRef.current?.focus();
|
|
1801
2484
|
setEditing(false);
|
|
1802
2485
|
};
|
|
1803
|
-
return /* @__PURE__ */
|
|
2486
|
+
return /* @__PURE__ */ import_react2.default.createElement(GridCellEditor, {
|
|
1804
2487
|
key: idx,
|
|
1805
2488
|
value,
|
|
1806
2489
|
style,
|
|
@@ -1808,7 +2491,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1808
2491
|
onClose: handleClose
|
|
1809
2492
|
});
|
|
1810
2493
|
}
|
|
1811
|
-
return /* @__PURE__ */
|
|
2494
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetCell, {
|
|
1812
2495
|
key: id2,
|
|
1813
2496
|
id: id2,
|
|
1814
2497
|
cell,
|
|
@@ -1820,13 +2503,25 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1820
2503
|
}
|
|
1821
2504
|
});
|
|
1822
2505
|
});
|
|
1823
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2506
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(SheetInput, {
|
|
1824
2507
|
ref: inputRef,
|
|
1825
|
-
|
|
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,
|
|
1826
2521
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
1827
|
-
onKeyDown
|
|
2522
|
+
onKeyDown,
|
|
1828
2523
|
...attendableAttrs
|
|
1829
|
-
})
|
|
2524
|
+
}));
|
|
1830
2525
|
});
|
|
1831
2526
|
var SelectionOverlay = ({ root }) => {
|
|
1832
2527
|
const { range } = useSheetContext();
|
|
@@ -1841,7 +2536,7 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1841
2536
|
const b1 = getRelativeClientRect(root, c1);
|
|
1842
2537
|
const b2 = getRelativeClientRect(root, c2);
|
|
1843
2538
|
const bounds = getRectUnion(b1, b2);
|
|
1844
|
-
return /* @__PURE__ */
|
|
2539
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1845
2540
|
role: "none",
|
|
1846
2541
|
style: bounds,
|
|
1847
2542
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
@@ -1850,8 +2545,8 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1850
2545
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1851
2546
|
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1852
2547
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1853
|
-
const decorationsForCell = decorations.getDecorationsForCell(
|
|
1854
|
-
const decorationAddedClasses = (0,
|
|
2548
|
+
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
2549
|
+
const decorationAddedClasses = (0, import_react2.useMemo)(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
1855
2550
|
decorationsForCell
|
|
1856
2551
|
]);
|
|
1857
2552
|
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
@@ -1859,16 +2554,16 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1859
2554
|
return children;
|
|
1860
2555
|
}
|
|
1861
2556
|
const DecoratorComponent = decorate;
|
|
1862
|
-
return /* @__PURE__ */
|
|
1863
|
-
}, /* @__PURE__ */
|
|
2557
|
+
return /* @__PURE__ */ import_react2.default.createElement(DecoratorComponent, null, children);
|
|
2558
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1864
2559
|
role: "none",
|
|
1865
|
-
className: (0,
|
|
2560
|
+
className: (0, import_react_ui_theme.mx)("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
1866
2561
|
}, value));
|
|
1867
|
-
return /* @__PURE__ */
|
|
2562
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1868
2563
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1869
2564
|
role: "cell",
|
|
1870
2565
|
style,
|
|
1871
|
-
className: (0,
|
|
2566
|
+
className: (0, import_react_ui_theme.mx)("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1872
2567
|
"z-20",
|
|
1873
2568
|
fragments.cellSelected
|
|
1874
2569
|
], classNames),
|
|
@@ -1886,32 +2581,32 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1886
2581
|
};
|
|
1887
2582
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1888
2583
|
const { model, range } = useSheetContext();
|
|
1889
|
-
const notifier = (0,
|
|
1890
|
-
(0,
|
|
2584
|
+
const notifier = (0, import_react2.useRef)();
|
|
2585
|
+
(0, import_react2.useEffect)(() => {
|
|
1891
2586
|
if (range) {
|
|
1892
|
-
notifier.current?.(
|
|
2587
|
+
notifier.current?.(rangeToA1Notation(range));
|
|
1893
2588
|
}
|
|
1894
2589
|
}, [
|
|
1895
2590
|
range
|
|
1896
2591
|
]);
|
|
1897
|
-
const extension = (0,
|
|
2592
|
+
const extension = (0, import_react2.useMemo)(() => [
|
|
1898
2593
|
editorKeys({
|
|
1899
2594
|
onNav,
|
|
1900
2595
|
onClose
|
|
1901
2596
|
}),
|
|
1902
2597
|
sheetExtension({
|
|
1903
|
-
functions: model.
|
|
2598
|
+
functions: model.graph.getFunctions()
|
|
1904
2599
|
}),
|
|
1905
2600
|
rangeExtension((fn) => notifier.current = fn)
|
|
1906
2601
|
], [
|
|
1907
2602
|
model
|
|
1908
2603
|
]);
|
|
1909
|
-
return /* @__PURE__ */
|
|
2604
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1910
2605
|
role: "cell",
|
|
1911
2606
|
style,
|
|
1912
|
-
className: (0,
|
|
2607
|
+
className: (0, import_react_ui_theme.mx)("z-20 flex", fragments.cellSelected),
|
|
1913
2608
|
onClick: (ev) => ev.stopPropagation()
|
|
1914
|
-
}, /* @__PURE__ */
|
|
2609
|
+
}, /* @__PURE__ */ import_react2.default.createElement(CellEditor, {
|
|
1915
2610
|
autoFocus: true,
|
|
1916
2611
|
value,
|
|
1917
2612
|
extension
|
|
@@ -1924,31 +2619,31 @@ var SheetStatusBar = () => {
|
|
|
1924
2619
|
if (cursor) {
|
|
1925
2620
|
value = model.getCellValue(cursor);
|
|
1926
2621
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1927
|
-
value = model.
|
|
2622
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1928
2623
|
isFormula = true;
|
|
1929
2624
|
} else if (value != null) {
|
|
1930
2625
|
value = String(value);
|
|
1931
2626
|
}
|
|
1932
2627
|
}
|
|
1933
|
-
return /* @__PURE__ */
|
|
1934
|
-
className: (0,
|
|
1935
|
-
}, /* @__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", {
|
|
1936
2631
|
className: "flex gap-4 items-center"
|
|
1937
|
-
}, /* @__PURE__ */
|
|
2632
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1938
2633
|
className: "flex w-16 items-center font-mono"
|
|
1939
|
-
}, range &&
|
|
2634
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1940
2635
|
className: "flex gap-2 items-center"
|
|
1941
|
-
}, /* @__PURE__ */
|
|
1942
|
-
className: (0,
|
|
1943
|
-
}), /* @__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", {
|
|
1944
2639
|
className: "font-mono"
|
|
1945
2640
|
}, value))));
|
|
1946
2641
|
};
|
|
1947
2642
|
var SheetDebug = () => {
|
|
1948
2643
|
const { model, cursor, range } = useSheetContext();
|
|
1949
|
-
const [, forceUpdate] = (0,
|
|
1950
|
-
(0,
|
|
1951
|
-
const accessor = (0,
|
|
2644
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2645
|
+
(0, import_react2.useEffect)(() => {
|
|
2646
|
+
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
1952
2647
|
const handleUpdate = () => forceUpdate({});
|
|
1953
2648
|
accessor.handle.addListener("change", handleUpdate);
|
|
1954
2649
|
handleUpdate();
|
|
@@ -1958,9 +2653,9 @@ var SheetDebug = () => {
|
|
|
1958
2653
|
}, [
|
|
1959
2654
|
model
|
|
1960
2655
|
]);
|
|
1961
|
-
return /* @__PURE__ */
|
|
1962
|
-
className: (0,
|
|
1963
|
-
}, /* @__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", {
|
|
1964
2659
|
className: "whitespace-pre-wrap"
|
|
1965
2660
|
}, JSON.stringify({
|
|
1966
2661
|
cursor,
|
|
@@ -1981,232 +2676,15 @@ var Sheet = {
|
|
|
1981
2676
|
StatusBar: SheetStatusBar,
|
|
1982
2677
|
Debug: SheetDebug
|
|
1983
2678
|
};
|
|
1984
|
-
var iconStyles = (0, import_react_ui_theme5.getSize)(5);
|
|
1985
|
-
var buttonStyles = "min-bs-0 p-2";
|
|
1986
|
-
var tooltipProps = {
|
|
1987
|
-
side: "top",
|
|
1988
|
-
classNames: "z-10"
|
|
1989
|
-
};
|
|
1990
|
-
var ToolbarSeparator = () => /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1991
|
-
role: "separator",
|
|
1992
|
-
className: "grow"
|
|
1993
|
-
});
|
|
1994
|
-
var ToolbarButton = ({ Icon: Icon2, children, ...props }) => {
|
|
1995
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Trigger, {
|
|
1996
|
-
asChild: true
|
|
1997
|
-
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Toolbar.Button, {
|
|
1998
|
-
variant: "ghost",
|
|
1999
|
-
...props,
|
|
2000
|
-
classNames: buttonStyles
|
|
2001
|
-
}, /* @__PURE__ */ import_react11.default.createElement(Icon2, {
|
|
2002
|
-
className: iconStyles
|
|
2003
|
-
}), /* @__PURE__ */ import_react11.default.createElement("span", {
|
|
2004
|
-
className: "sr-only"
|
|
2005
|
-
}, children))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Content, tooltipProps, children, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Arrow, null))));
|
|
2006
|
-
};
|
|
2007
|
-
var ToolbarToggleButton = ({ Icon: Icon2, children, ...props }) => {
|
|
2008
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Trigger, {
|
|
2009
|
-
asChild: true
|
|
2010
|
-
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Toolbar.ToggleGroupItem, {
|
|
2011
|
-
variant: "ghost",
|
|
2012
|
-
...props,
|
|
2013
|
-
classNames: buttonStyles
|
|
2014
|
-
}, /* @__PURE__ */ import_react11.default.createElement(Icon2, {
|
|
2015
|
-
className: iconStyles
|
|
2016
|
-
}), /* @__PURE__ */ import_react11.default.createElement("span", {
|
|
2017
|
-
className: "sr-only"
|
|
2018
|
-
}, children))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Content, tooltipProps, children, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Arrow, null))));
|
|
2019
|
-
};
|
|
2020
|
-
var [ToolbarContextProvider, useToolbarContext] = (0, import_react_context.createContext)("Toolbar");
|
|
2021
|
-
var ToolbarRoot = ({ children, onAction, classNames }) => {
|
|
2022
|
-
return /* @__PURE__ */ import_react10.default.createElement(ToolbarContextProvider, {
|
|
2023
|
-
onAction
|
|
2024
|
-
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.DensityProvider, {
|
|
2025
|
-
density: "fine"
|
|
2026
|
-
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.ElevationProvider, {
|
|
2027
|
-
elevation: "chrome"
|
|
2028
|
-
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.Root, {
|
|
2029
|
-
classNames: [
|
|
2030
|
-
"is-full shrink-0 overflow-x-auto overflow-y-hidden p-1",
|
|
2031
|
-
classNames
|
|
2032
|
-
]
|
|
2033
|
-
}, children))));
|
|
2034
|
-
};
|
|
2035
|
-
var formatOptions = [
|
|
2036
|
-
{
|
|
2037
|
-
type: "date",
|
|
2038
|
-
Icon: import_react9.Calendar,
|
|
2039
|
-
getState: (state) => false
|
|
2040
|
-
},
|
|
2041
|
-
{
|
|
2042
|
-
type: "currency",
|
|
2043
|
-
Icon: import_react9.CurrencyDollar,
|
|
2044
|
-
getState: (state) => false
|
|
2045
|
-
}
|
|
2046
|
-
];
|
|
2047
|
-
var Format = () => {
|
|
2048
|
-
const { onAction } = useToolbarContext("Format");
|
|
2049
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2050
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.ToggleGroup, {
|
|
2051
|
-
type: "single"
|
|
2052
|
-
}, formatOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ import_react10.default.createElement(ToolbarToggleButton, {
|
|
2053
|
-
key: type,
|
|
2054
|
-
value: type,
|
|
2055
|
-
Icon: Icon2,
|
|
2056
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2057
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2058
|
-
onClick: () => onAction?.({
|
|
2059
|
-
type
|
|
2060
|
-
})
|
|
2061
|
-
}, t(`toolbar ${type} label`))));
|
|
2062
|
-
};
|
|
2063
|
-
var alignmentOptions = [
|
|
2064
|
-
{
|
|
2065
|
-
type: "left",
|
|
2066
|
-
Icon: import_react9.TextAlignLeft,
|
|
2067
|
-
getState: (state) => false
|
|
2068
|
-
},
|
|
2069
|
-
{
|
|
2070
|
-
type: "center",
|
|
2071
|
-
Icon: import_react9.TextAlignCenter,
|
|
2072
|
-
getState: (state) => false
|
|
2073
|
-
},
|
|
2074
|
-
{
|
|
2075
|
-
type: "right",
|
|
2076
|
-
Icon: import_react9.TextAlignRight,
|
|
2077
|
-
getState: (state) => false
|
|
2078
|
-
}
|
|
2079
|
-
];
|
|
2080
|
-
var Alignment = () => {
|
|
2081
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
2082
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2083
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.ToggleGroup, {
|
|
2084
|
-
type: "single"
|
|
2085
|
-
}, alignmentOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ import_react10.default.createElement(ToolbarToggleButton, {
|
|
2086
|
-
key: type,
|
|
2087
|
-
value: type,
|
|
2088
|
-
Icon: Icon2,
|
|
2089
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2090
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2091
|
-
onClick: () => onAction?.({
|
|
2092
|
-
type
|
|
2093
|
-
})
|
|
2094
|
-
}, t(`toolbar ${type} label`))));
|
|
2095
|
-
};
|
|
2096
|
-
var styleOptions = [
|
|
2097
|
-
{
|
|
2098
|
-
type: "clear",
|
|
2099
|
-
Icon: import_react9.Eraser,
|
|
2100
|
-
getState: (state) => false
|
|
2101
|
-
},
|
|
2102
|
-
{
|
|
2103
|
-
type: "highlight",
|
|
2104
|
-
Icon: import_react9.HighlighterCircle,
|
|
2105
|
-
getState: (state) => false
|
|
2106
|
-
}
|
|
2107
|
-
];
|
|
2108
|
-
var Styles = () => {
|
|
2109
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
2110
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2111
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.ToggleGroup, {
|
|
2112
|
-
type: "single"
|
|
2113
|
-
}, styleOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ import_react10.default.createElement(ToolbarToggleButton, {
|
|
2114
|
-
key: type,
|
|
2115
|
-
value: type,
|
|
2116
|
-
Icon: Icon2,
|
|
2117
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2118
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2119
|
-
onClick: () => onAction?.({
|
|
2120
|
-
type
|
|
2121
|
-
})
|
|
2122
|
-
}, t(`toolbar ${type} label`))));
|
|
2123
|
-
};
|
|
2124
|
-
var Actions = () => {
|
|
2125
|
-
const { onAction } = useToolbarContext("Actions");
|
|
2126
|
-
const { cursor, range, model } = useSheetContext();
|
|
2127
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2128
|
-
const overlapsCommentAnchor = (model.sheet.threads ?? []).filter(import_util.nonNullable).filter((thread) => thread.status !== "resolved").some((thread) => {
|
|
2129
|
-
if (!cursor) {
|
|
2130
|
-
return false;
|
|
2131
|
-
}
|
|
2132
|
-
return (0, import_chunk_ZRQZFV5T.addressToIndex)(model.sheet, cursor) === thread.anchor;
|
|
2133
|
-
});
|
|
2134
|
-
const hasCursor = !!cursor;
|
|
2135
|
-
const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;
|
|
2136
|
-
const tooltipLabelKey = !hasCursor ? "no cursor label" : overlapsCommentAnchor ? "selection overlaps existing comment label" : range ? "comment ranges not supported label" : "comment label";
|
|
2137
|
-
return /* @__PURE__ */ import_react10.default.createElement(ToolbarButton, {
|
|
2138
|
-
value: "comment",
|
|
2139
|
-
Icon: import_react9.ChatText,
|
|
2140
|
-
"data-testid": "editor.toolbar.comment",
|
|
2141
|
-
onClick: () => {
|
|
2142
|
-
if (!cursor) {
|
|
2143
|
-
return;
|
|
2144
|
-
}
|
|
2145
|
-
return onAction?.({
|
|
2146
|
-
type: "comment",
|
|
2147
|
-
anchor: (0, import_chunk_ZRQZFV5T.addressToIndex)(model.sheet, cursor),
|
|
2148
|
-
cellContent: model.getCellText(cursor)
|
|
2149
|
-
});
|
|
2150
|
-
},
|
|
2151
|
-
disabled: !cursorOnly || overlapsCommentAnchor
|
|
2152
|
-
}, t(tooltipLabelKey));
|
|
2153
|
-
};
|
|
2154
|
-
var Toolbar = {
|
|
2155
|
-
Root: ToolbarRoot,
|
|
2156
|
-
Separator: ToolbarSeparator,
|
|
2157
|
-
Alignment,
|
|
2158
|
-
Format,
|
|
2159
|
-
Styles,
|
|
2160
|
-
Actions
|
|
2161
|
-
};
|
|
2162
|
-
var attentionFragment = (0, import_react_ui_theme.mx)("group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface", "group-focus-within/editor:border-separator");
|
|
2163
|
-
var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
|
|
2164
|
-
var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
|
|
2165
|
-
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
2166
|
-
const id = (0, import_echo.fullyQualifiedId)(sheet);
|
|
2167
|
-
const isDirectlyAttended = (0, import_react_ui_attention.useIsDirectlyAttended)(id);
|
|
2168
|
-
const handleAction = (0, import_react.useCallback)((action) => {
|
|
2169
|
-
switch (action.type) {
|
|
2170
|
-
case "comment": {
|
|
2171
|
-
void dispatch({
|
|
2172
|
-
action: "dxos.org/plugin/thread/action/create",
|
|
2173
|
-
data: {
|
|
2174
|
-
cursor: action.anchor,
|
|
2175
|
-
name: action.cellContent,
|
|
2176
|
-
subject: sheet
|
|
2177
|
-
}
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
}, [
|
|
2182
|
-
sheet,
|
|
2183
|
-
dispatch
|
|
2184
|
-
]);
|
|
2185
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2186
|
-
role: "none",
|
|
2187
|
-
className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0
|
|
2188
|
-
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Root, {
|
|
2189
|
-
sheet,
|
|
2190
|
-
space,
|
|
2191
|
-
remoteFunctionUrl
|
|
2192
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2193
|
-
role: "none",
|
|
2194
|
-
className: (0, import_react_ui_theme.mx)("flex flex-0 justify-center overflow-x-auto")
|
|
2195
|
-
}, /* @__PURE__ */ import_react.default.createElement(Toolbar.Root, {
|
|
2196
|
-
onAction: handleAction,
|
|
2197
|
-
classNames: (0, import_react_ui_theme.mx)(role === "section" ? [
|
|
2198
|
-
"z-[2] group-focus-within/section:visible",
|
|
2199
|
-
!isDirectlyAttended && "invisible",
|
|
2200
|
-
sectionToolbarLayout
|
|
2201
|
-
] : "group-focus-within/editor:border-separator group-[[aria-current]]/editor:border-separator")
|
|
2202
|
-
}, /* @__PURE__ */ import_react.default.createElement(Toolbar.Separator, null), /* @__PURE__ */ import_react.default.createElement(Toolbar.Actions, null))), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2203
|
-
role: "none",
|
|
2204
|
-
className: (0, import_react_ui_theme.mx)(role === "section" && "aspect-square border-is border-bs border-be border-separator", role === "article" && "flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator", import_react_ui_theme.focusRing, attentionFragment)
|
|
2205
|
-
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Main, null))));
|
|
2206
|
-
};
|
|
2207
|
-
var SheetContainer_default = SheetContainer;
|
|
2208
2679
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2209
2680
|
0 && (module.exports = {
|
|
2210
|
-
|
|
2681
|
+
ComputeGraphContextProvider,
|
|
2682
|
+
Sheet,
|
|
2683
|
+
SheetContainer,
|
|
2684
|
+
addressToIndex,
|
|
2685
|
+
compareIndexPositions,
|
|
2686
|
+
createSheet,
|
|
2687
|
+
useComputeGraph,
|
|
2688
|
+
useSheetContext
|
|
2211
2689
|
});
|
|
2212
|
-
//# sourceMappingURL=
|
|
2690
|
+
//# sourceMappingURL=chunk-2K53Z2TU.cjs.map
|