@odoo/o-spreadsheet 16.3.11 → 16.3.13

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.
@@ -311,7 +311,16 @@
311
311
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
312
312
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
313
313
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
314
+ const CACHE = {};
314
315
  function parseDateTime(str) {
316
+ if (str in CACHE) {
317
+ return CACHE[str];
318
+ }
319
+ const date = _parseDateTime(str);
320
+ CACHE[str] = date;
321
+ return date;
322
+ }
323
+ function _parseDateTime(str) {
315
324
  str = str.trim();
316
325
  let time;
317
326
  const timeMatch = str.match(timeRegexp);
@@ -2248,8 +2257,9 @@
2248
2257
  }
2249
2258
  get zone() {
2250
2259
  const { left, top, bottom, right } = this._zone;
2251
- if (right !== undefined && bottom !== undefined)
2252
- return { left, top, right, bottom };
2260
+ if (right !== undefined && bottom !== undefined) {
2261
+ return this._zone;
2262
+ }
2253
2263
  else if (bottom === undefined && right !== undefined) {
2254
2264
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).numberOfRows - 1 };
2255
2265
  }
@@ -4987,6 +4997,9 @@
4987
4997
  });
4988
4998
  this.state.values = this.getFilterValues(this.props.filterPosition);
4989
4999
  }
5000
+ get isReadonly() {
5001
+ return this.env.model.getters.isReadonly();
5002
+ }
4990
5003
  getFilterValues(position) {
4991
5004
  const sheetId = this.env.model.getters.getActiveSheetId();
4992
5005
  const filter = this.env.model.getters.getFilter({ sheetId, ...position });
@@ -19675,7 +19688,6 @@
19675
19688
  state = owl.useState(this.initialState());
19676
19689
  debounceTimeoutId;
19677
19690
  showFormulaState = false;
19678
- debouncedUpdateSearch;
19679
19691
  findAndReplaceRef = owl.useRef("findAndReplace");
19680
19692
  get hasSearchResult() {
19681
19693
  return this.env.model.getters.getCurrentSelectedMatchIndex() !== null;
@@ -19685,9 +19697,9 @@
19685
19697
  }
19686
19698
  setup() {
19687
19699
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
19688
- this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
19689
19700
  owl.onMounted(() => this.focusInput());
19690
19701
  owl.onWillUnmount(() => {
19702
+ clearTimeout(this.debounceTimeoutId);
19691
19703
  this.env.model.dispatch("CLEAR_SEARCH");
19692
19704
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
19693
19705
  });
@@ -19732,6 +19744,13 @@
19732
19744
  searchOptions: this.state.searchOptions,
19733
19745
  });
19734
19746
  }
