@odoo/o-spreadsheet 16.0.13 → 16.0.15

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,7 +109,7 @@ const SELECTION_BORDER_COLOR = "#3266ca";
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";
112
+ const DISABLED_TEXT_COLOR = "#CACACA";
113
113
  const DEFAULT_COLOR_SCALE_MIDPOINT_COLOR = 0xb6d7a8;
114
114
  const LINK_COLOR = "#01666b";
115
115
  const FILTERS_COLOR = "#188038";
@@ -723,12 +723,20 @@ function getDefaultCellHeight(style, numberOfLines) {
723
723
  2 * PADDING_AUTORESIZE_VERTICAL);
724
724
  }
725
725
  function computeTextWidth(context, text, style) {
726
- context.save();
727
- context.font = computeTextFont(style);
728
- const textWidth = context.measureText(text).width;
729
- context.restore();
730
- return textWidth;
726
+ const font = computeTextFont(style);
727
+ if (!textWidthCache[font]) {
728
+ textWidthCache[font] = {};
729
+ }
730
+ if (textWidthCache[font][text] === undefined) {
731
+ context.save();
732
+ context.font = font;
733
+ const textWidth = context.measureText(text).width;
734
+ context.restore();
735
+ textWidthCache[font][text] = textWidth;
736
+ }
737
+ return textWidthCache[font][text];
731
738
  }
