@odoo/o-spreadsheet 16.3.4 → 16.3.6

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";
@@ -4219,7 +4219,6 @@
4219
4219
  "SET_VIEWPORT_OFFSET",
4220
4220
  "SELECT_SEARCH_NEXT_MATCH",
4221
4221
  "SELECT_SEARCH_PREVIOUS_MATCH",
4222
- "REFRESH_SEARCH",
4223
4222
  "UPDATE_SEARCH",
4224
4223
  "CLEAR_SEARCH",
4225
4224
  "EVALUATE_CELLS",
@@ -5540,7 +5539,7 @@
5540
5539
  }
5541
5540
  }
5542
5541
  &.disabled {
5543
- color: ${MENU_ITEM_DISABLED_COLOR};
5542
+ color: ${DISABLED_TEXT_COLOR};
5544
5543
  cursor: not-allowed;
5545
5544
  }
5546
5545
  }
@@ -16377,7 +16376,7 @@
16377
16376
  };
16378
16377
  const categorieFunctionAll = {
16379
16378
  name: _lt("All"),
16380
- children: allFunctionListMenuBuilder(),
16379
+ children: [allFunctionListMenuBuilder],
16381
16380
  };
16382
16381
  function allFunctionListMenuBuilder() {
16383
16382
  const fnNames = functionRegistry.getKeys();
@@ -19644,6 +19643,7 @@
19644
19643
  state = owl.useState(this.initialState());
19645
19644
  debounceTimeoutId;
19646
19645
  showFormulaState = false;
19646
+ debouncedUpdateSearch;
19647
19647
  findAndReplaceRef = owl.useRef("findAndReplace");
19648
19648
  get hasSearchResult() {
19649
19649
  return this.env.model.getters.getCurrentSelectedMatchIndex() !== null;
@@ -19653,11 +19653,16 @@
19653
19653
  }
19654
19654
  setup() {
19655
19655
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
19656
+ this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
19656
19657
  owl.onMounted(() => this.focusInput());
19657
19658
  owl.onWillUnmount(() => {
19658
19659
  this.env.model.dispatch("CLEAR_SEARCH");
19659
19660
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
19660
19661
  });
19662
+ owl.useEffect(() => {
19663
+ this.state.searchOptions.searchFormulas = this.env.model.getters.shouldShowFormulas();
19664
+ this.searchFormulas();
19665
+ }, () => [this.env.model.getters.shouldShowFormulas()]);
19661
19666
  }
19662
19667
  onInput(ev) {
19663
19668
  this.state.toSearch = ev.target.value;
@@ -19677,10 +19682,6 @@
19677
19682
  this.replace();
19678
19683
  }
19679
19684
  }
19680
- onFocusSidePanel() {
19681
- this.state.searchOptions.searchFormulas = this.env.model.getters.shouldShowFormulas();
19682
- this.env.model.dispatch("REFRESH_SEARCH");
19683
- }
19684
19685
  searchFormulas() {
19685
19686
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", {
19686
19687
  show: this.state.searchOptions.searchFormulas,
@@ -19699,13 +19700,6 @@
19699
19700
  searchOptions: this.state.searchOptions,
19700
19701
  });
19701
19702
  }
19702
- debouncedUpdateSearch() {
19703
- clearTimeout(this.debounceTimeoutId);
19704
- this.debounceTimeoutId = setTimeout(() => {
19705
- this.updateSearch();
19706
- this.debounceTimeoutId = undefined;
19707
- }, 400);
19708
- }
19709
19703
  replace() {
19710
19704
  this.env.model.dispatch("REPLACE_SEARCH", {
19711
19705
  replaceWith: this.state.replaceWith,
@@ -21638,6 +21632,15 @@
21638
21632
  y = initialFigure.y - deltaY;
21639
21633
  }
21640
21634
  }
21635
+ // Restrict resizing if x or y reaches header boundaries
21636
+ if (x < 0) {
21637
+ width += x;
21638
+ x = 0;
21639
+ }
21640
+ if (y < 0) {
21641
+ height += y;
21642
+ y = 0;
21643
+ }
21641
21644
  return { ...initialFigure, x, y, width, height };
21642
21645
  }
