@univerjs/sheets-formula 0.1.0-alpha.1

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.
Files changed (180) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -0
  3. package/lib/cjs/index.js +4215 -0
  4. package/lib/cjs/locale/en-US.js +223 -0
  5. package/lib/cjs/locale/zh-CN.js +223 -0
  6. package/lib/esm/index.js +4205 -0
  7. package/lib/esm/locale/en-US.js +200 -0
  8. package/lib/esm/locale/zh-CN.js +200 -0
  9. package/lib/index.css +214 -0
  10. package/lib/types/commands/commands/insert-function.command.d.ts +23 -0
  11. package/lib/types/commands/commands/insert-function.command.d.ts.map +1 -0
  12. package/lib/types/commands/operations/__tests__/create-command-test-bed.d.ts +16 -0
  13. package/lib/types/commands/operations/__tests__/create-command-test-bed.d.ts.map +1 -0
  14. package/lib/types/commands/operations/__tests__/insert-function.operation.spec.d.ts +2 -0
  15. package/lib/types/commands/operations/__tests__/insert-function.operation.spec.d.ts.map +1 -0
  16. package/lib/types/commands/operations/editor-formula.operation.d.ts +11 -0
  17. package/lib/types/commands/operations/editor-formula.operation.d.ts.map +1 -0
  18. package/lib/types/commands/operations/help-function.operation.d.ts +3 -0
  19. package/lib/types/commands/operations/help-function.operation.d.ts.map +1 -0
  20. package/lib/types/commands/operations/insert-function.operation.d.ts +9 -0
  21. package/lib/types/commands/operations/insert-function.operation.d.ts.map +1 -0
  22. package/lib/types/commands/operations/more-functions.operation.d.ts +3 -0
  23. package/lib/types/commands/operations/more-functions.operation.d.ts.map +1 -0
  24. package/lib/types/commands/operations/reference-absolute.operation.d.ts +3 -0
  25. package/lib/types/commands/operations/reference-absolute.operation.d.ts.map +1 -0
  26. package/lib/types/commands/operations/search-function.operation.d.ts +3 -0
  27. package/lib/types/commands/operations/search-function.operation.d.ts.map +1 -0
  28. package/lib/types/common/plugin-name.d.ts +2 -0
  29. package/lib/types/common/plugin-name.d.ts.map +1 -0
  30. package/lib/types/common/prompt.d.ts +2 -0
  31. package/lib/types/common/prompt.d.ts.map +1 -0
  32. package/lib/types/common/selection.d.ts +5 -0
  33. package/lib/types/common/selection.d.ts.map +1 -0
  34. package/lib/types/controllers/__tests__/create-command-test-bed.d.ts +11 -0
  35. package/lib/types/controllers/__tests__/create-command-test-bed.d.ts.map +1 -0
  36. package/lib/types/controllers/__tests__/formula-auto-fill.controller.spec.d.ts +2 -0
  37. package/lib/types/controllers/__tests__/formula-auto-fill.controller.spec.d.ts.map +1 -0
  38. package/lib/types/controllers/formula-auto-fill.controller.d.ts +12 -0
  39. package/lib/types/controllers/formula-auto-fill.controller.d.ts.map +1 -0
  40. package/lib/types/controllers/formula-input.controller.d.ts +25 -0
  41. package/lib/types/controllers/formula-input.controller.d.ts.map +1 -0
  42. package/lib/types/controllers/formula-ui.controller.d.ts +19 -0
  43. package/lib/types/controllers/formula-ui.controller.d.ts.map +1 -0
  44. package/lib/types/controllers/menu.d.ts +5 -0
  45. package/lib/types/controllers/menu.d.ts.map +1 -0
  46. package/lib/types/controllers/prompt.controller.d.ts +146 -0
  47. package/lib/types/controllers/prompt.controller.d.ts.map +1 -0
  48. package/lib/types/controllers/shortcuts/prompt.shortcut.d.ts +10 -0
  49. package/lib/types/controllers/shortcuts/prompt.shortcut.d.ts.map +1 -0
  50. package/lib/types/formula-ui-plugin.d.ts +18 -0
  51. package/lib/types/formula-ui-plugin.d.ts.map +1 -0
  52. package/lib/types/index.d.ts +2 -0
  53. package/lib/types/index.d.ts.map +1 -0
  54. package/lib/types/locale/en-US.d.ts +136 -0
  55. package/lib/types/locale/en-US.d.ts.map +1 -0
  56. package/lib/types/locale/function-list/array/en-US.d.ts +3 -0
  57. package/lib/types/locale/function-list/array/en-US.d.ts.map +1 -0
  58. package/lib/types/locale/function-list/array/zh-CN.d.ts +3 -0
  59. package/lib/types/locale/function-list/array/zh-CN.d.ts.map +1 -0
  60. package/lib/types/locale/function-list/compatibility/en-US.d.ts +3 -0
  61. package/lib/types/locale/function-list/compatibility/en-US.d.ts.map +1 -0
  62. package/lib/types/locale/function-list/compatibility/zh-CN.d.ts +3 -0
  63. package/lib/types/locale/function-list/compatibility/zh-CN.d.ts.map +1 -0
  64. package/lib/types/locale/function-list/cube/en-US.d.ts +3 -0
  65. package/lib/types/locale/function-list/cube/en-US.d.ts.map +1 -0
  66. package/lib/types/locale/function-list/cube/zh-CN.d.ts +3 -0
  67. package/lib/types/locale/function-list/cube/zh-CN.d.ts.map +1 -0
  68. package/lib/types/locale/function-list/database/en-US.d.ts +3 -0
  69. package/lib/types/locale/function-list/database/en-US.d.ts.map +1 -0
  70. package/lib/types/locale/function-list/database/zh-CN.d.ts +3 -0
  71. package/lib/types/locale/function-list/database/zh-CN.d.ts.map +1 -0
  72. package/lib/types/locale/function-list/date/en-US.d.ts +3 -0
  73. package/lib/types/locale/function-list/date/en-US.d.ts.map +1 -0
  74. package/lib/types/locale/function-list/date/zh-CN.d.ts +3 -0
  75. package/lib/types/locale/function-list/date/zh-CN.d.ts.map +1 -0
  76. package/lib/types/locale/function-list/engineering/en-US.d.ts +3 -0
  77. package/lib/types/locale/function-list/engineering/en-US.d.ts.map +1 -0
  78. package/lib/types/locale/function-list/engineering/zh-CN.d.ts +3 -0
  79. package/lib/types/locale/function-list/engineering/zh-CN.d.ts.map +1 -0
  80. package/lib/types/locale/function-list/financial/en-US.d.ts +3 -0
  81. package/lib/types/locale/function-list/financial/en-US.d.ts.map +1 -0
  82. package/lib/types/locale/function-list/financial/zh-CN.d.ts +3 -0
  83. package/lib/types/locale/function-list/financial/zh-CN.d.ts.map +1 -0
  84. package/lib/types/locale/function-list/information/en-US.d.ts +3 -0
  85. package/lib/types/locale/function-list/information/en-US.d.ts.map +1 -0
  86. package/lib/types/locale/function-list/information/zh-CN.d.ts +3 -0
  87. package/lib/types/locale/function-list/information/zh-CN.d.ts.map +1 -0
  88. package/lib/types/locale/function-list/logical/en-US.d.ts +3 -0
  89. package/lib/types/locale/function-list/logical/en-US.d.ts.map +1 -0
  90. package/lib/types/locale/function-list/logical/zh-CN.d.ts +3 -0
  91. package/lib/types/locale/function-list/logical/zh-CN.d.ts.map +1 -0
  92. package/lib/types/locale/function-list/lookup/en-US.d.ts +3 -0
  93. package/lib/types/locale/function-list/lookup/en-US.d.ts.map +1 -0
  94. package/lib/types/locale/function-list/lookup/zh-CN.d.ts +3 -0
  95. package/lib/types/locale/function-list/lookup/zh-CN.d.ts.map +1 -0
  96. package/lib/types/locale/function-list/math/en-US.d.ts +36 -0
  97. package/lib/types/locale/function-list/math/en-US.d.ts.map +1 -0
  98. package/lib/types/locale/function-list/math/zh-CN.d.ts +36 -0
  99. package/lib/types/locale/function-list/math/zh-CN.d.ts.map +1 -0
  100. package/lib/types/locale/function-list/statistical/en-US.d.ts +60 -0
  101. package/lib/types/locale/function-list/statistical/en-US.d.ts.map +1 -0
  102. package/lib/types/locale/function-list/statistical/zh-CN.d.ts +60 -0
  103. package/lib/types/locale/function-list/statistical/zh-CN.d.ts.map +1 -0
  104. package/lib/types/locale/function-list/text/en-US.d.ts +3 -0
  105. package/lib/types/locale/function-list/text/en-US.d.ts.map +1 -0
  106. package/lib/types/locale/function-list/text/zh-CN.d.ts +3 -0
  107. package/lib/types/locale/function-list/text/zh-CN.d.ts.map +1 -0
  108. package/lib/types/locale/function-list/univer/en-US.d.ts +3 -0
  109. package/lib/types/locale/function-list/univer/en-US.d.ts.map +1 -0
  110. package/lib/types/locale/function-list/univer/zh-CN.d.ts +3 -0
  111. package/lib/types/locale/function-list/univer/zh-CN.d.ts.map +1 -0
  112. package/lib/types/locale/function-list/web/en-US.d.ts +3 -0
  113. package/lib/types/locale/function-list/web/en-US.d.ts.map +1 -0
  114. package/lib/types/locale/function-list/web/zh-CN.d.ts +3 -0
  115. package/lib/types/locale/function-list/web/zh-CN.d.ts.map +1 -0
  116. package/lib/types/locale/index.d.ts +3 -0
  117. package/lib/types/locale/index.d.ts.map +1 -0
  118. package/lib/types/locale/zh-CN.d.ts +136 -0
  119. package/lib/types/locale/zh-CN.d.ts.map +1 -0
  120. package/lib/types/services/description.service.d.ts +48 -0
  121. package/lib/types/services/description.service.d.ts.map +1 -0
  122. package/lib/types/services/formula-input.service.d.ts +95 -0
  123. package/lib/types/services/formula-input.service.d.ts.map +1 -0
  124. package/lib/types/services/function-list/array.d.ts +3 -0
  125. package/lib/types/services/function-list/array.d.ts.map +1 -0
  126. package/lib/types/services/function-list/compatibility.d.ts +3 -0
  127. package/lib/types/services/function-list/compatibility.d.ts.map +1 -0
  128. package/lib/types/services/function-list/cube.d.ts +3 -0
  129. package/lib/types/services/function-list/cube.d.ts.map +1 -0
  130. package/lib/types/services/function-list/database.d.ts +3 -0
  131. package/lib/types/services/function-list/database.d.ts.map +1 -0
  132. package/lib/types/services/function-list/date.d.ts +3 -0
  133. package/lib/types/services/function-list/date.d.ts.map +1 -0
  134. package/lib/types/services/function-list/engineering.d.ts +3 -0
  135. package/lib/types/services/function-list/engineering.d.ts.map +1 -0
  136. package/lib/types/services/function-list/financial.d.ts +3 -0
  137. package/lib/types/services/function-list/financial.d.ts.map +1 -0
  138. package/lib/types/services/function-list/function-list.d.ts +3 -0
  139. package/lib/types/services/function-list/function-list.d.ts.map +1 -0
  140. package/lib/types/services/function-list/information.d.ts +3 -0
  141. package/lib/types/services/function-list/information.d.ts.map +1 -0
  142. package/lib/types/services/function-list/logical.d.ts +3 -0
  143. package/lib/types/services/function-list/logical.d.ts.map +1 -0
  144. package/lib/types/services/function-list/lookup.d.ts +3 -0
  145. package/lib/types/services/function-list/lookup.d.ts.map +1 -0
  146. package/lib/types/services/function-list/math.d.ts +3 -0
  147. package/lib/types/services/function-list/math.d.ts.map +1 -0
  148. package/lib/types/services/function-list/statistical.d.ts +3 -0
  149. package/lib/types/services/function-list/statistical.d.ts.map +1 -0
  150. package/lib/types/services/function-list/text.d.ts +3 -0
  151. package/lib/types/services/function-list/text.d.ts.map +1 -0
  152. package/lib/types/services/function-list/univer.d.ts +3 -0
  153. package/lib/types/services/function-list/univer.d.ts.map +1 -0
  154. package/lib/types/services/function-list/web.d.ts +3 -0
  155. package/lib/types/services/function-list/web.d.ts.map +1 -0
  156. package/lib/types/services/prompt.service.d.ts +106 -0
  157. package/lib/types/services/prompt.service.d.ts.map +1 -0
  158. package/lib/types/services/utils.d.ts +8 -0
  159. package/lib/types/services/utils.d.ts.map +1 -0
  160. package/lib/types/views/FormulaPromptContainer.d.ts +3 -0
  161. package/lib/types/views/FormulaPromptContainer.d.ts.map +1 -0
  162. package/lib/types/views/more-functions/MoreFunctions.d.ts +3 -0
  163. package/lib/types/views/more-functions/MoreFunctions.d.ts.map +1 -0
  164. package/lib/types/views/more-functions/function-help/FunctionHelp.d.ts +9 -0
  165. package/lib/types/views/more-functions/function-help/FunctionHelp.d.ts.map +1 -0
  166. package/lib/types/views/more-functions/function-params/FunctionParams.d.ts +9 -0
  167. package/lib/types/views/more-functions/function-params/FunctionParams.d.ts.map +1 -0
  168. package/lib/types/views/more-functions/input-params/InputParams.d.ts +8 -0
  169. package/lib/types/views/more-functions/input-params/InputParams.d.ts.map +1 -0
  170. package/lib/types/views/more-functions/interface.d.ts +2 -0
  171. package/lib/types/views/more-functions/interface.d.ts.map +1 -0
  172. package/lib/types/views/more-functions/select-function/SelectFunction.d.ts +7 -0
  173. package/lib/types/views/more-functions/select-function/SelectFunction.d.ts.map +1 -0
  174. package/lib/types/views/prompt/error-function/error-function.d.ts +3 -0
  175. package/lib/types/views/prompt/error-function/error-function.d.ts.map +1 -0
  176. package/lib/types/views/prompt/help-function/HelpFunction.d.ts +3 -0
  177. package/lib/types/views/prompt/help-function/HelpFunction.d.ts.map +1 -0
  178. package/lib/types/views/prompt/search-function/SearchFunction.d.ts +3 -0
  179. package/lib/types/views/prompt/search-function/SearchFunction.d.ts.map +1 -0
  180. package/package.json +68 -0
