@odoo/o-spreadsheet 17.4.26 → 17.4.28

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.4.26
6
- * @date 2025-03-12T15:31:45.184Z
7
- * @hash a18429e
5
+ * @version 17.4.28
6
+ * @date 2025-03-26T12:48:33.387Z
7
+ * @hash a81a8f4
8
8
  */
9
9
 
10
10
  'use strict';
@@ -1009,7 +1009,10 @@ function rgbaStringToHex(color) {
1009
1009
  }
1010
1010
  else if (stringVals.length === 4) {
1011
1011
  const alpha = parseFloat(stringVals.pop() || "1");
1012
- alphaHex = Math.round((alpha || 1) * 255);
1012
+ if (isNaN(alpha)) {
1013
+ throw new Error("invalid alpha value");
1014
+ }
1015
+ alphaHex = Math.round(alpha * 255);
1013
1016
  }
1014
1017
  const vals = stringVals.map((val) => parseInt(val, 10));
1015
1018
  if (alphaHex !== 255) {
@@ -5199,11 +5202,13 @@ function getDefaultCellHeight(ctx, cell, colSize) {
5199
5202
  if (!cell || (!cell.isFormula && !cell.content)) {
5200
5203
  return DEFAULT_CELL_HEIGHT;
5201
5204
  }
5202
- const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5203
- const numberOfLines = cell.isFormula
5204
- ? 1
5205
- : splitTextToWidth(ctx, cell.content, cell.style, maxWidth).length;
5206
- const fontSize = computeTextFontSizeInPixels(cell.style);
5205
+ const content = cell.isFormula ? "" : cell.content;
5206
+ return getCellContentHeight(ctx, content, cell.style, colSize);
5207
+ }
5208
+ function getCellContentHeight(ctx, content, style, colSize) {
5209
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5210
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
5211
+ const fontSize = computeTextFontSizeInPixels(style);
5207
5212
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
5208
5213
  }
5209
5214
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -5963,7 +5968,7 @@ function isValidLocale(locale) {
5963
5968
  */
5964
5969
  function canonicalizeNumberContent(content, locale) {
5965
5970
  return content.startsWith("=")
5966
- ? canonicalizeFormula$1(content, locale)
5971
+ ? canonicalizeFormula(content, locale)
5967
5972
  : canonicalizeNumberLiteral(content, locale);
5968
5973
  }
5969
5974
  /**
@@ -5978,7 +5983,7 @@ function canonicalizeNumberContent(content, locale) {
5978
5983
  */
5979
5984
  function canonicalizeContent(content, locale) {
5980
5985
  return content.startsWith("=")
5981
- ? canonicalizeFormula$1(content, locale)
5986
+ ? canonicalizeFormula(content, locale)
5982
5987
  : canonicalizeLiteral(content, locale);
5983
5988
  }
5984
5989
  /**
@@ -5994,15 +5999,21 @@ function localizeContent(content, locale) {
5994
5999
  ? localizeFormula(content, locale)
5995
6000
  : localizeLiteral(content, locale);
5996
6001
  }
6002
+ /** Change a number string to its canonical form (en_US locale) */
6003
+ function canonicalizeNumberValue(content, locale) {
6004
+ return content.startsWith("=")
6005
+ ? canonicalizeFormula(content, locale)
6006
+ : canonicalizeNumberLiteral(content, locale);
6007
+ }
5997
6008
  /** Change a formula to its canonical form (en_US locale) */
5998
- function canonicalizeFormula$1(formula, locale) {
5999
- return _localizeFormula$1(formula, locale, DEFAULT_LOCALE);
6009
+ function canonicalizeFormula(formula, locale) {
6010
+ return _localizeFormula(formula, locale, DEFAULT_LOCALE);
6000
6011
  }
6001
6012
  /** Change a formula from the canonical form to the given locale */
6002
6013
  function localizeFormula(formula, locale) {
6003
- return _localizeFormula$1(formula, DEFAULT_LOCALE, locale);
6014
+ return _localizeFormula(formula, DEFAULT_LOCALE, locale);
6004
6015
  }
6005
- function _localizeFormula$1(formula, fromLocale, toLocale) {
6016
+ function _localizeFormula(formula, fromLocale, toLocale) {
6006
6017
  if (fromLocale.formulaArgSeparator === toLocale.formulaArgSeparator &&
6007
6018
  fromLocale.decimalSeparator === toLocale.decimalSeparator) {
6008
6019
  return formula;
@@ -6157,37 +6168,6 @@ function getDateTimeFormat(locale) {
6157
6168
  return locale.dateFormat + " " + locale.timeFormat;
6158
6169
  }
6159
6170
 
6160
- /** Change a number string to its canonical form (en_US locale) */
6161
- function canonicalizeNumberValue(content, locale) {
6162
- return content.startsWith("=")
6163
- ? canonicalizeFormula(content, locale)
6164
- : canonicalizeNumberLiteral(content, locale);
6165
- }
6166
- /** Change a formula to its canonical form (en_US locale) */
6167
- function canonicalizeFormula(formula, locale) {
6168
- return _localizeFormula(formula, locale, DEFAULT_LOCALE);
6169
- }
6170
- function _localizeFormula(formula, fromLocale, toLocale) {
6171
- if (fromLocale.formulaArgSeparator === toLocale.formulaArgSeparator &&
6172
- fromLocale.decimalSeparator === toLocale.decimalSeparator) {
6173
- return formula;
6174
- }
6175
- const tokens = tokenize(formula, fromLocale);
6176
- let localizedFormula = "";
6177
- for (const token of tokens) {
6178
- if (token.type === "NUMBER") {
6179
- localizedFormula += token.value.replace(fromLocale.decimalSeparator, toLocale.decimalSeparator);
6180
- }
6181
- else if (token.type === "ARG_SEPARATOR") {
6182
- localizedFormula += toLocale.formulaArgSeparator;
6183
- }
6184
- else {
6185
- localizedFormula += token.value;
6186
- }
6187
- }
6188
- return localizedFormula;
6189
- }
6190
-
6191
6171
  function boolAnd(args) {
6192
6172
  let foundBoolean = false;
6193
6173
  let acc = true;
@@ -6789,13 +6769,6 @@ class CellClipboardHandler extends AbstractCellClipboardHandler {
6789
6769
  this.clearClippedZones(content);
6790
6770
  const selection = target[0];
6791
6771
  this.pasteZone(sheetId, selection.left, selection.top, content.cells, options);
6792
- this.dispatch("MOVE_RANGES", {
6793
- target: content.zones,
6794
- sheetId: content.sheetId,
6795
- targetSheetId: sheetId,
6796
- col: selection.left,
6797
- row: selection.top,
6798
- });
6799
6772
  }
6800
6773
  /**
6801
6774
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -7256,14 +7229,15 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
7256
7229
  }
7257
7230
  merges.push(mergesInRow);
7258
7231
  }
7259
- return { merges };
7232
+ return { merges, sheetId };
7260
7233
  }
7261
7234
  /**
7262
7235
  * Paste the clipboard content in the given target
7263
7236
  */
7264
7237
  paste(target, content, options) {
7265
7238
  if (options.isCutOperation) {
7266
- return;
7239
+ const copiedMerges = content.merges.flat().filter(isDefined);
7240
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
7267
7241
  }
7268
7242
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
7269
7243
  }
@@ -7298,6 +7272,27 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
7298
7272
  }
7299
7273
  }
7300
7274
 
7275
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
7276
+ copy(data) {
7277
+ return {
7278
+ zones: data.clippedZones,
7279
+ sheetId: data.sheetId,
7280
+ };
7281
+ }
7282
+ paste(target, content, options) {
7283
+ if (options.isCutOperation) {
7284
+ const selection = target.zones[0];
7285
+ this.dispatch("MOVE_RANGES", {
7286
+ target: content.zones,
7287
+ sheetId: content.sheetId,
7288
+ targetSheetId: target.sheetId,
7289
+ col: selection.left,
7290
+ row: selection.top,
7291
+ });
7292
+ }
7293
+ }
7294
+ }
7295
+
7301
7296
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
7302
7297
  isPasteAllowed(sheetId, target, content, options) {
7303
7298
  if (!("cells" in content)) {
@@ -7465,7 +7460,8 @@ clipboardHandlersRegistries.cellHandlers
7465
7460
  .add("merge", MergeClipboardHandler)
7466
7461
  .add("border", BorderClipboardHandler)
7467
7462
  .add("table", TableClipboardHandler)
7468
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
7463
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
7464
+ .add("references", ReferenceClipboardHandler);
7469
7465
 
7470
7466
  function transformZone(zone, executed) {
7471
7467
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -9622,8 +9618,8 @@ class ComposerStore extends SpreadsheetStore {
9622
9618
  this.colorIndexByRange = {};
9623
9619
  }
9624
9620
  cancelEdition() {
9625
- this.cancelEditionAndActivateSheet();
9626
9621
  this.resetContent();
9622
+ this.cancelEditionAndActivateSheet();
9627
9623
  this.colorIndexByRange = {};
9628
9624
  }
9629
9625
  setCurrentContent(content, selection) {
@@ -9640,8 +9636,8 @@ class ComposerStore extends SpreadsheetStore {
9640
9636
  switch (cmd.type) {
9641
9637
  case "SELECT_FIGURE":
9642
9638
  if (cmd.id) {
9643
- this.cancelEditionAndActivateSheet();
9644
9639
  this.resetContent();
9640
+ this.cancelEditionAndActivateSheet();
9645
9641
  }
9646
9642
  break;
9647
9643
  case "SET_FORMATTING":
@@ -9691,8 +9687,8 @@ class ComposerStore extends SpreadsheetStore {
9691
9687
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
9692
9688
  if (!sheetIdExists && this.editionMode !== "inactive") {
9693
9689
  this.sheetId = this.getters.getActiveSheetId();
9694
- this.cancelEditionAndActivateSheet();
9695
9690
  this.resetContent();
9691
+ this.cancelEditionAndActivateSheet();
9696
9692
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
9697
9693
  }
9698
9694
  break;
@@ -12008,7 +12004,8 @@ function getChartLabelValues(getters, dataSets, labelRange) {
12008
12004
  }
12009
12005
  }
12010
12006
  else if (dataSets.length === 1) {
12011
- for (let i = 0; i < getData(getters, dataSets[0]).length; i++) {
12007
+ const dataLength = getData(getters, dataSets[0]).length;
12008
+ for (let i = 0; i < dataLength; i++) {
12012
12009
  labels.formattedValues.push("");
12013
12010
  labels.values.push("");
12014
12011
  }
@@ -37676,6 +37673,7 @@ class RemoveDuplicatesPanel extends owl.Component {
37676
37673
  columns: {},
37677
37674
  });
37678
37675
  setup() {
37676
+ this.updateColumns();
37679
37677
  owl.onWillUpdateProps(() => this.updateColumns());
37680
37678
  }
37681
37679
  toggleHasHeader() {
@@ -43162,9 +43160,9 @@ const XLSX_CHART_TYPES = [
43162
43160
  /** In XLSX color format (no #) */
43163
43161
  const AUTO_COLOR = "000000";
43164
43162
  const XLSX_ICONSET_MAP = {
43165
- arrow: "3Arrows",
43163
+ arrows: "3Arrows",
43166
43164
  smiley: "3Symbols",
43167
- dot: "3TrafficLights1",
43165
+ dots: "3TrafficLights1",
43168
43166
  };
43169
43167
  const NAMESPACE = {
43170
43168
  styleSheet: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
@@ -43580,6 +43578,7 @@ const ICON_SET_CONVERSION_MAP = {
43580
43578
  };
43581
43579
  /** Map between legend position in XLSX file and human readable position */
43582
43580
  const DRAWING_LEGEND_POSITION_CONVERSION_MAP = {
43581
+ none: "none",
43583
43582
  b: "bottom",
43584
43583
  t: "top",
43585
43584
  l: "left",
@@ -45829,7 +45828,7 @@ class XlsxChartExtractor extends XlsxBaseExtractor {
45829
45828
  default: "ffffff",
45830
45829
  }).asString(),
45831
45830
  legendPosition: DRAWING_LEGEND_POSITION_CONVERSION_MAP[this.extractChildAttr(rootChartElement, "c:legendPos", "val", {
45832
- default: "b",
45831
+ default: "none",
45833
45832
  }).asString()],
45834
45833
  stacked: barChartGrouping === "stacked",
45835
45834
  fontColor: "000000",
@@ -45863,7 +45862,7 @@ class XlsxChartExtractor extends XlsxBaseExtractor {
45863
45862
  default: "ffffff",
45864
45863
  }).asString(),
45865
45864
  legendPosition: DRAWING_LEGEND_POSITION_CONVERSION_MAP[this.extractChildAttr(chartElement, "c:legendPos", "val", {
45866
- default: "b",
45865
+ default: "none",
45867
45866
  }).asString()],
45868
45867
  stacked: barChartGrouping === "stacked",
45869
45868
  fontColor: "000000",
@@ -58763,12 +58762,7 @@ class SheetUIPlugin extends UIPlugin {
58763
58762
  }
58764
58763
  break;
58765
58764
  case "AUTORESIZE_ROWS":
58766
- this.dispatch("RESIZE_COLUMNS_ROWS", {
58767
- elements: cmd.rows,
58768
- dimension: "ROW",
58769
- size: null,
58770
- sheetId: cmd.sheetId,
58771
- });
58765
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
58772
58766
  break;
58773
58767
  }
58774
58768
  }
@@ -58918,6 +58912,48 @@ class SheetUIPlugin extends UIPlugin {
58918
58912
  }
58919
58913
  return "Success" /* CommandResult.Success */;
58920
58914
  }
58915
+ autoResizeRows(sheetId, rows) {
58916
+ const rowSizes = [];
58917
+ for (const row of rows) {
58918
+ let evaluatedRowSize = 0;
58919
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
58920
+ const cell = this.getters.getCellById(cellId);
58921
+ if (!cell) {
58922
+ continue;
58923
+ }
58924
+ const position = this.getters.getCellPosition(cell.id);
58925
+ const colSize = this.getters.getColSize(sheetId, position.col);
58926
+ if (cell.isFormula) {
58927
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
58928
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58929
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
58930
+ evaluatedRowSize = evaluatedSize;
58931
+ }
58932
+ }
58933
+ else {
58934
+ const content = cell.content;
58935
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58936
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
58937
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
58938
+ evaluatedRowSize = 0;
58939
+ }
58940
+ }
58941
+ }
58942
+ rowSizes.push(evaluatedRowSize || null);
58943
+ }
58944
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
58945
+ for (let i = 0; i < rowSizes.length; i++) {
58946
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
58947
+ }
58948
+ for (const [size, rows] of groupedSizes) {
58949
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
58950
+ elements: rows,
58951
+ dimension: "ROW",
58952
+ size,
58953
+ sheetId,
58954
+ });
58955
+ }
58956
+ }
58921
58957
  }
58922
58958
 
58923
58959
  class TableComputedStylePlugin extends UIPlugin {
@@ -64124,7 +64160,9 @@ css /* scss */ `
64124
64160
  margin-top: -1px;
64125
64161
  border: 1px solid;
64126
64162
 
64127
- .o-composer:empty:not(:focus):not(.active)::before {
64163
+ /* In readonly we always show the fx icon if the composer is empty, not matter the focus */
64164
+ .o-composer:empty:not(:focus):not(.active)::before,
64165
+ &.o-topbar-composer-readonly .o-composer:empty::before {
64128
64166
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
64129
64167
  position: relative;
64130
64168
  top: 20%;
@@ -67368,10 +67406,14 @@ function addIconSetRule(cf, rule) {
67368
67406
  continue;
67369
67407
  }
67370
67408
  const cfValueObjectNodes = cfValueObject.map((attrs) => escapeXml /*xml*/ `<cfvo ${formatAttributes(attrs)} />`);
67409
+ const iconSetAttrs = [["iconSet", getIconSet(rule.icons)]];
67410
+ if (isIconSetReversed(rule.icons)) {
67411
+ iconSetAttrs.push(["reverse", "1"]);
67412
+ }
67371
67413
  conditionalFormats.push(escapeXml /*xml*/ `
67372
67414
  <conditionalFormatting sqref="${range}">
67373
67415
  <cfRule ${formatAttributes(ruleAttributes)}>
67374
- <iconSet iconSet="${getIconSet(rule.icons)}">
67416
+ <iconSet ${formatAttributes(iconSetAttrs)}>
67375
67417
  ${joinXmlNodes(cfValueObjectNodes)}
67376
67418
  </iconSet>
67377
67419
  </cfRule>
@@ -67389,9 +67431,21 @@ function commonCfAttributes(cf) {
67389
67431
  ["stopIfTrue", cf.stopIfTrue ? 1 : 0],
67390
67432
  ];
67391
67433
  }
67434
+ function isIconSetReversed(iconSet) {
67435
+ const defaultIconSet = ICON_SETS[detectIconsType(iconSet)];
67436
+ return iconSet.upper === defaultIconSet.bad && iconSet.lower === defaultIconSet.good;
67437
+ }
67392
67438
  function getIconSet(iconSet) {
67393
- return XLSX_ICONSET_MAP[Object.keys(XLSX_ICONSET_MAP).find((key) => iconSet.upper.toLowerCase().startsWith(key)) ||
67394
- "dots"];
67439
+ return XLSX_ICONSET_MAP[detectIconsType(iconSet)];
67440
+ }
67441
+ /**
67442
+ * Partial detection based on "upper" point only.
67443
+ * We support any arbitrary icon in the set, while excel doesn't allow
67444
+ * mixing icons from different types.
67445
+ */
67446
+ function detectIconsType(iconSet) {
67447
+ const type = Object.keys(ICON_SETS).find((type) => Object.values(ICON_SETS[type]).includes(iconSet.upper)) || "dots";
67448
+ return type;
67395
67449
  }
67396
67450
  function thresholdAttributes(threshold, position) {
67397
67451
  const type = getExcelThresholdType(threshold.type, position);
@@ -69173,6 +69227,6 @@ exports.tokenColors = tokenColors;
69173
69227
  exports.tokenize = tokenize;
69174
69228
 
69175
69229
 
69176
- __info__.version = "17.4.26";
69177
- __info__.date = "2025-03-12T15:31:45.184Z";
69178
- __info__.hash = "a18429e";
69230
+ __info__.version = "17.4.28";
69231
+ __info__.date = "2025-03-26T12:48:33.387Z";
69232
+ __info__.hash = "a81a8f4";
@@ -4721,6 +4721,7 @@ declare class SheetUIPlugin extends UIPlugin {
4721
4721
  * not outside the sheet.
4722
4722
  */
4723
4723
  private checkZonesAreInSheet;
4724
+ private autoResizeRows;
4724
4725
  }
4725
4726
 
4726
4727
  /**