21643
21646
 
@@ -30941,7 +30944,8 @@
30941
30944
  }
30942
30945
  break;
30943
30946
  case "UPDATE_CELL":
30944
- if (!this.sizes[cmd.sheetId]?.["ROW"]?.[cmd.row]?.manualSize) {
30947
+ const row = this.sizes[cmd.sheetId]?.["ROW"]?.[cmd.row];
30948
+ if (row && !row.manualSize) {
30945
30949
  const { sheetId, row } = cmd;
30946
30950
  this.history.update("sizes", sheetId, "ROW", row, "computedSize", lazy(() => this.getRowTallestCellSize(sheetId, row)));
30947
30951
  }
@@ -36889,6 +36893,7 @@
36889
36893
  searchFormulas: false,
36890
36894
  };
36891
36895
  toSearch = "";
36896
+ isSearchDirty = false;
36892
36897
  // ---------------------------------------------------------------------------
36893
36898
  // Command Handling
36894
36899
  // ---------------------------------------------------------------------------
@@ -36912,18 +36917,33 @@
36912
36917
  case "REPLACE_ALL_SEARCH":
36913
36918
  this.replaceAll(cmd.replaceWith);
36914
36919
  break;
36920
+ case "EVALUATE_CELLS":
36921
+ case "UPDATE_CELL":
36922
+ case "REMOVE_FILTER_TABLE":
36923
+ case "UPDATE_FILTER":
36924
+ this.isSearchDirty = true;
36925
+ break;
36915
36926
  case "UNDO":
36916
36927
  case "REDO":
36917
36928
  case "REMOVE_COLUMNS_ROWS":
36929
+ case "HIDE_COLUMNS_ROWS":
36930
+ case "UNHIDE_COLUMNS_ROWS":
36918
36931
  case "ADD_COLUMNS_ROWS":
36919
- this.clearSearch();
36932
+ case "EVALUATE_CELLS":
36933
+ case "UPDATE_CELL":
36934
+ this.isSearchDirty = true;
36920
36935
  break;
36921
36936
  case "ACTIVATE_SHEET":
36922
- case "REFRESH_SEARCH":
36923
36937
  this.refreshSearch();
36924
36938
  break;
36925
36939
  }
36926
36940
  }
36941
+ finalize() {
36942
+ if (this.isSearchDirty) {
36943
+ this.refreshSearch();
36944
+ this.isSearchDirty = false;
36945
+ }
36946
+ }
36927
36947
  // ---------------------------------------------------------------------------
36928
36948
  // Getters
36929
36949
  // ---------------------------------------------------------------------------
