@odoo/o-spreadsheet 16.2.16 → 16.2.18

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.
@@ -299,7 +299,16 @@
299
299
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
300
300
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
301
301
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
302
+ const CACHE = {};
302
303
  function parseDateTime(str) {
304
+ if (str in CACHE) {
305
+ return CACHE[str];
306
+ }
307
+ const date = _parseDateTime(str);
308
+ CACHE[str] = date;
309
+ return date;
310
+ }
311
+ function _parseDateTime(str) {
303
312
  str = str.trim();
304
313
  let time;
305
314
  const timeMatch = str.match(timeRegexp);
@@ -2141,8 +2150,9 @@
2141
2150
  }
2142
2151
  get zone() {
2143
2152
  const { left, top, bottom, right } = this._zone;
2144
- if (right !== undefined && bottom !== undefined)
2145
- return { left, top, right, bottom };
2153
+ if (right !== undefined && bottom !== undefined) {
2154
+ return this._zone;
2155
+ }
2146
2156
  else if (bottom === undefined && right !== undefined) {
2147
2157
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).numberOfRows - 1 };
2148
2158
  }
@@ -4866,6 +4876,9 @@
4866
4876
  });
4867
4877
  this.state.values = this.getFilterValues(this.props.filterPosition);
4868
4878
  }
4879
+ get isReadonly() {
4880
+ return this.env.model.getters.isReadonly();
4881
+ }
4869
4882
  getFilterValues(position) {
4870
4883
  const sheetId = this.env.model.getters.getActiveSheetId();
4871
4884
  const filter = this.env.model.getters.getFilter({ sheetId, ...position });
@@ -18706,9 +18719,9 @@
18706
18719
  }
18707
18720
  setup() {
18708
18721
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
18709
- this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
18710
18722
  owl.onMounted(() => this.focusInput());
18711
18723
  owl.onWillUnmount(() => {
18724
+ clearTimeout(this.debounceTimeoutId);
18712
18725
  this.env.model.dispatch("CLEAR_SEARCH");
18713
18726
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
18714
18727
  });
@@ -18753,6 +18766,13 @@
18753
18766
  searchOptions: this.state.searchOptions,
18754
18767
  });
18755
18768
  }