739
+ const textWidthCache = {};
732
740
  function computeTextFont(style) {
733
741
  const italic = style.italic ? "italic " : "";
734
742
  const weight = style.bold ? "bold" : DEFAULT_FONT_WEIGHT;
@@ -3099,7 +3107,6 @@ const readonlyAllowedCommands = new Set([
3099
3107
  "SET_VIEWPORT_OFFSET",
3100
3108
  "SELECT_SEARCH_NEXT_MATCH",
3101
3109
  "SELECT_SEARCH_PREVIOUS_MATCH",
3102
- "REFRESH_SEARCH",
3103
3110
  "UPDATE_SEARCH",
3104
3111
  "CLEAR_SEARCH",
3105
3112
  "EVALUATE_CELLS",
@@ -4026,7 +4033,7 @@ css /* scss */ `
4026
4033
  }
4027
4034
  }
4028
4035
  &.disabled {
4029
- color: ${MENU_ITEM_DISABLED_COLOR};
4036
+ color: ${DISABLED_TEXT_COLOR};
4030
4037
  cursor: not-allowed;
4031
4038
  }
4032
4039
  }
@@ -9980,11 +9987,16 @@ class FindAndReplacePanel extends owl.Component {
9980
9987
  }
9981
9988
  setup() {
9982
9989
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
9990
+ this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
9983
9991
  owl.onMounted(() => this.focusInput());
9984
9992
  owl.onWillUnmount(() => {
9985
9993
  this.env.model.dispatch("CLEAR_SEARCH");
9986
9994
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
9987
9995
  });
9996
+ owl.useEffect(() => {
9997
+ this.state.searchOptions.searchFormulas = this.env.model.getters.shouldShowFormulas();
9998
+ this.searchFormulas();
9999
+ }, () => [this.env.model.getters.shouldShowFormulas()]);
9988
10000
  }
9989
10001
  onInput(ev) {
9990
10002
  this.state.toSearch = ev.target.value;
@@ -10002,10 +10014,6 @@ class FindAndReplacePanel extends owl.Component {
10002
10014
  this.replace();
10003
10015
  }
10004
10016
  }
10005
- onFocusSidePanel() {
10006
- this.state.searchOptions.searchFormulas = this.env.model.getters.shouldShowFormulas();
10007
- this.env.model.dispatch("REFRESH_SEARCH");
10008
- }
10009
10017
  searchFormulas() {
10010
10018
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", {
10011
10019
  show: this.state.searchOptions.searchFormulas,
@@ -10024,10 +10032,6 @@ class FindAndReplacePanel extends owl.Component {
10024
10032
  searchOptions: this.state.searchOptions,
10025
10033
  });
10026
10034
  }
10027
- debouncedUpdateSearch() {
10028
- clearTimeout(this.inDebounce);
10029
- this.inDebounce = setTimeout(() => this.updateSearch.call(this), 400);
10030
- }
10031
10035
  replace() {
10032
10036
  this.env.model.dispatch("REPLACE_SEARCH", {
10033
10037
  replaceWith: this.state.replaceWith,
@@ -21155,6 +21159,14 @@ class FiguresContainer extends owl.Component {
21155
21159
  if (dirY < 0) {
21156
21160
  this.dnd.y = dndInitialY - deltaY;
21157
21161
  }
21162
+ if (this.dnd.x < 0) {
21163
+ this.dnd.width += this.dnd.x;
21164
+ this.dnd.x = 0;
21165
+ }
21166
+ if (this.dnd.y < 0) {
21167
+ this.dnd.height += this.dnd.y;
21168
+ this.dnd.y = 0;
21169
+ }
21158
21170
  };
21159
21171
  const onMouseUp = (ev) => {
21160
21172
  if (!this.dnd.figId) {
@@ -28647,7 +28659,14 @@ class FiltersPlugin extends CorePlugin {
28647
28659
  this.history.update("tables", filterTables);
28648
28660
  break;
28649
28661
  case "DUPLICATE_SHEET":
28650
- this.history.update("tables", cmd.sheetIdTo, deepCopy(this.tables[cmd.sheetId]));
28662
+ const tables = {};
28663
+ for (const filterTable of Object.values(this.tables[cmd.sheetId] || {})) {
28664
+ if (filterTable) {
28665
+ const newFilterTable = deepCopy(filterTable);
28666
+ tables[newFilterTable.id] = newFilterTable;
28667
+ }
28668
+ }
28669
+ this.history.update("tables", cmd.sheetIdTo, tables);
28651
28670
  break;
28652
28671
  case "ADD_COLUMNS_ROWS":
28653
28672
  this.onAddColumnsRows(cmd);
@@ -33279,6 +33298,7 @@ class FindAndReplacePlugin extends UIPlugin {
33279
33298
  searchFormulas: false,
33280
33299
  };
33281
33300
  this.toSearch = "";
33301
+ this.isSearchDirty = false;
33282
33302
  }
33283
33303
  // ---------------------------------------------------------------------------
33284
33304
  // Command Handling
@@ -33303,18 +33323,25 @@ class FindAndReplacePlugin extends UIPlugin {
33303
33323
  case "REPLACE_ALL_SEARCH":
33304
33324
  this.replaceAll(cmd.replaceWith);
33305
33325
  break;
33326
+ case "EVALUATE_CELLS":
33327
+ case "UPDATE_CELL":
33328
+ this.isSearchDirty = true;
33329
+ break;
33306
33330
  case "UNDO":
33307
33331
  case "REDO":
33308
33332
  case "REMOVE_COLUMNS_ROWS":
33309
33333
  case "ADD_COLUMNS_ROWS":
33310
- this.clearSearch();
33311
- break;
33312
33334
  case "ACTIVATE_SHEET":
33313
- case "REFRESH_SEARCH":
33314
33335
  this.refreshSearch();
33315
33336
  break;
33316
33337
  }
33317
33338
  }
33339
+ finalize() {
33340
+ if (this.isSearchDirty) {
33341
+ this.refreshSearch();
33342
+ this.isSearchDirty = false;
33343
+ }
33344
+ }
33318
33345
  // ---------------------------------------------------------------------------
33319
33346
  // Getters
33320
33347
  // ---------------------------------------------------------------------------
@@ -33364,11 +33391,17 @@ class FindAndReplacePlugin extends UIPlugin {
33364
33391
  * Find matches using the current regex
33365
33392
  */
33366
33393
  findMatches() {
33367
- const activeSheetId = this.getters.getActiveSheetId();
33368
- const cells = this.getters.getCells(activeSheetId);
33394
+ const sheetId = this.getters.getActiveSheetId();
33395
+ const cells = this.getters.getCells(sheetId);
33369
33396
  const matches = [];
33370
33397
  if (this.toSearch) {
33371
33398
  for (const cell of Object.values(cells)) {
33399
+ const { col, row } = this.getters.getCellPosition(cell.id);
33400
+ const isColHidden = this.getters.isColHidden(sheetId, col);
33401
+ const isRowHidden = this.getters.isRowHidden(sheetId, row);
33402
+ if (isColHidden || isRowHidden) {
33403
+ continue;
33404
+ }
33372
33405
  if (cell &&
33373
33406
  this.currentSearchRegex &&
33374
33407
  this.currentSearchRegex.test(this.searchOptions.searchFormulas
@@ -35151,6 +35184,9 @@ SelectionInputPlugin.getters = [];
35151
35184
  * This plugin handles this internal state.
35152
35185
  */
35153
35186
  class SelectionInputsManagerPlugin extends UIPlugin {
35187
+ get currentInput() {
35188
+ return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
35189
+ }
35154
35190
  constructor(getters, state, dispatch, config, selection) {
35155
35191
  super(getters, state, dispatch, config, selection);
35156
35192
  this.state = state;
@@ -35158,9 +35194,6 @@ class SelectionInputsManagerPlugin extends UIPlugin {
35158
35194
  this.inputs = {};
35159
35195
  this.focusedInputId = null;
35160
35196
  }
35161
- get currentInput() {
35162
- return this.focusedInputId ? this.inputs[this.focusedInputId] : null;
35163
- }
35164
35197
  // ---------------------------------------------------------------------------
35165
35198
  // Command Handling
35166
35199
  // ---------------------------------------------------------------------------
@@ -37256,6 +37289,7 @@ class SortPlugin extends UIPlugin {
37256
37289
  const sortedIndexOfSortTypeCells = sortCells(sortingCells, sortDirection, Boolean(options.emptyCellAsZero));
37257
37290
  const sortedIndex = sortedIndexOfSortTypeCells.map((x) => x.index);
37258
37291
  const [width, height] = [cells.length, cells[0].length];
37292
+ const cellUpdates = [];
37259
37293
  for (let c = 0; c < width; c++) {
37260
37294
  for (let r = 0; r < height; r++) {
37261
37295
  let cell = cells[c][sortedIndex[r]];
@@ -37266,7 +37300,6 @@ class SortPlugin extends UIPlugin {
37266
37300
  col: newCol,
37267
37301
  row: newRow,
37268
37302
  content: "",
37269
- value: "",
37270
37303
  };
37271
37304
  if (cell) {
37272
37305
  let content = cell.content;
@@ -37280,11 +37313,11 @@ class SortPlugin extends UIPlugin {
37280
37313
  newCellValues.style = cell.style;
37281
37314
  newCellValues.content = content;
37282
37315
  newCellValues.format = cell.format;
37283
- newCellValues.value = cell.evaluated.value;
37284
37316
  }
37285
- this.dispatch("UPDATE_CELL", newCellValues);
37317
+ cellUpdates.push(newCellValues);
37286
37318
  }
37287
37319
  }
37320
+ cellUpdates.forEach((cmdPayload) => this.dispatch("UPDATE_CELL", cmdPayload));
37288
37321
  }
37289
37322
  /**
37290
37323
  * Return the distances between main merge cells in the zone.
@@ -38046,6 +38079,11 @@ css /* scss */ `
38046
38079
  .o-sidePanelButton:enabled {
38047
38080
  cursor: pointer;
38048
38081
  }
38082
+
38083
+ .o-sidePanelButton:disabled {
38084
+ color: ${DISABLED_TEXT_COLOR};
38085
+ }
38086
+
38049
38087
  .o-sidePanelButton:last-child {
38050
38088
  margin-right: 0px;
38051
38089
  }
@@ -42817,6 +42855,6 @@ exports.setTranslationMethod = setTranslationMethod;
42817
42855
  exports.tokenize = tokenize;
42818
42856
 
42819
42857
 
42820
- __info__.version = '16.0.13';
42821
- __info__.date = '2023-06-12T13:44:11.940Z';
42822
- __info__.hash = '3c9ec1e';
42858
+ __info__.version = '16.0.15';
42859
+ __info__.date = '2023-07-26T12:11:24.020Z';
42860
+ __info__.hash = '18da14b';