@odoo/o-spreadsheet 18.1.15 → 18.1.17

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 18.1.15
6
- * @date 2025-04-14T17:17:30.890Z
7
- * @hash ddaea83
5
+ * @version 18.1.17
6
+ * @date 2025-04-25T08:08:46.599Z
7
+ * @hash a63687f
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -3833,11 +3833,13 @@
3833
3833
  NullError: "#NULL!",
3834
3834
  };
3835
3835
  const errorTypes = new Set(Object.values(CellErrorType));
3836
- class EvaluationError extends Error {
3836
+ class EvaluationError {
3837
+ message;
3837
3838
  value;
3838
3839
  constructor(message = _t("Error"), value = CellErrorType.GenericError) {
3839
- super(message);
3840
+ this.message = message;
3840
3841
  this.value = value;
3842
+ this.message = message.toString();
3841
3843
  }
3842
3844
  }
3843
3845
  class BadExpressionError extends EvaluationError {
@@ -6890,6 +6892,12 @@
6890
6892
  }
6891
6893
  return null;
6892
6894
  }
6895
+ /**
6896
+ - \p{L} is for any letter (from any language)
6897
+ - \p{N} is for any number
6898
+ - the u flag at the end is for unicode, which enables the `\p{...}` syntax
6899
+ */
6900
+ const unicodeSymbolCharRegexp = /\p{L}|\p{N}|_|\.|!|\$/u;
6893
6901
  const SYMBOL_CHARS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$");
