@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
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -1007,7 +1007,10 @@ function rgbaStringToHex(color) {
1007
1007
  }
1008
1008
  else if (stringVals.length === 4) {
1009
1009
  const alpha = parseFloat(stringVals.pop() || "1");
1010
- alphaHex = Math.round((alpha || 1) * 255);
1010
+ if (isNaN(alpha)) {
1011
+ throw new Error("invalid alpha value");
1012
+ }
1013
+ alphaHex = Math.round(alpha * 255);
1011
1014
  }
1012
1015
  const vals = stringVals.map((val) => parseInt(val, 10));
1013
1016
  if (alphaHex !== 255) {
@@ -5197,11 +5200,13 @@ function getDefaultCellHeight(ctx, cell, colSize) {
5197
5200
  if (!cell || (!cell.isFormula && !cell.content)) {
5198
5201
  return DEFAULT_CELL_HEIGHT;
5199
5202
  }
5200
- const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5201
- const numberOfLines = cell.isFormula
5202
- ? 1
5203
- : splitTextToWidth(ctx, cell.content, cell.style, maxWidth).length;
5204
- const fontSize = computeTextFontSizeInPixels(cell.style);
5203
+ const content = cell.isFormula ? "" : cell.content;
5204
+ return getCellContentHeight(ctx, content, cell.style, colSize);
5205
+ }
5206
+ function getCellContentHeight(ctx, content, style, colSize) {
5207
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5208
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
5209
+ const fontSize = computeTextFontSizeInPixels(style);
5205
5210
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
5206
5211
  }
5207
5212
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -5961,7 +5966,7 @@ function isValidLocale(locale) {
5961
5966
  */
5962
5967
  function canonicalizeNumberContent(content, locale) {
5963
5968
  return content.startsWith("=")
5964
- ? canonicalizeFormula$1(content, locale)
5969
+ ? canonicalizeFormula(content, locale)
5965
5970
  : canonicalizeNumberLiteral(content, locale);
5966
5971
  }
5967
5972
  /**
@@ -5976,7 +5981,7 @@ function canonicalizeNumberContent(content, locale) {
5976
5981
  */
5977
5982
  function canonicalizeContent(content, locale) {
5978
5983
  return content.startsWith("=")
5979
- ? canonicalizeFormula$1(content, locale)
5984
+ ? canonicalizeFormula(content, locale)
5980
5985
  : canonicalizeLiteral(content, locale);
5981
5986
  }
5982
5987
  /**
@@ -5992,15 +5997,21 @@ function localizeContent(content, locale) {
5992
5997
  ? localizeFormula(content, locale)
5993
5998
  : localizeLiteral(content, locale);
5994
5999
  }
6000
+ /** Change a number string to its canonical form (en_US locale) */
6001
+ function canonicalizeNumberValue(content, locale) {
6002
+ return content.startsWith("=")
6003
+ ? canonicalizeFormula(content, locale)
6004
+ : canonicalizeNumberLiteral(content, locale);
6005
+ }
5995
6006
  /** Change a formula to its canonical form (en_US locale) */
5996
- function canonicalizeFormula$1(formula, locale) {
5997
- return _localizeFormula$1(formula, locale, DEFAULT_LOCALE);
6007
+ function canonicalizeFormula(formula, locale) {
6008
+ return _localizeFormula(formula, locale, DEFAULT_LOCALE);
5998
6009
  }
5999
6010
  /** Change a formula from the canonical form to the given locale */
6000
6011
  function localizeFormula(formula, locale) {
6001
- return _localizeFormula$1(formula, DEFAULT_LOCALE, locale);
6012
+ return _localizeFormula(formula, DEFAULT_LOCALE, locale);
6002
6013
  }
6003
- function _localizeFormula$1(formula, fromLocale, toLocale) {
6014
+ function _localizeFormula(formula, fromLocale, toLocale) {
6004
6015
  if (fromLocale.formulaArgSeparator === toLocale.formulaArgSeparator &&
6005
6016
  fromLocale.decimalSeparator === toLocale.decimalSeparator) {
6006
6017
  return formula;
@@ -6155,37 +6166,6 @@ function getDateTimeFormat(locale) {
6155
6166
  return locale.dateFormat + " " + locale.timeFormat;
6156
6167
  }
6157
6168
 
6158
- /** Change a number string to its canonical form (en_US locale) */
6159
- function canonicalizeNumberValue(content, locale) {
6160
- return content.startsWith("=")
6161
- ? canonicalizeFormula(content, locale)
6162
- : canonicalizeNumberLiteral(content, locale);
6163
- }
6164
- /** Change a formula to its canonical form (en_US locale) */
6165
- function canonicalizeFormula(formula, locale) {
6166
- return _localizeFormula(formula, locale, DEFAULT_LOCALE);
6167
- }
6168
- function _localizeFormula(formula, fromLocale, toLocale) {
6169
- if (fromLocale.formulaArgSeparator === toLocale.formulaArgSeparator &&
6170
- fromLocale.decimalSeparator === toLocale.decimalSeparator) {
6171
- return formula;
6172
- }
6173
- const tokens = tokenize(formula, fromLocale);
6174
- let localizedFormula = "";
6175
- for (const token of tokens) {
6176
- if (token.type === "NUMBER") {
6177
- localizedFormula += token.value.replace(fromLocale.decimalSeparator, toLocale.decimalSeparator);
6178
- }
6179
- else if (token.type === "ARG_SEPARATOR") {
6180
- localizedFormula += toLocale.formulaArgSeparator;
6181
- }
6182
- else {
6183
- localizedFormula += token.value;
6184
- }
6185
- }
6186
- return localizedFormula;
6187
- }
6188
-
6189
6169
  function boolAnd(args) {
6190
6170
  let foundBoolean = false;
6191
6171
  let acc = true;
@@ -6787,13 +6767,6 @@ class CellClipboardHandler extends AbstractCellClipboardHandler {
6787
6767
  this.clearClippedZones(content);
6788
6768
  const selection = target[0];
6789
6769
  this.pasteZone(sheetId, selection.left, selection.top, content.cells, options);
6790
- this.dispatch("MOVE_RANGES", {
6791
- target: content.zones,
6792
- sheetId: content.sheetId,
6793
- targetSheetId: sheetId,
6794
- col: selection.left,
6795
- row: selection.top,
6796
- });
6797
6770
  }
6798
6771
  /**
6799
6772
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -7254,14 +7227,15 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
7254
7227
  }
7255
7228
  merges.push(mergesInRow);
7256
7229
  }
7257
- return { merges };
7230
+ return { merges, sheetId };
7258
7231
  }
7259
7232
  /**
7260
7233
  * Paste the clipboard content in the given target
7261
7234
  */
7262
7235
  paste(target, content, options) {
7263
7236
  if (options.isCutOperation) {
7264
- return;
7237
+ const copiedMerges = content.merges.flat().filter(isDefined);
7238
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
7265
7239
  }
7266
7240
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
7267
7241
  }
@@ -7296,6 +7270,27 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
7296
7270
  }
7297
7271
  }
7298
7272
 
7273
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
7274
+ copy(data) {
7275
+ return {
7276
+ zones: data.clippedZones,
7277
+ sheetId: data.sheetId,
7278
+ };
7279
+ }
7280
+ paste(target, content, options) {
7281
+ if (options.isCutOperation) {
7282
+ const selection = target.zones[0];
7283
+ this.dispatch("MOVE_RANGES", {
7284
+ target: content.zones,
7285
+ sheetId: content.sheetId,
7286
+ targetSheetId: target.sheetId,
7287
+ col: selection.left,
7288
+ row: selection.top,
7289
+ });
7290
+ }
7291
+ }
7292
+ }
7293
+
7299
7294
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
7300
7295
  isPasteAllowed(sheetId, target, content, options) {
7301
7296
  if (!("cells" in content)) {
@@ -7463,7 +7458,8 @@ clipboardHandlersRegistries.cellHandlers
7463
7458
  .add("merge", MergeClipboardHandler)
7464
7459
  .add("border", BorderClipboardHandler)
7465
7460
  .add("table", TableClipboardHandler)
7466
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
7461
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
7462
+ .add("references", ReferenceClipboardHandler);
7467
7463
 
7468
7464
  function transformZone(zone, executed) {
7469
7465
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -9620,8 +9616,8 @@ class ComposerStore extends SpreadsheetStore {
9620
9616
  this.colorIndexByRange = {};
9621
9617
  }
9622
9618
  cancelEdition() {
9623
- this.cancelEditionAndActivateSheet();
9624
9619
  this.resetContent();
9620
+ this.cancelEditionAndActivateSheet();
9625
9621
  this.colorIndexByRange = {};
9626
9622
  }
9627
9623
  setCurrentContent(content, selection) {
@@ -9638,8 +9634,8 @@ class ComposerStore extends SpreadsheetStore {
9638
9634
  switch (cmd.type) {
9639
9635
  case "SELECT_FIGURE":
9640
9636
  if (cmd.id) {
9641
- this.cancelEditionAndActivateSheet();
9642
9637
  this.resetContent();
9638
+ this.cancelEditionAndActivateSheet();
9643
9639
  }
9644
9640
  break;
9645
9641
  case "SET_FORMATTING":
@@ -9689,8 +9685,8 @@ class ComposerStore extends SpreadsheetStore {
9689
9685
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
9690
9686
  if (!sheetIdExists && this.editionMode !== "inactive") {
9691
9687
  this.sheetId = this.getters.getActiveSheetId();
9692
- this.cancelEditionAndActivateSheet();
9693
9688
  this.resetContent();
9689
+ this.cancelEditionAndActivateSheet();
9694
9690
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
9695
9691
  }
9696
9692
  break;
@@ -12006,7 +12002,8 @@ function getChartLabelValues(getters, dataSets, labelRange) {
12006
12002
  }
12007
12003
  }
12008
12004
  else if (dataSets.length === 1) {
12009
- for (let i = 0; i < getData(getters, dataSets[0]).length; i++) {
12005
+ const dataLength = getData(getters, dataSets[0]).length;
12006
+ for (let i = 0; i < dataLength; i++) {
12010
12007
  labels.formattedValues.push("");
12011
12008
  labels.values.push("");
12012
12009
  }
@@ -37674,6 +37671,7 @@ class RemoveDuplicatesPanel extends Component {
37674
37671
  columns: {},
37675
37672
  });
37676
37673
  setup() {
37674
+ this.updateColumns();
37677
37675
  onWillUpdateProps(() => this.updateColumns());
37678
37676
  }
37679
37677
  toggleHasHeader() {
@@ -43160,9 +43158,9 @@ const XLSX_CHART_TYPES = [
43160
43158
  /** In XLSX color format (no #) */
43161
43159
  const AUTO_COLOR = "000000";
43162
43160
  const XLSX_ICONSET_MAP = {
43163
- arrow: "3Arrows",
43161
+ arrows: "3Arrows",
43164
43162
  smiley: "3Symbols",
43165
- dot: "3TrafficLights1",
43163
+ dots: "3TrafficLights1",
43166
43164
  };
43167
43165
  const NAMESPACE = {
43168
43166
  styleSheet: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
@@ -43578,6 +43576,7 @@ const ICON_SET_CONVERSION_MAP = {
43578
43576
  };
43579
43577
  /** Map between legend position in XLSX file and human readable position */
43580
43578
  const DRAWING_LEGEND_POSITION_CONVERSION_MAP = {
43579
+ none: "none",
43581
43580
  b: "bottom",
43582
43581
  t: "top",
43583
43582
  l: "left",
@@ -45827,7 +45826,7 @@ class XlsxChartExtractor extends XlsxBaseExtractor {
45827
45826
  default: "ffffff",
45828
45827
  }).asString(),
45829
45828
  legendPosition: DRAWING_LEGEND_POSITION_CONVERSION_MAP[this.extractChildAttr(rootChartElement, "c:legendPos", "val", {
45830
- default: "b",
45829
+ default: "none",
45831
45830
  }).asString()],
45832
45831
  stacked: barChartGrouping === "stacked",
45833
45832
  fontColor: "000000",
@@ -45861,7 +45860,7 @@ class XlsxChartExtractor extends XlsxBaseExtractor {
45861
45860
  default: "ffffff",
45862
45861
  }).asString(),
45863
45862
  legendPosition: DRAWING_LEGEND_POSITION_CONVERSION_MAP[this.extractChildAttr(chartElement, "c:legendPos", "val", {
45864
- default: "b",
45863
+ default: "none",
45865
45864
  }).asString()],
45866
45865
  stacked: barChartGrouping === "stacked",
45867
45866
  fontColor: "000000",
@@ -58761,12 +58760,7 @@ class SheetUIPlugin extends UIPlugin {
58761
58760
  }
58762
58761
  break;
58763
58762
  case "AUTORESIZE_ROWS":
58764
- this.dispatch("RESIZE_COLUMNS_ROWS", {
58765
- elements: cmd.rows,
58766
- dimension: "ROW",
58767
- size: null,
58768
- sheetId: cmd.sheetId,
58769
- });
58763
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
58770
58764
  break;
58771
58765
  }
58772
58766
  }
@@ -58916,6 +58910,48 @@ class SheetUIPlugin extends UIPlugin {
58916
58910
  }
58917
58911
  return "Success" /* CommandResult.Success */;
58918
58912
  }
58913
+ autoResizeRows(sheetId, rows) {
58914
+ const rowSizes = [];
58915
+ for (const row of rows) {
58916
+ let evaluatedRowSize = 0;
58917
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
58918
+ const cell = this.getters.getCellById(cellId);
58919
+ if (!cell) {
58920
+ continue;
58921
+ }
58922
+ const position = this.getters.getCellPosition(cell.id);
58923
+ const colSize = this.getters.getColSize(sheetId, position.col);
58924
+ if (cell.isFormula) {
58925
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
58926
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58927
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
58928
+ evaluatedRowSize = evaluatedSize;
58929
+ }
58930
+ }
58931
+ else {
58932
+ const content = cell.content;
58933
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58934
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
58935
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
58936
+ evaluatedRowSize = 0;
58937
+ }
58938
+ }
58939
+ }
58940
+ rowSizes.push(evaluatedRowSize || null);
58941
+ }
58942
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
58943
+ for (let i = 0; i < rowSizes.length; i++) {
58944
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
58945
+ }
58946
+ for (const [size, rows] of groupedSizes) {
58947
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
58948
+ elements: rows,
58949
+ dimension: "ROW",
58950
+ size,
58951
+ sheetId,
58952
+ });
58953
+ }
58954
+ }
58919
58955
  }
58920
58956
 
58921
58957
  class TableComputedStylePlugin extends UIPlugin {
@@ -64122,7 +64158,9 @@ css /* scss */ `
64122
64158
  margin-top: -1px;
64123
64159
  border: 1px solid;
64124
64160
 
64125
- .o-composer:empty:not(:focus):not(.active)::before {
64161
+ /* In readonly we always show the fx icon if the composer is empty, not matter the focus */
64162
+ .o-composer:empty:not(:focus):not(.active)::before,
64163
+ &.o-topbar-composer-readonly .o-composer:empty::before {
64126
64164
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
64127
64165
  position: relative;
64128
64166
  top: 20%;
@@ -67366,10 +67404,14 @@ function addIconSetRule(cf, rule) {
67366
67404
  continue;
67367
67405
  }
67368
67406
  const cfValueObjectNodes = cfValueObject.map((attrs) => escapeXml /*xml*/ `<cfvo ${formatAttributes(attrs)} />`);
67407
+ const iconSetAttrs = [["iconSet", getIconSet(rule.icons)]];
67408
+ if (isIconSetReversed(rule.icons)) {
67409
+ iconSetAttrs.push(["reverse", "1"]);
67410
+ }
67369
67411
  conditionalFormats.push(escapeXml /*xml*/ `
67370
67412
  <conditionalFormatting sqref="${range}">
67371
67413
  <cfRule ${formatAttributes(ruleAttributes)}>
67372
- <iconSet iconSet="${getIconSet(rule.icons)}">
67414
+ <iconSet ${formatAttributes(iconSetAttrs)}>
67373
67415
  ${joinXmlNodes(cfValueObjectNodes)}
67374
67416
  </iconSet>
67375
67417
  </cfRule>
@@ -67387,9 +67429,21 @@ function commonCfAttributes(cf) {
67387
67429
  ["stopIfTrue", cf.stopIfTrue ? 1 : 0],
67388
67430
  ];
67389
67431
  }
67432
+ function isIconSetReversed(iconSet) {
67433
+ const defaultIconSet = ICON_SETS[detectIconsType(iconSet)];
67434
+ return iconSet.upper === defaultIconSet.bad && iconSet.lower === defaultIconSet.good;
67435
+ }
67390
67436
  function getIconSet(iconSet) {
67391
- return XLSX_ICONSET_MAP[Object.keys(XLSX_ICONSET_MAP).find((key) => iconSet.upper.toLowerCase().startsWith(key)) ||
67392
- "dots"];
67437
+ return XLSX_ICONSET_MAP[detectIconsType(iconSet)];
67438
+ }
67439
+ /**
67440
+ * Partial detection based on "upper" point only.
67441
+ * We support any arbitrary icon in the set, while excel doesn't allow
67442
+ * mixing icons from different types.
67443
+ */
67444
+ function detectIconsType(iconSet) {
67445
+ const type = Object.keys(ICON_SETS).find((type) => Object.values(ICON_SETS[type]).includes(iconSet.upper)) || "dots";
67446
+ return type;
67393
67447
  }
67394
67448
  function thresholdAttributes(threshold, position) {
67395
67449
  const type = getExcelThresholdType(threshold.type, position);
@@ -69128,6 +69182,6 @@ const constants = {
69128
69182
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
69129
69183
 
69130
69184
 
69131
- __info__.version = "17.4.26";
69132
- __info__.date = "2025-03-12T15:31:45.184Z";
69133
- __info__.hash = "a18429e";
69185
+ __info__.version = "17.4.28";
69186
+ __info__.date = "2025-03-26T12:48:33.387Z";
69187
+ __info__.hash = "a81a8f4";