@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-staging.4b6f9cf
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-P3NF5KEI.mjs} +90 -88
- package/dist/lib/browser/SheetContainer-P3NF5KEI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-4LKIURJA.mjs} +917 -817
- package/dist/lib/browser/chunk-4LKIURJA.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-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-MPFKXY26.cjs} +88 -93
- package/dist/lib/node/SheetContainer-MPFKXY26.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-OO24XJBV.cjs} +853 -767
- package/dist/lib/node/chunk-OO24XJBV.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-22IOAW3B.mjs} +90 -88
- package/dist/lib/node-esm/SheetContainer-22IOAW3B.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-T3PRH7QS.mjs → chunk-BW36PM2Y.mjs} +917 -817
- package/dist/lib/node-esm/chunk-BW36PM2Y.mjs.map +7 -0
- 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/{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/FunctionEditor/FunctionEditor.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 +2 -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 +44 -50
- package/src/SheetPlugin.tsx +45 -12
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +6 -10
- package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
- package/src/components/GridSheet/GridSheet.tsx +196 -36
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +41 -21
- 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 +19 -12
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +98 -86
- 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_OO24XJBV_exports = {};
|
|
30
|
+
__export(chunk_OO24XJBV_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_OO24XJBV_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,299 +317,142 @@ var visitTree = (node, callback) => {
|
|
|
477
317
|
}
|
|
478
318
|
return false;
|
|
479
319
|
};
|
|
480
|
-
var
|
|
481
|
-
|
|
320
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
321
|
+
var typeMap = {
|
|
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
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var getTopLeft = (range) => {
|
|
350
|
+
const to = range.to ?? range.from;
|
|
482
351
|
return {
|
|
483
|
-
|
|
484
|
-
|
|
352
|
+
row: Math.min(range.from.row, to.row),
|
|
353
|
+
col: Math.min(range.from.col, to.col)
|
|
485
354
|
};
|
|
486
355
|
};
|
|
487
|
-
var
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
col,
|
|
516
|
-
row
|
|
517
|
-
};
|
|
518
|
-
const rawValue = model.getValue(address);
|
|
519
|
-
if (rawValue === void 0 || rawValue === null) {
|
|
356
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
357
|
+
sheet,
|
|
358
|
+
row: cell.row,
|
|
359
|
+
col: cell.col
|
|
360
|
+
});
|
|
361
|
+
var toModelRange = (sheet, range) => ({
|
|
362
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
363
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
364
|
+
});
|
|
365
|
+
var SheetModel = class extends import_context.Resource {
|
|
366
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
367
|
+
super();
|
|
368
|
+
this._graph = _graph;
|
|
369
|
+
this._sheet = _sheet;
|
|
370
|
+
this._options = _options;
|
|
371
|
+
this.id = `model-${import_keys.PublicKey.random().truncate()}`;
|
|
372
|
+
this.update = new import_async2.Event();
|
|
373
|
+
}
|
|
374
|
+
get graph() {
|
|
375
|
+
return this._graph;
|
|
376
|
+
}
|
|
377
|
+
get sheet() {
|
|
378
|
+
return this._sheet;
|
|
379
|
+
}
|
|
380
|
+
get readonly() {
|
|
381
|
+
return this._options.readonly;
|
|
382
|
+
}
|
|
383
|
+
get bounds() {
|
|
520
384
|
return {
|
|
521
|
-
|
|
385
|
+
rows: this._sheet.rows.length,
|
|
386
|
+
columns: this._sheet.columns.length
|
|
522
387
|
};
|
|
523
388
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
389
|
+
/**
|
|
390
|
+
* Initialize sheet and engine.
|
|
391
|
+
*/
|
|
392
|
+
async _open() {
|
|
393
|
+
(0, import_log.log)("initialize", {
|
|
394
|
+
id: this.id
|
|
395
|
+
}, {
|
|
396
|
+
F: __dxlog_file,
|
|
397
|
+
L: 113,
|
|
398
|
+
S: this,
|
|
399
|
+
C: (f, a) => f(...a)
|
|
400
|
+
});
|
|
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),
|
|
409
|
+
id: this._sheet.id
|
|
410
|
+
}));
|
|
411
|
+
await this._node.open();
|
|
412
|
+
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
413
|
+
this._ctx.onDispose(unsubscribe);
|
|
414
|
+
this.reset();
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Update engine.
|
|
418
|
+
* NOTE: This resets the undo history.
|
|
419
|
+
* @deprecated
|
|
420
|
+
*/
|
|
421
|
+
reset() {
|
|
422
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
423
|
+
F: __dxlog_file,
|
|
424
|
+
L: 139,
|
|
425
|
+
S: this,
|
|
426
|
+
A: [
|
|
427
|
+
"this._node",
|
|
428
|
+
""
|
|
429
|
+
]
|
|
430
|
+
});
|
|
431
|
+
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
432
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
433
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
434
|
+
F: __dxlog_file,
|
|
435
|
+
L: 142,
|
|
436
|
+
S: this,
|
|
437
|
+
A: [
|
|
438
|
+
"this._node",
|
|
439
|
+
""
|
|
440
|
+
]
|
|
544
441
|
});
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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";
|
|
667
|
-
var typeMap = {
|
|
668
|
-
BOOLEAN: import_schema.FieldValueType.Boolean,
|
|
669
|
-
NUMBER_RAW: import_schema.FieldValueType.Number,
|
|
670
|
-
NUMBER_PERCENT: import_schema.FieldValueType.Percent,
|
|
671
|
-
NUMBER_CURRENCY: import_schema.FieldValueType.Currency,
|
|
672
|
-
NUMBER_DATETIME: import_schema.FieldValueType.DateTime,
|
|
673
|
-
NUMBER_DATE: import_schema.FieldValueType.Date,
|
|
674
|
-
NUMBER_TIME: import_schema.FieldValueType.Time
|
|
675
|
-
};
|
|
676
|
-
var getTopLeft = (range) => {
|
|
677
|
-
const to = range.to ?? range.from;
|
|
678
|
-
return {
|
|
679
|
-
row: Math.min(range.from.row, to.row),
|
|
680
|
-
col: Math.min(range.from.col, to.col)
|
|
681
|
-
};
|
|
682
|
-
};
|
|
683
|
-
var toSimpleCellAddress = (sheet, cell) => ({
|
|
684
|
-
sheet,
|
|
685
|
-
row: cell.row,
|
|
686
|
-
col: cell.col
|
|
687
|
-
});
|
|
688
|
-
var toModelRange = (sheet, range) => ({
|
|
689
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
690
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
691
|
-
});
|
|
692
|
-
var SheetModel = class extends import_context.Resource {
|
|
693
|
-
constructor(_graph, _sheet, _options = {}) {
|
|
694
|
-
super();
|
|
695
|
-
this._graph = _graph;
|
|
696
|
-
this._sheet = _sheet;
|
|
697
|
-
this._options = _options;
|
|
698
|
-
this.id = `model-${import_keys.PublicKey.random().truncate()}`;
|
|
699
|
-
this.update = new import_async2.Event();
|
|
700
|
-
}
|
|
701
|
-
get graph() {
|
|
702
|
-
return this._graph;
|
|
703
|
-
}
|
|
704
|
-
get sheet() {
|
|
705
|
-
return this._sheet;
|
|
706
|
-
}
|
|
707
|
-
get readonly() {
|
|
708
|
-
return this._options.readonly;
|
|
709
|
-
}
|
|
710
|
-
get bounds() {
|
|
711
|
-
return {
|
|
712
|
-
rows: this._sheet.rows.length,
|
|
713
|
-
columns: this._sheet.columns.length
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Initialize sheet and engine.
|
|
718
|
-
*/
|
|
719
|
-
async _open() {
|
|
720
|
-
(0, import_log.log)("initialize", {
|
|
721
|
-
id: this.id
|
|
722
|
-
}, {
|
|
723
|
-
F: __dxlog_file2,
|
|
724
|
-
L: 106,
|
|
725
|
-
S: this,
|
|
726
|
-
C: (f, a) => f(...a)
|
|
727
|
-
});
|
|
728
|
-
initialize(this._sheet);
|
|
729
|
-
this._node = this._graph.getOrCreateNode((0, import_chunk_5XPK2V4A.createSheetName)({
|
|
730
|
-
type: (0, import_echo_schema3.getTypename)(this._sheet),
|
|
731
|
-
id: this._sheet.id
|
|
732
|
-
}));
|
|
733
|
-
await this._node.open();
|
|
734
|
-
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
735
|
-
this._ctx.onDispose(unsubscribe);
|
|
736
|
-
this.reset();
|
|
737
|
-
}
|
|
738
|
-
/**
|
|
739
|
-
* Update engine.
|
|
740
|
-
* NOTE: This resets the undo history.
|
|
741
|
-
* @deprecated
|
|
742
|
-
*/
|
|
743
|
-
reset() {
|
|
744
|
-
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
745
|
-
F: __dxlog_file2,
|
|
746
|
-
L: 126,
|
|
747
|
-
S: this,
|
|
748
|
-
A: [
|
|
749
|
-
"this._node",
|
|
750
|
-
""
|
|
751
|
-
]
|
|
752
|
-
});
|
|
753
|
-
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
754
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
755
|
-
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
756
|
-
F: __dxlog_file2,
|
|
757
|
-
L: 129,
|
|
758
|
-
S: this,
|
|
759
|
-
A: [
|
|
760
|
-
"this._node",
|
|
761
|
-
""
|
|
762
|
-
]
|
|
763
|
-
});
|
|
764
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
765
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
766
|
-
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
767
|
-
}
|
|
768
|
-
this._node.graph.hf.setCellContents({
|
|
769
|
-
sheet: this._node.sheetId,
|
|
770
|
-
row,
|
|
771
|
-
col
|
|
772
|
-
}, value);
|
|
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
|
+
}
|
|
450
|
+
}
|
|
451
|
+
this._node.graph.hf.setCellContents({
|
|
452
|
+
sheet: this._node.sheetId,
|
|
453
|
+
row,
|
|
454
|
+
col
|
|
455
|
+
}, value);
|
|
773
456
|
});
|
|
774
457
|
}
|
|
775
458
|
/**
|
|
@@ -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
|
}
|
|
@@ -1166,167 +927,368 @@ var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
|
1166
927
|
]);
|
|
1167
928
|
return model;
|
|
1168
929
|
};
|
|
1169
|
-
var
|
|
1170
|
-
|
|
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
|
+
})))));
|
|
1029
|
+
};
|
|
1030
|
+
var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-MPFKXY26.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 text-subdued",
|
|
1203
|
+
resizeHandle: "row"
|
|
1204
|
+
});
|
|
1205
|
+
var colLabelCell = (col) => ({
|
|
1206
|
+
value: (0, import_react_ui_grid3.colToA1Notation)(col),
|
|
1207
|
+
className: "text-subdued",
|
|
1208
|
+
resizeHandle: "col"
|
|
1209
|
+
});
|
|
1210
|
+
var cellGetter = (model) => {
|
|
1211
|
+
const getGridCells = gridCellGetter(model);
|
|
1212
|
+
return (nextBounds, plane) => {
|
|
1213
|
+
switch (plane) {
|
|
1214
|
+
case "grid":
|
|
1215
|
+
return getGridCells(nextBounds);
|
|
1216
|
+
case "frozenColsStart":
|
|
1217
|
+
return [
|
|
1218
|
+
...Array(nextBounds.end.row - nextBounds.start.row)
|
|
1219
|
+
].reduce((acc, _, r0) => {
|
|
1220
|
+
const r = nextBounds.start.row + r0;
|
|
1221
|
+
acc[`0,${r}`] = rowLabelCell(r);
|
|
1222
|
+
return acc;
|
|
1223
|
+
}, {});
|
|
1224
|
+
case "frozenRowsStart":
|
|
1225
|
+
return [
|
|
1226
|
+
...Array(nextBounds.end.col - nextBounds.start.col)
|
|
1227
|
+
].reduce((acc, _, c0) => {
|
|
1228
|
+
const c = nextBounds.start.col + c0;
|
|
1229
|
+
acc[`${c},0`] = colLabelCell(c);
|
|
1230
|
+
return acc;
|
|
1231
|
+
}, {});
|
|
1232
|
+
default:
|
|
1233
|
+
return {};
|
|
1317
1234
|
}
|
|
1318
|
-
}
|
|
1235
|
+
};
|
|
1319
1236
|
};
|
|
1320
|
-
var
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1237
|
+
var useSheetModelDxGridProps = (dxGrid, model) => {
|
|
1238
|
+
const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
|
|
1239
|
+
const [rows, setRows] = (0, import_react5.useState)(createDxGridRows(model));
|
|
1240
|
+
(0, import_react5.useEffect)(() => {
|
|
1241
|
+
const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1242
|
+
"cells"
|
|
1243
|
+
]);
|
|
1244
|
+
if (dxGrid) {
|
|
1245
|
+
dxGrid.getCells = cellGetter(model);
|
|
1246
|
+
}
|
|
1247
|
+
const handleCellsUpdate = () => {
|
|
1248
|
+
dxGrid?.requestUpdate("initialCells");
|
|
1249
|
+
};
|
|
1250
|
+
cellsAccessor.handle.addListener("change", handleCellsUpdate);
|
|
1251
|
+
const unsubscribe = model.graph.update.on(handleCellsUpdate);
|
|
1252
|
+
return () => {
|
|
1253
|
+
cellsAccessor.handle.removeListener("change", handleCellsUpdate);
|
|
1254
|
+
unsubscribe();
|
|
1255
|
+
};
|
|
1256
|
+
}, [
|
|
1327
1257
|
model,
|
|
1328
|
-
|
|
1329
|
-
|
|
1258
|
+
dxGrid
|
|
1259
|
+
]);
|
|
1260
|
+
(0, import_react5.useEffect)(() => {
|
|
1261
|
+
const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1262
|
+
"columnMeta"
|
|
1263
|
+
]);
|
|
1264
|
+
const rowMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
|
|
1265
|
+
"rowMeta"
|
|
1266
|
+
]);
|
|
1267
|
+
const handleColumnMetaUpdate = () => {
|
|
1268
|
+
setColumns(createDxGridColumns(model));
|
|
1269
|
+
};
|
|
1270
|
+
const handleRowMetaUpdate = () => {
|
|
1271
|
+
setRows(createDxGridRows(model));
|
|
1272
|
+
};
|
|
1273
|
+
columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
|
|
1274
|
+
rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
|
|
1275
|
+
return () => {
|
|
1276
|
+
columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
|
|
1277
|
+
rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
|
|
1278
|
+
};
|
|
1279
|
+
}, [
|
|
1280
|
+
model,
|
|
1281
|
+
dxGrid
|
|
1282
|
+
]);
|
|
1283
|
+
return {
|
|
1284
|
+
columns,
|
|
1285
|
+
rows
|
|
1286
|
+
};
|
|
1287
|
+
};
|
|
1288
|
+
var inertPosition = {
|
|
1289
|
+
plane: "grid",
|
|
1290
|
+
col: 0,
|
|
1291
|
+
row: 0
|
|
1330
1292
|
};
|
|
1331
1293
|
var initialCells = {
|
|
1332
1294
|
grid: {},
|
|
@@ -1349,11 +1311,11 @@ var frozen = {
|
|
|
1349
1311
|
};
|
|
1350
1312
|
var sheetRowDefault = {
|
|
1351
1313
|
frozenRowsStart: {
|
|
1352
|
-
size:
|
|
1314
|
+
size: import_react_ui_grid2.defaultSizeRow,
|
|
1353
1315
|
readonly: true
|
|
1354
1316
|
},
|
|
1355
1317
|
grid: {
|
|
1356
|
-
size:
|
|
1318
|
+
size: import_react_ui_grid2.defaultSizeRow,
|
|
1357
1319
|
resizeable: true
|
|
1358
1320
|
}
|
|
1359
1321
|
};
|
|
@@ -1368,46 +1330,63 @@ var sheetColDefault = {
|
|
|
1368
1330
|
}
|
|
1369
1331
|
};
|
|
1370
1332
|
var GridSheet = () => {
|
|
1371
|
-
const {
|
|
1372
|
-
const
|
|
1373
|
-
const
|
|
1333
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
|
|
1334
|
+
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
|
|
1335
|
+
const [dxGrid, setDxGrid] = (0, import_react4.useState)(null);
|
|
1336
|
+
const [extraplanarFocus, setExtraplanarFocus] = (0, import_react4.useState)(null);
|
|
1337
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1338
|
+
const rangeController = (0, import_react4.useRef)();
|
|
1374
1339
|
const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
|
|
1375
1340
|
const handleFocus = (0, import_react4.useCallback)((event) => {
|
|
1376
1341
|
if (!editing) {
|
|
1377
|
-
const cell = (0,
|
|
1378
|
-
if (cell
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1342
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1343
|
+
if (cell) {
|
|
1344
|
+
if (cell.plane === "grid") {
|
|
1345
|
+
setCursor({
|
|
1346
|
+
col: cell.col,
|
|
1347
|
+
row: cell.row
|
|
1348
|
+
});
|
|
1349
|
+
setExtraplanarFocus(null);
|
|
1350
|
+
} else {
|
|
1351
|
+
setExtraplanarFocus(cell);
|
|
1352
|
+
}
|
|
1353
|
+
} else {
|
|
1354
|
+
setExtraplanarFocus(null);
|
|
1383
1355
|
}
|
|
1384
1356
|
}
|
|
1385
1357
|
}, [
|
|
1386
1358
|
editing
|
|
1387
1359
|
]);
|
|
1388
|
-
const handleClose = (0, import_react4.useCallback)((
|
|
1360
|
+
const handleClose = (0, import_react4.useCallback)((_value, event) => {
|
|
1361
|
+
if (event) {
|
|
1362
|
+
const { key, shift } = event;
|
|
1363
|
+
const axis = [
|
|
1364
|
+
"Enter",
|
|
1365
|
+
"ArrowUp",
|
|
1366
|
+
"ArrowDown"
|
|
1367
|
+
].includes(key) ? "row" : [
|
|
1368
|
+
"Tab",
|
|
1369
|
+
"ArrowLeft",
|
|
1370
|
+
"ArrowRight"
|
|
1371
|
+
].includes(key) ? "col" : void 0;
|
|
1372
|
+
const delta = key.startsWith("Arrow") ? [
|
|
1373
|
+
"ArrowUp",
|
|
1374
|
+
"ArrowLeft"
|
|
1375
|
+
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1376
|
+
dxGrid?.refocus(axis, delta);
|
|
1377
|
+
}
|
|
1378
|
+
}, [
|
|
1379
|
+
model,
|
|
1380
|
+
editing,
|
|
1381
|
+
dxGrid
|
|
1382
|
+
]);
|
|
1383
|
+
const handleBlur = (0, import_react4.useCallback)((value) => {
|
|
1389
1384
|
if (value !== void 0) {
|
|
1390
1385
|
model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
|
|
1391
1386
|
}
|
|
1392
|
-
setEditing(null);
|
|
1393
|
-
const axis = [
|
|
1394
|
-
"Enter",
|
|
1395
|
-
"ArrowUp",
|
|
1396
|
-
"ArrowDown"
|
|
1397
|
-
].includes(key) ? "row" : [
|
|
1398
|
-
"Tab",
|
|
1399
|
-
"ArrowLeft",
|
|
1400
|
-
"ArrowRight"
|
|
1401
|
-
].includes(key) ? "col" : void 0;
|
|
1402
|
-
const delta = key.startsWith("Arrow") ? [
|
|
1403
|
-
"ArrowUp",
|
|
1404
|
-
"ArrowLeft"
|
|
1405
|
-
].includes(key) ? -1 : 1 : shift ? -1 : 1;
|
|
1406
|
-
dxGrid.current?.refocus(axis, delta);
|
|
1407
1387
|
}, [
|
|
1408
1388
|
model,
|
|
1409
|
-
editing
|
|
1410
|
-
setEditing
|
|
1389
|
+
editing
|
|
1411
1390
|
]);
|
|
1412
1391
|
const handleAxisResize = (0, import_react4.useCallback)(({ axis, size, index: numericIndex }) => {
|
|
1413
1392
|
if (axis === "row") {
|
|
@@ -1423,22 +1402,22 @@ var GridSheet = () => {
|
|
|
1423
1402
|
model
|
|
1424
1403
|
]);
|
|
1425
1404
|
const handleSelect = (0, import_react4.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
|
|
1426
|
-
const
|
|
1405
|
+
const range = {
|
|
1427
1406
|
from: {
|
|
1428
1407
|
col: minCol,
|
|
1429
1408
|
row: minRow
|
|
1430
1409
|
}
|
|
1431
1410
|
};
|
|
1432
1411
|
if (minCol !== maxCol || minRow !== maxRow) {
|
|
1433
|
-
|
|
1412
|
+
range.to = {
|
|
1434
1413
|
col: maxCol,
|
|
1435
1414
|
row: maxRow
|
|
1436
1415
|
};
|
|
1437
1416
|
}
|
|
1438
1417
|
if (editing) {
|
|
1439
|
-
|
|
1418
|
+
rangeController.current?.setRange((0, import_chunk_O7XR4R7Y.rangeToA1Notation)(range));
|
|
1440
1419
|
} else {
|
|
1441
|
-
setRange(
|
|
1420
|
+
setRange(range.to ? range : void 0);
|
|
1442
1421
|
}
|
|
1443
1422
|
}, [
|
|
1444
1423
|
editing
|
|
@@ -1450,16 +1429,63 @@ var GridSheet = () => {
|
|
|
1450
1429
|
}, [
|
|
1451
1430
|
hasAttention
|
|
1452
1431
|
]);
|
|
1432
|
+
const selectEntireAxis = (0, import_react4.useCallback)((pos) => {
|
|
1433
|
+
switch (pos.plane) {
|
|
1434
|
+
case "frozenRowsStart":
|
|
1435
|
+
return dxGrid?.setSelection({
|
|
1436
|
+
start: {
|
|
1437
|
+
col: pos.col,
|
|
1438
|
+
row: 0,
|
|
1439
|
+
plane: "grid"
|
|
1440
|
+
},
|
|
1441
|
+
end: {
|
|
1442
|
+
col: pos.col,
|
|
1443
|
+
row: model.sheet.rows.length - 1,
|
|
1444
|
+
plane: "grid"
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
case "frozenColsStart":
|
|
1448
|
+
return dxGrid?.setSelection({
|
|
1449
|
+
start: {
|
|
1450
|
+
row: pos.row,
|
|
1451
|
+
col: 0,
|
|
1452
|
+
plane: "grid"
|
|
1453
|
+
},
|
|
1454
|
+
end: {
|
|
1455
|
+
row: pos.row,
|
|
1456
|
+
col: model.sheet.columns.length - 1,
|
|
1457
|
+
plane: "grid"
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
}, [
|
|
1462
|
+
dxGrid,
|
|
1463
|
+
model.sheet
|
|
1464
|
+
]);
|
|
1465
|
+
const handleClick = (0, import_react4.useCallback)((event) => {
|
|
1466
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1467
|
+
if (cell) {
|
|
1468
|
+
selectEntireAxis(cell);
|
|
1469
|
+
}
|
|
1470
|
+
}, [
|
|
1471
|
+
selectEntireAxis
|
|
1472
|
+
]);
|
|
1453
1473
|
const handleKeyDown = (0, import_react4.useCallback)((event) => {
|
|
1454
|
-
const cursorFallbackRange = range ?? cursor ? {
|
|
1455
|
-
from: cursor,
|
|
1456
|
-
to: cursor
|
|
1457
|
-
} : null;
|
|
1458
1474
|
switch (event.key) {
|
|
1459
1475
|
case "Backspace":
|
|
1460
1476
|
case "Delete":
|
|
1461
1477
|
event.preventDefault();
|
|
1462
1478
|
return cursorFallbackRange && model.clear(cursorFallbackRange);
|
|
1479
|
+
case "Enter":
|
|
1480
|
+
case "Space":
|
|
1481
|
+
if (dxGrid && extraplanarFocus) {
|
|
1482
|
+
switch (extraplanarFocus.plane) {
|
|
1483
|
+
case "frozenRowsStart":
|
|
1484
|
+
case "frozenColsStart":
|
|
1485
|
+
event.preventDefault();
|
|
1486
|
+
return selectEntireAxis(extraplanarFocus);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1463
1489
|
}
|
|
1464
1490
|
if (event.metaKey || event.ctrlKey) {
|
|
1465
1491
|
switch (event.key) {
|
|
@@ -1485,13 +1511,55 @@ var GridSheet = () => {
|
|
|
1485
1511
|
}
|
|
1486
1512
|
}
|
|
1487
1513
|
}, [
|
|
1488
|
-
|
|
1514
|
+
cursorFallbackRange,
|
|
1489
1515
|
model,
|
|
1490
|
-
cursor
|
|
1516
|
+
cursor,
|
|
1517
|
+
extraplanarFocus,
|
|
1518
|
+
selectEntireAxis
|
|
1519
|
+
]);
|
|
1520
|
+
const contextMenuAnchorRef = (0, import_react4.useRef)(null);
|
|
1521
|
+
const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
|
|
1522
|
+
const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
|
|
1523
|
+
const handleContextMenu = (0, import_react4.useCallback)((event) => {
|
|
1524
|
+
const cell = (0, import_react_ui_grid2.closestCell)(event.target);
|
|
1525
|
+
if (cell && cell.plane.startsWith("frozen")) {
|
|
1526
|
+
event.preventDefault();
|
|
1527
|
+
contextMenuAnchorRef.current = event.target;
|
|
1528
|
+
setContextMenuOpen(cell);
|
|
1529
|
+
}
|
|
1530
|
+
}, []);
|
|
1531
|
+
const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
|
|
1532
|
+
switch (operation) {
|
|
1533
|
+
case "insert-before":
|
|
1534
|
+
case "insert-after":
|
|
1535
|
+
return dispatch({
|
|
1536
|
+
action: import_chunk_AWKOWDMI.SheetAction.INSERT_AXIS,
|
|
1537
|
+
data: {
|
|
1538
|
+
model,
|
|
1539
|
+
axis: contextMenuAxis,
|
|
1540
|
+
index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
break;
|
|
1544
|
+
case "drop":
|
|
1545
|
+
return dispatch({
|
|
1546
|
+
action: import_chunk_AWKOWDMI.SheetAction.DROP_AXIS,
|
|
1547
|
+
data: {
|
|
1548
|
+
model,
|
|
1549
|
+
axis: contextMenuAxis,
|
|
1550
|
+
axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
}, [
|
|
1555
|
+
contextMenuAxis,
|
|
1556
|
+
contextMenuOpen,
|
|
1557
|
+
model,
|
|
1558
|
+
dispatch
|
|
1491
1559
|
]);
|
|
1492
1560
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
1493
1561
|
const extension = (0, import_react4.useMemo)(() => [
|
|
1494
|
-
(0,
|
|
1562
|
+
(0, import_react_ui_grid2.editorKeys)({
|
|
1495
1563
|
onClose: handleClose,
|
|
1496
1564
|
...editing?.initialContent && {
|
|
1497
1565
|
onNav: handleClose
|
|
@@ -1500,7 +1568,14 @@ var GridSheet = () => {
|
|
|
1500
1568
|
sheetExtension({
|
|
1501
1569
|
functions: model.graph.getFunctions()
|
|
1502
1570
|
}),
|
|
1503
|
-
rangeExtension(
|
|
1571
|
+
rangeExtension({
|
|
1572
|
+
onInit: (fn) => rangeController.current = fn,
|
|
1573
|
+
onStateChange: (state) => {
|
|
1574
|
+
if (dxGrid) {
|
|
1575
|
+
dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
})
|
|
1504
1579
|
], [
|
|
1505
1580
|
model,
|
|
1506
1581
|
handleClose,
|
|
@@ -1512,14 +1587,16 @@ var GridSheet = () => {
|
|
|
1512
1587
|
}, [
|
|
1513
1588
|
model
|
|
1514
1589
|
]);
|
|
1515
|
-
useUpdateFocusedCellOnThreadSelection(
|
|
1516
|
-
|
|
1590
|
+
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1591
|
+
useSelectThreadOnCellFocus();
|
|
1592
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.GridCellEditor, {
|
|
1517
1593
|
getCellContent,
|
|
1518
|
-
extension
|
|
1519
|
-
|
|
1594
|
+
extension,
|
|
1595
|
+
onBlur: handleBlur
|
|
1596
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
|
|
1520
1597
|
initialCells,
|
|
1521
|
-
limitColumns: DEFAULT_COLUMNS,
|
|
1522
|
-
limitRows: DEFAULT_ROWS,
|
|
1598
|
+
limitColumns: import_chunk_O7XR4R7Y.DEFAULT_COLUMNS,
|
|
1599
|
+
limitRows: import_chunk_O7XR4R7Y.DEFAULT_ROWS,
|
|
1523
1600
|
columns,
|
|
1524
1601
|
rows,
|
|
1525
1602
|
onAxisResize: handleAxisResize,
|
|
@@ -1530,40 +1607,49 @@ var GridSheet = () => {
|
|
|
1530
1607
|
onFocus: handleFocus,
|
|
1531
1608
|
onWheelCapture: handleWheel,
|
|
1532
1609
|
onKeyDown: handleKeyDown,
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1610
|
+
onContextMenu: handleContextMenu,
|
|
1611
|
+
onClick: handleClick,
|
|
1612
|
+
overscroll: "trap",
|
|
1613
|
+
className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:border-separator",
|
|
1614
|
+
activeRefs,
|
|
1615
|
+
ref: setDxGrid
|
|
1616
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
|
|
1617
|
+
modal: false,
|
|
1618
|
+
open: !!contextMenuOpen,
|
|
1619
|
+
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1620
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
|
|
1621
|
+
virtualRef: contextMenuAnchorRef
|
|
1622
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Content, {
|
|
1623
|
+
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1624
|
+
sideOffset: 4,
|
|
1625
|
+
collisionPadding: 8
|
|
1626
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1627
|
+
onClick: () => handleAxisMenuAction("insert-before")
|
|
1628
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1629
|
+
size: 5,
|
|
1630
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1631
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1632
|
+
onClick: () => handleAxisMenuAction("insert-after")
|
|
1633
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1634
|
+
size: 5,
|
|
1635
|
+
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1636
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
|
|
1637
|
+
onClick: () => handleAxisMenuAction("drop")
|
|
1638
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
|
|
1639
|
+
size: 5,
|
|
1640
|
+
icon: "ph--backspace--regular"
|
|
1641
|
+
}), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
|
|
1552
1642
|
};
|
|
1553
1643
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1554
1644
|
0 && (module.exports = {
|
|
1555
1645
|
ComputeGraphContextProvider,
|
|
1556
1646
|
GridSheet,
|
|
1647
|
+
RangeList,
|
|
1557
1648
|
SheetContainer,
|
|
1558
1649
|
SheetProvider,
|
|
1559
|
-
|
|
1560
|
-
addressToIndex,
|
|
1561
|
-
compareIndexPositions,
|
|
1650
|
+
completeCellRangeToThreadCursor,
|
|
1562
1651
|
computeGraphFacet,
|
|
1563
|
-
createSheet,
|
|
1564
|
-
inRange,
|
|
1565
|
-
rangeToA1Notation,
|
|
1566
1652
|
useComputeGraph,
|
|
1567
1653
|
useSheetContext
|
|
1568
1654
|
});
|
|
1569
|
-
//# sourceMappingURL=chunk-
|
|
1655
|
+
//# sourceMappingURL=chunk-OO24XJBV.cjs.map
|