@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
  'use strict';
@@ -1058,16 +1058,21 @@ const colors = [
1058
1058
  "#001f3f",
1059
1059
  ];
1060
1060
  /*
1061
- * transform a color number (R * 256^2 + G * 256 + B) into classic hex6 value
1061
+ * transform a color number (R * 256^2 + G * 256 + B) into classic hex (+alpha) value
1062
1062
  * */
1063
- function colorNumberString(color) {
1064
- return toHex(color.toString(16).padStart(6, "0"));
1063
+ function colorNumberToHex(color, alpha = 1) {
1064
+ const alphaHex = alpha !== 1
1065
+ ? Math.round(alpha * 255)
1066
+ .toString(16)
1067
+ .padStart(2, "0")
1068
+ : "";
1069
+ return toHex(color.toString(16).padStart(6, "0")) + alphaHex;
1065
1070
  }
1066
1071
  function colorToNumber(color) {
1067
1072
  if (typeof color === "number") {
1068
1073
  return color;
1069
1074
  }
1070
- return Number.parseInt(toHex(color).slice(1), 16);
1075
+ return Number.parseInt(toHex(color).slice(1, 7), 16);
1071
1076
  }
1072
1077
  /**
1073
1078
  * Converts any CSS color value to a standardized hex6 value.
@@ -1326,6 +1331,12 @@ function hslaToHex(hsla) {
1326
1331
  function hexToHSLA(hex) {
1327
1332
  return rgbaToHSLA(colorToRGBA(hex));
1328
1333
  }
1334
+ function colorOrNumberToRGBA(color) {
1335
+ if (typeof color === "number") {
1336
+ return colorToRGBA(colorNumberToHex(color));
1337
+ }
1338
+ return colorToRGBA(color);
1339
+ }
1329
1340
  /**
1330
1341
  * Will compare two color strings
1331
1342
  * A tolerance can be provided to account for small differences that could
@@ -1607,6 +1618,8 @@ function getColorScale(colorScalePoints) {
1607
1618
  const sortedColorScalePoints = [...colorScalePoints.sort((a, b) => a.value - b.value)];
1608
1619
  const thresholds = [];
1609
1620
  for (let i = 1; i < sortedColorScalePoints.length; i++) {
1621
+ const minColorAlpha = colorOrNumberToRGBA(sortedColorScalePoints[i - 1].color).a;
1622
+ const maxColorAlpha = colorOrNumberToRGBA(sortedColorScalePoints[i].color).a;
1610
1623
  const minColor = colorToNumber(sortedColorScalePoints[i - 1].color);
1611
1624
  const maxColor = colorToNumber(sortedColorScalePoints[i].color);
1612
1625
  thresholds.push({
@@ -1614,19 +1627,21 @@ function getColorScale(colorScalePoints) {
1614
1627
  max: sortedColorScalePoints[i].value,
1615
1628
  minColor,
1616
1629
  maxColor,
1630
+ minColorAlpha: minColorAlpha,
1631
+ maxColorAlpha: maxColorAlpha,
1617
1632
  colorDiff: computeColorDiffUnits(sortedColorScalePoints[i - 1].value, sortedColorScalePoints[i].value, minColor, maxColor),
1618
1633
  });
1619
1634
  }
1620
1635
  return (value) => {
1621
1636
  if (value < thresholds[0].min) {
1622
- return colorNumberString(thresholds[0].minColor);
1637
+ return colorNumberToHex(thresholds[0].minColor, thresholds[0].minColorAlpha);
1623
1638
  }
1624
1639
  for (const threshold of thresholds) {
1625
1640
  if (value >= threshold.min && value <= threshold.max) {
1626
- return colorNumberString(colorCell(value, threshold.min, threshold.minColor, threshold.colorDiff));
1641
+ return colorNumberToHex(colorCell(value, threshold.min, threshold.minColor, threshold.colorDiff), threshold.maxColorAlpha);
1627
1642
  }
1628
1643
  }
1629
- return colorNumberString(thresholds[thresholds.length - 1].maxColor);
1644
+ return colorNumberToHex(thresholds[thresholds.length - 1].maxColor, thresholds[thresholds.length - 1].maxColorAlpha);
1630
1645
  };
1631
1646
  }
1632
1647
  function computeColorDiffUnits(minValue, maxValue, minColor, maxColor) {
@@ -19626,7 +19641,7 @@ const OFFSET = {
19626
19641
  right: startingCol + offsetWidth - 1,
19627
19642
  bottom: startingRow + offsetHeight - 1,
19628
19643
  };
19629
- const range = this.getters.getRangeFromZone(this.__originSheetId, dependencyZone);
19644
+ const range = this.getters.getRangeFromZone(sheetId, dependencyZone);
19630
19645
  if (range.invalidXc || range.invalidSheetName) {
19631
19646
  return new InvalidReferenceError();
19632
19647
  }
@@ -22762,6 +22777,7 @@ class ChartJsComponent extends owl.Component {
22762
22777
  this.animationStore = useStore(ChartAnimationStore);
22763
22778
  }
22764
22779
  owl.onMounted(() => {
22780
+ registerChartJSExtensions();
22765
22781
  const runtime = this.chartRuntime;
22766
22782
  this.currentRuntime = runtime;
22767
22783
  // Note: chartJS modify the runtime in place, so it's important to give it a copy
@@ -43817,7 +43833,7 @@ const insertDropdown = {
43817
43833
  env.openSidePanel("DataValidationEditor", {
43818
43834
  rule: localizeDataValidationRule(rule, env.model.getters.getLocale()),
43819
43835
  onExit: () => {
43820
- env.openSidePanel("DataValidation");
43836
+ env.replaceSidePanel("DataValidation", "DataValidationEditor");
43821
43837
  },
43822
43838
  });
43823
43839
  },
@@ -51845,16 +51861,16 @@ class ConditionalFormatPreview extends owl.Component {
51845
51861
  return cssPropertiesToCss(cellStyleToCss(rule.style));
51846
51862
  }
51847
51863
  else if (rule.type === "ColorScaleRule") {
51848
- const minColor = colorNumberString(rule.minimum.color);
51849
- const midColor = rule.midpoint ? colorNumberString(rule.midpoint.color) : null;
51850
- const maxColor = colorNumberString(rule.maximum.color);
51864
+ const minColor = colorNumberToHex(rule.minimum.color);
51865
+ const midColor = rule.midpoint ? colorNumberToHex(rule.midpoint.color) : null;
51866
+ const maxColor = colorNumberToHex(rule.maximum.color);
51851
51867
  const baseString = "background-image: linear-gradient(to right, ";
51852
51868
  return midColor
51853
51869
  ? baseString + minColor + ", " + midColor + ", " + maxColor + ")"
51854
51870
  : baseString + minColor + ", " + maxColor + ")";
51855
51871
  }
51856
51872
  else if (rule.type === "DataBarRule") {
51857
- const color = colorNumberString(rule.color);
51873
+ const color = colorNumberToHex(rule.color);
51858
51874
  return `background-image: linear-gradient(to right, ${color} 50%, white 50%)`;
51859
51875
  }
51860
51876
  return "";
@@ -52062,7 +52078,7 @@ class ConditionalFormattingEditor extends owl.Component {
52062
52078
  icons = ICONS;
52063
52079
  iconSets = ICON_SETS;
52064
52080
  getTextDecoration = getTextDecoration;
52065
- colorNumberString = colorNumberString;
52081
+ colorNumberToHex = colorNumberToHex;
52066
52082
  state;
52067
52083
  setup() {
52068
52084
  this.state = owl.useState({
@@ -52313,9 +52329,9 @@ class ConditionalFormattingEditor extends owl.Component {
52313
52329
  }
52314
52330
  getPreviewGradient() {
52315
52331
  const rule = this.state.rules.colorScale;
52316
- const minColor = colorNumberString(rule.minimum.color);
52317
- const midColor = colorNumberString(rule.midpoint?.color || DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52318
- const maxColor = colorNumberString(rule.maximum.color);
52332
+ const minColor = colorNumberToHex(rule.minimum.color);
52333
+ const midColor = colorNumberToHex(rule.midpoint?.color || DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52334
+ const maxColor = colorNumberToHex(rule.maximum.color);
52319
52335
  const baseString = "background-image: linear-gradient(to right, ";
52320
52336
  return rule.midpoint === undefined
52321
52337
  ? baseString + minColor + ", " + maxColor + ")"
@@ -52323,8 +52339,8 @@ class ConditionalFormattingEditor extends owl.Component {
52323
52339
  }
52324
52340
  getThresholdColor(threshold) {
52325
52341
  return threshold
52326
- ? colorNumberString(threshold.color)
52327
- : colorNumberString(DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52342
+ ? colorNumberToHex(threshold.color)
52343
+ : colorNumberToHex(DEFAULT_COLOR_SCALE_MIDPOINT_COLOR);
52328
52344
  }
52329
52345
  onMidpointChange(ev) {
52330
52346
  const type = ev.target.value;
@@ -53637,11 +53653,15 @@ class PivotMeasureDisplayPanel extends owl.Component {
53637
53653
  this.store = useLocalStore(PivotMeasureDisplayPanelStore, this.props.pivotId, this.props.measure);
53638
53654
  }
53639
53655
  onSave() {
53640
- this.env.openSidePanel("PivotSidePanel", { pivotId: this.props.pivotId });
53656
+ this.env.replaceSidePanel("PivotSidePanel", `pivot_measure_display_${this.props.pivotId}_${this.props.measure.id}`, {
53657
+ pivotId: this.props.pivotId,
53658
+ });
53641
53659
  }
53642
53660
  onCancel() {
53643
53661
  this.store.cancelMeasureDisplayEdition();
53644
- this.env.openSidePanel("PivotSidePanel", { pivotId: this.props.pivotId });
53662
+ this.env.replaceSidePanel("PivotSidePanel", `pivot_measure_display_${this.props.pivotId}_${this.props.measure.id}`, {
53663
+ pivotId: this.props.pivotId,
53664
+ });
53645
53665
  }
53646
53666
  get fieldChoices() {
53647
53667
  return this.store.fields.map((field) => ({
@@ -54103,7 +54123,7 @@ class PivotMeasureEditor extends owl.Component {
54103
54123
  });
54104
54124
  }
54105
54125
  openShowValuesAs() {
54106
- this.env.openSidePanel("PivotMeasureDisplayPanel", {
54126
+ this.env.replaceSidePanel("PivotMeasureDisplayPanel", `pivot_key_${this.props.pivotId}`, {
54107
54127
  pivotId: this.props.pivotId,
54108
54128
  measure: this.props.measure,
54109
54129
  });
@@ -54363,7 +54383,7 @@ class PivotLayoutConfigurator extends owl.Component {
54363
54383
  this.props.onDimensionsUpdated(update);
54364
54384
  }
54365
54385
  getMeasureId(fieldName, aggregator) {
54366
- const baseId = fieldName + (aggregator ? `:${aggregator}` : "");
54386
+ const baseId = fieldName.replaceAll("'", "") + (aggregator ? `:${aggregator}` : "");
54367
54387
  let id = baseId;
54368
54388
  let i = 2;
54369
54389
  while (this.props.definition.measures.some((m) => m.id === id)) {
@@ -57202,7 +57222,11 @@ sidePanelRegistry.add("PivotMeasureDisplayPanel", {
57202
57222
  try {
57203
57223
  // This will throw if the pivot or measure does not exist
57204
57224
  getters.getPivot(props.pivotId).getMeasure(props.measure.id);
57205
- return { isOpen: true, props, key: "pivot_measure_display" };
57225
+ return {
57226
+ isOpen: true,
57227
+ props,
57228
+ key: `pivot_measure_display_${props.pivotId}_${props.measure.id}`,
57229
+ };
57206
57230
  }
57207
57231
  catch (e) {
57208
57232
  return { isOpen: false };
@@ -57227,6 +57251,7 @@ const MIN_SHEET_VIEW_WIDTH = 150;
57227
57251
  class SidePanelStore extends SpreadsheetStore {
57228
57252
  mutators = [
57229
57253
  "open",
57254
+ "replace",
57230
57255
  "toggle",
57231
57256
  "close",
57232
57257
  "changePanelSize",
@@ -57288,8 +57313,7 @@ class SidePanelStore extends SpreadsheetStore {
57288
57313
  if (!state.isOpen) {
57289
57314
  return;
57290
57315
  }
57291
- const mainPanelKey = this.mainPanel ? this.getPanelKey(this.mainPanel) : undefined;
57292
- if (!this.mainPanel || !this.mainPanel.isPinned || mainPanelKey === state.key) {
57316
+ if (!this.mainPanel || !this.mainPanel.isPinned || this.mainPanelKey === state.key) {
57293
57317
  this._openPanel("mainPanel", newPanelInfo, state);
57294
57318
  return;
57295
57319
  }
@@ -57308,6 +57332,34 @@ class SidePanelStore extends SpreadsheetStore {
57308
57332
  }
57309
57333
  this._openPanel("secondaryPanel", newPanelInfo, state);
57310
57334
  }
57335
+ replace(componentTag, currentPanelKey, initialPanelProps = {}) {
57336
+ const newPanelInfo = { initialPanelProps, componentTag, size: DEFAULT_SIDE_PANEL_SIZE };
57337
+ const state = this.computeState(newPanelInfo);
57338
+ if (!state.isOpen) {
57339
+ return;
57340
+ }
57341
+ const ensureMainPanelExpanded = () => {
57342
+ if (this.mainPanel?.isCollapsed) {
57343
+ this.toggleCollapsePanel("mainPanel");
57344
+ }
57345
+ };
57346
+ // Close the current panel if the target panel is already open
57347
+ const isMainPanel = this.mainPanelKey === state.key;
57348
+ const isSecondaryPanel = this.secondaryPanelKey === state.key;
57349
+ if (isMainPanel && this.secondaryPanel) {
57350
+ this.close();
57351
+ ensureMainPanelExpanded();
57352
+ return;
57353
+ }
57354
+ if (isSecondaryPanel) {
57355
+ this.closeMainPanel();
57356
+ this.togglePinPanel();
57357
+ ensureMainPanelExpanded();
57358
+ return;
57359
+ }
57360
+ const targetPanel = this.mainPanelKey === currentPanelKey ? "mainPanel" : "secondaryPanel";
57361
+ this._openPanel(targetPanel, newPanelInfo, state);
57362
+ }
57311
57363
  _openPanel(panel, newPanel, state) {
57312
57364
  const currentPanel = this[panel];
57313
57365
  if (currentPanel && newPanel.componentTag !== currentPanel.componentTag) {
@@ -57367,11 +57419,9 @@ class SidePanelStore extends SpreadsheetStore {
57367
57419
  panelInfo.size = size;
57368
57420
  }
57369
57421
  resetPanelSize(panel) {
57370
- const panelInfo = this[panel];
57371
- if (!panelInfo) {
57372
- return;
57422
+ if (this[panel]) {
57423
+ this[panel].size = DEFAULT_SIDE_PANEL_SIZE;
57373
57424
  }
57374
- panelInfo.size = DEFAULT_SIDE_PANEL_SIZE;
57375
57425
  }
57376
57426
  togglePinPanel() {
57377
57427
  if (!this.mainPanel) {
@@ -66547,9 +66597,9 @@ class CustomColorsPlugin extends CoreViewPlugin {
66547
66597
  formatColors.push(rule.style.fillColor);
66548
66598
  }
66549
66599
  else if (rule.type === "ColorScaleRule") {
66550
- formatColors.push(colorNumberString(rule.minimum.color));
66551
- formatColors.push(rule.midpoint ? colorNumberString(rule.midpoint.color) : undefined);
66552
- formatColors.push(colorNumberString(rule.maximum.color));
66600
+ formatColors.push(colorNumberToHex(rule.minimum.color));
66601
+ formatColors.push(rule.midpoint ? colorNumberToHex(rule.midpoint.color) : undefined);
66602
+ formatColors.push(colorNumberToHex(rule.maximum.color));
66553
66603
  }
66554
66604
  }
66555
66605
  return formatColors.filter(isDefined);
@@ -66920,7 +66970,7 @@ class EvaluationConditionalFormatPlugin extends CoreViewPlugin {
66920
66970
  if (!computedDataBars[col])
66921
66971
  computedDataBars[col] = [];
66922
66972
  computedDataBars[col][row] = {
66923
- color: colorNumberString(color),
66973
+ color: colorNumberToHex(color),
66924
66974
  percentage: (cell.value * 100) / max,
66925
66975
  };
66926
66976
  }
@@ -77765,9 +77815,7 @@ class ClickableCellsStore extends SpreadsheetStore {
77765
77815
  }
77766
77816
  if (!(xc in clickableCells[sheetId])) {
77767
77817
  const clickableCell = this.findClickableItem(position);
77768
- if (clickableCell) {
77769
- clickableCells[sheetId][xc] = clickableCell;
77770
- }
77818
+ clickableCells[sheetId][xc] = clickableCell;
77771
77819
  }
77772
77820
  return clickableCells[sheetId][xc];
77773
77821
  }
@@ -79937,7 +79985,6 @@ css /* scss */ `
79937
79985
  }
79938
79986
  }
79939
79987
 
79940
- .o-spreadsheet-topbar-wrapper,
79941
79988
  .o-spreadsheet-bottombar-wrapper {
79942
79989
  z-index: ${ComponentsImportance.ScrollBar + 1};
79943
79990
  }
@@ -80010,6 +80057,7 @@ class Spreadsheet extends owl.Component {
80010
80057
  loadLocales: this.model.config.external.loadLocales,
80011
80058
  isDashboard: () => this.model.getters.isDashboard(),
80012
80059
  openSidePanel: this.sidePanel.open.bind(this.sidePanel),
80060
+ replaceSidePanel: this.sidePanel.replace.bind(this.sidePanel),
80013
80061
  toggleSidePanel: this.sidePanel.toggle.bind(this.sidePanel),
80014
80062
  clipboard: this.env.clipboard || instantiateClipboard(),
80015
80063
  startCellEdition: (content) => this.composerFocusStore.focusActiveComposer({ content }),
@@ -80052,7 +80100,6 @@ class Spreadsheet extends owl.Component {
80052
80100
  this.checkViewportSize();
80053
80101
  stores.on("store-updated", this, render);
80054
80102
  resizeObserver.observe(this.spreadsheetRef.el);
80055
- registerChartJSExtensions();
80056
80103
  });
80057
80104
  owl.onWillUnmount(() => {
80058
80105
  this.unbindModelEvents();
@@ -82585,7 +82632,7 @@ function addDataBarRule(cf, rule) {
82585
82632
  <dataBar>
82586
82633
  <cfvo type="min" val="0"/>
82587
82634
  <cfvo type="max" val="100"/>
82588
- <color rgb="${toXlsxHexColor(colorNumberString(rule.color))}"/>
82635
+ <color rgb="${toXlsxHexColor(colorNumberToHex(rule.color))}"/>
82589
82636
  </dataBar>
82590
82637
  </cfRule>
82591
82638
  </conditionalFormatting>
@@ -82613,7 +82660,7 @@ function addColorScaleRule(cf, rule) {
82613
82660
  continue;
82614
82661
  }
82615
82662
  cfValueObject.push(thresholdAttributes(threshold, position));
82616
- colors.push([["rgb", toXlsxHexColor(colorNumberString(threshold.color))]]);
82663
+ colors.push([["rgb", toXlsxHexColor(colorNumberToHex(threshold.color))]]);
82617
82664
  }
82618
82665
  if (!canExport) {
82619
82666
  console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");
@@ -84672,6 +84719,6 @@ exports.tokenColors = tokenColors;
84672
84719
  exports.tokenize = tokenize;
84673
84720
 
84674
84721
 
84675
- __info__.version = "18.4.4";
84676
- __info__.date = "2025-07-30T11:20:08.639Z";
84677
- __info__.hash = "b14de14";
84722
+ __info__.version = "18.4.6";
84723
+ __info__.date = "2025-08-18T08:16:33.453Z";
84724
+ __info__.hash = "9c7c143";
@@ -4294,6 +4294,7 @@ interface SpreadsheetChildEnv extends NotificationStoreMethods {
4294
4294
  imageProvider?: ImageProviderInterface;
4295
4295
  isDashboard: () => boolean;
4296
4296
  openSidePanel: (panel: string, panelProps?: any) => void;
4297
+ replaceSidePanel: (panel: string, currentPanel: string, panelProps?: any) => void;
4297
4298
  toggleSidePanel: (panel: string, panelProps?: any) => void;
4298
4299
  clipboard: ClipboardInterface;
4299
4300
  startCellEdition: (content?: string) => void;
@@ -9139,7 +9140,7 @@ interface PanelInfo {
9139
9140
  isCollapsed?: boolean;
9140
9141
  }
9141
9142
  declare class SidePanelStore extends SpreadsheetStore {
9142
- mutators: readonly ["open", "toggle", "close", "changePanelSize", "resetPanelSize", "togglePinPanel", "closeMainPanel", "changeSpreadsheetWidth", "toggleCollapsePanel"];
9143
+ mutators: readonly ["open", "replace", "toggle", "close", "changePanelSize", "resetPanelSize", "togglePinPanel", "closeMainPanel", "changeSpreadsheetWidth", "toggleCollapsePanel"];
9143
9144
  mainPanel: (PanelInfo & {
9144
9145
  isCollapsed?: boolean;
9145
9146
  isPinned?: boolean;
@@ -9161,6 +9162,7 @@ declare class SidePanelStore extends SpreadsheetStore {
9161
9162
  private getPanelProps;
9162
9163
  private getPanelKey;
9163
9164
  open(componentTag: string, initialPanelProps?: SidePanelComponentProps): void;
9165
+ replace(componentTag: string, currentPanelKey: string, initialPanelProps?: SidePanelComponentProps): void;
9164
9166
  private _openPanel;
9165
9167
  toggle(componentTag: string, panelProps: SidePanelComponentProps): void;
9166
9168
  close(): void;