19747
+ debouncedUpdateSearch() {
19748
+ clearTimeout(this.debounceTimeoutId);
19749
+ this.debounceTimeoutId = setTimeout(() => {
19750
+ this.updateSearch();
19751
+ this.debounceTimeoutId = undefined;
19752
+ }, 200);
19753
+ }
19735
19754
  replace() {
19736
19755
  this.env.model.dispatch("REPLACE_SEARCH", {
19737
19756
  replaceWith: this.state.replaceWith,
@@ -22505,7 +22524,14 @@
22505
22524
  return;
22506
22525
  }
22507
22526
  if (this.state.waitingForMove === true) {
22508
- this.startMovement(ev);
22527
+ if (!this.env.model.getters.isGridSelectionActive()) {
22528
+ this._selectElement(index, false);
22529
+ }
22530
+ else {
22531
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
22532
+ // a way to have the grid selection follow the other selections evolution
22533
+ this.startMovement(ev);
22534
+ }
22509
22535
  return;
22510
22536
  }
22511
22537
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -29630,10 +29656,11 @@
29630
29656
  * Reconstructs the original formula string based on a normalized form and its dependencies
29631
29657
  */
29632
29658
  buildFormulaContent(sheetId, cell, dependencies) {
29633
- const ranges = dependencies || [...cell.dependencies];
29659
+ const ranges = dependencies || cell.dependencies;
29660
+ let rangeIndex = 0;
29634
29661
  return concat(cell.compiledFormula.tokens.map((token) => {
29635
29662
  if (token.type === "REFERENCE") {
29636
- const range = ranges.shift();
29663
+ const range = ranges[rangeIndex++];
29637
29664
  return this.getters.getRangeString(range, sheetId);
29638
29665
  }
29639
29666
  return token.value;
@@ -30938,7 +30965,11 @@
30938
30965
  let sizes = [...this.sizes[cmd.sheetId][cmd.dimension]];
30939
30966
  const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
30940
30967
  const baseSize = sizes[cmd.base];
30941
- sizes.splice(addIndex, 0, ...Array(cmd.quantity).fill(baseSize));
30968
+ const sizesToInsert = range(0, cmd.quantity).map(() => ({
30969
+ manualSize: baseSize.manualSize,
30970
+ computedSize: lazy(baseSize.computedSize()),
30971
+ }));
30972
+ sizes.splice(addIndex, 0, ...sizesToInsert);
30942
30973
  sizes = sizes.map((size, row) => {
30943
30974
  if (cmd.dimension === "ROW" && row > cmd.base + cmd.quantity) {
30944
30975
  // invalidate sizes
@@ -34447,30 +34478,26 @@
34447
34478
  const { end } = this.getters.getColDimensions(sheetId, targetCol);
34448
34479
  const maxCol = this.getters.getNumberCols(sheetId);
34449
34480
  if (this.offsetX + this.offsetCorrectionX + this.viewportWidth < end) {
34450
- for (let col = this.left; this.offsetX + this.offsetCorrectionX + this.viewportWidth < end; col++) {
34451
- if (col > maxCol) {
34452
- break;
34453
- }
34454
- if (this.getters.isColHidden(sheetId, col)) {
34455
- continue;
34456
- }
34457
- this.offsetX = this.getters.getColDimensions(sheetId, col).end - this.offsetCorrectionX;
34458
- this.offsetScrollbarX = this.offsetX;
34459
- this.adjustViewportZoneX();
34481
+ let finalTarget = targetCol;
34482
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol < maxCol) {
34483
+ finalTarget++;
34460
34484
  }
34485
+ const finalTargetEnd = this.getters.getColDimensions(sheetId, finalTarget).end;
34486
+ const startIndex = this.searchHeaderIndex("COL", finalTargetEnd - this.viewportWidth - this.offsetCorrectionX, this.boundaries.left, true);
34487
+ this.offsetX =
34488
+ this.getters.getColDimensions(sheetId, startIndex).end - this.offsetCorrectionX;
34489
+ this.offsetScrollbarX = this.offsetX;
34490
+ this.adjustViewportZoneX();
34461
34491
  }
34462
34492
  else if (this.left > targetCol) {
34463
- for (let col = this.left; col >= targetCol; col--) {
34464
- if (col < 0) {
34465
- break;
34466
- }
34467
- if (this.getters.isColHidden(sheetId, col)) {
34468
- continue;
34469
- }
34470
- this.offsetX = this.getters.getColDimensions(sheetId, col).start - this.offsetCorrectionX;
34471
- this.offsetScrollbarX = this.offsetX;
34472
- this.adjustViewportZoneX();
34493
+ let finalTarget = targetCol;
34494
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol > 0) {
34495
+ finalTarget--;
34473
34496
  }
34497
+ this.offsetX =
34498
+ this.getters.getColDimensions(sheetId, finalTarget).start - this.offsetCorrectionX;
34499
+ this.offsetScrollbarX = this.offsetX;
34500
+ this.adjustViewportZoneX();
34474
34501
  }
34475
34502
  }
34476
34503
  adjustPositionY(targetRow) {
@@ -34478,30 +34505,26 @@
34478
34505
  const { end } = this.getters.getRowDimensions(sheetId, targetRow);
34479
34506
  const maxRow = this.getters.getNumberRows(sheetId);
34480
34507
  if (this.offsetY + this.viewportHeight + this.offsetCorrectionY < end) {
34481
- for (let row = this.top; this.offsetY + this.viewportHeight + this.offsetCorrectionY < end; row++) {
34482
- if (row > maxRow) {
34483
- break;
34484
- }
34485
- if (this.getters.isRowHidden(sheetId, row)) {
34486
- continue;
34487
- }
34488
- this.offsetY = this.getters.getRowDimensions(sheetId, row).end - this.offsetCorrectionY;
34489
- this.offsetScrollbarY = this.offsetY;
34490
- this.adjustViewportZoneY();
34508
+ let finalTarget = targetRow;
34509
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow < maxRow) {
34510
+ finalTarget++;
34491
34511
  }
34512
+ const finalTargetEnd = this.getters.getRowDimensions(sheetId, finalTarget).end;
34513
+ const startIndex = this.searchHeaderIndex("ROW", finalTargetEnd - this.viewportHeight - this.offsetCorrectionY, this.boundaries.top, true);
34514
+ this.offsetY =
34515
+ this.getters.getRowDimensions(sheetId, startIndex).end - this.offsetCorrectionY;
34516
+ this.offsetScrollbarY = this.offsetY;
34517
+ this.adjustViewportZoneY();
34492
34518
  }
34493
34519
  else if (this.top > targetRow) {
34494
- for (let row = this.top; row >= targetRow; row--) {
34495
- if (row < 0) {
34496
- break;
34497
- }
34498
- if (this.getters.isRowHidden(sheetId, row)) {
34499
- continue;
34500
- }
34501
- this.offsetY = this.getters.getRowDimensions(sheetId, row).start - this.offsetCorrectionY;
34502
- this.offsetScrollbarY = this.offsetY;
34503
- this.adjustViewportZoneY();
34520
+ let finalTarget = targetRow;
34521
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow > 0) {
34522
+ finalTarget--;
34504
34523
  }
34524
+ this.offsetY =
34525
+ this.getters.getRowDimensions(sheetId, finalTarget).start - this.offsetCorrectionY;
34526
+ this.offsetScrollbarY = this.offsetY;
34527
+ this.adjustViewportZoneY();
34505
34528
  }
34506
34529
  }
34507
34530
  setViewportOffset(offsetX, offsetY) {
@@ -36977,14 +37000,10 @@
36977
37000
  case "REPLACE_ALL_SEARCH":
36978
37001
  this.replaceAll(cmd.replaceWith);
36979
37002
  break;
36980
- case "EVALUATE_CELLS":
36981
- case "UPDATE_CELL":
36982
- case "REMOVE_FILTER_TABLE":
36983
- case "UPDATE_FILTER":
36984
- this.isSearchDirty = true;
36985
- break;
36986
37003
  case "UNDO":
36987
37004
  case "REDO":
37005
+ case "REMOVE_FILTER_TABLE":
37006
+ case "UPDATE_FILTER":
36988
37007
  case "REMOVE_COLUMNS_ROWS":
36989
37008
  case "HIDE_COLUMNS_ROWS":
36990
37009
  case "UNHIDE_COLUMNS_ROWS":
@@ -39703,7 +39722,7 @@
39703
39722
  });
39704
39723
  for (const filterTable of this.copiedTables) {
39705
39724
  this.dispatch("REMOVE_FILTER_TABLE", {
39706
- sheetId: this.getters.getActiveSheetId(),
39725
+ sheetId: this.sheetId,
39707
39726
  target: [filterTable.zone],
39708
39727
  });
39709
39728
  }
@@ -41193,6 +41212,7 @@
41193
41212
  "isSingleColSelected",
41194
41213
  "getElementsFromSelection",
41195
41214
  "tryGetActiveSheetId",
41215
+ "isGridSelectionActive",
41196
41216
  ];
41197
41217
  gridSelection = {
41198
41218
  anchor: {
@@ -41402,6 +41422,9 @@
41402
41422
  // ---------------------------------------------------------------------------
41403
41423
  // Getters
41404
41424
  // ---------------------------------------------------------------------------
41425
+ isGridSelectionActive() {
41426
+ return this.selection.isListening(this);
41427
+ }
41405
41428
  getActiveSheet() {
41406
41429
  return this.activeSheet;
41407
41430
  }
@@ -45257,6 +45280,9 @@
45257
45280
  anchor: { zone, cell: this.anchor.cell },
45258
45281
  });
45259
45282
  }
45283
+ isListening(owner) {
45284
+ return this.stream.isListening(owner);
45285
+ }
45260
45286
  /**
45261
45287
  * Process a new anchor selection event. If the new anchor is inside
45262
45288
  * the sheet boundaries, the event is pushed to the event stream to
@@ -47719,9 +47745,9 @@
47719
47745
  Object.defineProperty(exports, '__esModule', { value: true });
47720
47746
 
47721
47747
 
47722
- __info__.version = '16.3.11';
47723
- __info__.date = '2023-09-21T15:56:40.754Z';
47724
- __info__.hash = '245df8c';
47748
+ __info__.version = '16.3.13';
47749
+ __info__.date = '2023-10-10T07:28:39.702Z';
47750
+ __info__.hash = '67b6363';
47725
47751
 
47726
47752
 
47727
47753
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);