@odoo/o-spreadsheet 18.4.4 → 18.4.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.
@@ -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 18.4.4
6
- * @date 2025-07-30T11:20:08.639Z
7
- * @hash b14de14
5
+ * @version 18.4.6
6
+ * @date 2025-08-18T08:16:33.453Z
7
+ * @hash 9c7c143
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, App, blockDom, useState, onPatched, useExternalListener, onWillUpdateProps, onWillStart, onWillPatch, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -1056,16 +1056,21 @@ const colors = [
1056
1056
  "#001f3f",
1057
1057
  ];
1058
1058
  /*
1059
- * transform a color number (R * 256^2 + G * 256 + B) into classic hex6 value
1059
+ * transform a color number (R * 256^2 + G * 256 + B) into classic hex (+alpha) value
1060
1060
  * */
1061
- function colorNumberString(color) {
1062
- return toHex(color.toString(16).padStart(6, "0"));
1061
+ function colorNumberToHex(color, alpha = 1) {
1062
+ const alphaHex = alpha !== 1
1063
+ ? Math.round(alpha * 255)
1064
+ .toString(16)
1065
+ .padStart(2, "0")
1066
+ : "";
1067
+ return toHex(color.toString(16).padStart(6, "0")) + alphaHex;
1063
1068
  }
1064
1069
  function colorToNumber(color) {
1065
1070
  if (typeof color === "number") {
1066
1071
  return color;
1067
1072
  }
1068
- return Number.parseInt(toHex(color).slice(1), 16);
1073
+ return Number.parseInt(toHex(color).slice(1, 7), 16);
1069
1074
  }
1070
1075
  /**
1071
1076
  * Converts any CSS color value to a standardized hex6 value.
@@ -1324,6 +1329,12 @@ function hslaToHex(hsla) {
1324
1329
  function hexToHSLA(hex) {
1325
1330
  return rgbaToHSLA(colorToRGBA(hex));
1326
1331
  }
1332
+ function colorOrNumberToRGBA(color) {
1333
+ if (typeof color === "number") {
1334
+ return colorToRGBA(colorNumberToHex(color));
1335
+ }
1336
+ return colorToRGBA(color);
1337
+ }
1327
1338
  /**
1328
1339
  * Will compare two color strings
1329
1340
  * A tolerance can be provided to account for small differences that could
@@ -1605,6 +1616,8 @@ function getColorScale(colorScalePoints) {
1605
1616
  const sortedColorScalePoints = [...colorScalePoints.sort((a, b) => a.value - b.value)];
1606
1617
  const thresholds = [];
1607
1618
  for (let i = 1; i < sortedColorScalePoints.length; i++) {
1619
+ const minColorAlpha = colorOrNumberToRGBA(sortedColorScalePoints[i - 1].color).a;
1620
+ const maxColorAlpha = colorOrNumberToRGBA(sortedColorScalePoints[i].color).a;
1608
1621
  const minColor = colorToNumber(sortedColorScalePoints[i - 1].color);
1609
1622
  const maxColor = colorToNumber(sortedColorScalePoints[i].color);
1610
1623
  thresholds.push({
@@ -1612,19 +1625,21 @@ function getColorScale(colorScalePoints) {
1612
1625
  max: sortedColorScalePoints[i].value,
1613
1626
  minColor,
1614
1627
  maxColor,
1628
+ minColorAlpha: minColorAlpha,
1629
+ maxColorAlpha: maxColorAlpha,
1615
1630
  colorDiff: computeColorDiffUnits(sortedColorScalePoints[i - 1].value, sortedColorScalePoints[i].value, minColor, maxColor),
1616
1631
  });
1617
1632
  }
1618
1633
  return (value) => {
1619
1634
  if (value < thresholds[0].min) {
1620
- return colorNumberString(thresholds[0].minColor);
1635
+ return colorNumberToHex(thresholds[0].minColor, thresholds[0].minColorAlpha);
1621
1636
  }
1622
1637
  for (const threshold of thresholds) {
1623
1638
  if (value >= threshold.min && value <= threshold.max) {
1624
- return colorNumberString(colorCell(value, threshold.min, threshold.minColor, threshold.colorDiff));
1639
+ return colorNumberToHex(colorCell(value, threshold.min, threshold.minColor, threshold.colorDiff), threshold.maxColorAlpha);
1625
1640
  }
1626
1641
  }
1627
- return colorNumberString(thresholds[thresholds.length - 1].maxColor);
1642
+ return colorNumberToHex(thresholds[thresholds.length - 1].maxColor, thresholds[thresholds.length - 1].maxColorAlpha);
1628
1643
  };
1629
1644
  }
1630
1645
  function computeColorDiffUnits(minValue, maxValue, minColor, maxColor) {
@@ -19624,7 +19639,7 @@ const OFFSET = {
19624
19639
  right: startingCol + offsetWidth - 1,
19625
19640
  bottom: startingRow + offsetHeight - 1,
19626
19641
  };
19627
- const range = this.getters.getRangeFromZone(this.__originSheetId, dependencyZone);
19642
+ const range = this.getters.getRangeFromZone(sheetId, dependencyZone);
19628
19643
  if (range.invalidXc || range.invalidSheetName) {
19629
19644
  return new InvalidReferenceError();
19630
19645
  }
@@ -22760,6 +22775,7 @@ class ChartJsComponent extends Component {
22760
22775
  this.animationStore = useStore(ChartAnimationStore);
22761
22776
  }
22762
22777
  onMounted(() => {
22778
+ registerChartJSExtensions();
22763
22779
  const runtime = this.chartRuntime;
22764
22780
  this.currentRuntime = runtime;
22765
22781
  // Note: chartJS modify the runtime in place, so it's important to give it a copy
@@ -43815,7 +43831,7 @@ const insertDropdown = {
43815
43831
  env.openSidePanel("DataValidationEditor", {
43816
43832
  rule: localizeDataValidationRule(rule, env.model.getters.getLocale()),
43817
43833
  onExit: () => {
43818
- env.openSidePanel("DataValidation");
43834
+ env.replaceSidePanel("DataValidation", "DataValidationEditor");
43819
43835
  },
43820
43836
  });
43821
43837
  },
@@ -51843,16 +51859,16 @@ class ConditionalFormatPreview extends Component {
51843
51859
  return cssPropertiesToCss(cellStyleToCss(rule.style));
51844
51860
  }
51845
51861
  else if (rule.type === "ColorScaleRule") {
51846
- const minColor = colorNumberString(rule.minimum.color);
51847
- const midColor = rule.midpoint ? colorNumberString(rule.midpoint.color) : null;
51848
- const maxColor = colorNumberString(rule.maximum.color);
51862
+ const minColor = colorNumberToHex(rule.minimum.color);
51863
+ const midColor = rule.midpoint ? colorNumberToHex(rule.midpoint.color) : null;
51864
+ const maxColor = colorNumberToHex(rule.maximum.color);
51849
51865
  const baseString = "background-image: linear-gradient(to right, ";
51850
51866
  return midColor
51851
51867
  ? baseString + minColor + ", " + midColor + ", " + maxColor + ")"
51852
51868
  : baseString + minColor + ", " + maxColor + ")";
51853
51869
  }
51854
51870
  else if (rule.type === "DataBarRule") {
51855
- const color = colorNumberString(rule.color);
51871
+ const color = colorNumberToHex(rule.color);
51856
51872
  return `background-image: linear-gradient(to right, ${color} 50%, white 50%)`;
51857
51873
  }
51858
51874
  return "";
@@ -52060,7 +52076,7 @@ class ConditionalFormattingEditor extends Component {
52060
52076
  icons = ICONS;
52061
52077
  iconSets = ICON_SETS;
52062
52078
  getTextDecoration = getTextDecoration;
52063
- colorNumberString = colorNumberString;
52079
+ colorNumberToHex = colorNumberToHex;
52064
52080
  state;
52065
52081
  setup() {
52066
52082
  this.state = useState({
@@ -52311,9 +52327,9 @@ class ConditionalFormattingEditor extends Component {
52311
52327
  }
52312
52328
  getPreviewGradient() {
52313
52329
  const rule = this.state.rules.colorScale;
52314
- const minColor = colorNumberString(rule.minimum.color);
52315
- const midColor = colorNumberString(rule.midpoint?.color || DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52316
- const maxColor = colorNumberString(rule.maximum.color);
52330
+ const minColor = colorNumberToHex(rule.minimum.color);
52331
+ const midColor = colorNumberToHex(rule.midpoint?.color || DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52332
+ const maxColor = colorNumberToHex(rule.maximum.color);
52317
52333
  const baseString = "background-image: linear-gradient(to right, ";
52318
52334
  return rule.midpoint === undefined
52319
52335
  ? baseString + minColor + ", " + maxColor + ")"
@@ -52321,8 +52337,8 @@ class ConditionalFormattingEditor extends Component {
52321
52337
  }
52322
52338
  getThresholdColor(threshold) {
52323
52339
  return threshold
52324
- ? colorNumberString(threshold.color)
52325
- : colorNumberString(DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52340
+ ? colorNumberToHex(threshold.color)
52341
+ : colorNumberToHex(DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52326
52342
  }
52327
52343
  onMidpointChange(ev) {
52328
52344
  const type = ev.target.value;
@@ -53635,11 +53651,15 @@ class PivotMeasureDisplayPanel extends Component {
53635
53651
  this.store = useLocalStore(PivotMeasureDisplayPanelStore, this.props.pivotId, this.props.measure);
53636
53652
  }
53637
53653
  onSave() {
53638
- this.env.openSidePanel("PivotSidePanel", { pivotId: this.props.pivotId });
53654
+ this.env.replaceSidePanel("PivotSidePanel", `pivot_measure_display_${this.props.pivotId}_${this.props.measure.id}`, {
53655
+ pivotId: this.props.pivotId,
53656
+ });
53639
53657
  }
53640
53658
  onCancel() {
53641
53659
  this.store.cancelMeasureDisplayEdition();
53642
- this.env.openSidePanel("PivotSidePanel", { pivotId: this.props.pivotId });
53660
+ this.env.replaceSidePanel("PivotSidePanel", `pivot_measure_display_${this.props.pivotId}_${this.props.measure.id}`, {
53661
+ pivotId: this.props.pivotId,
53662
+ });
53643
53663
  }
53644
53664
  get fieldChoices() {
53645
53665
  return this.store.fields.map((field) => ({
@@ -54101,7 +54121,7 @@ class PivotMeasureEditor extends Component {
54101
54121
  });
54102
54122
  }
54103
54123
  openShowValuesAs() {
54104
- this.env.openSidePanel("PivotMeasureDisplayPanel", {
54124
+ this.env.replaceSidePanel("PivotMeasureDisplayPanel", `pivot_key_${this.props.pivotId}`, {
54105
54125
  pivotId: this.props.pivotId,
54106
54126
  measure: this.props.measure,
54107
54127
  });
@@ -54361,7 +54381,7 @@ class PivotLayoutConfigurator extends Component {
54361
54381
  this.props.onDimensionsUpdated(update);
54362
54382
  }
54363
54383
  getMeasureId(fieldName, aggregator) {
54364
- const baseId = fieldName + (aggregator ? `:${aggregator}` : "");
54384
+ const baseId = fieldName.replaceAll("'", "") + (aggregator ? `:${aggregator}` : "");
54365
54385
  let id = baseId;
54366
54386
  let i = 2;
54367
54387
  while (this.props.definition.measures.some((m) => m.id === id)) {
@@ -57200,7 +57220,11 @@ sidePanelRegistry.add("PivotMeasureDisplayPanel", {
57200
57220
  try {
57201
57221
  // This will throw if the pivot or measure does not exist
57202
57222
  getters.getPivot(props.pivotId).getMeasure(props.measure.id);
57203
- return { isOpen: true, props, key: "pivot_measure_display" };
57223
+ return {
57224
+ isOpen: true,
57225
+ props,
57226
+ key: `pivot_measure_display_${props.pivotId}_${props.measure.id}`,
57227
+ };
57204
57228
  }
57205
57229
  catch (e) {
57206
57230
  return { isOpen: false };
@@ -57225,6 +57249,7 @@ const MIN_SHEET_VIEW_WIDTH = 150;
57225
57249
  class SidePanelStore extends SpreadsheetStore {
57226
57250
  mutators = [
57227
57251
  "open",
57252
+ "replace",
57228
57253
  "toggle",
57229
57254
  "close",
57230
57255
  "changePanelSize",
@@ -57286,8 +57311,7 @@ class SidePanelStore extends SpreadsheetStore {
57286
57311
  if (!state.isOpen) {
57287
57312
  return;
57288
57313
  }
57289
- const mainPanelKey = this.mainPanel ? this.getPanelKey(this.mainPanel) : undefined;
57290
- if (!this.mainPanel || !this.mainPanel.isPinned || mainPanelKey === state.key) {
57314
+ if (!this.mainPanel || !this.mainPanel.isPinned || this.mainPanelKey === state.key) {
57291
57315
  this._openPanel("mainPanel", newPanelInfo, state);
57292
57316
  return;
57293
57317
  }
@@ -57306,6 +57330,34 @@ class SidePanelStore extends SpreadsheetStore {
57306
57330
  }
57307
57331
  this._openPanel("secondaryPanel", newPanelInfo, state);
57308
57332
  }
57333
+ replace(componentTag, currentPanelKey, initialPanelProps = {}) {
57334
+ const newPanelInfo = { initialPanelProps, componentTag, size: DEFAULT_SIDE_PANEL_SIZE };
57335
+ const state = this.computeState(newPanelInfo);
57336
+ if (!state.isOpen) {
57337
+ return;
57338
+ }
57339
+ const ensureMainPanelExpanded = () => {
57340
+ if (this.mainPanel?.isCollapsed) {
57341
+ this.toggleCollapsePanel("mainPanel");
57342
+ }
57343
+ };
57344
+ // Close the current panel if the target panel is already open
57345
+ const isMainPanel = this.mainPanelKey === state.key;
57346
+ const isSecondaryPanel = this.secondaryPanelKey === state.key;
57347
+ if (isMainPanel && this.secondaryPanel) {
57348
+ this.close();
57349
+ ensureMainPanelExpanded();
57350
+ return;
57351
+ }
57352
+ if (isSecondaryPanel) {
57353
+ this.closeMainPanel();
57354
+ this.togglePinPanel();
57355
+ ensureMainPanelExpanded();
57356
+ return;
57357
+ }
57358
+ const targetPanel = this.mainPanelKey === currentPanelKey ? "mainPanel" : "secondaryPanel";
57359
+ this._openPanel(targetPanel, newPanelInfo, state);
57360
+ }
57309
57361
  _openPanel(panel, newPanel, state) {
57310
57362
  const currentPanel = this[panel];
57311
57363
  if (currentPanel && newPanel.componentTag !== currentPanel.componentTag) {
@@ -57365,11 +57417,9 @@ class SidePanelStore extends SpreadsheetStore {
57365
57417
  panelInfo.size = size;
57366
57418
  }
57367
57419
  resetPanelSize(panel) {
57368
- const panelInfo = this[panel];
57369
- if (!panelInfo) {
57370
- return;
57420
+ if (this[panel]) {
57421
+ this[panel].size = DEFAULT_SIDE_PANEL_SIZE;
57371
57422
  }
57372
- panelInfo.size = DEFAULT_SIDE_PANEL_SIZE;
57373
57423
  }
57374
57424
  togglePinPanel() {
57375
57425
  if (!this.mainPanel) {
@@ -66545,9 +66595,9 @@ class CustomColorsPlugin extends CoreViewPlugin {
66545
66595
  formatColors.push(rule.style.fillColor);
66546
66596
  }
66547
66597
  else if (rule.type === "ColorScaleRule") {
66548
- formatColors.push(colorNumberString(rule.minimum.color));
66549
- formatColors.push(rule.midpoint ? colorNumberString(rule.midpoint.color) : undefined);
66550
- formatColors.push(colorNumberString(rule.maximum.color));
66598
+ formatColors.push(colorNumberToHex(rule.minimum.color));
66599
+ formatColors.push(rule.midpoint ? colorNumberToHex(rule.midpoint.color) : undefined);
66600
+ formatColors.push(colorNumberToHex(rule.maximum.color));
66551
66601
  }
66552
66602
  }
66553
66603
  return formatColors.filter(isDefined);
@@ -66918,7 +66968,7 @@ class EvaluationConditionalFormatPlugin extends CoreViewPlugin {
66918
66968
  if (!computedDataBars[col])
66919
66969
  computedDataBars[col] = [];
66920
66970
  computedDataBars[col][row] = {
66921
- color: colorNumberString(color),
66971
+ color: colorNumberToHex(color),
66922
66972
  percentage: (cell.value * 100) / max,
66923
66973
  };
66924
66974
  }
@@ -77763,9 +77813,7 @@ class ClickableCellsStore extends SpreadsheetStore {
77763
77813
  }
77764
77814
  if (!(xc in clickableCells[sheetId])) {
77765
77815
  const clickableCell = this.findClickableItem(position);
77766
- if (clickableCell) {
77767
- clickableCells[sheetId][xc] = clickableCell;
77768
- }
77816
+ clickableCells[sheetId][xc] = clickableCell;
77769
77817
  }
77770
77818
  return clickableCells[sheetId][xc];
77771
77819
  }
@@ -79935,7 +79983,6 @@ css /* scss */ `
79935
79983
  }
79936
79984
  }
79937
79985
 
79938
- .o-spreadsheet-topbar-wrapper,
79939
79986
  .o-spreadsheet-bottombar-wrapper {
79940
79987
  z-index: ${ComponentsImportance.ScrollBar + 1};
79941
79988
  }
@@ -80008,6 +80055,7 @@ class Spreadsheet extends Component {
80008
80055
  loadLocales: this.model.config.external.loadLocales,
80009
80056
  isDashboard: () => this.model.getters.isDashboard(),
80010
80057
  openSidePanel: this.sidePanel.open.bind(this.sidePanel),
80058
+ replaceSidePanel: this.sidePanel.replace.bind(this.sidePanel),
80011
80059
  toggleSidePanel: this.sidePanel.toggle.bind(this.sidePanel),
80012
80060
  clipboard: this.env.clipboard || instantiateClipboard(),
80013
80061
  startCellEdition: (content) => this.composerFocusStore.focusActiveComposer({ content }),
@@ -80050,7 +80098,6 @@ class Spreadsheet extends Component {
80050
80098
  this.checkViewportSize();
80051
80099
  stores.on("store-updated", this, render);
80052
80100
  resizeObserver.observe(this.spreadsheetRef.el);
80053
- registerChartJSExtensions();
80054
80101
  });
80055
80102
  onWillUnmount(() => {
80056
80103
  this.unbindModelEvents();
@@ -82583,7 +82630,7 @@ function addDataBarRule(cf, rule) {
82583
82630
  <dataBar>
82584
82631
  <cfvo type="min" val="0"/>
82585
82632
  <cfvo type="max" val="100"/>
82586
- <color rgb="${toXlsxHexColor(colorNumberString(rule.color))}"/>
82633
+ <color rgb="${toXlsxHexColor(colorNumberToHex(rule.color))}"/>
82587
82634
  </dataBar>
82588
82635
  </cfRule>
82589
82636
  </conditionalFormatting>
@@ -82611,7 +82658,7 @@ function addColorScaleRule(cf, rule) {
82611
82658
  continue;
82612
82659
  }
82613
82660
  cfValueObject.push(thresholdAttributes(threshold, position));
82614
- colors.push([["rgb", toXlsxHexColor(colorNumberString(threshold.color))]]);
82661
+ colors.push([["rgb", toXlsxHexColor(colorNumberToHex(threshold.color))]]);
82615
82662
  }
82616
82663
  if (!canExport) {
82617
82664
  console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");
@@ -84622,6 +84669,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
84622
84669
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, ClientDisconnectedError, CommandResult, CorePlugin, CoreViewPlugin, DispatchResult, EvaluationError, LocalTransportService, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, chartHelpers, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateChartEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
84623
84670
 
84624
84671
 
84625
- __info__.version = "18.4.4";
84626
- __info__.date = "2025-07-30T11:20:08.639Z";
84627
- __info__.hash = "b14de14";
84672
+ __info__.version = "18.4.6";
84673
+ __info__.date = "2025-08-18T08:16:33.453Z";
84674
+ __info__.hash = "9c7c143";