@odoo/o-spreadsheet 16.4.0 → 16.4.2

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.
@@ -109,8 +109,8 @@
109
109
  const HEADER_BORDER_COLOR = "#C0C0C0";
110
110
  const CELL_BORDER_COLOR = "#E2E3E3";
111
111
  const BACKGROUND_CHART_COLOR = "#FFFFFF";
112
- const MENU_ITEM_DISABLED_COLOR = "#CACACA";
113
112
  const BG_HOVER_COLOR = "#EBEBEB";
113
+ const DISABLED_TEXT_COLOR = "#CACACA";
114
114
  const DEFAULT_COLOR_SCALE_MIDPOINT_COLOR = 0xb6d7a8;
115
115
  const LINK_COLOR = "#01666b";
116
116
  const FILTERS_COLOR = "#188038";
@@ -4052,7 +4052,6 @@
4052
4052
  "SET_VIEWPORT_OFFSET",
4053
4053
  "SELECT_SEARCH_NEXT_MATCH",
4054
4054
  "SELECT_SEARCH_PREVIOUS_MATCH",
4055
- "REFRESH_SEARCH",
4056
4055
  "UPDATE_SEARCH",
4057
4056
  "CLEAR_SEARCH",
4058
4057
  "EVALUATE_CELLS",
@@ -5991,7 +5990,7 @@
5991
5990
  }
5992
5991
  }
5993
5992
  &.disabled {
5994
- color: ${MENU_ITEM_DISABLED_COLOR};
5993
+ color: ${DISABLED_TEXT_COLOR};
5995
5994
  cursor: not-allowed;
5996
5995
  }
5997
5996
  }
@@ -22691,6 +22690,7 @@
22691
22690
  state = owl.useState(this.initialState());
22692
22691
  debounceTimeoutId;
22693
22692
  showFormulaState = false;
22693
+ debouncedUpdateSearch;
22694
22694
  findAndReplaceRef = owl.useRef("findAndReplace");
22695
22695
  get hasSearchResult() {
22696
22696
  return this.env.model.getters.getCurrentSelectedMatchIndex() !== null;
@@ -22700,11 +22700,16 @@
22700
22700
  }
22701
22701
  setup() {
22702
22702
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
22703
+ this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
22703
22704
  owl.onMounted(() => this.focusInput());
22704
22705
  owl.onWillUnmount(() => {
22705
22706
  this.env.model.dispatch("CLEAR_SEARCH");
22706
22707
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
22707
22708
  });
22709
+ owl.useEffect(() => {
22710
+ this.state.searchOptions.searchFormulas = this.env.model.getters.shouldShowFormulas();
22711
+ this.searchFormulas();
22712
+ }, () => [this.env.model.getters.shouldShowFormulas()]);
22708
22713
  }
22709
22714
  onInput(ev) {
22710
22715
  this.state.toSearch = ev.target.value;
@@ -22724,10 +22729,6 @@
22724
22729
  this.replace();
22725
22730
  }
22726
22731
  }
22727
- onFocusSidePanel() {
22728
- this.state.searchOptions.searchFormulas = this.env.model.getters.shouldShowFormulas();
22729
- this.env.model.dispatch("REFRESH_SEARCH");
22730
- }
22731
22732
  searchFormulas() {
22732
22733
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", {
22733
22734
  show: this.state.searchOptions.searchFormulas,
@@ -22746,13 +22747,6 @@
22746
22747
  searchOptions: this.state.searchOptions,
22747
22748
  });
22748
22749
  }
22749
- debouncedUpdateSearch() {
22750
- clearTimeout(this.debounceTimeoutId);
22751
- this.debounceTimeoutId = setTimeout(() => {
22752
- this.updateSearch();
22753
- this.debounceTimeoutId = undefined;
22754
- }, 400);
22755
- }
22756
22750
  replace() {
22757
22751
  this.env.model.dispatch("REPLACE_SEARCH", {
22758
22752
  replaceWith: this.state.replaceWith,
@@ -24692,6 +24686,15 @@
24692
24686
  y = initialFigure.y - deltaY;
24693
24687
  }
24694
24688
  }
24689
+ // Restrict resizing if x or y reaches header boundaries
24690
+ if (x < 0) {
24691
+ width += x;
24692
+ x = 0;
24693
+ }
24694
+ if (y < 0) {
24695
+ height += y;
24696
+ y = 0;
24697
+ }
24695
24698
  return { ...initialFigure, x, y, width, height };
24696
24699
  }
24697
24700
 
@@ -38531,6 +38534,7 @@
38531
38534
  searchFormulas: false,
38532
38535
  };
38533
38536
  toSearch = "";
38537
+ isSearchDirty = false;
38534
38538
  // ---------------------------------------------------------------------------
38535
38539
  // Command Handling
38536
38540
  // ---------------------------------------------------------------------------
@@ -38554,18 +38558,33 @@
38554
38558
  case "REPLACE_ALL_SEARCH":
38555
38559
  this.replaceAll(cmd.replaceWith);
38556
38560
  break;
38561
+ case "EVALUATE_CELLS":
38562
+ case "UPDATE_CELL":
38563
+ case "REMOVE_FILTER_TABLE":
38564
+ case "UPDATE_FILTER":
38565
+ this.isSearchDirty = true;
38566
+ break;
38557
38567
  case "UNDO":
38558
38568
  case "REDO":
38559
38569
  case "REMOVE_COLUMNS_ROWS":
38570
+ case "HIDE_COLUMNS_ROWS":
38571
+ case "UNHIDE_COLUMNS_ROWS":
38560
38572
  case "ADD_COLUMNS_ROWS":
