@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-staging.54a8bab
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-JZEKRM4Z.mjs} +83 -76
- package/dist/lib/browser/SheetContainer-JZEKRM4Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-BVUN7SHF.mjs} +6 -13
- package/dist/lib/browser/chunk-BVUN7SHF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-G2FUL6PK.mjs} +791 -690
- package/dist/lib/browser/chunk-G2FUL6PK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D3QTX46O.mjs → chunk-RABELMEQ.mjs} +3 -2
- package/dist/lib/browser/{chunk-D3QTX46O.mjs.map → chunk-RABELMEQ.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-VMSX6Z4X.mjs} +297 -44
- package/dist/lib/browser/chunk-VMSX6Z4X.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-GGWUX644.mjs} +4 -2
- package/dist/lib/browser/index.mjs +91 -21
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +2 -2
- package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-PJE74VO4.cjs} +81 -81
- package/dist/lib/node/SheetContainer-PJE74VO4.cjs.map +7 -0
- package/dist/lib/node/{chunk-QIFIGEKV.cjs → chunk-2ZVZI2KJ.cjs} +6 -5
- package/dist/lib/node/{chunk-QIFIGEKV.cjs.map → chunk-2ZVZI2KJ.cjs.map} +3 -3
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-AWKOWDMI.cjs} +10 -17
- package/dist/lib/node/chunk-AWKOWDMI.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-O7XR4R7Y.cjs} +306 -42
- package/dist/lib/node/chunk-O7XR4R7Y.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-STZ7S7RF.cjs} +755 -668
- package/dist/lib/node/chunk-STZ7S7RF.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-KGWA2QLE.cjs} +21 -19
- package/dist/lib/node/compute-graph-KGWA2QLE.cjs.map +7 -0
- package/dist/lib/node/index.cjs +109 -42
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +7 -7
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-R73XEXHU.mjs} +83 -76
- package/dist/lib/node-esm/SheetContainer-R73XEXHU.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VCYJWE3O.mjs → chunk-BM2Q3FFC.mjs} +3 -2
- package/dist/lib/node-esm/{chunk-VCYJWE3O.mjs.map → chunk-BM2Q3FFC.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-CR4K75EL.mjs} +296 -44
- package/dist/lib/node-esm/chunk-CR4K75EL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-UIBWRHW7.mjs} +6 -13
- package/dist/lib/node-esm/chunk-UIBWRHW7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-V5N3Y2O5.mjs} +791 -690
- package/dist/lib/node-esm/chunk-V5N3Y2O5.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-2SCZT7N5.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +91 -21
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/types.mjs +2 -2
- 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/SheetContainer/SheetContainer.stories.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 +6 -3
- 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 +3 -3
- 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 +2 -2
- 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 +3 -7
- 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/meta.d.ts +1 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- 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 +13 -6
- 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 +18 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +37 -33
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +43 -50
- package/src/SheetPlugin.tsx +45 -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 +181 -24
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +34 -18
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +5 -3
- package/src/components/SheetContainer/SheetContainer.tsx +10 -4
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +98 -74
- 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 +27 -9
- package/src/{graph → compute-graph}/compute-node.ts +2 -3
- package/src/{graph → compute-graph}/functions/async-function.ts +1 -0
- package/src/{graph → compute-graph}/functions/edge-function.ts +5 -3
- package/src/defs/index.ts +1 -1
- package/src/defs/sheet-range-types.ts +9 -6
- package/src/defs/types.ts +6 -1
- package/src/defs/util.ts +4 -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/meta.ts +1 -0
- package/src/model/index.ts +1 -1
- package/src/model/sheet-model.test.ts +6 -4
- package/src/model/sheet-model.ts +103 -26
- 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 +18 -3
- package/src/types.ts +24 -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-GGWUX644.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-2SCZT7N5.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/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_STZ7S7RF_exports = {};
|
|
30
|
+
__export(chunk_STZ7S7RF_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
|
|
47
|
-
var
|
|
48
|
-
var
|
|
41
|
+
module.exports = __toCommonJS(chunk_STZ7S7RF_exports);
|
|
42
|
+
var import_chunk_O7XR4R7Y = require("./chunk-O7XR4R7Y.cjs");
|
|
43
|
+
var import_chunk_AWKOWDMI = require("./chunk-AWKOWDMI.cjs");
|
|
44
|
+
var import_chunk_2ZVZI2KJ = require("./chunk-2ZVZI2KJ.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
|
-
var import_schema = require("@dxos/schema");
|
|
87
71
|
var import_hyperformula = require("#hyperformula");
|
|
88
|
-
var
|
|
89
|
-
var
|
|
72
|
+
var import_react3 = require("react");
|
|
73
|
+
var import_react4 = __toESM(require("react"));
|
|
90
74
|
var import_app_framework = require("@dxos/app-framework");
|
|
91
|
-
var
|
|
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");
|
|
92
79
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
93
|
-
var
|
|
94
|
-
var import_invariant4 = require("@dxos/invariant");
|
|
95
|
-
var import_echo3 = require("@dxos/react-client/echo");
|
|
80
|
+
var import_react_ui_data = require("@dxos/react-ui-data");
|
|
96
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");
|
|
84
|
+
var import_app_framework2 = require("@dxos/app-framework");
|
|
85
|
+
var import_async3 = require("@dxos/async");
|
|
86
|
+
var import_echo3 = require("@dxos/react-client/echo");
|
|
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_O7XR4R7Y.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,201 +317,34 @@ 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
|
-
BOOLEAN:
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
322
|
+
BOOLEAN: {
|
|
323
|
+
type: import_echo_schema.TypeEnum.Boolean
|
|
324
|
+
},
|
|
325
|
+
NUMBER_RAW: {
|
|
326
|
+
type: import_echo_schema.TypeEnum.Number
|
|
327
|
+
},
|
|
328
|
+
NUMBER_PERCENT: {
|
|
329
|
+
type: import_echo_schema.TypeEnum.Number,
|
|
330
|
+
format: import_echo_schema.FormatEnum.Percent
|
|
331
|
+
},
|
|
332
|
+
NUMBER_CURRENCY: {
|
|
333
|
+
type: import_echo_schema.TypeEnum.Number,
|
|
334
|
+
format: import_echo_schema.FormatEnum.Currency
|
|
335
|
+
},
|
|
336
|
+
NUMBER_DATETIME: {
|
|
337
|
+
type: import_echo_schema.TypeEnum.String,
|
|
338
|
+
format: import_echo_schema.FormatEnum.DateTime
|
|
339
|
+
},
|
|
340
|
+
NUMBER_DATE: {
|
|
341
|
+
type: import_echo_schema.TypeEnum.String,
|
|
342
|
+
format: import_echo_schema.FormatEnum.Date
|
|
343
|
+
},
|
|
344
|
+
NUMBER_TIME: {
|
|
345
|
+
type: import_echo_schema.TypeEnum.String,
|
|
346
|
+
format: import_echo_schema.FormatEnum.Time
|
|
347
|
+
}
|
|
675
348
|
};
|
|
676
349
|
var getTopLeft = (range) => {
|
|
677
350
|
const to = range.to ?? range.from;
|
|
@@ -720,14 +393,19 @@ var SheetModel = class extends import_context.Resource {
|
|
|
720
393
|
(0, import_log.log)("initialize", {
|
|
721
394
|
id: this.id
|
|
722
395
|
}, {
|
|
723
|
-
F:
|
|
724
|
-
L:
|
|
396
|
+
F: __dxlog_file,
|
|
397
|
+
L: 113,
|
|
725
398
|
S: this,
|
|
726
399
|
C: (f, a) => f(...a)
|
|
727
400
|
});
|
|
728
|
-
initialize(this._sheet);
|
|
729
|
-
this.
|
|
730
|
-
|
|
401
|
+
(0, import_chunk_O7XR4R7Y.initialize)(this._sheet);
|
|
402
|
+
this._graph.update.on((event) => {
|
|
403
|
+
if (event.type === "functionsUpdated") {
|
|
404
|
+
this.reset();
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
this._node = this._graph.getOrCreateNode((0, import_chunk_O7XR4R7Y.createSheetName)({
|
|
408
|
+
type: (0, import_echo_schema.getTypename)(this._sheet),
|
|
731
409
|
id: this._sheet.id
|
|
732
410
|
}));
|
|
733
411
|
await this._node.open();
|
|
@@ -742,8 +420,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
742
420
|
*/
|
|
743
421
|
reset() {
|
|
744
422
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
745
|
-
F:
|
|
746
|
-
L:
|
|
423
|
+
F: __dxlog_file,
|
|
424
|
+
L: 139,
|
|
747
425
|
S: this,
|
|
748
426
|
A: [
|
|
749
427
|
"this._node",
|
|
@@ -753,17 +431,22 @@ var SheetModel = class extends import_context.Resource {
|
|
|
753
431
|
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
754
432
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
755
433
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
756
|
-
F:
|
|
757
|
-
L:
|
|
434
|
+
F: __dxlog_file,
|
|
435
|
+
L: 142,
|
|
758
436
|
S: this,
|
|
759
437
|
A: [
|
|
760
438
|
"this._node",
|
|
761
439
|
""
|
|
762
440
|
]
|
|
763
441
|
});
|
|
764
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
765
|
-
if (
|
|
766
|
-
|
|
442
|
+
const { col, row } = (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, key);
|
|
443
|
+
if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
|
|
444
|
+
const binding = this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
445
|
+
if (binding) {
|
|
446
|
+
value = this._graph.mapFormulaToNative(binding);
|
|
447
|
+
} else {
|
|
448
|
+
value = "";
|
|
449
|
+
}
|
|
767
450
|
}
|
|
768
451
|
this._node.graph.hf.setCellContents({
|
|
769
452
|
sheet: this._node.sheetId,
|
|
@@ -783,11 +466,79 @@ var SheetModel = class extends import_context.Resource {
|
|
|
783
466
|
this._node?.graph.hf.rebuildAndRecalculate();
|
|
784
467
|
}
|
|
785
468
|
insertRows(i, n = 1) {
|
|
786
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
469
|
+
const idx = (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.rows, i, n, import_chunk_O7XR4R7Y.MAX_ROWS);
|
|
787
470
|
this.reset();
|
|
471
|
+
return idx;
|
|
788
472
|
}
|
|
789
473
|
insertColumns(i, n = 1) {
|
|
790
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
474
|
+
const idx = (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.columns, i, n, import_chunk_O7XR4R7Y.MAX_COLUMNS);
|
|
475
|
+
this.reset();
|
|
476
|
+
return idx;
|
|
477
|
+
}
|
|
478
|
+
dropRow(rowIndex) {
|
|
479
|
+
const range = {
|
|
480
|
+
from: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
|
|
481
|
+
to: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
|
|
482
|
+
};
|
|
483
|
+
const values = this.getCellValues(range).flat();
|
|
484
|
+
const index = this._sheet.rows.indexOf(rowIndex);
|
|
485
|
+
this.clear(range);
|
|
486
|
+
this._sheet.rows.splice(index, 1);
|
|
487
|
+
delete this._sheet.rowMeta[rowIndex];
|
|
488
|
+
this.reset();
|
|
489
|
+
return {
|
|
490
|
+
axis: "row",
|
|
491
|
+
index,
|
|
492
|
+
axisIndex: rowIndex,
|
|
493
|
+
axisMeta: this._sheet.rowMeta[rowIndex],
|
|
494
|
+
values
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
dropColumn(colIndex) {
|
|
498
|
+
const range = {
|
|
499
|
+
from: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
|
|
500
|
+
to: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
|
|
501
|
+
};
|
|
502
|
+
const values = this.getCellValues(range).flat();
|
|
503
|
+
const index = this._sheet.columns.indexOf(colIndex);
|
|
504
|
+
this.clear(range);
|
|
505
|
+
this._sheet.columns.splice(index, 1);
|
|
506
|
+
delete this._sheet.columnMeta[colIndex];
|
|
507
|
+
this.reset();
|
|
508
|
+
return {
|
|
509
|
+
axis: "col",
|
|
510
|
+
index,
|
|
511
|
+
axisIndex: colIndex,
|
|
512
|
+
axisMeta: this._sheet.rowMeta[colIndex],
|
|
513
|
+
values
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
restoreRow({ index, axisIndex, axisMeta, values }) {
|
|
517
|
+
this._sheet.rows.splice(index, 0, axisIndex);
|
|
518
|
+
values.forEach((value, col) => {
|
|
519
|
+
if (value) {
|
|
520
|
+
this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
|
|
521
|
+
value
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
if (axisMeta) {
|
|
526
|
+
this._sheet.rowMeta[axisIndex] = axisMeta;
|
|
527
|
+
}
|
|
528
|
+
this.reset();
|
|
529
|
+
}
|
|
530
|
+
restoreColumn({ index, axisIndex, axisMeta, values }) {
|
|
531
|
+
this._sheet.columns.splice(index, 0, axisIndex);
|
|
532
|
+
values.forEach((value, row) => {
|
|
533
|
+
if (value) {
|
|
534
|
+
this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
|
|
535
|
+
value
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
if (axisMeta) {
|
|
540
|
+
this._sheet.columnMeta[axisIndex] = axisMeta;
|
|
541
|
+
}
|
|
791
542
|
this.reset();
|
|
792
543
|
}
|
|
793
544
|
//
|
|
@@ -799,8 +550,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
799
550
|
*/
|
|
800
551
|
clear(range) {
|
|
801
552
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
802
|
-
F:
|
|
803
|
-
L:
|
|
553
|
+
F: __dxlog_file,
|
|
554
|
+
L: 245,
|
|
804
555
|
S: this,
|
|
805
556
|
A: [
|
|
806
557
|
"this._node",
|
|
@@ -811,14 +562,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
811
562
|
const values = this._iterRange(range, () => null);
|
|
812
563
|
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
813
564
|
this._iterRange(range, (cell) => {
|
|
814
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
565
|
+
const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
|
|
815
566
|
delete this._sheet.cells[idx];
|
|
816
567
|
});
|
|
817
568
|
}
|
|
818
569
|
cut(range) {
|
|
819
570
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
820
|
-
F:
|
|
821
|
-
L:
|
|
571
|
+
F: __dxlog_file,
|
|
572
|
+
L: 256,
|
|
822
573
|
S: this,
|
|
823
574
|
A: [
|
|
824
575
|
"this._node",
|
|
@@ -827,14 +578,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
827
578
|
});
|
|
828
579
|
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
829
580
|
this._iterRange(range, (cell) => {
|
|
830
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
581
|
+
const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
|
|
831
582
|
delete this._sheet.cells[idx];
|
|
832
583
|
});
|
|
833
584
|
}
|
|
834
585
|
copy(range) {
|
|
835
586
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
836
|
-
F:
|
|
837
|
-
L:
|
|
587
|
+
F: __dxlog_file,
|
|
588
|
+
L: 265,
|
|
838
589
|
S: this,
|
|
839
590
|
A: [
|
|
840
591
|
"this._node",
|
|
@@ -845,8 +596,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
845
596
|
}
|
|
846
597
|
paste(cell) {
|
|
847
598
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
848
|
-
F:
|
|
849
|
-
L:
|
|
599
|
+
F: __dxlog_file,
|
|
600
|
+
L: 270,
|
|
850
601
|
S: this,
|
|
851
602
|
A: [
|
|
852
603
|
"this._node",
|
|
@@ -858,7 +609,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
858
609
|
for (const change of changes) {
|
|
859
610
|
if (change instanceof import_hyperformula.ExportedCellChange) {
|
|
860
611
|
const { address, newValue } = change;
|
|
861
|
-
const idx = addressToIndex(this._sheet, {
|
|
612
|
+
const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, {
|
|
862
613
|
row: address.row,
|
|
863
614
|
col: address.col
|
|
864
615
|
});
|
|
@@ -872,8 +623,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
872
623
|
// TODO(burdon): Display undo/redo state.
|
|
873
624
|
undo() {
|
|
874
625
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
875
|
-
F:
|
|
876
|
-
L:
|
|
626
|
+
F: __dxlog_file,
|
|
627
|
+
L: 285,
|
|
877
628
|
S: this,
|
|
878
629
|
A: [
|
|
879
630
|
"this._node",
|
|
@@ -886,8 +637,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
886
637
|
}
|
|
887
638
|
redo() {
|
|
888
639
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
889
|
-
F:
|
|
890
|
-
L:
|
|
640
|
+
F: __dxlog_file,
|
|
641
|
+
L: 293,
|
|
891
642
|
S: this,
|
|
892
643
|
A: [
|
|
893
644
|
"this._node",
|
|
@@ -902,7 +653,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
902
653
|
* Get value from sheet.
|
|
903
654
|
*/
|
|
904
655
|
getCellValue(cell) {
|
|
905
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
656
|
+
const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
|
|
906
657
|
return this._sheet.cells[idx]?.value ?? null;
|
|
907
658
|
}
|
|
908
659
|
/**
|
|
@@ -913,7 +664,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
913
664
|
if (value == null) {
|
|
914
665
|
return void 0;
|
|
915
666
|
}
|
|
916
|
-
if (
|
|
667
|
+
if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
|
|
917
668
|
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
918
669
|
} else {
|
|
919
670
|
return String(value);
|
|
@@ -930,16 +681,26 @@ var SheetModel = class extends import_context.Resource {
|
|
|
930
681
|
*/
|
|
931
682
|
getValue(cell) {
|
|
932
683
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
933
|
-
F:
|
|
934
|
-
L:
|
|
684
|
+
F: __dxlog_file,
|
|
685
|
+
L: 336,
|
|
935
686
|
S: this,
|
|
936
687
|
A: [
|
|
937
688
|
"this._node",
|
|
938
689
|
""
|
|
939
690
|
]
|
|
940
691
|
});
|
|
941
|
-
const
|
|
692
|
+
const address = toSimpleCellAddress(this._node.sheetId, cell);
|
|
693
|
+
const value = this._node.graph.hf.getCellValue(address);
|
|
942
694
|
if (value instanceof import_hyperformula.DetailedCellError) {
|
|
695
|
+
import_log.log.info("cell error", {
|
|
696
|
+
cell,
|
|
697
|
+
error: value
|
|
698
|
+
}, {
|
|
699
|
+
F: __dxlog_file,
|
|
700
|
+
L: 341,
|
|
701
|
+
S: this,
|
|
702
|
+
C: (f, a) => f(...a)
|
|
703
|
+
});
|
|
943
704
|
return value.toString();
|
|
944
705
|
}
|
|
945
706
|
return value;
|
|
@@ -947,10 +708,10 @@ var SheetModel = class extends import_context.Resource {
|
|
|
947
708
|
/**
|
|
948
709
|
* Get value type.
|
|
949
710
|
*/
|
|
950
|
-
|
|
711
|
+
getValueDescription(cell) {
|
|
951
712
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
952
|
-
F:
|
|
953
|
-
L:
|
|
713
|
+
F: __dxlog_file,
|
|
714
|
+
L: 352,
|
|
954
715
|
S: this,
|
|
955
716
|
A: [
|
|
956
717
|
"this._node",
|
|
@@ -966,8 +727,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
966
727
|
*/
|
|
967
728
|
setValue(cell, value) {
|
|
968
729
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
969
|
-
F:
|
|
970
|
-
L:
|
|
730
|
+
F: __dxlog_file,
|
|
731
|
+
L: 362,
|
|
971
732
|
S: this,
|
|
972
733
|
A: [
|
|
973
734
|
"this._node",
|
|
@@ -975,15 +736,15 @@ var SheetModel = class extends import_context.Resource {
|
|
|
975
736
|
]
|
|
976
737
|
});
|
|
977
738
|
if (this._options.readonly) {
|
|
978
|
-
throw new ReadonlyException();
|
|
739
|
+
throw new import_chunk_O7XR4R7Y.ReadonlyException();
|
|
979
740
|
}
|
|
980
741
|
let refresh = false;
|
|
981
742
|
if (cell.row >= this._sheet.rows.length) {
|
|
982
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
743
|
+
(0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_O7XR4R7Y.MAX_ROWS);
|
|
983
744
|
refresh = true;
|
|
984
745
|
}
|
|
985
746
|
if (cell.col >= this._sheet.columns.length) {
|
|
986
|
-
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
747
|
+
(0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_O7XR4R7Y.MAX_COLUMNS);
|
|
987
748
|
refresh = true;
|
|
988
749
|
}
|
|
989
750
|
if (refresh) {
|
|
@@ -995,14 +756,14 @@ var SheetModel = class extends import_context.Resource {
|
|
|
995
756
|
col: cell.col
|
|
996
757
|
}, [
|
|
997
758
|
[
|
|
998
|
-
|
|
759
|
+
(0, import_chunk_O7XR4R7Y.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
|
|
999
760
|
]
|
|
1000
761
|
]);
|
|
1001
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
762
|
+
const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
|
|
1002
763
|
if (value === void 0 || value === null) {
|
|
1003
764
|
delete this._sheet.cells[idx];
|
|
1004
765
|
} else {
|
|
1005
|
-
if (
|
|
766
|
+
if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
|
|
1006
767
|
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1007
768
|
}
|
|
1008
769
|
this._sheet.cells[idx] = {
|
|
@@ -1015,7 +776,7 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1015
776
|
*/
|
|
1016
777
|
setValues(values) {
|
|
1017
778
|
Object.entries(values).forEach(([key, { value }]) => {
|
|
1018
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
779
|
+
this.setValue((0, import_chunk_O7XR4R7Y.addressFromA1Notation)(key), value);
|
|
1019
780
|
});
|
|
1020
781
|
}
|
|
1021
782
|
/**
|
|
@@ -1062,34 +823,34 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1062
823
|
* Map from A1 notation to indices.
|
|
1063
824
|
*/
|
|
1064
825
|
mapFormulaRefsToIndices(formula) {
|
|
1065
|
-
(0, import_invariant3.invariant)(
|
|
1066
|
-
F:
|
|
1067
|
-
L:
|
|
826
|
+
(0, import_invariant3.invariant)((0, import_chunk_O7XR4R7Y.isFormula)(formula), void 0, {
|
|
827
|
+
F: __dxlog_file,
|
|
828
|
+
L: 451,
|
|
1068
829
|
S: this,
|
|
1069
830
|
A: [
|
|
1070
|
-
"formula
|
|
831
|
+
"isFormula(formula)",
|
|
1071
832
|
""
|
|
1072
833
|
]
|
|
1073
834
|
});
|
|
1074
835
|
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1075
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
836
|
+
return (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, (0, import_chunk_O7XR4R7Y.addressFromA1Notation)(match));
|
|
1076
837
|
});
|
|
1077
838
|
}
|
|
1078
839
|
/**
|
|
1079
840
|
* Map from indices to A1 notation.
|
|
1080
841
|
*/
|
|
1081
842
|
mapFormulaIndicesToRefs(formula) {
|
|
1082
|
-
(0, import_invariant3.invariant)(
|
|
1083
|
-
F:
|
|
1084
|
-
L:
|
|
843
|
+
(0, import_invariant3.invariant)((0, import_chunk_O7XR4R7Y.isFormula)(formula), void 0, {
|
|
844
|
+
F: __dxlog_file,
|
|
845
|
+
L: 461,
|
|
1085
846
|
S: this,
|
|
1086
847
|
A: [
|
|
1087
|
-
"formula
|
|
848
|
+
"isFormula(formula)",
|
|
1088
849
|
""
|
|
1089
850
|
]
|
|
1090
851
|
});
|
|
1091
852
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1092
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
853
|
+
return (0, import_chunk_O7XR4R7Y.addressToA1Notation)((0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, idx));
|
|
1093
854
|
});
|
|
1094
855
|
}
|
|
1095
856
|
//
|
|
@@ -1106,8 +867,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1106
867
|
}
|
|
1107
868
|
toDateTime(num) {
|
|
1108
869
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1109
|
-
F:
|
|
1110
|
-
L:
|
|
870
|
+
F: __dxlog_file,
|
|
871
|
+
L: 482,
|
|
1111
872
|
S: this,
|
|
1112
873
|
A: [
|
|
1113
874
|
"this._node",
|
|
@@ -1118,8 +879,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1118
879
|
}
|
|
1119
880
|
toDate(num) {
|
|
1120
881
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1121
|
-
F:
|
|
1122
|
-
L:
|
|
882
|
+
F: __dxlog_file,
|
|
883
|
+
L: 487,
|
|
1123
884
|
S: this,
|
|
1124
885
|
A: [
|
|
1125
886
|
"this._node",
|
|
@@ -1130,8 +891,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1130
891
|
}
|
|
1131
892
|
toTime(num) {
|
|
1132
893
|
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1133
|
-
F:
|
|
1134
|
-
L:
|
|
894
|
+
F: __dxlog_file,
|
|
895
|
+
L: 492,
|
|
1135
896
|
S: this,
|
|
1136
897
|
A: [
|
|
1137
898
|
"this._node",
|
|
@@ -1142,8 +903,8 @@ var SheetModel = class extends import_context.Resource {
|
|
|
1142
903
|
}
|
|
1143
904
|
};
|
|
1144
905
|
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1145
|
-
const [model, setModel] = (0,
|
|
1146
|
-
(0,
|
|
906
|
+
const [model, setModel] = (0, import_react3.useState)();
|
|
907
|
+
(0, import_react3.useEffect)(() => {
|
|
1147
908
|
if (!graph || !sheet) {
|
|
1148
909
|
return;
|
|
1149
910
|
}
|
|
@@ -1164,169 +925,369 @@ var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
|
1164
925
|
sheet,
|
|
1165
926
|
readonly
|
|
1166
927
|
]);
|
|
1167
|
-
return model;
|
|
928
|
+
return model;
|
|
929
|
+
};
|
|
930
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
|
|
931
|
+
var SheetContext = /* @__PURE__ */ (0, import_react2.createContext)(void 0);
|
|
932
|
+
var useSheetContext = () => {
|
|
933
|
+
const context = (0, import_react2.useContext)(SheetContext);
|
|
934
|
+
(0, import_invariant2.invariant)(context, void 0, {
|
|
935
|
+
F: __dxlog_file2,
|
|
936
|
+
L: 52,
|
|
937
|
+
S: void 0,
|
|
938
|
+
A: [
|
|
939
|
+
"context",
|
|
940
|
+
""
|
|
941
|
+
]
|
|
942
|
+
});
|
|
943
|
+
return context;
|
|
944
|
+
};
|
|
945
|
+
var SheetProviderImpl = ({ model, onInfo, children, __gridScope }) => {
|
|
946
|
+
const { id, editing, setEditing } = (0, import_react_ui_grid.useGridContext)("SheetProvider", __gridScope);
|
|
947
|
+
const [cursor, setCursorInternal] = (0, import_react2.useState)();
|
|
948
|
+
const [range, setRangeInternal] = (0, import_react2.useState)();
|
|
949
|
+
const [cursorFallbackRange, setCursorFallbackRange] = (0, import_react2.useState)();
|
|
950
|
+
const [activeRefs, setActiveRefs] = (0, import_react2.useState)("");
|
|
951
|
+
const setCursor = (0, import_react2.useCallback)((nextCursor) => {
|
|
952
|
+
setCursorInternal(nextCursor);
|
|
953
|
+
setCursorFallbackRange(range?.to ? range : nextCursor ? {
|
|
954
|
+
from: nextCursor,
|
|
955
|
+
to: nextCursor
|
|
956
|
+
} : void 0);
|
|
957
|
+
}, [
|
|
958
|
+
range
|
|
959
|
+
]);
|
|
960
|
+
const setRange = (0, import_react2.useCallback)((nextRange) => {
|
|
961
|
+
setRangeInternal(nextRange);
|
|
962
|
+
setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
|
|
963
|
+
from: cursor,
|
|
964
|
+
to: cursor
|
|
965
|
+
} : void 0);
|
|
966
|
+
}, [
|
|
967
|
+
cursor
|
|
968
|
+
]);
|
|
969
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContext.Provider, {
|
|
970
|
+
value: {
|
|
971
|
+
id,
|
|
972
|
+
model,
|
|
973
|
+
editing,
|
|
974
|
+
setEditing,
|
|
975
|
+
cursor,
|
|
976
|
+
setCursor,
|
|
977
|
+
range,
|
|
978
|
+
setRange,
|
|
979
|
+
cursorFallbackRange,
|
|
980
|
+
activeRefs,
|
|
981
|
+
setActiveRefs,
|
|
982
|
+
// TODO(burdon): Change to event.
|
|
983
|
+
onInfo
|
|
984
|
+
}
|
|
985
|
+
}, children);
|
|
986
|
+
};
|
|
987
|
+
var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
988
|
+
const model = useSheetModel(graph, sheet, {
|
|
989
|
+
readonly
|
|
990
|
+
});
|
|
991
|
+
return !model ? null : /* @__PURE__ */ import_react2.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
992
|
+
id: (0, import_echo.fullyQualifiedId)(sheet)
|
|
993
|
+
}, /* @__PURE__ */ import_react2.default.createElement(SheetProviderImpl, {
|
|
994
|
+
model,
|
|
995
|
+
onInfo
|
|
996
|
+
}, children));
|
|
997
|
+
};
|
|
998
|
+
var RangeList = ({ sheet }) => {
|
|
999
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
|
|
1000
|
+
const handleSelectRange = (range) => {
|
|
1001
|
+
};
|
|
1002
|
+
const handleDeleteRange = (0, import_react8.useCallback)((range) => {
|
|
1003
|
+
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
1004
|
+
sheet.ranges.splice(index, 1);
|
|
1005
|
+
}, [
|
|
1006
|
+
sheet
|
|
1007
|
+
]);
|
|
1008
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("h2", {
|
|
1009
|
+
className: "p-2 text-sm font-semibold"
|
|
1010
|
+
}, t("range list heading")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
|
|
1011
|
+
items: sheet.ranges,
|
|
1012
|
+
isItem: import_echo_schema2.S.is(import_chunk_AWKOWDMI.Range)
|
|
1013
|
+
}, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
|
|
1014
|
+
key: i,
|
|
1015
|
+
item: range,
|
|
1016
|
+
classNames: [
|
|
1017
|
+
"p-2",
|
|
1018
|
+
import_react_ui_theme3.ghostHover
|
|
1019
|
+
]
|
|
1020
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
|
|
1021
|
+
onClick: () => handleSelectRange(range)
|
|
1022
|
+
}, t("range title", {
|
|
1023
|
+
position: (0, import_chunk_O7XR4R7Y.rangeToA1Notation)((0, import_chunk_O7XR4R7Y.rangeFromIndex)(sheet, range.range)),
|
|
1024
|
+
key: t(`range key ${range.key} label`),
|
|
1025
|
+
value: t(`range value ${range.value} label`)
|
|
1026
|
+
})), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
|
|
1027
|
+
onClick: () => handleDeleteRange(range)
|
|
1028
|
+
})))));
|
|
1168
1029
|
};
|
|
1169
|
-
var
|
|
1170
|
-
|
|
1030
|
+
var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-PJE74VO4.cjs"));
|
|
1031
|
+
var completeCellRangeToThreadCursor = (range) => {
|
|
1032
|
+
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
1033
|
+
};
|
|
1034
|
+
var parseThreadAnchorAsCellRange = (cursor) => {
|
|
1035
|
+
const coords = cursor.split(",");
|
|
1036
|
+
if (coords.length !== 4) {
|
|
1037
|
+
return null;
|
|
1038
|
+
} else {
|
|
1039
|
+
const [fromCol, fromRow, toCol, toRow] = coords;
|
|
1040
|
+
return {
|
|
1041
|
+
from: {
|
|
1042
|
+
col: parseInt(fromCol),
|
|
1043
|
+
row: parseInt(fromRow)
|
|
1044
|
+
},
|
|
1045
|
+
to: {
|
|
1046
|
+
col: parseInt(toCol),
|
|
1047
|
+
row: parseInt(toRow)
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
1053
|
+
const { model, setActiveRefs } = useSheetContext();
|
|
1054
|
+
const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
|
|
1171
1055
|
switch (action) {
|
|
1172
|
-
case
|
|
1173
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== (0,
|
|
1056
|
+
case import_app_framework2.LayoutAction.SCROLL_INTO_VIEW: {
|
|
1057
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
|
|
1174
1058
|
return;
|
|
1175
1059
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1060
|
+
setActiveRefs(data.thread);
|
|
1061
|
+
const range = parseThreadAnchorAsCellRange(data.cursor);
|
|
1062
|
+
range && grid?.setFocus({
|
|
1063
|
+
...range.to,
|
|
1179
1064
|
plane: "grid"
|
|
1180
1065
|
}, true);
|
|
1181
1066
|
}
|
|
1182
1067
|
}
|
|
1183
1068
|
}, [
|
|
1184
|
-
model.sheet
|
|
1069
|
+
model.sheet,
|
|
1070
|
+
setActiveRefs
|
|
1185
1071
|
]);
|
|
1186
|
-
(0,
|
|
1072
|
+
(0, import_app_framework2.useIntentResolver)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN, handleScrollIntoView);
|
|
1187
1073
|
};
|
|
1188
|
-
var useSelectThreadOnCellFocus = (
|
|
1189
|
-
const
|
|
1190
|
-
const
|
|
1074
|
+
var useSelectThreadOnCellFocus = () => {
|
|
1075
|
+
const { model, cursor } = useSheetContext();
|
|
1076
|
+
const dispatch = (0, import_app_framework2.useIntentDispatcher)();
|
|
1077
|
+
const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
|
|
1191
1078
|
// TODO(thure): Surely we can find a better dependency for this…
|
|
1192
1079
|
JSON.stringify(model.sheet.threads)
|
|
1193
1080
|
]);
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
model.sheet
|
|
1197
|
-
]);
|
|
1198
|
-
const selectClosestThread = (0, import_react7.useCallback)((cellAddress) => {
|
|
1199
|
-
if (!cellAddress || !activeThreads) {
|
|
1081
|
+
const selectClosestThread = (0, import_react6.useCallback)((cellAddress) => {
|
|
1082
|
+
if (!cellAddress || !threads) {
|
|
1200
1083
|
return;
|
|
1201
1084
|
}
|
|
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
|
-
]);
|
|
1085
|
+
const closestThread = threads?.find(({ anchor }) => {
|
|
1086
|
+
if (anchor) {
|
|
1087
|
+
const range = parseThreadAnchorAsCellRange(anchor);
|
|
1088
|
+
return range ? (0, import_chunk_O7XR4R7Y.inRange)(range, cellAddress) : false;
|
|
1089
|
+
} else {
|
|
1090
|
+
return false;
|
|
1214
1091
|
}
|
|
1092
|
+
});
|
|
1093
|
+
if (closestThread) {
|
|
1094
|
+
void dispatch([
|
|
1095
|
+
{
|
|
1096
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
1097
|
+
data: {
|
|
1098
|
+
current: (0, import_echo3.fullyQualifiedId)(closestThread)
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
]);
|
|
1215
1102
|
}
|
|
1216
1103
|
}, [
|
|
1217
1104
|
dispatch,
|
|
1218
|
-
|
|
1219
|
-
activeThreadAddresses,
|
|
1220
|
-
model.sheet
|
|
1105
|
+
threads
|
|
1221
1106
|
]);
|
|
1222
|
-
const debounced = (0,
|
|
1107
|
+
const debounced = (0, import_react6.useMemo)(() => {
|
|
1223
1108
|
return (0, import_async3.debounce)((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
1224
1109
|
}, [
|
|
1225
1110
|
selectClosestThread
|
|
1226
1111
|
]);
|
|
1227
|
-
(0,
|
|
1112
|
+
(0, import_react6.useEffect)(() => {
|
|
1228
1113
|
if (!cursor) {
|
|
1229
1114
|
return;
|
|
1230
1115
|
}
|
|
1231
1116
|
debounced(cursor);
|
|
1232
1117
|
}, [
|
|
1233
1118
|
cursor,
|
|
1234
|
-
|
|
1119
|
+
debounced
|
|
1235
1120
|
]);
|
|
1236
1121
|
};
|
|
1237
|
-
var
|
|
1122
|
+
var dxGridCellIndexToSheetCellAddress = (index) => {
|
|
1123
|
+
const [colStr, rowStr] = index.split(",");
|
|
1238
1124
|
return {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
"bg-greenFill"
|
|
1242
|
-
],
|
|
1243
|
-
cellIndex
|
|
1125
|
+
col: parseInt(colStr),
|
|
1126
|
+
row: parseInt(rowStr)
|
|
1244
1127
|
};
|
|
1245
1128
|
};
|
|
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();
|
|
1129
|
+
var createDxGridColumns = (model) => {
|
|
1130
|
+
return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
|
|
1131
|
+
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
1132
|
+
acc.grid[numericIndex] = {
|
|
1133
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
1134
|
+
resizeable: true
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
return acc;
|
|
1138
|
+
}, {
|
|
1139
|
+
grid: {}
|
|
1280
1140
|
});
|
|
1281
1141
|
};
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
]
|
|
1142
|
+
var createDxGridRows = (model) => {
|
|
1143
|
+
return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
|
|
1144
|
+
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
1145
|
+
acc.grid[numericIndex] = {
|
|
1146
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
1147
|
+
resizeable: true
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
return acc;
|
|
1151
|
+
}, {
|
|
1152
|
+
grid: {}
|
|
1294
1153
|
});
|
|
1295
|
-
return context;
|
|
1296
1154
|
};
|
|
1297
|
-
var
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1155
|
+
var projectCellProps = (model, col, row) => {
|
|
1156
|
+
const address = {
|
|
1157
|
+
col,
|
|
1158
|
+
row
|
|
1159
|
+
};
|
|
1160
|
+
const rawValue = model.getValue(address);
|
|
1161
|
+
const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_O7XR4R7Y.inRange)((0, import_chunk_O7XR4R7Y.rangeFromIndex)(model.sheet, range), address));
|
|
1162
|
+
const threadRefs = model.sheet.threads?.filter((thread) => {
|
|
1163
|
+
const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
|
|
1164
|
+
return thread && range ? (0, import_chunk_O7XR4R7Y.inRange)(range, address) : false;
|
|
1165
|
+
}).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
|
|
1166
|
+
const description = model.getValueDescription(address);
|
|
1167
|
+
const type = description?.type;
|
|
1168
|
+
const format = description?.format;
|
|
1169
|
+
const classNames = ranges?.map(import_chunk_O7XR4R7Y.cellClassNameForRange).reverse();
|
|
1170
|
+
return {
|
|
1171
|
+
value: (0, import_react_ui_data.parseValue)({
|
|
1172
|
+
type,
|
|
1173
|
+
format,
|
|
1174
|
+
value: rawValue
|
|
1175
|
+
}),
|
|
1176
|
+
className: (0, import_react_ui_theme2.mx)((0, import_react_ui_data.cellClassesForFieldType)({
|
|
1177
|
+
type,
|
|
1178
|
+
format
|
|
1179
|
+
}), threadRefs && import_react_ui_grid3.commentedClassName, classNames),
|
|
1180
|
+
dataRefs: threadRefs
|
|
1181
|
+
};
|
|
1182
|
+
};
|
|
1183
|
+
var gridCellGetter = (model) => {
|
|
1184
|
+
const cachedGridCells = {};
|
|
1185
|
+
return (nextBounds) => {
|
|
1186
|
+
[
|
|
1187
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1188
|
+
].forEach((_, c0) => {
|
|
1189
|
+
return [
|
|
1190
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1191
|
+
].forEach((_2, r0) => {
|
|
1192
|
+
const col = nextBounds.start.col + c0;
|
|
1193
|
+
const row = nextBounds.start.row + r0;
|
|
1194
|
+
cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
|
|
1195
|
+
});
|
|
1196
|
+
});
|
|
1197
|
+
return cachedGridCells;
|
|
1198
|
+
};
|
|
1199
|
+
};
|
|
1200
|
+
var rowLabelCell = (row) => ({
|
|
1201
|
+
value: (0, import_react_ui_grid3.rowToA1Notation)(row),
|
|
1202
|
+
className: "text-end !pie-1",
|
|
1203
|
+
resizeHandle: "row"
|
|
1204
|
+
});
|
|
1205
|
+
var colLabelCell = (col) => ({
|
|
1206
|
+
value: (0, import_react_ui_grid3.colToA1Notation)(col),
|
|
1207
|
+
resizeHandle: "col"
|
|
1208
|
+
});
|
|
1209
|
+
var cellGetter = (model) => {
|
|
1210
|
+
const getGridCells = gridCellGetter(model);
|
|
1211
|
+
return (nextBounds, plane) => {
|
|
1212
|
+
switch (plane) {
|
|
1213
|
+
case "grid":
|
|
1214
|
+
return getGridCells(nextBounds);
|
|
1215
|
+
case "frozenColsStart":
|
|
1216
|
+
return [
|
|
1217
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1218
|
+
].reduce((acc, _, r0) => {
|
|
1219
|
+
const r = nextBounds.start.row + r0;
|
|
1220
|
+
acc[`0,${r}`] = rowLabelCell(r);
|
|
1221
|
+
return acc;
|
|
1222
|
+
}, {});
|
|
1223
|
+
case "frozenRowsStart":
|
|
1224
|
+
return [
|
|
1225
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1226
|
+
].reduce((acc, _, c0) => {
|
|
1227
|
+
const c = nextBounds.start.col + c0;
|
|
1228
|
+
acc[`${c},0`] = colLabelCell(c);
|
|
1229
|
+
return acc;
|
|
1230
|
+
}, {});
|
|
1231
|
+
default:
|
|
1232
|
+
return {};
|
|
1317
1233
|
}
|
|
1318
|
-
}
|
|
1234
|
+
};
|
|
1319
1235
|
};
|
|
1320
|
-
var
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1236
|
+
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1237
|
+
const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1238
|
+
const [rows, setRows] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1239
|
+
(0, import_react5.useEffect)(() => {
|
|
1240
|
+
const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1241
|
+
"cells"
|
|
1242
|
+
]);
|
|
1243
|
+
if (dxGrid) {
|
|
1244
|
+
dxGrid.getCells = cellGetter(model);
|
|
1245
|
+
}
|
|
1246
|
+
const handleCellsUpdate = () => {
|
|
1247
|
+
dxGrid?.requestUpdate("initialCells");
|
|
1248
|
+
};
|
|
1249
|
+
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1250
|
+
const unsubscribe = model.graph.update.on(handleCellsUpdate);
|
|
1251
|
+
return () => {
|
|
1252
|
+
cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1253
|
+
unsubscribe();
|
|
1254
|
+
};
|
|
1255
|
+
}, [
|
|
1327
1256
|
model,
|
|
1328
|
-
|
|
1329
|
-
|
|
1257
|
+
dxGrid
|
|
1258
|
+
]);
|
|
1259
|
+
(0, import_react5.useEffect)(() => {
|
|
1260
|
+
const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1261
|
+
"columnMeta"
|
|
1262
|
+
]);
|
|
1263
|
+
const rowMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1264
|
+
"rowMeta"
|
|
1265
|
+
]);
|
|
1266
|
+
const handleColumnMetaUpdate = () => {
|
|
1267
|
+
setColumns(createDxGridColumns(model));
|
|
1268
|
+
};
|
|
1269
|
+
const handleRowMetaUpdate = () => {
|
|
1270
|
+
setRows(createDxGridRows(model));
|
|
1271
|
+
};
|
|
1272
|
+
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1273
|
+
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1274
|
+
return () => {
|
|
1275
|
+
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1276
|
+
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1277
|
+
};
|
|
1278
|
+
}, [
|
|
1279
|
+
model,
|
|
1280
|
+
dxGrid
|
|
1281
|
+
]);
|
|
1282
|
+
return {
|
|
1283
|
+
columns,
|
|
1284
|
+
rows
|
|
1285
|
+
};
|
|
1286
|
+
};
|
|
1287
|
+
var inertPosition = {
|
|
1288
|
+
plane: "grid",
|
|
1289
|
+
col: 0,
|
|
1290
|
+
row: 0
|
|
1330
1291
|
};
|
|
1331
1292
|
var initialCells = {
|
|
1332
1293
|
grid: {},
|
|
@@ -1368,18 +1329,28 @@ var sheetColDefault = {
|
|
|
1368
1329
|
}
|
|
1369
1330
|
};
|
|
1370
1331
|
var GridSheet = () => {
|
|
1371
|
-
const {
|
|
1372
|
-
const
|
|
1373
|
-
const
|
|
1332
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
|
|
1333
|
+
const { id, model, editing, setEditing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
|
|
1334
|
+
const [dxGrid, setDxGrid] = (0, import_react4.useState)(null);
|
|
1335
|
+
const [extraplanarFocus, setExtraplanarFocus] = (0, import_react4.useState)(null);
|
|
1336
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1337
|
+
const rangeController = (0, import_react4.useRef)();
|
|
1374
1338
|
const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
|
|
1375
1339
|
const handleFocus = (0, import_react4.useCallback)((event) => {
|
|
1376
1340
|
if (!editing) {
|
|
1377
|
-
const cell = (0,
|
|
1378
|
-
if (cell
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1341
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1342
|
+
if (cell) {
|
|
1343
|
+
if (cell.plane === "grid") {
|
|
1344
|
+
setCursor({
|
|
1345
|
+
col: cell.col,
|
|
1346
|
+
row: cell.row
|
|
1347
|
+
});
|
|
1348
|
+
setExtraplanarFocus(null);
|
|
1349
|
+
} else {
|
|
1350
|
+
setExtraplanarFocus(cell);
|
|
1351
|
+
}
|
|
1352
|
+
} else {
|
|
1353
|
+
setExtraplanarFocus(null);
|
|
1383
1354
|
}
|
|
1384
1355
|
}
|
|
1385
1356
|
}, [
|
|
@@ -1403,11 +1374,20 @@ var GridSheet = () => {
|
|
|
1403
1374
|
"ArrowUp",
|
|
1404
1375
|
"ArrowLeft"
|
|
1405
1376
|
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1406
|
-
dxGrid
|
|
1377
|
+
dxGrid?.refocus(axis, delta);
|
|
1407
1378
|
}, [
|
|
1408
1379
|
model,
|
|
1409
1380
|
editing,
|
|
1410
|
-
|
|
1381
|
+
dxGrid
|
|
1382
|
+
]);
|
|
1383
|
+
const handleBlur = (0, import_react4.useCallback)((value) => {
|
|
1384
|
+
if (value !== void 0) {
|
|
1385
|
+
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1386
|
+
}
|
|
1387
|
+
setEditing(null);
|
|
1388
|
+
}, [
|
|
1389
|
+
model,
|
|
1390
|
+
editing
|
|
1411
1391
|
]);
|
|
1412
1392
|
const handleAxisResize = (0, import_react4.useCallback)(({ axis, size, index: numericIndex }) => {
|
|
1413
1393
|
if (axis === "row") {
|
|
@@ -1423,22 +1403,22 @@ var GridSheet = () => {
|
|
|
1423
1403
|
model
|
|
1424
1404
|
]);
|
|
1425
1405
|
const handleSelect = (0, import_react4.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1426
|
-
const
|
|
1406
|
+
const range = {
|
|
1427
1407
|
from: {
|
|
1428
1408
|
col: minCol,
|
|
1429
1409
|
row: minRow
|
|
1430
1410
|
}
|
|
1431
1411
|
};
|
|
1432
1412
|
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1433
|
-
|
|
1413
|
+
range.to = {
|
|
1434
1414
|
col: maxCol,
|
|
1435
1415
|
row: maxRow
|
|
1436
1416
|
};
|
|
1437
1417
|
}
|
|
1438
1418
|
if (editing) {
|
|
1439
|
-
|
|
1419
|
+
rangeController.current?.setRange((0, import_chunk_O7XR4R7Y.rangeToA1Notation)(range));
|
|
1440
1420
|
} else {
|
|
1441
|
-
setRange(
|
|
1421
|
+
setRange(range.to ? range : void 0);
|
|
1442
1422
|
}
|
|
1443
1423
|
}, [
|
|
1444
1424
|
editing
|
|
@@ -1450,16 +1430,63 @@ var GridSheet = () => {
|
|
|
1450
1430
|
}, [
|
|
1451
1431
|
hasAttention
|
|
1452
1432
|
]);
|
|
1433
|
+
const selectEntireAxis = (0, import_react4.useCallback)((pos) => {
|
|
1434
|
+
switch (pos.plane) {
|
|
1435
|
+
case "frozenRowsStart":
|
|
1436
|
+
return dxGrid?.setSelection({
|
|
1437
|
+
start: {
|
|
1438
|
+
col: pos.col,
|
|
1439
|
+
row: 0,
|
|
1440
|
+
plane: "grid"
|
|
1441
|
+
},
|
|
1442
|
+
end: {
|
|
1443
|
+
col: pos.col,
|
|
1444
|
+
row: model.sheet.rows.length - 1,
|
|
1445
|
+
plane: "grid"
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
case "frozenColsStart":
|
|
1449
|
+
return dxGrid?.setSelection({
|
|
1450
|
+
start: {
|
|
1451
|
+
row: pos.row,
|
|
1452
|
+
col: 0,
|
|
1453
|
+
plane: "grid"
|
|
1454
|
+
},
|
|
1455
|
+
end: {
|
|
1456
|
+
row: pos.row,
|
|
1457
|
+
col: model.sheet.columns.length - 1,
|
|
1458
|
+
plane: "grid"
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
}, [
|
|
1463
|
+
dxGrid,
|
|
1464
|
+
model.sheet
|
|
1465
|
+
]);
|
|
1466
|
+
const handleClick = (0, import_react4.useCallback)((event) => {
|
|
1467
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1468
|
+
if (cell) {
|
|
1469
|
+
selectEntireAxis(cell);
|
|
1470
|
+
}
|
|
1471
|
+
}, [
|
|
1472
|
+
selectEntireAxis
|
|
1473
|
+
]);
|
|
1453
1474
|
const handleKeyDown = (0, import_react4.useCallback)((event) => {
|
|
1454
|
-
const cursorFallbackRange = range ?? cursor ? {
|
|
1455
|
-
from: cursor,
|
|
1456
|
-
to: cursor
|
|
1457
|
-
} : null;
|
|
1458
1475
|
switch (event.key) {
|
|
1459
1476
|
case "Backspace":
|
|
1460
1477
|
case "Delete":
|
|
1461
1478
|
event.preventDefault();
|
|
1462
1479
|
return cursorFallbackRange && model.clear(cursorFallbackRange);
|
|
1480
|
+
case "Enter":
|
|
1481
|
+
case "Space":
|
|
1482
|
+
if (dxGrid && extraplanarFocus) {
|
|
1483
|
+
switch (extraplanarFocus.plane) {
|
|
1484
|
+
case "frozenRowsStart":
|
|
1485
|
+
case "frozenColsStart":
|
|
1486
|
+
event.preventDefault();
|
|
1487
|
+
return selectEntireAxis(extraplanarFocus);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1463
1490
|
}
|
|
1464
1491
|
if (event.metaKey || event.ctrlKey) {
|
|
1465
1492
|
switch (event.key) {
|
|
@@ -1485,13 +1512,55 @@ var GridSheet = () => {
|
|
|
1485
1512
|
}
|
|
1486
1513
|
}
|
|
1487
1514
|
}, [
|
|
1488
|
-
|
|
1515
|
+
cursorFallbackRange,
|
|
1489
1516
|
model,
|
|
1490
|
-
cursor
|
|
1517
|
+
cursor,
|
|
1518
|
+
extraplanarFocus,
|
|
1519
|
+
selectEntireAxis
|
|
1520
|
+
]);
|
|
1521
|
+
const contextMenuAnchorRef = (0, import_react4.useRef)(null);
|
|
1522
|
+
const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
|
|
1523
|
+
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1524
|
+
const handleContextMenu = (0, import_react4.useCallback)((event) => {
|
|
1525
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1526
|
+
if (cell && cell.plane.startsWith("frozen")) {
|
|
1527
|
+
event.preventDefault();
|
|
1528
|
+
contextMenuAnchorRef.current = event.target;
|
|
1529
|
+
setContextMenuOpen(cell);
|
|
1530
|
+
}
|
|
1531
|
+
}, []);
|
|
1532
|
+
const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
|
|
1533
|
+
switch (operation) {
|
|
1534
|
+
case "insert-before":
|
|
1535
|
+
case "insert-after":
|
|
1536
|
+
return dispatch({
|
|
1537
|
+
action: import_chunk_AWKOWDMI.SheetAction.INSERT_AXIS,
|
|
1538
|
+
data: {
|
|
1539
|
+
model,
|
|
1540
|
+
axis: contextMenuAxis,
|
|
1541
|
+
index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
break;
|
|
1545
|
+
case "drop":
|
|
1546
|
+
return dispatch({
|
|
1547
|
+
action: import_chunk_AWKOWDMI.SheetAction.DROP_AXIS,
|
|
1548
|
+
data: {
|
|
1549
|
+
model,
|
|
1550
|
+
axis: contextMenuAxis,
|
|
1551
|
+
axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
}, [
|
|
1556
|
+
contextMenuAxis,
|
|
1557
|
+
contextMenuOpen,
|
|
1558
|
+
model,
|
|
1559
|
+
dispatch
|
|
1491
1560
|
]);
|
|
1492
1561
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1493
1562
|
const extension = (0, import_react4.useMemo)(() => [
|
|
1494
|
-
(0,
|
|
1563
|
+
(0, import_react_ui_grid2.editorKeys)({
|
|
1495
1564
|
onClose: handleClose,
|
|
1496
1565
|
...editing?.initialContent && {
|
|
1497
1566
|
onNav: handleClose
|
|
@@ -1500,7 +1569,14 @@ var GridSheet = () => {
|
|
|
1500
1569
|
sheetExtension({
|
|
1501
1570
|
functions: model.graph.getFunctions()
|
|
1502
1571
|
}),
|
|
1503
|
-
rangeExtension(
|
|
1572
|
+
rangeExtension({
|
|
1573
|
+
onInit: (fn) => rangeController.current = fn,
|
|
1574
|
+
onStateChange: (state) => {
|
|
1575
|
+
if (dxGrid) {
|
|
1576
|
+
dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
})
|
|
1504
1580
|
], [
|
|
1505
1581
|
model,
|
|
1506
1582
|
handleClose,
|
|
@@ -1512,14 +1588,16 @@ var GridSheet = () => {
|
|
|
1512
1588
|
}, [
|
|
1513
1589
|
model
|
|
1514
1590
|
]);
|
|
1515
|
-
useUpdateFocusedCellOnThreadSelection(
|
|
1516
|
-
|
|
1591
|
+
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1592
|
+
useSelectThreadOnCellFocus();
|
|
1593
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.GridCellEditor, {
|
|
1517
1594
|
getCellContent,
|
|
1518
|
-
extension
|
|
1519
|
-
|
|
1595
|
+
extension,
|
|
1596
|
+
onBlur: handleBlur
|
|
1597
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
|
|
1520
1598
|
initialCells,
|
|
1521
|
-
limitColumns: DEFAULT_COLUMNS,
|
|
1522
|
-
limitRows: DEFAULT_ROWS,
|
|
1599
|
+
limitColumns: import_chunk_O7XR4R7Y.DEFAULT_COLUMNS,
|
|
1600
|
+
limitRows: import_chunk_O7XR4R7Y.DEFAULT_ROWS,
|
|
1523
1601
|
columns,
|
|
1524
1602
|
rows,
|
|
1525
1603
|
onAxisResize: handleAxisResize,
|
|
@@ -1530,40 +1608,49 @@ var GridSheet = () => {
|
|
|
1530
1608
|
onFocus: handleFocus,
|
|
1531
1609
|
onWheelCapture: handleWheel,
|
|
1532
1610
|
onKeyDown: handleKeyDown,
|
|
1611
|
+
onContextMenu: handleContextMenu,
|
|
1612
|
+
onClick: handleClick,
|
|
1533
1613
|
overscroll: "inline",
|
|
1534
1614
|
className: "[--dx-grid-base:var(--surface-bg)]",
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
},
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1615
|
+
activeRefs,
|
|
1616
|
+
ref: setDxGrid
|
|
1617
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
|
|
1618
|
+
modal: false,
|
|
1619
|
+
open: !!contextMenuOpen,
|
|
1620
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1621
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
|
|
1622
|
+
virtualRef: contextMenuAnchorRef
|
|
1623
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Content, {
|
|
1624
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1625
|
+
sideOffset: 4,
|
|
1626
|
+
collisionPadding: 8
|
|
1627
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1628
|
+
onClick: () => handleAxisMenuAction("insert-before")
|
|
1629
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1630
|
+
size: 5,
|
|
1631
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1632
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1633
|
+
onClick: () => handleAxisMenuAction("insert-after")
|
|
1634
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1635
|
+
size: 5,
|
|
1636
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1637
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1638
|
+
onClick: () => handleAxisMenuAction("drop")
|
|
1639
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1640
|
+
size: 5,
|
|
1641
|
+
icon: "ph--backspace--regular"
|
|
1642
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
|
|
1552
1643
|
};
|
|
1553
1644
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1554
1645
|
0 && (module.exports = {
|
|
1555
1646
|
ComputeGraphContextProvider,
|
|
1556
1647
|
GridSheet,
|
|
1648
|
+
RangeList,
|
|
1557
1649
|
SheetContainer,
|
|
1558
1650
|
SheetProvider,
|
|
1559
|
-
|
|
1560
|
-
addressToIndex,
|
|
1561
|
-
compareIndexPositions,
|
|
1651
|
+
completeCellRangeToThreadCursor,
|
|
1562
1652
|
computeGraphFacet,
|
|
1563
|
-
createSheet,
|
|
1564
|
-
inRange,
|
|
1565
|
-
rangeToA1Notation,
|
|
1566
1653
|
useComputeGraph,
|
|
1567
1654
|
useSheetContext
|
|
1568
1655
|
});
|
|
1569
|
-
//# sourceMappingURL=chunk-
|
|
1656
|
+
//# sourceMappingURL=chunk-STZ7S7RF.cjs.map
|