@leankylin-sheet/formula-parser 3.1.28 → 3.1.30

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 (204) hide show
  1. package/{lib/grammar-parser/grammar-parser.js → dist/index.esm.js} +856 -46
  2. package/{es/grammar-parser/grammar-parser.js → dist/index.js} +903 -42
  3. package/dist/packages/core/src/api/cell.d.ts +10 -0
  4. package/dist/packages/core/src/api/common.d.ts +57 -0
  5. package/dist/packages/core/src/api/errors.d.ts +2 -0
  6. package/dist/packages/core/src/api/index.d.ts +9 -0
  7. package/dist/packages/core/src/api/merge.d.ts +5 -0
  8. package/dist/packages/core/src/api/range.d.ts +22 -0
  9. package/dist/packages/core/src/api/rowcol.d.ts +14 -0
  10. package/dist/packages/core/src/api/sheet.d.ts +10 -0
  11. package/dist/packages/core/src/api/workbook.d.ts +15 -0
  12. package/dist/packages/core/src/canvas.d.ts +56 -0
  13. package/dist/packages/core/src/context.d.ts +193 -0
  14. package/dist/packages/core/src/events/copy.d.ts +2 -0
  15. package/dist/packages/core/src/events/index.d.ts +4 -0
  16. package/dist/packages/core/src/events/keyboard.d.ts +6 -0
  17. package/dist/packages/core/src/events/mouse.d.ts +25 -0
  18. package/dist/packages/core/src/events/paste.d.ts +5 -0
  19. package/dist/packages/core/src/index.d.ts +10 -0
  20. package/dist/packages/core/src/locale/en.d.ts +1028 -0
  21. package/dist/packages/core/src/locale/es.d.ts +1132 -0
  22. package/dist/packages/core/src/locale/index.d.ts +1046 -0
  23. package/dist/packages/core/src/locale/zh.d.ts +1045 -0
  24. package/dist/packages/core/src/locale/zh_tw.d.ts +1185 -0
  25. package/dist/packages/core/src/modules/ConditionFormat.d.ts +17 -0
  26. package/dist/packages/core/src/modules/border.d.ts +3 -0
  27. package/dist/packages/core/src/modules/cell.d.ts +32 -0
  28. package/dist/packages/core/src/modules/clipboard.d.ts +3 -0
  29. package/dist/packages/core/src/modules/color.d.ts +1 -0
  30. package/dist/packages/core/src/modules/comment.d.ts +96 -0
  31. package/dist/packages/core/src/modules/conditionalFormat.d.ts +2 -0
  32. package/dist/packages/core/src/modules/cursor.d.ts +3 -0
  33. package/dist/packages/core/src/modules/dataVerification.d.ts +11 -0
  34. package/dist/packages/core/src/modules/dropCell.d.ts +10 -0
  35. package/dist/packages/core/src/modules/filter.d.ts +45 -0
  36. package/dist/packages/core/src/modules/format.d.ts +6 -0
  37. package/dist/packages/core/src/modules/formula.d.ts +53 -0
  38. package/dist/packages/core/src/modules/freeze.d.ts +5 -0
  39. package/dist/packages/core/src/modules/hyperlink.d.ts +21 -0
  40. package/dist/packages/core/src/modules/image.d.ts +31 -0
  41. package/dist/packages/core/src/modules/index.d.ts +35 -0
  42. package/dist/packages/core/src/modules/inline-string.d.ts +36 -0
  43. package/dist/packages/core/src/modules/location.d.ts +6 -0
  44. package/dist/packages/core/src/modules/locationCondition.d.ts +21 -0
  45. package/dist/packages/core/src/modules/merge.d.ts +3 -0
  46. package/dist/packages/core/src/modules/mobile.d.ts +5 -0
  47. package/dist/packages/core/src/modules/moveCells.d.ts +5 -0
  48. package/dist/packages/core/src/modules/protection.d.ts +5 -0
  49. package/dist/packages/core/src/modules/refresh.d.ts +3 -0
  50. package/dist/packages/core/src/modules/rowcol.d.ts +19 -0
  51. package/dist/packages/core/src/modules/screenshot.d.ts +2 -0
  52. package/dist/packages/core/src/modules/searchReplace.d.ts +36 -0
  53. package/dist/packages/core/src/modules/selection.d.ts +47 -0
  54. package/dist/packages/core/src/modules/sheet.d.ts +10 -0
  55. package/dist/packages/core/src/modules/sort.d.ts +7 -0
  56. package/dist/packages/core/src/modules/splitColumn.d.ts +5 -0
  57. package/dist/packages/core/src/modules/ssf.d.ts +2 -0
  58. package/dist/packages/core/src/modules/text.d.ts +10 -0
  59. package/dist/packages/core/src/modules/toolbar.d.ts +32 -0
  60. package/dist/packages/core/src/modules/validation.d.ts +19 -0
  61. package/dist/packages/core/src/modules/zoom.d.ts +3 -0
  62. package/dist/packages/core/src/settings.d.ts +132 -0
  63. package/dist/packages/core/src/types.d.ts +351 -0
  64. package/dist/packages/core/src/utils/index.d.ts +17 -0
  65. package/dist/packages/core/src/utils/patch.d.ts +37 -0
  66. package/dist/packages/formula-parser/src/error.d.ts +10 -0
  67. package/dist/packages/formula-parser/src/evaluate-by-operator/evaluate-by-operator.d.ts +2 -0
  68. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/add.d.ts +6 -0
  69. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/ampersand.d.ts +6 -0
  70. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/divide.d.ts +6 -0
  71. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/equal.d.ts +6 -0
  72. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/formula-function.d.ts +7 -0
  73. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/greater-than-or-equal.d.ts +6 -0
  74. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/greater-than.d.ts +6 -0
  75. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/less-than-or-equal.d.ts +6 -0
  76. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/less-than.d.ts +6 -0
  77. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/minus.d.ts +6 -0
  78. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/multiply.d.ts +6 -0
  79. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/not-equal.d.ts +6 -0
  80. package/dist/packages/formula-parser/src/evaluate-by-operator/operator/power.d.ts +6 -0
  81. package/dist/packages/formula-parser/src/grammar-parser/grammar-parser.d.ts +4 -0
  82. package/dist/packages/formula-parser/src/helper/cell.d.ts +6 -0
  83. package/dist/packages/formula-parser/src/helper/number.d.ts +2 -0
  84. package/dist/packages/formula-parser/src/helper/string.d.ts +1 -0
  85. package/{es/index.js → dist/packages/formula-parser/src/index.d.ts} +5 -5
  86. package/dist/packages/formula-parser/src/parser.d.ts +20 -0
  87. package/dist/packages/formula-parser/src/supported-formulas.d.ts +2 -0
  88. package/dist/packages/react/src/components/CellOptions/index.d.ts +4 -0
  89. package/dist/packages/react/src/components/ChangeColor/index.d.ts +7 -0
  90. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +6 -0
  91. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +7 -0
  92. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +3 -0
  93. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +3 -0
  94. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +8 -0
  95. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +4 -0
  96. package/dist/packages/react/src/components/ContextMenu/index.d.ts +4 -0
  97. package/dist/packages/react/src/components/CustomSort/index.d.ts +4 -0
  98. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +4 -0
  99. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +4 -0
  100. package/dist/packages/react/src/components/DataVerification/index.d.ts +4 -0
  101. package/dist/packages/react/src/components/Dialog/index.d.ts +12 -0
  102. package/dist/packages/react/src/components/FilterOption/index.d.ts +5 -0
  103. package/dist/packages/react/src/components/FormatSearch/index.d.ts +6 -0
  104. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +5 -0
  105. package/dist/packages/react/src/components/FxEditor/CalcInfo.d.ts +3 -0
  106. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +3 -0
  107. package/dist/packages/react/src/components/FxEditor/index.d.ts +4 -0
  108. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +3 -0
  109. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +5 -0
  110. package/dist/packages/react/src/components/LocationCondition/index.d.ts +3 -0
  111. package/dist/packages/react/src/components/MessageBox/index.d.ts +9 -0
  112. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +3 -0
  113. package/dist/packages/react/src/components/SVGDefines.d.ts +3 -0
  114. package/dist/packages/react/src/components/SVGIcon.d.ts +9 -0
  115. package/dist/packages/react/src/components/SearchReplace/index.d.ts +4 -0
  116. package/dist/packages/react/src/components/Sheet/index.d.ts +8 -0
  117. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +8 -0
  118. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +9 -0
  119. package/dist/packages/react/src/components/SheetList/index.d.ts +4 -0
  120. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +3 -0
  121. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +11 -0
  122. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +4 -0
  123. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +4 -0
  124. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +3 -0
  125. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +3 -0
  126. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +7 -0
  127. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +4 -0
  128. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +8 -0
  129. package/dist/packages/react/src/components/SheetTab/index.d.ts +4 -0
  130. package/dist/packages/react/src/components/SplitColumn/index.d.ts +3 -0
  131. package/dist/packages/react/src/components/Toolbar/Button.d.ts +11 -0
  132. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +6 -0
  133. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +10 -0
  134. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +7 -0
  135. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +11 -0
  136. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +8 -0
  137. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +9 -0
  138. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +4 -0
  139. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +6 -0
  140. package/dist/packages/react/src/components/Toolbar/Select.d.ts +14 -0
  141. package/dist/packages/react/src/components/Toolbar/index.d.ts +7 -0
  142. package/dist/packages/react/src/components/Workbook/api.d.ts +121 -0
  143. package/dist/packages/react/src/components/Workbook/index.d.ts +130 -0
  144. package/dist/packages/react/src/components/ZoomControl/index.d.ts +4 -0
  145. package/dist/packages/react/src/components/index.d.ts +3 -0
  146. package/dist/packages/react/src/context/index.d.ts +25 -0
  147. package/dist/packages/react/src/context/modal.d.ts +10 -0
  148. package/dist/packages/react/src/hooks/useAlert.d.ts +4 -0
  149. package/dist/packages/react/src/hooks/useDialog.d.ts +5 -0
  150. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +2 -0
  151. package/dist/packages/react/src/hooks/usePrevious.d.ts +2 -0
  152. package/dist/packages/react/src/index.d.ts +1 -0
  153. package/dist/stories/data/cell.d.ts +1180 -0
  154. package/dist/stories/data/dataVerification.d.ts +131 -0
  155. package/dist/stories/data/empty.d.ts +10 -0
  156. package/dist/stories/data/formula.d.ts +362 -0
  157. package/dist/stories/data/freeze.d.ts +34 -0
  158. package/dist/stories/data/protected.d.ts +40 -0
  159. package/dist/stories/utils.d.ts +1 -0
  160. package/package.json +6 -18
  161. package/LICENSE +0 -21
  162. package/es/error.js +0 -45
  163. package/es/evaluate-by-operator/evaluate-by-operator.js +0 -70
  164. package/es/evaluate-by-operator/operator/add.js +0 -16
  165. package/es/evaluate-by-operator/operator/ampersand.js +0 -10
  166. package/es/evaluate-by-operator/operator/divide.js +0 -21
  167. package/es/evaluate-by-operator/operator/equal.js +0 -5
  168. package/es/evaluate-by-operator/operator/formula-function.js +0 -40
  169. package/es/evaluate-by-operator/operator/greater-than-or-equal.js +0 -5
  170. package/es/evaluate-by-operator/operator/greater-than.js +0 -5
  171. package/es/evaluate-by-operator/operator/less-than-or-equal.js +0 -5
  172. package/es/evaluate-by-operator/operator/less-than.js +0 -5
  173. package/es/evaluate-by-operator/operator/minus.js +0 -16
  174. package/es/evaluate-by-operator/operator/multiply.js +0 -16
  175. package/es/evaluate-by-operator/operator/not-equal.js +0 -5
  176. package/es/evaluate-by-operator/operator/power.js +0 -11
  177. package/es/grammar-parser/grammar-parser.jison +0 -230
  178. package/es/helper/cell.js +0 -117
  179. package/es/helper/number.js +0 -25
  180. package/es/helper/string.js +0 -13
  181. package/es/parser.js +0 -306
  182. package/es/supported-formulas.js +0 -3
  183. package/lib/error.js +0 -53
  184. package/lib/evaluate-by-operator/evaluate-by-operator.js +0 -77
  185. package/lib/evaluate-by-operator/operator/add.js +0 -23
  186. package/lib/evaluate-by-operator/operator/ampersand.js +0 -17
  187. package/lib/evaluate-by-operator/operator/divide.js +0 -28
  188. package/lib/evaluate-by-operator/operator/equal.js +0 -12
  189. package/lib/evaluate-by-operator/operator/formula-function.js +0 -51
  190. package/lib/evaluate-by-operator/operator/greater-than-or-equal.js +0 -12
  191. package/lib/evaluate-by-operator/operator/greater-than.js +0 -12
  192. package/lib/evaluate-by-operator/operator/less-than-or-equal.js +0 -12
  193. package/lib/evaluate-by-operator/operator/less-than.js +0 -12
  194. package/lib/evaluate-by-operator/operator/minus.js +0 -23
  195. package/lib/evaluate-by-operator/operator/multiply.js +0 -23
  196. package/lib/evaluate-by-operator/operator/not-equal.js +0 -12
  197. package/lib/evaluate-by-operator/operator/power.js +0 -18
  198. package/lib/grammar-parser/grammar-parser.jison +0 -230
  199. package/lib/helper/cell.js +0 -128
  200. package/lib/helper/number.js +0 -32
  201. package/lib/helper/string.js +0 -19
  202. package/lib/index.js +0 -115
  203. package/lib/parser.js +0 -314
  204. package/lib/supported-formulas.js +0 -12
