@leankylin-sheet/formula-parser 3.1.29 → 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
@@ -1,70 +0,0 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- 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); }
4
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
- 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; }
7
- /* eslint-disable import/no-named-as-default-member */
8
- import add from './operator/add';
9
- import ampersand from './operator/ampersand';
10
- import divide from './operator/divide';
11
- import equal from './operator/equal';
12
- import formulaFunction from './operator/formula-function';
13
- import greaterThan from './operator/greater-than';
14
- import greaterThanOrEqual from './operator/greater-than-or-equal';
15
- import lessThan from './operator/less-than';
16
- import lessThanOrEqual from './operator/less-than-or-equal';
17
- import minus from './operator/minus';
18
- import multiply from './operator/multiply';
19
- import notEqual from './operator/not-equal';
20
- import power from './operator/power';
21
- import { ERROR_NAME } from './../error';
22
- var availableOperators = Object.create(null);
23
-
24
- /**
25
- * Evaluate values by operator id.git
26
- *
27
- * @param {String} operator Operator id.
28
- * @param {Array} [params=[]] Arguments to evaluate.
29
- * @returns {*}
30
- */
31
- export default function evaluateByOperator(operator) {
32
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
33
- operator = operator.toUpperCase();
34
- if (!availableOperators[operator]) {
35
- throw Error(ERROR_NAME);
36
- }
37
- return availableOperators[operator].apply(availableOperators, _toConsumableArray(params));
38
- }
39
-
40
- /**
41
- * Register operator.
42
- *
43
- * @param {String|Array} symbol Symbol to register.
44
- * @param {Function} func Logic to register for this symbol.
45
- */
46
- export function registerOperation(symbol, func) {
47
- if (!Array.isArray(symbol)) {
48
- symbol = [symbol.toUpperCase()];
49
- }
50
- symbol.forEach(function (s) {
51
- if (func.isFactory) {
52
- availableOperators[s] = func(s);
53
- } else {
54
- availableOperators[s] = func;
55
- }
56
- });
57
- }
58
- registerOperation(add.SYMBOL, add);
59
- registerOperation(ampersand.SYMBOL, ampersand);
60
- registerOperation(divide.SYMBOL, divide);
61
- registerOperation(equal.SYMBOL, equal);
62
- registerOperation(power.SYMBOL, power);
63
- registerOperation(formulaFunction.SYMBOL, formulaFunction);
64
- registerOperation(greaterThan.SYMBOL, greaterThan);
65
- registerOperation(greaterThanOrEqual.SYMBOL, greaterThanOrEqual);
66
- registerOperation(lessThan.SYMBOL, lessThan);
67
- registerOperation(lessThanOrEqual.SYMBOL, lessThanOrEqual);
68
- registerOperation(multiply.SYMBOL, multiply);
69
- registerOperation(notEqual.SYMBOL, notEqual);
70
- registerOperation(minus.SYMBOL, minus);
@@ -1,16 +0,0 @@
1
- import { toNumber } from './../../helper/number';
2
- import { ERROR_VALUE } from './../../error';
3
- export var SYMBOL = '+';
4
- export default function func(first) {
5
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
6
- rest[_key - 1] = arguments[_key];
7
- }
8
- var result = rest.reduce(function (acc, value) {
9
- return acc + toNumber(value || 0);
10
- }, toNumber(first || 0));
11
- if (isNaN(result)) {
12
- throw Error(ERROR_VALUE);
13
- }
14
- return result;
15
- }
16
- func.SYMBOL = SYMBOL;
@@ -1,10 +0,0 @@
1
- export var SYMBOL = '&';
2
- export default function func() {
3
- for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
4
- params[_key] = arguments[_key];
5
- }
6
- return params.reduce(function (acc, value) {
7
- return acc + value.toString();
8
- }, '');
9
- }
10
- func.SYMBOL = SYMBOL;
@@ -1,21 +0,0 @@
1
- import { toNumber } from './../../helper/number';
2
- import { ERROR_DIV_ZERO, ERROR_VALUE } from './../../error';
3
- export var SYMBOL = '/';
4
- export default function func(first) {
5
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
6
- rest[_key - 1] = arguments[_key];
7
- }
8
- var result = rest.reduce(function (acc, value) {
9
- return acc / toNumber(value);
10
- }, toNumber(first));
11
- if (result === Infinity) {
12
- return ERROR_DIV_ZERO;
13
- // throw Error(ERROR_DIV_ZERO);
14
- }
15
- if (isNaN(result)) {
16
- return ERROR_VALUE;
17
- // throw Error(ERROR_VALUE);
18
- }
19
- return result;
20
- }
21
- func.SYMBOL = SYMBOL;
@@ -1,5 +0,0 @@
1
- export var SYMBOL = '=';
2
- export default function func(exp1, exp2) {
3
- return exp1 === exp2;
4
- }
5
- func.SYMBOL = SYMBOL;
@@ -1,40 +0,0 @@
1
- import * as formulajs from '@formulajs/formulajs';
2
- import SUPPORTED_FORMULAS from './../../supported-formulas';
3
- import { ERROR_NAME } from './../../error';
4
- export var SYMBOL = SUPPORTED_FORMULAS;
5
- export default function func(symbol) {
6
- return function __formulaFunction() {
7
- symbol = symbol.toUpperCase();
8
- var symbolParts = symbol.split('.');
9
- var foundFormula = false;
10
- var result;
11
- if (symbolParts.length === 1) {
12
- if (formulajs[symbolParts[0]]) {
13
- foundFormula = true;
14
- result = formulajs[symbolParts[0]].apply(formulajs, arguments);
15
- }
16
- } else {
17
- var length = symbolParts.length;
18
- var index = 0;
19
- var nestedFormula = formulajs;
20
- while (index < length) {
21
- nestedFormula = nestedFormula[symbolParts[index]];
22
- index++;
23
- if (!nestedFormula) {
24
- nestedFormula = null;
25
- break;
26
- }
27
- }
28
- if (nestedFormula) {
29
- foundFormula = true;
30
- result = nestedFormula.apply(void 0, arguments);
31
- }
32
- }
33
- if (!foundFormula) {
34
- throw Error(ERROR_NAME);
35
- }
36
- return result;
37
- };
38
- }
39
- func.isFactory = true;
40
- func.SYMBOL = SYMBOL;
@@ -1,5 +0,0 @@
1
- export var SYMBOL = '>=';
2
- export default function func(exp1, exp2) {
3
- return exp1 >= exp2;
4
- }
5
- func.SYMBOL = SYMBOL;
@@ -1,5 +0,0 @@
1
- export var SYMBOL = '>';
2
- export default function func(exp1, exp2) {
3
- return exp1 > exp2;
4
- }
5
- func.SYMBOL = SYMBOL;
@@ -1,5 +0,0 @@
1
- export var SYMBOL = '<=';
2
- export default function func(exp1, exp2) {
3
- return exp1 <= exp2;
4
- }
5
- func.SYMBOL = SYMBOL;
@@ -1,5 +0,0 @@
1
- export var SYMBOL = '<';
2
- export default function func(exp1, exp2) {
3
- return exp1 < exp2;
4
- }
5
- func.SYMBOL = SYMBOL;
@@ -1,16 +0,0 @@
1
- import { toNumber } from './../../helper/number';
2
- import { ERROR_VALUE } from './../../error';
3
- export var SYMBOL = '-';
4
- export default function func(first) {
5
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
6
- rest[_key - 1] = arguments[_key];
7
- }
8
- var result = rest.reduce(function (acc, value) {
9
- return acc - toNumber(value);
10
- }, toNumber(first));
11
- if (isNaN(result)) {
12
- throw Error(ERROR_VALUE);
13
- }
14
- return result;
15
- }
16
- func.SYMBOL = SYMBOL;
@@ -1,16 +0,0 @@
1
- import { toNumber } from './../../helper/number';
2
- import { ERROR_VALUE } from './../../error';
3
- export var SYMBOL = '*';
4
- export default function func(first) {
5
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
6
- rest[_key - 1] = arguments[_key];
7
- }
8
- var result = rest.reduce(function (acc, value) {
9
- return acc * toNumber(value);
10
- }, toNumber(first));
11
- if (isNaN(result)) {
12
- throw Error(ERROR_VALUE);
13
- }
14
- return result;
15
- }
16
- func.SYMBOL = SYMBOL;
@@ -1,5 +0,0 @@
1
- export var SYMBOL = '<>';
2
- export default function func(exp1, exp2) {
3
- return exp1 !== exp2;
4
- }
5
- func.SYMBOL = SYMBOL;
@@ -1,11 +0,0 @@
1
- import { toNumber } from './../../helper/number';
2
- import { ERROR_VALUE } from './../../error';
3
- export var SYMBOL = '^';
4
- export default function func(exp1, exp2) {
5
- var result = Math.pow(toNumber(exp1), toNumber(exp2));
6
- if (isNaN(result)) {
7
- throw Error(ERROR_VALUE);
8
- }
9
- return result;
10
- }
11
- func.SYMBOL = SYMBOL;
@@ -1,230 +0,0 @@
1
- /* description: Parses end evaluates mathematical expressions. */
2
- /* lexical grammar */
3
- %lex
4
- %%
5
- \s+ {/* skip whitespace */}
6
- '"'("\\"["]|[^"])*'"' {return 'STRING';}
7
- "'"('\\'[']|[^'])*"'" {return 'STRING';}
8
- [A-Za-z]{1,}[A-Za-z_0-9\.]+(?=[(]) {return 'FUNCTION';}
9
- '#'[A-Z0-9\/]+('!'|'?')? {return 'ERROR';}
10
- '$'[A-Za-z]+'$'[0-9]+ {return 'ABSOLUTE_CELL';}
11
- '$'[A-Za-z]+[0-9]+ {return 'MIXED_CELL';}
12
- [A-Za-z]+'$'[0-9]+ {return 'MIXED_CELL';}
13
- [A-Za-z]+[0-9]+ {return 'RELATIVE_CELL';}
14
- [A-Za-z\.]+(?=[(]) {return 'FUNCTION';}
15
- [A-Za-z]{1,}[A-Za-z_0-9]+ {return 'VARIABLE';}
16
- [A-Za-z_]+ {return 'VARIABLE';}
17
- [0-9]+ {return 'NUMBER';}
18
- '['(.*)?']' {return 'ARRAY';}
19
- "&" {return '&';}
20
- " " {return ' ';}
21
- [.] {return 'DECIMAL';}
22
- ":" {return ':';}
23
- ";" {return ';';}
24
- "," {return ',';}
25
- "*" {return '*';}
26
- "/" {return '/';}
27
- "-" {return '-';}
28
- "+" {return '+';}
29
- "^" {return '^';}
30
- "(" {return '(';}
31
- ")" {return ')';}
32
- ">" {return '>';}
33
- "<" {return '<';}
34
- "NOT" {return 'NOT';}
35
- '"' {return '"';}
36
- "'" {return "'";}
37
- "!" {return "!";}
38
- "=" {return '=';}
39
- "%" {return '%';}
40
- [#] {return '#';}
41
- <<EOF>> {return 'EOF';}
42
- /lex
43
-
44
- /* operator associations and precedence (low-top, high-bottom) */
45
- %left '='
46
- %left '<=' '>=' '<>' 'NOT' '||'
47
- %left '>' '<'
48
- %left '+' '-'
49
- %left '*' '/'
50
- %left '^'
51
- %left '&'
52
- %left '%'
53
- %left UMINUS
54
-
55
- %start expressions
56
-
57
- %% /* language grammar */
58
-
59
- expressions
60
- : expression EOF {
61
- return $1;
62
- }
63
- ;
64
-
65
- expression
66
- : variableSequence {
67
- $$ = yy.callVariable($1[0]);
68
- }
69
- | number {
70
- $$ = yy.toNumber($1);
71
- }
72
- | STRING {
73
- $$ = yy.trimEdges($1);
74
- }
75
- | expression '&' expression {
76
- $$ = yy.evaluateByOperator('&', [$1, $3]);
77
- }
78
- | expression '=' expression {
79
- $$ = yy.evaluateByOperator('=', [$1, $3]);
80
- }
81
- | expression '+' expression {
82
- $$ = yy.evaluateByOperator('+', [$1, $3]);
83
- }
84
- | '(' expression ')' {
85
- $$ = $2;
86
- }
87
- | expression '<' '=' expression {
88
- $$ = yy.evaluateByOperator('<=', [$1, $4]);
89
- }
90
- | expression '>' '=' expression {
91
- $$ = yy.evaluateByOperator('>=', [$1, $4]);
92
- }
93
- | expression '<' '>' expression {
94
- $$ = yy.evaluateByOperator('<>', [$1, $4]);
95
- }
96
- | expression NOT expression {
97
- $$ = yy.evaluateByOperator('NOT', [$1, $3]);
98
- }
99
- | expression '>' expression {
100
- $$ = yy.evaluateByOperator('>', [$1, $3]);
101
- }
102
- | expression '<' expression {
103
- $$ = yy.evaluateByOperator('<', [$1, $3]);
104
- }
105
- | expression '-' expression {
106
- $$ = yy.evaluateByOperator('-', [$1, $3]);
107
- }
108
- | expression '*' expression {
109
- $$ = yy.evaluateByOperator('*', [$1, $3]);
110
- }
111
- | expression '/' expression {
112
- $$ = yy.evaluateByOperator('/', [$1, $3]);
113
- }
114
- | expression '^' expression {
115
- $$ = yy.evaluateByOperator('^', [$1, $3]);
116
- }
117
- | '-' expression {
118
- var n1 = yy.invertNumber($2);
119
-
120
- $$ = n1;
121
-
122
- if (isNaN($$)) {
123
- $$ = 0;
124
- }
125
- }
126
- | '+' expression {
127
- var n1 = yy.toNumber($2);
128
-
129
- $$ = n1;
130
-
131
- if (isNaN($$)) {
132
- $$ = 0;
133
- }
134
- }
135
- | FUNCTION '(' ')' {
136
- $$ = yy.callFunction($1);
137
- }
138
- | FUNCTION '(' expseq ')' {
139
- $$ = yy.callFunction($1, $3);
140
- }
141
- | cell
142
- | error
143
- | error error
144
- ;
145
-
146
- cell
147
- : ABSOLUTE_CELL {
148
- $$ = yy.cellValue($1);
149
- }
150
- | RELATIVE_CELL {
151
- $$ = yy.cellValue($1);
152
- }
153
- | MIXED_CELL {
154
- $$ = yy.cellValue($1);
155
- }
156
- | ABSOLUTE_CELL ':' ABSOLUTE_CELL {
157
- $$ = yy.rangeValue($1, $3);
158
- }
159
- | ABSOLUTE_CELL ':' RELATIVE_CELL {
160
- $$ = yy.rangeValue($1, $3);
161
- }
162
- | ABSOLUTE_CELL ':' MIXED_CELL {
163
- $$ = yy.rangeValue($1, $3);
164
- }
165
- | RELATIVE_CELL ':' ABSOLUTE_CELL {
166
- $$ = yy.rangeValue($1, $3);
167
- }
168
- | RELATIVE_CELL ':' RELATIVE_CELL {
169
- $$ = yy.rangeValue($1, $3);
170
- }
171
- | RELATIVE_CELL ':' MIXED_CELL {
172
- $$ = yy.rangeValue($1, $3);
173
- }
174
- | MIXED_CELL ':' ABSOLUTE_CELL {
175
- $$ = yy.rangeValue($1, $3);
176
- }
177
- | MIXED_CELL ':' RELATIVE_CELL {
178
- $$ = yy.rangeValue($1, $3);
179
- }
180
- | MIXED_CELL ':' MIXED_CELL {
181
- $$ = yy.rangeValue($1, $3);
182
- }
183
- ;
184
-
185
- expseq
186
- : expression {
187
- $$ = [$1];
188
- }
189
- | ARRAY {
190
- $$ = yy.trimEdges(yytext).split(',');
191
- }
192
- | expseq ';' expression {
193
- $1.push($3);
194
- $$ = $1;
195
- }
196
- | expseq ',' expression {
197
- $1.push($3);
198
- $$ = $1;
199
- }
200
- ;
201
-
202
- variableSequence
203
- : VARIABLE {
204
- $$ = [$1];
205
- }
206
- | variableSequence DECIMAL VARIABLE {
207
- $$ = (Array.isArray($1) ? $1 : [$1]);
208
- $$.push($3);
209
- }
210
- ;
211
-
212
- number
213
- : NUMBER {
214
- $$ = $1;
215
- }
216
- | NUMBER DECIMAL NUMBER {
217
- $$ = ($1 + '.' + $3) * 1;
218
- }
219
- | number '%' {
220
- $$ = $1 * 0.01;
221
- }
222
- ;
223
-
224
- error
225
- : ERROR {
226
- $$ = yy.throwError($1);
227
- }
228
- ;
229
-
230
- %%
package/es/helper/cell.js DELETED
@@ -1,117 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- 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."); }
3
- 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); }
4
- 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; }
5
- 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; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- /**
8
- * Convert row label to index.
9
- *
10
- * @param {String} label Row label (eq. '1', '5')
11
- * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
12
- */
13
- export function rowLabelToIndex(label) {
14
- var result = parseInt(label, 10);
15
- if (isNaN(result)) {
16
- result = -1;
17
- } else {
18
- result = Math.max(result - 1, -1);
19
- }
20
- return result;
21
- }
22
-
23
- /**
24
- * Convert row index to label.
25
- *
26
- * @param {Number} row Row index.
27
- * @returns {String} Returns row label (eq. '1', '7').
28
- */
29
- export function rowIndexToLabel(row) {
30
- var result = '';
31
- if (row >= 0) {
32
- result = "".concat(row + 1);
33
- }
34
- return result;
35
- }
36
- var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
37
- var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
38
-
39
- /**
40
- * Convert column label to index.
41
- *
42
- * @param {String} label Column label (eq. 'ABB', 'CNQ')
43
- * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
44
- */
45
- export function columnLabelToIndex(label) {
46
- var result = 0;
47
- if (typeof label === 'string') {
48
- label = label.toUpperCase();
49
- for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
50
- result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
51
- }
52
- }
53
- --result;
54
- return result;
55
- }
56
-
57
- /**
58
- * Convert column index to label.
59
- *
60
- * @param {Number} column Column index.
61
- * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
62
- */
63
- export function columnIndexToLabel(column) {
64
- var result = '';
65
- while (column >= 0) {
66
- result = String.fromCharCode(column % COLUMN_LABEL_BASE_LENGTH + 97) + result;
67
- column = Math.floor(column / COLUMN_LABEL_BASE_LENGTH) - 1;
68
- }
69
- return result.toUpperCase();
70
- }
71
- var simpleSheetName = "[A-Za-z0-9_\xC0-\u02AF]+";
72
- var quotedSheetName = "'(?:(?!').|'')*'";
73
- var sheetNameRegexp = "(".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
74
- var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
75
-
76
- /**
77
- * Extract cell coordinates.
78
- *
79
- * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
80
- * @returns {Array} Returns an array of objects.
81
- */
82
- export function extractLabel(label) {
83
- if (typeof label !== 'string' || !LABEL_EXTRACT_REGEXP.test(label)) {
84
- return [];
85
- }
86
- var _label$toUpperCase$ma = label.toUpperCase().match(LABEL_EXTRACT_REGEXP),
87
- _label$toUpperCase$ma2 = _slicedToArray(_label$toUpperCase$ma, 6),
88
- sheetNameStr = _label$toUpperCase$ma2[1],
89
- columnAbs = _label$toUpperCase$ma2[2],
90
- column = _label$toUpperCase$ma2[3],
91
- rowAbs = _label$toUpperCase$ma2[4],
92
- row = _label$toUpperCase$ma2[5];
93
- if (column == null && row == null) return [];
94
- var sheetName = sheetNameStr == null ? null : label.slice(0, sheetNameStr.length).replace(/^'|'$/g, "").replace(/''/g, "'");
95
- return [{
96
- index: rowLabelToIndex(row),
97
- label: row,
98
- isAbsolute: rowAbs === '$'
99
- }, {
100
- index: columnLabelToIndex(column),
101
- label: column,
102
- isAbsolute: columnAbs === '$'
103
- }, sheetName];
104
- }
105
-
106
- /**
107
- * Convert row and column indexes into cell label.
108
- *
109
- * @param {Object} row Object with `index` and `isAbsolute` properties.
110
- * @param {Object} column Object with `index` and `isAbsolute` properties.
111
- * @returns {String} Returns cell label.
112
- */
113
- export function toLabel(row, column) {
114
- var rowLabel = (row.isAbsolute ? '$' : '') + rowIndexToLabel(row.index);
115
- var columnLabel = (column.isAbsolute ? '$' : '') + columnIndexToLabel(column.index);
116
- return columnLabel + rowLabel;
117
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Convert value into number.
3
- *
4
- * @param {String|Number} number
5
- * @returns {*}
6
- */
7
- export function toNumber(number) {
8
- var result;
9
- if (typeof number === 'number') {
10
- result = number;
11
- } else if (typeof number === 'string') {
12
- result = number.indexOf('.') > -1 ? parseFloat(number) : parseInt(number, 10);
13
- }
14
- return result;
15
- }
16
-
17
- /**
18
- * Invert provided number.
19
- *
20
- * @param {Number} number
21
- * @returns {Number} Returns inverted number.
22
- */
23
- export function invertNumber(number) {
24
- return -1 * toNumber(number);
25
- }
@@ -1,13 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
- /**
3
- * Trim value by cutting character starting from the beginning and ending at the same time.
4
- *
5
- * @param {String} string String to trimming.
6
- * @param {Number} [margin=1] Number of character to cut.
7
- * @returns {String}
8
- */
9
- export function trimEdges(string) {
10
- var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11
- string = string.substring(margin, string.length - margin);
12
- return string;
13
- }