6894
6902
  /**
6895
6903
  * A "Symbol" is just basically any word-like element that can appear in a
@@ -6930,7 +6938,8 @@
6930
6938
  };
6931
6939
  }
6932
6940
  }
6933
- while (chars.current && SYMBOL_CHARS.has(chars.current)) {
6941
+ while (chars.current &&
6942
+ (SYMBOL_CHARS.has(chars.current) || chars.current.match(unicodeSymbolCharRegexp))) {
6934
6943
  result += chars.shift();
6935
6944
  }
6936
6945
  if (result.length) {
@@ -9236,7 +9245,7 @@
9236
9245
  if (executed.type === "ADD_COLUMNS_ROWS") {
9237
9246
  return expandZoneOnInsertion(zone, executed.dimension === "COL" ? "left" : "top", executed.base, executed.position, executed.quantity);
9238
9247
  }
9239
- return { ...zone };
9248
+ return zone;
9240
9249
  }
9241
9250
  function transformRangeData(range, executed) {
9242
9251
  const deletedSheet = executed.type === "DELETE_SHEET" && executed.sheetId;
@@ -13571,7 +13580,7 @@ stores.inject(MyMetaStore, storeInstance);
13571
13580
  }
13572
13581
  }
13573
13582
  if (!found) {
13574
- throw new NotAvailableError(_t("Value not found in the given data."));
13583
+ return new NotAvailableError(_t("Value not found in the given data."));
13575
13584
  }
13576
13585
  return rank;
13577
13586
  },
@@ -15311,7 +15320,7 @@ stores.inject(MyMetaStore, storeInstance);
15311
15320
  result.push(row.data);
15312
15321
  }
15313
15322
  if (!result.length)
15314
- throw new EvaluationError(_t("No unique values found"));
15323
+ return new EvaluationError(_t("No unique values found"));
15315
15324
  return _byColumn ? result : transposeMatrix(result);
15316
15325
  },
15317
15326
  isExported: true,
@@ -19090,7 +19099,7 @@ stores.inject(MyMetaStore, storeInstance);
19090
19099
  }
19091
19100
  const _cellReference = cellReference?.value;
19092
19101
  if (!_cellReference) {
19093
- throw new Error("In this context, the function OFFSET needs to have a cell or range in parameter.");
19102
+ return new EvaluationError("In this context, the function OFFSET needs to have a cell or range in parameter.");
19094
19103
  }
19095
19104
  const zone = toZone(_cellReference);
19096
19105
  let offsetHeight = zone.bottom - zone.top + 1;
@@ -38553,7 +38562,7 @@ stores.inject(MyMetaStore, storeInstance);
38553
38562
  }
38554
38563
  setHexColor(ev) {
38555
38564
  // only support HEX code input
38556
- const val = ev.target.value.slice(0, 7);
38565
+ const val = ev.target.value.replace("##", "#").slice(0, 7);
38557
38566
  this.state.customHexColor = val;
38558
38567
  if (!isColorValid(val)) ;
38559
38568
  else {
@@ -50106,39 +50115,6 @@ stores.inject(MyMetaStore, storeInstance);
50106
50115
  }
50107
50116
  return hoveredPosition;
50108
50117
  }
50109
- function useTouchMove(gridRef, handler, canMoveUp) {
50110
- let x = null;
50111
- let y = null;
50112
- function onTouchStart(ev) {
50113
- if (ev.touches.length !== 1)
50114
- return;
50115
- x = ev.touches[0].clientX;
50116
- y = ev.touches[0].clientY;
50117
- }
50118
- function onTouchEnd() {
50119
- x = null;
50120
- y = null;
50121
- }
50122
- function onTouchMove(ev) {
50123
- if (ev.touches.length !== 1)
50124
- return;
50125
- // On mobile browsers, swiping down is often associated with "pull to refresh".
50126
- // We only want this behavior if the grid is already at the top.
50127
- // Otherwise we only want to move the canvas up, without triggering any refresh.
50128
- if (canMoveUp()) {
50129
- ev.preventDefault();
50130
- ev.stopPropagation();
50131
- }
50132
- const currentX = ev.touches[0].clientX;
50133
- const currentY = ev.touches[0].clientY;
50134
- handler(x - currentX, y - currentY);
50135
- x = currentX;
50136
- y = currentY;
50137
- }
50138
- useRefListener(gridRef, "touchstart", onTouchStart);
50139
- useRefListener(gridRef, "touchend", onTouchEnd);
50140
- useRefListener(gridRef, "touchmove", onTouchMove);
50141
- }
50142
50118
  class GridOverlay extends owl.Component {
50143
50119
  static template = "o-spreadsheet-GridOverlay";
50144
50120
  static props = {
@@ -50186,10 +50162,6 @@ stores.inject(MyMetaStore, storeInstance);
50186
50162
  owl.onWillUnmount(() => {
50187
50163
  resizeObserver.disconnect();
50188
50164
  });
50189
- useTouchMove(this.gridOverlay, this.props.onGridMoved, () => {
50190
- const { scrollY } = this.env.model.getters.getActiveSheetDOMScrollInfo();
50191
- return scrollY > 0;
50192
- });
50193
50165
  this.cellPopovers = useStore(CellPopoverStore);
50194
50166
  this.paintFormatStore = useStore(PaintFormatStore);
50195
50167
  }
@@ -51547,6 +51519,73 @@ stores.inject(MyMetaStore, storeInstance);
51547
51519
  }
51548
51520
  }
51549
51521
 
51522
+ const friction = 0.95;
51523
+ const verticalScrollFactor = 1;
51524
+ const horizontalScrollFactor = 1;
51525
+ function useTouchScroll(ref, updateScroll, canMoveUp) {
51526
+ let lastX = 0;
51527
+ let lastY = 0;
51528
+ let velocityX = 0;
51529
+ let velocityY = 0;
51530
+ let isMouseDown = false;
51531
+ let lastTime = 0;
51532
+ useRefListener(ref, "touchstart", onTouchStart, { capture: false });
51533
+ useRefListener(ref, "touchmove", onTouchMove, { capture: false });
51534
+ useRefListener(ref, "touchend", onTouchEnd, { capture: false });
51535
+ function onTouchStart(event) {
51536
+ isMouseDown = true;
51537
+ ({ clientX: lastX, clientY: lastY } = event.touches[0]);
51538
+ velocityX = 0;
51539
+ velocityY = 0;
51540
+ }
51541
+ function onTouchMove(event) {
51542
+ if (!isMouseDown)
51543
+ return;
51544
+ const currentTime = Date.now();
51545
+ const { clientX, clientY } = event.touches[0];
51546
+ let deltaX = lastX - clientX;
51547
+ let deltaY = lastY - clientY;
51548
+ const elapsedTime = currentTime - lastTime;
51549
+ velocityX = deltaX / elapsedTime;
51550
+ velocityY = deltaY / elapsedTime;
51551
+ lastX = clientX;
51552
+ lastY = clientY;
51553
+ lastTime = currentTime;
51554
+ if (canMoveUp()) {
51555
+ if (event.cancelable) {
51556
+ event.preventDefault();
51557
+ }
51558
+ event.stopPropagation();
51559
+ }
51560
+ updateScroll(deltaX * horizontalScrollFactor, deltaY * verticalScrollFactor);
51561
+ }
51562
+ function onTouchEnd(ev) {
51563
+ isMouseDown = false;
51564
+ lastX = lastY = 0;
51565
+ requestAnimationFrame(scroll);
51566
+ }
51567
+ function scroll() {
51568
+ if (Math.abs(velocityX) < 0.05) {
51569
+ velocityX = 0;
51570
+ }
51571
+ if (Math.abs(velocityY) < 0.05) {
51572
+ velocityY = 0;
51573
+ }
51574
+ if (!velocityX && !velocityY) {
51575
+ return;
51576
+ }
51577
+ const currentTime = Date.now();
51578
+ const elapsedTime = Math.abs(currentTime - lastTime);
51579
+ const deltaX = velocityX * elapsedTime;
51580
+ const deltaY = velocityY * elapsedTime;
51581
+ updateScroll(deltaX * horizontalScrollFactor, deltaY * verticalScrollFactor);
51582
+ lastTime = currentTime;
51583
+ velocityX *= friction;
51584
+ velocityY *= friction;
51585
+ requestAnimationFrame(scroll);
51586
+ }
51587
+ }
51588
+
51550
51589
  function useWheelHandler(handler) {
51551
51590
  function normalize(val, deltaMode) {
51552
51591
  return val * (deltaMode === 0 ? 1 : DEFAULT_CELL_HEIGHT);
@@ -52167,6 +52206,10 @@ stores.inject(MyMetaStore, storeInstance);
52167
52206
  this.DOMFocusableElementStore.focusableElement?.focus();
52168
52207
  }
52169
52208
  }, () => [this.sidePanel.isOpen]);
52209
+ useTouchScroll(this.gridRef, this.moveCanvas.bind(this), () => {
52210
+ const { scrollY } = this.env.model.getters.getActiveSheetScrollInfo();
52211
+ return scrollY > 0;
52212
+ });
52170
52213
  }
52171
52214
  onCellHovered({ col, row }) {
52172
52215
  this.hoveredCell.hover({ col, row });
@@ -61831,6 +61874,16 @@ stores.inject(MyMetaStore, storeInstance);
61831
61874
  }
61832
61875
  return values;
61833
61876
  }
61877
+ else if (rowDomain.length === this.definition.rows.length &&
61878
+ colDomain.length &&
61879
+ colDomain.length < this.definition.columns.length) {
61880
+ const colSubTree = this.getSubTreeMatchingDomain(table.getColTree(), colDomain);
61881
+ const domains = this.treeToLeafDomains(colSubTree, colDomain);
61882
+ for (const domain of domains) {
61883
+ values.push(this._getPivotCellValueAndFormat(measure.id, rowDomain.concat(domain)));
61884
+ }
61885
+ return values;
61886
+ }
61834
61887
  else {
61835
61888
  const tree = table.getRowTree();
61836
61889
  const subTree = this.getSubTreeMatchingDomain(tree, rowDomain);
@@ -63376,10 +63429,8 @@ stores.inject(MyMetaStore, storeInstance);
63376
63429
  }
63377
63430
  const target = [];
63378
63431
  for (const zone1 of toTransform.target) {
63379
- for (const zone2 of executed.target) {
63380
- if (!overlap(zone1, zone2)) {
63381
- target.push({ ...zone1 });
63382
- }
63432
+ if (executed.target.every((zone2) => !overlap(zone1, zone2))) {
63433
+ target.push(zone1);
63383
63434
  }
63384
63435
  }
63385
63436
  if (target.length) {
@@ -69651,6 +69702,10 @@ stores.inject(MyMetaStore, storeInstance);
69651
69702
  this.hoveredCell.clear();
69652
69703
  });
69653
69704
  this.cellPopovers = useStore(CellPopoverStore);
69705
+ useTouchScroll(gridRef, this.moveCanvas.bind(this), () => {
69706
+ const { scrollY } = this.env.model.getters.getActiveSheetScrollInfo();
69707
+ return scrollY > 0;
69708
+ });
69654
69709
  }
69655
69710
  onCellHovered({ col, row }) {
69656
69711
  this.hoveredCell.hover({ col, row });
@@ -75725,9 +75780,9 @@ stores.inject(MyMetaStore, storeInstance);
75725
75780
  exports.tokenize = tokenize;
75726
75781
 
75727
75782
 
75728
- __info__.version = "18.1.15";
75729
- __info__.date = "2025-04-14T17:17:30.890Z";
75730
- __info__.hash = "ddaea83";
75783
+ __info__.version = "18.1.17";
75784
+ __info__.date = "2025-04-25T08:08:46.599Z";
75785
+ __info__.hash = "a63687f";
75731
75786
 
75732
75787
 
75733
75788
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);