18769
+ debouncedUpdateSearch() {
18770
+ clearTimeout(this.debounceTimeoutId);
18771
+ this.debounceTimeoutId = setTimeout(() => {
18772
+ this.updateSearch();
18773
+ this.debounceTimeoutId = undefined;
18774
+ }, 200);
18775
+ }
18756
18776
  replace() {
18757
18777
  this.env.model.dispatch("REPLACE_SEARCH", {
18758
18778
  replaceWith: this.state.replaceWith,
@@ -21163,7 +21183,14 @@
21163
21183
  return;
21164
21184
  }
21165
21185
  if (this.state.waitingForMove === true) {
21166
- this.startMovement(ev);
21186
+ if (!this.env.model.getters.isGridSelectionActive()) {
21187
+ this._selectElement(index, false);
21188
+ }
21189
+ else {
21190
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
21191
+ // a way to have the grid selection follow the other selections evolution
21192
+ this.startMovement(ev);
21193
+ }
21167
21194
  return;
21168
21195
  }
21169
21196
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -28123,10 +28150,11 @@
28123
28150
  * Reconstructs the original formula string based on a normalized form and its dependencies
28124
28151
  */
28125
28152
  buildFormulaContent(sheetId, cell, dependencies) {
28126
- const ranges = dependencies || [...cell.dependencies];
28153
+ const ranges = dependencies || cell.dependencies;
28154
+ let rangeIndex = 0;
28127
28155
  return concat(cell.compiledFormula.tokens.map((token) => {
28128
28156
  if (token.type === "REFERENCE") {
28129
- const range = ranges.shift();
28157
+ const range = ranges[rangeIndex++];
28130
28158
  return this.getters.getRangeString(range, sheetId);
28131
28159
  }
28132
28160
  return token.value;
@@ -29432,7 +29460,11 @@
29432
29460
  let sizes = [...this.sizes[cmd.sheetId][cmd.dimension]];
29433
29461
  const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
29434
29462
  const baseSize = sizes[cmd.base];
29435
- sizes.splice(addIndex, 0, ...Array(cmd.quantity).fill(baseSize));
29463
+ const sizesToInsert = range(0, cmd.quantity).map(() => ({
29464
+ manualSize: baseSize.manualSize,
29465
+ computedSize: lazy(baseSize.computedSize()),
29466
+ }));
29467
+ sizes.splice(addIndex, 0, ...sizesToInsert);
29436
29468
  sizes = sizes.map((size, row) => {
29437
29469
  if (cmd.dimension === "ROW" && row > cmd.base + cmd.quantity) {
29438
29470
  // invalidate sizes
@@ -32945,30 +32977,26 @@
32945
32977
  const { end } = this.getters.getColDimensions(sheetId, targetCol);
32946
32978
  const maxCol = this.getters.getNumberCols(sheetId);
32947
32979
  if (this.offsetX + this.offsetCorrectionX + this.viewportWidth < end) {
32948
- for (let col = this.left; this.offsetX + this.offsetCorrectionX + this.viewportWidth < end; col++) {
32949
- if (col > maxCol) {
32950
- break;
32951
- }
32952
- if (this.getters.isColHidden(sheetId, col)) {
32953
- continue;
32954
- }
32955
- this.offsetX = this.getters.getColDimensions(sheetId, col).end - this.offsetCorrectionX;
32956
- this.offsetScrollbarX = this.offsetX;
32957
- this.adjustViewportZoneX();
32980
+ let finalTarget = targetCol;
32981
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol < maxCol) {
32982
+ finalTarget++;
32958
32983
  }
32984
+ const finalTargetEnd = this.getters.getColDimensions(sheetId, finalTarget).end;
32985
+ const startIndex = this.searchHeaderIndex("COL", finalTargetEnd - this.viewportWidth - this.offsetCorrectionX, this.boundaries.left, true);
32986
+ this.offsetX =
32987
+ this.getters.getColDimensions(sheetId, startIndex).end - this.offsetCorrectionX;
32988
+ this.offsetScrollbarX = this.offsetX;
32989
+ this.adjustViewportZoneX();
32959
32990
  }
32960
32991
  else if (this.left > targetCol) {
32961
- for (let col = this.left; col >= targetCol; col--) {
32962
- if (col < 0) {
32963
- break;
32964
- }
32965
- if (this.getters.isColHidden(sheetId, col)) {
32966
- continue;
32967
- }
32968
- this.offsetX = this.getters.getColDimensions(sheetId, col).start - this.offsetCorrectionX;
32969
- this.offsetScrollbarX = this.offsetX;
32970
- this.adjustViewportZoneX();
32992
+ let finalTarget = targetCol;
32993
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol > 0) {
32994
+ finalTarget--;
32971
32995
  }
32996
+ this.offsetX =
32997
+ this.getters.getColDimensions(sheetId, finalTarget).start - this.offsetCorrectionX;
32998
+ this.offsetScrollbarX = this.offsetX;
32999
+ this.adjustViewportZoneX();
32972
33000
  }
32973
33001
  }
32974
33002
  adjustPositionY(targetRow) {
@@ -32976,30 +33004,26 @@
32976
33004
  const { end } = this.getters.getRowDimensions(sheetId, targetRow);
32977
33005
  const maxRow = this.getters.getNumberRows(sheetId);
32978
33006
  if (this.offsetY + this.viewportHeight + this.offsetCorrectionY < end) {
32979
- for (let row = this.top; this.offsetY + this.viewportHeight + this.offsetCorrectionY < end; row++) {
32980
- if (row > maxRow) {
32981
- break;
32982
- }
32983
- if (this.getters.isRowHidden(sheetId, row)) {
32984
- continue;
32985
- }
32986
- this.offsetY = this.getters.getRowDimensions(sheetId, row).end - this.offsetCorrectionY;
32987
- this.offsetScrollbarY = this.offsetY;
32988
- this.adjustViewportZoneY();
33007
+ let finalTarget = targetRow;
33008
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow < maxRow) {
33009
+ finalTarget++;
32989
33010
  }
33011
+ const finalTargetEnd = this.getters.getRowDimensions(sheetId, finalTarget).end;
33012
+ const startIndex = this.searchHeaderIndex("ROW", finalTargetEnd - this.viewportHeight - this.offsetCorrectionY, this.boundaries.top, true);
33013
+ this.offsetY =
33014
+ this.getters.getRowDimensions(sheetId, startIndex).end - this.offsetCorrectionY;
33015
+ this.offsetScrollbarY = this.offsetY;
33016
+ this.adjustViewportZoneY();
32990
33017
  }
32991
33018
  else if (this.top > targetRow) {
32992
- for (let row = this.top; row >= targetRow; row--) {
32993
- if (row < 0) {
32994
- break;
32995
- }
32996
- if (this.getters.isRowHidden(sheetId, row)) {
32997
- continue;
32998
- }
32999
- this.offsetY = this.getters.getRowDimensions(sheetId, row).start - this.offsetCorrectionY;
33000
- this.offsetScrollbarY = this.offsetY;
33001
- this.adjustViewportZoneY();
33019
+ let finalTarget = targetRow;
33020
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow > 0) {
33021
+ finalTarget--;
33002
33022
  }
33023
+ this.offsetY =
33024
+ this.getters.getRowDimensions(sheetId, finalTarget).start - this.offsetCorrectionY;
33025
+ this.offsetScrollbarY = this.offsetY;
33026
+ this.adjustViewportZoneY();
33003
33027
  }
33004
33028
  }
33005
33029
  setViewportOffset(offsetX, offsetY) {
@@ -34574,14 +34598,10 @@
34574
34598
  case "REPLACE_ALL_SEARCH":
34575
34599
  this.replaceAll(cmd.replaceWith);
34576
34600
  break;
34577
- case "EVALUATE_CELLS":
34578
- case "UPDATE_CELL":
34579
- case "REMOVE_FILTER_TABLE":
34580
- case "UPDATE_FILTER":
34581
- this.isSearchDirty = true;
34582
- break;
34583
34601
  case "UNDO":
34584
34602
  case "REDO":
34603
+ case "REMOVE_FILTER_TABLE":
34604
+ case "UPDATE_FILTER":
34585
34605
  case "REMOVE_COLUMNS_ROWS":
34586
34606
  case "HIDE_COLUMNS_ROWS":
34587
34607
  case "UNHIDE_COLUMNS_ROWS":
@@ -37581,7 +37601,7 @@
37581
37601
  });
37582
37602
  for (const filterTable of this.copiedTables) {
37583
37603
  this.dispatch("REMOVE_FILTER_TABLE", {
37584
- sheetId: this.getters.getActiveSheetId(),
37604
+ sheetId: this.sheetId,
37585
37605
  target: [filterTable.zone],
37586
37606
  });
37587
37607
  }
@@ -39240,6 +39260,9 @@
39240
39260
  // ---------------------------------------------------------------------------
39241
39261
  // Getters
39242
39262
  // ---------------------------------------------------------------------------
39263
+ isGridSelectionActive() {
39264
+ return this.selection.isListening(this);
39265
+ }
39243
39266
  getActiveSheet() {
39244
39267
  return this.activeSheet;
39245
39268
  }
@@ -39614,6 +39637,7 @@
39614
39637
  "getSheetPosition",
39615
39638
  "isSelected",
39616
39639
  "getElementsFromSelection",
39640
+ "isGridSelectionActive",
39617
39641
  ];
39618
39642
 
39619
39643
  const corePluginRegistry = new Registry()
@@ -43092,6 +43116,9 @@
43092
43116
  anchor: { zone, cell: this.anchor.cell },
43093
43117
  });
43094
43118
  }
43119
+ isListening(owner) {
43120
+ return this.stream.isListening(owner);
43121
+ }
43095
43122
  /**
43096
43123
  * Process a new anchor selection event. If the new anchor is inside
43097
43124
  * the sheet boundaries, the event is pushed to the event stream to
@@ -45457,9 +45484,9 @@
45457
45484
  Object.defineProperty(exports, '__esModule', { value: true });
45458
45485
 
45459
45486
 
45460
- __info__.version = '16.2.16';
45461
- __info__.date = '2023-09-21T15:56:53.639Z';
45462
- __info__.hash = '1a70819';
45487
+ __info__.version = '16.2.18';
45488
+ __info__.date = '2023-10-10T07:29:40.321Z';
45489
+ __info__.hash = '451fa09';
45463
45490
 
45464
45491
 
45465
45492
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);