@leankylin-sheet/formula-parser 3.1.30 → 4.0.0

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 (160) hide show
  1. package/dist/index.esm.js +82 -161
  2. package/dist/index.js +82 -161
  3. package/package.json +1 -1
  4. package/dist/packages/core/src/api/cell.d.ts +0 -10
  5. package/dist/packages/core/src/api/common.d.ts +0 -57
  6. package/dist/packages/core/src/api/errors.d.ts +0 -2
  7. package/dist/packages/core/src/api/index.d.ts +0 -9
  8. package/dist/packages/core/src/api/merge.d.ts +0 -5
  9. package/dist/packages/core/src/api/range.d.ts +0 -22
  10. package/dist/packages/core/src/api/rowcol.d.ts +0 -14
  11. package/dist/packages/core/src/api/sheet.d.ts +0 -10
  12. package/dist/packages/core/src/api/workbook.d.ts +0 -15
  13. package/dist/packages/core/src/canvas.d.ts +0 -56
  14. package/dist/packages/core/src/context.d.ts +0 -193
  15. package/dist/packages/core/src/events/copy.d.ts +0 -2
  16. package/dist/packages/core/src/events/index.d.ts +0 -4
  17. package/dist/packages/core/src/events/keyboard.d.ts +0 -6
  18. package/dist/packages/core/src/events/mouse.d.ts +0 -25
  19. package/dist/packages/core/src/events/paste.d.ts +0 -5
  20. package/dist/packages/core/src/index.d.ts +0 -10
  21. package/dist/packages/core/src/locale/en.d.ts +0 -1028
  22. package/dist/packages/core/src/locale/es.d.ts +0 -1132
  23. package/dist/packages/core/src/locale/index.d.ts +0 -1046
  24. package/dist/packages/core/src/locale/zh.d.ts +0 -1045
  25. package/dist/packages/core/src/locale/zh_tw.d.ts +0 -1185
  26. package/dist/packages/core/src/modules/ConditionFormat.d.ts +0 -17
  27. package/dist/packages/core/src/modules/border.d.ts +0 -3
  28. package/dist/packages/core/src/modules/cell.d.ts +0 -32
  29. package/dist/packages/core/src/modules/clipboard.d.ts +0 -3
  30. package/dist/packages/core/src/modules/color.d.ts +0 -1
  31. package/dist/packages/core/src/modules/comment.d.ts +0 -96
  32. package/dist/packages/core/src/modules/conditionalFormat.d.ts +0 -2
  33. package/dist/packages/core/src/modules/cursor.d.ts +0 -3
  34. package/dist/packages/core/src/modules/dataVerification.d.ts +0 -11
  35. package/dist/packages/core/src/modules/dropCell.d.ts +0 -10
  36. package/dist/packages/core/src/modules/filter.d.ts +0 -45
  37. package/dist/packages/core/src/modules/format.d.ts +0 -6
  38. package/dist/packages/core/src/modules/formula.d.ts +0 -53
  39. package/dist/packages/core/src/modules/freeze.d.ts +0 -5
  40. package/dist/packages/core/src/modules/hyperlink.d.ts +0 -21
  41. package/dist/packages/core/src/modules/image.d.ts +0 -31
  42. package/dist/packages/core/src/modules/index.d.ts +0 -35
  43. package/dist/packages/core/src/modules/inline-string.d.ts +0 -36
  44. package/dist/packages/core/src/modules/location.d.ts +0 -6
  45. package/dist/packages/core/src/modules/locationCondition.d.ts +0 -21
  46. package/dist/packages/core/src/modules/merge.d.ts +0 -3
  47. package/dist/packages/core/src/modules/mobile.d.ts +0 -5
  48. package/dist/packages/core/src/modules/moveCells.d.ts +0 -5
  49. package/dist/packages/core/src/modules/protection.d.ts +0 -5
  50. package/dist/packages/core/src/modules/refresh.d.ts +0 -3
  51. package/dist/packages/core/src/modules/rowcol.d.ts +0 -19
  52. package/dist/packages/core/src/modules/screenshot.d.ts +0 -2
  53. package/dist/packages/core/src/modules/searchReplace.d.ts +0 -36
  54. package/dist/packages/core/src/modules/selection.d.ts +0 -47
  55. package/dist/packages/core/src/modules/sheet.d.ts +0 -10
  56. package/dist/packages/core/src/modules/sort.d.ts +0 -7
  57. package/dist/packages/core/src/modules/splitColumn.d.ts +0 -5
  58. package/dist/packages/core/src/modules/ssf.d.ts +0 -2
  59. package/dist/packages/core/src/modules/text.d.ts +0 -10
  60. package/dist/packages/core/src/modules/toolbar.d.ts +0 -32
  61. package/dist/packages/core/src/modules/validation.d.ts +0 -19
  62. package/dist/packages/core/src/modules/zoom.d.ts +0 -3
  63. package/dist/packages/core/src/settings.d.ts +0 -132
  64. package/dist/packages/core/src/types.d.ts +0 -351
  65. package/dist/packages/core/src/utils/index.d.ts +0 -17
  66. package/dist/packages/core/src/utils/patch.d.ts +0 -37
  67. package/dist/packages/react/src/components/CellOptions/index.d.ts +0 -4
  68. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  69. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  70. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  71. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  72. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  73. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  74. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  75. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -4
  76. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  77. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  78. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  79. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  80. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -12
  81. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  82. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  83. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  84. package/dist/packages/react/src/components/FxEditor/CalcInfo.d.ts +0 -3
  85. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  86. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  87. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  88. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  89. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  90. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  91. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  92. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -3
  93. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  94. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -4
  95. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  96. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  97. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  98. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  99. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  100. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  101. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  102. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  103. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  104. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  105. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  106. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  107. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  108. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  109. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  110. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -11
  111. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  112. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -10
  113. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  114. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  115. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  116. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  117. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  118. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  119. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  120. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -7
  121. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -121
  122. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -130
  123. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  124. package/dist/packages/react/src/components/index.d.ts +0 -3
  125. package/dist/packages/react/src/context/index.d.ts +0 -25
  126. package/dist/packages/react/src/context/modal.d.ts +0 -10
  127. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  128. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  129. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  130. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  131. package/dist/packages/react/src/index.d.ts +0 -1
  132. package/dist/stories/data/cell.d.ts +0 -1180
  133. package/dist/stories/data/dataVerification.d.ts +0 -131
  134. package/dist/stories/data/empty.d.ts +0 -10
  135. package/dist/stories/data/formula.d.ts +0 -362
  136. package/dist/stories/data/freeze.d.ts +0 -34
  137. package/dist/stories/data/protected.d.ts +0 -40
  138. package/dist/stories/utils.d.ts +0 -1
  139. /package/dist/{packages/formula-parser/src/error.d.ts → error.d.ts} +0 -0
  140. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/evaluate-by-operator.d.ts +0 -0
  141. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/add.d.ts +0 -0
  142. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/ampersand.d.ts +0 -0
  143. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/divide.d.ts +0 -0
  144. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/equal.d.ts +0 -0
  145. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/formula-function.d.ts +0 -0
  146. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/greater-than-or-equal.d.ts +0 -0
  147. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/greater-than.d.ts +0 -0
  148. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/less-than-or-equal.d.ts +0 -0
  149. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/less-than.d.ts +0 -0
  150. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/minus.d.ts +0 -0
  151. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/multiply.d.ts +0 -0
  152. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/not-equal.d.ts +0 -0
  153. /package/dist/{packages/formula-parser/src/evaluate-by-operator → evaluate-by-operator}/operator/power.d.ts +0 -0
  154. /package/dist/{packages/formula-parser/src/grammar-parser → grammar-parser}/grammar-parser.d.ts +0 -0
  155. /package/dist/{packages/formula-parser/src/helper → helper}/cell.d.ts +0 -0
  156. /package/dist/{packages/formula-parser/src/helper → helper}/number.d.ts +0 -0
  157. /package/dist/{packages/formula-parser/src/helper → helper}/string.d.ts +0 -0
  158. /package/dist/{packages/formula-parser/src/index.d.ts → index.d.ts} +0 -0
  159. /package/dist/{packages/formula-parser/src/parser.d.ts → parser.d.ts} +0 -0
  160. /package/dist/{packages/formula-parser/src/supported-formulas.d.ts → supported-formulas.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -476,82 +476,7 @@ registerOperation(func$a.SYMBOL, func$a);
476
476
  registerOperation(func$b.SYMBOL, func$b);
477
477
  registerOperation(func$9.SYMBOL, func$9);
478
478
 
479
- /* parser generated by jison 0.4.18 */
480
- /*
481
- Returns a Parser object of the following structure:
482
-
483
- Parser: {
484
- yy: {}
485
- }
486
-
487
- Parser.prototype: {
488
- yy: {},
489
- trace: function(),
490
- symbols_: {associative list: name ==> number},
491
- terminals_: {associative list: number ==> name},
492
- productions_: [...],
493
- performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
494
- table: [...],
495
- defaultActions: {...},
496
- parseError: function(str, hash),
497
- parse: function(input),
498
-
499
- lexer: {
500
- EOF: 1,
501
- parseError: function(str, hash),
502
- setInput: function(input),
503
- input: function(),
504
- unput: function(str),
505
- more: function(),
506
- less: function(n),
507
- pastInput: function(),
508
- upcomingInput: function(),
509
- showPosition: function(),
510
- test_match: function(regex_match_array, rule_index),
511
- next: function(),
512
- lex: function(),
513
- begin: function(condition),
514
- popState: function(),
515
- _currentRules: function(),
516
- topState: function(),
517
- pushState: function(condition),
518
-
519
- options: {
520
- ranges: boolean (optional: true ==> token location info will include a .range[] member)
521
- flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
522
- backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
523
- },
524
-
525
- performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
526
- rules: [...],
527
- conditions: {associative list: name ==> set},
528
- }
529
- }
530
-
531
-
532
- token location info (@$, _$, etc.): {
533
- first_line: n,
534
- last_line: n,
535
- first_column: n,
536
- last_column: n,
537
- range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
538
- }
539
-
540
-
541
- the parseError function receives a 'hash' object with these members for lexer and parser errors: {
542
- text: (matched text)
543
- token: (the produced terminal token, if any)
544
- line: (yylineno)
545
- }
546
- while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
547
- loc: (yylloc)
548
- expected: (string describing the set of expected tokens)
549
- recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
550
- }
551
- */
552
-
553
- /* addresses */
554
- var simpleSheetName = "[A-Za-z0-9_\xC0-\u02AF]+";
479
+ var simpleSheetName = "[A-Za-z0-9_\u4E00-\u9FFF]+";
555
480
  var quotedSheetName = "'(?:(?!').|'')*'";
556
481
  var sheetNameRegexp = "(?:".concat(simpleSheetName, "|").concat(quotedSheetName, ")!");
557
482
  var ABSOLUTE_CELL = new RegExp("^(?:".concat(sheetNameRegexp, ")?(?:[$][A-Za-z]+[$][0-9]+)"));
@@ -596,13 +521,13 @@ var parser = {
596
521
  trace: function trace() {},
597
522
  yy: {},
598
523
  symbols_: {
599
- "error": 2,
600
- "expressions": 3,
601
- "expression": 4,
602
- "EOF": 5,
603
- "variableSequence": 6,
604
- "number": 7,
605
- "STRING": 8,
524
+ error: 2,
525
+ expressions: 3,
526
+ expression: 4,
527
+ EOF: 5,
528
+ variableSequence: 6,
529
+ number: 7,
530
+ STRING: 8,
606
531
  "&": 9,
607
532
  "=": 10,
608
533
  "+": 11,
@@ -610,28 +535,28 @@ var parser = {
610
535
  ")": 13,
611
536
  "<": 14,
612
537
  ">": 15,
613
- "NOT": 16,
538
+ NOT: 16,
614
539
  "-": 17,
615
540
  "*": 18,
616
541
  "/": 19,
617
542
  "^": 20,
618
- "FUNCTION": 21,
619
- "expseq": 22,
620
- "cell": 23,
621
- "ABSOLUTE_CELL": 24,
622
- "RELATIVE_CELL": 25,
623
- "MIXED_CELL": 26,
543
+ FUNCTION: 21,
544
+ expseq: 22,
545
+ cell: 23,
546
+ ABSOLUTE_CELL: 24,
547
+ RELATIVE_CELL: 25,
548
+ MIXED_CELL: 26,
624
549
  ":": 27,
625
- "ARRAY": 28,
550
+ ARRAY: 28,
626
551
  ";": 29,
627
552
  ",": 30,
628
- "VARIABLE": 31,
629
- "DECIMAL": 32,
630
- "NUMBER": 33,
553
+ VARIABLE: 31,
554
+ DECIMAL: 32,
555
+ NUMBER: 33,
631
556
  "%": 34,
632
- "ERROR": 35,
633
- "$accept": 0,
634
- "$end": 1
557
+ ERROR: 35,
558
+ $accept: 0,
559
+ $end: 1
635
560
  },
636
561
  terminals_: {
637
562
  5: "EOF",
@@ -680,46 +605,46 @@ var parser = {
680
605
  this.$ = yy.trimEdges($$[$0]);
681
606
  break;
682
607
  case 5:
683
- this.$ = yy.evaluateByOperator('&', [$$[$0 - 2], $$[$0]]);
608
+ this.$ = yy.evaluateByOperator("&", [$$[$0 - 2], $$[$0]]);
684
609
  break;
685
610
  case 6:
686
- this.$ = yy.evaluateByOperator('=', [$$[$0 - 2], $$[$0]]);
611
+ this.$ = yy.evaluateByOperator("=", [$$[$0 - 2], $$[$0]]);
687
612
  break;
688
613
  case 7:
689
- this.$ = yy.evaluateByOperator('+', [$$[$0 - 2], $$[$0]]);
614
+ this.$ = yy.evaluateByOperator("+", [$$[$0 - 2], $$[$0]]);
690
615
  break;
691
616
  case 8:
692
617
  this.$ = $$[$0 - 1];
693
618
  break;
694
619
  case 9:
695
- this.$ = yy.evaluateByOperator('<=', [$$[$0 - 3], $$[$0]]);
620
+ this.$ = yy.evaluateByOperator("<=", [$$[$0 - 3], $$[$0]]);
696
621
  break;
697
622
  case 10:
698
- this.$ = yy.evaluateByOperator('>=', [$$[$0 - 3], $$[$0]]);
623
+ this.$ = yy.evaluateByOperator(">=", [$$[$0 - 3], $$[$0]]);
699
624
  break;
700
625
  case 11:
701
- this.$ = yy.evaluateByOperator('<>', [$$[$0 - 3], $$[$0]]);
626
+ this.$ = yy.evaluateByOperator("<>", [$$[$0 - 3], $$[$0]]);
702
627
  break;
703
628
  case 12:
704
- this.$ = yy.evaluateByOperator('NOT', [$$[$0 - 2], $$[$0]]);
629
+ this.$ = yy.evaluateByOperator("NOT", [$$[$0 - 2], $$[$0]]);
705
630
  break;
706
631
  case 13:
707
- this.$ = yy.evaluateByOperator('>', [$$[$0 - 2], $$[$0]]);
632
+ this.$ = yy.evaluateByOperator(">", [$$[$0 - 2], $$[$0]]);
708
633
  break;
709
634
  case 14:
710
- this.$ = yy.evaluateByOperator('<', [$$[$0 - 2], $$[$0]]);
635
+ this.$ = yy.evaluateByOperator("<", [$$[$0 - 2], $$[$0]]);
711
636
  break;
712
637
  case 15:
713
- this.$ = yy.evaluateByOperator('-', [$$[$0 - 2], $$[$0]]);
638
+ this.$ = yy.evaluateByOperator("-", [$$[$0 - 2], $$[$0]]);
714
639
  break;
715
640
  case 16:
716
- this.$ = yy.evaluateByOperator('*', [$$[$0 - 2], $$[$0]]);
641
+ this.$ = yy.evaluateByOperator("*", [$$[$0 - 2], $$[$0]]);
717
642
  break;
718
643
  case 17:
719
- this.$ = yy.evaluateByOperator('/', [$$[$0 - 2], $$[$0]]);
644
+ this.$ = yy.evaluateByOperator("/", [$$[$0 - 2], $$[$0]]);
720
645
  break;
721
646
  case 18:
722
- this.$ = yy.evaluateByOperator('^', [$$[$0 - 2], $$[$0]]);
647
+ this.$ = yy.evaluateByOperator("^", [$$[$0 - 2], $$[$0]]);
723
648
  break;
724
649
  case 19:
725
650
  var n1 = yy.invertNumber($$[$0]);
@@ -762,7 +687,7 @@ var parser = {
762
687
  this.$ = [$$[$0]];
763
688
  break;
764
689
  case 39:
765
- this.$ = yy.trimEdges(yytext).split(',');
690
+ this.$ = yy.trimEdges(yytext).split(",");
766
691
  break;
767
692
  case 40:
768
693
  case 41:
@@ -777,7 +702,7 @@ var parser = {
777
702
  this.$ = $$[$0];
778
703
  break;
779
704
  case 45:
780
- this.$ = ($$[$0 - 2] + '.' + $$[$0]) * 1;
705
+ this.$ = ($$[$0 - 2] + "." + $$[$0]) * 1;
781
706
  break;
782
707
  case 46:
783
708
  this.$ = $$[$0 - 1] * 0.01;
@@ -1337,7 +1262,7 @@ var parser = {
1337
1262
  lstack = [],
1338
1263
  // location stack
1339
1264
  table = this.table,
1340
- yytext = '',
1265
+ yytext = "",
1341
1266
  yylineno = 0,
1342
1267
  yyleng = 0,
1343
1268
  recovering = 0,
@@ -1346,7 +1271,6 @@ var parser = {
1346
1271
  var args = lstack.slice.call(arguments, 1);
1347
1272
 
1348
1273
  //this.reductionCount = this.shiftCount = 0;
1349
-
1350
1274
  var lexer = Object.create(this.lexer);
1351
1275
  var sharedState = {
1352
1276
  yy: {}
@@ -1360,13 +1284,13 @@ var parser = {
1360
1284
  lexer.setInput(input, sharedState.yy);
1361
1285
  sharedState.yy.lexer = lexer;
1362
1286
  sharedState.yy.parser = this;
1363
- if (typeof lexer.yylloc == 'undefined') {
1287
+ if (typeof lexer.yylloc == "undefined") {
1364
1288
  lexer.yylloc = {};
1365
1289
  }
1366
1290
  var yyloc = lexer.yylloc;
1367
1291
  lstack.push(yyloc);
1368
1292
  var ranges = lexer.options && lexer.options.ranges;
1369
- if (typeof sharedState.yy.parseError === 'function') {
1293
+ if (typeof sharedState.yy.parseError === "function") {
1370
1294
  this.parseError = sharedState.yy.parseError;
1371
1295
  } else {
1372
1296
  this.parseError = Object.getPrototypeOf(this).parseError;
@@ -1380,7 +1304,7 @@ var parser = {
1380
1304
  var token;
1381
1305
  token = lexer.lex() || EOF;
1382
1306
  // if token isn't its numeric value, convert
1383
- if (typeof token !== 'number') {
1307
+ if (typeof token !== "number") {
1384
1308
  token = self.symbols_[token] || token;
1385
1309
  }
1386
1310
  return token;
@@ -1401,18 +1325,18 @@ var parser = {
1401
1325
  state = stack[stack.length - 1];
1402
1326
 
1403
1327
  // use default actions if available
1328
+
1404
1329
  if (_this.defaultActions[state]) {
1405
1330
  action = _this.defaultActions[state];
1406
1331
  } else {
1407
- if (symbol === null || typeof symbol == 'undefined') {
1332
+ if (symbol === null || typeof symbol == "undefined") {
1408
1333
  symbol = lex();
1409
1334
  }
1410
1335
  // read action for current state and first input
1411
1336
  action = table[state] && table[state][symbol];
1412
1337
  }
1413
-
1414
1338
  // handle parse error
1415
- if (typeof action === 'undefined' || !action.length || !action[0]) {
1339
+ if (typeof action === "undefined" || !action.length || !action[0]) {
1416
1340
  // Return the rule stack depth where the nearest error rule can be found.
1417
1341
  // Return FALSE when no error recovery rule was found.
1418
1342
  var locateNearestErrorRecoveryRule = function locateNearestErrorRecoveryRule(state) {
@@ -1433,7 +1357,7 @@ var parser = {
1433
1357
  ++depth;
1434
1358
  }
1435
1359
  };
1436
- errStr = '';
1360
+ errStr = "";
1437
1361
  if (!recovering) {
1438
1362
  // first see if there's any chance at hitting an error recovery rule:
1439
1363
  error_rule_depth = locateNearestErrorRecoveryRule(state);
@@ -1446,9 +1370,9 @@ var parser = {
1446
1370
  }
1447
1371
  }
1448
1372
  if (lexer.showPosition) {
1449
- errStr = 'Parse error on line ' + (yylineno + 1) + ":\n" + lexer.showPosition() + "\nExpecting " + expected.join(', ') + ", got '" + (_this.terminals_[symbol] || symbol) + "'";
1373
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (_this.terminals_[symbol] || symbol) + "'";
1450
1374
  } else {
1451
- errStr = 'Parse error on line ' + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (_this.terminals_[symbol] || symbol) + "'");
1375
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (_this.terminals_[symbol] || symbol) + "'");
1452
1376
  }
1453
1377
  _this.parseError(errStr, {
1454
1378
  text: lexer.match,
@@ -1465,7 +1389,7 @@ var parser = {
1465
1389
  // just recovered from another error
1466
1390
  if (recovering == 3) {
1467
1391
  if (symbol === EOF || preErrorSymbol === EOF) {
1468
- throw new Error(errStr || 'Parsing halted while starting to recover from another error.');
1392
+ throw new Error(errStr || "Parsing halted while starting to recover from another error.");
1469
1393
  }
1470
1394
 
1471
1395
  // discard current lookahead and grab another
@@ -1478,7 +1402,7 @@ var parser = {
1478
1402
 
1479
1403
  // try to recover from error
1480
1404
  if (error_rule_depth === false) {
1481
- throw new Error(errStr || 'Parsing halted. No suitable error recovery rule available.');
1405
+ throw new Error(errStr || "Parsing halted. No suitable error recovery rule available.");
1482
1406
  }
1483
1407
  popStack(error_rule_depth);
1484
1408
  preErrorSymbol = symbol == TERROR ? null : symbol; // save the lookahead token
@@ -1487,10 +1411,9 @@ var parser = {
1487
1411
  action = table[state] && table[state][TERROR];
1488
1412
  recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
1489
1413
  }
1490
-
1491
1414
  // this shouldn't happen, unless resolve defaults are off
1492
1415
  if (action[0] instanceof Array && action.length > 1) {
1493
- throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
1416
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
1494
1417
  }
1495
1418
  switch (action[0]) {
1496
1419
  case 1:
@@ -1520,7 +1443,6 @@ var parser = {
1520
1443
  case 2:
1521
1444
  // reduce
1522
1445
  //this.reductionCount++;
1523
-
1524
1446
  len = _this.productions_[action[1]][1];
1525
1447
 
1526
1448
  // perform semantic action
@@ -1536,7 +1458,7 @@ var parser = {
1536
1458
  yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
1537
1459
  }
1538
1460
  r = _this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));
1539
- if (typeof r !== 'undefined') {
1461
+ if (typeof r !== "undefined") {
1540
1462
  return {
1541
1463
  v: r
1542
1464
  };
@@ -1590,8 +1512,8 @@ var lexer = function () {
1590
1512
  this._input = input;
1591
1513
  this._more = this._backtrack = this.done = false;
1592
1514
  this.yylineno = this.yyleng = 0;
1593
- this.yytext = this.matched = this.match = '';
1594
- this.conditionStack = ['INITIAL'];
1515
+ this.yytext = this.matched = this.match = "";
1516
+ this.conditionStack = ["INITIAL"];
1595
1517
  this.yylloc = {
1596
1518
  first_line: 1,
1597
1519
  first_column: 0,
@@ -1662,7 +1584,7 @@ var lexer = function () {
1662
1584
  if (this.options.backtrack_lexer) {
1663
1585
  this._backtrack = true;
1664
1586
  } else {
1665
- return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
1587
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
1666
1588
  text: "",
1667
1589
  token: null,
1668
1590
  line: this.yylineno
@@ -1677,7 +1599,7 @@ var lexer = function () {
1677
1599
  // displays already matched input, i.e. for error messages
1678
1600
  pastInput: function pastInput() {
1679
1601
  var past = this.matched.substr(0, this.matched.length - this.match.length);
1680
- return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, "");
1602
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
1681
1603
  },
1682
1604
  // displays upcoming input, i.e. for error messages
1683
1605
  upcomingInput: function upcomingInput() {
@@ -1685,7 +1607,7 @@ var lexer = function () {
1685
1607
  if (next.length < 20) {
1686
1608
  next += this._input.substr(0, 20 - next.length);
1687
1609
  }
1688
- return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
1610
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
1689
1611
  },
1690
1612
  // displays the character position where the lexing error occurred, i.e. for error messages
1691
1613
  showPosition: function showPosition() {
@@ -1768,8 +1690,8 @@ var lexer = function () {
1768
1690
  }
1769
1691
  var token, match, tempMatch, index;
1770
1692
  if (!this._more) {
1771
- this.yytext = '';
1772
- this.match = '';
1693
+ this.yytext = "";
1694
+ this.match = "";
1773
1695
  }
1774
1696
  var rules = this._currentRules();
1775
1697
  for (var i = 0; i < rules.length; i++) {
@@ -1809,7 +1731,7 @@ var lexer = function () {
1809
1731
  if (this._input === "") {
1810
1732
  return this.EOF;
1811
1733
  } else {
1812
- return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
1734
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
1813
1735
  text: "",
1814
1736
  token: null,
1815
1737
  line: this.yylineno
@@ -1866,8 +1788,7 @@ var lexer = function () {
1866
1788
  options: {},
1867
1789
  performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
1868
1790
  switch ($avoiding_name_collisions) {
1869
- case 0:
1870
- /* skip whitespace */
1791
+ case 0 /* skip whitespace */:
1871
1792
  break;
1872
1793
  case 1:
1873
1794
  return 8;
@@ -1898,7 +1819,7 @@ var lexer = function () {
1898
1819
  case 14:
1899
1820
  return 9;
1900
1821
  case 15:
1901
- return ' ';
1822
+ return " ";
1902
1823
  case 16:
1903
1824
  return 32;
1904
1825
  case 17:
@@ -1938,16 +1859,16 @@ var lexer = function () {
1938
1859
  case 34:
1939
1860
  return 34;
1940
1861
  case 35:
1941
- return '#';
1862
+ return "#";
1942
1863
  case 36:
1943
1864
  return 5;
1944
1865
  }
1945
1866
  },
1946
1867
  rules: [/^(?:\s+)/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*'[^'!])/, /^(?:[A-Za-z]{1,}[A-Za-z_0-9\.]+(?=[(]))/, /^(?:#[A-Z0-9\/]+(!|\?)?)/, ABSOLUTE_CELL, MIXED_CELL_COL, MIXED_CELL_ROW, RELATIVE_CELL, /^(?:[A-Za-z\.]+(?=[(]))/, /^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/, /^(?:[A-Za-z_]+)/, /^(?:[0-9]+)/, /^(?:\[(.*)?\])/, /^(?:&)/, /^(?: )/, /^(?:[.])/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:>)/, /^(?:<)/, /^(?:NOT\b)/, /^(?:")/, /^(?:')/, /^(?:!)/, /^(?:=)/, /^(?:%)/, /^(?:[#])/, /^(?:$)/],
1947
1868
  conditions: {
1948
- "INITIAL": {
1949
- "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],
1950
- "inclusive": true
1869
+ INITIAL: {
1870
+ rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],
1871
+ inclusive: true
1951
1872
  }
1952
1873
  }
1953
1874
  };
@@ -1997,13 +1918,13 @@ function rowLabelToIndex(label) {
1997
1918
  * @returns {String} Returns row label (eq. '1', '7').
1998
1919
  */
1999
1920
  function rowIndexToLabel(row) {
2000
- var result = '';
1921
+ var result = "";
2001
1922
  if (row >= 0) {
2002
1923
  result = "".concat(row + 1);
2003
1924
  }
2004
1925
  return result;
2005
1926
  }
2006
- var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
1927
+ var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2007
1928
  var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
2008
1929
 
2009
1930
  /**
@@ -2014,7 +1935,7 @@ var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
2014
1935
  */
2015
1936
  function columnLabelToIndex(label) {
2016
1937
  var result = 0;
2017
- if (typeof label === 'string') {
1938
+ if (typeof label === "string") {
2018
1939
  label = label.toUpperCase();
2019
1940
  for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
2020
1941
  result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
@@ -2031,14 +1952,14 @@ function columnLabelToIndex(label) {
2031
1952
  * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
2032
1953
  */
2033
1954
  function columnIndexToLabel(column) {
2034
- var result = '';
1955
+ var result = "";
2035
1956
  while (column >= 0) {
2036
1957
  result = String.fromCharCode(column % COLUMN_LABEL_BASE_LENGTH + 97) + result;
2037
1958
  column = Math.floor(column / COLUMN_LABEL_BASE_LENGTH) - 1;
2038
1959
  }
2039
1960
  return result.toUpperCase();
2040
1961
  }
2041
- var simpleSheetName$1 = "[A-Za-z0-9_\xC0-\u02AF]+";
1962
+ var simpleSheetName$1 = "[A-Za-z0-9_\u4E00-\u9FFF]+";
2042
1963
  var quotedSheetName$1 = "'(?:(?!').|'')*'";
2043
1964
  var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
2044
1965
  var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
@@ -2050,7 +1971,7 @@ var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?
2050
1971
  * @returns {Array} Returns an array of objects.
2051
1972
  */
2052
1973
  function extractLabel(label) {
2053
- if (typeof label !== 'string' || !LABEL_EXTRACT_REGEXP.test(label)) {
1974
+ if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
2054
1975
  return [];
2055
1976
  }
2056
1977
  var _label$toUpperCase$ma = label.toUpperCase().match(LABEL_EXTRACT_REGEXP),
@@ -2065,11 +1986,11 @@ function extractLabel(label) {
2065
1986
  return [{
2066
1987
  index: rowLabelToIndex(row),
2067
1988
  label: row,
2068
- isAbsolute: rowAbs === '$'
1989
+ isAbsolute: rowAbs === "$"
2069
1990
  }, {
2070
1991
  index: columnLabelToIndex(column),
2071
1992
  label: column,
2072
- isAbsolute: columnAbs === '$'
1993
+ isAbsolute: columnAbs === "$"
2073
1994
  }, sheetName];
2074
1995
  }
2075
1996
 
@@ -2081,8 +2002,8 @@ function extractLabel(label) {
2081
2002
  * @returns {String} Returns cell label.
2082
2003
  */
2083
2004
  function toLabel(row, column) {
2084
- var rowLabel = (row.isAbsolute ? '$' : '') + rowIndexToLabel(row.index);
2085
- var columnLabel = (column.isAbsolute ? '$' : '') + columnIndexToLabel(column.index);
2005
+ var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
2006
+ var columnLabel = (column.isAbsolute ? "$" : "") + columnIndexToLabel(column.index);
2086
2007
  return columnLabel + rowLabel;
2087
2008
  }
2088
2009
 
@@ -2119,7 +2040,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2119
2040
  _this.variables = Object.create(null);
2120
2041
  _this.functions = Object.create(null);
2121
2042
  _this.options = Object.create(null);
2122
- _this.setVariable('TRUE', true).setVariable('FALSE', false).setVariable('NULL', null);
2043
+ _this.setVariable("TRUE", true).setVariable("FALSE", false).setVariable("NULL", null);
2123
2044
  return _this;
2124
2045
  }
2125
2046
 
@@ -2139,8 +2060,8 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2139
2060
  var error$1 = null;
2140
2061
  this.options = options;
2141
2062
  try {
2142
- if (expression === '') {
2143
- result = '';
2063
+ if (expression === "") {
2064
+ result = "";
2144
2065
  } else {
2145
2066
  result = this.parser.parse(expression);
2146
2067
  }
@@ -2199,7 +2120,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2199
2120
  key: "_callVariable",
2200
2121
  value: function _callVariable(name) {
2201
2122
  var value = this.getVariable(name);
2202
- this.emit('callVariable', name, function (newValue) {
2123
+ this.emit("callVariable", name, function (newValue) {
2203
2124
  if (newValue !== void 0) {
2204
2125
  value = newValue;
2205
2126
  }
@@ -2253,7 +2174,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2253
2174
  if (fn) {
2254
2175
  value = fn(params);
2255
2176
  }
2256
- this.emit('callFunction', name, params, function (newValue) {
2177
+ this.emit("callFunction", name, params, function (newValue) {
2257
2178
  if (newValue !== void 0) {
2258
2179
  value = newValue;
2259
2180
  }
@@ -2285,7 +2206,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2285
2206
  throw Error(ERROR_NAME);
2286
2207
  }
2287
2208
  var value = void 0;
2288
- this.emit('callCellValue', {
2209
+ this.emit("callCellValue", {
2289
2210
  label: label,
2290
2211
  row: row,
2291
2212
  column: column,
@@ -2340,7 +2261,7 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2340
2261
  startCell.label = toLabel(startCell.row, startCell.column);
2341
2262
  endCell.label = toLabel(endCell.row, endCell.column);
2342
2263
  var value = [];
2343
- this.emit('callRangeValue', startCell, endCell, this.options, function () {
2264
+ this.emit("callRangeValue", startCell, endCell, this.options, function () {
2344
2265
  var _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2345
2266
  value = _value;
2346
2267
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/formula-parser",
3
- "version": "3.1.30",
3
+ "version": "4.0.0",
4
4
  "description": "Formula parser",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,10 +0,0 @@
1
- import { Context } from "../context";
2
- import { Cell, SingleRange } from "../types";
3
- import { CommonOptions } from "./common";
4
- export declare function getCellValue(ctx: Context, row: number, column: number, options?: CommonOptions & {
5
- type?: keyof Cell;
6
- }): any;
7
- export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
8
- export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
9
- export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
10
- export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: "up" | "down" | "left" | "right"): void;
@@ -1,57 +0,0 @@
1
- import { Context } from "../context";
2
- import { CellMatrix, CellWithRowAndCol, Sheet } from "../types";
3
- export type CommonOptions = {
4
- index?: number;
5
- id?: string;
6
- };
7
- export declare const dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
8
- export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
9
- export declare function getSheet(ctx: Context, options?: CommonOptions): Sheet;
10
- export declare function getSheetWithLatestCelldata(ctx: Context, options?: CommonOptions): {
11
- celldata: CellWithRowAndCol[];
12
- name: string;
13
- config?: import("../types").SheetConfig | undefined;
14
- order?: number | undefined;
15
- color?: string | undefined;
16
- data?: CellMatrix | undefined;
17
- id?: string | undefined;
18
- images?: import("../types").Image[] | undefined;
19
- zoomRatio?: number | undefined;
20
- column?: number | undefined;
21
- row?: number | undefined;
22
- addRows?: number | undefined;
23
- status?: number | undefined;
24
- hide?: number | undefined;
25
- luckysheet_select_save?: import("../types").Selection[] | undefined;
26
- luckysheet_selection_range?: {
27
- row: number[];
28
- column: number[];
29
- }[] | undefined;
30
- calcChain?: any[] | undefined;
31
- defaultRowHeight?: number | undefined;
32
- defaultColWidth?: number | undefined;
33
- showGridLines?: number | boolean | undefined;
34
- pivotTable?: any;
35
- isPivotTable?: boolean | undefined;
36
- filter?: Record<string, any> | undefined;
37
- filter_select?: {
38
- row: number[];
39
- column: number[];
40
- } | undefined;
41
- luckysheet_conditionformat_save?: any[] | undefined;
42
- luckysheet_alternateformat_save?: any[] | undefined;
43
- dataVerification?: any;
44
- hyperlink?: Record<string, {
45
- linkType: string;
46
- linkAddress: string;
47
- }> | undefined;
48
- dynamicArray_compute?: any;
49
- dynamicArray?: any[] | undefined;
50
- frozen?: {
51
- type: "column" | "row" | "both" | "rangeRow" | "rangeColumn" | "rangeBoth";
52
- range?: {
53
- row_focus: number;
54
- column_focus: number;
55
- } | undefined;
56
- } | undefined;
57
- };
@@ -1,2 +0,0 @@
1
- export declare const INVALID_PARAMS: Error;
2
- export declare const SHEET_NOT_FOUND: Error;
@@ -1,9 +0,0 @@
1
- import { getSheetWithLatestCelldata, CommonOptions, dataToCelldata, celldataToData } from "./common";
2
- export type { CommonOptions };
3
- export { getSheetWithLatestCelldata, dataToCelldata, celldataToData };
4
- export * from "./cell";
5
- export * from "./rowcol";
6
- export * from "./range";
7
- export * from "./merge";
8
- export * from "./sheet";
9
- export * from "./workbook";