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