@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-main.8b352a0
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-R65IDJHN.mjs} +54 -58
- package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-5KVQ5IPW.mjs} +3 -12
- package/dist/lib/browser/chunk-5KVQ5IPW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-I2DKJ72A.mjs} +570 -669
- package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-KCYJSOFB.mjs} +252 -33
- package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-SJT67236.mjs} +4 -2
- package/dist/lib/browser/index.mjs +62 -20
- 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-6BO4C5X2.cjs} +52 -62
- package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-2XJ5I4UF.cjs} +6 -15
- package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-DEPJHN47.cjs} +534 -646
- package/dist/lib/node/chunk-DEPJHN47.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-JF5XNTF3.cjs} +257 -28
- package/dist/lib/node/chunk-JF5XNTF3.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-AQBDL7HO.cjs} +21 -19
- package/dist/lib/node/compute-graph-AQBDL7HO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +70 -31
- 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-MJXC5E3P.mjs} +54 -58
- package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-25V7WY4R.mjs} +570 -669
- package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-5TXLF6PL.mjs} +3 -12
- package/dist/lib/node-esm/chunk-5TXLF6PL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-XBEHKYO7.mjs} +251 -33
- package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-FRCKXEYK.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +62 -20
- 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 +1 -2
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +7 -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/SheetContainer/SheetContainer.d.ts +6 -3
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -2
- 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 +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 +7 -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 +13 -3
- 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 +25 -12
- 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 +118 -22
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +24 -14
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +3 -3
- package/src/components/SheetContainer/SheetContainer.tsx +10 -4
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +44 -41
- 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 +5 -4
- 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 +13 -3
- package/src/types.ts +4 -2
- 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/browser/chunk-GSV5QNLD.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-5XPK2V4A.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-5WPZCXNS.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-SJT67236.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-FRCKXEYK.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,70 @@ 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_DEPJHN47_exports = {};
|
|
30
|
+
__export(chunk_DEPJHN47_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_DEPJHN47_exports);
|
|
42
|
+
var import_chunk_JF5XNTF3 = require("./chunk-JF5XNTF3.cjs");
|
|
43
|
+
var import_chunk_2XJ5I4UF = require("./chunk-2XJ5I4UF.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_ui2 = require("@dxos/react-ui");
|
|
91
|
+
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
92
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
97
93
|
var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
|
|
98
94
|
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
99
95
|
return /* @__PURE__ */ import_react.default.createElement(ComputeGraphContext.Provider, {
|
|
@@ -102,184 +98,22 @@ var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
|
102
98
|
}
|
|
103
99
|
}, children);
|
|
104
100
|
};
|
|
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;
|
|
101
|
+
var useComputeGraph = (space) => {
|
|
102
|
+
const { registry } = (0, import_react.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
|
|
103
|
+
const [graph] = (0, import_react_hooks.useAsyncState)(async () => {
|
|
104
|
+
if (space) {
|
|
105
|
+
const graph2 = registry.getOrCreateGraph(space);
|
|
106
|
+
await graph2.open();
|
|
107
|
+
return graph2;
|
|
242
108
|
}
|
|
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
|
-
}
|
|
109
|
+
}, [
|
|
110
|
+
space,
|
|
111
|
+
registry
|
|
112
|
+
]);
|
|
113
|
+
return graph;
|
|
280
114
|
};
|
|
281
115
|
var updateAllDecorations = import_state.StateEffect.define();
|
|
282
|
-
var computeGraphFacet = (0,
|
|
116
|
+
var computeGraphFacet = (0, import_react_ui_editor.singleValueFacet)();
|
|
283
117
|
var highlightStyles = import_language2.HighlightStyle.define([
|
|
284
118
|
// Function.
|
|
285
119
|
{
|
|
@@ -310,7 +144,7 @@ var highlightStyles = import_language2.HighlightStyle.define([
|
|
|
310
144
|
class: "text-unAccent"
|
|
311
145
|
}
|
|
312
146
|
]);
|
|
313
|
-
var languageFacet = (0,
|
|
147
|
+
var languageFacet = (0, import_react_ui_editor2.singleValueFacet)();
|
|
314
148
|
var sheetExtension = ({ functions = [] }) => {
|
|
315
149
|
const { extension, language } = (0, import_codemirror_lang_spreadsheet.spreadsheet)({
|
|
316
150
|
idiom: "en-US",
|
|
@@ -402,27 +236,29 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
402
236
|
])
|
|
403
237
|
];
|
|
404
238
|
};
|
|
405
|
-
var rangeExtension = (onInit) => {
|
|
239
|
+
var rangeExtension = ({ onInit, onStateChange }) => {
|
|
406
240
|
let view;
|
|
407
241
|
let activeRange;
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
242
|
+
const notifier = {
|
|
243
|
+
setRange: (range) => {
|
|
244
|
+
if (activeRange) {
|
|
245
|
+
view.dispatch(view.state.update({
|
|
246
|
+
changes: {
|
|
247
|
+
...activeRange,
|
|
248
|
+
insert: range.toString()
|
|
249
|
+
},
|
|
250
|
+
selection: {
|
|
251
|
+
anchor: activeRange.from + range.length
|
|
252
|
+
}
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
view.focus();
|
|
419
256
|
}
|
|
420
|
-
view.focus();
|
|
421
257
|
};
|
|
422
258
|
return import_view2.ViewPlugin.fromClass(class {
|
|
423
259
|
constructor(_view) {
|
|
424
260
|
view = _view;
|
|
425
|
-
onInit(
|
|
261
|
+
onInit?.(notifier);
|
|
426
262
|
}
|
|
427
263
|
update(view2) {
|
|
428
264
|
const { anchor } = view2.state.selection.ranges[0];
|
|
@@ -432,20 +268,18 @@ var rangeExtension = (onInit) => {
|
|
|
432
268
|
visitTree(topNode, ({ type, from, to }) => {
|
|
433
269
|
if (from <= anchor && to >= anchor) {
|
|
434
270
|
switch (type.name) {
|
|
435
|
-
case "Function":
|
|
271
|
+
case "Function":
|
|
436
272
|
activeRange = {
|
|
437
273
|
from: to,
|
|
438
274
|
to
|
|
439
275
|
};
|
|
440
276
|
break;
|
|
441
|
-
|
|
442
|
-
case "CloseParen": {
|
|
277
|
+
case "CloseParen":
|
|
443
278
|
activeRange = {
|
|
444
279
|
from,
|
|
445
280
|
to: from
|
|
446
281
|
};
|
|
447
282
|
break;
|
|
448
|
-
}
|
|
449
283
|
case "RangeToken":
|
|
450
284
|
case "CellToken":
|
|
451
285
|
activeRange = {
|
|
@@ -458,11 +292,17 @@ var rangeExtension = (onInit) => {
|
|
|
458
292
|
return false;
|
|
459
293
|
});
|
|
460
294
|
if (!activeRange && view2.state.doc.toString()[0] === "=") {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
295
|
+
const str = view2.state.doc.sliceString(1);
|
|
296
|
+
if (import_chunk_JF5XNTF3.RANGE_NOTATION.test(str)) {
|
|
297
|
+
activeRange = {
|
|
298
|
+
from: 1,
|
|
299
|
+
to: str.length + 1
|
|
300
|
+
};
|
|
301
|
+
}
|
|
465
302
|
}
|
|
303
|
+
onStateChange?.({
|
|
304
|
+
activeRange: activeRange ? view2.state.doc.sliceString(activeRange.from, activeRange.to) : void 0
|
|
305
|
+
});
|
|
466
306
|
}
|
|
467
307
|
});
|
|
468
308
|
};
|
|
@@ -477,193 +317,7 @@ var visitTree = (node, callback) => {
|
|
|
477
317
|
}
|
|
478
318
|
return false;
|
|
479
319
|
};
|
|
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";
|
|
320
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
667
321
|
var typeMap = {
|
|
668
322
|
BOOLEAN: import_schema.FieldValueType.Boolean,
|
|
669
323
|
NUMBER_RAW: import_schema.FieldValueType.Number,
|
|
@@ -720,14 +374,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
720
374
|
(0, import_log.log)("initialize", {
|
|
721
375
|
id: this.id
|
|
722
376
|
}, {
|
|
723
|
-
F:
|
|
724
|
-
L:
|
|
377
|
+
F: __dxlog_file,
|
|
378
|
+
L: 111,
|
|
725
379
|
S: this,
|
|
726
380
|
C: (f, a) => f(...a)
|
|
727
381
|
});
|
|
728
|
-
initialize(this._sheet);
|
|
729
|
-
this._node = this._graph.getOrCreateNode((0,
|
|
730
|
-
type: (0,
|
|
382
|
+
(0, import_chunk_JF5XNTF3.initialize)(this._sheet);
|
|
383
|
+
this._node = this._graph.getOrCreateNode((0, import_chunk_JF5XNTF3.createSheetName)({
|
|
384
|
+
type: (0, import_echo_schema.getTypename)(this._sheet),
|
|
731
385
|
id: this._sheet.id
|
|
732
386
|
}));
|
|
733
387
|
await this._node.open();
|
|
@@ -742,8 +396,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
742
396
|
*/
|
|
743
397
|
reset() {
|
|
744
398
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
745
|
-
F:
|
|
746
|
-
L:
|
|
399
|
+
F: __dxlog_file,
|
|
400
|
+
L: 131,
|
|
747
401
|
S: this,
|
|
748
402
|
A: [
|
|
749
403
|
"this._node",
|
|
@@ -753,16 +407,16 @@ var SheetModel = class extends import_context.Resource {
|
|
|
753
407
|
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
754
408
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
755
409
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
756
|
-
F:
|
|
757
|
-
L:
|
|
410
|
+
F: __dxlog_file,
|
|
411
|
+
L: 134,
|
|
758
412
|
S: this,
|
|
759
413
|
A: [
|
|
760
414
|
"this._node",
|
|
761
415
|
""
|
|
762
416
|
]
|
|
763
417
|
});
|
|
764
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
765
|
-
if (
|
|
418
|
+
const { col, row } = (0, import_chunk_JF5XNTF3.addressFromIndex)(this._sheet, key);
|
|
419
|
+
if ((0, import_chunk_JF5XNTF3.isFormula)(value)) {
|
|
766
420
|
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
767
421
|
}
|
|
768
422
|
this._node.graph.hf.setCellContents({
|
|
@@ -783,11 +437,11 @@ var SheetModel = class extends import_context.Resource {
|
|
|
783
437
|
this._node?.graph.hf.rebuildAndRecalculate();
|
|
784
438
|
}
|
|
785
439
|
insertRows(i, n = 1) {
|
|
786
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
440
|
+
(0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.rows, i, n, import_chunk_JF5XNTF3.MAX_ROWS);
|
|
787
441
|
this.reset();
|
|
788
442
|
}
|
|
789
443
|
insertColumns(i, n = 1) {
|
|
790
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
444
|
+
(0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.columns, i, n, import_chunk_JF5XNTF3.MAX_COLUMNS);
|
|
791
445
|
this.reset();
|
|
792
446
|
}
|
|
793
447
|
//
|
|
@@ -799,8 +453,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
799
453
|
*/
|
|
800
454
|
clear(range) {
|
|
801
455
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
802
|
-
F:
|
|
803
|
-
L:
|
|
456
|
+
F: __dxlog_file,
|
|
457
|
+
L: 176,
|
|
804
458
|
S: this,
|
|
805
459
|
A: [
|
|
806
460
|
"this._node",
|
|
@@ -811,14 +465,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
811
465
|
const values = this._iterRange(range, () => null);
|
|
812
466
|
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
813
467
|
this._iterRange(range, (cell) => {
|
|
814
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
468
|
+
const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
|
|
815
469
|
delete this._sheet.cells[idx];
|
|
816
470
|
});
|
|
817
471
|
}
|
|
818
472
|
cut(range) {
|
|
819
473
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
820
|
-
F:
|
|
821
|
-
L:
|
|
474
|
+
F: __dxlog_file,
|
|
475
|
+
L: 187,
|
|
822
476
|
S: this,
|
|
823
477
|
A: [
|
|
824
478
|
"this._node",
|
|
@@ -827,14 +481,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
827
481
|
});
|
|
828
482
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
829
483
|
this._iterRange(range, (cell) => {
|
|
830
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
484
|
+
const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
|
|
831
485
|
delete this._sheet.cells[idx];
|
|
832
486
|
});
|
|
833
487
|
}
|
|
834
488
|
copy(range) {
|
|
835
489
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
836
|
-
F:
|
|
837
|
-
L:
|
|
490
|
+
F: __dxlog_file,
|
|
491
|
+
L: 196,
|
|
838
492
|
S: this,
|
|
839
493
|
A: [
|
|
840
494
|
"this._node",
|
|
@@ -845,8 +499,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
845
499
|
}
|
|
846
500
|
paste(cell) {
|
|
847
501
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
848
|
-
F:
|
|
849
|
-
L:
|
|
502
|
+
F: __dxlog_file,
|
|
503
|
+
L: 201,
|
|
850
504
|
S: this,
|
|
851
505
|
A: [
|
|
852
506
|
"this._node",
|
|
@@ -858,7 +512,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
858
512
|
for (const change of changes) {
|
|
859
513
|
if (change instanceof import_hyperformula.ExportedCellChange) {
|
|
860
514
|
const { address, newValue } = change;
|
|
861
|
-
const idx = addressToIndex(this._sheet, {
|
|
515
|
+
const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, {
|
|
862
516
|
row: address.row,
|
|
863
517
|
col: address.col
|
|
864
518
|
});
|
|
@@ -872,8 +526,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
872
526
|
// TODO(burdon): Display undo/redo state.
|
|
873
527
|
undo() {
|
|
874
528
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
875
|
-
F:
|
|
876
|
-
L:
|
|
529
|
+
F: __dxlog_file,
|
|
530
|
+
L: 216,
|
|
877
531
|
S: this,
|
|
878
532
|
A: [
|
|
879
533
|
"this._node",
|
|
@@ -886,8 +540,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
886
540
|
}
|
|
887
541
|
redo() {
|
|
888
542
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
889
|
-
F:
|
|
890
|
-
L:
|
|
543
|
+
F: __dxlog_file,
|
|
544
|
+
L: 224,
|
|
891
545
|
S: this,
|
|
892
546
|
A: [
|
|
893
547
|
"this._node",
|
|
@@ -902,7 +556,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
902
556
|
* Get value from sheet.
|
|
903
557
|
*/
|
|
904
558
|
getCellValue(cell) {
|
|
905
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
559
|
+
const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
|
|
906
560
|
return this._sheet.cells[idx]?.value ?? null;
|
|
907
561
|
}
|
|
908
562
|
/**
|
|
@@ -913,7 +567,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
913
567
|
if (value == null) {
|
|
914
568
|
return void 0;
|
|
915
569
|
}
|
|
916
|
-
if (
|
|
570
|
+
if ((0, import_chunk_JF5XNTF3.isFormula)(value)) {
|
|
917
571
|
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
918
572
|
} else {
|
|
919
573
|
return String(value);
|
|
@@ -930,8 +584,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
930
584
|
*/
|
|
931
585
|
getValue(cell) {
|
|
932
586
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
933
|
-
F:
|
|
934
|
-
L:
|
|
587
|
+
F: __dxlog_file,
|
|
588
|
+
L: 267,
|
|
935
589
|
S: this,
|
|
936
590
|
A: [
|
|
937
591
|
"this._node",
|
|
@@ -949,8 +603,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
949
603
|
*/
|
|
950
604
|
getValueType(cell) {
|
|
951
605
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
952
|
-
F:
|
|
953
|
-
L:
|
|
606
|
+
F: __dxlog_file,
|
|
607
|
+
L: 280,
|
|
954
608
|
S: this,
|
|
955
609
|
A: [
|
|
956
610
|
"this._node",
|
|
@@ -966,8 +620,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
966
620
|
*/
|
|
967
621
|
setValue(cell, value) {
|
|
968
622
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
969
|
-
F:
|
|
970
|
-
L:
|
|
623
|
+
F: __dxlog_file,
|
|
624
|
+
L: 290,
|
|
971
625
|
S: this,
|
|
972
626
|
A: [
|
|
973
627
|
"this._node",
|
|
@@ -975,15 +629,15 @@ var SheetModel = class extends import_context.Resource {
|
|
|
975
629
|
]
|
|
976
630
|
});
|
|
977
631
|
if (this._options.readonly) {
|
|
978
|
-
throw new ReadonlyException();
|
|
632
|
+
throw new import_chunk_JF5XNTF3.ReadonlyException();
|
|
979
633
|
}
|
|
980
634
|
let refresh = false;
|
|
981
635
|
if (cell.row >= this._sheet.rows.length) {
|
|
982
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
636
|
+
(0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_JF5XNTF3.MAX_ROWS);
|
|
983
637
|
refresh = true;
|
|
984
638
|
}
|
|
985
639
|
if (cell.col >= this._sheet.columns.length) {
|
|
986
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
640
|
+
(0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_JF5XNTF3.MAX_COLUMNS);
|
|
987
641
|
refresh = true;
|
|
988
642
|
}
|
|
989
643
|
if (refresh) {
|
|
@@ -995,14 +649,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
995
649
|
col: cell.col
|
|
996
650
|
}, [
|
|
997
651
|
[
|
|
998
|
-
|
|
652
|
+
(0, import_chunk_JF5XNTF3.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
|
|
999
653
|
]
|
|
1000
654
|
]);
|
|
1001
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
655
|
+
const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
|
|
1002
656
|
if (value === void 0 || value === null) {
|
|
1003
657
|
delete this._sheet.cells[idx];
|
|
1004
658
|
} else {
|
|
1005
|
-
if (
|
|
659
|
+
if ((0, import_chunk_JF5XNTF3.isFormula)(value)) {
|
|
1006
660
|
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1007
661
|
}
|
|
1008
662
|
this._sheet.cells[idx] = {
|
|
@@ -1015,7 +669,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1015
669
|
*/
|
|
1016
670
|
setValues(values) {
|
|
1017
671
|
Object.entries(values).forEach(([key, { value }]) => {
|
|
1018
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
672
|
+
this.setValue((0, import_chunk_JF5XNTF3.addressFromA1Notation)(key), value);
|
|
1019
673
|
});
|
|
1020
674
|
}
|
|
1021
675
|
/**
|
|
@@ -1062,34 +716,34 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1062
716
|
* Map from A1 notation to indices.
|
|
1063
717
|
*/
|
|
1064
718
|
mapFormulaRefsToIndices(formula) {
|
|
1065
|
-
(0, import_invariant3.invariant)(
|
|
1066
|
-
F:
|
|
1067
|
-
L:
|
|
719
|
+
(0, import_invariant3.invariant)((0, import_chunk_JF5XNTF3.isFormula)(formula), void 0, {
|
|
720
|
+
F: __dxlog_file,
|
|
721
|
+
L: 379,
|
|
1068
722
|
S: this,
|
|
1069
723
|
A: [
|
|
1070
|
-
"formula
|
|
724
|
+
"isFormula(formula)",
|
|
1071
725
|
""
|
|
1072
726
|
]
|
|
1073
727
|
});
|
|
1074
728
|
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1075
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
729
|
+
return (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, (0, import_chunk_JF5XNTF3.addressFromA1Notation)(match));
|
|
1076
730
|
});
|
|
1077
731
|
}
|
|
1078
732
|
/**
|
|
1079
733
|
* Map from indices to A1 notation.
|
|
1080
734
|
*/
|
|
1081
735
|
mapFormulaIndicesToRefs(formula) {
|
|
1082
|
-
(0, import_invariant3.invariant)(
|
|
1083
|
-
F:
|
|
1084
|
-
L:
|
|
736
|
+
(0, import_invariant3.invariant)((0, import_chunk_JF5XNTF3.isFormula)(formula), void 0, {
|
|
737
|
+
F: __dxlog_file,
|
|
738
|
+
L: 389,
|
|
1085
739
|
S: this,
|
|
1086
740
|
A: [
|
|
1087
|
-
"formula
|
|
741
|
+
"isFormula(formula)",
|
|
1088
742
|
""
|
|
1089
743
|
]
|
|
1090
744
|
});
|
|
1091
745
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1092
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
746
|
+
return (0, import_chunk_JF5XNTF3.addressToA1Notation)((0, import_chunk_JF5XNTF3.addressFromIndex)(this._sheet, idx));
|
|
1093
747
|
});
|
|
1094
748
|
}
|
|
1095
749
|
//
|
|
@@ -1106,8 +760,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1106
760
|
}
|
|
1107
761
|
toDateTime(num) {
|
|
1108
762
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1109
|
-
F:
|
|
1110
|
-
L:
|
|
763
|
+
F: __dxlog_file,
|
|
764
|
+
L: 410,
|
|
1111
765
|
S: this,
|
|
1112
766
|
A: [
|
|
1113
767
|
"this._node",
|
|
@@ -1118,8 +772,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1118
772
|
}
|
|
1119
773
|
toDate(num) {
|
|
1120
774
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1121
|
-
F:
|
|
1122
|
-
L:
|
|
775
|
+
F: __dxlog_file,
|
|
776
|
+
L: 415,
|
|
1123
777
|
S: this,
|
|
1124
778
|
A: [
|
|
1125
779
|
"this._node",
|
|
@@ -1130,8 +784,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1130
784
|
}
|
|
1131
785
|
toTime(num) {
|
|
1132
786
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1133
|
-
F:
|
|
1134
|
-
L:
|
|
787
|
+
F: __dxlog_file,
|
|
788
|
+
L: 420,
|
|
1135
789
|
S: this,
|
|
1136
790
|
A: [
|
|
1137
791
|
"this._node",
|
|
@@ -1142,8 +796,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1142
796
|
}
|
|
1143
797
|
};
|
|
1144
798
|
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1145
|
-
const [model, setModel] = (0,
|
|
1146
|
-
(0,
|
|
799
|
+
const [model, setModel] = (0, import_react3.useState)();
|
|
800
|
+
(0, import_react3.useEffect)(() => {
|
|
1147
801
|
if (!graph || !sheet) {
|
|
1148
802
|
return;
|
|
1149
803
|
}
|
|
@@ -1166,167 +820,353 @@ var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
|
1166
820
|
]);
|
|
1167
821
|
return model;
|
|
1168
822
|
};
|
|
1169
|
-
var
|
|
1170
|
-
|
|
823
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
824
|
+
var SheetContext = /* @__PURE__ */ (0, import_react2.createContext)(void 0);
|
|
825
|
+
var useSheetContext = () => {
|
|
826
|
+
const context = (0, import_react2.useContext)(SheetContext);
|
|
827
|
+
(0, import_invariant2.invariant)(context, void 0, {
|
|
828
|
+
F: __dxlog_file2,
|
|
829
|
+
L: 52,
|
|
830
|
+
S: void 0,
|
|
831
|
+
A: [
|
|
832
|
+
"context",
|
|
833
|
+
""
|
|
834
|
+
]
|
|
835
|
+
});
|
|
836
|
+
return context;
|
|
837
|
+
};
|
|
838
|
+
var SheetProviderImpl = ({ model, onInfo, children, __gridScope }) => {
|
|
839
|
+
const { id, editing, setEditing } = (0, import_react_ui_grid.useGridContext)("SheetProvider", __gridScope);
|
|
840
|
+
const [cursor, setCursorInternal] = (0, import_react2.useState)();
|
|
841
|
+
const [range, setRangeInternal] = (0, import_react2.useState)();
|
|
842
|
+
const [cursorFallbackRange, setCursorFallbackRange] = (0, import_react2.useState)();
|
|
843
|
+
const [activeRefs, setActiveRefs] = (0, import_react2.useState)("");
|
|
844
|
+
const setCursor = (0, import_react2.useCallback)((nextCursor) => {
|
|
845
|
+
setCursorInternal(nextCursor);
|
|
846
|
+
setCursorFallbackRange(range?.to ? range : nextCursor ? {
|
|
847
|
+
from: nextCursor,
|
|
848
|
+
to: nextCursor
|
|
849
|
+
} : void 0);
|
|
850
|
+
}, [
|
|
851
|
+
range
|
|
852
|
+
]);
|
|
853
|
+
const setRange = (0, import_react2.useCallback)((nextRange) => {
|
|
854
|
+
setRangeInternal(nextRange);
|
|
855
|
+
setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
|
|
856
|
+
from: cursor,
|
|
857
|
+
to: cursor
|
|
858
|
+
} : void 0);
|
|
859
|
+
}, [
|
|
860
|
+
cursor
|
|
861
|
+
]);
|
|
862
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContext.Provider, {
|
|
863
|
+
value: {
|
|
864
|
+
id,
|
|
865
|
+
model,
|
|
866
|
+
editing,
|
|
867
|
+
setEditing,
|
|
868
|
+
cursor,
|
|
869
|
+
setCursor,
|
|
870
|
+
range,
|
|
871
|
+
setRange,
|
|
872
|
+
cursorFallbackRange,
|
|
873
|
+
activeRefs,
|
|
874
|
+
setActiveRefs,
|
|
875
|
+
// TODO(burdon): Change to event.
|
|
876
|
+
onInfo
|
|
877
|
+
}
|
|
878
|
+
}, children);
|
|
879
|
+
};
|
|
880
|
+
var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
881
|
+
const model = useSheetModel(graph, sheet, {
|
|
882
|
+
readonly
|
|
883
|
+
});
|
|
884
|
+
return !model ? null : /* @__PURE__ */ import_react2.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
885
|
+
id: (0, import_echo.fullyQualifiedId)(sheet)
|
|
886
|
+
}, /* @__PURE__ */ import_react2.default.createElement(SheetProviderImpl, {
|
|
887
|
+
model,
|
|
888
|
+
onInfo
|
|
889
|
+
}, children));
|
|
890
|
+
};
|
|
891
|
+
var RangeList = ({ sheet }) => {
|
|
892
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_QIFIGEKV.SHEET_PLUGIN);
|
|
893
|
+
const handleSelectRange = (range) => {
|
|
894
|
+
};
|
|
895
|
+
const handleDeleteRange = (0, import_react8.useCallback)((range) => {
|
|
896
|
+
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
897
|
+
sheet.ranges.splice(index, 1);
|
|
898
|
+
}, [
|
|
899
|
+
sheet
|
|
900
|
+
]);
|
|
901
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("h2", {
|
|
902
|
+
className: "p-2 text-sm font-semibold"
|
|
903
|
+
}, t("range list heading")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
|
|
904
|
+
items: sheet.ranges,
|
|
905
|
+
isItem: import_echo_schema2.S.is(import_chunk_2XJ5I4UF.Range)
|
|
906
|
+
}, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
|
|
907
|
+
key: i,
|
|
908
|
+
item: range,
|
|
909
|
+
classNames: [
|
|
910
|
+
"p-2",
|
|
911
|
+
import_react_ui_theme3.ghostHover
|
|
912
|
+
]
|
|
913
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
|
|
914
|
+
onClick: () => handleSelectRange(range)
|
|
915
|
+
}, t("range title", {
|
|
916
|
+
position: (0, import_chunk_JF5XNTF3.rangeToA1Notation)((0, import_chunk_JF5XNTF3.rangeFromIndex)(sheet, range.range)),
|
|
917
|
+
key: t(`range key ${range.key} label`),
|
|
918
|
+
value: t(`range value ${range.value} label`)
|
|
919
|
+
})), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
|
|
920
|
+
onClick: () => handleDeleteRange(range)
|
|
921
|
+
})))));
|
|
922
|
+
};
|
|
923
|
+
var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-6BO4C5X2.cjs"));
|
|
924
|
+
var completeCellRangeToThreadCursor = (range) => {
|
|
925
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
926
|
+
};
|
|
927
|
+
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
928
|
+
const coords = cursor.split(",");
|
|
929
|
+
if (coords.length !== 4) {
|
|
930
|
+
return null;
|
|
931
|
+
} else {
|
|
932
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
933
|
+
return {
|
|
934
|
+
from: {
|
|
935
|
+
col: parseInt(fromCol),
|
|
936
|
+
row: parseInt(fromRow)
|
|
937
|
+
},
|
|
938
|
+
to: {
|
|
939
|
+
col: parseInt(toCol),
|
|
940
|
+
row: parseInt(toRow)
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
946
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
947
|
+
const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
|
|
1171
948
|
switch (action) {
|
|
1172
949
|
case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
|
|
1173
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== (0,
|
|
950
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
|
|
1174
951
|
return;
|
|
1175
952
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
953
|
+
setActiveRefs(data.thread);
|
|
954
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
955
|
+
range && grid?.setFocus({
|
|
956
|
+
...range.to,
|
|
1179
957
|
plane: "grid"
|
|
1180
958
|
}, true);
|
|
1181
959
|
}
|
|
1182
960
|
}
|
|
1183
961
|
}, [
|
|
1184
|
-
model.sheet
|
|
962
|
+
model.sheet,
|
|
963
|
+
setActiveRefs
|
|
1185
964
|
]);
|
|
1186
965
|
(0, import_app_framework.useIntentResolver)(import_chunk_QIFIGEKV.SHEET_PLUGIN, handleScrollIntoView);
|
|
1187
966
|
};
|
|
1188
|
-
var useSelectThreadOnCellFocus = (
|
|
967
|
+
var useSelectThreadOnCellFocus = () => {
|
|
968
|
+
const { model, cursor } = useSheetContext();
|
|
1189
969
|
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1190
|
-
const
|
|
970
|
+
const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
|
|
1191
971
|
// TODO(thure): Surely we can find a better dependency for this…
|
|
1192
972
|
JSON.stringify(model.sheet.threads)
|
|
1193
973
|
]);
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
model.sheet
|
|
1197
|
-
]);
|
|
1198
|
-
const selectClosestThread = (0, import_react7.useCallback)((cellAddress) => {
|
|
1199
|
-
if (!cellAddress || !activeThreads) {
|
|
974
|
+
const selectClosestThread = (0, import_react6.useCallback)((cellAddress) => {
|
|
975
|
+
if (!cellAddress || !threads) {
|
|
1200
976
|
return;
|
|
1201
977
|
}
|
|
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
|
-
]);
|
|
978
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
979
|
+
if (anchor) {
|
|
980
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
981
|
+
return range ? (0, import_chunk_JF5XNTF3.inRange)(range, cellAddress) : false;
|
|
982
|
+
} else {
|
|
983
|
+
return false;
|
|
1214
984
|
}
|
|
985
|
+
});
|
|
986
|
+
if (closestThread) {
|
|
987
|
+
void dispatch([
|
|
988
|
+
{
|
|
989
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
990
|
+
data: {
|
|
991
|
+
current: (0, import_echo3.fullyQualifiedId)(closestThread)
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
]);
|
|
1215
995
|
}
|
|
1216
996
|
}, [
|
|
1217
997
|
dispatch,
|
|
1218
|
-
|
|
1219
|
-
activeThreadAddresses,
|
|
1220
|
-
model.sheet
|
|
998
|
+
threads
|
|
1221
999
|
]);
|
|
1222
|
-
const debounced = (0,
|
|
1000
|
+
const debounced = (0, import_react6.useMemo)(() => {
|
|
1223
1001
|
return (0, import_async3.debounce)((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
1224
1002
|
}, [
|
|
1225
1003
|
selectClosestThread
|
|
1226
1004
|
]);
|
|
1227
|
-
(0,
|
|
1005
|
+
(0, import_react6.useEffect)(() => {
|
|
1228
1006
|
if (!cursor) {
|
|
1229
1007
|
return;
|
|
1230
1008
|
}
|
|
1231
1009
|
debounced(cursor);
|
|
1232
1010
|
}, [
|
|
1233
1011
|
cursor,
|
|
1234
|
-
|
|
1012
|
+
debounced
|
|
1235
1013
|
]);
|
|
1236
1014
|
};
|
|
1237
|
-
var
|
|
1015
|
+
var dxGridCellIndexToSheetCellAddress = (index) => {
|
|
1016
|
+
const [colStr, rowStr] = index.split(",");
|
|
1238
1017
|
return {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
"bg-greenFill"
|
|
1242
|
-
],
|
|
1243
|
-
cellIndex
|
|
1018
|
+
col: parseInt(colStr),
|
|
1019
|
+
row: parseInt(rowStr)
|
|
1244
1020
|
};
|
|
1245
1021
|
};
|
|
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();
|
|
1022
|
+
var createDxGridColumns = (model) => {
|
|
1023
|
+
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
1024
|
+
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
1025
|
+
acc.grid[numericIndex] = {
|
|
1026
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
1027
|
+
resizeable: true
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
return acc;
|
|
1031
|
+
}, {
|
|
1032
|
+
grid: {}
|
|
1280
1033
|
});
|
|
1281
1034
|
};
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
]
|
|
1035
|
+
var createDxGridRows = (model) => {
|
|
1036
|
+
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
1037
|
+
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
1038
|
+
acc.grid[numericIndex] = {
|
|
1039
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
1040
|
+
resizeable: true
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
return acc;
|
|
1044
|
+
}, {
|
|
1045
|
+
grid: {}
|
|
1294
1046
|
});
|
|
1295
|
-
return context;
|
|
1296
1047
|
};
|
|
1297
|
-
var
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1048
|
+
var projectCellProps = (model, col, row) => {
|
|
1049
|
+
const address = {
|
|
1050
|
+
col,
|
|
1051
|
+
row
|
|
1052
|
+
};
|
|
1053
|
+
const rawValue = model.getValue(address);
|
|
1054
|
+
const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_JF5XNTF3.inRange)((0, import_chunk_JF5XNTF3.rangeFromIndex)(model.sheet, range), address));
|
|
1055
|
+
const threadRefs = model.sheet.threads?.filter((thread) => {
|
|
1056
|
+
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
|
|
1057
|
+
return thread && range ? (0, import_chunk_JF5XNTF3.inRange)(range, address) : false;
|
|
1058
|
+
}).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
|
|
1059
|
+
const type = model.getValueType(address);
|
|
1060
|
+
const classNames = ranges?.map(import_chunk_JF5XNTF3.cellClassNameForRange).reverse();
|
|
1061
|
+
return {
|
|
1062
|
+
value: (0, import_react_ui_data.parseValue)(type, rawValue),
|
|
1063
|
+
className: (0, import_react_ui_theme2.mx)((0, import_react_ui_data.cellClassesForFieldType)(type), threadRefs && import_react_ui_grid3.commentedClassName, classNames),
|
|
1064
|
+
dataRefs: threadRefs
|
|
1065
|
+
};
|
|
1066
|
+
};
|
|
1067
|
+
var gridCellGetter = (model) => {
|
|
1068
|
+
const cachedGridCells = {};
|
|
1069
|
+
return (nextBounds) => {
|
|
1070
|
+
[
|
|
1071
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1072
|
+
].forEach((_, c0) => {
|
|
1073
|
+
return [
|
|
1074
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1075
|
+
].forEach((_2, r0) => {
|
|
1076
|
+
const col = nextBounds.start.col + c0;
|
|
1077
|
+
const row = nextBounds.start.row + r0;
|
|
1078
|
+
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
1079
|
+
});
|
|
1080
|
+
});
|
|
1081
|
+
return cachedGridCells;
|
|
1082
|
+
};
|
|
1083
|
+
};
|
|
1084
|
+
var rowLabelCell = (row) => ({
|
|
1085
|
+
value: (0, import_react_ui_grid3.rowToA1Notation)(row),
|
|
1086
|
+
className: "text-end !pie-1",
|
|
1087
|
+
resizeHandle: "row"
|
|
1088
|
+
});
|
|
1089
|
+
var colLabelCell = (col) => ({
|
|
1090
|
+
value: (0, import_react_ui_grid3.colToA1Notation)(col),
|
|
1091
|
+
resizeHandle: "col"
|
|
1092
|
+
});
|
|
1093
|
+
var cellGetter = (model) => {
|
|
1094
|
+
const getGridCells = gridCellGetter(model);
|
|
1095
|
+
return (nextBounds, plane) => {
|
|
1096
|
+
switch (plane) {
|
|
1097
|
+
case "grid":
|
|
1098
|
+
return getGridCells(nextBounds);
|
|
1099
|
+
case "frozenColsStart":
|
|
1100
|
+
return [
|
|
1101
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1102
|
+
].reduce((acc, _, r0) => {
|
|
1103
|
+
const r = nextBounds.start.row + r0;
|
|
1104
|
+
acc[`0,${r}`] = rowLabelCell(r);
|
|
1105
|
+
return acc;
|
|
1106
|
+
}, {});
|
|
1107
|
+
case "frozenRowsStart":
|
|
1108
|
+
return [
|
|
1109
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1110
|
+
].reduce((acc, _, c0) => {
|
|
1111
|
+
const c = nextBounds.start.col + c0;
|
|
1112
|
+
acc[`${c},0`] = colLabelCell(c);
|
|
1113
|
+
return acc;
|
|
1114
|
+
}, {});
|
|
1115
|
+
default:
|
|
1116
|
+
return {};
|
|
1317
1117
|
}
|
|
1318
|
-
}
|
|
1118
|
+
};
|
|
1319
1119
|
};
|
|
1320
|
-
var
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1120
|
+
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1121
|
+
const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1122
|
+
const [rows, setRows] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1123
|
+
(0, import_react5.useEffect)(() => {
|
|
1124
|
+
const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1125
|
+
"cells"
|
|
1126
|
+
]);
|
|
1127
|
+
if (dxGrid) {
|
|
1128
|
+
dxGrid.getCells = cellGetter(model);
|
|
1129
|
+
}
|
|
1130
|
+
const handleCellsUpdate = () => {
|
|
1131
|
+
dxGrid?.requestUpdate("initialCells");
|
|
1132
|
+
};
|
|
1133
|
+
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1134
|
+
return () => cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1135
|
+
}, [
|
|
1327
1136
|
model,
|
|
1328
|
-
|
|
1329
|
-
|
|
1137
|
+
dxGrid
|
|
1138
|
+
]);
|
|
1139
|
+
(0, import_react5.useEffect)(() => {
|
|
1140
|
+
const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1141
|
+
"columnMeta"
|
|
1142
|
+
]);
|
|
1143
|
+
const rowMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1144
|
+
"rowMeta"
|
|
1145
|
+
]);
|
|
1146
|
+
const handleColumnMetaUpdate = () => {
|
|
1147
|
+
setColumns(createDxGridColumns(model));
|
|
1148
|
+
};
|
|
1149
|
+
const handleRowMetaUpdate = () => {
|
|
1150
|
+
setRows(createDxGridRows(model));
|
|
1151
|
+
};
|
|
1152
|
+
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1153
|
+
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1154
|
+
return () => {
|
|
1155
|
+
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1156
|
+
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1157
|
+
};
|
|
1158
|
+
}, [
|
|
1159
|
+
model
|
|
1160
|
+
]);
|
|
1161
|
+
return {
|
|
1162
|
+
columns,
|
|
1163
|
+
rows
|
|
1164
|
+
};
|
|
1165
|
+
};
|
|
1166
|
+
var inertPosition = {
|
|
1167
|
+
plane: "grid",
|
|
1168
|
+
col: 0,
|
|
1169
|
+
row: 0
|
|
1330
1170
|
};
|
|
1331
1171
|
var initialCells = {
|
|
1332
1172
|
grid: {},
|
|
@@ -1368,13 +1208,14 @@ var sheetColDefault = {
|
|
|
1368
1208
|
}
|
|
1369
1209
|
};
|
|
1370
1210
|
var GridSheet = () => {
|
|
1371
|
-
const {
|
|
1372
|
-
const
|
|
1373
|
-
const
|
|
1211
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_QIFIGEKV.SHEET_PLUGIN);
|
|
1212
|
+
const { id, model, editing, setEditing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
|
|
1213
|
+
const [dxGrid, setDxGrid] = (0, import_react4.useState)(null);
|
|
1214
|
+
const rangeController = (0, import_react4.useRef)();
|
|
1374
1215
|
const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
|
|
1375
1216
|
const handleFocus = (0, import_react4.useCallback)((event) => {
|
|
1376
1217
|
if (!editing) {
|
|
1377
|
-
const cell = (0,
|
|
1218
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1378
1219
|
if (cell && cell.plane === "grid") {
|
|
1379
1220
|
setCursor({
|
|
1380
1221
|
col: cell.col,
|
|
@@ -1403,11 +1244,20 @@ var GridSheet = () => {
|
|
|
1403
1244
|
"ArrowUp",
|
|
1404
1245
|
"ArrowLeft"
|
|
1405
1246
|
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1406
|
-
dxGrid
|
|
1247
|
+
dxGrid?.refocus(axis, delta);
|
|
1407
1248
|
}, [
|
|
1408
1249
|
model,
|
|
1409
1250
|
editing,
|
|
1410
|
-
|
|
1251
|
+
dxGrid
|
|
1252
|
+
]);
|
|
1253
|
+
const handleBlur = (0, import_react4.useCallback)((value) => {
|
|
1254
|
+
if (value !== void 0) {
|
|
1255
|
+
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1256
|
+
}
|
|
1257
|
+
setEditing(null);
|
|
1258
|
+
}, [
|
|
1259
|
+
model,
|
|
1260
|
+
editing
|
|
1411
1261
|
]);
|
|
1412
1262
|
const handleAxisResize = (0, import_react4.useCallback)(({ axis, size, index: numericIndex }) => {
|
|
1413
1263
|
if (axis === "row") {
|
|
@@ -1423,22 +1273,22 @@ var GridSheet = () => {
|
|
|
1423
1273
|
model
|
|
1424
1274
|
]);
|
|
1425
1275
|
const handleSelect = (0, import_react4.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1426
|
-
const
|
|
1276
|
+
const range = {
|
|
1427
1277
|
from: {
|
|
1428
1278
|
col: minCol,
|
|
1429
1279
|
row: minRow
|
|
1430
1280
|
}
|
|
1431
1281
|
};
|
|
1432
1282
|
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1433
|
-
|
|
1283
|
+
range.to = {
|
|
1434
1284
|
col: maxCol,
|
|
1435
1285
|
row: maxRow
|
|
1436
1286
|
};
|
|
1437
1287
|
}
|
|
1438
1288
|
if (editing) {
|
|
1439
|
-
|
|
1289
|
+
rangeController.current?.setRange((0, import_chunk_JF5XNTF3.rangeToA1Notation)(range));
|
|
1440
1290
|
} else {
|
|
1441
|
-
setRange(
|
|
1291
|
+
setRange(range.to ? range : void 0);
|
|
1442
1292
|
}
|
|
1443
1293
|
}, [
|
|
1444
1294
|
editing
|
|
@@ -1451,10 +1301,6 @@ var GridSheet = () => {
|
|
|
1451
1301
|
hasAttention
|
|
1452
1302
|
]);
|
|
1453
1303
|
const handleKeyDown = (0, import_react4.useCallback)((event) => {
|
|
1454
|
-
const cursorFallbackRange = range ?? cursor ? {
|
|
1455
|
-
from: cursor,
|
|
1456
|
-
to: cursor
|
|
1457
|
-
} : null;
|
|
1458
1304
|
switch (event.key) {
|
|
1459
1305
|
case "Backspace":
|
|
1460
1306
|
case "Delete":
|
|
@@ -1485,13 +1331,37 @@ var GridSheet = () => {
|
|
|
1485
1331
|
}
|
|
1486
1332
|
}
|
|
1487
1333
|
}, [
|
|
1488
|
-
|
|
1334
|
+
cursorFallbackRange,
|
|
1489
1335
|
model,
|
|
1490
1336
|
cursor
|
|
1491
1337
|
]);
|
|
1338
|
+
const contextMenuAnchorRef = (0, import_react4.useRef)(null);
|
|
1339
|
+
const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
|
|
1340
|
+
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1341
|
+
const handleContextMenu = (0, import_react4.useCallback)((event) => {
|
|
1342
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1343
|
+
if (cell && cell.plane.startsWith("frozen")) {
|
|
1344
|
+
event.preventDefault();
|
|
1345
|
+
contextMenuAnchorRef.current = event.target;
|
|
1346
|
+
setContextMenuOpen(cell);
|
|
1347
|
+
}
|
|
1348
|
+
}, []);
|
|
1349
|
+
const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
|
|
1350
|
+
switch (operation) {
|
|
1351
|
+
case "add-before":
|
|
1352
|
+
case "add-after":
|
|
1353
|
+
model[contextMenuAxis === "col" ? "insertColumns" : "insertRows"](contextMenuOpen[contextMenuAxis] + (operation === "add-before" ? 0 : 1), 1);
|
|
1354
|
+
break;
|
|
1355
|
+
case "remove":
|
|
1356
|
+
}
|
|
1357
|
+
}, [
|
|
1358
|
+
contextMenuAxis,
|
|
1359
|
+
contextMenuOpen,
|
|
1360
|
+
model
|
|
1361
|
+
]);
|
|
1492
1362
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1493
1363
|
const extension = (0, import_react4.useMemo)(() => [
|
|
1494
|
-
(0,
|
|
1364
|
+
(0, import_react_ui_grid2.editorKeys)({
|
|
1495
1365
|
onClose: handleClose,
|
|
1496
1366
|
...editing?.initialContent && {
|
|
1497
1367
|
onNav: handleClose
|
|
@@ -1500,7 +1370,14 @@ var GridSheet = () => {
|
|
|
1500
1370
|
sheetExtension({
|
|
1501
1371
|
functions: model.graph.getFunctions()
|
|
1502
1372
|
}),
|
|
1503
|
-
rangeExtension(
|
|
1373
|
+
rangeExtension({
|
|
1374
|
+
onInit: (fn) => rangeController.current = fn,
|
|
1375
|
+
onStateChange: (state) => {
|
|
1376
|
+
if (dxGrid) {
|
|
1377
|
+
dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
})
|
|
1504
1381
|
], [
|
|
1505
1382
|
model,
|
|
1506
1383
|
handleClose,
|
|
@@ -1512,14 +1389,16 @@ var GridSheet = () => {
|
|
|
1512
1389
|
}, [
|
|
1513
1390
|
model
|
|
1514
1391
|
]);
|
|
1515
|
-
useUpdateFocusedCellOnThreadSelection(
|
|
1516
|
-
|
|
1392
|
+
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1393
|
+
useSelectThreadOnCellFocus();
|
|
1394
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.GridCellEditor, {
|
|
1517
1395
|
getCellContent,
|
|
1518
|
-
extension
|
|
1519
|
-
|
|
1396
|
+
extension,
|
|
1397
|
+
onBlur: handleBlur
|
|
1398
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
|
|
1520
1399
|
initialCells,
|
|
1521
|
-
limitColumns: DEFAULT_COLUMNS,
|
|
1522
|
-
limitRows: DEFAULT_ROWS,
|
|
1400
|
+
limitColumns: import_chunk_JF5XNTF3.DEFAULT_COLUMNS,
|
|
1401
|
+
limitRows: import_chunk_JF5XNTF3.DEFAULT_ROWS,
|
|
1523
1402
|
columns,
|
|
1524
1403
|
rows,
|
|
1525
1404
|
onAxisResize: handleAxisResize,
|
|
@@ -1530,40 +1409,49 @@ var GridSheet = () => {
|
|
|
1530
1409
|
onFocus: handleFocus,
|
|
1531
1410
|
onWheelCapture: handleWheel,
|
|
1532
1411
|
onKeyDown: handleKeyDown,
|
|
1412
|
+
onContextMenu: handleContextMenu,
|
|
1533
1413
|
overscroll: "inline",
|
|
1534
1414
|
className: "[--dx-grid-base:var(--surface-bg)]",
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
},
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1415
|
+
activeRefs,
|
|
1416
|
+
ref: setDxGrid
|
|
1417
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
|
|
1418
|
+
modal: false,
|
|
1419
|
+
open: !!contextMenuOpen,
|
|
1420
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1421
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
|
|
1422
|
+
virtualRef: contextMenuAnchorRef
|
|
1423
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Content, {
|
|
1424
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1425
|
+
sideOffset: 4,
|
|
1426
|
+
collisionPadding: 8
|
|
1427
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1428
|
+
onClick: () => handleAxisMenuAction("add-before")
|
|
1429
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1430
|
+
size: 5,
|
|
1431
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1432
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1433
|
+
onClick: () => handleAxisMenuAction("add-after")
|
|
1434
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1435
|
+
size: 5,
|
|
1436
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1437
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1438
|
+
disabled: true,
|
|
1439
|
+
onClick: () => handleAxisMenuAction("remove")
|
|
1440
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1441
|
+
size: 5,
|
|
1442
|
+
icon: "ph--backspace--regular"
|
|
1443
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
|
|
1552
1444
|
};
|
|
1553
1445
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1554
1446
|
0 && (module.exports = {
|
|
1555
1447
|
ComputeGraphContextProvider,
|
|
1556
1448
|
GridSheet,
|
|
1449
|
+
RangeList,
|
|
1557
1450
|
SheetContainer,
|
|
1558
1451
|
SheetProvider,
|
|
1559
|
-
|
|
1560
|
-
addressToIndex,
|
|
1561
|
-
compareIndexPositions,
|
|
1452
|
+
completeCellRangeToThreadCursor,
|
|
1562
1453
|
computeGraphFacet,
|
|
1563
|
-
createSheet,
|
|
1564
|
-
inRange,
|
|
1565
|
-
rangeToA1Notation,
|
|
1566
1454
|
useComputeGraph,
|
|
1567
1455
|
useSheetContext
|
|
1568
1456
|
});
|
|
1569
|
-
//# sourceMappingURL=chunk-
|
|
1457
|
+
//# sourceMappingURL=chunk-DEPJHN47.cjs.map
|