package/lib/parser.js DELETED
@@ -1,314 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _tinyEmitter = _interopRequireDefault(require("tiny-emitter"));
9
- var _evaluateByOperator = _interopRequireDefault(require("./evaluate-by-operator/evaluate-by-operator"));
10
- var _grammarParser = require("./grammar-parser/grammar-parser");
11
- var _string = require("./helper/string");
12
- var _number = require("./helper/number");
13
- var _error = _interopRequireWildcard(require("./error"));
14
- var _cell = require("./helper/cell");
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
22
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
23
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
26
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
27
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
28
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
29
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
30
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
31
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
36
- /**
37
- * @class Parser
38
- */
39
- var Parser = /*#__PURE__*/function (_Emitter) {
40
- function Parser() {
41
- var _this;
42
- _classCallCheck(this, Parser);
43
- _this = _callSuper(this, Parser);
44
- _this.parser = new _grammarParser.Parser();
45
- _this.parser.yy = {
46
- toNumber: _number.toNumber,
47
- trimEdges: _string.trimEdges,
48
- invertNumber: _number.invertNumber,
49
- throwError: function throwError(errorName) {
50
- return _this._throwError(errorName);
51
- },
52
- callVariable: function callVariable(variable) {
53
- return _this._callVariable(variable);
54
- },
55
- evaluateByOperator: _evaluateByOperator["default"],
56
- callFunction: function callFunction(name, params) {
57
- return _this._callFunction(name, params);
58
- },
59
- cellValue: function cellValue(value) {
60
- return _this._callCellValue(value);
61
- },
62
- rangeValue: function rangeValue(start, end) {
63
- return _this._callRangeValue(start, end);
64
- }
65
- };
66
- _this.variables = Object.create(null);
67
- _this.functions = Object.create(null);
68
- _this.options = Object.create(null);
69
- _this.setVariable('TRUE', true).setVariable('FALSE', false).setVariable('NULL', null);
70
- return _this;
71
- }
72
-
73
- /**
74
- * Parse formula expression.
75
- *
76
- * @param {string} expression to parse.
77
- * @param {object} options additional params.
78
- * @param {string} options.sheetId id of sheet which the formula expression belongs to.
79
- * @return {*} Returns an object with tow properties `error` and `result`.
80
- */
81
- _inherits(Parser, _Emitter);
82
- return _createClass(Parser, [{
83
- key: "parse",
84
- value: function parse(expression, options) {
85
- var result = null;
86
- var error = null;
87
- this.options = options;
88
- try {
89
- if (expression === '') {
90
- result = '';
91
- } else {
92
- result = this.parser.parse(expression);
93
- }
94
- } catch (ex) {
95
- var message = (0, _error["default"])(ex.message);
96
- if (message) {
97
- error = message;
98
- } else {
99
- error = (0, _error["default"])(_error.ERROR);
100
- }
101
- }
102
- if (result instanceof Error) {
103
- error = (0, _error["default"])(result.message) || (0, _error["default"])(_error.ERROR);
104
- result = null;
105
- }
106
- return {
107
- error: error,
108
- result: result
109
- };
110
- }
111
-
112
- /**
113
- * Set predefined variable name which can be visible while parsing formula expression.
114
- *
115
- * @param {String} name Variable name.
116
- * @param {*} value Variable value.
117
- * @returns {Parser}
118
- */
119
- }, {
120
- key: "setVariable",
121
- value: function setVariable(name, value) {
122
- this.variables[name] = value;
123
- return this;
124
- }
125
-
126
- /**
127
- * Get variable name.
128
- *
129
- * @param {String} name Variable name.
130
- * @returns {*}
131
- */
132
- }, {
133
- key: "getVariable",
134
- value: function getVariable(name) {
135
- return this.variables[name];
136
- }
137
-
138
- /**
139
- * Retrieve variable value by its name.
140
- *
141
- * @param name Variable name.
142
- * @returns {*}
143
- * @private
144
- */
145
- }, {
146
- key: "_callVariable",
147
- value: function _callVariable(name) {
148
- var value = this.getVariable(name);
149
- this.emit('callVariable', name, function (newValue) {
150
- if (newValue !== void 0) {
151
- value = newValue;
152
- }
153
- });
154
- if (value === void 0) {
155
- throw Error(_error.ERROR_NAME);
156
- }
157
- return value;
158
- }
159
-
160
- /**
161
- * Set custom function which can be visible while parsing formula expression.
162
- *
163
- * @param {String} name Custom function name.
164
- * @param {Function} fn Custom function.
165
- * @returns {Parser}
166
- */
167
- }, {
168
- key: "setFunction",
169
- value: function setFunction(name, fn) {
170
- this.functions[name] = fn;
171
- return this;
172
- }
173
-
174
- /**
175
- * Get custom function.
176
- *
177
- * @param {String} name Custom function name.
178
- * @returns {*}
179
- */
180
- }, {
181
- key: "getFunction",
182
- value: function getFunction(name) {
183
- return this.functions[name];
184
- }
185
-
186
- /**
187
- * Call function with provided params.
188
- *
189
- * @param name Function name.
190
- * @param params Function params.
191
- * @returns {*}
192
- * @private
193
- */
194
- }, {
195
- key: "_callFunction",
196
- value: function _callFunction(name) {
197
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
198
- var fn = this.getFunction(name);
199
- var value;
200
- if (fn) {
201
- value = fn(params);
202
- }
203
- this.emit('callFunction', name, params, function (newValue) {
204
- if (newValue !== void 0) {
205
- value = newValue;
206
- }
207
- });
208
- return value === void 0 ? (0, _evaluateByOperator["default"])(name, params) : value;
209
- }
210
-
211
- /**
212
- * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
213
- *
214
- * @param {String} label Coordinates.
215
- * @returns {*}
216
- * @private
217
- */
218
- }, {
219
- key: "_callCellValue",
220
- value: function _callCellValue(label) {
221
- var _extractLabel = (0, _cell.extractLabel)(label),
222
- _extractLabel2 = _slicedToArray(_extractLabel, 3),
223
- row = _extractLabel2[0],
224
- column = _extractLabel2[1],
225
- sheetName = _extractLabel2[2];
226
- if ((column === null || column === void 0 ? void 0 : column.index) === -1) {
227
- if (row.isAbsolute || column.isAbsolute) {
228
- throw Error(_error.ERROR_NAME);
229
- }
230
- return row.index + 1;
231
- } else if ((row === null || row === void 0 ? void 0 : row.index) === -1) {
232
- throw Error(_error.ERROR_NAME);
233
- }
234
- var value = void 0;
235
- this.emit('callCellValue', {
236
- label: label,
237
- row: row,
238
- column: column,
239
- sheetName: sheetName
240
- }, this.options, function (_value) {
241
- value = _value;
242
- });
243
- return value;
244
- }
245
-
246
- /**
247
- * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
248
- *
249
- * @param {String} startLabel Coordinates of the first cell.
250
- * @param {String} endLabel Coordinates of the last cell.
251
- * @returns {Array} Returns an array of mixed values.
252
- * @private
253
- */
254
- }, {
255
- key: "_callRangeValue",
256
- value: function _callRangeValue(startLabel, endLabel) {
257
- var _extractLabel3 = (0, _cell.extractLabel)(startLabel),
258
- _extractLabel4 = _slicedToArray(_extractLabel3, 3),
259
- startRow = _extractLabel4[0],
260
- startColumn = _extractLabel4[1],
261
- startSheetName = _extractLabel4[2];
262
- var _extractLabel5 = (0, _cell.extractLabel)(endLabel),
263
- _extractLabel6 = _slicedToArray(_extractLabel5, 3),
264
- endRow = _extractLabel6[0],
265
- endColumn = _extractLabel6[1],
266
- endSheetName = _extractLabel6[2];
267
- if (endSheetName != null && startSheetName != endSheetName) {
268
- throw Error(_error.ERROR_VALUE);
269
- }
270
- var startCell = {};
271
- var endCell = {};
272
- startCell.sheetName = startSheetName;
273
- if (startRow.index <= endRow.index) {
274
- startCell.row = startRow;
275
- endCell.row = endRow;
276
- } else {
277
- startCell.row = endRow;
278
- endCell.row = startRow;
279
- }
280
- if (startColumn.index <= endColumn.index) {
281
- startCell.column = startColumn;
282
- endCell.column = endColumn;
283
- } else {
284
- startCell.column = endColumn;
285
- endCell.column = startColumn;
286
- }
287
- startCell.label = (0, _cell.toLabel)(startCell.row, startCell.column);
288
- endCell.label = (0, _cell.toLabel)(endCell.row, endCell.column);
289
- var value = [];
290
- this.emit('callRangeValue', startCell, endCell, this.options, function () {
291
- var _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
292
- value = _value;
293
- });
294
- return value;
295
- }
296
-
297
- /**
298
- * Try to throw error by its name.
299
- *
300
- * @param {String} errorName Error name.
301
- * @returns {String}
302
- * @private
303
- */
304
- }, {
305
- key: "_throwError",
306
- value: function _throwError(errorName) {
307
- if ((0, _error.isValidStrict)(errorName)) {
308
- throw Error(errorName);
309
- }
310
- throw Error(_error.ERROR);
311
- }
312
- }]);
313
- }(_tinyEmitter["default"]);
314
- var _default = exports["default"] = Parser;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var formulajs = _interopRequireWildcard(require("@formulajs/formulajs"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
11
- var SUPPORTED_FORMULAS = Object.keys(formulajs);
12
- var _default = exports["default"] = SUPPORTED_FORMULAS;