@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-staging.9e90729
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-AKWROARP.mjs → SheetContainer-JBB7W52Y.mjs} +42 -52
- package/dist/lib/browser/SheetContainer-JBB7W52Y.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-2ZK3YMZG.mjs} +248 -33
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs.map → chunk-2ZK3YMZG.mjs.map} +4 -4
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-3QWIMZZJ.mjs} +2 -11
- package/dist/lib/browser/chunk-3QWIMZZJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-XXDHBYZQ.mjs} +553 -668
- package/dist/lib/browser/chunk-XXDHBYZQ.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-ZQKB6QVP.mjs} +4 -2
- package/dist/lib/browser/index.mjs +57 -14
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-L37HUFCF.cjs} +44 -58
- package/dist/lib/node/SheetContainer-L37HUFCF.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-7AWAC3R3.cjs} +517 -645
- package/dist/lib/node/chunk-7AWAC3R3.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-QNFMTK3X.cjs} +252 -28
- package/dist/lib/node/{chunk-5XPK2V4A.cjs.map → chunk-QNFMTK3X.cjs.map} +4 -4
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-V7E5JZBD.cjs} +5 -14
- package/dist/lib/node/chunk-V7E5JZBD.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-RJB6OVW6.cjs} +21 -19
- package/dist/lib/node/compute-graph-RJB6OVW6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +66 -27
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +6 -6
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-CLKFEM35.mjs} +42 -52
- package/dist/lib/node-esm/SheetContainer-CLKFEM35.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-3JYJEOCF.mjs} +553 -668
- package/dist/lib/node-esm/chunk-3JYJEOCF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-JBTORSST.mjs} +247 -33
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs.map → chunk-JBTORSST.mjs.map} +4 -4
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-SPQFLYC2.mjs} +2 -11
- package/dist/lib/node-esm/chunk-SPQFLYC2.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-VKRG526N.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +57 -14
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +9 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/index.d.ts +2 -0
- package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +7 -5
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/{graph → compute-graph}/compute-graph.d.ts +1 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/compute-graph/util.d.ts.map +1 -0
- package/dist/types/src/defs/index.d.ts +1 -1
- package/dist/types/src/defs/index.d.ts.map +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/defs/types.d.ts +6 -0
- package/dist/types/src/defs/types.d.ts.map +1 -1
- package/dist/types/src/defs/util.d.ts +2 -6
- package/dist/types/src/defs/util.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +23 -3
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/index.d.ts +2 -0
- package/dist/types/src/integrations/index.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts +8 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +1 -1
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/{hooks → model}/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +4 -0
- package/dist/types/src/serializer.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +6 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -30
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +43 -50
- package/src/SheetPlugin.tsx +23 -10
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +5 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
- package/src/components/GridSheet/GridSheet.tsx +114 -19
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +17 -7
- package/src/components/RangeList/RangeList.tsx +38 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +1 -1
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +34 -35
- package/src/components/index.ts +1 -0
- package/src/{graph → compute-graph}/compute-graph.stories.tsx +2 -1
- package/src/{graph → compute-graph}/compute-graph.ts +5 -2
- package/src/{graph → compute-graph}/compute-node.ts +2 -3
- package/src/defs/index.ts +1 -1
- package/src/defs/sheet-range-types.ts +1 -0
- package/src/defs/types.ts +6 -1
- package/src/defs/util.ts +3 -19
- package/src/extensions/compute.stories.tsx +2 -2
- package/src/extensions/compute.ts +2 -2
- package/src/extensions/editor/extension.test.ts +1 -1
- package/src/extensions/editor/extension.ts +48 -23
- package/src/index.ts +2 -2
- package/src/integrations/index.ts +5 -0
- package/src/integrations/thread-ranges.ts +101 -0
- package/src/model/index.ts +1 -1
- package/src/model/sheet-model.test.ts +1 -1
- package/src/model/sheet-model.ts +13 -8
- package/src/{hooks → model}/useSheetModel.ts +1 -1
- package/src/serializer.ts +27 -0
- package/src/testing/testing.tsx +1 -1
- package/src/translations.ts +6 -0
- package/src/types.ts +3 -1
- package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +0 -7
- package/dist/lib/node/chunk-53BMSUIK.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -6
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -26
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/src/hooks/hooks.stories.tsx +0 -53
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/model/decorations.ts +0 -66
- /package/dist/lib/browser/{graph-M4IQ76QX.mjs.map → compute-graph-ZQKB6QVP.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-VKRG526N.mjs.map} +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph-registry.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.stories.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-node.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/async-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/edge-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/function-defs.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/hyperformula.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-builder.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-plugin.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/util.d.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph-registry.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph.test.ts +0 -0
- /package/src/{graph → compute-graph}/functions/async-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/edge-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/function-defs.ts +0 -0
- /package/src/{graph → compute-graph}/functions/index.ts +0 -0
- /package/src/{graph → compute-graph}/hyperformula.test.ts +0 -0
- /package/src/{graph → compute-graph}/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-builder.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-plugin.ts +0 -0
- /package/src/{graph → compute-graph}/util.ts +0 -0
|
@@ -26,74 +26,69 @@ 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(
|
|
29
|
+
var chunk_7AWAC3R3_exports = {};
|
|
30
|
+
__export(chunk_7AWAC3R3_exports, {
|
|
31
31
|
ComputeGraphContextProvider: () => ComputeGraphContextProvider,
|
|
32
32
|
GridSheet: () => GridSheet,
|
|
33
|
+
RangeList: () => RangeList,
|
|
33
34
|
SheetContainer: () => SheetContainer,
|
|
34
35
|
SheetProvider: () => SheetProvider,
|
|
35
|
-
|
|
36
|
-
addressToIndex: () => addressToIndex,
|
|
37
|
-
compareIndexPositions: () => compareIndexPositions,
|
|
36
|
+
completeCellRangeToThreadCursor: () => completeCellRangeToThreadCursor,
|
|
38
37
|
computeGraphFacet: () => computeGraphFacet,
|
|
39
|
-
createSheet: () => createSheet,
|
|
40
|
-
inRange: () => inRange,
|
|
41
|
-
rangeToA1Notation: () => rangeToA1Notation,
|
|
42
38
|
useComputeGraph: () => useComputeGraph,
|
|
43
39
|
useSheetContext: () => useSheetContext
|
|
44
40
|
});
|
|
45
|
-
module.exports = __toCommonJS(
|
|
46
|
-
var
|
|
41
|
+
module.exports = __toCommonJS(chunk_7AWAC3R3_exports);
|
|
42
|
+
var import_chunk_QNFMTK3X = require("./chunk-QNFMTK3X.cjs");
|
|
43
|
+
var import_chunk_V7E5JZBD = require("./chunk-V7E5JZBD.cjs");
|
|
47
44
|
var import_chunk_QIFIGEKV = require("./chunk-QIFIGEKV.cjs");
|
|
48
|
-
var import_chunk_5XPK2V4A = require("./chunk-5XPK2V4A.cjs");
|
|
49
45
|
var import_react = __toESM(require("react"));
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var import_invariant = require("@dxos/invariant");
|
|
46
|
+
var import_debug = require("@dxos/debug");
|
|
47
|
+
var import_react_hooks = require("@dxos/react-hooks");
|
|
53
48
|
var import_language = require("@codemirror/language");
|
|
54
49
|
var import_state = require("@codemirror/state");
|
|
55
50
|
var import_view = require("@codemirror/view");
|
|
56
51
|
var import_async = require("@dxos/async");
|
|
57
|
-
var
|
|
58
|
-
var
|
|
52
|
+
var import_invariant = require("@dxos/invariant");
|
|
53
|
+
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
59
54
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
60
55
|
var import_language2 = require("@codemirror/language");
|
|
61
56
|
var import_view2 = require("@codemirror/view");
|
|
62
57
|
var import_highlight = require("@lezer/highlight");
|
|
63
58
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
64
|
-
var
|
|
59
|
+
var import_react_ui_editor2 = require("@dxos/react-ui-editor");
|
|
65
60
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
66
|
-
var import_react2 = require("react");
|
|
67
|
-
var
|
|
68
|
-
var import_react_hooks = require("@dxos/react-hooks");
|
|
69
|
-
var import_react3 = require("react");
|
|
70
|
-
var import_react4 = __toESM(require("react"));
|
|
71
|
-
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
72
|
-
var import_react_ui_grid = require("@dxos/react-ui-grid");
|
|
73
|
-
var import_react5 = require("react");
|
|
61
|
+
var import_react2 = __toESM(require("react"));
|
|
62
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
74
63
|
var import_echo = require("@dxos/react-client/echo");
|
|
75
|
-
var
|
|
76
|
-
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
77
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
78
|
-
var import_react6 = require("react");
|
|
79
|
-
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
64
|
+
var import_react_ui_grid = require("@dxos/react-ui-grid");
|
|
80
65
|
var import_async2 = require("@dxos/async");
|
|
81
66
|
var import_context = require("@dxos/context");
|
|
82
|
-
var
|
|
67
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
83
68
|
var import_invariant3 = require("@dxos/invariant");
|
|
84
69
|
var import_keys = require("@dxos/keys");
|
|
85
70
|
var import_log = require("@dxos/log");
|
|
86
71
|
var import_schema = require("@dxos/schema");
|
|
87
72
|
var import_hyperformula = require("#hyperformula");
|
|
88
|
-
var
|
|
89
|
-
var
|
|
73
|
+
var import_react3 = require("react");
|
|
74
|
+
var import_react4 = __toESM(require("react"));
|
|
75
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
76
|
+
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
77
|
+
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
78
|
+
var import_react5 = require("react");
|
|
79
|
+
var import_echo2 = require("@dxos/react-client/echo");
|
|
80
|
+
var import_react_ui_data = require("@dxos/react-ui-data");
|
|
81
|
+
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
82
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
83
|
+
var import_react6 = require("react");
|
|
90
84
|
var import_app_framework = require("@dxos/app-framework");
|
|
91
85
|
var import_async3 = require("@dxos/async");
|
|
92
|
-
var import_echo2 = require("@dxos/react-client/echo");
|
|
93
|
-
var import_react8 = __toESM(require("react"));
|
|
94
|
-
var import_invariant4 = require("@dxos/invariant");
|
|
95
86
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
96
|
-
var
|
|
87
|
+
var import_react7 = require("react");
|
|
88
|
+
var import_react8 = __toESM(require("react"));
|
|
89
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
90
|
+
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
91
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
97
92
|
var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
|
|
98
93
|
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
99
94
|
return /* @__PURE__ */ import_react.default.createElement(ComputeGraphContext.Provider, {
|
|
@@ -102,184 +97,22 @@ var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
|
102
97
|
}
|
|
103
98
|
}, children);
|
|
104
99
|
};
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
var columnLetter = (col) => {
|
|
114
|
-
(0, import_invariant.invariant)(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
115
|
-
F: __dxlog_file,
|
|
116
|
-
L: 26,
|
|
117
|
-
S: void 0,
|
|
118
|
-
A: [
|
|
119
|
-
"col < MAX_COLUMNS",
|
|
120
|
-
"`Invalid column: ${col}`"
|
|
121
|
-
]
|
|
122
|
-
});
|
|
123
|
-
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
124
|
-
};
|
|
125
|
-
var addressToA1Notation = ({ col, row }) => {
|
|
126
|
-
return `${columnLetter(col)}${row + 1}`;
|
|
127
|
-
};
|
|
128
|
-
var addressFromA1Notation = (ref) => {
|
|
129
|
-
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
130
|
-
(0, import_invariant.invariant)(match, `Invalid notation: ${ref}`, {
|
|
131
|
-
F: __dxlog_file,
|
|
132
|
-
L: 40,
|
|
133
|
-
S: void 0,
|
|
134
|
-
A: [
|
|
135
|
-
"match",
|
|
136
|
-
"`Invalid notation: ${ref}`"
|
|
137
|
-
]
|
|
138
|
-
});
|
|
139
|
-
return {
|
|
140
|
-
row: parseInt(match[2], 10) - 1,
|
|
141
|
-
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
var rangeToA1Notation = (range) => {
|
|
145
|
-
return [
|
|
146
|
-
range?.from && addressToA1Notation(range?.from),
|
|
147
|
-
range?.to && addressToA1Notation(range?.to)
|
|
148
|
-
].filter(Boolean).join(":");
|
|
149
|
-
};
|
|
150
|
-
var inRange = (range, cell) => {
|
|
151
|
-
if (!range) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
const { from, to } = range;
|
|
155
|
-
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
if (!from || !to) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
const { col: c1, row: r1 } = from;
|
|
162
|
-
const { col: c2, row: r2 } = to;
|
|
163
|
-
const cMin = Math.min(c1, c2);
|
|
164
|
-
const cMax = Math.max(c1, c2);
|
|
165
|
-
const rMin = Math.min(r1, r2);
|
|
166
|
-
const rMax = Math.max(r1, r2);
|
|
167
|
-
const { col, row } = cell;
|
|
168
|
-
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
169
|
-
};
|
|
170
|
-
var ApiError = class extends Error {
|
|
171
|
-
};
|
|
172
|
-
var ReadonlyException = class extends ApiError {
|
|
173
|
-
};
|
|
174
|
-
var RangeException = class extends ApiError {
|
|
175
|
-
constructor(n) {
|
|
176
|
-
super();
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
var createIndex = (length = 8) => {
|
|
180
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
181
|
-
const charactersLength = characters.length;
|
|
182
|
-
const randomBuffer = (0, import_crypto.randomBytes)(length);
|
|
183
|
-
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
184
|
-
};
|
|
185
|
-
var createIndices = (length) => Array.from({
|
|
186
|
-
length
|
|
187
|
-
}).map(() => createIndex());
|
|
188
|
-
var insertIndices = (indices, i, n, max) => {
|
|
189
|
-
if (i + n > max) {
|
|
190
|
-
throw new RangeException(i + n);
|
|
191
|
-
}
|
|
192
|
-
const idx = createIndices(n);
|
|
193
|
-
indices.splice(i, 0, ...idx);
|
|
194
|
-
};
|
|
195
|
-
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
196
|
-
if (!sheet.rows.length) {
|
|
197
|
-
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
198
|
-
}
|
|
199
|
-
if (!sheet.columns.length) {
|
|
200
|
-
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
var createSheet = ({ name, cells, ...size } = {}) => {
|
|
204
|
-
const sheet = (0, import_echo_schema.create)(import_chunk_NZARD7UP.SheetType, {
|
|
205
|
-
name,
|
|
206
|
-
cells: {},
|
|
207
|
-
rows: [],
|
|
208
|
-
columns: [],
|
|
209
|
-
rowMeta: {},
|
|
210
|
-
columnMeta: {},
|
|
211
|
-
ranges: []
|
|
212
|
-
});
|
|
213
|
-
initialize(sheet, size);
|
|
214
|
-
if (cells) {
|
|
215
|
-
Object.entries(cells).forEach(([key, { value }]) => {
|
|
216
|
-
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
217
|
-
sheet.cells[idx] = {
|
|
218
|
-
value
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return sheet;
|
|
223
|
-
};
|
|
224
|
-
var addressToIndex = (sheet, cell) => {
|
|
225
|
-
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
226
|
-
};
|
|
227
|
-
var addressFromIndex = (sheet, idx) => {
|
|
228
|
-
const [column, row] = idx.split("@");
|
|
229
|
-
return {
|
|
230
|
-
col: sheet.columns.indexOf(column),
|
|
231
|
-
row: sheet.rows.indexOf(row)
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
var closest = (cursor, cells) => {
|
|
235
|
-
let closestCell2;
|
|
236
|
-
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
237
|
-
for (const cell of cells) {
|
|
238
|
-
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
239
|
-
if (distance < closestDistance) {
|
|
240
|
-
closestCell2 = cell;
|
|
241
|
-
closestDistance = distance;
|
|
100
|
+
var useComputeGraph = (space) => {
|
|
101
|
+
const { registry } = (0, import_react.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
|
|
102
|
+
const [graph] = (0, import_react_hooks.useAsyncState)(async () => {
|
|
103
|
+
if (space) {
|
|
104
|
+
const graph2 = registry.getOrCreateGraph(space);
|
|
105
|
+
await graph2.open();
|
|
106
|
+
return graph2;
|
|
242
107
|
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
249
|
-
if (rowA !== rowB) {
|
|
250
|
-
return rowA - rowB;
|
|
251
|
-
} else {
|
|
252
|
-
return columnA - columnB;
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
var cellClassNameForRange = ({ key, value }) => {
|
|
256
|
-
switch (key) {
|
|
257
|
-
case "align":
|
|
258
|
-
switch (value) {
|
|
259
|
-
case "start":
|
|
260
|
-
return "text-start";
|
|
261
|
-
case "center":
|
|
262
|
-
return "text-center";
|
|
263
|
-
case "end":
|
|
264
|
-
return "text-end";
|
|
265
|
-
default:
|
|
266
|
-
return void 0;
|
|
267
|
-
}
|
|
268
|
-
case "comment":
|
|
269
|
-
return "bg-gridComment";
|
|
270
|
-
case "style":
|
|
271
|
-
switch (value) {
|
|
272
|
-
case "highlight":
|
|
273
|
-
return "bg-gridHighlight";
|
|
274
|
-
default:
|
|
275
|
-
return void 0;
|
|
276
|
-
}
|
|
277
|
-
default:
|
|
278
|
-
return void 0;
|
|
279
|
-
}
|
|
108
|
+
}, [
|
|
109
|
+
space,
|
|
110
|
+
registry
|
|
111
|
+
]);
|
|
112
|
+
return graph;
|
|
280
113
|
};
|
|
281
114
|
var updateAllDecorations = import_state.StateEffect.define();
|
|
282
|
-
var computeGraphFacet = (0,
|
|
115
|
+
var computeGraphFacet = (0, import_react_ui_editor.singleValueFacet)();
|
|
283
116
|
var highlightStyles = import_language2.HighlightStyle.define([
|
|
284
117
|
// Function.
|
|
285
118
|
{
|
|
@@ -310,7 +143,7 @@ var highlightStyles = import_language2.HighlightStyle.define([
|
|
|
310
143
|
class: "text-unAccent"
|
|
311
144
|
}
|
|
312
145
|
]);
|
|
313
|
-
var languageFacet = (0,
|
|
146
|
+
var languageFacet = (0, import_react_ui_editor2.singleValueFacet)();
|
|
314
147
|
var sheetExtension = ({ functions = [] }) => {
|
|
315
148
|
const { extension, language } = (0, import_codemirror_lang_spreadsheet.spreadsheet)({
|
|
316
149
|
idiom: "en-US",
|
|
@@ -402,27 +235,29 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
402
235
|
])
|
|
403
236
|
];
|
|
404
237
|
};
|
|
405
|
-
var rangeExtension = (onInit) => {
|
|
238
|
+
var rangeExtension = ({ onInit, onStateChange }) => {
|
|
406
239
|
let view;
|
|
407
240
|
let activeRange;
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
241
|
+
const notifier = {
|
|
242
|
+
setRange: (range) => {
|
|
243
|
+
if (activeRange) {
|
|
244
|
+
view.dispatch(view.state.update({
|
|
245
|
+
changes: {
|
|
246
|
+
...activeRange,
|
|
247
|
+
insert: range.toString()
|
|
248
|
+
},
|
|
249
|
+
selection: {
|
|
250
|
+
anchor: activeRange.from + range.length
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
view.focus();
|
|
419
255
|
}
|
|
420
|
-
view.focus();
|
|
421
256
|
};
|
|
422
257
|
return import_view2.ViewPlugin.fromClass(class {
|
|
423
258
|
constructor(_view) {
|
|
424
259
|
view = _view;
|
|
425
|
-
onInit(
|
|
260
|
+
onInit?.(notifier);
|
|
426
261
|
}
|
|
427
262
|
update(view2) {
|
|
428
263
|
const { anchor } = view2.state.selection.ranges[0];
|
|
@@ -432,20 +267,18 @@ var rangeExtension = (onInit) => {
|
|
|
432
267
|
visitTree(topNode, ({ type, from, to }) => {
|
|
433
268
|
if (from <= anchor && to >= anchor) {
|
|
434
269
|
switch (type.name) {
|
|
435
|
-
case "Function":
|
|
270
|
+
case "Function":
|
|
436
271
|
activeRange = {
|
|
437
272
|
from: to,
|
|
438
273
|
to
|
|
439
274
|
};
|
|
440
275
|
break;
|
|
441
|
-
|
|
442
|
-
case "CloseParen": {
|
|
276
|
+
case "CloseParen":
|
|
443
277
|
activeRange = {
|
|
444
278
|
from,
|
|
445
279
|
to: from
|
|
446
280
|
};
|
|
447
281
|
break;
|
|
448
|
-
}
|
|
449
282
|
case "RangeToken":
|
|
450
283
|
case "CellToken":
|
|
451
284
|
activeRange = {
|
|
@@ -458,11 +291,17 @@ var rangeExtension = (onInit) => {
|
|
|
458
291
|
return false;
|
|
459
292
|
});
|
|
460
293
|
if (!activeRange && view2.state.doc.toString()[0] === "=") {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
294
|
+
const str = view2.state.doc.sliceString(1);
|
|
295
|
+
if (import_chunk_QNFMTK3X.RANGE_NOTATION.test(str)) {
|
|
296
|
+
activeRange = {
|
|
297
|
+
from: 1,
|
|
298
|
+
to: str.length + 1
|
|
299
|
+
};
|
|
300
|
+
}
|
|
465
301
|
}
|
|
302
|
+
onStateChange?.({
|
|
303
|
+
activeRange: activeRange ? view2.state.doc.sliceString(activeRange.from, activeRange.to) : void 0
|
|
304
|
+
});
|
|
466
305
|
}
|
|
467
306
|
});
|
|
468
307
|
};
|
|
@@ -477,193 +316,7 @@ var visitTree = (node, callback) => {
|
|
|
477
316
|
}
|
|
478
317
|
return false;
|
|
479
318
|
};
|
|
480
|
-
var
|
|
481
|
-
const [colStr, rowStr] = index.split(",");
|
|
482
|
-
return {
|
|
483
|
-
col: parseInt(colStr),
|
|
484
|
-
row: parseInt(rowStr)
|
|
485
|
-
};
|
|
486
|
-
};
|
|
487
|
-
var createDxGridColumns = (model) => {
|
|
488
|
-
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
489
|
-
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
490
|
-
acc.grid[numericIndex] = {
|
|
491
|
-
size: model.sheet.columnMeta[columnId].size,
|
|
492
|
-
resizeable: true
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
return acc;
|
|
496
|
-
}, {
|
|
497
|
-
grid: {}
|
|
498
|
-
});
|
|
499
|
-
};
|
|
500
|
-
var createDxGridRows = (model) => {
|
|
501
|
-
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
502
|
-
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
503
|
-
acc.grid[numericIndex] = {
|
|
504
|
-
size: model.sheet.rowMeta[rowId].size,
|
|
505
|
-
resizeable: true
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
return acc;
|
|
509
|
-
}, {
|
|
510
|
-
grid: {}
|
|
511
|
-
});
|
|
512
|
-
};
|
|
513
|
-
var projectCellProps = (model, col, row) => {
|
|
514
|
-
const address = {
|
|
515
|
-
col,
|
|
516
|
-
row
|
|
517
|
-
};
|
|
518
|
-
const rawValue = model.getValue(address);
|
|
519
|
-
if (rawValue === void 0 || rawValue === null) {
|
|
520
|
-
return {
|
|
521
|
-
value: ""
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
const ranges = model.sheet.ranges?.filter(({ range }) => inRange(range, address));
|
|
525
|
-
const type = model.getValueType(address);
|
|
526
|
-
const classNames = ranges?.map(cellClassNameForRange).reverse();
|
|
527
|
-
return {
|
|
528
|
-
value: (0, import_react_ui_data.parseValue)(type, rawValue),
|
|
529
|
-
className: (0, import_react_ui_theme2.mx)((0, import_react_ui_data.cellClassesForFieldType)(type), classNames)
|
|
530
|
-
};
|
|
531
|
-
};
|
|
532
|
-
var gridCellGetter = (model) => {
|
|
533
|
-
const cachedGridCells = {};
|
|
534
|
-
return (nextBounds) => {
|
|
535
|
-
[
|
|
536
|
-
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
537
|
-
].forEach((_, c0) => {
|
|
538
|
-
return [
|
|
539
|
-
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
540
|
-
].forEach((_2, r0) => {
|
|
541
|
-
const col = nextBounds.start.col + c0;
|
|
542
|
-
const row = nextBounds.start.row + r0;
|
|
543
|
-
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
544
|
-
});
|
|
545
|
-
});
|
|
546
|
-
return cachedGridCells;
|
|
547
|
-
};
|
|
548
|
-
};
|
|
549
|
-
var rowLabelCell = (row) => ({
|
|
550
|
-
value: (0, import_react_ui_grid2.rowToA1Notation)(row),
|
|
551
|
-
className: "text-end !pie-1",
|
|
552
|
-
resizeHandle: "row"
|
|
553
|
-
});
|
|
554
|
-
var colLabelCell = (col) => ({
|
|
555
|
-
value: (0, import_react_ui_grid2.colToA1Notation)(col),
|
|
556
|
-
resizeHandle: "col"
|
|
557
|
-
});
|
|
558
|
-
var cellGetter = (model) => {
|
|
559
|
-
const getGridCells = gridCellGetter(model);
|
|
560
|
-
return (nextBounds, plane) => {
|
|
561
|
-
switch (plane) {
|
|
562
|
-
case "grid":
|
|
563
|
-
return getGridCells(nextBounds);
|
|
564
|
-
case "frozenColsStart":
|
|
565
|
-
return [
|
|
566
|
-
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
567
|
-
].reduce((acc, _, r0) => {
|
|
568
|
-
const r = nextBounds.start.row + r0;
|
|
569
|
-
acc[`0,${r}`] = rowLabelCell(r);
|
|
570
|
-
return acc;
|
|
571
|
-
}, {});
|
|
572
|
-
case "frozenRowsStart":
|
|
573
|
-
return [
|
|
574
|
-
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
575
|
-
].reduce((acc, _, c0) => {
|
|
576
|
-
const c = nextBounds.start.col + c0;
|
|
577
|
-
acc[`${c},0`] = colLabelCell(c);
|
|
578
|
-
return acc;
|
|
579
|
-
}, {});
|
|
580
|
-
default:
|
|
581
|
-
return {};
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
};
|
|
585
|
-
var useSheetModelDxGridProps = (dxGridRef, model) => {
|
|
586
|
-
const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
587
|
-
const [rows, setRows] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
588
|
-
(0, import_react5.useLayoutEffect)(() => {
|
|
589
|
-
const cellsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
590
|
-
"cells"
|
|
591
|
-
]);
|
|
592
|
-
if (dxGridRef.current) {
|
|
593
|
-
dxGridRef.current.getCells = cellGetter(model);
|
|
594
|
-
}
|
|
595
|
-
const handleCellsUpdate = () => {
|
|
596
|
-
dxGridRef.current?.requestUpdate("initialCells");
|
|
597
|
-
};
|
|
598
|
-
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
599
|
-
return () => cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
600
|
-
}, [
|
|
601
|
-
model
|
|
602
|
-
]);
|
|
603
|
-
(0, import_react5.useEffect)(() => {
|
|
604
|
-
const columnMetaAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
605
|
-
"columnMeta"
|
|
606
|
-
]);
|
|
607
|
-
const rowMetaAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
608
|
-
"rowMeta"
|
|
609
|
-
]);
|
|
610
|
-
const handleColumnMetaUpdate = () => {
|
|
611
|
-
setColumns(createDxGridColumns(model));
|
|
612
|
-
};
|
|
613
|
-
const handleRowMetaUpdate = () => {
|
|
614
|
-
setRows(createDxGridRows(model));
|
|
615
|
-
};
|
|
616
|
-
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
617
|
-
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
618
|
-
return () => {
|
|
619
|
-
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
620
|
-
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
621
|
-
};
|
|
622
|
-
}, [
|
|
623
|
-
model
|
|
624
|
-
]);
|
|
625
|
-
return {
|
|
626
|
-
columns,
|
|
627
|
-
rows
|
|
628
|
-
};
|
|
629
|
-
};
|
|
630
|
-
var createDecorations = () => {
|
|
631
|
-
const { decorations } = (0, import_echo_schema2.create)({
|
|
632
|
-
decorations: {}
|
|
633
|
-
});
|
|
634
|
-
const addDecoration = (cellIndex, decorator) => {
|
|
635
|
-
decorations[cellIndex] = [
|
|
636
|
-
...decorations[cellIndex] || [],
|
|
637
|
-
decorator
|
|
638
|
-
];
|
|
639
|
-
};
|
|
640
|
-
const removeDecoration = (cellIndex, type) => {
|
|
641
|
-
if (type) {
|
|
642
|
-
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
643
|
-
} else {
|
|
644
|
-
delete decorations[cellIndex];
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
const getDecorationsForCell = (cellIndex) => {
|
|
648
|
-
return decorations[cellIndex];
|
|
649
|
-
};
|
|
650
|
-
const getAllDecorations = () => {
|
|
651
|
-
const result = [];
|
|
652
|
-
for (const decoratorArray of Object.values(decorations)) {
|
|
653
|
-
for (const decorator of decoratorArray) {
|
|
654
|
-
result.push(decorator);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
return result;
|
|
658
|
-
};
|
|
659
|
-
return {
|
|
660
|
-
addDecoration,
|
|
661
|
-
removeDecoration,
|
|
662
|
-
getDecorationsForCell,
|
|
663
|
-
getAllDecorations
|
|
664
|
-
};
|
|
665
|
-
};
|
|
666
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
319
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
667
320
|
var typeMap = {
|
|
668
321
|
BOOLEAN: import_schema.FieldValueType.Boolean,
|
|
669
322
|
NUMBER_RAW: import_schema.FieldValueType.Number,
|
|
@@ -720,14 +373,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
720
373
|
(0, import_log.log)("initialize", {
|
|
721
374
|
id: this.id
|
|
722
375
|
}, {
|
|
723
|
-
F:
|
|
724
|
-
L:
|
|
376
|
+
F: __dxlog_file,
|
|
377
|
+
L: 111,
|
|
725
378
|
S: this,
|
|
726
379
|
C: (f, a) => f(...a)
|
|
727
380
|
});
|
|
728
|
-
initialize(this._sheet);
|
|
729
|
-
this._node = this._graph.getOrCreateNode((0,
|
|
730
|
-
type: (0,
|
|
381
|
+
(0, import_chunk_QNFMTK3X.initialize)(this._sheet);
|
|
382
|
+
this._node = this._graph.getOrCreateNode((0, import_chunk_QNFMTK3X.createSheetName)({
|
|
383
|
+
type: (0, import_echo_schema.getTypename)(this._sheet),
|
|
731
384
|
id: this._sheet.id
|
|
732
385
|
}));
|
|
733
386
|
await this._node.open();
|
|
@@ -742,8 +395,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
742
395
|
*/
|
|
743
396
|
reset() {
|
|
744
397
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
745
|
-
F:
|
|
746
|
-
L:
|
|
398
|
+
F: __dxlog_file,
|
|
399
|
+
L: 131,
|
|
747
400
|
S: this,
|
|
748
401
|
A: [
|
|
749
402
|
"this._node",
|
|
@@ -753,16 +406,16 @@ var SheetModel = class extends import_context.Resource {
|
|
|
753
406
|
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
754
407
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
755
408
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
756
|
-
F:
|
|
757
|
-
L:
|
|
409
|
+
F: __dxlog_file,
|
|
410
|
+
L: 134,
|
|
758
411
|
S: this,
|
|
759
412
|
A: [
|
|
760
413
|
"this._node",
|
|
761
414
|
""
|
|
762
415
|
]
|
|
763
416
|
});
|
|
764
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
765
|
-
if (
|
|
417
|
+
const { col, row } = (0, import_chunk_QNFMTK3X.addressFromIndex)(this._sheet, key);
|
|
418
|
+
if ((0, import_chunk_QNFMTK3X.isFormula)(value)) {
|
|
766
419
|
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
767
420
|
}
|
|
768
421
|
this._node.graph.hf.setCellContents({
|
|
@@ -783,11 +436,11 @@ var SheetModel = class extends import_context.Resource {
|
|
|
783
436
|
this._node?.graph.hf.rebuildAndRecalculate();
|
|
784
437
|
}
|
|
785
438
|
insertRows(i, n = 1) {
|
|
786
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
439
|
+
(0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.rows, i, n, import_chunk_QNFMTK3X.MAX_ROWS);
|
|
787
440
|
this.reset();
|
|
788
441
|
}
|
|
789
442
|
insertColumns(i, n = 1) {
|
|
790
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
443
|
+
(0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.columns, i, n, import_chunk_QNFMTK3X.MAX_COLUMNS);
|
|
791
444
|
this.reset();
|
|
792
445
|
}
|
|
793
446
|
//
|
|
@@ -799,8 +452,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
799
452
|
*/
|
|
800
453
|
clear(range) {
|
|
801
454
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
802
|
-
F:
|
|
803
|
-
L:
|
|
455
|
+
F: __dxlog_file,
|
|
456
|
+
L: 176,
|
|
804
457
|
S: this,
|
|
805
458
|
A: [
|
|
806
459
|
"this._node",
|
|
@@ -811,14 +464,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
811
464
|
const values = this._iterRange(range, () => null);
|
|
812
465
|
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
813
466
|
this._iterRange(range, (cell) => {
|
|
814
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
467
|
+
const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
|
|
815
468
|
delete this._sheet.cells[idx];
|
|
816
469
|
});
|
|
817
470
|
}
|
|
818
471
|
cut(range) {
|
|
819
472
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
820
|
-
F:
|
|
821
|
-
L:
|
|
473
|
+
F: __dxlog_file,
|
|
474
|
+
L: 187,
|
|
822
475
|
S: this,
|
|
823
476
|
A: [
|
|
824
477
|
"this._node",
|
|
@@ -827,14 +480,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
827
480
|
});
|
|
828
481
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
829
482
|
this._iterRange(range, (cell) => {
|
|
830
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
483
|
+
const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
|
|
831
484
|
delete this._sheet.cells[idx];
|
|
832
485
|
});
|
|
833
486
|
}
|
|
834
487
|
copy(range) {
|
|
835
488
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
836
|
-
F:
|
|
837
|
-
L:
|
|
489
|
+
F: __dxlog_file,
|
|
490
|
+
L: 196,
|
|
838
491
|
S: this,
|
|
839
492
|
A: [
|
|
840
493
|
"this._node",
|
|
@@ -845,8 +498,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
845
498
|
}
|
|
846
499
|
paste(cell) {
|
|
847
500
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
848
|
-
F:
|
|
849
|
-
L:
|
|
501
|
+
F: __dxlog_file,
|
|
502
|
+
L: 201,
|
|
850
503
|
S: this,
|
|
851
504
|
A: [
|
|
852
505
|
"this._node",
|
|
@@ -858,7 +511,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
858
511
|
for (const change of changes) {
|
|
859
512
|
if (change instanceof import_hyperformula.ExportedCellChange) {
|
|
860
513
|
const { address, newValue } = change;
|
|
861
|
-
const idx = addressToIndex(this._sheet, {
|
|
514
|
+
const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, {
|
|
862
515
|
row: address.row,
|
|
863
516
|
col: address.col
|
|
864
517
|
});
|
|
@@ -872,8 +525,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
872
525
|
// TODO(burdon): Display undo/redo state.
|
|
873
526
|
undo() {
|
|
874
527
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
875
|
-
F:
|
|
876
|
-
L:
|
|
528
|
+
F: __dxlog_file,
|
|
529
|
+
L: 216,
|
|
877
530
|
S: this,
|
|
878
531
|
A: [
|
|
879
532
|
"this._node",
|
|
@@ -886,8 +539,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
886
539
|
}
|
|
887
540
|
redo() {
|
|
888
541
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
889
|
-
F:
|
|
890
|
-
L:
|
|
542
|
+
F: __dxlog_file,
|
|
543
|
+
L: 224,
|
|
891
544
|
S: this,
|
|
892
545
|
A: [
|
|
893
546
|
"this._node",
|
|
@@ -902,7 +555,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
902
555
|
* Get value from sheet.
|
|
903
556
|
*/
|
|
904
557
|
getCellValue(cell) {
|
|
905
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
558
|
+
const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
|
|
906
559
|
return this._sheet.cells[idx]?.value ?? null;
|
|
907
560
|
}
|
|
908
561
|
/**
|
|
@@ -913,7 +566,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
913
566
|
if (value == null) {
|
|
914
567
|
return void 0;
|
|
915
568
|
}
|
|
916
|
-
if (
|
|
569
|
+
if ((0, import_chunk_QNFMTK3X.isFormula)(value)) {
|
|
917
570
|
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
918
571
|
} else {
|
|
919
572
|
return String(value);
|
|
@@ -930,8 +583,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
930
583
|
*/
|
|
931
584
|
getValue(cell) {
|
|
932
585
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
933
|
-
F:
|
|
934
|
-
L:
|
|
586
|
+
F: __dxlog_file,
|
|
587
|
+
L: 267,
|
|
935
588
|
S: this,
|
|
936
589
|
A: [
|
|
937
590
|
"this._node",
|
|
@@ -949,8 +602,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
949
602
|
*/
|
|
950
603
|
getValueType(cell) {
|
|
951
604
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
952
|
-
F:
|
|
953
|
-
L:
|
|
605
|
+
F: __dxlog_file,
|
|
606
|
+
L: 280,
|
|
954
607
|
S: this,
|
|
955
608
|
A: [
|
|
956
609
|
"this._node",
|
|
@@ -966,8 +619,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
966
619
|
*/
|
|
967
620
|
setValue(cell, value) {
|
|
968
621
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
969
|
-
F:
|
|
970
|
-
L:
|
|
622
|
+
F: __dxlog_file,
|
|
623
|
+
L: 290,
|
|
971
624
|
S: this,
|
|
972
625
|
A: [
|
|
973
626
|
"this._node",
|
|
@@ -975,15 +628,15 @@ var SheetModel = class extends import_context.Resource {
|
|
|
975
628
|
]
|
|
976
629
|
});
|
|
977
630
|
if (this._options.readonly) {
|
|
978
|
-
throw new ReadonlyException();
|
|
631
|
+
throw new import_chunk_QNFMTK3X.ReadonlyException();
|
|
979
632
|
}
|
|
980
633
|
let refresh = false;
|
|
981
634
|
if (cell.row >= this._sheet.rows.length) {
|
|
982
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
635
|
+
(0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_QNFMTK3X.MAX_ROWS);
|
|
983
636
|
refresh = true;
|
|
984
637
|
}
|
|
985
638
|
if (cell.col >= this._sheet.columns.length) {
|
|
986
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
639
|
+
(0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_QNFMTK3X.MAX_COLUMNS);
|
|
987
640
|
refresh = true;
|
|
988
641
|
}
|
|
989
642
|
if (refresh) {
|
|
@@ -995,14 +648,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
995
648
|
col: cell.col
|
|
996
649
|
}, [
|
|
997
650
|
[
|
|
998
|
-
|
|
651
|
+
(0, import_chunk_QNFMTK3X.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
|
|
999
652
|
]
|
|
1000
653
|
]);
|
|
1001
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
654
|
+
const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
|
|
1002
655
|
if (value === void 0 || value === null) {
|
|
1003
656
|
delete this._sheet.cells[idx];
|
|
1004
657
|
} else {
|
|
1005
|
-
if (
|
|
658
|
+
if ((0, import_chunk_QNFMTK3X.isFormula)(value)) {
|
|
1006
659
|
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1007
660
|
}
|
|
1008
661
|
this._sheet.cells[idx] = {
|
|
@@ -1015,7 +668,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1015
668
|
*/
|
|
1016
669
|
setValues(values) {
|
|
1017
670
|
Object.entries(values).forEach(([key, { value }]) => {
|
|
1018
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
671
|
+
this.setValue((0, import_chunk_QNFMTK3X.addressFromA1Notation)(key), value);
|
|
1019
672
|
});
|
|
1020
673
|
}
|
|
1021
674
|
/**
|
|
@@ -1062,34 +715,34 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1062
715
|
* Map from A1 notation to indices.
|
|
1063
716
|
*/
|
|
1064
717
|
mapFormulaRefsToIndices(formula) {
|
|
1065
|
-
(0, import_invariant3.invariant)(
|
|
1066
|
-
F:
|
|
1067
|
-
L:
|
|
718
|
+
(0, import_invariant3.invariant)((0, import_chunk_QNFMTK3X.isFormula)(formula), void 0, {
|
|
719
|
+
F: __dxlog_file,
|
|
720
|
+
L: 379,
|
|
1068
721
|
S: this,
|
|
1069
722
|
A: [
|
|
1070
|
-
"formula
|
|
723
|
+
"isFormula(formula)",
|
|
1071
724
|
""
|
|
1072
725
|
]
|
|
1073
726
|
});
|
|
1074
727
|
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1075
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
728
|
+
return (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, (0, import_chunk_QNFMTK3X.addressFromA1Notation)(match));
|
|
1076
729
|
});
|
|
1077
730
|
}
|
|
1078
731
|
/**
|
|
1079
732
|
* Map from indices to A1 notation.
|
|
1080
733
|
*/
|
|
1081
734
|
mapFormulaIndicesToRefs(formula) {
|
|
1082
|
-
(0, import_invariant3.invariant)(
|
|
1083
|
-
F:
|
|
1084
|
-
L:
|
|
735
|
+
(0, import_invariant3.invariant)((0, import_chunk_QNFMTK3X.isFormula)(formula), void 0, {
|
|
736
|
+
F: __dxlog_file,
|
|
737
|
+
L: 389,
|
|
1085
738
|
S: this,
|
|
1086
739
|
A: [
|
|
1087
|
-
"formula
|
|
740
|
+
"isFormula(formula)",
|
|
1088
741
|
""
|
|
1089
742
|
]
|
|
1090
743
|
});
|
|
1091
744
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1092
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
745
|
+
return (0, import_chunk_QNFMTK3X.addressToA1Notation)((0, import_chunk_QNFMTK3X.addressFromIndex)(this._sheet, idx));
|
|
1093
746
|
});
|
|
1094
747
|
}
|
|
1095
748
|
//
|
|
@@ -1106,8 +759,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1106
759
|
}
|
|
1107
760
|
toDateTime(num) {
|
|
1108
761
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1109
|
-
F:
|
|
1110
|
-
L:
|
|
762
|
+
F: __dxlog_file,
|
|
763
|
+
L: 410,
|
|
1111
764
|
S: this,
|
|
1112
765
|
A: [
|
|
1113
766
|
"this._node",
|
|
@@ -1118,8 +771,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1118
771
|
}
|
|
1119
772
|
toDate(num) {
|
|
1120
773
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1121
|
-
F:
|
|
1122
|
-
L:
|
|
774
|
+
F: __dxlog_file,
|
|
775
|
+
L: 415,
|
|
1123
776
|
S: this,
|
|
1124
777
|
A: [
|
|
1125
778
|
"this._node",
|
|
@@ -1130,8 +783,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1130
783
|
}
|
|
1131
784
|
toTime(num) {
|
|
1132
785
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1133
|
-
F:
|
|
1134
|
-
L:
|
|
786
|
+
F: __dxlog_file,
|
|
787
|
+
L: 420,
|
|
1135
788
|
S: this,
|
|
1136
789
|
A: [
|
|
1137
790
|
"this._node",
|
|
@@ -1142,8 +795,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1142
795
|
}
|
|
1143
796
|
};
|
|
1144
797
|
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1145
|
-
const [model, setModel] = (0,
|
|
1146
|
-
(0,
|
|
798
|
+
const [model, setModel] = (0, import_react3.useState)();
|
|
799
|
+
(0, import_react3.useEffect)(() => {
|
|
1147
800
|
if (!graph || !sheet) {
|
|
1148
801
|
return;
|
|
1149
802
|
}
|
|
@@ -1166,167 +819,339 @@ var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
|
1166
819
|
]);
|
|
1167
820
|
return model;
|
|
1168
821
|
};
|
|
1169
|
-
var
|
|
1170
|
-
|
|
822
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
823
|
+
var SheetContext = /* @__PURE__ */ (0, import_react2.createContext)(void 0);
|
|
824
|
+
var useSheetContext = () => {
|
|
825
|
+
const context = (0, import_react2.useContext)(SheetContext);
|
|
826
|
+
(0, import_invariant2.invariant)(context, void 0, {
|
|
827
|
+
F: __dxlog_file2,
|
|
828
|
+
L: 52,
|
|
829
|
+
S: void 0,
|
|
830
|
+
A: [
|
|
831
|
+
"context",
|
|
832
|
+
""
|
|
833
|
+
]
|
|
834
|
+
});
|
|
835
|
+
return context;
|
|
836
|
+
};
|
|
837
|
+
var SheetProviderImpl = ({ model, onInfo, children, __gridScope }) => {
|
|
838
|
+
const { id, editing, setEditing } = (0, import_react_ui_grid.useGridContext)("SheetProvider", __gridScope);
|
|
839
|
+
const [cursor, setCursorInternal] = (0, import_react2.useState)();
|
|
840
|
+
const [range, setRangeInternal] = (0, import_react2.useState)();
|
|
841
|
+
const [cursorFallbackRange, setCursorFallbackRange] = (0, import_react2.useState)();
|
|
842
|
+
const [activeRefs, setActiveRefs] = (0, import_react2.useState)("");
|
|
843
|
+
const setCursor = (0, import_react2.useCallback)((nextCursor) => {
|
|
844
|
+
setCursorInternal(nextCursor);
|
|
845
|
+
setCursorFallbackRange(range?.to ? range : nextCursor ? {
|
|
846
|
+
from: nextCursor,
|
|
847
|
+
to: nextCursor
|
|
848
|
+
} : void 0);
|
|
849
|
+
}, [
|
|
850
|
+
range
|
|
851
|
+
]);
|
|
852
|
+
const setRange = (0, import_react2.useCallback)((nextRange) => {
|
|
853
|
+
setRangeInternal(nextRange);
|
|
854
|
+
setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
|
|
855
|
+
from: cursor,
|
|
856
|
+
to: cursor
|
|
857
|
+
} : void 0);
|
|
858
|
+
}, [
|
|
859
|
+
cursor
|
|
860
|
+
]);
|
|
861
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContext.Provider, {
|
|
862
|
+
value: {
|
|
863
|
+
id,
|
|
864
|
+
model,
|
|
865
|
+
editing,
|
|
866
|
+
setEditing,
|
|
867
|
+
cursor,
|
|
868
|
+
setCursor,
|
|
869
|
+
range,
|
|
870
|
+
setRange,
|
|
871
|
+
cursorFallbackRange,
|
|
872
|
+
activeRefs,
|
|
873
|
+
setActiveRefs,
|
|
874
|
+
// TODO(burdon): Change to event.
|
|
875
|
+
onInfo
|
|
876
|
+
}
|
|
877
|
+
}, children);
|
|
878
|
+
};
|
|
879
|
+
var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
880
|
+
const model = useSheetModel(graph, sheet, {
|
|
881
|
+
readonly
|
|
882
|
+
});
|
|
883
|
+
return !model ? null : /* @__PURE__ */ import_react2.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
884
|
+
id: (0, import_echo.fullyQualifiedId)(sheet)
|
|
885
|
+
}, /* @__PURE__ */ import_react2.default.createElement(SheetProviderImpl, {
|
|
886
|
+
model,
|
|
887
|
+
onInfo
|
|
888
|
+
}, children));
|
|
889
|
+
};
|
|
890
|
+
var RangeList = ({ sheet, onSelect, onDelete }) => {
|
|
891
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
892
|
+
className: "flex flex-col"
|
|
893
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
|
|
894
|
+
items: sheet.ranges,
|
|
895
|
+
isItem: import_echo_schema2.S.is(import_chunk_V7E5JZBD.Range)
|
|
896
|
+
}, ({ items }) => items.map((item, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
|
|
897
|
+
key: i,
|
|
898
|
+
item,
|
|
899
|
+
classNames: [
|
|
900
|
+
"p-2",
|
|
901
|
+
import_react_ui_theme3.ghostHover
|
|
902
|
+
]
|
|
903
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
|
|
904
|
+
onClick: () => onSelect?.(item)
|
|
905
|
+
}, (0, import_chunk_QNFMTK3X.rangeToA1Notation)((0, import_chunk_QNFMTK3X.rangeFromIndex)(sheet, item.range))), onDelete && /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
|
|
906
|
+
onClick: () => onDelete(item)
|
|
907
|
+
})))));
|
|
908
|
+
};
|
|
909
|
+
var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-L37HUFCF.cjs"));
|
|
910
|
+
var completeCellRangeToThreadCursor = (range) => {
|
|
911
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
912
|
+
};
|
|
913
|
+
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
914
|
+
const coords = cursor.split(",");
|
|
915
|
+
if (coords.length !== 4) {
|
|
916
|
+
return null;
|
|
917
|
+
} else {
|
|
918
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
919
|
+
return {
|
|
920
|
+
from: {
|
|
921
|
+
col: parseInt(fromCol),
|
|
922
|
+
row: parseInt(fromRow)
|
|
923
|
+
},
|
|
924
|
+
to: {
|
|
925
|
+
col: parseInt(toCol),
|
|
926
|
+
row: parseInt(toRow)
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
932
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
933
|
+
const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
|
|
1171
934
|
switch (action) {
|
|
1172
935
|
case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
|
|
1173
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== (0,
|
|
936
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
|
|
1174
937
|
return;
|
|
1175
938
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
939
|
+
setActiveRefs(data.thread);
|
|
940
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
941
|
+
range && grid.current?.setFocus({
|
|
942
|
+
...range.to,
|
|
1179
943
|
plane: "grid"
|
|
1180
944
|
}, true);
|
|
1181
945
|
}
|
|
1182
946
|
}
|
|
1183
947
|
}, [
|
|
1184
|
-
model.sheet
|
|
948
|
+
model.sheet,
|
|
949
|
+
setActiveRefs
|
|
1185
950
|
]);
|
|
1186
951
|
(0, import_app_framework.useIntentResolver)(import_chunk_QIFIGEKV.SHEET_PLUGIN, handleScrollIntoView);
|
|
1187
952
|
};
|
|
1188
|
-
var useSelectThreadOnCellFocus = (
|
|
953
|
+
var useSelectThreadOnCellFocus = () => {
|
|
954
|
+
const { model, cursor } = useSheetContext();
|
|
1189
955
|
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1190
|
-
const
|
|
956
|
+
const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
|
|
1191
957
|
// TODO(thure): Surely we can find a better dependency for this…
|
|
1192
958
|
JSON.stringify(model.sheet.threads)
|
|
1193
959
|
]);
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
model.sheet
|
|
1197
|
-
]);
|
|
1198
|
-
const selectClosestThread = (0, import_react7.useCallback)((cellAddress) => {
|
|
1199
|
-
if (!cellAddress || !activeThreads) {
|
|
960
|
+
const selectClosestThread = (0, import_react6.useCallback)((cellAddress) => {
|
|
961
|
+
if (!cellAddress || !threads) {
|
|
1200
962
|
return;
|
|
1201
963
|
}
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
action: "dxos.org/plugin/thread/action/select",
|
|
1209
|
-
data: {
|
|
1210
|
-
current: (0, import_echo2.fullyQualifiedId)(closestThread)
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
]);
|
|
964
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
965
|
+
if (anchor) {
|
|
966
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
967
|
+
return range ? (0, import_chunk_QNFMTK3X.inRange)(range, cellAddress) : false;
|
|
968
|
+
} else {
|
|
969
|
+
return false;
|
|
1214
970
|
}
|
|
971
|
+
});
|
|
972
|
+
if (closestThread) {
|
|
973
|
+
void dispatch([
|
|
974
|
+
{
|
|
975
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
976
|
+
data: {
|
|
977
|
+
current: (0, import_echo3.fullyQualifiedId)(closestThread)
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
]);
|
|
1215
981
|
}
|
|
1216
982
|
}, [
|
|
1217
983
|
dispatch,
|
|
1218
|
-
|
|
1219
|
-
activeThreadAddresses,
|
|
1220
|
-
model.sheet
|
|
984
|
+
threads
|
|
1221
985
|
]);
|
|
1222
|
-
const debounced = (0,
|
|
986
|
+
const debounced = (0, import_react6.useMemo)(() => {
|
|
1223
987
|
return (0, import_async3.debounce)((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
1224
988
|
}, [
|
|
1225
989
|
selectClosestThread
|
|
1226
990
|
]);
|
|
1227
|
-
(0,
|
|
991
|
+
(0, import_react6.useEffect)(() => {
|
|
1228
992
|
if (!cursor) {
|
|
1229
993
|
return;
|
|
1230
994
|
}
|
|
1231
995
|
debounced(cursor);
|
|
1232
996
|
}, [
|
|
1233
997
|
cursor,
|
|
1234
|
-
|
|
998
|
+
debounced
|
|
1235
999
|
]);
|
|
1236
1000
|
};
|
|
1237
|
-
var
|
|
1001
|
+
var dxGridCellIndexToSheetCellAddress = (index) => {
|
|
1002
|
+
const [colStr, rowStr] = index.split(",");
|
|
1238
1003
|
return {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
"bg-greenFill"
|
|
1242
|
-
],
|
|
1243
|
-
cellIndex
|
|
1004
|
+
col: parseInt(colStr),
|
|
1005
|
+
row: parseInt(rowStr)
|
|
1244
1006
|
};
|
|
1245
1007
|
};
|
|
1246
|
-
var
|
|
1247
|
-
|
|
1248
|
-
model.sheet
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
return;
|
|
1258
|
-
}
|
|
1259
|
-
for (const thread of sheet.threads) {
|
|
1260
|
-
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1261
|
-
continue;
|
|
1262
|
-
}
|
|
1263
|
-
activeThreadAnchors.add(thread.anchor);
|
|
1264
|
-
const index = thread.anchor;
|
|
1265
|
-
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1266
|
-
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1267
|
-
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
for (const decoration of decorations.getAllDecorations()) {
|
|
1271
|
-
if (decoration.type !== "comment") {
|
|
1272
|
-
continue;
|
|
1273
|
-
}
|
|
1274
|
-
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1275
|
-
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
});
|
|
1279
|
-
return () => unsubscribe();
|
|
1008
|
+
var createDxGridColumns = (model) => {
|
|
1009
|
+
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
1010
|
+
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
1011
|
+
acc.grid[numericIndex] = {
|
|
1012
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
1013
|
+
resizeable: true
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
return acc;
|
|
1017
|
+
}, {
|
|
1018
|
+
grid: {}
|
|
1280
1019
|
});
|
|
1281
1020
|
};
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
]
|
|
1021
|
+
var createDxGridRows = (model) => {
|
|
1022
|
+
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
1023
|
+
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
1024
|
+
acc.grid[numericIndex] = {
|
|
1025
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
1026
|
+
resizeable: true
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
return acc;
|
|
1030
|
+
}, {
|
|
1031
|
+
grid: {}
|
|
1294
1032
|
});
|
|
1295
|
-
return context;
|
|
1296
1033
|
};
|
|
1297
|
-
var
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1034
|
+
var projectCellProps = (model, col, row) => {
|
|
1035
|
+
const address = {
|
|
1036
|
+
col,
|
|
1037
|
+
row
|
|
1038
|
+
};
|
|
1039
|
+
const rawValue = model.getValue(address);
|
|
1040
|
+
const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_QNFMTK3X.inRange)((0, import_chunk_QNFMTK3X.rangeFromIndex)(model.sheet, range), address));
|
|
1041
|
+
const threadRefs = model.sheet.threads?.filter((thread) => {
|
|
1042
|
+
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
|
|
1043
|
+
return thread && range ? (0, import_chunk_QNFMTK3X.inRange)(range, address) : false;
|
|
1044
|
+
}).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
|
|
1045
|
+
const type = model.getValueType(address);
|
|
1046
|
+
const classNames = ranges?.map(import_chunk_QNFMTK3X.cellClassNameForRange).reverse();
|
|
1047
|
+
return {
|
|
1048
|
+
value: (0, import_react_ui_data.parseValue)(type, rawValue),
|
|
1049
|
+
className: (0, import_react_ui_theme2.mx)((0, import_react_ui_data.cellClassesForFieldType)(type), threadRefs && import_react_ui_grid3.commentedClassName, classNames),
|
|
1050
|
+
dataRefs: threadRefs
|
|
1051
|
+
};
|
|
1052
|
+
};
|
|
1053
|
+
var gridCellGetter = (model) => {
|
|
1054
|
+
const cachedGridCells = {};
|
|
1055
|
+
return (nextBounds) => {
|
|
1056
|
+
[
|
|
1057
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1058
|
+
].forEach((_, c0) => {
|
|
1059
|
+
return [
|
|
1060
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1061
|
+
].forEach((_2, r0) => {
|
|
1062
|
+
const col = nextBounds.start.col + c0;
|
|
1063
|
+
const row = nextBounds.start.row + r0;
|
|
1064
|
+
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
1065
|
+
});
|
|
1066
|
+
});
|
|
1067
|
+
return cachedGridCells;
|
|
1068
|
+
};
|
|
1069
|
+
};
|
|
1070
|
+
var rowLabelCell = (row) => ({
|
|
1071
|
+
value: (0, import_react_ui_grid3.rowToA1Notation)(row),
|
|
1072
|
+
className: "text-end !pie-1",
|
|
1073
|
+
resizeHandle: "row"
|
|
1074
|
+
});
|
|
1075
|
+
var colLabelCell = (col) => ({
|
|
1076
|
+
value: (0, import_react_ui_grid3.colToA1Notation)(col),
|
|
1077
|
+
resizeHandle: "col"
|
|
1078
|
+
});
|
|
1079
|
+
var cellGetter = (model) => {
|
|
1080
|
+
const getGridCells = gridCellGetter(model);
|
|
1081
|
+
return (nextBounds, plane) => {
|
|
1082
|
+
switch (plane) {
|
|
1083
|
+
case "grid":
|
|
1084
|
+
return getGridCells(nextBounds);
|
|
1085
|
+
case "frozenColsStart":
|
|
1086
|
+
return [
|
|
1087
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1088
|
+
].reduce((acc, _, r0) => {
|
|
1089
|
+
const r = nextBounds.start.row + r0;
|
|
1090
|
+
acc[`0,${r}`] = rowLabelCell(r);
|
|
1091
|
+
return acc;
|
|
1092
|
+
}, {});
|
|
1093
|
+
case "frozenRowsStart":
|
|
1094
|
+
return [
|
|
1095
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1096
|
+
].reduce((acc, _, c0) => {
|
|
1097
|
+
const c = nextBounds.start.col + c0;
|
|
1098
|
+
acc[`${c},0`] = colLabelCell(c);
|
|
1099
|
+
return acc;
|
|
1100
|
+
}, {});
|
|
1101
|
+
default:
|
|
1102
|
+
return {};
|
|
1317
1103
|
}
|
|
1318
|
-
}
|
|
1104
|
+
};
|
|
1319
1105
|
};
|
|
1320
|
-
var
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1106
|
+
var useSheetModelDxGridProps = (dxGridRef, model) => {
|
|
1107
|
+
const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1108
|
+
const [rows, setRows] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1109
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
1110
|
+
const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1111
|
+
"cells"
|
|
1112
|
+
]);
|
|
1113
|
+
if (dxGridRef.current) {
|
|
1114
|
+
dxGridRef.current.getCells = cellGetter(model);
|
|
1115
|
+
}
|
|
1116
|
+
const handleCellsUpdate = () => {
|
|
1117
|
+
dxGridRef.current?.requestUpdate("initialCells");
|
|
1118
|
+
};
|
|
1119
|
+
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1120
|
+
return () => cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1121
|
+
}, [
|
|
1122
|
+
model
|
|
1123
|
+
]);
|
|
1124
|
+
(0, import_react5.useEffect)(() => {
|
|
1125
|
+
const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1126
|
+
"columnMeta"
|
|
1127
|
+
]);
|
|
1128
|
+
const rowMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1129
|
+
"rowMeta"
|
|
1130
|
+
]);
|
|
1131
|
+
const handleColumnMetaUpdate = () => {
|
|
1132
|
+
setColumns(createDxGridColumns(model));
|
|
1133
|
+
};
|
|
1134
|
+
const handleRowMetaUpdate = () => {
|
|
1135
|
+
setRows(createDxGridRows(model));
|
|
1136
|
+
};
|
|
1137
|
+
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1138
|
+
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1139
|
+
return () => {
|
|
1140
|
+
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1141
|
+
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1142
|
+
};
|
|
1143
|
+
}, [
|
|
1144
|
+
model
|
|
1145
|
+
]);
|
|
1146
|
+
return {
|
|
1147
|
+
columns,
|
|
1148
|
+
rows
|
|
1149
|
+
};
|
|
1150
|
+
};
|
|
1151
|
+
var inertPosition = {
|
|
1152
|
+
plane: "grid",
|
|
1153
|
+
col: 0,
|
|
1154
|
+
row: 0
|
|
1330
1155
|
};
|
|
1331
1156
|
var initialCells = {
|
|
1332
1157
|
grid: {},
|
|
@@ -1368,13 +1193,14 @@ var sheetColDefault = {
|
|
|
1368
1193
|
}
|
|
1369
1194
|
};
|
|
1370
1195
|
var GridSheet = () => {
|
|
1371
|
-
const {
|
|
1196
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_QIFIGEKV.SHEET_PLUGIN);
|
|
1197
|
+
const { id, model, editing, setEditing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
|
|
1372
1198
|
const dxGrid = (0, import_react4.useRef)(null);
|
|
1373
|
-
const
|
|
1199
|
+
const rangeController = (0, import_react4.useRef)();
|
|
1374
1200
|
const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
|
|
1375
1201
|
const handleFocus = (0, import_react4.useCallback)((event) => {
|
|
1376
1202
|
if (!editing) {
|
|
1377
|
-
const cell = (0,
|
|
1203
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1378
1204
|
if (cell && cell.plane === "grid") {
|
|
1379
1205
|
setCursor({
|
|
1380
1206
|
col: cell.col,
|
|
@@ -1406,8 +1232,16 @@ var GridSheet = () => {
|
|
|
1406
1232
|
dxGrid.current?.refocus(axis, delta);
|
|
1407
1233
|
}, [
|
|
1408
1234
|
model,
|
|
1409
|
-
editing
|
|
1410
|
-
|
|
1235
|
+
editing
|
|
1236
|
+
]);
|
|
1237
|
+
const handleBlur = (0, import_react4.useCallback)((value) => {
|
|
1238
|
+
if (value !== void 0) {
|
|
1239
|
+
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1240
|
+
}
|
|
1241
|
+
setEditing(null);
|
|
1242
|
+
}, [
|
|
1243
|
+
model,
|
|
1244
|
+
editing
|
|
1411
1245
|
]);
|
|
1412
1246
|
const handleAxisResize = (0, import_react4.useCallback)(({ axis, size, index: numericIndex }) => {
|
|
1413
1247
|
if (axis === "row") {
|
|
@@ -1423,22 +1257,22 @@ var GridSheet = () => {
|
|
|
1423
1257
|
model
|
|
1424
1258
|
]);
|
|
1425
1259
|
const handleSelect = (0, import_react4.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1426
|
-
const
|
|
1260
|
+
const range = {
|
|
1427
1261
|
from: {
|
|
1428
1262
|
col: minCol,
|
|
1429
1263
|
row: minRow
|
|
1430
1264
|
}
|
|
1431
1265
|
};
|
|
1432
1266
|
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1433
|
-
|
|
1267
|
+
range.to = {
|
|
1434
1268
|
col: maxCol,
|
|
1435
1269
|
row: maxRow
|
|
1436
1270
|
};
|
|
1437
1271
|
}
|
|
1438
1272
|
if (editing) {
|
|
1439
|
-
|
|
1273
|
+
rangeController.current?.setRange((0, import_chunk_QNFMTK3X.rangeToA1Notation)(range));
|
|
1440
1274
|
} else {
|
|
1441
|
-
setRange(
|
|
1275
|
+
setRange(range.to ? range : void 0);
|
|
1442
1276
|
}
|
|
1443
1277
|
}, [
|
|
1444
1278
|
editing
|
|
@@ -1451,10 +1285,6 @@ var GridSheet = () => {
|
|
|
1451
1285
|
hasAttention
|
|
1452
1286
|
]);
|
|
1453
1287
|
const handleKeyDown = (0, import_react4.useCallback)((event) => {
|
|
1454
|
-
const cursorFallbackRange = range ?? cursor ? {
|
|
1455
|
-
from: cursor,
|
|
1456
|
-
to: cursor
|
|
1457
|
-
} : null;
|
|
1458
1288
|
switch (event.key) {
|
|
1459
1289
|
case "Backspace":
|
|
1460
1290
|
case "Delete":
|
|
@@ -1485,13 +1315,37 @@ var GridSheet = () => {
|
|
|
1485
1315
|
}
|
|
1486
1316
|
}
|
|
1487
1317
|
}, [
|
|
1488
|
-
|
|
1318
|
+
cursorFallbackRange,
|
|
1489
1319
|
model,
|
|
1490
1320
|
cursor
|
|
1491
1321
|
]);
|
|
1322
|
+
const contextMenuAnchorRef = (0, import_react4.useRef)(null);
|
|
1323
|
+
const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
|
|
1324
|
+
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1325
|
+
const handleContextMenu = (0, import_react4.useCallback)((event) => {
|
|
1326
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1327
|
+
if (cell && cell.plane.startsWith("frozen")) {
|
|
1328
|
+
event.preventDefault();
|
|
1329
|
+
contextMenuAnchorRef.current = event.target;
|
|
1330
|
+
setContextMenuOpen(cell);
|
|
1331
|
+
}
|
|
1332
|
+
}, []);
|
|
1333
|
+
const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
|
|
1334
|
+
switch (operation) {
|
|
1335
|
+
case "add-before":
|
|
1336
|
+
case "add-after":
|
|
1337
|
+
model[contextMenuAxis === "col" ? "insertColumns" : "insertRows"](contextMenuOpen[contextMenuAxis] + (operation === "add-before" ? 0 : 1), 1);
|
|
1338
|
+
break;
|
|
1339
|
+
case "remove":
|
|
1340
|
+
}
|
|
1341
|
+
}, [
|
|
1342
|
+
contextMenuAxis,
|
|
1343
|
+
contextMenuOpen,
|
|
1344
|
+
model
|
|
1345
|
+
]);
|
|
1492
1346
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1493
1347
|
const extension = (0, import_react4.useMemo)(() => [
|
|
1494
|
-
(0,
|
|
1348
|
+
(0, import_react_ui_grid2.editorKeys)({
|
|
1495
1349
|
onClose: handleClose,
|
|
1496
1350
|
...editing?.initialContent && {
|
|
1497
1351
|
onNav: handleClose
|
|
@@ -1500,7 +1354,14 @@ var GridSheet = () => {
|
|
|
1500
1354
|
sheetExtension({
|
|
1501
1355
|
functions: model.graph.getFunctions()
|
|
1502
1356
|
}),
|
|
1503
|
-
rangeExtension(
|
|
1357
|
+
rangeExtension({
|
|
1358
|
+
onInit: (fn) => rangeController.current = fn,
|
|
1359
|
+
onStateChange: (state) => {
|
|
1360
|
+
if (dxGrid.current) {
|
|
1361
|
+
dxGrid.current.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
})
|
|
1504
1365
|
], [
|
|
1505
1366
|
model,
|
|
1506
1367
|
handleClose,
|
|
@@ -1512,14 +1373,16 @@ var GridSheet = () => {
|
|
|
1512
1373
|
}, [
|
|
1513
1374
|
model
|
|
1514
1375
|
]);
|
|
1515
|
-
useUpdateFocusedCellOnThreadSelection(
|
|
1516
|
-
|
|
1376
|
+
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1377
|
+
useSelectThreadOnCellFocus();
|
|
1378
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.GridCellEditor, {
|
|
1517
1379
|
getCellContent,
|
|
1518
|
-
extension
|
|
1519
|
-
|
|
1380
|
+
extension,
|
|
1381
|
+
onBlur: handleBlur
|
|
1382
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
|
|
1520
1383
|
initialCells,
|
|
1521
|
-
limitColumns: DEFAULT_COLUMNS,
|
|
1522
|
-
limitRows: DEFAULT_ROWS,
|
|
1384
|
+
limitColumns: import_chunk_QNFMTK3X.DEFAULT_COLUMNS,
|
|
1385
|
+
limitRows: import_chunk_QNFMTK3X.DEFAULT_ROWS,
|
|
1523
1386
|
columns,
|
|
1524
1387
|
rows,
|
|
1525
1388
|
onAxisResize: handleAxisResize,
|
|
@@ -1530,40 +1393,49 @@ var GridSheet = () => {
|
|
|
1530
1393
|
onFocus: handleFocus,
|
|
1531
1394
|
onWheelCapture: handleWheel,
|
|
1532
1395
|
onKeyDown: handleKeyDown,
|
|
1396
|
+
onContextMenu: handleContextMenu,
|
|
1533
1397
|
overscroll: "inline",
|
|
1534
1398
|
className: "[--dx-grid-base:var(--surface-bg)]",
|
|
1399
|
+
activeRefs,
|
|
1535
1400
|
ref: dxGrid
|
|
1536
|
-
})
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1401
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
|
|
1402
|
+
modal: false,
|
|
1403
|
+
open: !!contextMenuOpen,
|
|
1404
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1405
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
|
|
1406
|
+
virtualRef: contextMenuAnchorRef
|
|
1407
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Content, {
|
|
1408
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1409
|
+
sideOffset: 4,
|
|
1410
|
+
collisionPadding: 8
|
|
1411
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1412
|
+
onClick: () => handleAxisMenuAction("add-before")
|
|
1413
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1414
|
+
size: 5,
|
|
1415
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1416
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1417
|
+
onClick: () => handleAxisMenuAction("add-after")
|
|
1418
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1419
|
+
size: 5,
|
|
1420
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1421
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1422
|
+
disabled: true,
|
|
1423
|
+
onClick: () => handleAxisMenuAction("remove")
|
|
1424
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1425
|
+
size: 5,
|
|
1426
|
+
icon: "ph--backspace--regular"
|
|
1427
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
|
|
1552
1428
|
};
|
|
1553
1429
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1554
1430
|
0 && (module.exports = {
|
|
1555
1431
|
ComputeGraphContextProvider,
|
|
1556
1432
|
GridSheet,
|
|
1433
|
+
RangeList,
|
|
1557
1434
|
SheetContainer,
|
|
1558
1435
|
SheetProvider,
|
|
1559
|
-
|
|
1560
|
-
addressToIndex,
|
|
1561
|
-
compareIndexPositions,
|
|
1436
|
+
completeCellRangeToThreadCursor,
|
|
1562
1437
|
computeGraphFacet,
|
|
1563
|
-
createSheet,
|
|
1564
|
-
inRange,
|
|
1565
|
-
rangeToA1Notation,
|
|
1566
1438
|
useComputeGraph,
|
|
1567
1439
|
useSheetContext
|
|
1568
1440
|
});
|
|
1569
|
-
//# sourceMappingURL=chunk-
|
|
1441
|
+
//# sourceMappingURL=chunk-7AWAC3R3.cjs.map
|