@@ -0,0 +1,4215 @@
1
+ "use strict";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _array_without_holes(arr) {
11
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
12
+ }
13
+ function _assert_this_initialized(self) {
14
+ if (self === void 0) {
15
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
16
+ }
17
+ return self;
18
+ }
19
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
20
+ try {
21
+ var info = gen[key](arg);
22
+ var value = info.value;
23
+ } catch (error) {
24
+ reject(error);
25
+ return;
26
+ }
27
+ if (info.done) {
28
+ resolve(value);
29
+ } else {
30
+ Promise.resolve(value).then(_next, _throw);
31
+ }
32
+ }
33
+ function _async_to_generator(fn) {
34
+ return function() {
35
+ var self = this, args = arguments;
36
+ return new Promise(function(resolve, reject) {
37
+ var gen = fn.apply(self, args);
38
+ function _next(value) {
39
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
40
+ }
41
+ function _throw(err) {
42
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
43
+ }
44
+ _next(undefined);
45
+ });
46
+ };
47
+ }
48
+ function _class_call_check(instance, Constructor) {
49
+ if (!(instance instanceof Constructor)) {
50
+ throw new TypeError("Cannot call a class as a function");
51
+ }
52
+ }
53
+ function _defineProperties(target, props) {
54
+ for(var i = 0; i < props.length; i++){
55
+ var descriptor = props[i];
56
+ descriptor.enumerable = descriptor.enumerable || false;
57
+ descriptor.configurable = true;
58
+ if ("value" in descriptor) descriptor.writable = true;
59
+ Object.defineProperty(target, descriptor.key, descriptor);
60
+ }
61
+ }
62
+ function _create_class(Constructor, protoProps, staticProps) {
63
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
64
+ if (staticProps) _defineProperties(Constructor, staticProps);
65
+ return Constructor;
66
+ }
67
+ function _define_property(obj, key, value) {
68
+ if (key in obj) {
69
+ Object.defineProperty(obj, key, {
70
+ value: value,
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true
74
+ });
75
+ } else {
76
+ obj[key] = value;
77
+ }
78
+ return obj;
79
+ }
80
+ function _get_prototype_of(o) {
81
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
82
+ return o.__proto__ || Object.getPrototypeOf(o);
83
+ };
84
+ return _get_prototype_of(o);
85
+ }
86
+ function _inherits(subClass, superClass) {
87
+ if (typeof superClass !== "function" && superClass !== null) {
88
+ throw new TypeError("Super expression must either be null or a function");
89
+ }
90
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
91
+ constructor: {
92
+ value: subClass,
93
+ writable: true,
94
+ configurable: true
95
+ }
96
+ });
97
+ if (superClass) _set_prototype_of(subClass, superClass);
98
+ }
99
+ function _iterable_to_array(iter) {
100
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
101
+ }
102
+ function _iterable_to_array_limit(arr, i) {
103
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
104
+ if (_i == null) return;
105
+ var _arr = [];
106
+ var _n = true;
107
+ var _d = false;
108
+ var _s, _e;
109
+ try {
110
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
111
+ _arr.push(_s.value);
112
+ if (i && _arr.length === i) break;
113
+ }
114
+ } catch (err) {
115
+ _d = true;
116
+ _e = err;
117
+ } finally{
118
+ try {
119
+ if (!_n && _i["return"] != null) _i["return"]();
120
+ } finally{
121
+ if (_d) throw _e;
122
+ }
123
+ }
124
+ return _arr;
125
+ }
126
+ function _non_iterable_rest() {
127
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
128
+ }
129
+ function _non_iterable_spread() {
130
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
131
+ }
132
+ function _object_spread(target) {
133
+ for(var i = 1; i < arguments.length; i++){
134
+ var source = arguments[i] != null ? arguments[i] : {};
135
+ var ownKeys = Object.keys(source);
136
+ if (typeof Object.getOwnPropertySymbols === "function") {
137
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
138
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
139
+ }));
140
+ }
141
+ ownKeys.forEach(function(key) {
142
+ _define_property(target, key, source[key]);
143
+ });
144
+ }
145
+ return target;
146
+ }
147
+ function _possible_constructor_return(self, call) {
148
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
149
+ return call;
150
+ }
151
+ return _assert_this_initialized(self);
152
+ }
153
+ function _set_prototype_of(o, p) {
154
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
155
+ o.__proto__ = p;
156
+ return o;
157
+ };
158
+ return _set_prototype_of(o, p);
159
+ }
160
+ function _sliced_to_array(arr, i) {
161
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
162
+ }
163
+ function _to_consumable_array(arr) {
164
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
165
+ }
166
+ function _type_of(obj) {
167
+ "@swc/helpers - typeof";
168
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
169
+ }
170
+ function _unsupported_iterable_to_array(o, minLen) {
171
+ if (!o) return;
172
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
173
+ var n = Object.prototype.toString.call(o).slice(8, -1);
174
+ if (n === "Object" && o.constructor) n = o.constructor.name;
175
+ if (n === "Map" || n === "Set") return Array.from(n);
176
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
177
+ }
178
+ function _is_native_reflect_construct() {
179
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
180
+ if (Reflect.construct.sham) return false;
181
+ if (typeof Proxy === "function") return true;
182
+ try {
183
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
184
+ return true;
185
+ } catch (e) {
186
+ return false;
187
+ }
188
+ }
189
+ function _create_super(Derived) {
190
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
191
+ return function _createSuperInternal() {
192
+ var Super = _get_prototype_of(Derived), result;
193
+ if (hasNativeReflectConstruct) {
194
+ var NewTarget = _get_prototype_of(this).constructor;
195
+ result = Reflect.construct(Super, arguments, NewTarget);
196
+ } else {
197
+ result = Super.apply(this, arguments);
198
+ }
199
+ return _possible_constructor_return(this, result);
200
+ };
201
+ }
202
+ function _ts_generator(thisArg, body) {
203
+ var f, y, t, g, _ = {
204
+ label: 0,
205
+ sent: function() {
206
+ if (t[0] & 1) throw t[1];
207
+ return t[1];
208
+ },
209
+ trys: [],
210
+ ops: []
211
+ };
212
+ return g = {
213
+ next: verb(0),
214
+ "throw": verb(1),
215
+ "return": verb(2)
216
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
217
+ return this;
218
+ }), g;
219
+ function verb(n) {
220
+ return function(v) {
221
+ return step([
222
+ n,
223
+ v
224
+ ]);
225
+ };
226
+ }
227
+ function step(op) {
228
+ if (f) throw new TypeError("Generator is already executing.");
229
+ while(_)try {
230
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
231
+ if (y = 0, t) op = [
232
+ op[0] & 2,
233
+ t.value
234
+ ];
235
+ switch(op[0]){
236
+ case 0:
237
+ case 1:
238
+ t = op;
239
+ break;
240
+ case 4:
241
+ _.label++;
242
+ return {
243
+ value: op[1],
244
+ done: false
245
+ };
246
+ case 5:
247
+ _.label++;
248
+ y = op[1];
249
+ op = [
250
+ 0
251
+ ];
252
+ continue;
253
+ case 7:
254
+ op = _.ops.pop();
255
+ _.trys.pop();
256
+ continue;
257
+ default:
258
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
259
+ _ = 0;
260
+ continue;
261
+ }
262
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
263
+ _.label = op[1];
264
+ break;
265
+ }
266
+ if (op[0] === 6 && _.label < t[1]) {
267
+ _.label = t[1];
268
+ t = op;
269
+ break;
270
+ }
271
+ if (t && _.label < t[2]) {
272
+ _.label = t[2];
273
+ _.ops.push(op);
274
+ break;
275
+ }
276
+ if (t[2]) _.ops.pop();
277
+ _.trys.pop();
278
+ continue;
279
+ }
280
+ op = body.call(thisArg, _);
281
+ } catch (e) {
282
+ op = [
283
+ 6,
284
+ e
285
+ ];
286
+ y = 0;
287
+ } finally{
288
+ f = t = 0;
289
+ }
290
+ if (op[0] & 5) throw op[1];
291
+ return {
292
+ value: op[0] ? op[1] : void 0,
293
+ done: true
294
+ };
295
+ }
296
+ }
297
+ var _import_core17_Plugin, _class;
298
+ var __create = Object.create;
299
+ var __defProp = Object.defineProperty;
300
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
301
+ var __getOwnPropNames = Object.getOwnPropertyNames;
302
+ var __getProtoOf = Object.getPrototypeOf;
303
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
304
+ var __export = function(target, all) {
305
+ for(var name in all)__defProp(target, name, {
306
+ get: all[name],
307
+ enumerable: true
308
+ });
309
+ };
310
+ var __copyProps = function(to, from, except, desc) {
311
+ if (from && typeof from === "object" || typeof from === "function") {
312
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
313
+ try {
314
+ var _loop = function() {
315
+ var key = _step.value;
316
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
317
+ get: function() {
318
+ return from[key];
319
+ },
320
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
321
+ });
322
+ };
323
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
324
+ } catch (err) {
325
+ _didIteratorError = true;
326
+ _iteratorError = err;
327
+ } finally{
328
+ try {
329
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
330
+ _iterator.return();
331
+ }
332
+ } finally{
333
+ if (_didIteratorError) {
334
+ throw _iteratorError;
335
+ }
336
+ }
337
+ }
338
+ }
339
+ return to;
340
+ };
341
+ var __toESM = function(mod, isNodeMode, target) {
342
+ return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
343
+ // file that has been converted to a CommonJS file using a Babel-
344
+ // compatible transform (i.e. "__esModule" has not been set), then set
345
+ // "default" to the CommonJS "module.exports" for node compatibility.
346
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
347
+ value: mod,
348
+ enumerable: true
349
+ }) : target, mod);
350
+ };
351
+ var __toCommonJS = function(mod) {
352
+ return __copyProps(__defProp({}, "__esModule", {
353
+ value: true
354
+ }), mod);
355
+ };
356
+ var __decorateClass = function(decorators, target, key, kind) {
357
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
358
+ for(var i = decorators.length - 1, decorator; i >= 0; i--)if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
359
+ if (kind && result) __defProp(target, key, result);
360
+ return result;
361
+ };
362
+ var __decorateParam = function(index, decorator) {
363
+ return function(target, key) {
364
+ return decorator(target, key, index);
365
+ };
366
+ };
367
+ // src/index.ts
368
+ var src_exports = {};
369
+ __export(src_exports, {
370
+ FormulaUIPlugin: function() {
371
+ return FormulaUIPlugin;
372
+ }
373
+ });
374
+ module.exports = __toCommonJS(src_exports);
375
+ // src/formula-ui-plugin.ts
376
+ var import_core17 = require("@univerjs/core");
377
+ var import_redi8 = require("@wendellhu/redi");
378
+ // src/common/plugin-name.ts
379
+ var FORMULA_UI_PLUGIN_NAME = "formula-ui";
380
+ // src/controllers/formula-auto-fill.controller.ts
381
+ var import_core = require("@univerjs/core");
382
+ var import_engine_formula = require("@univerjs/engine-formula");
383
+ var import_sheets_ui = require("@univerjs/sheets-ui");
384
+ var import_redi = require("@wendellhu/redi");
385
+ var FormulaAutoFillController = /*#__PURE__*/ function(_import_core_Disposable) {
386
+ _inherits(FormulaAutoFillController, _import_core_Disposable);
387
+ var _super = _create_super(FormulaAutoFillController);
388
+ function FormulaAutoFillController(_autoFillService, _formulaEngineService) {
389
+ _class_call_check(this, FormulaAutoFillController);
390
+ var _this;
391
+ _this = _super.call(this);
392
+ _this._autoFillService = _autoFillService;
393
+ _this._formulaEngineService = _formulaEngineService;
394
+ _this._initialize();
395
+ return _this;
396
+ }
397
+ _create_class(FormulaAutoFillController, [
398
+ {
399
+ key: "_initialize",
400
+ value: function _initialize() {
401
+ this._registerAutoFill();
402
+ }
403
+ },
404
+ {
405
+ key: "_registerAutoFill",
406
+ value: function _registerAutoFill() {
407
+ var _this = this;
408
+ var formulaRule = {
409
+ type: import_sheets_ui.DATA_TYPE.FORMULA,
410
+ priority: 1001,
411
+ match: function(cellData) {
412
+ return (0, import_core.isFormulaString)(cellData === null || cellData === void 0 ? void 0 : cellData.f);
413
+ },
414
+ isContinue: function(prev, cur) {
415
+ if (prev.type === import_sheets_ui.DATA_TYPE.FORMULA) {
416
+ return true;
417
+ }
418
+ return false;
419
+ },
420
+ applyFunctions: _define_property({}, import_sheets_ui.APPLY_TYPE.COPY, function(dataWithIndex, len, direction, copyDataPiece) {
421
+ var data = dataWithIndex.data, index = dataWithIndex.index;
422
+ return _this._fillCopyFormula(data, len, direction, index, copyDataPiece);
423
+ })
424
+ };
425
+ this._autoFillService.registerRule(formulaRule);
426
+ }
427
+ },
428
+ {
429
+ key: "_fillCopyFormula",
430
+ value: function _fillCopyFormula(data, len, direction, index, copyDataPiece) {
431
+ var step = getDataLength(copyDataPiece);
432
+ var applyData = [];
433
+ var formulaIdMap = /* @__PURE__ */ new Map();
434
+ for(var i = 1; i <= len; i++){
435
+ var index2 = (i - 1) % data.length;
436
+ var d = import_core.Tools.deepClone(data[index2]);
437
+ if (d) {
438
+ var _data_index2;
439
+ var originalFormula = (_data_index2 = data[index2]) === null || _data_index2 === void 0 ? void 0 : _data_index2.f;
440
+ if (originalFormula) {
441
+ var formulaId = formulaIdMap.get(index2);
442
+ if (!formulaId) {
443
+ formulaId = import_core.Tools.generateRandomId(6);
444
+ formulaIdMap.set(index2, formulaId);
445
+ var _directionToOffset = directionToOffset(step, direction), offsetX = _directionToOffset.offsetX, offsetY = _directionToOffset.offsetY;
446
+ var shiftedFormula = this._formulaEngineService.moveFormulaRefOffset(originalFormula, offsetX, offsetY);
447
+ d.si = formulaId;
448
+ d.f = shiftedFormula;
449
+ d.v = null;
450
+ d.p = null;
451
+ } else {
452
+ d.si = formulaId;
453
+ d.f = null;
454
+ d.v = null;
455
+ d.p = null;
456
+ }
457
+ if (direction === import_core.Direction.DOWN || direction === import_core.Direction.RIGHT) {
458
+ applyData.push(d);
459
+ } else {
460
+ applyData.unshift(d);
461
+ }
462
+ }
463
+ }
464
+ }
465
+ return applyData;
466
+ }
467
+ }
468
+ ]);
469
+ return FormulaAutoFillController;
470
+ }(import_core.Disposable);
471
+ FormulaAutoFillController = __decorateClass([
472
+ (0, import_core.OnLifecycle)(import_core.LifecycleStages.Ready, FormulaAutoFillController),
473
+ __decorateParam(0, import_sheets_ui.IAutoFillService),
474
+ __decorateParam(1, (0, import_redi.Inject)(import_engine_formula.FormulaEngineService))
475
+ ], FormulaAutoFillController);
476
+ function directionToOffset(step, direction) {
477
+ var offsetX = 0;
478
+ var offsetY = 0;
479
+ switch(direction){
480
+ case import_core.Direction.UP:
481
+ offsetY = -step;
482
+ break;
483
+ case import_core.Direction.RIGHT:
484
+ offsetX = step;
485
+ break;
486
+ case import_core.Direction.DOWN:
487
+ offsetY = step;
488
+ break;
489
+ case import_core.Direction.LEFT:
490
+ offsetX = -step;
491
+ break;
492
+ }
493
+ return {
494
+ offsetX: offsetX,
495
+ offsetY: offsetY
496
+ };
497
+ }
498
+ function getDataLength(copyDataPiece) {
499
+ var length = 0;
500
+ for(var t in copyDataPiece){
501
+ copyDataPiece[t].forEach(function(item) {
502
+ length += item.data.length;
503
+ });
504
+ }
505
+ return length;
506
+ }
507
+ // src/controllers/formula-input.controller.ts
508
+ var import_core3 = require("@univerjs/core");
509
+ var import_engine_formula3 = require("@univerjs/engine-formula");
510
+ var import_engine_render = require("@univerjs/engine-render");
511
+ var import_sheets_ui2 = require("@univerjs/sheets-ui");
512
+ var import_ui = require("@univerjs/ui");
513
+ var import_redi3 = require("@wendellhu/redi");
514
+ // src/commands/operations/reference-absolute.operation.ts
515
+ var import_core2 = require("@univerjs/core");
516
+ var ReferenceAbsoluteOperation = {
517
+ id: "formula-ui.operation.change-ref-to-absolute",
518
+ type: import_core2.CommandType.OPERATION,
519
+ handler: function() {
520
+ var _ref = _async_to_generator(function(accessor) {
521
+ return _ts_generator(this, function(_state) {
522
+ return [
523
+ 2,
524
+ true
525
+ ];
526
+ });
527
+ });
528
+ return function(accessor) {
529
+ return _ref.apply(this, arguments);
530
+ };
531
+ }()
532
+ };
533
+ // src/services/formula-input.service.ts
534
+ var import_engine_formula2 = require("@univerjs/engine-formula");
535
+ var import_redi2 = require("@wendellhu/redi");
536
+ var import_rxjs = require("rxjs");
537
+ var FormulaInputService = /*#__PURE__*/ function() {
538
+ function FormulaInputService(_formulaEngineService) {
539
+ _class_call_check(this, FormulaInputService);
540
+ _define_property(this, "_sequenceNodes", []);
541
+ _define_property(this, "_isSelectionMoving", false);
542
+ _define_property(this, "_isLockedOnSelectionChangeRefString", false);
543
+ _define_property(this, "_isLockedOnSelectionInsertRefString", false);
544
+ _define_property(this, "_syncToEditor$", new import_rxjs.Subject());
545
+ _define_property(this, "syncToEditor$", this._syncToEditor$.asObservable());
546
+ _define_property(this, "_changeRef$", new import_rxjs.Subject());
547
+ _define_property(this, "changeRef$", this._changeRef$.asObservable());
548
+ _define_property(this, "_inputFormula$", new import_rxjs.Subject());
549
+ _define_property(this, "inputFormula$", this._inputFormula$.asObservable());
550
+ this._formulaEngineService = _formulaEngineService;
551
+ }
552
+ _create_class(FormulaInputService, [
553
+ {
554
+ key: "dispose",
555
+ value: function dispose() {
556
+ this._sequenceNodes = [];
557
+ }
558
+ },
559
+ {
560
+ key: "inputFormula",
561
+ value: function inputFormula(formulaString) {
562
+ this._inputFormula$.next(formulaString);
563
+ }
564
+ },
565
+ {
566
+ key: "syncToEditor",
567
+ value: function syncToEditor(textSelectionOffset) {
568
+ this._syncToEditor$.next({
569
+ sequences: this.getSequenceNodes(),
570
+ textSelectionOffset: textSelectionOffset
571
+ });
572
+ }
573
+ },
574
+ {
575
+ key: "getSequenceNodes",
576
+ value: function getSequenceNodes() {
577
+ return _to_consumable_array(this._sequenceNodes);
578
+ }
579
+ },
580
+ {
581
+ key: "setSequenceNodes",
582
+ value: function setSequenceNodes(nodes) {
583
+ this._sequenceNodes = nodes;
584
+ }
585
+ },
586
+ {
587
+ key: "clearSequenceNodes",
588
+ value: function clearSequenceNodes() {
589
+ this._sequenceNodes = [];
590
+ }
591
+ },
592
+ {
593
+ key: "getCurrentSequenceNode",
594
+ value: function getCurrentSequenceNode(strIndex) {
595
+ return this._sequenceNodes[this.getCurrentSequenceNodeIndex(strIndex)];
596
+ }
597
+ },
598
+ {
599
+ key: "getCurrentSequenceNodeByIndex",
600
+ value: function getCurrentSequenceNodeByIndex(nodeIndex) {
601
+ return this._sequenceNodes[nodeIndex];
602
+ }
603
+ },
604
+ {
605
+ /**
606
+ * Query the text coordinates in the sequenceNodes and determine the actual insertion index.
607
+ * @param sequenceNodes
608
+ * @param strIndex
609
+ * @returns
610
+ */ key: "getCurrentSequenceNodeIndex",
611
+ value: function getCurrentSequenceNodeIndex(strIndex) {
612
+ var nodeIndex = 0;
613
+ for(var i = 0, len = this._sequenceNodes.length; i < len; i++){
614
+ var node = this._sequenceNodes[i];
615
+ if (typeof node === "string") {
616
+ nodeIndex++;
617
+ } else {
618
+ var endIndex = node.endIndex;
619
+ nodeIndex = endIndex;
620
+ }
621
+ if (strIndex <= nodeIndex) {
622
+ return i;
623
+ }
624
+ }
625
+ return this._sequenceNodes.length;
626
+ }
627
+ },
628
+ {
629
+ /**
630
+ * Synchronize the reference text based on the changes of the selection.
631
+ * @param refIndex
632
+ * @param rangeWithCoord
633
+ * @returns
634
+ */ key: "updateSequenceRef",
635
+ value: function updateSequenceRef(nodeIndex, refString) {
636
+ var node = this._sequenceNodes[nodeIndex];
637
+ if (typeof node === "string" || node.nodeType !== import_engine_formula2.sequenceNodeType.REFERENCE) {
638
+ return;
639
+ }
640
+ var difference = refString.length - node.token.length;
641
+ var newNode = _object_spread({}, node);
642
+ newNode.token = refString;
643
+ newNode.endIndex += difference;
644
+ this._sequenceNodes[nodeIndex] = newNode;
645
+ for(var i = nodeIndex + 1, len = this._sequenceNodes.length; i < len; i++){
646
+ var node2 = this._sequenceNodes[i];
647
+ if (typeof node2 === "string") {
648
+ continue;
649
+ }
650
+ var newNode2 = _object_spread({}, node2);
651
+ newNode2.startIndex += difference;
652
+ newNode2.endIndex += difference;
653
+ this._sequenceNodes[i] = newNode2;
654
+ }
655
+ this._changeRef$.next(true);
656
+ }
657
+ },
658
+ {
659
+ /**
660
+ * When the cursor is on the right side of a formula token,
661
+ * you can add reference text to the formula by drawing a selection.
662
+ * @param index
663
+ * @param range
664
+ */ key: "insertSequenceRef",
665
+ value: function insertSequenceRef(index, refString) {
666
+ var refStringCount = refString.length;
667
+ var nodeIndex = this.getCurrentSequenceNodeIndex(index);
668
+ this._sequenceNodes.splice(nodeIndex, 0, {
669
+ token: refString,
670
+ startIndex: index,
671
+ endIndex: index + refStringCount - 1,
672
+ nodeType: import_engine_formula2.sequenceNodeType.REFERENCE
673
+ });
674
+ for(var i = nodeIndex + 1, len = this._sequenceNodes.length; i < len; i++){
675
+ var node = this._sequenceNodes[i];
676
+ if (typeof node === "string") {
677
+ continue;
678
+ }
679
+ var newNode = _object_spread({}, node);
680
+ newNode.startIndex += refStringCount;
681
+ newNode.endIndex += refStringCount;
682
+ this._sequenceNodes[i] = newNode;
683
+ }
684
+ this._changeRef$.next(true);
685
+ }
686
+ },
687
+ {
688
+ /**
689
+ * Insert a string at the cursor position in the text corresponding to the sequenceNodes.
690
+ * @param sequenceNodes
691
+ * @param index
692
+ * @param content
693
+ */ key: "insertSequenceString",
694
+ value: function insertSequenceString(index, content) {
695
+ var _this__sequenceNodes;
696
+ var nodeIndex = this.getCurrentSequenceNodeIndex(index);
697
+ var str = content.split("");
698
+ (_this__sequenceNodes = this._sequenceNodes).splice.apply(_this__sequenceNodes, [
699
+ nodeIndex,
700
+ 0
701
+ ].concat(_to_consumable_array(str)));
702
+ var contentCount = str.length;
703
+ for(var i = nodeIndex + contentCount, len = this._sequenceNodes.length; i < len; i++){
704
+ var node = this._sequenceNodes[i];
705
+ if (typeof node === "string") {
706
+ continue;
707
+ }
708
+ var newNode = _object_spread({}, node);
709
+ newNode.startIndex += contentCount;
710
+ newNode.endIndex += contentCount;
711
+ this._sequenceNodes[i] = newNode;
712
+ }
713
+ this._changeRef$.next(true);
714
+ }
715
+ },
716
+ {
717
+ key: "enableSelectionMoving",
718
+ value: function enableSelectionMoving() {
719
+ this._isSelectionMoving = true;
720
+ }
721
+ },
722
+ {
723
+ key: "disableSelectionMoving",
724
+ value: function disableSelectionMoving() {
725
+ this._isSelectionMoving = false;
726
+ }
727
+ },
728
+ {
729
+ key: "isSelectionMoving",
730
+ value: function isSelectionMoving() {
731
+ return this._isSelectionMoving;
732
+ }
733
+ },
734
+ {
735
+ key: "enableLockedSelectionChange",
736
+ value: function enableLockedSelectionChange() {
737
+ this._isLockedOnSelectionChangeRefString = true;
738
+ }
739
+ },
740
+ {
741
+ key: "disableLockedSelectionChange",
742
+ value: function disableLockedSelectionChange() {
743
+ this._isLockedOnSelectionChangeRefString = false;
744
+ }
745
+ },
746
+ {
747
+ key: "isLockedSelectionChange",
748
+ value: function isLockedSelectionChange() {
749
+ return this._isLockedOnSelectionChangeRefString;
750
+ }
751
+ },
752
+ {
753
+ key: "enableLockedSelectionInsert",
754
+ value: function enableLockedSelectionInsert() {
755
+ this._isLockedOnSelectionInsertRefString = true;
756
+ }
757
+ },
758
+ {
759
+ key: "disableLockedSelectionInsert",
760
+ value: function disableLockedSelectionInsert() {
761
+ this._isLockedOnSelectionInsertRefString = false;
762
+ }
763
+ },
764
+ {
765
+ key: "isLockedSelectionInsert",
766
+ value: function isLockedSelectionInsert() {
767
+ return this._isLockedOnSelectionInsertRefString;
768
+ }
769
+ }
770
+ ]);
771
+ return FormulaInputService;
772
+ }();
773
+ FormulaInputService = __decorateClass([
774
+ __decorateParam(0, (0, import_redi2.Inject)(import_engine_formula2.FormulaEngineService))
775
+ ], FormulaInputService);
776
+ var IFormulaInputService = (0, import_redi2.createIdentifier)("formula-ui.input-service");
777
+ // src/controllers/formula-input.controller.ts
778
+ var FormulaInputController = /*#__PURE__*/ function(_import_core3_Disposable) {
779
+ _inherits(FormulaInputController, _import_core3_Disposable);
780
+ var _super = _create_super(FormulaInputController);
781
+ function FormulaInputController(_commandService, _textSelectionRenderManager, _editorBridgeService, _formulaEngineService, _renderManagerService, _formulaInputService) {
782
+ _class_call_check(this, FormulaInputController);
783
+ var _this;
784
+ _this = _super.call(this);
785
+ _define_property(_assert_this_initialized(_this), "_userCursorMove", false);
786
+ _this._commandService = _commandService;
787
+ _this._textSelectionRenderManager = _textSelectionRenderManager;
788
+ _this._editorBridgeService = _editorBridgeService;
789
+ _this._formulaEngineService = _formulaEngineService;
790
+ _this._renderManagerService = _renderManagerService;
791
+ _this._formulaInputService = _formulaInputService;
792
+ _this._initialize();
793
+ return _this;
794
+ }
795
+ _create_class(FormulaInputController, [
796
+ {
797
+ key: "_initialize",
798
+ value: function _initialize() {
799
+ this._commandExecutedListener();
800
+ this._initialEditorInputChange();
801
+ this._userMouseListener();
802
+ this._inputFormulaListener();
803
+ }
804
+ },
805
+ {
806
+ key: "_initialEditorInputChange",
807
+ value: function _initialEditorInputChange() {
808
+ var _this = this;
809
+ this.disposeWithMe((0, import_core3.toDisposable)(this._textSelectionRenderManager.onInputBefore$.subscribe(function(param) {
810
+ var e = param === null || param === void 0 ? void 0 : param.event;
811
+ if (e == null) {
812
+ return;
813
+ }
814
+ if (e.which !== import_ui.KeyCode.F4) {
815
+ _this._userCursorMove = false;
816
+ }
817
+ })));
818
+ }
819
+ },
820
+ {
821
+ key: "_userMouseListener",
822
+ value: function _userMouseListener() {
823
+ var _this = this;
824
+ var editorObject = this._getEditorObject();
825
+ if (editorObject == null) {
826
+ return;
827
+ }
828
+ var documentComponent = editorObject.document;
829
+ this.disposeWithMe((0, import_core3.toDisposable)(documentComponent.onPointerDownObserver.add(function() {
830
+ _this._userCursorMove = true;
831
+ })));
832
+ }
833
+ },
834
+ {
835
+ key: "_inputFormulaListener",
836
+ value: function _inputFormulaListener() {
837
+ var _this = this;
838
+ this.disposeWithMe((0, import_core3.toDisposable)(this._formulaInputService.inputFormula$.subscribe(function(formulaString) {
839
+ var visibleState = _this._editorBridgeService.isVisible();
840
+ if (visibleState.visible === false) {
841
+ _this._editorBridgeService.changeVisible({
842
+ visible: true,
843
+ eventType: import_engine_render.DeviceInputEventType.Dblclick
844
+ });
845
+ }
846
+ var lastSequenceNodes = _this._formulaEngineService.buildSequenceNodes(formulaString) || [];
847
+ _this._formulaInputService.setSequenceNodes(lastSequenceNodes);
848
+ _this._formulaInputService.syncToEditor(formulaString.length - 1);
849
+ })));
850
+ }
851
+ },
852
+ {
853
+ key: "_changeRefString",
854
+ value: function _changeRefString() {
855
+ var activeRange = this._textSelectionRenderManager.getActiveRange();
856
+ if (activeRange == null) {
857
+ return;
858
+ }
859
+ var startOffset = activeRange.startOffset;
860
+ var strIndex = startOffset - 2;
861
+ var nodeIndex = this._formulaInputService.getCurrentSequenceNodeIndex(strIndex);
862
+ var node = this._formulaInputService.getCurrentSequenceNodeByIndex(nodeIndex);
863
+ if (node == null || typeof node === "string" || node.nodeType !== import_engine_formula3.sequenceNodeType.REFERENCE) {
864
+ return;
865
+ }
866
+ var tokenArray = node.token.split("!");
867
+ var token = node.token;
868
+ if (tokenArray.length > 1) {
869
+ token = tokenArray[tokenArray.length - 1];
870
+ }
871
+ var unitIDAndSheetName = "";
872
+ for(var i = 0, len = tokenArray.length; i < len - 1; i++){
873
+ unitIDAndSheetName += tokenArray[i];
874
+ }
875
+ var finalToken = token;
876
+ if (token.indexOf(import_engine_formula3.matchToken.COLON) > -1) {
877
+ if (!this._userCursorMove) {
878
+ finalToken = this._changeRangeRef(token);
879
+ } else {
880
+ var refStringSplit = token.split(import_engine_formula3.matchToken.COLON);
881
+ var prefix = refStringSplit[0];
882
+ var suffix = refStringSplit[1];
883
+ var relativeIndex = strIndex - node.startIndex;
884
+ if (relativeIndex <= prefix.length) {
885
+ finalToken = this._changeSingleRef(prefix) + import_engine_formula3.matchToken.COLON + suffix;
886
+ } else {
887
+ finalToken = prefix + import_engine_formula3.matchToken.COLON + this._changeSingleRef(suffix);
888
+ }
889
+ }
890
+ } else {
891
+ finalToken = this._changeSingleRef(token);
892
+ }
893
+ finalToken = unitIDAndSheetName + finalToken;
894
+ var difference = finalToken.length - node.token.length;
895
+ this._formulaInputService.updateSequenceRef(nodeIndex, finalToken);
896
+ this._formulaInputService.syncToEditor(strIndex + difference + 1);
897
+ }
898
+ },
899
+ {
900
+ key: "_changeRangeRef",
901
+ value: function _changeRangeRef(token) {
902
+ var range = (0, import_core3.deserializeRangeWithSheet)(token).range;
903
+ var resultToken = "";
904
+ if (range.startAbsoluteRefType === import_core3.AbsoluteRefType.NONE || range.startAbsoluteRefType == null) {
905
+ range.startAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
906
+ range.endAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
907
+ } else {
908
+ range.startAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
909
+ range.endAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
910
+ }
911
+ resultToken = (0, import_core3.serializeRange)(range);
912
+ return resultToken;
913
+ }
914
+ },
915
+ {
916
+ key: "_changeSingleRef",
917
+ value: function _changeSingleRef(token) {
918
+ var range = (0, import_core3.deserializeRangeWithSheet)(token).range;
919
+ var type = range.startAbsoluteRefType;
920
+ var resultToken = "";
921
+ if (type === import_core3.AbsoluteRefType.NONE || type == null) {
922
+ range.startAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
923
+ range.endAbsoluteRefType = import_core3.AbsoluteRefType.ALL;
924
+ } else if (type === import_core3.AbsoluteRefType.ALL) {
925
+ range.startAbsoluteRefType = import_core3.AbsoluteRefType.ROW;
926
+ range.endAbsoluteRefType = import_core3.AbsoluteRefType.ROW;
927
+ } else if (type === import_core3.AbsoluteRefType.ROW) {
928
+ range.startAbsoluteRefType = import_core3.AbsoluteRefType.COLUMN;
929
+ range.endAbsoluteRefType = import_core3.AbsoluteRefType.COLUMN;
930
+ } else {
931
+ range.startAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
932
+ range.endAbsoluteRefType = import_core3.AbsoluteRefType.NONE;
933
+ }
934
+ resultToken = (0, import_core3.serializeRange)(range);
935
+ return resultToken;
936
+ }
937
+ },
938
+ {
939
+ key: "_commandExecutedListener",
940
+ value: function _commandExecutedListener() {
941
+ var _this = this;
942
+ var updateCommandList = [
943
+ ReferenceAbsoluteOperation.id
944
+ ];
945
+ this.disposeWithMe(this._commandService.onCommandExecuted(function(command) {
946
+ if (!updateCommandList.includes(command.id)) {
947
+ return;
948
+ }
949
+ _this._changeRefString();
950
+ }));
951
+ }
952
+ },
953
+ {
954
+ key: "_getEditorObject",
955
+ value: function _getEditorObject() {
956
+ return (0, import_sheets_ui2.getEditorObject)(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
957
+ }
958
+ }
959
+ ]);
960
+ return FormulaInputController;
961
+ }(import_core3.Disposable);
962
+ FormulaInputController = __decorateClass([
963
+ (0, import_core3.OnLifecycle)(import_core3.LifecycleStages.Steady, FormulaInputController),
964
+ __decorateParam(0, import_core3.ICommandService),
965
+ __decorateParam(1, import_engine_render.ITextSelectionRenderManager),
966
+ __decorateParam(2, (0, import_redi3.Inject)(import_sheets_ui2.IEditorBridgeService)),
967
+ __decorateParam(3, (0, import_redi3.Inject)(import_engine_formula3.FormulaEngineService)),
968
+ __decorateParam(4, import_engine_render.IRenderManagerService),
969
+ __decorateParam(5, IFormulaInputService)
970
+ ], FormulaInputController);
971
+ // src/controllers/formula-ui.controller.ts
972
+ var import_core15 = require("@univerjs/core");
973
+ var import_ui6 = require("@univerjs/ui");
974
+ var import_redi6 = require("@wendellhu/redi");
975
+ var import_react_bindings6 = require("@wendellhu/redi/react-bindings");
976
+ // src/commands/commands/insert-function.command.ts
977
+ var import_core4 = require("@univerjs/core");
978
+ var import_sheets = require("@univerjs/sheets");
979
+ var InsertFunctionCommand = {
980
+ id: "formula-ui.command.insert-function",
981
+ type: import_core4.CommandType.COMMAND,
982
+ handler: function() {
983
+ var _ref = _async_to_generator(function(accessor, params) {
984
+ var list, commandService, cellMatrix, setRangeValuesParams;
985
+ return _ts_generator(this, function(_state) {
986
+ list = params.list;
987
+ commandService = accessor.get(import_core4.ICommandService);
988
+ cellMatrix = new import_core4.ObjectMatrix();
989
+ list.forEach(function(item) {
990
+ var range = item.range, primary = item.primary, formula = item.formula;
991
+ var row = primary.row, column = primary.column;
992
+ var formulaId = import_core4.Tools.generateRandomId(6);
993
+ cellMatrix.setValue(row, column, {
994
+ f: formula,
995
+ si: formulaId
996
+ });
997
+ var startRow = range.startRow, startColumn = range.startColumn, endRow = range.endRow, endColumn = range.endColumn;
998
+ for(var i = startRow; i <= endRow; i++){
999
+ for(var j = startColumn; j <= endColumn; j++){
1000
+ if (i !== row || j !== column) {
1001
+ cellMatrix.setValue(i, j, {
1002
+ si: formulaId
1003
+ });
1004
+ }
1005
+ }
1006
+ }
1007
+ });
1008
+ setRangeValuesParams = {
1009
+ value: cellMatrix.getData()
1010
+ };
1011
+ return [
1012
+ 2,
1013
+ commandService.executeCommand(import_sheets.SetRangeValuesCommand.id, setRangeValuesParams)
1014
+ ];
1015
+ });
1016
+ });
1017
+ return function(accessor, params) {
1018
+ return _ref.apply(this, arguments);
1019
+ };
1020
+ }()
1021
+ };
1022
+ // src/commands/operations/editor-formula.operation.ts
1023
+ var import_core5 = require("@univerjs/core");
1024
+ var SelectEditorFormulaOperation = {
1025
+ id: "formula-ui.operation.select-editor-formula",
1026
+ type: import_core5.CommandType.OPERATION,
1027
+ handler: function(accessor, params) {
1028
+ return(// const { eventType, keycode } = params;
1029
+ // const formulaPromptService = accessor.get(IFormulaPromptService);
1030
+ // const editorBridgeService = accessor.get(IEditorBridgeService);
1031
+ // switch (keycode) {
1032
+ // case KeyCode.ARROW_DOWN:
1033
+ // formulaPromptService.navigate({ direction: Direction.DOWN });
1034
+ // break;
1035
+ // case KeyCode.ARROW_UP:
1036
+ // formulaPromptService.navigate({ direction: Direction.UP });
1037
+ // break;
1038
+ // // case KeyCode.ENTER:
1039
+ // // case KeyCode.TAB:
1040
+ // // if (formulaPromptService.isSearching()) {
1041
+ // // formulaPromptService.accept(true);
1042
+ // // } else {
1043
+ // // const editorBridgeParameters = {
1044
+ // // visible: false,
1045
+ // // eventType,
1046
+ // // keycode,
1047
+ // // };
1048
+ // // editorBridgeService.changeVisible(editorBridgeParameters);
1049
+ // // }
1050
+ // // break;
1051
+ // default:
1052
+ // break;
1053
+ // }
1054
+ true);
1055
+ }
1056
+ };
1057
+ // src/commands/operations/help-function.operation.ts
1058
+ var import_core6 = require("@univerjs/core");
1059
+ // src/services/prompt.service.ts
1060
+ var import_redi4 = require("@wendellhu/redi");
1061
+ var import_rxjs2 = require("rxjs");
1062
+ var IFormulaPromptService = (0, import_redi4.createIdentifier)("formula-ui.prompt-service");
1063
+ var FormulaPromptService = /*#__PURE__*/ function() {
1064
+ function FormulaPromptService() {
1065
+ _class_call_check(this, FormulaPromptService);
1066
+ _define_property(this, "_search$", new import_rxjs2.Subject());
1067
+ _define_property(this, "_help$", new import_rxjs2.Subject());
1068
+ _define_property(this, "_navigate$", new import_rxjs2.Subject());
1069
+ _define_property(this, "_accept$", new import_rxjs2.Subject());
1070
+ _define_property(this, "_acceptFormulaName$", new import_rxjs2.Subject());
1071
+ _define_property(this, "search$", this._search$.asObservable());
1072
+ _define_property(this, "help$", this._help$.asObservable());
1073
+ _define_property(this, "navigate$", this._navigate$.asObservable());
1074
+ _define_property(this, "accept$", this._accept$.asObservable());
1075
+ _define_property(this, "acceptFormulaName$", this._acceptFormulaName$.asObservable());
1076
+ _define_property(this, "_searching", false);
1077
+ _define_property(this, "_helping", false);
1078
+ _define_property(this, "_isInsertRefString", false);
1079
+ }
1080
+ _create_class(FormulaPromptService, [
1081
+ {
1082
+ key: "dispose",
1083
+ value: function dispose() {
1084
+ this._search$.complete();
1085
+ this._help$.complete();
1086
+ this._navigate$.complete();
1087
+ this._accept$.complete();
1088
+ this._acceptFormulaName$.complete();
1089
+ }
1090
+ },
1091
+ {
1092
+ key: "search",
1093
+ value: function search(param) {
1094
+ this._searching = param.visible;
1095
+ this._search$.next(param);
1096
+ }
1097
+ },
1098
+ {
1099
+ key: "isSearching",
1100
+ value: function isSearching() {
1101
+ return this._searching;
1102
+ }
1103
+ },
1104
+ {
1105
+ key: "help",
1106
+ value: function help(param) {
1107
+ this._helping = param.visible;
1108
+ this._help$.next(param);
1109
+ }
1110
+ },
1111
+ {
1112
+ key: "isHelping",
1113
+ value: function isHelping() {
1114
+ return this._helping;
1115
+ }
1116
+ },
1117
+ {
1118
+ key: "navigate",
1119
+ value: function navigate(param) {
1120
+ this._navigate$.next(param);
1121
+ }
1122
+ },
1123
+ {
1124
+ key: "accept",
1125
+ value: function accept(param) {
1126
+ this._accept$.next(param);
1127
+ }
1128
+ },
1129
+ {
1130
+ key: "acceptFormulaName",
1131
+ value: function acceptFormulaName(param) {
1132
+ this._acceptFormulaName$.next(param);
1133
+ }
1134
+ }
1135
+ ]);
1136
+ return FormulaPromptService;
1137
+ }();
1138
+ // src/commands/operations/help-function.operation.ts
1139
+ var HelpFunctionOperation = {
1140
+ id: "formula-ui.operation.help-function",
1141
+ type: import_core6.CommandType.OPERATION,
1142
+ handler: function() {
1143
+ var _ref = _async_to_generator(function(accessor, params) {
1144
+ var promptService;
1145
+ return _ts_generator(this, function(_state) {
1146
+ promptService = accessor.get(IFormulaPromptService);
1147
+ promptService.help(params);
1148
+ return [
1149
+ 2,
1150
+ true
1151
+ ];
1152
+ });
1153
+ });
1154
+ return function(accessor, params) {
1155
+ return _ref.apply(this, arguments);
1156
+ };
1157
+ }()
1158
+ };
1159
+ // src/commands/operations/insert-function.operation.ts
1160
+ var import_core7 = require("@univerjs/core");
1161
+ var import_sheets2 = require("@univerjs/sheets");
1162
+ var InsertFunctionOperation = {
1163
+ id: "formula-ui.operation.insert-function",
1164
+ type: import_core7.CommandType.OPERATION,
1165
+ handler: function() {
1166
+ var _ref = _async_to_generator(function(accessor, params) {
1167
+ var selectionManagerService, formulaInputService, currentSelections, univerInstanceService, cellMatrix, value, commandService, list;
1168
+ return _ts_generator(this, function(_state) {
1169
+ selectionManagerService = accessor.get(import_sheets2.SelectionManagerService);
1170
+ formulaInputService = accessor.get(IFormulaInputService);
1171
+ currentSelections = selectionManagerService.getSelections();
1172
+ if (!currentSelections || !currentSelections.length) {
1173
+ return [
1174
+ 2,
1175
+ false
1176
+ ];
1177
+ }
1178
+ univerInstanceService = accessor.get(import_core7.IUniverInstanceService);
1179
+ cellMatrix = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix();
1180
+ value = params.value;
1181
+ commandService = accessor.get(import_core7.ICommandService);
1182
+ list = [];
1183
+ currentSelections.some(function(selection) {
1184
+ var range = selection.range, primary = selection.primary;
1185
+ var _primary_actualRow;
1186
+ var row = (_primary_actualRow = primary === null || primary === void 0 ? void 0 : primary.actualRow) !== null && _primary_actualRow !== void 0 ? _primary_actualRow : range.startRow;
1187
+ var _primary_actualColumn;
1188
+ var column = (_primary_actualColumn = primary === null || primary === void 0 ? void 0 : primary.actualColumn) !== null && _primary_actualColumn !== void 0 ? _primary_actualColumn : range.startColumn;
1189
+ var refRange = findRefRange(cellMatrix, row, column);
1190
+ if (!refRange) {
1191
+ formulaInputService.inputFormula("=".concat(value, "("));
1192
+ return true;
1193
+ }
1194
+ var rangeString = (0, import_core7.serializeRange)(refRange);
1195
+ var formulaString = "=".concat(value, "(").concat(rangeString, ")");
1196
+ list.push({
1197
+ range: range,
1198
+ primary: {
1199
+ row: row,
1200
+ column: column
1201
+ },
1202
+ formula: formulaString
1203
+ });
1204
+ return false;
1205
+ });
1206
+ if (list.length === 0) return [
1207
+ 2,
1208
+ false
1209
+ ];
1210
+ return [
1211
+ 2,
1212
+ commandService.executeCommand(InsertFunctionCommand.id, {
1213
+ list: list
1214
+ })
1215
+ ];
1216
+ });
1217
+ });
1218
+ return function(accessor, params) {
1219
+ return _ref.apply(this, arguments);
1220
+ };
1221
+ }()
1222
+ };
1223
+ function findRefRange(cellMatrix, row, column) {
1224
+ var startRow = findStartRow(cellMatrix, row, column);
1225
+ if (startRow !== row) {
1226
+ return {
1227
+ startRow: startRow,
1228
+ endRow: row - 1,
1229
+ startColumn: column,
1230
+ endColumn: column
1231
+ };
1232
+ }
1233
+ var startColumn = findStartColumn(cellMatrix, row, column);
1234
+ if (startColumn !== column) {
1235
+ return {
1236
+ startRow: row,
1237
+ endRow: row,
1238
+ startColumn: startColumn,
1239
+ endColumn: column - 1
1240
+ };
1241
+ }
1242
+ return null;
1243
+ }
1244
+ function findStartRow(cellMatrix, row, column) {
1245
+ var isFirstNumber = false;
1246
+ if (row === 0) return row;
1247
+ for(var r = row - 1; r >= 0; r--){
1248
+ var cell = cellMatrix.getValue(r, column);
1249
+ if (isNumberCell(cell) && !isFirstNumber) {
1250
+ if (r === 0) return 0;
1251
+ isFirstNumber = true;
1252
+ } else if (isFirstNumber && !isNumberCell(cell)) {
1253
+ return r + 1;
1254
+ } else if (isFirstNumber && r === 0) {
1255
+ return 0;
1256
+ }
1257
+ }
1258
+ return row;
1259
+ }
1260
+ function findStartColumn(cellMatrix, row, column) {
1261
+ var isFirstNumber = false;
1262
+ if (column === 0) return column;
1263
+ for(var c = column - 1; c >= 0; c--){
1264
+ var cell = cellMatrix.getValue(row, c);
1265
+ if (isNumberCell(cell) && !isFirstNumber) {
1266
+ if (c === 0) return 0;
1267
+ isFirstNumber = true;
1268
+ } else if (isFirstNumber && !isNumberCell(cell)) {
1269
+ return c + 1;
1270
+ } else if (isFirstNumber && c === 0) {
1271
+ return 0;
1272
+ }
1273
+ }
1274
+ return column;
1275
+ }
1276
+ function isNumberCell(cell) {
1277
+ return cell && (import_core7.Tools.isStringNumber(cell.v) || (0, import_core7.getCellValueType)(cell) === import_core7.CellValueType.NUMBER);
1278
+ }
1279
+ // src/commands/operations/more-functions.operation.ts
1280
+ var import_core8 = require("@univerjs/core");
1281
+ var import_ui2 = require("@univerjs/ui");
1282
+ // src/views/more-functions/interface.ts
1283
+ var MORE_FUNCTIONS_COMPONENT = "".concat(FORMULA_UI_PLUGIN_NAME, "_MORE_FUNCTIONS_COMPONENT");
1284
+ // src/commands/operations/more-functions.operation.ts
1285
+ var MoreFunctionsOperation = {
1286
+ id: "formula-ui.operation.more-functions",
1287
+ type: import_core8.CommandType.OPERATION,
1288
+ handler: function() {
1289
+ var _ref = _async_to_generator(function(accessor) {
1290
+ var sidebarService;
1291
+ return _ts_generator(this, function(_state) {
1292
+ sidebarService = accessor.get(import_ui2.ISidebarService);
1293
+ sidebarService.open({
1294
+ header: {
1295
+ title: "formula.insert.tooltip"
1296
+ },
1297
+ children: {
1298
+ label: MORE_FUNCTIONS_COMPONENT
1299
+ }
1300
+ });
1301
+ return [
1302
+ 2,
1303
+ true
1304
+ ];
1305
+ });
1306
+ });
1307
+ return function(accessor) {
1308
+ return _ref.apply(this, arguments);
1309
+ };
1310
+ }()
1311
+ };
1312
+ // src/commands/operations/search-function.operation.ts
1313
+ var import_core9 = require("@univerjs/core");
1314
+ var SearchFunctionOperation = {
1315
+ id: "formula-ui.operation.search-function",
1316
+ type: import_core9.CommandType.OPERATION,
1317
+ handler: function() {
1318
+ var _ref = _async_to_generator(function(accessor, params) {
1319
+ var promptService;
1320
+ return _ts_generator(this, function(_state) {
1321
+ promptService = accessor.get(IFormulaPromptService);
1322
+ promptService.search(params);
1323
+ return [
1324
+ 2,
1325
+ true
1326
+ ];
1327
+ });
1328
+ });
1329
+ return function(accessor, params) {
1330
+ return _ref.apply(this, arguments);
1331
+ };
1332
+ }()
1333
+ };
1334
+ // src/views/FormulaPromptContainer.tsx
1335
+ var import_react4 = __toESM(require("react"));
1336
+ // src/views/prompt/error-function/error-function.tsx
1337
+ var import_sheets_ui3 = require("@univerjs/sheets-ui");
1338
+ var import_react_bindings = require("@wendellhu/redi/react-bindings");
1339
+ var import_react = __toESM(require("react"));
1340
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/prompt/error-function/index.module.less
1341
+ var index_module_default = {
1342
+ "formulaErrorFunction": "univer-formula-error-function"
1343
+ };
1344
+ // src/views/prompt/error-function/error-function.tsx
1345
+ function ErrorFunction() {
1346
+ var _ref = _sliced_to_array((0, import_react.useState)(false), 2), visible = _ref[0], setVisible = _ref[1];
1347
+ var _ref1 = _sliced_to_array((0, import_react.useState)({
1348
+ left: 0,
1349
+ top: 0
1350
+ }), 2), position = _ref1[0], setPosition = _ref1[1];
1351
+ var promptService = (0, import_react_bindings.useDependency)(IFormulaPromptService);
1352
+ var cellEditorManagerService = (0, import_react_bindings.useDependency)(import_sheets_ui3.ICellEditorManagerService);
1353
+ (0, import_react.useEffect)(function() {
1354
+ var subscription = promptService.help$.subscribe(function(params) {
1355
+ var selection = cellEditorManagerService.getState();
1356
+ if (!selection) return;
1357
+ var visible2 = params.visible;
1358
+ if (!visible2) {
1359
+ setVisible(visible2);
1360
+ return;
1361
+ }
1362
+ var _selection_endX = selection.endX, endX = _selection_endX === void 0 ? 0 : _selection_endX, _selection_startY = selection.startY, startY = _selection_startY === void 0 ? 0 : _selection_startY;
1363
+ setPosition({
1364
+ left: endX,
1365
+ top: startY
1366
+ });
1367
+ setVisible(visible2);
1368
+ });
1369
+ return function() {
1370
+ subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
1371
+ };
1372
+ }, []);
1373
+ return visible ? /* @__PURE__ */ import_react.default.createElement("div", {
1374
+ className: index_module_default.formulaErrorFunction,
1375
+ style: {
1376
+ left: position.left,
1377
+ top: position.top
1378
+ }
1379
+ }) : null;
1380
+ }
1381
+ // src/views/prompt/help-function/HelpFunction.tsx
1382
+ var import_core10 = require("@univerjs/core");
1383
+ var import_design = require("@univerjs/design");
1384
+ var import_icons = require("@univerjs/icons");
1385
+ var import_sheets_ui4 = require("@univerjs/sheets-ui");
1386
+ var import_react_bindings2 = require("@wendellhu/redi/react-bindings");
1387
+ var import_react2 = __toESM(require("react"));
1388
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/prompt/help-function/index.module.less
1389
+ var index_module_default2 = {
1390
+ "formulaHelpFunction": "univer-formula-help-function",
1391
+ "formulaHelpFunctionTitle": "univer-formula-help-function-title",
1392
+ "formulaHelpFunctionTitleIcons": "univer-formula-help-function-title-icons",
1393
+ "formulaHelpFunctionTitleIcon": "univer-formula-help-function-title-icon",
1394
+ "formulaHelpFunctionContent": "univer-formula-help-function-content",
1395
+ "formulaHelpFunctionContentInner": "univer-formula-help-function-content-inner",
1396
+ "formulaHelpFunctionContentParams": "univer-formula-help-function-content-params",
1397
+ "formulaHelpFunctionContentParamsTitle": "univer-formula-help-function-content-params-title",
1398
+ "formulaHelpFunctionContentParamsDetail": "univer-formula-help-function-content-params-detail",
1399
+ "formulaHelpFunctionActive": "univer-formula-help-function-active",
1400
+ "formulaHelpDecorator": "univer-formula-help-decorator"
1401
+ };
1402
+ // src/views/prompt/help-function/HelpFunction.tsx
1403
+ function HelpFunction() {
1404
+ var _ref = _sliced_to_array((0, import_react2.useState)(false), 2), visible = _ref[0], setVisible = _ref[1];
1405
+ var _ref1 = _sliced_to_array((0, import_react2.useState)(true), 2), contentVisible = _ref1[0], setContentVisible = _ref1[1];
1406
+ var _ref2 = _sliced_to_array((0, import_react2.useState)(true), 2), helpVisible = _ref2[0], setHelpVisible = _ref2[1];
1407
+ var _ref3 = _sliced_to_array((0, import_react2.useState)(0), 2), paramIndex = _ref3[0], setParamIndex = _ref3[1];
1408
+ var _ref4 = _sliced_to_array((0, import_react2.useState)([
1409
+ 0,
1410
+ 0
1411
+ ]), 2), offset = _ref4[0], setOffset = _ref4[1];
1412
+ var _ref5 = _sliced_to_array((0, import_react2.useState)({
1413
+ left: 0,
1414
+ top: 0
1415
+ }), 2), decoratorPosition = _ref5[0], setDecoratorPosition = _ref5[1];
1416
+ var _ref6 = _sliced_to_array((0, import_react2.useState)(null), 2), functionInfo = _ref6[0], setFunctionInfo = _ref6[1];
1417
+ var promptService = (0, import_react_bindings2.useDependency)(IFormulaPromptService);
1418
+ var cellEditorManagerService = (0, import_react_bindings2.useDependency)(import_sheets_ui4.ICellEditorManagerService);
1419
+ var localeService = (0, import_react_bindings2.useDependency)(import_core10.LocaleService);
1420
+ var formulaEditorManagerService = (0, import_react_bindings2.useDependency)(import_sheets_ui4.IFormulaEditorManagerService);
1421
+ var contextService = (0, import_react_bindings2.useDependency)(import_core10.IContextService);
1422
+ var required = localeService.t("formula.prompt.required");
1423
+ var optional = localeService.t("formula.prompt.optional");
1424
+ (0, import_react2.useEffect)(function() {
1425
+ var subscription = promptService.help$.subscribe(function(params) {
1426
+ var visible2 = params.visible, paramIndex2 = params.paramIndex, functionInfo2 = params.functionInfo;
1427
+ if (!visible2) {
1428
+ setVisible(visible2);
1429
+ return;
1430
+ }
1431
+ var isFocusFormulaEditor = contextService.getContextValue(import_core10.FOCUSING_FORMULA_EDITOR);
1432
+ var position = isFocusFormulaEditor ? formulaEditorManagerService.getPosition() : cellEditorManagerService.getRect();
1433
+ if (position == null) {
1434
+ return;
1435
+ }
1436
+ var left = position.left, top = position.top, height = position.height;
1437
+ var localeInfo = {
1438
+ functionName: functionInfo2.functionName,
1439
+ functionType: functionInfo2.functionType,
1440
+ description: localeService.t(functionInfo2.description),
1441
+ abstract: localeService.t(functionInfo2.abstract),
1442
+ functionParameter: functionInfo2.functionParameter.map(function(item) {
1443
+ return {
1444
+ name: localeService.t(item.name),
1445
+ detail: localeService.t(item.detail),
1446
+ example: item.example,
1447
+ require: item.require,
1448
+ repeat: item.repeat
1449
+ };
1450
+ })
1451
+ };
1452
+ setOffset([
1453
+ left,
1454
+ top + height
1455
+ ]);
1456
+ setParamIndex(paramIndex2);
1457
+ setFunctionInfo(localeInfo);
1458
+ setDecoratorPosition({
1459
+ left: left,
1460
+ top: top
1461
+ });
1462
+ setVisible(visible2);
1463
+ });
1464
+ return function() {
1465
+ subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
1466
+ };
1467
+ }, []);
1468
+ function handleSwitchActive(paramIndex2) {
1469
+ setParamIndex(paramIndex2);
1470
+ }
1471
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, helpVisible ? /* @__PURE__ */ import_react2.default.createElement(import_design.Popup, {
1472
+ visible: visible,
1473
+ offset: offset
1474
+ }, functionInfo ? /* @__PURE__ */ import_react2.default.createElement("div", {
1475
+ className: index_module_default2.formulaHelpFunction
1476
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
1477
+ className: index_module_default2.formulaHelpFunctionTitle
1478
+ }, /* @__PURE__ */ import_react2.default.createElement(Help, {
1479
+ prefix: functionInfo.functionName,
1480
+ value: functionInfo.functionParameter,
1481
+ active: paramIndex,
1482
+ onClick: handleSwitchActive
1483
+ }), /* @__PURE__ */ import_react2.default.createElement("div", {
1484
+ className: index_module_default2.formulaHelpFunctionTitleIcons
1485
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
1486
+ className: index_module_default2.formulaHelpFunctionTitleIcon,
1487
+ style: {
1488
+ transform: contentVisible ? "rotateZ(-90deg)" : "rotateZ(90deg)"
1489
+ },
1490
+ onClick: function() {
1491
+ return setContentVisible(!contentVisible);
1492
+ }
1493
+ }, /* @__PURE__ */ import_react2.default.createElement(import_icons.MoreSingle, null)), /* @__PURE__ */ import_react2.default.createElement("div", {
1494
+ className: index_module_default2.formulaHelpFunctionTitleIcon,
1495
+ onClick: function() {
1496
+ return setHelpVisible(!helpVisible);
1497
+ }
1498
+ }, /* @__PURE__ */ import_react2.default.createElement(import_icons.CloseSingle, null)))), /* @__PURE__ */ import_react2.default.createElement("div", {
1499
+ className: index_module_default2.formulaHelpFunctionContent,
1500
+ style: {
1501
+ height: contentVisible ? "unset" : 0
1502
+ }
1503
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
1504
+ className: index_module_default2.formulaHelpFunctionContentInner
1505
+ }, /* @__PURE__ */ import_react2.default.createElement(Params, {
1506
+ title: localeService.t("formula.prompt.helpExample"),
1507
+ value: "".concat(functionInfo.functionName, "(").concat(functionInfo.functionParameter.map(function(item) {
1508
+ return item.example;
1509
+ }).join(","), ")")
1510
+ }), /* @__PURE__ */ import_react2.default.createElement(Params, {
1511
+ title: localeService.t("formula.prompt.helpAbstract"),
1512
+ value: functionInfo.description
1513
+ }), functionInfo && functionInfo.functionParameter && functionInfo.functionParameter.map(function(item, i) {
1514
+ return /* @__PURE__ */ import_react2.default.createElement(Params, {
1515
+ key: i,
1516
+ className: paramIndex === i ? index_module_default2.formulaHelpFunctionActive : "",
1517
+ title: item.name,
1518
+ value: "".concat(item.require ? required : optional, " ").concat(item.detail)
1519
+ });
1520
+ })))) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null)) : visible ? /* @__PURE__ */ import_react2.default.createElement("div", {
1521
+ className: index_module_default2.formulaHelpDecorator,
1522
+ onClick: function() {
1523
+ return setHelpVisible(!helpVisible);
1524
+ },
1525
+ style: {
1526
+ left: decoratorPosition.left - 24,
1527
+ top: decoratorPosition.top
1528
+ }
1529
+ }, /* @__PURE__ */ import_react2.default.createElement(import_icons.DetailsSingle, null)) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null));
1530
+ }
1531
+ var Params = function(props) {
1532
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
1533
+ className: index_module_default2.formulaHelpFunctionContentParams
1534
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
1535
+ className: "".concat(index_module_default2.formulaHelpFunctionContentParamsTitle, " ").concat(props.className)
1536
+ }, props.title), /* @__PURE__ */ import_react2.default.createElement("div", {
1537
+ className: index_module_default2.formulaHelpFunctionContentParamsDetail
1538
+ }, props.value));
1539
+ };
1540
+ var Help = function(props) {
1541
+ var prefix = props.prefix, value = props.value, active = props.active, onClick = props.onClick;
1542
+ return /* @__PURE__ */ import_react2.default.createElement("div", null, /* @__PURE__ */ import_react2.default.createElement("span", null, prefix, "("), value && value.map(function(item, i) {
1543
+ return(// TODO@Dushusir: more params needs to be active
1544
+ /* @__PURE__ */ import_react2.default.createElement("span", {
1545
+ key: i
1546
+ }, /* @__PURE__ */ import_react2.default.createElement("span", {
1547
+ className: active === i ? index_module_default2.formulaHelpFunctionActive : "",
1548
+ onClick: function() {
1549
+ return onClick(i);
1550
+ }
1551
+ }, item.repeat ? "[".concat(item.name, ",...]") : item.name), i === value.length - 1 ? "" : ","));
1552
+ }), ")");
1553
+ };
1554
+ // src/views/prompt/search-function/SearchFunction.tsx
1555
+ var import_core11 = require("@univerjs/core");
1556
+ var import_design2 = require("@univerjs/design");
1557
+ var import_sheets_ui5 = require("@univerjs/sheets-ui");
1558
+ var import_react_bindings3 = require("@wendellhu/redi/react-bindings");
1559
+ var import_react3 = __toESM(require("react"));
1560
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/prompt/search-function/index.module.less
1561
+ var index_module_default3 = {
1562
+ "formulaSearchFunction": "univer-formula-search-function",
1563
+ "formulaSearchFunctionItem": "univer-formula-search-function-item",
1564
+ "formulaSearchFunctionItemName": "univer-formula-search-function-item-name",
1565
+ "formulaSearchFunctionItemNameLight": "univer-formula-search-function-item-name-light",
1566
+ "formulaSearchFunctionItemDesc": "univer-formula-search-function-item-desc",
1567
+ "formulaSearchFunctionItemActive": "univer-formula-search-function-item-active"
1568
+ };
1569
+ // src/views/prompt/search-function/SearchFunction.tsx
1570
+ function SearchFunction() {
1571
+ var _ref = _sliced_to_array((0, import_react3.useState)(false), 2), visible = _ref[0], setVisible = _ref[1];
1572
+ var _ref1 = _sliced_to_array((0, import_react3.useState)(0), 2), active = _ref1[0], setActive = _ref1[1];
1573
+ var _ref2 = _sliced_to_array((0, import_react3.useState)([
1574
+ 0,
1575
+ 0
1576
+ ]), 2), offset = _ref2[0], setOffset = _ref2[1];
1577
+ var _ref3 = _sliced_to_array((0, import_react3.useState)([]), 2), searchList = _ref3[0], setSearchList = _ref3[1];
1578
+ var _ref4 = _sliced_to_array((0, import_react3.useState)(""), 2), searchText = _ref4[0], setSearchText = _ref4[1];
1579
+ var promptService = (0, import_react_bindings3.useDependency)(IFormulaPromptService);
1580
+ var cellEditorManagerService = (0, import_react_bindings3.useDependency)(import_sheets_ui5.ICellEditorManagerService);
1581
+ var formulaEditorManagerService = (0, import_react_bindings3.useDependency)(import_sheets_ui5.IFormulaEditorManagerService);
1582
+ var contextService = (0, import_react_bindings3.useDependency)(import_core11.IContextService);
1583
+ (0, import_react3.useEffect)(function() {
1584
+ var updatedSearchList = [];
1585
+ var updatedActive = 0;
1586
+ var subscribeSearch = promptService.search$.subscribe(function(params) {
1587
+ var visible2 = params.visible, searchText2 = params.searchText, searchList2 = params.searchList;
1588
+ if (!visible2) {
1589
+ setVisible(visible2);
1590
+ return;
1591
+ }
1592
+ var isFocusFormulaEditor = contextService.getContextValue(import_core11.FOCUSING_FORMULA_EDITOR);
1593
+ var position = isFocusFormulaEditor ? formulaEditorManagerService.getPosition() : cellEditorManagerService.getRect();
1594
+ if (position == null) {
1595
+ return;
1596
+ }
1597
+ var left = position.left, top = position.top, height = position.height;
1598
+ setSearchText(searchText2);
1599
+ setSearchList(searchList2);
1600
+ updatedSearchList = searchList2;
1601
+ setOffset([
1602
+ left,
1603
+ top + height
1604
+ ]);
1605
+ setVisible(visible2);
1606
+ setActive(0);
1607
+ });
1608
+ var subscribeNavigate = promptService.navigate$.subscribe(function(params) {
1609
+ var direction = params.direction;
1610
+ if (direction === import_core11.Direction.UP) {
1611
+ var nextActive = updatedActive - 1;
1612
+ nextActive = nextActive < 0 ? updatedSearchList.length - 1 : nextActive;
1613
+ setActive(nextActive);
1614
+ updatedActive = nextActive;
1615
+ } else if (direction === import_core11.Direction.DOWN) {
1616
+ var nextActive1 = updatedActive + 1;
1617
+ nextActive1 = nextActive1 >= updatedSearchList.length ? 0 : nextActive1;
1618
+ setActive(nextActive1);
1619
+ updatedActive = nextActive1;
1620
+ }
1621
+ });
1622
+ var subscribeAccept = promptService.accept$.subscribe(function(params) {
1623
+ var functionName = updatedSearchList[updatedActive].name;
1624
+ promptService.acceptFormulaName(functionName);
1625
+ });
1626
+ return function() {
1627
+ subscribeSearch === null || subscribeSearch === void 0 ? void 0 : subscribeSearch.unsubscribe();
1628
+ subscribeNavigate === null || subscribeNavigate === void 0 ? void 0 : subscribeNavigate.unsubscribe();
1629
+ subscribeAccept === null || subscribeAccept === void 0 ? void 0 : subscribeAccept.unsubscribe();
1630
+ };
1631
+ }, []);
1632
+ function handleLiMouseEnter(index) {
1633
+ setActive(index);
1634
+ }
1635
+ function handleLiMouseLeave() {
1636
+ setActive(-1);
1637
+ }
1638
+ return /* @__PURE__ */ import_react3.default.createElement(import_design2.Popup, {
1639
+ visible: visible,
1640
+ offset: offset
1641
+ }, /* @__PURE__ */ import_react3.default.createElement("ul", {
1642
+ className: index_module_default3.formulaSearchFunction
1643
+ }, searchList.map(function(item, index) {
1644
+ return /* @__PURE__ */ import_react3.default.createElement("li", {
1645
+ key: index,
1646
+ className: active === index ? "".concat(index_module_default3.formulaSearchFunctionItem, " ").concat(index_module_default3.formulaSearchFunctionItemActive) : index_module_default3.formulaSearchFunctionItem,
1647
+ onMouseEnter: function() {
1648
+ return handleLiMouseEnter(index);
1649
+ },
1650
+ onMouseLeave: handleLiMouseLeave,
1651
+ onClick: function() {
1652
+ return promptService.acceptFormulaName(item.name);
1653
+ }
1654
+ }, /* @__PURE__ */ import_react3.default.createElement("span", {
1655
+ className: index_module_default3.formulaSearchFunctionItemName
1656
+ }, /* @__PURE__ */ import_react3.default.createElement("span", {
1657
+ className: index_module_default3.formulaSearchFunctionItemNameLight
1658
+ }, searchText), /* @__PURE__ */ import_react3.default.createElement("span", null, item.name.slice(searchText.length))), /* @__PURE__ */ import_react3.default.createElement("span", {
1659
+ className: index_module_default3.formulaSearchFunctionItemDesc
1660
+ }, item.desc));
1661
+ })));
1662
+ }
1663
+ // src/views/FormulaPromptContainer.tsx
1664
+ function RenderFormulaPromptContent() {
1665
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(SearchFunction, null), /* @__PURE__ */ import_react4.default.createElement(HelpFunction, null), /* @__PURE__ */ import_react4.default.createElement(ErrorFunction, null));
1666
+ }
1667
+ // src/views/more-functions/MoreFunctions.tsx
1668
+ var import_core14 = require("@univerjs/core");
1669
+ var import_design4 = require("@univerjs/design");
1670
+ var import_ui3 = require("@univerjs/ui");
1671
+ var import_react_bindings5 = require("@wendellhu/redi/react-bindings");
1672
+ var import_react9 = __toESM(require("react"));
1673
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/index.module.less
1674
+ var index_module_default4 = {
1675
+ "formulaMoreFunctions": "univer-formula-more-functions",
1676
+ "formulaMoreFunctionsOperation": "univer-formula-more-functions-operation"
1677
+ };
1678
+ // src/views/more-functions/input-params/InputParams.tsx
1679
+ var import_sheets_ui6 = require("@univerjs/sheets-ui");
1680
+ var import_react7 = __toESM(require("react"));
1681
+ // src/views/more-functions/function-help/FunctionHelp.tsx
1682
+ var import_react5 = __toESM(require("react"));
1683
+ function FunctionHelp(props) {
1684
+ var prefix = props.prefix, value = props.value;
1685
+ return /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("span", null, prefix, "("), value && value.map(function(item, i) {
1686
+ return /* @__PURE__ */ import_react5.default.createElement("span", {
1687
+ key: i
1688
+ }, /* @__PURE__ */ import_react5.default.createElement("span", null, item.repeat ? "[".concat(item.name, ",...]") : item.name), i === value.length - 1 ? "" : ",");
1689
+ }), ")");
1690
+ }
1691
+ // src/views/more-functions/function-params/FunctionParams.tsx
1692
+ var import_react6 = __toESM(require("react"));
1693
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/function-params/index.module.less
1694
+ var index_module_default5 = {
1695
+ "formulaFunctionParams": "univer-formula-function-params",
1696
+ "formulaFunctionParamsTitle": "univer-formula-function-params-title",
1697
+ "formulaFunctionParamsDetail": "univer-formula-function-params-detail"
1698
+ };
1699
+ // src/views/more-functions/function-params/FunctionParams.tsx
1700
+ function FunctionParams(props) {
1701
+ var className = props.className, value = props.value, title = props.title;
1702
+ return /* @__PURE__ */ import_react6.default.createElement("div", {
1703
+ className: index_module_default5.formulaFunctionParams
1704
+ }, /* @__PURE__ */ import_react6.default.createElement("div", {
1705
+ className: "".concat(index_module_default5.formulaFunctionParamsTitle, " ").concat(className)
1706
+ }, title), /* @__PURE__ */ import_react6.default.createElement("div", {
1707
+ className: index_module_default5.formulaFunctionParamsDetail
1708
+ }, value));
1709
+ }
1710
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/input-params/index.module.less
1711
+ var index_module_default6 = {
1712
+ "formulaInputParamsList": "univer-formula-input-params-list",
1713
+ "formulaInputParamsListItemName": "univer-formula-input-params-list-item-name",
1714
+ "formulaInputParamsListItemSelector": "univer-formula-input-params-list-item-selector"
1715
+ };
1716
+ // src/views/more-functions/input-params/InputParams.tsx
1717
+ function InputParams(props) {
1718
+ var functionInfo = props.functionInfo, onChange = props.onChange;
1719
+ if (!functionInfo) return null;
1720
+ var _ref = _sliced_to_array((0, import_react7.useState)([]), 2), params = _ref[0], setParams = _ref[1];
1721
+ var _ref1 = _sliced_to_array((0, import_react7.useState)(functionInfo.functionParameter), 2), functionParameter = _ref1[0], setFunctionParameter = _ref1[1];
1722
+ var _ref2 = _sliced_to_array((0, import_react7.useState)(-1), 2), activeIndex = _ref2[0], setActiveIndex = _ref2[1];
1723
+ function handleChange(range, paramIndex) {
1724
+ var newParams = _to_consumable_array(params);
1725
+ newParams[paramIndex] = range;
1726
+ setParams(newParams);
1727
+ onChange(newParams);
1728
+ }
1729
+ function handleActive(i) {
1730
+ if (i === functionParameter.length - 1 && functionParameter[i].repeat) {
1731
+ var newFunctionParameter = _to_consumable_array(functionParameter);
1732
+ newFunctionParameter.push(functionParameter[i]);
1733
+ setFunctionParameter(newFunctionParameter);
1734
+ }
1735
+ setActiveIndex(i);
1736
+ }
1737
+ return /* @__PURE__ */ import_react7.default.createElement("div", {
1738
+ className: index_module_default6.formulaInputParams
1739
+ }, /* @__PURE__ */ import_react7.default.createElement("div", {
1740
+ className: index_module_default6.formulaInputParamsList
1741
+ }, functionParameter.map(function(item, i) {
1742
+ return /* @__PURE__ */ import_react7.default.createElement("div", {
1743
+ key: i
1744
+ }, /* @__PURE__ */ import_react7.default.createElement("div", {
1745
+ className: index_module_default6.formulaInputParamsListItemName
1746
+ }, item.name), /* @__PURE__ */ import_react7.default.createElement("div", {
1747
+ className: index_module_default6.formulaInputParamsListItemSelector
1748
+ }, /* @__PURE__ */ import_react7.default.createElement(import_sheets_ui6.RangeSelector, {
1749
+ onChange: function(range) {
1750
+ return handleChange(range, i);
1751
+ },
1752
+ onActive: function() {
1753
+ return handleActive(i);
1754
+ }
1755
+ })));
1756
+ })), /* @__PURE__ */ import_react7.default.createElement("div", {
1757
+ className: index_module_default6.formulaInputParamsInfo
1758
+ }, /* @__PURE__ */ import_react7.default.createElement(FunctionParams, {
1759
+ title: activeIndex === -1 ? /* @__PURE__ */ import_react7.default.createElement(FunctionHelp, {
1760
+ prefix: functionInfo.functionName,
1761
+ value: functionParameter
1762
+ }) : functionParameter[activeIndex].name,
1763
+ value: activeIndex === -1 ? functionInfo.description : functionParameter[activeIndex].detail
1764
+ })));
1765
+ }
1766
+ // src/views/more-functions/select-function/SelectFunction.tsx
1767
+ var import_core13 = require("@univerjs/core");
1768
+ var import_design3 = require("@univerjs/design");
1769
+ var import_engine_formula7 = require("@univerjs/engine-formula");
1770
+ var import_icons2 = require("@univerjs/icons");
1771
+ var import_react_bindings4 = require("@wendellhu/redi/react-bindings");
1772
+ var import_react8 = __toESM(require("react"));
1773
+ // src/services/description.service.ts
1774
+ var import_core12 = require("@univerjs/core");
1775
+ var import_engine_formula6 = require("@univerjs/engine-formula");
1776
+ var import_redi5 = require("@wendellhu/redi");
1777
+ // src/services/function-list/array.ts
1778
+ var FUNCTION_LIST_ARRAY = [];
1779
+ // src/services/function-list/compatibility.ts
1780
+ var FUNCTION_LIST_COMPATIBILITY = [];
1781
+ // src/services/function-list/cube.ts
1782
+ var FUNCTION_LIST_CUBE = [];
1783
+ // src/services/function-list/database.ts
1784
+ var FUNCTION_LIST_DATABASE = [];
1785
+ // src/services/function-list/date.ts
1786
+ var FUNCTION_LIST_DATE = [];
1787
+ // src/services/function-list/engineering.ts
1788
+ var FUNCTION_LIST_ENGINEERING = [];
1789
+ // src/services/function-list/financial.ts
1790
+ var FUNCTION_LIST_FINANCIAL = [];
1791
+ // src/services/function-list/information.ts
1792
+ var FUNCTION_LIST_INFORMATION = [];
1793
+ // src/services/function-list/logical.ts
1794
+ var FUNCTION_LIST_LOGICAL = [];
1795
+ // src/services/function-list/lookup.ts
1796
+ var FUNCTION_LIST_LOOKUP = [];
1797
+ // src/services/function-list/math.ts
1798
+ var import_engine_formula4 = require("@univerjs/engine-formula");
1799
+ var import_formula = require("@univerjs/formula");
1800
+ var FUNCTION_LIST_MATH = [
1801
+ {
1802
+ functionName: import_engine_formula4.FUNCTION_NAMES.SUM,
1803
+ aliasFunctionName: "formula.functionList.SUM.aliasFunctionName",
1804
+ functionType: import_engine_formula4.FunctionType.Math,
1805
+ description: "formula.functionList.SUM.description",
1806
+ abstract: "formula.functionList.SUM.abstract",
1807
+ functionParameter: [
1808
+ {
1809
+ name: "formula.functionList.SUM.functionParameter.number1.name",
1810
+ detail: "formula.functionList.SUM.functionParameter.number1.detail",
1811
+ example: "A1:A20",
1812
+ require: 1,
1813
+ repeat: 0
1814
+ },
1815
+ {
1816
+ name: "formula.functionList.SUM.functionParameter.number2.name",
1817
+ detail: "formula.functionList.SUM.functionParameter.number2.detail",
1818
+ example: "B2:B10",
1819
+ require: 0,
1820
+ repeat: 1
1821
+ }
1822
+ ]
1823
+ },
1824
+ {
1825
+ functionName: import_formula.FUNCTION_NAMES_MATH.SUMIF,
1826
+ aliasFunctionName: "formula.functionList.SUMIF.aliasFunctionName",
1827
+ functionType: import_engine_formula4.FunctionType.Math,
1828
+ description: "formula.functionList.SUMIF.description",
1829
+ abstract: "formula.functionList.SUMIF.abstract",
1830
+ functionParameter: [
1831
+ {
1832
+ name: "formula.functionList.SUMIF.functionParameter.range.name",
1833
+ detail: "formula.functionList.SUMIF.functionParameter.range.detail",
1834
+ example: "A1:A20",
1835
+ require: 1,
1836
+ repeat: 0
1837
+ },
1838
+ {
1839
+ name: "formula.functionList.SUMIF.functionParameter.criteria.name",
1840
+ detail: "formula.functionList.SUMIF.functionParameter.criteria.detail",
1841
+ example: ">5",
1842
+ require: 1,
1843
+ repeat: 0
1844
+ },
1845
+ {
1846
+ name: "formula.functionList.SUMIF.functionParameter.sum_range.name",
1847
+ detail: "formula.functionList.SUMIF.functionParameter.sum_range.detail",
1848
+ example: "B1:B20",
1849
+ require: 0,
1850
+ repeat: 0
1851
+ }
1852
+ ]
1853
+ }
1854
+ ];
1855
+ // src/services/function-list/statistical.ts
1856
+ var import_engine_formula5 = require("@univerjs/engine-formula");
1857
+ var FUNCTION_LIST_STATISTICAL = [
1858
+ {
1859
+ functionName: import_engine_formula5.FUNCTION_NAMES.AVERAGE,
1860
+ aliasFunctionName: "formula.functionList.AVERAGE.aliasFunctionName",
1861
+ functionType: import_engine_formula5.FunctionType.Statistical,
1862
+ description: "formula.functionList.AVERAGE.description",
1863
+ abstract: "formula.functionList.AVERAGE.abstract",
1864
+ functionParameter: [
1865
+ {
1866
+ name: "formula.functionList.AVERAGE.functionParameter.number1.name",
1867
+ detail: "formula.functionList.AVERAGE.functionParameter.number1.detail",
1868
+ example: "A1:A20",
1869
+ require: 1,
1870
+ repeat: 0
1871
+ },
1872
+ {
1873
+ name: "formula.functionList.AVERAGE.functionParameter.number2.name",
1874
+ detail: "formula.functionList.AVERAGE.functionParameter.number2.detail",
1875
+ example: "B2:B10",
1876
+ require: 0,
1877
+ repeat: 1
1878
+ }
1879
+ ]
1880
+ },
1881
+ {
1882
+ functionName: import_engine_formula5.FUNCTION_NAMES.MAX,
1883
+ aliasFunctionName: "formula.functionList.MAX.aliasFunctionName",
1884
+ functionType: import_engine_formula5.FunctionType.Statistical,
1885
+ description: "formula.functionList.MAX.description",
1886
+ abstract: "formula.functionList.MAX.abstract",
1887
+ functionParameter: [
1888
+ {
1889
+ name: "formula.functionList.MAX.functionParameter.number1.name",
1890
+ detail: "formula.functionList.MAX.functionParameter.number1.detail",
1891
+ example: "A1:A20",
1892
+ require: 1,
1893
+ repeat: 0
1894
+ },
1895
+ {
1896
+ name: "formula.functionList.MAX.functionParameter.number2.name",
1897
+ detail: "formula.functionList.MAX.functionParameter.number2.detail",
1898
+ example: "B2:B10",
1899
+ require: 0,
1900
+ repeat: 1
1901
+ }
1902
+ ]
1903
+ },
1904
+ {
1905
+ functionName: import_engine_formula5.FUNCTION_NAMES.COUNT,
1906
+ aliasFunctionName: "formula.functionList.COUNT.aliasFunctionName",
1907
+ functionType: import_engine_formula5.FunctionType.Statistical,
1908
+ description: "formula.functionList.COUNT.description",
1909
+ abstract: "formula.functionList.COUNT.abstract",
1910
+ functionParameter: [
1911
+ {
1912
+ name: "formula.functionList.COUNT.functionParameter.value1.name",
1913
+ detail: "formula.functionList.COUNT.functionParameter.value1.detail",
1914
+ example: "A1:A20",
1915
+ require: 1,
1916
+ repeat: 0
1917
+ },
1918
+ {
1919
+ name: "formula.functionList.COUNT.functionParameter.value2.name",
1920
+ detail: "formula.functionList.COUNT.functionParameter.value2.detail",
1921
+ example: "B2:B10",
1922
+ require: 0,
1923
+ repeat: 1
1924
+ }
1925
+ ]
1926
+ },
1927
+ {
1928
+ functionName: import_engine_formula5.FUNCTION_NAMES.MIN,
1929
+ aliasFunctionName: "formula.functionList.MIN.aliasFunctionName",
1930
+ functionType: import_engine_formula5.FunctionType.Statistical,
1931
+ description: "formula.functionList.MIN.description",
1932
+ abstract: "formula.functionList.MIN.abstract",
1933
+ functionParameter: [
1934
+ {
1935
+ name: "formula.functionList.MIN.functionParameter.number1.name",
1936
+ detail: "formula.functionList.MIN.functionParameter.number1.detail",
1937
+ example: "A1:A20",
1938
+ require: 1,
1939
+ repeat: 0
1940
+ },
1941
+ {
1942
+ name: "formula.functionList.MIN.functionParameter.number2.name",
1943
+ detail: "formula.functionList.MIN.functionParameter.number2.detail",
1944
+ example: "B2:B10",
1945
+ require: 0,
1946
+ repeat: 1
1947
+ }
1948
+ ]
1949
+ }
1950
+ ];
1951
+ // src/services/function-list/text.ts
1952
+ var FUNCTION_LIST_TEXT = [];
1953
+ // src/services/function-list/univer.ts
1954
+ var FUNCTION_LIST_UNIVER = [];
1955
+ // src/services/function-list/web.ts
1956
+ var FUNCTION_LIST_WEB = [];
1957
+ // src/services/function-list/function-list.ts
1958
+ var FUNCTION_LIST = _to_consumable_array(FUNCTION_LIST_FINANCIAL).concat(_to_consumable_array(FUNCTION_LIST_DATE), _to_consumable_array(FUNCTION_LIST_MATH), _to_consumable_array(FUNCTION_LIST_STATISTICAL), _to_consumable_array(FUNCTION_LIST_LOOKUP), _to_consumable_array(FUNCTION_LIST_DATABASE), _to_consumable_array(FUNCTION_LIST_TEXT), _to_consumable_array(FUNCTION_LIST_LOGICAL), _to_consumable_array(FUNCTION_LIST_INFORMATION), _to_consumable_array(FUNCTION_LIST_ENGINEERING), _to_consumable_array(FUNCTION_LIST_CUBE), _to_consumable_array(FUNCTION_LIST_COMPATIBILITY), _to_consumable_array(FUNCTION_LIST_WEB), _to_consumable_array(FUNCTION_LIST_ARRAY), _to_consumable_array(FUNCTION_LIST_UNIVER));
1959
+ // src/services/utils.ts
1960
+ function getFunctionTypeValues(enumObj, localeService) {
1961
+ return Object.keys(enumObj).filter(function(key) {
1962
+ return isNaN(Number(key));
1963
+ }).map(function(key) {
1964
+ return {
1965
+ label: localeService.t("formula.functionType.".concat(key.toLocaleLowerCase())),
1966
+ value: "".concat(enumObj[key])
1967
+ };
1968
+ });
1969
+ }
1970
+ function getFunctionName(item, localeService) {
1971
+ var functionName = "";
1972
+ if (item.aliasFunctionName) {
1973
+ functionName = localeService.t(item.aliasFunctionName);
1974
+ if (functionName === item.aliasFunctionName) {
1975
+ functionName = item.functionName;
1976
+ }
1977
+ } else {
1978
+ functionName = item.functionName;
1979
+ }
1980
+ return functionName;
1981
+ }
1982
+ // src/services/description.service.ts
1983
+ var IDescriptionService = (0, import_redi5.createIdentifier)("formula-ui.description-service");
1984
+ var DescriptionService = /*#__PURE__*/ function() {
1985
+ function DescriptionService(_description, _formulaEngineService, _localeService) {
1986
+ _class_call_check(this, DescriptionService);
1987
+ this._description = _description;
1988
+ this._formulaEngineService = _formulaEngineService;
1989
+ this._localeService = _localeService;
1990
+ this._initialize();
1991
+ this._registerDescription();
1992
+ }
1993
+ _create_class(DescriptionService, [
1994
+ {
1995
+ key: "dispose",
1996
+ value: function dispose() {
1997
+ this._localeService.localeChanged$.complete();
1998
+ }
1999
+ },
2000
+ {
2001
+ key: "getDescriptions",
2002
+ value: function getDescriptions() {
2003
+ return this._formulaEngineService.getDescriptions();
2004
+ }
2005
+ },
2006
+ {
2007
+ key: "hasFunction",
2008
+ value: function hasFunction(searchText) {
2009
+ var functionList = this._formulaEngineService.getDescriptions();
2010
+ return functionList.get(searchText.toLocaleUpperCase()) !== void 0;
2011
+ }
2012
+ },
2013
+ {
2014
+ key: "getFunctionInfo",
2015
+ value: function getFunctionInfo(searchText) {
2016
+ var functionList = this._formulaEngineService.getDescriptions();
2017
+ return functionList.get(searchText.toLocaleUpperCase());
2018
+ }
2019
+ },
2020
+ {
2021
+ key: "getSearchListByName",
2022
+ value: function getSearchListByName(searchText) {
2023
+ var searchList = [];
2024
+ var functionList = this._formulaEngineService.getDescriptions();
2025
+ searchText = searchText.toLocaleUpperCase();
2026
+ functionList.forEach(function(item) {
2027
+ var functionName = item.functionName, abstract = item.abstract;
2028
+ if (functionName.indexOf(searchText) > -1) {
2029
+ searchList.push({
2030
+ name: functionName,
2031
+ desc: abstract
2032
+ });
2033
+ }
2034
+ });
2035
+ return searchList;
2036
+ }
2037
+ },
2038
+ {
2039
+ key: "getSearchListByType",
2040
+ value: function getSearchListByType(type) {
2041
+ var searchList = [];
2042
+ var functionList = this._formulaEngineService.getDescriptions();
2043
+ functionList.forEach(function(item) {
2044
+ var functionName = item.functionName, functionType = item.functionType, abstract = item.abstract;
2045
+ if (functionType === type || type === -1) {
2046
+ searchList.push({
2047
+ name: functionName,
2048
+ desc: abstract
2049
+ });
2050
+ }
2051
+ });
2052
+ return searchList;
2053
+ }
2054
+ },
2055
+ {
2056
+ key: "_initialize",
2057
+ value: function _initialize() {
2058
+ var _this = this;
2059
+ this._localeService.localeChanged$.subscribe(function() {
2060
+ _this._registerDescription();
2061
+ });
2062
+ }
2063
+ },
2064
+ {
2065
+ key: "_registerDescription",
2066
+ value: function _registerDescription() {
2067
+ var _this__formulaEngineService;
2068
+ var localeService = this._localeService;
2069
+ var functionList = FUNCTION_LIST.concat(this._description || []);
2070
+ var functionListLocale = functionList.map(function(functionInfo) {
2071
+ return {
2072
+ functionName: getFunctionName(functionInfo, localeService),
2073
+ functionType: functionInfo.functionType,
2074
+ description: localeService.t(functionInfo.description),
2075
+ abstract: localeService.t(functionInfo.abstract),
2076
+ functionParameter: functionInfo.functionParameter.map(function(item) {
2077
+ return {
2078
+ name: localeService.t(item.name),
2079
+ detail: localeService.t(item.detail),
2080
+ example: item.example,
2081
+ require: item.require,
2082
+ repeat: item.repeat
2083
+ };
2084
+ })
2085
+ };
2086
+ });
2087
+ (_this__formulaEngineService = this._formulaEngineService).registerDescription.apply(_this__formulaEngineService, _to_consumable_array(functionListLocale));
2088
+ }
2089
+ }
2090
+ ]);
2091
+ return DescriptionService;
2092
+ }();
2093
+ DescriptionService = __decorateClass([
2094
+ __decorateParam(1, (0, import_redi5.Inject)(import_engine_formula6.FormulaEngineService)),
2095
+ __decorateParam(2, (0, import_redi5.Inject)(import_core12.LocaleService))
2096
+ ], DescriptionService);
2097
+ // stylePlugin:/Users/jikkaixiao/dev/univer/packages/sheets-formula/src/views/more-functions/select-function/index.module.less
2098
+ var index_module_default7 = {
2099
+ "formulaSelectFunctionSelect": "univer-formula-select-function-select",
2100
+ "formulaSelectFunctionResult": "univer-formula-select-function-result",
2101
+ "formulaSelectFunctionResultItem": "univer-formula-select-function-result-item",
2102
+ "formulaSelectFunctionResultItemNameLight": "univer-formula-select-function-result-item-name-light",
2103
+ "formulaSelectFunctionResultItemSelected": "univer-formula-select-function-result-item-selected",
2104
+ "formulaSelectFunctionResultItemActive": "univer-formula-select-function-result-item-active",
2105
+ "formulaSelectFunctionContent": "univer-formula-select-function-content"
2106
+ };
2107
+ // src/views/more-functions/select-function/SelectFunction.tsx
2108
+ function SelectFunction(props) {
2109
+ var onChange = props.onChange;
2110
+ var allTypeValue = "-1";
2111
+ var _ref = _sliced_to_array((0, import_react8.useState)(""), 2), searchText = _ref[0], setSearchText = _ref[1];
2112
+ var _ref1 = _sliced_to_array((0, import_react8.useState)([]), 2), selectList = _ref1[0], setSelectList = _ref1[1];
2113
+ var _ref2 = _sliced_to_array((0, import_react8.useState)(0), 2), active = _ref2[0], setActive = _ref2[1];
2114
+ var _ref3 = _sliced_to_array((0, import_react8.useState)(allTypeValue), 2), typeSelected = _ref3[0], setTypeSelected = _ref3[1];
2115
+ var _ref4 = _sliced_to_array((0, import_react8.useState)(0), 2), nameSelected = _ref4[0], setNameSelected = _ref4[1];
2116
+ var _ref5 = _sliced_to_array((0, import_react8.useState)(null), 2), functionInfo = _ref5[0], setFunctionInfo = _ref5[1];
2117
+ var descriptionService = (0, import_react_bindings4.useDependency)(IDescriptionService);
2118
+ var localeService = (0, import_react_bindings4.useDependency)(import_core13.LocaleService);
2119
+ var options = getFunctionTypeValues(import_engine_formula7.FunctionType, localeService);
2120
+ options.unshift({
2121
+ label: localeService.t("formula.moreFunctions.allFunctions"),
2122
+ value: allTypeValue
2123
+ });
2124
+ var required = localeService.t("formula.prompt.required");
2125
+ var optional = localeService.t("formula.prompt.optional");
2126
+ (0, import_react8.useEffect)(function() {
2127
+ handleSelectChange(allTypeValue);
2128
+ }, []);
2129
+ (0, import_react8.useEffect)(function() {
2130
+ setCurrentFunctionInfo(0);
2131
+ }, [
2132
+ selectList
2133
+ ]);
2134
+ var highlightSearchText = function(text) {
2135
+ var regex = new RegExp("(".concat(searchText.toLocaleUpperCase(), ")"));
2136
+ var parts = text.split(regex).filter(Boolean);
2137
+ return parts.map(function(part, index) {
2138
+ if (part.match(regex)) {
2139
+ return /* @__PURE__ */ import_react8.default.createElement("span", {
2140
+ key: index,
2141
+ className: index_module_default7.formulaSelectFunctionResultItemNameLight
2142
+ }, part);
2143
+ }
2144
+ return part;
2145
+ });
2146
+ };
2147
+ var setCurrentFunctionInfo = function(selectedIndex) {
2148
+ if (selectList.length === 0) {
2149
+ setFunctionInfo(null);
2150
+ return;
2151
+ }
2152
+ setNameSelected(selectedIndex);
2153
+ var functionInfo2 = descriptionService.getFunctionInfo(selectList[selectedIndex].name);
2154
+ if (!functionInfo2) {
2155
+ setFunctionInfo(null);
2156
+ return;
2157
+ }
2158
+ setFunctionInfo(functionInfo2);
2159
+ onChange(functionInfo2);
2160
+ };
2161
+ function handleSelectChange(value) {
2162
+ setTypeSelected(value);
2163
+ var selectList2 = descriptionService.getSearchListByType(+value);
2164
+ setSelectList(selectList2);
2165
+ }
2166
+ function handleSearchInputChange(value) {
2167
+ setSearchText(value);
2168
+ var selectList2 = descriptionService.getSearchListByName(value);
2169
+ setSelectList(selectList2);
2170
+ }
2171
+ function handleSelectListKeyDown(e) {
2172
+ e.stopPropagation();
2173
+ if (e.key === "ArrowDown") {
2174
+ var nextActive = active + 1;
2175
+ setActive(nextActive === selectList.length ? 0 : nextActive);
2176
+ } else if (e.key === "ArrowUp") {
2177
+ var nextActive1 = active - 1;
2178
+ setActive(nextActive1 === -1 ? selectList.length - 1 : nextActive1);
2179
+ } else if (e.key === "Enter") {
2180
+ setCurrentFunctionInfo(active);
2181
+ }
2182
+ }
2183
+ var handleLiMouseEnter = function(index) {
2184
+ setActive(index);
2185
+ };
2186
+ var handleLiMouseLeave = function() {
2187
+ setActive(-1);
2188
+ };
2189
+ return /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("div", {
2190
+ className: index_module_default7.formulaSelectFunctionSelect
2191
+ }, /* @__PURE__ */ import_react8.default.createElement(import_design3.Select, {
2192
+ value: typeSelected,
2193
+ options: options,
2194
+ onChange: handleSelectChange
2195
+ }), /* @__PURE__ */ import_react8.default.createElement(import_design3.Input, {
2196
+ placeholder: localeService.t("formula.moreFunctions.searchFunctionPlaceholder"),
2197
+ onKeyDown: handleSelectListKeyDown,
2198
+ value: searchText,
2199
+ onChange: handleSearchInputChange,
2200
+ size: "large",
2201
+ allowClear: true
2202
+ })), /* @__PURE__ */ import_react8.default.createElement("ul", {
2203
+ className: index_module_default7.formulaSelectFunctionResult,
2204
+ onKeyDown: handleSelectListKeyDown,
2205
+ tabIndex: -1
2206
+ }, selectList.map(function(param, index) {
2207
+ var name = param.name;
2208
+ return /* @__PURE__ */ import_react8.default.createElement("li", {
2209
+ key: index,
2210
+ className: active === index ? "".concat(index_module_default7.formulaSelectFunctionResultItem, " ").concat(index_module_default7.formulaSelectFunctionResultItemActive) : index_module_default7.formulaSelectFunctionResultItem,
2211
+ onMouseEnter: function() {
2212
+ return handleLiMouseEnter(index);
2213
+ },
2214
+ onMouseLeave: handleLiMouseLeave,
2215
+ onClick: function() {
2216
+ return setCurrentFunctionInfo(index);
2217
+ }
2218
+ }, nameSelected === index && /* @__PURE__ */ import_react8.default.createElement(import_icons2.CheckMarkSingle, {
2219
+ className: index_module_default7.formulaSelectFunctionResultItemSelected
2220
+ }), /* @__PURE__ */ import_react8.default.createElement("span", {
2221
+ className: index_module_default7.formulaSelectFunctionResultItemName
2222
+ }, highlightSearchText(name)));
2223
+ })), functionInfo && /* @__PURE__ */ import_react8.default.createElement("div", {
2224
+ className: index_module_default7.formulaSelectFunctionContent
2225
+ }, /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
2226
+ title: functionInfo.functionName,
2227
+ value: functionInfo.description
2228
+ }), /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
2229
+ title: localeService.t("formula.moreFunctions.syntax"),
2230
+ value: /* @__PURE__ */ import_react8.default.createElement(FunctionHelp, {
2231
+ prefix: functionInfo.functionName,
2232
+ value: functionInfo.functionParameter
2233
+ })
2234
+ }), /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
2235
+ title: localeService.t("formula.prompt.helpExample"),
2236
+ value: "".concat(functionInfo.functionName, "(").concat(functionInfo.functionParameter.map(function(item) {
2237
+ return item.example;
2238
+ }).join(","), ")")
2239
+ }), functionInfo.functionParameter && functionInfo.functionParameter.map(function(item, i) {
2240
+ return /* @__PURE__ */ import_react8.default.createElement(FunctionParams, {
2241
+ key: i,
2242
+ title: item.name,
2243
+ value: "".concat(item.require ? required : optional, " ").concat(item.detail)
2244
+ });
2245
+ })));
2246
+ }
2247
+ // src/views/more-functions/MoreFunctions.tsx
2248
+ function MoreFunctions() {
2249
+ var _ref = _sliced_to_array((0, import_react9.useState)(true), 2), selectFunction = _ref[0], setSelectFunction = _ref[1];
2250
+ var _ref1 = _sliced_to_array((0, import_react9.useState)(false), 2), inputParams = _ref1[0], setInputParams = _ref1[1];
2251
+ var _ref2 = _sliced_to_array((0, import_react9.useState)([]), 2), params = _ref2[0], setParams = _ref2[1];
2252
+ var _ref3 = _sliced_to_array((0, import_react9.useState)(null), 2), functionInfo = _ref3[0], setFunctionInfo = _ref3[1];
2253
+ var localeService = (0, import_react_bindings5.useDependency)(import_core14.LocaleService);
2254
+ var sidebarService = (0, import_react_bindings5.useDependency)(import_ui3.ISidebarService);
2255
+ var formulaInputService = (0, import_react_bindings5.useDependency)(IFormulaInputService);
2256
+ function handleClickNextPrev() {
2257
+ if (selectFunction) {}
2258
+ setSelectFunction(!selectFunction);
2259
+ setInputParams(!inputParams);
2260
+ }
2261
+ function handleConfirm() {
2262
+ formulaInputService.inputFormula("=".concat(functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.functionName, "("));
2263
+ }
2264
+ return /* @__PURE__ */ import_react9.default.createElement("div", {
2265
+ className: index_module_default4.formulaMoreFunctions
2266
+ }, selectFunction && /* @__PURE__ */ import_react9.default.createElement(SelectFunction, {
2267
+ onChange: setFunctionInfo
2268
+ }), inputParams && /* @__PURE__ */ import_react9.default.createElement(InputParams, {
2269
+ functionInfo: functionInfo,
2270
+ onChange: setParams
2271
+ }), /* @__PURE__ */ import_react9.default.createElement("div", {
2272
+ className: index_module_default4.formulaMoreFunctionsOperation
2273
+ }, inputParams && /* @__PURE__ */ import_react9.default.createElement(import_design4.Button, {
2274
+ type: "primary",
2275
+ onClick: handleClickNextPrev
2276
+ }, localeService.t("formula.moreFunctions.next")), inputParams && /* @__PURE__ */ import_react9.default.createElement(import_design4.Button, {
2277
+ onClick: handleClickNextPrev
2278
+ }, localeService.t("formula.moreFunctions.prev")), selectFunction && /* @__PURE__ */ import_react9.default.createElement(import_design4.Button, {
2279
+ type: "primary",
2280
+ onClick: handleConfirm
2281
+ }, localeService.t("formula.moreFunctions.confirm"))));
2282
+ }
2283
+ // src/controllers/menu.ts
2284
+ var import_ui4 = require("@univerjs/ui");
2285
+ function InsertFunctionMenuItemFactory(accessor) {
2286
+ return {
2287
+ id: InsertFunctionOperation.id,
2288
+ icon: "FunctionSingle",
2289
+ tooltip: "formula.insert.tooltip",
2290
+ group: import_ui4.MenuGroup.TOOLBAR_FORMULAS_INSERT,
2291
+ type: import_ui4.MenuItemType.SELECTOR,
2292
+ positions: [
2293
+ import_ui4.MenuPosition.TOOLBAR_START
2294
+ ],
2295
+ selections: [
2296
+ {
2297
+ label: "SUM",
2298
+ value: "SUM",
2299
+ icon: "SumSingle"
2300
+ },
2301
+ {
2302
+ label: "AVERAGE",
2303
+ value: "AVERAGE",
2304
+ icon: "AvgSingle"
2305
+ },
2306
+ {
2307
+ label: "COUNT",
2308
+ value: "COUNT",
2309
+ icon: "CntSingle"
2310
+ },
2311
+ {
2312
+ label: "MAX",
2313
+ value: "MAX",
2314
+ icon: "MaxSingle"
2315
+ },
2316
+ {
2317
+ label: "MIN",
2318
+ value: "MIN",
2319
+ icon: "MinSingle"
2320
+ }
2321
+ ]
2322
+ };
2323
+ }
2324
+ function MoreFunctionsMenuItemFactory(accessor) {
2325
+ return {
2326
+ id: MoreFunctionsOperation.id,
2327
+ title: "formula.insert.more",
2328
+ positions: InsertFunctionOperation.id,
2329
+ type: import_ui4.MenuItemType.BUTTON
2330
+ };
2331
+ }
2332
+ // src/controllers/shortcuts/prompt.shortcut.ts
2333
+ var import_engine_render2 = require("@univerjs/engine-render");
2334
+ var import_sheets_ui7 = require("@univerjs/sheets-ui");
2335
+ var import_ui5 = require("@univerjs/ui");
2336
+ // src/common/prompt.ts
2337
+ var META_KEY_CTRL_AND_SHIFT = "meta_key_ctrl_And_Shift";
2338
+ // src/controllers/shortcuts/prompt.shortcut.ts
2339
+ var PROMPT_SELECTION_KEYCODE_ARROW_LIST = [
2340
+ import_ui5.KeyCode.ARROW_DOWN,
2341
+ import_ui5.KeyCode.ARROW_UP,
2342
+ import_ui5.KeyCode.ARROW_LEFT,
2343
+ import_ui5.KeyCode.ARROW_RIGHT
2344
+ ];
2345
+ var PROMPT_SELECTION_KEYCODE_LIST = _to_consumable_array(PROMPT_SELECTION_KEYCODE_ARROW_LIST).concat([
2346
+ import_ui5.KeyCode.ENTER,
2347
+ import_ui5.KeyCode.TAB
2348
+ ]);
2349
+ function promptSelectionShortcutItem() {
2350
+ var shortcutList = [];
2351
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2352
+ try {
2353
+ for(var _iterator = PROMPT_SELECTION_KEYCODE_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2354
+ var keycode = _step.value;
2355
+ shortcutList.push({
2356
+ id: SelectEditorFormulaOperation.id,
2357
+ binding: keycode,
2358
+ preconditions: function(contextService) {
2359
+ return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
2360
+ },
2361
+ staticParameters: {
2362
+ eventType: import_engine_render2.DeviceInputEventType.Keyboard,
2363
+ keycode: keycode
2364
+ }
2365
+ });
2366
+ }
2367
+ } catch (err) {
2368
+ _didIteratorError = true;
2369
+ _iteratorError = err;
2370
+ } finally{
2371
+ try {
2372
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2373
+ _iterator.return();
2374
+ }
2375
+ } finally{
2376
+ if (_didIteratorError) {
2377
+ throw _iteratorError;
2378
+ }
2379
+ }
2380
+ }
2381
+ return shortcutList;
2382
+ }
2383
+ function promptSelectionShortcutItemShift() {
2384
+ var shortcutList = [];
2385
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2386
+ try {
2387
+ for(var _iterator = PROMPT_SELECTION_KEYCODE_ARROW_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2388
+ var keycode = _step.value;
2389
+ shortcutList.push({
2390
+ id: SelectEditorFormulaOperation.id,
2391
+ binding: keycode | import_ui5.MetaKeys.SHIFT,
2392
+ preconditions: function(contextService) {
2393
+ return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
2394
+ },
2395
+ staticParameters: {
2396
+ eventType: import_engine_render2.DeviceInputEventType.Keyboard,
2397
+ keycode: keycode,
2398
+ metaKey: import_ui5.MetaKeys.SHIFT
2399
+ }
2400
+ });
2401
+ }
2402
+ } catch (err) {
2403
+ _didIteratorError = true;
2404
+ _iteratorError = err;
2405
+ } finally{
2406
+ try {
2407
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2408
+ _iterator.return();
2409
+ }
2410
+ } finally{
2411
+ if (_didIteratorError) {
2412
+ throw _iteratorError;
2413
+ }
2414
+ }
2415
+ }
2416
+ return shortcutList;
2417
+ }
2418
+ function promptSelectionShortcutItemCtrl() {
2419
+ var shortcutList = [];
2420
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2421
+ try {
2422
+ for(var _iterator = PROMPT_SELECTION_KEYCODE_ARROW_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2423
+ var keycode = _step.value;
2424
+ shortcutList.push({
2425
+ id: SelectEditorFormulaOperation.id,
2426
+ binding: keycode | import_ui5.MetaKeys.CTRL_COMMAND,
2427
+ preconditions: function(contextService) {
2428
+ return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
2429
+ },
2430
+ staticParameters: {
2431
+ eventType: import_engine_render2.DeviceInputEventType.Keyboard,
2432
+ keycode: keycode,
2433
+ metaKey: import_ui5.MetaKeys.CTRL_COMMAND
2434
+ }
2435
+ });
2436
+ }
2437
+ } catch (err) {
2438
+ _didIteratorError = true;
2439
+ _iteratorError = err;
2440
+ } finally{
2441
+ try {
2442
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2443
+ _iterator.return();
2444
+ }
2445
+ } finally{
2446
+ if (_didIteratorError) {
2447
+ throw _iteratorError;
2448
+ }
2449
+ }
2450
+ }
2451
+ return shortcutList;
2452
+ }
2453
+ function promptSelectionShortcutItemCtrlAndShift() {
2454
+ var shortcutList = [];
2455
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2456
+ try {
2457
+ for(var _iterator = PROMPT_SELECTION_KEYCODE_ARROW_LIST[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2458
+ var keycode = _step.value;
2459
+ shortcutList.push({
2460
+ id: SelectEditorFormulaOperation.id,
2461
+ binding: keycode | import_ui5.MetaKeys.SHIFT | import_ui5.MetaKeys.CTRL_COMMAND,
2462
+ preconditions: function(contextService) {
2463
+ return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
2464
+ },
2465
+ staticParameters: {
2466
+ eventType: import_engine_render2.DeviceInputEventType.Keyboard,
2467
+ keycode: keycode,
2468
+ metaKey: META_KEY_CTRL_AND_SHIFT
2469
+ }
2470
+ });
2471
+ }
2472
+ } catch (err) {
2473
+ _didIteratorError = true;
2474
+ _iteratorError = err;
2475
+ } finally{
2476
+ try {
2477
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2478
+ _iterator.return();
2479
+ }
2480
+ } finally{
2481
+ if (_didIteratorError) {
2482
+ throw _iteratorError;
2483
+ }
2484
+ }
2485
+ }
2486
+ return shortcutList;
2487
+ }
2488
+ var ChangeRefToAbsoluteShortcut = {
2489
+ id: ReferenceAbsoluteOperation.id,
2490
+ binding: import_ui5.KeyCode.F4,
2491
+ preconditions: function(contextService) {
2492
+ return (0, import_sheets_ui7.whenEditorInputFormulaActivated)(contextService);
2493
+ }
2494
+ };
2495
+ // src/controllers/formula-ui.controller.ts
2496
+ var FormulaUIController = /*#__PURE__*/ function(_import_core15_Disposable) {
2497
+ _inherits(FormulaUIController, _import_core15_Disposable);
2498
+ var _super = _create_super(FormulaUIController);
2499
+ function FormulaUIController(_injector, _menuService, _commandService, _shortcutService, _uiController, _componentManager) {
2500
+ _class_call_check(this, FormulaUIController);
2501
+ var _this;
2502
+ _this = _super.call(this);
2503
+ _this._injector = _injector;
2504
+ _this._menuService = _menuService;
2505
+ _this._commandService = _commandService;
2506
+ _this._shortcutService = _shortcutService;
2507
+ _this._uiController = _uiController;
2508
+ _this._componentManager = _componentManager;
2509
+ _this._initialize();
2510
+ return _this;
2511
+ }
2512
+ _create_class(FormulaUIController, [
2513
+ {
2514
+ key: "_initialize",
2515
+ value: function _initialize() {
2516
+ this._registerCommands();
2517
+ this._registerMenus();
2518
+ this._registerShortcuts();
2519
+ this._registerComponents();
2520
+ }
2521
+ },
2522
+ {
2523
+ key: "_registerMenus",
2524
+ value: function _registerMenus() {
2525
+ var _this = this;
2526
+ [
2527
+ InsertFunctionMenuItemFactory,
2528
+ MoreFunctionsMenuItemFactory
2529
+ ].forEach(function(factory) {
2530
+ _this.disposeWithMe(_this._menuService.addMenuItem(_this._injector.invoke(factory)));
2531
+ });
2532
+ }
2533
+ },
2534
+ {
2535
+ key: "_registerCommands",
2536
+ value: function _registerCommands() {
2537
+ var _this = this;
2538
+ [
2539
+ InsertFunctionCommand,
2540
+ InsertFunctionOperation,
2541
+ MoreFunctionsOperation,
2542
+ SearchFunctionOperation,
2543
+ HelpFunctionOperation,
2544
+ SelectEditorFormulaOperation,
2545
+ ReferenceAbsoluteOperation
2546
+ ].forEach(function(command) {
2547
+ return _this.disposeWithMe(_this._commandService.registerCommand(command));
2548
+ });
2549
+ }
2550
+ },
2551
+ {
2552
+ key: "_registerShortcuts",
2553
+ value: function _registerShortcuts() {
2554
+ var _this = this;
2555
+ _to_consumable_array(promptSelectionShortcutItem()).concat(_to_consumable_array(promptSelectionShortcutItemShift()), _to_consumable_array(promptSelectionShortcutItemCtrl()), _to_consumable_array(promptSelectionShortcutItemCtrlAndShift()), [
2556
+ ChangeRefToAbsoluteShortcut
2557
+ ]).forEach(function(item) {
2558
+ _this.disposeWithMe(_this._shortcutService.registerShortcut(item));
2559
+ });
2560
+ }
2561
+ },
2562
+ {
2563
+ key: "_registerComponents",
2564
+ value: function _registerComponents() {
2565
+ var _this = this;
2566
+ this.disposeWithMe(this._uiController.registerContentComponent(function() {
2567
+ return (0, import_react_bindings6.connectInjector)(RenderFormulaPromptContent, _this._injector);
2568
+ }));
2569
+ this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions);
2570
+ }
2571
+ }
2572
+ ]);
2573
+ return FormulaUIController;
2574
+ }(import_core15.Disposable);
2575
+ FormulaUIController = __decorateClass([
2576
+ (0, import_core15.OnLifecycle)(import_core15.LifecycleStages.Ready, FormulaUIController),
2577
+ __decorateParam(0, (0, import_redi6.Inject)(import_redi6.Injector)),
2578
+ __decorateParam(1, import_ui6.IMenuService),
2579
+ __decorateParam(2, import_core15.ICommandService),
2580
+ __decorateParam(3, import_ui6.IShortcutService),
2581
+ __decorateParam(4, import_ui6.IUIController),
2582
+ __decorateParam(5, (0, import_redi6.Inject)(import_ui6.ComponentManager))
2583
+ ], FormulaUIController);
2584
+ // src/controllers/prompt.controller.ts
2585
+ var import_core16 = require("@univerjs/core");
2586
+ var import_docs = require("@univerjs/docs");
2587
+ var import_engine_formula8 = require("@univerjs/engine-formula");
2588
+ var import_engine_render3 = require("@univerjs/engine-render");
2589
+ var import_sheets3 = require("@univerjs/sheets");
2590
+ var import_sheets_ui8 = require("@univerjs/sheets-ui");
2591
+ var import_ui7 = require("@univerjs/ui");
2592
+ var import_redi7 = require("@wendellhu/redi");
2593
+ // src/common/selection.ts
2594
+ var import_tinycolor = require("@ctrl/tinycolor");
2595
+ var FORMULA_REF_SELECTION_PLUGIN_NAME = "formula_reference_selection_plugin_name";
2596
+ function getFormulaRefSelectionStyle(themeService, refColor, id) {
2597
+ var style = themeService.getCurrentTheme();
2598
+ var fill = new import_tinycolor.TinyColor(refColor).setAlpha(0.05).toString();
2599
+ return {
2600
+ id: id,
2601
+ strokeWidth: 2,
2602
+ stroke: refColor,
2603
+ // strokeDash: 10,
2604
+ fill: fill,
2605
+ widgets: {
2606
+ tl: true,
2607
+ tc: true,
2608
+ tr: true,
2609
+ ml: true,
2610
+ mr: true,
2611
+ bl: true,
2612
+ bc: true,
2613
+ br: true
2614
+ },
2615
+ widgetSize: 6,
2616
+ widgetStrokeWidth: 1,
2617
+ widgetStroke: style.colorWhite,
2618
+ hasAutoFill: false,
2619
+ hasRowHeader: false,
2620
+ hasColumnHeader: false
2621
+ };
2622
+ }
2623
+ // src/controllers/prompt.controller.ts
2624
+ var PromptController = /*#__PURE__*/ function(_import_core16_Disposable) {
2625
+ _inherits(PromptController, _import_core16_Disposable);
2626
+ var _super = _create_super(PromptController);
2627
+ function PromptController(_commandService, _localeService, _contextService, _textSelectionRenderManager, _editorBridgeService, _formulaPromptService, _formulaEngineService, _renderManagerService, _themeService, _selectionManagerService, _sheetSkeletonManagerService, _currentUniverService, _selectionRenderService, _descriptionService, _textSelectionManagerService, _formulaInputService, _docViewModelManagerService) {
2628
+ _class_call_check(this, PromptController);
2629
+ var _this;
2630
+ _this = _super.call(this);
2631
+ _define_property(_assert_this_initialized(_this), "_formulaRefColors", []);
2632
+ _define_property(_assert_this_initialized(_this), "_previousSequenceNodes", void 0);
2633
+ _define_property(_assert_this_initialized(_this), "_previousRangesCount", 0);
2634
+ _define_property(_assert_this_initialized(_this), "_previousInsertRefStringIndex", void 0);
2635
+ _define_property(_assert_this_initialized(_this), "_currentInsertRefStringIndex", -1);
2636
+ _define_property(_assert_this_initialized(_this), "_currentUnitId", void 0);
2637
+ _define_property(_assert_this_initialized(_this), "_currentSheetId", void 0);
2638
+ _define_property(_assert_this_initialized(_this), "_arrowMoveActionState", 0 /* InitialState */ );
2639
+ _define_property(_assert_this_initialized(_this), "_isSelectionMovingRefSelections", []);
2640
+ _define_property(_assert_this_initialized(_this), "_stringColor", "");
2641
+ _define_property(_assert_this_initialized(_this), "_numberColor", "");
2642
+ _define_property(_assert_this_initialized(_this), "_insertSelections", []);
2643
+ _define_property(_assert_this_initialized(_this), "_inputPanelState", 0 /* InitialState */ );
2644
+ _this._commandService = _commandService;
2645
+ _this._localeService = _localeService;
2646
+ _this._contextService = _contextService;
2647
+ _this._textSelectionRenderManager = _textSelectionRenderManager;
2648
+ _this._editorBridgeService = _editorBridgeService;
2649
+ _this._formulaPromptService = _formulaPromptService;
2650
+ _this._formulaEngineService = _formulaEngineService;
2651
+ _this._renderManagerService = _renderManagerService;
2652
+ _this._themeService = _themeService;
2653
+ _this._selectionManagerService = _selectionManagerService;
2654
+ _this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
2655
+ _this._currentUniverService = _currentUniverService;
2656
+ _this._selectionRenderService = _selectionRenderService;
2657
+ _this._descriptionService = _descriptionService;
2658
+ _this._textSelectionManagerService = _textSelectionManagerService;
2659
+ _this._formulaInputService = _formulaInputService;
2660
+ _this._docViewModelManagerService = _docViewModelManagerService;
2661
+ _this._initialize();
2662
+ return _this;
2663
+ }
2664
+ _create_class(PromptController, [
2665
+ {
2666
+ key: "dispose",
2667
+ value: function dispose() {
2668
+ this._formulaRefColors = [];
2669
+ this._resetTemp();
2670
+ }
2671
+ },
2672
+ {
2673
+ key: "_resetTemp",
2674
+ value: function _resetTemp() {
2675
+ this._previousSequenceNodes = null;
2676
+ this._previousInsertRefStringIndex = null;
2677
+ this._currentUnitId = null;
2678
+ this._currentSheetId = null;
2679
+ this._isSelectionMovingRefSelections = [];
2680
+ this._previousRangesCount = 0;
2681
+ this._currentInsertRefStringIndex = -1;
2682
+ }
2683
+ },
2684
+ {
2685
+ key: "_initialize",
2686
+ value: function _initialize() {
2687
+ this._initialCursorSync();
2688
+ this._initAcceptFormula();
2689
+ this._initialFormulaTheme();
2690
+ this._initialRefSelectionUpdateEvent();
2691
+ this._initialRefSelectionInsertEvent();
2692
+ this._initialExitEditor();
2693
+ this._initialEditorInputChange();
2694
+ this._commandExecutedListener();
2695
+ this._cursorStateListener();
2696
+ this._syncEditorListener();
2697
+ }
2698
+ },
2699
+ {
2700
+ key: "_initialFormulaTheme",
2701
+ value: function _initialFormulaTheme() {
2702
+ var style = this._themeService.getCurrentTheme();
2703
+ this._formulaRefColors = [
2704
+ style.loopColor1,
2705
+ style.loopColor2,
2706
+ style.loopColor3,
2707
+ style.loopColor4,
2708
+ style.loopColor5,
2709
+ style.loopColor6,
2710
+ style.loopColor7,
2711
+ style.loopColor8,
2712
+ style.loopColor9,
2713
+ style.loopColor10,
2714
+ style.loopColor11,
2715
+ style.loopColor12
2716
+ ];
2717
+ this._numberColor = style.hyacinth700;
2718
+ this._stringColor = style.verdancy800;
2719
+ }
2720
+ },
2721
+ {
2722
+ key: "_initialCursorSync",
2723
+ value: function _initialCursorSync() {
2724
+ var _this = this;
2725
+ this.disposeWithMe((0, import_core16.toDisposable)(this._textSelectionRenderManager.textSelection$.subscribe(function() {
2726
+ if (_this._editorBridgeService.isVisible().visible === false || _this._formulaInputService.isSelectionMoving()) {
2727
+ return;
2728
+ }
2729
+ var currentBody = _this._getCurrentBody();
2730
+ var dataStream = (currentBody === null || currentBody === void 0 ? void 0 : currentBody.dataStream) || "";
2731
+ _this._contextSwitch(dataStream);
2732
+ _this._changeKeepVisibleHideState();
2733
+ _this._switchSelectionPlugin();
2734
+ if (_this._formulaInputService.isLockedSelectionChange()) {
2735
+ return;
2736
+ }
2737
+ _this._highlightFormula();
2738
+ _this._changeFunctionPanelState();
2739
+ })));
2740
+ }
2741
+ },
2742
+ {
2743
+ key: "_initialEditorInputChange",
2744
+ value: function _initialEditorInputChange() {
2745
+ var _this = this;
2746
+ this.disposeWithMe((0, import_core16.toDisposable)(this._textSelectionRenderManager.onInputBefore$.subscribe(function(param) {
2747
+ _this._previousSequenceNodes = null;
2748
+ _this._previousInsertRefStringIndex = null;
2749
+ _this._selectionRenderService.enableSkipRemainLast();
2750
+ var e = param === null || param === void 0 ? void 0 : param.event;
2751
+ if (e == null) {
2752
+ return;
2753
+ }
2754
+ if (![
2755
+ import_ui7.KeyCode.ARROW_DOWN,
2756
+ import_ui7.KeyCode.ARROW_UP,
2757
+ import_ui7.KeyCode.ARROW_LEFT,
2758
+ import_ui7.KeyCode.ARROW_RIGHT
2759
+ ].includes(e.which)) {
2760
+ if (_this._arrowMoveActionState !== 1 /* moveCursor */ ) {
2761
+ _this._arrowMoveActionState = 2 /* moveRefReady */ ;
2762
+ }
2763
+ _this._inputPanelState = 1 /* keyNormal */ ;
2764
+ } else {
2765
+ _this._inputPanelState = 2 /* keyArrow */ ;
2766
+ }
2767
+ })));
2768
+ }
2769
+ },
2770
+ {
2771
+ key: "_initialExitEditor",
2772
+ value: function _initialExitEditor() {
2773
+ var _this = this;
2774
+ this.disposeWithMe((0, import_core16.toDisposable)(this._editorBridgeService.afterVisible$.subscribe(function(visibleParam) {
2775
+ if (visibleParam.visible === true) {
2776
+ var _this__getCurrentUnitIdAndSheetId = _this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
2777
+ if (_this._currentUnitId == null) {
2778
+ _this._currentUnitId = unitId;
2779
+ }
2780
+ if (_this._currentSheetId == null) {
2781
+ _this._currentSheetId = sheetId;
2782
+ }
2783
+ return;
2784
+ }
2785
+ var current = _this._selectionManagerService.getCurrent();
2786
+ if ((current === null || current === void 0 ? void 0 : current.pluginName) === import_sheets3.NORMAL_SELECTION_PLUGIN_NAME) {
2787
+ _this._disableForceKeepVisible();
2788
+ return;
2789
+ }
2790
+ _this._selectionManagerService.clear();
2791
+ _this._selectionManagerService.changePlugin(import_sheets3.NORMAL_SELECTION_PLUGIN_NAME);
2792
+ _this._updateEditorModel("\r\n", []);
2793
+ _this._contextService.setContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA, false);
2794
+ _this._disableForceKeepVisible();
2795
+ _this._selectionRenderService.resetStyle();
2796
+ _this._resetTemp();
2797
+ _this._hideFunctionPanel();
2798
+ })));
2799
+ }
2800
+ },
2801
+ {
2802
+ key: "_initialRefSelectionUpdateEvent",
2803
+ value: function _initialRefSelectionUpdateEvent() {
2804
+ var _this = this;
2805
+ var disposableCollection = new import_core16.DisposableCollection();
2806
+ this.disposeWithMe((0, import_core16.toDisposable)(this._selectionManagerService.selectionInfo$.subscribe(function() {
2807
+ disposableCollection.dispose();
2808
+ var current = _this._selectionManagerService.getCurrent();
2809
+ _this._formulaInputService.disableSelectionMoving();
2810
+ if ((current === null || current === void 0 ? void 0 : current.pluginName) !== FORMULA_REF_SELECTION_PLUGIN_NAME) {
2811
+ return;
2812
+ }
2813
+ _this._updateRefSelectionStyle(_this._isSelectionMovingRefSelections);
2814
+ var selectionControls = _this._selectionRenderService.getCurrentControls();
2815
+ selectionControls.forEach(function(controlSelection) {
2816
+ controlSelection.disableHelperSelection();
2817
+ disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionMoving$.subscribe(function(toRange) {
2818
+ _this._changeControlSelection(toRange, controlSelection);
2819
+ })));
2820
+ disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionScaling$.subscribe(function(toRange) {
2821
+ _this._changeControlSelection(toRange, controlSelection);
2822
+ })));
2823
+ disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionMoved$.subscribe(function() {
2824
+ _this._formulaInputService.disableLockedSelectionChange();
2825
+ })));
2826
+ disposableCollection.add((0, import_core16.toDisposable)(controlSelection.selectionScaled$.subscribe(function() {
2827
+ _this._formulaInputService.disableLockedSelectionChange();
2828
+ })));
2829
+ });
2830
+ })));
2831
+ }
2832
+ },
2833
+ {
2834
+ key: "_syncEditorListener",
2835
+ value: function _syncEditorListener() {
2836
+ var _this = this;
2837
+ this.disposeWithMe((0, import_core16.toDisposable)(this._formulaInputService.syncToEditor$.subscribe(function(param) {
2838
+ var sequences = param.sequences, textSelectionOffset = param.textSelectionOffset;
2839
+ _this._syncToEditor(sequences, textSelectionOffset);
2840
+ })));
2841
+ }
2842
+ },
2843
+ {
2844
+ key: "_selectionChanging",
2845
+ value: function _selectionChanging(ranges) {
2846
+ var isSync = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
2847
+ if (ranges == null) {
2848
+ return;
2849
+ }
2850
+ if (!this._formulaInputService.isLockedSelectionInsert()) {
2851
+ return;
2852
+ }
2853
+ this._formulaInputService.enableSelectionMoving();
2854
+ this._inertControlSelection(ranges);
2855
+ if (ranges == null || isSync === false) {
2856
+ return;
2857
+ }
2858
+ var currentRange = ranges[ranges.length - 1];
2859
+ this._inertControlSelectionReplace(currentRange);
2860
+ }
2861
+ },
2862
+ {
2863
+ key: "_initialRefSelectionInsertEvent",
2864
+ value: function _initialRefSelectionInsertEvent() {
2865
+ var _this = this;
2866
+ this.disposeWithMe((0, import_core16.toDisposable)(this._selectionRenderService.selectionMoving$.subscribe(this._selectionChanging.bind(this))));
2867
+ this.disposeWithMe((0, import_core16.toDisposable)(this._selectionRenderService.selectionMoveStart$.subscribe(function(ranges) {
2868
+ _this._selectionChanging(ranges, true);
2869
+ })));
2870
+ }
2871
+ },
2872
+ {
2873
+ key: "_initAcceptFormula",
2874
+ value: function _initAcceptFormula() {
2875
+ var _this = this;
2876
+ this.disposeWithMe((0, import_core16.toDisposable)(this._formulaPromptService.acceptFormulaName$.subscribe(function(formulaString) {
2877
+ var activeRange = _this._textSelectionRenderManager.getActiveRange();
2878
+ if (activeRange == null) {
2879
+ _this._hideFunctionPanel();
2880
+ return;
2881
+ }
2882
+ var startOffset = activeRange.startOffset;
2883
+ var lastSequenceNodes = _this._formulaInputService.getSequenceNodes();
2884
+ var nodeIndex = _this._formulaInputService.getCurrentSequenceNodeIndex(startOffset - 2);
2885
+ var node = lastSequenceNodes[nodeIndex];
2886
+ if (node == null || typeof node === "string") {
2887
+ _this._hideFunctionPanel();
2888
+ return;
2889
+ }
2890
+ var difference = formulaString.length - node.token.length;
2891
+ var newNode = _object_spread({}, node);
2892
+ newNode.token = formulaString;
2893
+ newNode.endIndex += difference;
2894
+ lastSequenceNodes[nodeIndex] = newNode;
2895
+ lastSequenceNodes.splice(nodeIndex + 1, 0, import_engine_formula8.matchToken.OPEN_BRACKET);
2896
+ var formulaStringCount = formulaString.length + 1;
2897
+ for(var i = nodeIndex + 2, len = lastSequenceNodes.length; i < len; i++){
2898
+ var node2 = lastSequenceNodes[i];
2899
+ if (typeof node2 === "string") {
2900
+ continue;
2901
+ }
2902
+ var newNode2 = _object_spread({}, node2);
2903
+ newNode2.startIndex += formulaStringCount;
2904
+ newNode2.endIndex += formulaStringCount;
2905
+ lastSequenceNodes[i] = newNode2;
2906
+ }
2907
+ _this._syncToEditor(lastSequenceNodes, newNode.endIndex + 2);
2908
+ })));
2909
+ }
2910
+ },
2911
+ {
2912
+ key: "_changeFunctionPanelState",
2913
+ value: function _changeFunctionPanelState() {
2914
+ var activeRange = this._textSelectionRenderManager.getActiveRange();
2915
+ if (activeRange == null) {
2916
+ this._hideFunctionPanel();
2917
+ return;
2918
+ }
2919
+ var startOffset = activeRange.startOffset;
2920
+ var currentSequenceNode = this._formulaInputService.getCurrentSequenceNode(startOffset - 2);
2921
+ if (currentSequenceNode == null) {
2922
+ this._hideFunctionPanel();
2923
+ return;
2924
+ }
2925
+ if (typeof currentSequenceNode !== "string" && currentSequenceNode.nodeType === import_engine_formula8.sequenceNodeType.FUNCTION) {
2926
+ var token = currentSequenceNode.token.toUpperCase();
2927
+ if (this._inputPanelState === 1 /* keyNormal */ ) {
2928
+ var searchList = this._descriptionService.getSearchListByName(token);
2929
+ this._hideFunctionPanel();
2930
+ if (searchList == null || searchList.length === 0) {
2931
+ return;
2932
+ }
2933
+ this._commandService.executeCommand(SearchFunctionOperation.id, {
2934
+ visible: true,
2935
+ searchText: token,
2936
+ searchList: searchList
2937
+ });
2938
+ } else if (this._descriptionService.hasFunction(token)) {
2939
+ this._changeHelpFunctionPanelState(token, -1);
2940
+ }
2941
+ return;
2942
+ }
2943
+ var currentBody = this._getCurrentBody();
2944
+ var dataStream = (currentBody === null || currentBody === void 0 ? void 0 : currentBody.dataStream) || "";
2945
+ var functionAndParameter = this._formulaEngineService.getFunctionAndParameter(dataStream, startOffset - 1);
2946
+ if (functionAndParameter == null) {
2947
+ this._hideFunctionPanel();
2948
+ return;
2949
+ }
2950
+ var functionName = functionAndParameter.functionName, paramIndex = functionAndParameter.paramIndex;
2951
+ this._changeHelpFunctionPanelState(functionName.toUpperCase(), paramIndex);
2952
+ }
2953
+ },
2954
+ {
2955
+ key: "_changeHelpFunctionPanelState",
2956
+ value: function _changeHelpFunctionPanelState(token, paramIndex) {
2957
+ var functionInfo = this._descriptionService.getFunctionInfo(token);
2958
+ this._hideFunctionPanel();
2959
+ if (functionInfo == null) {
2960
+ return;
2961
+ }
2962
+ this._commandService.executeCommand(HelpFunctionOperation.id, {
2963
+ visible: true,
2964
+ paramIndex: paramIndex,
2965
+ functionInfo: functionInfo
2966
+ });
2967
+ }
2968
+ },
2969
+ {
2970
+ key: "_hideFunctionPanel",
2971
+ value: function _hideFunctionPanel() {
2972
+ this._commandService.executeCommand(SearchFunctionOperation.id, {
2973
+ visible: false,
2974
+ searchText: ""
2975
+ });
2976
+ this._commandService.executeCommand(HelpFunctionOperation.id, {
2977
+ visible: false,
2978
+ paramIndex: -1
2979
+ });
2980
+ }
2981
+ },
2982
+ {
2983
+ /**
2984
+ * If the cursor is located at a formula token,
2985
+ * it is necessary to prohibit the behavior of closing the editor by clicking on the canvas,
2986
+ * in order to generate reference text for the formula.
2987
+ */ key: "_changeKeepVisibleHideState",
2988
+ value: function _changeKeepVisibleHideState() {
2989
+ if (this._getContextState() === false) {
2990
+ this._disableForceKeepVisible();
2991
+ return;
2992
+ }
2993
+ var char = this._getCurrentChar();
2994
+ if (char == null) {
2995
+ this._disableForceKeepVisible();
2996
+ return;
2997
+ }
2998
+ if (this._matchRefDrawToken(char)) {
2999
+ this._editorBridgeService.enableForceKeepVisible();
3000
+ this._formulaInputService.enableLockedSelectionInsert();
3001
+ this._selectionRenderService.enableRemainLast();
3002
+ if (this._arrowMoveActionState !== 1 /* moveCursor */ ) {
3003
+ this._arrowMoveActionState = 2 /* moveRefReady */ ;
3004
+ }
3005
+ } else {
3006
+ this._disableForceKeepVisible();
3007
+ }
3008
+ }
3009
+ },
3010
+ {
3011
+ /**
3012
+ * Determine whether the character is a token keyword for the formula engine.
3013
+ * @param char
3014
+ * @returns
3015
+ */ key: "_matchRefDrawToken",
3016
+ value: function _matchRefDrawToken(char) {
3017
+ return (0, import_engine_formula8.isFormulaLexerToken)(char) && char !== import_engine_formula8.matchToken.CLOSE_BRACES && char !== import_engine_formula8.matchToken.CLOSE_BRACKET && char !== import_engine_formula8.matchToken.SINGLE_QUOTATION && char !== import_engine_formula8.matchToken.DOUBLE_QUOTATION || char === " ";
3018
+ }
3019
+ },
3020
+ {
3021
+ /**
3022
+ *
3023
+ * @returns Return the character under the current cursor in the editor.
3024
+ */ key: "_getCurrentChar",
3025
+ value: function _getCurrentChar() {
3026
+ var activeRange = this._textSelectionRenderManager.getActiveRange();
3027
+ if (activeRange == null) {
3028
+ return;
3029
+ }
3030
+ var startOffset = activeRange.startOffset;
3031
+ var body = this._getCurrentBody();
3032
+ if (body == null || startOffset == null) {
3033
+ return;
3034
+ }
3035
+ var dataStream = body.dataStream;
3036
+ return dataStream[startOffset - 1];
3037
+ }
3038
+ },
3039
+ {
3040
+ /**
3041
+ * Disable the ref string generation mode. In the ref string generation mode,
3042
+ * users can select a certain area using the mouse and arrow keys, and convert the area into a ref string.
3043
+ */ key: "_disableForceKeepVisible",
3044
+ value: function _disableForceKeepVisible() {
3045
+ this._editorBridgeService.disableForceKeepVisible();
3046
+ this._formulaInputService.disableLockedSelectionInsert();
3047
+ this._currentInsertRefStringIndex = -1;
3048
+ this._selectionRenderService.disableRemainLast();
3049
+ if (this._arrowMoveActionState === 2 /* moveRefReady */ ) {
3050
+ this._arrowMoveActionState = 4 /* exitInput */ ;
3051
+ }
3052
+ }
3053
+ },
3054
+ {
3055
+ key: "_getCurrentBody",
3056
+ value: function _getCurrentBody() {
3057
+ var _documentModel_snapshot;
3058
+ var editorUnitId = this._editorBridgeService.getCurrentEditorId();
3059
+ if (editorUnitId == null) {
3060
+ return;
3061
+ }
3062
+ var documentModel = this._currentUniverService.getUniverDocInstance(editorUnitId);
3063
+ return documentModel === null || documentModel === void 0 ? void 0 : (_documentModel_snapshot = documentModel.snapshot) === null || _documentModel_snapshot === void 0 ? void 0 : _documentModel_snapshot.body;
3064
+ }
3065
+ },
3066
+ {
3067
+ key: "_getFormulaAndCellEditorBody",
3068
+ value: function _getFormulaAndCellEditorBody() {
3069
+ var _this = this;
3070
+ var unitIds = [
3071
+ import_core16.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
3072
+ import_core16.DOCS_NORMAL_EDITOR_UNIT_ID_KEY
3073
+ ];
3074
+ return unitIds.map(function(unitId) {
3075
+ var dataModel = _this._currentUniverService.getUniverDocInstance(unitId);
3076
+ return dataModel === null || dataModel === void 0 ? void 0 : dataModel.getBody();
3077
+ });
3078
+ }
3079
+ },
3080
+ {
3081
+ /**
3082
+ * Detect whether the user's input content is a formula. If it is a formula,
3083
+ * serialize the current input content into a sequenceNode;
3084
+ * otherwise, close the formula panel.
3085
+ * @param currentInputValue The text content entered by the user in the editor.
3086
+ * @returns
3087
+ */ key: "_contextSwitch",
3088
+ value: function _contextSwitch(currentInputValue) {
3089
+ if ((0, import_core16.isFormulaString)(currentInputValue)) {
3090
+ this._contextService.setContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA, true);
3091
+ var lastSequenceNodes = this._formulaEngineService.buildSequenceNodes(currentInputValue.replace(/\r/g, "").replace(/\n/g, "")) || [];
3092
+ this._formulaInputService.setSequenceNodes(lastSequenceNodes);
3093
+ var activeRange = this._textSelectionRenderManager.getActiveRange();
3094
+ if (activeRange == null) {
3095
+ return;
3096
+ }
3097
+ var startOffset = activeRange.startOffset;
3098
+ this._currentInsertRefStringIndex = startOffset - 1;
3099
+ } else {
3100
+ this._contextService.setContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA, false);
3101
+ this._formulaInputService.disableLockedSelectionChange();
3102
+ this._formulaInputService.disableLockedSelectionInsert();
3103
+ this._formulaInputService.clearSequenceNodes();
3104
+ this._hideFunctionPanel();
3105
+ }
3106
+ }
3107
+ },
3108
+ {
3109
+ key: "_getContextState",
3110
+ value: function _getContextState() {
3111
+ return this._contextService.getContextValue(import_core16.FOCUSING_EDITOR_INPUT_FORMULA);
3112
+ }
3113
+ },
3114
+ {
3115
+ /**
3116
+ * Switch from formula selection state to regular selection state.
3117
+ */ key: "_switchSelectionPlugin",
3118
+ value: function _switchSelectionPlugin() {
3119
+ if (this._getContextState() === true) {
3120
+ this._selectionManagerService.changePluginNoRefresh(FORMULA_REF_SELECTION_PLUGIN_NAME);
3121
+ var style = (0, import_sheets3.getNormalSelectionStyle)(this._themeService);
3122
+ style.strokeDash = 8;
3123
+ style.hasAutoFill = false;
3124
+ style.hasRowHeader = false;
3125
+ style.hasColumnHeader = false;
3126
+ this._selectionRenderService.setStyle(style);
3127
+ } else {
3128
+ this._selectionManagerService.changePluginNoRefresh(import_sheets3.NORMAL_SELECTION_PLUGIN_NAME);
3129
+ this._selectionRenderService.resetStyle();
3130
+ }
3131
+ }
3132
+ },
3133
+ {
3134
+ /**
3135
+ * Highlight cell editor and formula bar editor.
3136
+ */ key: "_highlightFormula",
3137
+ value: function _highlightFormula() {
3138
+ if (this._getContextState() === false) {
3139
+ return;
3140
+ }
3141
+ var sequenceNodes = this._formulaInputService.getSequenceNodes();
3142
+ var bodyList = this._getFormulaAndCellEditorBody().filter(function(b) {
3143
+ return !!b;
3144
+ });
3145
+ this._selectionManagerService.clear();
3146
+ if (sequenceNodes == null || sequenceNodes.length === 0) {
3147
+ bodyList.forEach(function(body) {
3148
+ return body.textRuns = [];
3149
+ });
3150
+ } else {
3151
+ var _this__buildTextRuns = this._buildTextRuns(sequenceNodes), textRuns = _this__buildTextRuns.textRuns, refSelections = _this__buildTextRuns.refSelections;
3152
+ bodyList.forEach(function(body) {
3153
+ return body.textRuns = textRuns;
3154
+ });
3155
+ this._refreshSelectionForReference(refSelections);
3156
+ }
3157
+ this._refreshFormulaAndCellEditor();
3158
+ }
3159
+ },
3160
+ {
3161
+ /**
3162
+ * :
3163
+ * #
3164
+ * Generate styles for formula text, highlighting references, text, numbers, and arrays.
3165
+ * @returns
3166
+ */ key: "_buildTextRuns",
3167
+ value: function _buildTextRuns(sequenceNodes) {
3168
+ var textRuns = [];
3169
+ var refSelections = [];
3170
+ var refColorIndex = 0;
3171
+ for(var i = 0, len = sequenceNodes.length; i < len; i++){
3172
+ var node = sequenceNodes[i];
3173
+ if (typeof node === "string") {
3174
+ continue;
3175
+ }
3176
+ var startIndex = node.startIndex, endIndex = node.endIndex, nodeType = node.nodeType, token = node.token;
3177
+ var themeColor = "";
3178
+ if (nodeType === import_engine_formula8.sequenceNodeType.REFERENCE) {
3179
+ var colorIndex = refColorIndex % this._formulaRefColors.length;
3180
+ themeColor = this._formulaRefColors[colorIndex];
3181
+ refSelections.push({
3182
+ refIndex: i,
3183
+ themeColor: themeColor,
3184
+ token: token
3185
+ });
3186
+ refColorIndex++;
3187
+ } else if (nodeType === import_engine_formula8.sequenceNodeType.NUMBER) {
3188
+ themeColor = this._numberColor;
3189
+ } else if (nodeType === import_engine_formula8.sequenceNodeType.STRING) {
3190
+ themeColor = this._stringColor;
3191
+ } else if (nodeType === import_engine_formula8.sequenceNodeType.ARRAY) {
3192
+ themeColor = this._stringColor;
3193
+ }
3194
+ if (themeColor.length > 0) {
3195
+ textRuns.push({
3196
+ st: startIndex + 1,
3197
+ ed: endIndex + 2,
3198
+ ts: {
3199
+ cl: {
3200
+ rgb: themeColor
3201
+ }
3202
+ }
3203
+ });
3204
+ }
3205
+ }
3206
+ return {
3207
+ textRuns: textRuns,
3208
+ refSelections: refSelections
3209
+ };
3210
+ }
3211
+ },
3212
+ {
3213
+ /**
3214
+ * Draw the referenced selection text based on the style and token.
3215
+ * @param refSelections
3216
+ * @returns
3217
+ */ key: "_refreshSelectionForReference",
3218
+ value: function _refreshSelectionForReference(refSelections) {
3219
+ var _this = this, _loop = function(i, len) {
3220
+ var _this__insertSelections_find;
3221
+ var refSelection = refSelections[i];
3222
+ var themeColor = refSelection.themeColor, token = refSelection.token, refIndex = refSelection.refIndex;
3223
+ var gridRange = (0, import_core16.deserializeRangeWithSheet)(token);
3224
+ var refUnitId = gridRange.unitId, sheetName = gridRange.sheetName, range = gridRange.range;
3225
+ if (refUnitId != null && refUnitId.length > 0 && unitId !== refUnitId) {
3226
+ return "continue";
3227
+ }
3228
+ var refSheetId = _this._getSheetIdByName(unitId, sheetName.trim());
3229
+ if (refSheetId != null && refSheetId !== sheetId) {
3230
+ return "continue";
3231
+ }
3232
+ var primary = (_this__insertSelections_find = _this._insertSelections.find(function(selection) {
3233
+ var _selection_range = selection.range, startRow = _selection_range.startRow, startColumn = _selection_range.startColumn, endRow = _selection_range.endRow, endColumn = _selection_range.endColumn;
3234
+ if (startRow === range.startRow && startColumn === range.startColumn && endRow === range.endRow && endColumn === range.endColumn) {
3235
+ return true;
3236
+ }
3237
+ return false;
3238
+ })) === null || _this__insertSelections_find === void 0 ? void 0 : _this__insertSelections_find.primary;
3239
+ if (primary != null) {
3240
+ lastRange = {
3241
+ range: range,
3242
+ primary: primary,
3243
+ style: getFormulaRefSelectionStyle(_this._themeService, themeColor, refIndex.toString())
3244
+ };
3245
+ return "continue";
3246
+ }
3247
+ selectionWithStyle.push({
3248
+ range: range,
3249
+ primary: primary,
3250
+ style: getFormulaRefSelectionStyle(_this._themeService, themeColor, refIndex.toString())
3251
+ });
3252
+ };
3253
+ var _this__getCurrentUnitIdAndSheetId = this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
3254
+ var selectionWithStyle = [];
3255
+ var workbook = this._currentUniverService.getUniverSheetInstance(unitId);
3256
+ var worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
3257
+ if (worksheet == null) {
3258
+ return;
3259
+ }
3260
+ var lastRange = null;
3261
+ for(var i = 0, len = refSelections.length; i < len; i++)_loop(i, len);
3262
+ if (lastRange) {
3263
+ selectionWithStyle.push(lastRange);
3264
+ }
3265
+ if (selectionWithStyle.length === 0) {
3266
+ return;
3267
+ }
3268
+ this._selectionManagerService.add(selectionWithStyle);
3269
+ }
3270
+ },
3271
+ {
3272
+ key: "_getSheetIdByName",
3273
+ value: function _getSheetIdByName(unitId, sheetName) {
3274
+ var _workbook_getSheetBySheetName;
3275
+ var workbook = this._currentUniverService.getUniverSheetInstance(unitId);
3276
+ return workbook === null || workbook === void 0 ? void 0 : (_workbook_getSheetBySheetName = workbook.getSheetBySheetName((0, import_engine_formula8.normalizeSheetName)(sheetName))) === null || _workbook_getSheetBySheetName === void 0 ? void 0 : _workbook_getSheetBySheetName.getSheetId();
3277
+ }
3278
+ },
3279
+ {
3280
+ key: "_getSheetNameById",
3281
+ value: function _getSheetNameById(unitId, sheetId) {
3282
+ var _workbook_getSheetBySheetId;
3283
+ var workbook = this._currentUniverService.getUniverSheetInstance(unitId);
3284
+ var sheetName = (workbook === null || workbook === void 0 ? void 0 : (_workbook_getSheetBySheetId = workbook.getSheetBySheetId(sheetId)) === null || _workbook_getSheetBySheetId === void 0 ? void 0 : _workbook_getSheetBySheetId.getName()) || "";
3285
+ if (sheetName.length > 0 && (0, import_engine_formula8.includeFormulaLexerToken)(sheetName)) {
3286
+ sheetName = "'".concat(sheetName, "'");
3287
+ }
3288
+ return sheetName;
3289
+ }
3290
+ },
3291
+ {
3292
+ key: "_getCurrentUnitIdAndSheetId",
3293
+ value: function _getCurrentUnitIdAndSheetId() {
3294
+ var current = this._sheetSkeletonManagerService.getCurrent();
3295
+ if (current == null) {
3296
+ var workbook = this._currentUniverService.getCurrentUniverSheetInstance();
3297
+ var worksheet = workbook.getActiveSheet();
3298
+ return {
3299
+ unitId: workbook.getUnitId(),
3300
+ sheetId: worksheet.getSheetId()
3301
+ };
3302
+ }
3303
+ var unitId = current.unitId, sheetId = current.sheetId;
3304
+ return {
3305
+ unitId: unitId,
3306
+ sheetId: sheetId
3307
+ };
3308
+ }
3309
+ },
3310
+ {
3311
+ /**
3312
+ * Convert the selection range to a ref string for the formula engine, such as A1:B1
3313
+ * @param range
3314
+ * @returns
3315
+ */ key: "_getRefString",
3316
+ value: function _getRefString(range) {
3317
+ var _this__getCurrentUnitIdAndSheetId = this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
3318
+ var refUnitId = "";
3319
+ var refSheetName = "";
3320
+ if (unitId === this._currentUnitId) {
3321
+ refUnitId = "";
3322
+ } else {
3323
+ refUnitId = unitId;
3324
+ }
3325
+ if (sheetId === this._currentSheetId) {
3326
+ refSheetName = "";
3327
+ } else {
3328
+ refSheetName = this._getSheetNameById(unitId, sheetId);
3329
+ }
3330
+ var startRow = range.startRow, endRow = range.endRow, startColumn = range.startColumn, endColumn = range.endColumn;
3331
+ return (0, import_core16.serializeRangeToRefString)({
3332
+ sheetName: refSheetName,
3333
+ unitId: refUnitId,
3334
+ range: {
3335
+ startRow: startRow,
3336
+ endRow: endRow,
3337
+ startColumn: startColumn,
3338
+ endColumn: endColumn
3339
+ }
3340
+ });
3341
+ }
3342
+ },
3343
+ {
3344
+ key: "_syncToEditor",
3345
+ value: /**
3346
+ * Restore the sequenceNode generated by the lexer to the text in the editor, and set the cursor position.
3347
+ * @param sequenceNodes
3348
+ * @param textSelectionOffset
3349
+ * @returns
3350
+ */ function _syncToEditor(sequenceNodes, textSelectionOffset) {
3351
+ var canUndo = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
3352
+ var _this = this;
3353
+ return _async_to_generator(function() {
3354
+ var dataStream, _this__buildTextRuns, textRuns, refSelections, activeRange, collapsed, style;
3355
+ return _ts_generator(this, function(_state) {
3356
+ switch(_state.label){
3357
+ case 0:
3358
+ dataStream = (0, import_engine_formula8.generateStringWithSequence)(sequenceNodes);
3359
+ _this__buildTextRuns = _this._buildTextRuns(sequenceNodes), textRuns = _this__buildTextRuns.textRuns, refSelections = _this__buildTextRuns.refSelections;
3360
+ _this._isSelectionMovingRefSelections = refSelections;
3361
+ activeRange = _this._textSelectionManagerService.getLast();
3362
+ if (activeRange == null) {
3363
+ return [
3364
+ 2
3365
+ ];
3366
+ }
3367
+ collapsed = activeRange.collapsed, style = activeRange.style;
3368
+ _this._currentInsertRefStringIndex = textSelectionOffset;
3369
+ return [
3370
+ 4,
3371
+ _this._fitEditorSize()
3372
+ ];
3373
+ case 1:
3374
+ _state.sent();
3375
+ if (canUndo) {
3376
+ _this._commandService.executeCommand(import_docs.ReplaceContentCommand.id, {
3377
+ unitId: _this._editorBridgeService.getCurrentEditorId(),
3378
+ body: {
3379
+ dataStream: "=".concat(dataStream),
3380
+ textRuns: textRuns
3381
+ },
3382
+ textRanges: [
3383
+ {
3384
+ startOffset: textSelectionOffset + 1,
3385
+ endOffset: textSelectionOffset + 1,
3386
+ collapsed: collapsed,
3387
+ style: style
3388
+ }
3389
+ ],
3390
+ segmentId: null
3391
+ });
3392
+ } else {
3393
+ _this._updateEditorModel("=".concat(dataStream, "\r\n"), textRuns);
3394
+ _this._textSelectionManagerService.replaceTextRanges([
3395
+ {
3396
+ startOffset: textSelectionOffset + 1,
3397
+ endOffset: textSelectionOffset + 1,
3398
+ collapsed: collapsed,
3399
+ style: style
3400
+ }
3401
+ ]);
3402
+ }
3403
+ return [
3404
+ 2
3405
+ ];
3406
+ }
3407
+ });
3408
+ })();
3409
+ }
3410
+ },
3411
+ {
3412
+ key: "_fitEditorSize",
3413
+ value: function _fitEditorSize() {
3414
+ var _this = this;
3415
+ return _async_to_generator(function() {
3416
+ var editorUnitId;
3417
+ return _ts_generator(this, function(_state) {
3418
+ switch(_state.label){
3419
+ case 0:
3420
+ editorUnitId = _this._editorBridgeService.getCurrentEditorId();
3421
+ if (editorUnitId == null) {
3422
+ return [
3423
+ 2
3424
+ ];
3425
+ }
3426
+ return [
3427
+ 4,
3428
+ _this._commandService.syncExecuteCommand(import_sheets_ui8.SetEditorResizeOperation.id, {
3429
+ unitId: editorUnitId
3430
+ })
3431
+ ];
3432
+ case 1:
3433
+ _state.sent();
3434
+ return [
3435
+ 2
3436
+ ];
3437
+ }
3438
+ });
3439
+ })();
3440
+ }
3441
+ },
3442
+ {
3443
+ /**
3444
+ * Update the editor's model value to facilitate formula updates.
3445
+ * @param dataStream
3446
+ * @param textRuns
3447
+ * @returns
3448
+ */ key: "_updateEditorModel",
3449
+ value: function _updateEditorModel(dataStream, textRuns) {
3450
+ var editorUnitId = this._editorBridgeService.getCurrentEditorId();
3451
+ if (editorUnitId == null) {
3452
+ return;
3453
+ }
3454
+ var documentDataModel = this._currentUniverService.getUniverDocInstance(editorUnitId);
3455
+ var docViewModel = this._docViewModelManagerService.getViewModel(editorUnitId);
3456
+ if (docViewModel == null || documentDataModel == null) {
3457
+ return;
3458
+ }
3459
+ var snapshot = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getSnapshot();
3460
+ if (snapshot == null) {
3461
+ return;
3462
+ }
3463
+ var newBody = {
3464
+ dataStream: dataStream,
3465
+ textRuns: textRuns
3466
+ };
3467
+ snapshot.body = newBody;
3468
+ docViewModel.reset(documentDataModel);
3469
+ }
3470
+ },
3471
+ {
3472
+ key: "_inertControlSelectionReplace",
3473
+ value: function _inertControlSelectionReplace(currentRange) {
3474
+ var _this = this;
3475
+ if (this._previousSequenceNodes == null) {
3476
+ this._previousSequenceNodes = this._formulaInputService.getSequenceNodes();
3477
+ }
3478
+ if (this._previousInsertRefStringIndex == null) {
3479
+ this._previousInsertRefStringIndex = this._currentInsertRefStringIndex;
3480
+ }
3481
+ var insertNodes = import_core16.Tools.deepClone(this._previousSequenceNodes);
3482
+ if (insertNodes == null) {
3483
+ return;
3484
+ }
3485
+ var refString = this._getRefString(currentRange);
3486
+ this._formulaInputService.setSequenceNodes(insertNodes);
3487
+ this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex, refString);
3488
+ this._syncToEditor(insertNodes, this._previousInsertRefStringIndex + refString.length);
3489
+ var selectionDatas = this._selectionRenderService.getSelectionDataWithStyle();
3490
+ this._insertSelections = [];
3491
+ selectionDatas.forEach(function(currentSelection) {
3492
+ var range = (0, import_sheets3.convertSelectionDataToRange)(currentSelection);
3493
+ _this._insertSelections.push(range);
3494
+ });
3495
+ }
3496
+ },
3497
+ {
3498
+ key: "_inertControlSelection",
3499
+ value: function _inertControlSelection(ranges) {
3500
+ var currentRange = ranges[ranges.length - 1];
3501
+ if ((ranges.length === this._previousRangesCount || this._previousRangesCount === 0) && this._previousSequenceNodes != null) {
3502
+ this._inertControlSelectionReplace(currentRange);
3503
+ } else {
3504
+ var insertNodes = this._formulaInputService.getSequenceNodes();
3505
+ if (insertNodes == null) {
3506
+ return;
3507
+ }
3508
+ var char = this._getCurrentChar();
3509
+ if (char == null) {
3510
+ return;
3511
+ }
3512
+ this._previousInsertRefStringIndex = this._currentInsertRefStringIndex;
3513
+ if (!this._matchRefDrawToken(char)) {
3514
+ this._formulaInputService.insertSequenceString(this._currentInsertRefStringIndex, import_engine_formula8.matchToken.COMMA);
3515
+ insertNodes = this._formulaInputService.getSequenceNodes();
3516
+ this._previousInsertRefStringIndex += 1;
3517
+ }
3518
+ this._previousSequenceNodes = import_core16.Tools.deepClone(insertNodes);
3519
+ var refString = this._getRefString(currentRange);
3520
+ this._formulaInputService.setSequenceNodes(insertNodes);
3521
+ this._formulaInputService.insertSequenceRef(this._previousInsertRefStringIndex, refString);
3522
+ this._selectionRenderService.disableSkipRemainLast();
3523
+ }
3524
+ this._arrowMoveActionState = 2 /* moveRefReady */ ;
3525
+ this._previousRangesCount = ranges.length;
3526
+ }
3527
+ },
3528
+ {
3529
+ key: "_updateRefSelectionStyle",
3530
+ value: function _updateRefSelectionStyle(refSelections) {
3531
+ var _this = this, _loop = function(i, len) {
3532
+ var refSelection = refSelections[i];
3533
+ var refIndex = refSelection.refIndex, themeColor = refSelection.themeColor, token = refSelection.token;
3534
+ var rangeWithSheet = (0, import_core16.deserializeRangeWithSheet)(token);
3535
+ var refUnitId = rangeWithSheet.unitId, sheetName = rangeWithSheet.sheetName, range = rangeWithSheet.range;
3536
+ if (refUnitId != null && refUnitId.length > 0 && unitId !== refUnitId) {
3537
+ return "continue";
3538
+ }
3539
+ var refSheetId = _this._getSheetIdByName(unitId, sheetName.trim());
3540
+ if (refSheetId != null && refSheetId !== sheetId) {
3541
+ return "continue";
3542
+ }
3543
+ var control = controls.find(function(c) {
3544
+ var _c_getRange = c.getRange(), startRow = _c_getRange.startRow, startColumn = _c_getRange.startColumn, endRow = _c_getRange.endRow, endColumn = _c_getRange.endColumn;
3545
+ if (startRow === range.startRow && startColumn === range.startColumn && endRow === range.endRow && endColumn === range.endColumn) {
3546
+ return true;
3547
+ }
3548
+ return false;
3549
+ });
3550
+ if (control == null) {
3551
+ return "continue";
3552
+ }
3553
+ var style = getFormulaRefSelectionStyle(_this._themeService, themeColor, refIndex.toString());
3554
+ control.updateStyle(style);
3555
+ };
3556
+ var controls = this._selectionRenderService.getCurrentControls();
3557
+ var _this__getCurrentUnitIdAndSheetId = this._getCurrentUnitIdAndSheetId(), unitId = _this__getCurrentUnitIdAndSheetId.unitId, sheetId = _this__getCurrentUnitIdAndSheetId.sheetId;
3558
+ for(var i = 0, len = refSelections.length; i < len; i++)_loop(i, len);
3559
+ }
3560
+ },
3561
+ {
3562
+ key: "_changeControlSelection",
3563
+ value: function _changeControlSelection(toRange, controlSelection) {
3564
+ var _controlSelection_selectionStyle;
3565
+ if (!toRange) {
3566
+ return;
3567
+ }
3568
+ this._formulaInputService.enableLockedSelectionChange();
3569
+ var id = (_controlSelection_selectionStyle = controlSelection.selectionStyle) === null || _controlSelection_selectionStyle === void 0 ? void 0 : _controlSelection_selectionStyle.id;
3570
+ if (id == null || !import_core16.Tools.isStringNumber(id)) {
3571
+ return;
3572
+ }
3573
+ var startRow = toRange.startRow, endRow = toRange.endRow, startColumn = toRange.startColumn, endColumn = toRange.endColumn;
3574
+ var refString = this._getRefString({
3575
+ startRow: startRow,
3576
+ endRow: endRow,
3577
+ startColumn: startColumn,
3578
+ endColumn: endColumn
3579
+ });
3580
+ var nodeIndex = Number(id);
3581
+ this._formulaInputService.updateSequenceRef(nodeIndex, refString);
3582
+ var sequenceNodes = this._formulaInputService.getSequenceNodes();
3583
+ var node = sequenceNodes[nodeIndex];
3584
+ if (typeof node === "string") {
3585
+ return;
3586
+ }
3587
+ this._syncToEditor(sequenceNodes, node.endIndex + 1);
3588
+ controlSelection.update(toRange);
3589
+ }
3590
+ },
3591
+ {
3592
+ key: "_refreshFormulaAndCellEditor",
3593
+ value: function _refreshFormulaAndCellEditor() {
3594
+ var unitIds = [
3595
+ import_core16.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
3596
+ import_core16.DOCS_NORMAL_EDITOR_UNIT_ID_KEY
3597
+ ];
3598
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3599
+ try {
3600
+ for(var _iterator = unitIds[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3601
+ var unitId = _step.value;
3602
+ var _documentComponent_getSkeleton;
3603
+ var editorObject = (0, import_sheets_ui8.getEditorObject)(unitId, this._renderManagerService);
3604
+ var documentComponent = editorObject === null || editorObject === void 0 ? void 0 : editorObject.document;
3605
+ if (documentComponent == null) {
3606
+ continue;
3607
+ }
3608
+ (_documentComponent_getSkeleton = documentComponent.getSkeleton()) === null || _documentComponent_getSkeleton === void 0 ? void 0 : _documentComponent_getSkeleton.calculate();
3609
+ documentComponent.makeDirty();
3610
+ }
3611
+ } catch (err) {
3612
+ _didIteratorError = true;
3613
+ _iteratorError = err;
3614
+ } finally{
3615
+ try {
3616
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3617
+ _iterator.return();
3618
+ }
3619
+ } finally{
3620
+ if (_didIteratorError) {
3621
+ throw _iteratorError;
3622
+ }
3623
+ }
3624
+ }
3625
+ }
3626
+ },
3627
+ {
3628
+ key: "_cursorStateListener",
3629
+ value: function _cursorStateListener() {
3630
+ var _this = this;
3631
+ var editorObject = this._getEditorObject();
3632
+ if (editorObject == null) {
3633
+ return;
3634
+ }
3635
+ var documentComponent = editorObject.document;
3636
+ this.disposeWithMe((0, import_core16.toDisposable)(documentComponent.onPointerDownObserver.add(function() {
3637
+ _this._arrowMoveActionState = 1 /* moveCursor */ ;
3638
+ _this._inputPanelState = 3 /* mouse */ ;
3639
+ })));
3640
+ }
3641
+ },
3642
+ {
3643
+ key: "_commandExecutedListener",
3644
+ value: function _commandExecutedListener() {
3645
+ var _this = this;
3646
+ var updateCommandList = [
3647
+ SelectEditorFormulaOperation.id
3648
+ ];
3649
+ this.disposeWithMe(this._commandService.onCommandExecuted(function(command) {
3650
+ if (updateCommandList.includes(command.id)) {
3651
+ var params = command.params;
3652
+ var keycode = params.keycode, metaKey = params.metaKey;
3653
+ if (keycode === import_ui7.KeyCode.ENTER) {
3654
+ if (_this._formulaPromptService.isSearching()) {
3655
+ _this._formulaPromptService.accept(true);
3656
+ return;
3657
+ }
3658
+ _this._editorBridgeService.changeVisible({
3659
+ visible: false,
3660
+ eventType: import_engine_render3.DeviceInputEventType.Keyboard,
3661
+ keycode: keycode
3662
+ });
3663
+ _this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
3664
+ direction: import_core16.Direction.DOWN
3665
+ });
3666
+ return;
3667
+ }
3668
+ if (keycode === import_ui7.KeyCode.TAB) {
3669
+ if (_this._formulaPromptService.isSearching()) {
3670
+ _this._formulaPromptService.accept(true);
3671
+ return;
3672
+ }
3673
+ _this._editorBridgeService.changeVisible({
3674
+ visible: false,
3675
+ eventType: import_engine_render3.DeviceInputEventType.Keyboard,
3676
+ keycode: keycode
3677
+ });
3678
+ _this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
3679
+ direction: import_core16.Direction.RIGHT
3680
+ });
3681
+ return;
3682
+ }
3683
+ if (_this._formulaPromptService.isSearching()) {
3684
+ if (keycode === import_ui7.KeyCode.ARROW_DOWN) {
3685
+ _this._formulaPromptService.navigate({
3686
+ direction: import_core16.Direction.DOWN
3687
+ });
3688
+ return;
3689
+ }
3690
+ if (keycode === import_ui7.KeyCode.ARROW_UP) {
3691
+ _this._formulaPromptService.navigate({
3692
+ direction: import_core16.Direction.UP
3693
+ });
3694
+ return;
3695
+ }
3696
+ }
3697
+ if (_this._arrowMoveActionState === 1 /* moveCursor */ ) {
3698
+ _this._moveInEditor(keycode);
3699
+ return;
3700
+ }
3701
+ if (_this._arrowMoveActionState === 4 /* exitInput */ ) {
3702
+ _this._editorBridgeService.changeVisible({
3703
+ visible: false,
3704
+ eventType: import_engine_render3.DeviceInputEventType.Keyboard,
3705
+ keycode: keycode
3706
+ });
3707
+ return;
3708
+ }
3709
+ if (_this._arrowMoveActionState === 2 /* moveRefReady */ ) {
3710
+ _this._arrowMoveActionState = 3 /* movingRef */ ;
3711
+ }
3712
+ var previousRanges = _this._selectionManagerService.getSelectionRanges() || [];
3713
+ if (previousRanges.length === 0) {
3714
+ var selectionData = _this._selectionManagerService.getLastByPlugin(import_sheets3.NORMAL_SELECTION_PLUGIN_NAME);
3715
+ if (selectionData != null) {
3716
+ var selectionDataNew = import_core16.Tools.deepClone(selectionData);
3717
+ _this._selectionManagerService.add([
3718
+ selectionDataNew
3719
+ ]);
3720
+ }
3721
+ }
3722
+ var direction = import_core16.Direction.DOWN;
3723
+ if (keycode === import_ui7.KeyCode.ARROW_DOWN) {
3724
+ direction = import_core16.Direction.DOWN;
3725
+ } else if (keycode === import_ui7.KeyCode.ARROW_UP) {
3726
+ direction = import_core16.Direction.UP;
3727
+ } else if (keycode === import_ui7.KeyCode.ARROW_LEFT) {
3728
+ direction = import_core16.Direction.LEFT;
3729
+ } else if (keycode === import_ui7.KeyCode.ARROW_RIGHT) {
3730
+ direction = import_core16.Direction.RIGHT;
3731
+ }
3732
+ if (metaKey === import_ui7.MetaKeys.CTRL_COMMAND) {
3733
+ _this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
3734
+ direction: direction,
3735
+ jumpOver: import_sheets_ui8.JumpOver.moveGap
3736
+ });
3737
+ } else if (metaKey === import_ui7.MetaKeys.SHIFT) {
3738
+ _this._commandService.executeCommand(import_sheets_ui8.ExpandSelectionCommand.id, {
3739
+ direction: direction
3740
+ });
3741
+ } else if (metaKey === META_KEY_CTRL_AND_SHIFT) {
3742
+ _this._commandService.executeCommand(import_sheets_ui8.ExpandSelectionCommand.id, {
3743
+ direction: direction,
3744
+ jumpOver: import_sheets_ui8.JumpOver.moveGap
3745
+ });
3746
+ } else {
3747
+ _this._commandService.executeCommand(import_sheets_ui8.MoveSelectionCommand.id, {
3748
+ direction: direction
3749
+ });
3750
+ }
3751
+ var ranges = _this._selectionManagerService.getSelectionRanges() || [];
3752
+ var currentRange = ranges[ranges.length - 1];
3753
+ _this._inertControlSelectionReplace(currentRange);
3754
+ }
3755
+ }));
3756
+ }
3757
+ },
3758
+ {
3759
+ key: "_moveInEditor",
3760
+ value: function _moveInEditor(keycode) {
3761
+ if (keycode == null) {
3762
+ return;
3763
+ }
3764
+ var direction = import_core16.Direction.LEFT;
3765
+ if (keycode === import_ui7.KeyCode.ARROW_DOWN) {
3766
+ direction = import_core16.Direction.DOWN;
3767
+ } else if (keycode === import_ui7.KeyCode.ARROW_UP) {
3768
+ direction = import_core16.Direction.UP;
3769
+ } else if (keycode === import_ui7.KeyCode.ARROW_RIGHT) {
3770
+ direction = import_core16.Direction.RIGHT;
3771
+ }
3772
+ this._commandService.executeCommand(import_docs.MoveCursorOperation.id, {
3773
+ direction: direction
3774
+ });
3775
+ }
3776
+ },
3777
+ {
3778
+ key: "_getEditorObject",
3779
+ value: function _getEditorObject() {
3780
+ return (0, import_sheets_ui8.getEditorObject)(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
3781
+ }
3782
+ }
3783
+ ]);
3784
+ return PromptController;
3785
+ }(import_core16.Disposable);
3786
+ PromptController = __decorateClass([
3787
+ (0, import_core16.OnLifecycle)(import_core16.LifecycleStages.Steady, PromptController),
3788
+ __decorateParam(0, import_core16.ICommandService),
3789
+ __decorateParam(1, (0, import_redi7.Inject)(import_core16.LocaleService)),
3790
+ __decorateParam(2, import_core16.IContextService),
3791
+ __decorateParam(3, import_engine_render3.ITextSelectionRenderManager),
3792
+ __decorateParam(4, (0, import_redi7.Inject)(import_sheets_ui8.IEditorBridgeService)),
3793
+ __decorateParam(5, (0, import_redi7.Inject)(IFormulaPromptService)),
3794
+ __decorateParam(6, (0, import_redi7.Inject)(import_engine_formula8.FormulaEngineService)),
3795
+ __decorateParam(7, import_engine_render3.IRenderManagerService),
3796
+ __decorateParam(8, (0, import_redi7.Inject)(import_core16.ThemeService)),
3797
+ __decorateParam(9, (0, import_redi7.Inject)(import_sheets3.SelectionManagerService)),
3798
+ __decorateParam(10, (0, import_redi7.Inject)(import_sheets_ui8.SheetSkeletonManagerService)),
3799
+ __decorateParam(11, import_core16.IUniverInstanceService),
3800
+ __decorateParam(12, (0, import_redi7.Inject)(import_sheets_ui8.ISelectionRenderService)),
3801
+ __decorateParam(13, (0, import_redi7.Inject)(IDescriptionService)),
3802
+ __decorateParam(14, (0, import_redi7.Inject)(import_docs.TextSelectionManagerService)),
3803
+ __decorateParam(15, IFormulaInputService),
3804
+ __decorateParam(16, (0, import_redi7.Inject)(import_docs.DocViewModelManagerService))
3805
+ ], PromptController);
3806
+ // src/locale/function-list/array/en-US.ts
3807
+ var en_US_default = {};
3808
+ // src/locale/function-list/compatibility/en-US.ts
3809
+ var en_US_default2 = {};
3810
+ // src/locale/function-list/cube/en-US.ts
3811
+ var en_US_default3 = {};
3812
+ // src/locale/function-list/database/en-US.ts
3813
+ var en_US_default4 = {};
3814
+ // src/locale/function-list/date/en-US.ts
3815
+ var en_US_default5 = {};
3816
+ // src/locale/function-list/engineering/en-US.ts
3817
+ var en_US_default6 = {};
3818
+ // src/locale/function-list/financial/en-US.ts
3819
+ var en_US_default7 = {};
3820
+ // src/locale/function-list/information/en-US.ts
3821
+ var en_US_default8 = {};
3822
+ // src/locale/function-list/logical/en-US.ts
3823
+ var en_US_default9 = {};
3824
+ // src/locale/function-list/lookup/en-US.ts
3825
+ var en_US_default10 = {};
3826
+ // src/locale/function-list/math/en-US.ts
3827
+ var en_US_default11 = {
3828
+ SUM: {
3829
+ description: "You can add individual values, cell references or ranges or a mix of all three.",
3830
+ abstract: "Adds its arguments",
3831
+ functionParameter: {
3832
+ number1: {
3833
+ name: "number1",
3834
+ detail: "The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8."
3835
+ },
3836
+ number2: {
3837
+ name: "number2",
3838
+ detail: "This is the second number you want to add. You can specify up to 255 numbers in this way."
3839
+ }
3840
+ }
3841
+ },
3842
+ SUMIF: {
3843
+ description: "Sum the values in a range that meet criteria that you specify.",
3844
+ abstract: "Adds the cells specified by a given criteria",
3845
+ functionParameter: {
3846
+ range: {
3847
+ name: "range",
3848
+ detail: "The range of cells that you want evaluated by criteria."
3849
+ },
3850
+ criteria: {
3851
+ name: "criteria",
3852
+ detail: "The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. Wildcard characters can be included - a question mark (?) to match any single character, an asterisk (*) to match any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character."
3853
+ },
3854
+ sum_range: {
3855
+ name: "sum_range",
3856
+ detail: "The actual cells to add, if you want to add cells other than those specified in the range argument. If the sum_range argument is omitted, Excel adds the cells that are specified in the range argument (the same cells to which the criteria is applied)."
3857
+ }
3858
+ }
3859
+ }
3860
+ };
3861
+ // src/locale/function-list/statistical/en-US.ts
3862
+ var en_US_default12 = {
3863
+ AVERAGE: {
3864
+ description: "Returns the average (arithmetic mean) of the arguments.",
3865
+ abstract: "Returns the average of its arguments",
3866
+ functionParameter: {
3867
+ number1: {
3868
+ name: "number1",
3869
+ detail: "The first number, cell reference, or range for which you want the average."
3870
+ },
3871
+ number2: {
3872
+ name: "number2",
3873
+ detail: "Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255."
3874
+ }
3875
+ }
3876
+ },
3877
+ COUNT: {
3878
+ description: "Counts the number of cells that contain numbers, and counts numbers within the list of arguments.",
3879
+ abstract: "Counts how many numbers are in the list of arguments",
3880
+ functionParameter: {
3881
+ value1: {
3882
+ name: "value1",
3883
+ detail: "The first item, cell reference, or range within which you want to count numbers."
3884
+ },
3885
+ value2: {
3886
+ name: "value2",
3887
+ detail: "Up to 255 additional items, cell references, or ranges within which you want to count numbers."
3888
+ }
3889
+ }
3890
+ },
3891
+ MAX: {
3892
+ description: "Returns the largest value in a set of values.",
3893
+ abstract: "Returns the maximum value in a list of arguments",
3894
+ functionParameter: {
3895
+ number1: {
3896
+ name: "number1",
3897
+ detail: "The first number, cell reference, or range to calculate the maximum value from."
3898
+ },
3899
+ number2: {
3900
+ name: "number2",
3901
+ detail: "Additional numbers, cell references or ranges to calculate the maximum value from, up to a maximum of 255."
3902
+ }
3903
+ }
3904
+ },
3905
+ MIN: {
3906
+ description: "Returns the smallest number in a set of values.",
3907
+ abstract: "Returns the minimum value in a list of arguments",
3908
+ functionParameter: {
3909
+ number1: {
3910
+ name: "number1",
3911
+ detail: "The first number, cell reference, or range to calculate the minimum value from."
3912
+ },
3913
+ number2: {
3914
+ name: "number2",
3915
+ detail: "Additional numbers, cell references or ranges to calculate the minimum value from, up to a maximum of 255."
3916
+ }
3917
+ }
3918
+ }
3919
+ };
3920
+ // src/locale/function-list/text/en-US.ts
3921
+ var en_US_default13 = {};
3922
+ // src/locale/function-list/univer/en-US.ts
3923
+ var en_US_default14 = {};
3924
+ // src/locale/function-list/web/en-US.ts
3925
+ var en_US_default15 = {};
3926
+ // src/locale/en-US.ts
3927
+ var en_US_default16 = {
3928
+ formula: {
3929
+ insert: {
3930
+ tooltip: "Functions",
3931
+ sum: "SUM",
3932
+ average: "AVERAGE",
3933
+ count: "COUNT",
3934
+ max: "MAX",
3935
+ min: "MIN",
3936
+ more: "More Functions..."
3937
+ },
3938
+ functionList: _object_spread({}, en_US_default7, en_US_default5, en_US_default11, en_US_default12, en_US_default10, en_US_default4, en_US_default13, en_US_default9, en_US_default8, en_US_default6, en_US_default3, en_US_default2, en_US_default15, en_US_default, en_US_default14),
3939
+ prompt: {
3940
+ helpExample: "EXAMPLE",
3941
+ helpAbstract: "ABOUT",
3942
+ required: "Required.",
3943
+ optional: "Optional."
3944
+ },
3945
+ functionType: {
3946
+ financial: "Financial",
3947
+ date: "Date & Time",
3948
+ math: "Math & Trig",
3949
+ statistical: "Statistical",
3950
+ lookup: "Lookup & Reference",
3951
+ database: "Database",
3952
+ text: "Text",
3953
+ logical: "Logical",
3954
+ information: "Information",
3955
+ engineering: "Engineering",
3956
+ cube: "Cube",
3957
+ compatibility: "Compatibility",
3958
+ web: "Web",
3959
+ array: "Array",
3960
+ univer: "Univer"
3961
+ },
3962
+ moreFunctions: {
3963
+ confirm: "Confirm",
3964
+ prev: "Previous",
3965
+ next: "Next",
3966
+ searchFunctionPlaceholder: "Search function",
3967
+ allFunctions: "All Functions",
3968
+ syntax: "SYNTAX"
3969
+ }
3970
+ }
3971
+ };
3972
+ // src/locale/function-list/array/zh-CN.ts
3973
+ var zh_CN_default = {};
3974
+ // src/locale/function-list/compatibility/zh-CN.ts
3975
+ var zh_CN_default2 = {};
3976
+ // src/locale/function-list/cube/zh-CN.ts
3977
+ var zh_CN_default3 = {};
3978
+ // src/locale/function-list/database/zh-CN.ts
3979
+ var zh_CN_default4 = {};
3980
+ // src/locale/function-list/date/zh-CN.ts
3981
+ var zh_CN_default5 = {};
3982
+ // src/locale/function-list/engineering/zh-CN.ts
3983
+ var zh_CN_default6 = {};
3984
+ // src/locale/function-list/financial/zh-CN.ts
3985
+ var zh_CN_default7 = {};
3986
+ // src/locale/function-list/information/zh-CN.ts
3987
+ var zh_CN_default8 = {};
3988
+ // src/locale/function-list/logical/zh-CN.ts
3989
+ var zh_CN_default9 = {};
3990
+ // src/locale/function-list/lookup/zh-CN.ts
3991
+ var zh_CN_default10 = {};
3992
+ // src/locale/function-list/math/zh-CN.ts
3993
+ var zh_CN_default11 = {
3994
+ SUM: {
3995
+ description: "将单个值、单元格引用或是区域相加,或者将三者的组合相加。",
3996
+ abstract: "求参数的和",
3997
+ functionParameter: {
3998
+ number1: {
3999
+ name: "数值1",
4000
+ detail: "要相加的第一个数字。 该数字可以是 4 之类的数字,B6 之类的单元格引用或 B2:B8 之类的单元格范围。"
4001
+ },
4002
+ number2: {
4003
+ name: "数值2",
4004
+ detail: "这是要相加的第二个数字。 可以按照这种方式最多指定 255 个数字。"
4005
+ }
4006
+ }
4007
+ },
4008
+ SUMIF: {
4009
+ description: "对范围中符合指定条件的值求和。",
4010
+ abstract: "按给定条件对指定单元格求和",
4011
+ functionParameter: {
4012
+ range: {
4013
+ name: "范围",
4014
+ detail: "要根据条件进行检测的范围。"
4015
+ },
4016
+ criteria: {
4017
+ name: "条件",
4018
+ detail: "以数字、表达式、单元格引用、文本或函数的形式来定义将添加哪些单元格。可包括的通配符字符 - 问号(?)以匹配任意单个字符,星号(*)以匹配任意字符序列。 如果要查找实际的问号或星号,请在该字符前键入波形符(~)。"
4019
+ },
4020
+ sum_range: {
4021
+ name: "求和范围",
4022
+ detail: "要添加的实际单元格,如果要添加在范围参数指定以外的其他单元格。 如果省略sum_range参数,Excel就会添加范围参数中指定的单元格(与应用标准的单元格相同)。"
4023
+ }
4024
+ }
4025
+ }
4026
+ };
4027
+ // src/locale/function-list/statistical/zh-CN.ts
4028
+ var zh_CN_default12 = {
4029
+ AVERAGE: {
4030
+ description: "返回参数的平均值(算术平均值)。",
4031
+ abstract: "返回参数平均值",
4032
+ functionParameter: {
4033
+ number1: {
4034
+ name: "数值1",
4035
+ detail: "要计算平均值的第一个数字、单元格引用或单元格区域。"
4036
+ },
4037
+ number2: {
4038
+ name: "数值2",
4039
+ detail: "要计算平均值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"
4040
+ }
4041
+ }
4042
+ },
4043
+ COUNT: {
4044
+ description: "计算包含数字的单元格个数以及参数列表中数字的个数。",
4045
+ abstract: "计算参数列表中数字的个数",
4046
+ functionParameter: {
4047
+ value1: {
4048
+ name: "值1",
4049
+ detail: "要计算其中数字的个数的第一项、单元格引用或区域。"
4050
+ },
4051
+ value2: {
4052
+ name: "值2",
4053
+ detail: "要计算其中数字的个数的其他项、单元格引用或区域,最多可包含 255 个。"
4054
+ }
4055
+ }
4056
+ },
4057
+ MAX: {
4058
+ description: "返回一组值中的最大值。",
4059
+ abstract: "返回参数列表中的最大值",
4060
+ functionParameter: {
4061
+ number1: {
4062
+ name: "数值1",
4063
+ detail: "要计算最大值的第一个数字、单元格引用或单元格区域。"
4064
+ },
4065
+ number2: {
4066
+ name: "数值2",
4067
+ detail: "要计算最大值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"
4068
+ }
4069
+ }
4070
+ },
4071
+ MIN: {
4072
+ description: "返回一组值中的最小值。",
4073
+ abstract: "返回参数列表中的最小值",
4074
+ functionParameter: {
4075
+ number1: {
4076
+ name: "数值1",
4077
+ detail: "要计算最小值的第一个数字、单元格引用或单元格区域。"
4078
+ },
4079
+ number2: {
4080
+ name: "数值2",
4081
+ detail: "要计算最小值的其他数字、单元格引用或单元格区域,最多可包含 255 个。"
4082
+ }
4083
+ }
4084
+ }
4085
+ };
4086
+ // src/locale/function-list/text/zh-CN.ts
4087
+ var zh_CN_default13 = {};
4088
+ // src/locale/function-list/univer/zh-CN.ts
4089
+ var zh_CN_default14 = {};
4090
+ // src/locale/function-list/web/zh-CN.ts
4091
+ var zh_CN_default15 = {};
4092
+ // src/locale/zh-CN.ts
4093
+ var zh_CN_default16 = {
4094
+ formula: {
4095
+ insert: {
4096
+ tooltip: "函数",
4097
+ sum: "求和",
4098
+ average: "平均值",
4099
+ count: "计数",
4100
+ max: "最大值",
4101
+ min: "最小值",
4102
+ more: "更多函数..."
4103
+ },
4104
+ functionList: _object_spread({}, zh_CN_default7, zh_CN_default5, zh_CN_default11, zh_CN_default12, zh_CN_default10, zh_CN_default4, zh_CN_default13, zh_CN_default9, zh_CN_default8, zh_CN_default6, zh_CN_default3, zh_CN_default2, zh_CN_default15, zh_CN_default, zh_CN_default14),
4105
+ prompt: {
4106
+ helpExample: "示例",
4107
+ helpAbstract: "简介",
4108
+ required: "必需。",
4109
+ optional: "可选。"
4110
+ },
4111
+ functionType: {
4112
+ financial: "财务",
4113
+ date: "日期与时间",
4114
+ math: "数学与三角函数",
4115
+ statistical: "统计",
4116
+ lookup: "查找与引用",
4117
+ database: "数据库",
4118
+ text: "文本",
4119
+ logical: "逻辑",
4120
+ information: "信息",
4121
+ engineering: "工程",
4122
+ cube: "多维数据集",
4123
+ compatibility: "兼容性",
4124
+ web: "Web",
4125
+ array: "数组",
4126
+ univer: "Univer"
4127
+ },
4128
+ moreFunctions: {
4129
+ confirm: "应用",
4130
+ prev: "上一步",
4131
+ next: "下一步",
4132
+ searchFunctionPlaceholder: "搜索函数",
4133
+ allFunctions: "全部函数",
4134
+ syntax: "语法"
4135
+ }
4136
+ }
4137
+ };
4138
+ // src/formula-ui-plugin.ts
4139
+ var FormulaUIPlugin = (_class = /*#__PURE__*/ function(_superClass) {
4140
+ _inherits(_class, _superClass);
4141
+ var _super = _create_super(_class);
4142
+ function _class(_config, _injector, _localeService, _currentUniverService) {
4143
+ _class_call_check(this, _class);
4144
+ var _this;
4145
+ _this = _super.call(this, FORMULA_UI_PLUGIN_NAME);
4146
+ _this._config = _config;
4147
+ _this._injector = _injector;
4148
+ _this._localeService = _localeService;
4149
+ _this._currentUniverService = _currentUniverService;
4150
+ return _this;
4151
+ }
4152
+ _create_class(_class, [
4153
+ {
4154
+ key: "initialize",
4155
+ value: function initialize() {
4156
+ var _this = this;
4157
+ this._localeService.load({
4158
+ enUS: en_US_default16
4159
+ });
4160
+ var dependencies = [
4161
+ // services
4162
+ [
4163
+ IFormulaPromptService,
4164
+ {
4165
+ useClass: FormulaPromptService
4166
+ }
4167
+ ],
4168
+ [
4169
+ IFormulaInputService,
4170
+ {
4171
+ useClass: FormulaInputService
4172
+ }
4173
+ ],
4174
+ [
4175
+ IDescriptionService,
4176
+ {
4177
+ useFactory: function() {
4178
+ var _this__config;
4179
+ return _this._injector.createInstance(DescriptionService, ((_this__config = _this._config) === null || _this__config === void 0 ? void 0 : _this__config.description) || []);
4180
+ }
4181
+ }
4182
+ ],
4183
+ // controllers
4184
+ [
4185
+ FormulaUIController
4186
+ ],
4187
+ [
4188
+ PromptController
4189
+ ],
4190
+ [
4191
+ FormulaInputController
4192
+ ],
4193
+ [
4194
+ FormulaAutoFillController
4195
+ ]
4196
+ ];
4197
+ dependencies.forEach(function(dependency) {
4198
+ return _this._injector.add(dependency);
4199
+ });
4200
+ }
4201
+ },
4202
+ {
4203
+ key: "onReady",
4204
+ value: function onReady() {
4205
+ this.initialize();
4206
+ }
4207
+ }
4208
+ ]);
4209
+ return _class;
4210
+ }(_import_core17_Plugin = import_core17.Plugin), _define_property(_class, "type", import_core17.PluginType.Sheet), _class);
4211
+ FormulaUIPlugin = __decorateClass([
4212
+ __decorateParam(1, (0, import_redi8.Inject)(import_redi8.Injector)),
4213
+ __decorateParam(2, (0, import_redi8.Inject)(import_core17.LocaleService)),
4214
+ __decorateParam(3, import_core17.IUniverInstanceService)
4215
+ ], FormulaUIPlugin);