38561
- this.clearSearch();
38573
+ case "EVALUATE_CELLS":
38574
+ case "UPDATE_CELL":
38575
+ this.isSearchDirty = true;
38562
38576
  break;
38563
38577
  case "ACTIVATE_SHEET":
38564
- case "REFRESH_SEARCH":
38565
38578
  this.refreshSearch();
38566
38579
  break;
38567
38580
  }
38568
38581
  }
38582
+ finalize() {
38583
+ if (this.isSearchDirty) {
38584
+ this.refreshSearch();
38585
+ this.isSearchDirty = false;
38586
+ }
38587
+ }
38569
38588
  // ---------------------------------------------------------------------------
38570
38589
  // Getters
38571
38590
  // ---------------------------------------------------------------------------
@@ -38621,6 +38640,11 @@
38621
38640
  if (this.toSearch) {
38622
38641
  for (const cell of Object.values(cells)) {
38623
38642
  const { col, row } = this.getters.getCellPosition(cell.id);
38643
+ const isColHidden = this.getters.isColHidden(sheetId, col);
38644
+ const isRowHidden = this.getters.isRowHidden(sheetId, row);
38645
+ if (isColHidden || isRowHidden) {
38646
+ continue;
38647
+ }
38624
38648
  if (cell &&
38625
38649
  this.currentSearchRegex &&
38626
38650
  this.currentSearchRegex.test(this.getSearchableString({ sheetId, col, row }))) {
@@ -38680,37 +38704,32 @@
38680
38704
  // ---------------------------------------------------------------------------
38681
38705
  // Replace
38682
38706
  // ---------------------------------------------------------------------------
38683
- /**
38684
- * Replace the value of the currently selected match
38685
- */
38686
- replace(replaceWith) {
38687
- if (this.selectedMatchIndex === null || !this.currentSearchRegex) {
38707
+ replaceMatch(selectedMatch, replaceWith) {
38708
+ if (!this.currentSearchRegex) {
38688
38709
  return;
38689
38710
  }
38690
- const matches = this.searchMatches;
38691
- const selectedMatch = matches[this.selectedMatchIndex];
38692
38711
  const sheetId = this.getters.getActiveSheetId();
38693
38712
  const cell = this.getters.getCell({ sheetId, ...selectedMatch });
38713
+ const { col, row } = selectedMatch;
38694
38714
  if (cell?.isFormula && !this.searchOptions.searchFormulas) {
38695
- this.selectNextCell(Direction.next);
38715
+ return;
38696
38716
  }
38697
- else {
38698
- const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
38699
- const toReplace = this.getSearchableString({
38700
- sheetId,
38701
- col: selectedMatch.col,
38702
- row: selectedMatch.row,
38703
- });
38704
- const newContent = toReplace.replace(replaceRegex, replaceWith);
38705
- this.dispatch("UPDATE_CELL", {
38706
- sheetId: this.getters.getActiveSheetId(),
38707
- col: selectedMatch.col,
38708
- row: selectedMatch.row,
38709
- content: canonicalizeContent(newContent, this.getters.getLocale()),
38710
- });
38711
- this.searchMatches.splice(this.selectedMatchIndex, 1);
38712
- this.selectNextCell(Direction.current);
38717
+ const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
38718
+ const toReplace = this.getSearchableString({ sheetId, col, row });
38719
+ const content = toReplace.replace(replaceRegex, replaceWith);
38720
+ const canonicalContent = canonicalizeContent(content, this.getters.getLocale());
38721
+ this.dispatch("UPDATE_CELL", { sheetId, col, row, content: canonicalContent });
38722
+ }
38723
+ /**
38724
+ * Replace the value of the currently selected match
38725
+ */
38726
+ replace(replaceWith) {
38727
+ if (this.selectedMatchIndex === null) {
38728
+ return;
38713
38729
  }
38730
+ const selectedMatch = this.searchMatches[this.selectedMatchIndex];
38731
+ this.replaceMatch(selectedMatch, replaceWith);
38732
+ this.selectNextCell(Direction.next);
38714
38733
  }
38715
38734
  /**
38716
38735
  * Apply the replace function to all the matches one time.
@@ -38718,7 +38737,7 @@
38718
38737
  replaceAll(replaceWith) {
38719
38738
  const matchCount = this.searchMatches.length;
38720
38739
  for (let i = 0; i < matchCount; i++) {
38721
- this.replace(replaceWith);
38740
+ this.replaceMatch(this.searchMatches[i], replaceWith);
38722
38741
  }
38723
38742
  }
38724
38743
  getSearchableString(position) {
@@ -45721,6 +45740,11 @@
45721
45740
  .o-sidePanelButton:enabled {
45722
45741
  cursor: pointer;
45723
45742
  }
45743
+
45744
+ .o-sidePanelButton:disabled {
45745
+ color: ${DISABLED_TEXT_COLOR};
45746
+ }
45747
+
45724
45748
  .o-sidePanelButton:last-child {
45725
45749
  margin-right: 0px;
45726
45750
  }
@@ -50515,9 +50539,9 @@
50515
50539
  Object.defineProperty(exports, '__esModule', { value: true });
50516
50540
 
50517
50541
 
50518
- __info__.version = '16.4.0';
50519
- __info__.date = '2023-07-24T06:26:19.494Z';
50520
- __info__.hash = '4eb614c';
50542
+ __info__.version = '16.4.2';
50543
+ __info__.date = '2023-08-07T12:49:47.066Z';
50544
+ __info__.hash = 'd5697c0';
50521
50545
 
50522
50546
 
50523
50547
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);