@odoo/o-spreadsheet 16.0.46 → 16.0.47

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.
@@ -8251,15 +8251,6 @@ function createLineChartRuntime(chart, getters) {
8251
8251
  }
8252
8252
  const colors = new ChartColors();
8253
8253
  for (let [index, { label, data }] of dataSetsValues.entries()) {
8254
- if (["linear", "time"].includes(axisType)) {
8255
- // Replace empty string labels by undefined to make sure chartJS doesn't decide that "" is the same as 0
8256
- data = data.map((y, index) => ({ x: labels[index] || undefined, y }));
8257
- }
8258
- const color = colors.next();
8259
- let backgroundRGBA = colorToRGBA(color);
8260
- if (chart.stacked) {
8261
- backgroundRGBA.a = LINE_FILL_TRANSPARENCY;
8262
- }
8263
8254
  if (chart.cumulative) {
8264
8255
  let accumulator = 0;
8265
8256
  data = data.map((value) => {
@@ -8270,6 +8261,15 @@ function createLineChartRuntime(chart, getters) {
8270
8261
  return value;
8271
8262
  });
8272
8263
  }
8264
+ if (["linear", "time"].includes(axisType)) {
8265
+ // Replace empty string labels by undefined to make sure chartJS doesn't decide that "" is the same as 0
8266
+ data = data.map((y, index) => ({ x: labels[index] || undefined, y }));
8267
+ }
8268
+ const color = colors.next();
8269
+ let backgroundRGBA = colorToRGBA(color);
8270
+ if (chart.stacked) {
8271
+ backgroundRGBA.a = LINE_FILL_TRANSPARENCY;
8272
+ }
8273
8273
  const backgroundColor = rgbaToHex(backgroundRGBA);
8274
8274
  const dataset = {
8275
8275
  label,
@@ -11391,6 +11391,9 @@ function getPredicate(descr, isQuery) {
11391
11391
  return result;
11392
11392
  }
11393
11393
  function operandToRegExp(operand) {
11394
+ if (operand === "*") {
11395
+ return /.+/;
11396
+ }
11394
11397
  let exp = "";
11395
11398
  let predecessor = "";
11396
11399
  for (let char of operand) {
@@ -11414,9 +11417,9 @@ function operandToRegExp(operand) {
11414
11417
  }
11415
11418
  return new RegExp("^" + exp + "$", "i");
11416
11419
  }
11417
- function evaluatePredicate(value, criterion) {
11420
+ function evaluatePredicate(value = "", criterion) {
11418
11421
  const { operator, operand } = criterion;
11419
- if (value === undefined || operand === undefined) {
11422
+ if (operand === undefined) {
11420
11423
  return false;
11421
11424
  }
11422
11425
  if (typeof operand === "number" && operator === "=") {
@@ -18405,6 +18408,147 @@ function tokenizeInvalidRange(chars) {
18405
18408
  return null;
18406
18409
  }
18407
18410
 
18411
+ var State;
18412
+ (function (State) {
18413
+ /**
18414
+ * Initial state.
18415
+ * Expecting any reference for the left part of a range
18416
+ * e.g. "A1", "1", "A", "Sheet1!A1", "Sheet1!A"
18417
+ */
18418
+ State[State["LeftRef"] = 0] = "LeftRef";
18419
+ /**
18420
+ * Expecting any reference for the right part of a range
18421
+ * e.g. "A1", "1", "A", "Sheet1!A1", "Sheet1!A"
18422
+ */
18423
+ State[State["RightRef"] = 1] = "RightRef";
18424
+ /**
18425
+ * Expecting the separator without any constraint on the right part
18426
+ */
18427
+ State[State["Separator"] = 2] = "Separator";
18428
+ /**
18429
+ * Expecting the separator for a full column range
18430
+ */
18431
+ State[State["FullColumnSeparator"] = 3] = "FullColumnSeparator";
18432
+ /**
18433
+ * Expecting the separator for a full row range
18434
+ */
18435
+ State[State["FullRowSeparator"] = 4] = "FullRowSeparator";
18436
+ /**
18437
+ * Expecting the right part of a full column range
18438
+ * e.g. "1", "A1"
18439
+ */
18440
+ State[State["RightColumnRef"] = 5] = "RightColumnRef";
18441
+ /**
18442
+ * Expecting the right part of a full row range
18443
+ * e.g. "A", "A1"
18444
+ */
18445
+ State[State["RightRowRef"] = 6] = "RightRowRef";
18446
+ /**
18447
+ * Final state. A range has been matched
18448
+ */
18449
+ State[State["Found"] = 7] = "Found";
18450
+ })(State || (State = {}));
18451
+ const goTo = (state, guard = () => true) => [
18452
+ {
18453
+ goTo: state,
18454
+ guard,
18455
+ },
18456
+ ];
18457
+ const goToMulti = (state, guard = () => true) => ({
18458
+ goTo: state,
18459
+ guard,
18460
+ });
18461
+ const machine = {
18462
+ [State.LeftRef]: {
18463
+ REFERENCE: goTo(State.Separator),
18464
+ NUMBER: goTo(State.FullRowSeparator),
18465
+ SYMBOL: [
18466
+ goToMulti(State.FullColumnSeparator, (token) => isColReference(token.value)),
18467
+ goToMulti(State.FullRowSeparator, (token) => isRowReference(token.value)),
18468
+ ],
18469
+ },
18470
+ [State.FullColumnSeparator]: {
18471
+ SPACE: goTo(State.FullColumnSeparator),
18472
+ OPERATOR: goTo(State.RightColumnRef, (token) => token.value === ":"),
18473
+ },
18474
+ [State.FullRowSeparator]: {
18475
+ SPACE: goTo(State.FullRowSeparator),
18476
+ OPERATOR: goTo(State.RightRowRef, (token) => token.value === ":"),
18477
+ },
18478
+ [State.Separator]: {
18479
+ SPACE: goTo(State.Separator),
18480
+ OPERATOR: goTo(State.RightRef, (token) => token.value === ":"),
18481
+ },
18482
+ [State.RightRef]: {
18483
+ SPACE: goTo(State.RightRef),
18484
+ NUMBER: goTo(State.Found),
18485
+ REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18486
+ SYMBOL: goTo(State.Found, (token) => isColHeader(token.value) || isRowHeader(token.value)),
18487
+ },
18488
+ [State.RightColumnRef]: {
18489
+ SPACE: goTo(State.RightColumnRef),
18490
+ SYMBOL: goTo(State.Found, (token) => isColHeader(token.value)),
18491
+ REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18492
+ },
18493
+ [State.RightRowRef]: {
18494
+ SPACE: goTo(State.RightRowRef),
18495
+ NUMBER: goTo(State.Found),
18496
+ REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18497
+ SYMBOL: goTo(State.Found, (token) => isRowHeader(token.value)),
18498
+ },
18499
+ [State.Found]: {},
18500
+ };
18501
+ /**
18502
+ * Check if the list of tokens starts with a sequence of tokens representing
18503
+ * a range.
18504
+ * If a range is found, the sequence is removed from the list and is returned
18505
+ * as a single token.
18506
+ */
18507
+ function matchReference(tokens) {
18508
+ var _a;
18509
+ let head = 0;
18510
+ let transitions = machine[State.LeftRef];
18511
+ let matchedTokens = "";
18512
+ while (transitions !== undefined) {
18513
+ const token = tokens[head++];
18514
+ if (!token) {
18515
+ return null;
18516
+ }
18517
+ const transition = (_a = transitions[token.type]) === null || _a === void 0 ? void 0 : _a.find((transition) => transition.guard(token));
18518
+ const nextState = transition ? transition.goTo : undefined;
18519
+ switch (nextState) {
18520
+ case undefined:
18521
+ return null;
18522
+ case State.Found:
18523
+ matchedTokens += token.value;
18524
+ tokens.splice(0, head);
18525
+ return {
18526
+ type: "REFERENCE",
18527
+ value: matchedTokens,
18528
+ };
18529
+ default:
18530
+ transitions = machine[nextState];
18531
+ matchedTokens += token.value;
18532
+ break;
18533
+ }
18534
+ }
18535
+ return null;
18536
+ }
18537
+ /**
18538
+ * Take the result of the tokenizer and transform it to be usable in the
18539
+ * manipulations of range
18540
+ *
18541
+ * @param formula
18542
+ */
18543
+ function rangeTokenize(formula) {
18544
+ const tokens = tokenize(formula);
18545
+ const result = [];
18546
+ while (tokens.length) {
18547
+ result.push(matchReference(tokens) || tokens.shift());
18548
+ }
18549
+ return result;
18550
+ }
18551
+
18408
18552
  const functionRegex = /[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/;
18409
18553
  const UNARY_OPERATORS_PREFIX = ["-", "+"];
18410
18554
  const UNARY_OPERATORS_POSTFIX = ["%"];
@@ -18571,7 +18715,7 @@ function parseExpression(tokens, bp) {
18571
18715
  * Parse an expression (as a string) into an AST.
18572
18716
  */
18573
18717
  function parse(str) {
18574
- return parseTokens(tokenize(str));
18718
+ return parseTokens(rangeTokenize(str));
18575
18719
  }
18576
18720
  function parseTokens(tokens) {
18577
18721
  tokens = tokens.filter((x) => x.type !== "SPACE");
@@ -18683,147 +18827,6 @@ function rightOperandToFormula(operationAST) {
18683
18827
  return needParenthesis ? `(${astToFormula(rightOperation)})` : astToFormula(rightOperation);
18684
18828
  }
18685
18829
 
18686
- var State;
18687
- (function (State) {
18688
- /**
18689
- * Initial state.
18690
- * Expecting any reference for the left part of a range
18691
- * e.g. "A1", "1", "A", "Sheet1!A1", "Sheet1!A"
18692
- */
18693
- State[State["LeftRef"] = 0] = "LeftRef";
18694
- /**
18695
- * Expecting any reference for the right part of a range
18696
- * e.g. "A1", "1", "A", "Sheet1!A1", "Sheet1!A"
18697
- */
18698
- State[State["RightRef"] = 1] = "RightRef";
18699
- /**
18700
- * Expecting the separator without any constraint on the right part
18701
- */
18702
- State[State["Separator"] = 2] = "Separator";
18703
- /**
18704
- * Expecting the separator for a full column range
18705
- */
18706
- State[State["FullColumnSeparator"] = 3] = "FullColumnSeparator";
18707
- /**
18708
- * Expecting the separator for a full row range
18709
- */
18710
- State[State["FullRowSeparator"] = 4] = "FullRowSeparator";
18711
- /**
18712
- * Expecting the right part of a full column range
18713
- * e.g. "1", "A1"
18714
- */
18715
- State[State["RightColumnRef"] = 5] = "RightColumnRef";
18716
- /**
18717
- * Expecting the right part of a full row range
18718
- * e.g. "A", "A1"
18719
- */
18720
- State[State["RightRowRef"] = 6] = "RightRowRef";
18721
- /**
18722
- * Final state. A range has been matched
18723
- */
18724
- State[State["Found"] = 7] = "Found";
18725
- })(State || (State = {}));
18726
- const goTo = (state, guard = () => true) => [
18727
- {
18728
- goTo: state,
18729
- guard,
18730
- },
18731
- ];
18732
- const goToMulti = (state, guard = () => true) => ({
18733
- goTo: state,
18734
- guard,
18735
- });
18736
- const machine = {
18737
- [State.LeftRef]: {
18738
- REFERENCE: goTo(State.Separator),
18739
- NUMBER: goTo(State.FullRowSeparator),
18740
- SYMBOL: [
18741
- goToMulti(State.FullColumnSeparator, (token) => isColReference(token.value)),
18742
- goToMulti(State.FullRowSeparator, (token) => isRowReference(token.value)),
18743
- ],
18744
- },
18745
- [State.FullColumnSeparator]: {
18746
- SPACE: goTo(State.FullColumnSeparator),
18747
- OPERATOR: goTo(State.RightColumnRef, (token) => token.value === ":"),
18748
- },
18749
- [State.FullRowSeparator]: {
18750
- SPACE: goTo(State.FullRowSeparator),
18751
- OPERATOR: goTo(State.RightRowRef, (token) => token.value === ":"),
18752
- },
18753
- [State.Separator]: {
18754
- SPACE: goTo(State.Separator),
18755
- OPERATOR: goTo(State.RightRef, (token) => token.value === ":"),
18756
- },
18757
- [State.RightRef]: {
18758
- SPACE: goTo(State.RightRef),
18759
- NUMBER: goTo(State.Found),
18760
- REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18761
- SYMBOL: goTo(State.Found, (token) => isColHeader(token.value) || isRowHeader(token.value)),
18762
- },
18763
- [State.RightColumnRef]: {
18764
- SPACE: goTo(State.RightColumnRef),
18765
- SYMBOL: goTo(State.Found, (token) => isColHeader(token.value)),
18766
- REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18767
- },
18768
- [State.RightRowRef]: {
18769
- SPACE: goTo(State.RightRowRef),
18770
- NUMBER: goTo(State.Found),
18771
- REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18772
- SYMBOL: goTo(State.Found, (token) => isRowHeader(token.value)),
18773
- },
18774
- [State.Found]: {},
18775
- };
18776
- /**
18777
- * Check if the list of tokens starts with a sequence of tokens representing
18778
- * a range.
18779
- * If a range is found, the sequence is removed from the list and is returned
18780
- * as a single token.
18781
- */
18782
- function matchReference(tokens) {
18783
- var _a;
18784
- let head = 0;
18785
- let transitions = machine[State.LeftRef];
18786
- let matchedTokens = "";
18787
- while (transitions !== undefined) {
18788
- const token = tokens[head++];
18789
- if (!token) {
18790
- return null;
18791
- }
18792
- const transition = (_a = transitions[token.type]) === null || _a === void 0 ? void 0 : _a.find((transition) => transition.guard(token));
18793
- const nextState = transition ? transition.goTo : undefined;
18794
- switch (nextState) {
18795
- case undefined:
18796
- return null;
18797
- case State.Found:
18798
- matchedTokens += token.value;
18799
- tokens.splice(0, head);
18800
- return {
18801
- type: "REFERENCE",
18802
- value: matchedTokens,
18803
- };
18804
- default:
18805
- transitions = machine[nextState];
18806
- matchedTokens += token.value;
18807
- break;
18808
- }
18809
- }
18810
- return null;
18811
- }
18812
- /**
18813
- * Take the result of the tokenizer and transform it to be usable in the
18814
- * manipulations of range
18815
- *
18816
- * @param formula
18817
- */
18818
- function rangeTokenize(formula) {
18819
- const tokens = tokenize(formula);
18820
- const result = [];
18821
- while (tokens.length) {
18822
- result.push(matchReference(tokens) || tokens.shift());
18823
- }
18824
- return result;
18825
- }
18826
-
18827
18830
  const functions$2 = functionRegistry.content;
18828
18831
  const OPERATOR_MAP = {
18829
18832
  "=": "EQ",
@@ -27606,6 +27609,22 @@ class BordersPlugin extends CorePlugin {
27606
27609
  return [];
27607
27610
  return Object.keys(sheetBorders).map((index) => parseInt(index, 10));
27608
27611
  }
27612
+ /**
27613
+ * Get all the rows which contains at least a border
27614
+ */
27615
+ getRowsWithBorders(sheetId) {
27616
+ var _a;
27617
+ const sheetBorders = (_a = this.borders[sheetId]) === null || _a === void 0 ? void 0 : _a.filter(isDefined$1);
27618
+ if (!sheetBorders)
27619
+ return [];
27620
+ const rowsWithBorders = new Set();
27621
+ for (const rowBorders of sheetBorders) {
27622
+ for (const rowBorder in rowBorders) {
27623
+ rowsWithBorders.add(parseInt(rowBorder, 10));
27624
+ }
27625
+ }
27626
+ return Array.from(rowsWithBorders);
27627
+ }
27609
27628
  /**
27610
27629
  * Get the range of all the rows in the sheet
27611
27630
  */
@@ -27655,7 +27674,7 @@ class BordersPlugin extends CorePlugin {
27655
27674
  destructive: false,
27656
27675
  });
27657
27676
  }
27658
- this.getRowsRange(sheetId)
27677
+ this.getRowsWithBorders(sheetId)
27659
27678
  .filter((row) => row >= start)
27660
27679
  .sort((a, b) => (delta < 0 ? a - b : b - a)) // start by the end when moving up
27661
27680
  .forEach((row) => {
@@ -43417,6 +43436,6 @@ exports.setTranslationMethod = setTranslationMethod;
43417
43436
  exports.tokenize = tokenize;
43418
43437
 
43419
43438
 
43420
- __info__.version = '16.0.46';
43421
- __info__.date = '2024-07-02T10:32:41.666Z';
43422
- __info__.hash = 'd52d430';
43439
+ __info__.version = '16.0.47';
43440
+ __info__.date = '2024-07-08T05:37:37.541Z';
43441
+ __info__.hash = 'f52ca6f';
@@ -3025,6 +3025,10 @@ declare class BordersPlugin extends CorePlugin<BordersPluginState> implements Bo
3025
3025
  * Get all the columns which contains at least a border
3026
3026
  */
3027
3027
  private getColumnsWithBorders;
3028
+ /**
3029
+ * Get all the rows which contains at least a border
3030
+ */
3031
+ private getRowsWithBorders;
3028
3032
  /**
3029
3033
  * Get the range of all the rows in the sheet
3030
3034
  */