@@ -36979,6 +36999,11 @@
36979
36999
  if (this.toSearch) {
36980
37000
  for (const cell of Object.values(cells)) {
36981
37001
  const { col, row } = this.getters.getCellPosition(cell.id);
37002
+ const isColHidden = this.getters.isColHidden(sheetId, col);
37003
+ const isRowHidden = this.getters.isRowHidden(sheetId, row);
37004
+ if (isColHidden || isRowHidden) {
37005
+ continue;
37006
+ }
36982
37007
  if (cell &&
36983
37008
  this.currentSearchRegex &&
36984
37009
  this.currentSearchRegex.test(this.getSearchableString({ sheetId, col, row }))) {
@@ -37038,37 +37063,31 @@
37038
37063
  // ---------------------------------------------------------------------------
37039
37064
  // Replace
37040
37065
  // ---------------------------------------------------------------------------
37041
- /**
37042
- * Replace the value of the currently selected match
37043
- */
37044
- replace(replaceWith) {
37045
- if (this.selectedMatchIndex === null || !this.currentSearchRegex) {
37066
+ replaceMatch(selectedMatch, replaceWith) {
37067
+ if (!this.currentSearchRegex) {
37046
37068
  return;
37047
37069
  }
37048
- const matches = this.searchMatches;
37049
- const selectedMatch = matches[this.selectedMatchIndex];
37050
37070
  const sheetId = this.getters.getActiveSheetId();
37051
37071
  const cell = this.getters.getCell({ sheetId, ...selectedMatch });
37072
+ const { col, row } = selectedMatch;
37052
37073
  if (cell?.isFormula && !this.searchOptions.searchFormulas) {
37053
- this.selectNextCell(Direction.next);
37074
+ return;
37054
37075
  }
37055
- else {
37056
- const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
37057
- const toReplace = this.getSearchableString({
37058
- sheetId,
37059
- col: selectedMatch.col,
37060
- row: selectedMatch.row,
37061
- });
37062
- const newContent = toReplace.replace(replaceRegex, replaceWith);
37063
- this.dispatch("UPDATE_CELL", {
37064
- sheetId: this.getters.getActiveSheetId(),
37065
- col: selectedMatch.col,
37066
- row: selectedMatch.row,
37067
- content: newContent,
37068
- });
37069
- this.searchMatches.splice(this.selectedMatchIndex, 1);
37070
- this.selectNextCell(Direction.current);
37076
+ const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
37077
+ const toReplace = this.getSearchableString({ sheetId, col, row });
37078
+ const content = toReplace.replace(replaceRegex, replaceWith);
37079
+ this.dispatch("UPDATE_CELL", { sheetId, col, row, content });
37080
+ }
37081
+ /**
37082
+ * Replace the value of the currently selected match
37083
+ */
37084
+ replace(replaceWith) {
37085
+ if (this.selectedMatchIndex === null) {
37086
+ return;
37071
37087
  }
37088
+ const selectedMatch = this.searchMatches[this.selectedMatchIndex];
37089
+ this.replaceMatch(selectedMatch, replaceWith);
37090
+ this.selectNextCell(Direction.next);
37072
37091
  }
37073
37092
  /**
37074
37093
  * Apply the replace function to all the matches one time.
@@ -37076,7 +37095,7 @@
37076
37095
  replaceAll(replaceWith) {
37077
37096
  const matchCount = this.searchMatches.length;
37078
37097
  for (let i = 0; i < matchCount; i++) {
37079
- this.replace(replaceWith);
37098
+ this.replaceMatch(this.searchMatches[i], replaceWith);
37080
37099
  }
37081
37100
  }
37082
37101
  getSearchableString(position) {
@@ -38616,10 +38635,8 @@
38616
38635
  }
38617
38636
  updateCellCommands.push(newCellValues);
38618
38637
  }
38619
- for (const cmd of updateCellCommands) {
38620
- this.dispatch("UPDATE_CELL", cmd);
38621
- }
38622
38638
  }
38639
+ updateCellCommands.forEach((cmdPayload) => this.dispatch("UPDATE_CELL", cmdPayload));
38623
38640
  }
38624
38641
  /**
38625
38642
  * Return the distances between main merge cells in the zone.
@@ -42884,6 +42901,11 @@
42884
42901
  .o-sidePanelButton:enabled {
42885
42902
  cursor: pointer;
42886
42903
  }
42904
+
42905
+ .o-sidePanelButton:disabled {
42906
+ color: ${DISABLED_TEXT_COLOR};
42907
+ }
42908
+
42887
42909
  .o-sidePanelButton:last-child {
42888
42910
  margin-right: 0px;
42889
42911
  }
@@ -47632,9 +47654,9 @@
47632
47654
  Object.defineProperty(exports, '__esModule', { value: true });
47633
47655
 
47634
47656
 
47635
- __info__.version = '16.3.4';
47636
- __info__.date = '2023-06-26T14:34:27.019Z';
47637
- __info__.hash = '94f9dcd';
47657
+ __info__.version = '16.3.6';
47658
+ __info__.date = '2023-08-07T09:00:44.937Z';
47659
+ __info__.hash = '36bb0b8';
47638
47660
 
47639
47661
 
47640
47662
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);