@odoo/o-spreadsheet 18.5.0-alpha.3 → 18.5.0-alpha.4

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.5.0-alpha.3
6
- * @date 2025-07-28T13:43:05.981Z
7
- * @hash 53dfee8
5
+ * @version 18.5.0-alpha.4
6
+ * @date 2025-07-30T11:23:18.805Z
7
+ * @hash 34a4ab3
8
8
  */
9
9
 
10
10
  'use strict';
@@ -8640,12 +8640,12 @@ const AGGREGATOR_NAMES = {
8640
8640
  avg: _t("Average"),
8641
8641
  sum: _t("Sum"),
8642
8642
  };
8643
- const NUMBER_CHAR_AGGREGATORS = ["max", "min", "avg", "sum", "count_distinct", "count"];
8643
+ const DEFAULT_AGGREGATORS = ["max", "min", "avg", "sum", "count_distinct", "count"];
8644
8644
  const AGGREGATORS_BY_FIELD_TYPE = {
8645
- integer: NUMBER_CHAR_AGGREGATORS,
8646
- char: NUMBER_CHAR_AGGREGATORS,
8645
+ integer: DEFAULT_AGGREGATORS,
8646
+ char: DEFAULT_AGGREGATORS,
8647
+ datetime: DEFAULT_AGGREGATORS,
8647
8648
  boolean: ["count_distinct", "count", "bool_and", "bool_or"],
8648
- datetime: ["max", "min", "count_distinct", "count"],
8649
8649
  };
8650
8650
  const AGGREGATORS = {};
8651
8651
  for (const type in AGGREGATORS_BY_FIELD_TYPE) {
@@ -30517,28 +30517,17 @@ class MenuPopover extends owl.Component {
30517
30517
  }
30518
30518
  }
30519
30519
 
30520
- class ChartDashboardMenu extends owl.Component {
30521
- static template = "spreadsheet.ChartDashboardMenu";
30522
- static components = { MenuPopover };
30523
- static props = { figureUI: Object };
30520
+ class ChartDashboardMenuStore extends SpreadsheetStore {
30521
+ chartId;
30522
+ mutators = ["reset"];
30524
30523
  originalChartDefinition;
30525
- fullScreenFigureStore;
30526
- menuState = owl.useState({ isOpen: false, anchorRect: null, menuItems: [] });
30527
- setup() {
30528
- super.setup();
30529
- this.fullScreenFigureStore = useStore(FullScreenChartStore);
30530
- this.originalChartDefinition = this.env.model.getters.getChartDefinition(this.props.figureUI.id);
30531
- owl.onWillUpdateProps(({ figureUI }) => {
30532
- if (figureUI.id !== this.props.figureUI.id) {
30533
- this.originalChartDefinition = this.env.model.getters.getChartDefinition(figureUI.id);
30534
- }
30535
- });
30536
- }
30537
- getMenuItems() {
30538
- return [this.fullScreenMenuItem, ...this.changeChartTypeMenuItems].filter(isDefined);
30524
+ constructor(get, chartId) {
30525
+ super(get);
30526
+ this.chartId = chartId;
30527
+ this.originalChartDefinition = this.getters.getChartDefinition(this.chartId);
30539
30528
  }
30540
30529
  get changeChartTypeMenuItems() {
30541
- const definition = this.env.model.getters.getChartDefinition(this.props.figureUI.id);
30530
+ const definition = this.getters.getChartDefinition(this.chartId);
30542
30531
  if (!["line", "bar", "pie"].includes(definition.type)) {
30543
30532
  return [];
30544
30533
  }
@@ -30547,27 +30536,19 @@ class ChartDashboardMenu extends owl.Component {
30547
30536
  return {
30548
30537
  id: item.chartType,
30549
30538
  label: item.displayName,
30550
- onClick: () => this.onTypeChange(item.chartType),
30551
- isSelected: item.chartType === this.selectedChartType,
30539
+ onClick: () => this.updateType(item.chartType),
30540
+ isSelected: item.chartType === this.getters.getChartDefinition(this.chartId).type,
30552
30541
  iconClass: this.getIconClasses(item.chartType),
30553
30542
  };
30554
30543
  });
30555
30544
  }
30556
- getIconClasses(type) {
30557
- if (type.includes("bar")) {
30558
- return "fa fa-bar-chart";
30559
- }
30560
- if (type.includes("line")) {
30561
- return "fa fa-line-chart";
30562
- }
30563
- if (type.includes("pie")) {
30564
- return "fa fa-pie-chart";
30565
- }
30566
- return "";
30545
+ reset(chartId) {
30546
+ this.chartId = chartId;
30547
+ this.originalChartDefinition = this.getters.getChartDefinition(chartId);
30567
30548
  }
30568
- onTypeChange(type) {
30569
- const figureId = this.props.figureUI.id;
30570
- const currentDefinition = this.env.model.getters.getChartDefinition(figureId);
30549
+ updateType(type) {
30550
+ const figureId = this.chartId;
30551
+ const currentDefinition = this.getters.getChartDefinition(figureId);
30571
30552
  if (currentDefinition.type === type) {
30572
30553
  return;
30573
30554
  }
@@ -30578,7 +30559,7 @@ class ChartDashboardMenu extends owl.Component {
30578
30559
  else {
30579
30560
  const newChartInfo = chartSubtypeRegistry.get(type);
30580
30561
  const ChartClass = chartRegistry.get(newChartInfo.chartType);
30581
- const chartCreationContext = this.env.model.getters.getContextCreationChart(figureId);
30562
+ const chartCreationContext = this.getters.getContextCreationChart(figureId);
30582
30563
  if (!chartCreationContext)
30583
30564
  return;
30584
30565
  definition = {
@@ -30586,14 +30567,45 @@ class ChartDashboardMenu extends owl.Component {
30586
30567
  ...newChartInfo.subtypeDefinition,
30587
30568
  };
30588
30569
  }
30589
- this.env.model.dispatch("UPDATE_CHART", {
30570
+ this.model.dispatch("UPDATE_CHART", {
30590
30571
  definition,
30591
30572
  figureId,
30592
- sheetId: this.env.model.getters.getActiveSheetId(),
30573
+ sheetId: this.getters.getActiveSheetId(),
30574
+ });
30575
+ }
30576
+ getIconClasses(type) {
30577
+ if (type.includes("bar")) {
30578
+ return "fa fa-bar-chart";
30579
+ }
30580
+ if (type.includes("line")) {
30581
+ return "fa fa-line-chart";
30582
+ }
30583
+ if (type.includes("pie")) {
30584
+ return "fa fa-pie-chart";
30585
+ }
30586
+ return "";
30587
+ }
30588
+ }
30589
+
30590
+ class ChartDashboardMenu extends owl.Component {
30591
+ static template = "o-spreadsheet-ChartDashboardMenu";
30592
+ static components = { MenuPopover };
30593
+ static props = { figureUI: Object };
30594
+ fullScreenFigureStore;
30595
+ store;
30596
+ menuState = owl.useState({ isOpen: false, anchorRect: null, menuItems: [] });
30597
+ setup() {
30598
+ super.setup();
30599
+ this.store = useLocalStore(ChartDashboardMenuStore, this.props.figureUI.id);
30600
+ this.fullScreenFigureStore = useStore(FullScreenChartStore);
30601
+ owl.onWillUpdateProps(({ figureUI }) => {
30602
+ if (figureUI.id !== this.props.figureUI.id) {
30603
+ this.store.reset(figureUI.id);
30604
+ }
30593
30605
  });
30594
30606
  }
30595
- get selectedChartType() {
30596
- return this.env.model.getters.getChartDefinition(this.props.figureUI.id).type;
30607
+ getMenuItems() {
30608
+ return [this.fullScreenMenuItem, ...this.store.changeChartTypeMenuItems].filter(isDefined);
30597
30609
  }
30598
30610
  get backgroundColor() {
30599
30611
  const color = this.env.model.getters.getChartDefinition(this.props.figureUI.id).background;
@@ -31735,7 +31747,7 @@ criterionEvaluatorRegistry.add("isValueInRange", {
31735
31747
  }
31736
31748
  const criterionValues = getters.getDataValidationRangeValues(sheetId, criterion);
31737
31749
  return criterionValues
31738
- .map((value) => value.toLowerCase())
31750
+ .map((value) => value.value.toLowerCase())
31739
31751
  .includes(value.toString().toLowerCase());
31740
31752
  },
31741
31753
  getErrorString: (criterion) => _t("The value must be a value in the range %s", String(criterion.values[0])),
@@ -52112,7 +52124,8 @@ class ConditionalFormattingEditor extends owl.Component {
52112
52124
  static props = {
52113
52125
  editedCf: Object,
52114
52126
  onCancel: Function,
52115
- onSave: Function,
52127
+ onExit: Function,
52128
+ isNewCf: Boolean,
52116
52129
  };
52117
52130
  static components = {
52118
52131
  SelectionInput,
@@ -52137,6 +52150,7 @@ class ConditionalFormattingEditor extends owl.Component {
52137
52150
  currentCFType: this.props.editedCf.rule.type,
52138
52151
  ranges: this.props.editedCf.ranges,
52139
52152
  rules: this.getDefaultRules(),
52153
+ hasEditedCf: this.props.isNewCf,
52140
52154
  });
52141
52155
  switch (this.props.editedCf.rule.type) {
52142
52156
  case "CellIsRule":
@@ -52188,6 +52202,9 @@ class ConditionalFormattingEditor extends owl.Component {
52188
52202
  ranges: ranges.map((xc) => this.env.model.getters.getRangeDataFromXc(sheetId, xc)),
52189
52203
  sheetId,
52190
52204
  });
52205
+ if (result.isSuccessful) {
52206
+ this.state.hasEditedCf = true;
52207
+ }
52191
52208
  const reasons = result.reasons.filter((r) => r !== "NoChanges" /* CommandResult.NoChanges */);
52192
52209
  if (!newCf.suppressErrors) {
52193
52210
  this.state.errors = reasons;
@@ -52209,7 +52226,15 @@ class ConditionalFormattingEditor extends owl.Component {
52209
52226
  onSave() {
52210
52227
  const result = this.updateConditionalFormat({});
52211
52228
  if (result.length === 0) {
52212
- this.props.onSave();
52229
+ this.props.onExit();
52230
+ }
52231
+ }
52232
+ onCancel() {
52233
+ if (this.state.hasEditedCf) {
52234
+ this.props.onCancel();
52235
+ }
52236
+ else {
52237
+ this.props.onExit();
52213
52238
  }
52214
52239
  }
52215
52240
  getDefaultRules() {
@@ -67105,8 +67130,16 @@ class EvaluationDataValidationPlugin extends CoreViewPlugin {
67105
67130
  }
67106
67131
  getDataValidationRangeValues(sheetId, criterion) {
67107
67132
  const range = this.getters.getRangeFromSheetXC(sheetId, String(criterion.values[0]));
67108
- const criterionValues = this.getters.getRangeValues(range);
67109
- return criterionValues.map((value) => value?.toString()).filter(isDefined);
67133
+ const values = [];
67134
+ const labelsSet = new Set();
67135
+ for (const p of positions(range.zone)) {
67136
+ const cell = this.getters.getEvaluatedCell({ ...p, sheetId: range.sheetId });
67137
+ if (cell.formattedValue && !labelsSet.has(cell.formattedValue)) {
67138
+ labelsSet.add(cell.formattedValue);
67139
+ values.push({ label: cell.formattedValue, value: cell.value?.toString() || "" });
67140
+ }
67141
+ }
67142
+ return values;
67110
67143
  }
67111
67144
  isCellValidCheckbox(cellPosition) {
67112
67145
  if (!this.getters.isMainCellPosition(cellPosition)) {
@@ -75728,25 +75761,30 @@ autoCompleteProviders.add("dataValidation", {
75728
75761
  }
75729
75762
  const sheetId = this.composer.currentEditedCell.sheetId;
75730
75763
  const values = rule.criterion.type === "isValueInRange"
75731
- ? Array.from(new Set(this.getters.getDataValidationRangeValues(sheetId, rule.criterion)))
75732
- : rule.criterion.values;
75764
+ ? this.getters.getDataValidationRangeValues(sheetId, rule.criterion)
75765
+ : rule.criterion.values.map((value) => ({ label: value, value }));
75733
75766
  const isChip = rule.criterion.displayStyle === "chip";
75734
75767
  if (!isChip) {
75735
- return values.map((value) => ({ text: value }));
75768
+ return values.map((value) => ({
75769
+ text: value.value,
75770
+ fuzzySearchKey: value.label,
75771
+ htmlContent: [{ value: value.label }],
75772
+ }));
75736
75773
  }
75737
75774
  const colors = rule.criterion.colors;
75738
75775
  return values.map((value) => {
75739
- const color = colors?.[value];
75776
+ const color = colors?.[value.value];
75740
75777
  return {
75741
- text: value,
75778
+ text: value.value,
75742
75779
  htmlContent: [
75743
75780
  {
75744
- value,
75781
+ value: value.label,
75745
75782
  color: color ? chipTextColor(color) : undefined,
75746
75783
  backgroundColor: color || GRAY_200,
75747
75784
  classes: ["badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start"],
75748
75785
  },
75749
75786
  ],
75787
+ fuzzySearchKey: value.label,
75750
75788
  };
75751
75789
  });
75752
75790
  },
@@ -84720,6 +84758,8 @@ const components = {
84720
84758
  WaterfallChartDesignPanel,
84721
84759
  ComboChartDesignPanel,
84722
84760
  FunnelChartDesignPanel,
84761
+ SunburstChartDesignPanel,
84762
+ TreeMapChartDesignPanel,
84723
84763
  ChartTypePicker,
84724
84764
  FigureComponent,
84725
84765
  MenuPopover,
@@ -84749,6 +84789,7 @@ const hooks = {
84749
84789
  };
84750
84790
  const stores = {
84751
84791
  useStoreProvider,
84792
+ ChartDashboardMenuStore,
84752
84793
  DependencyContainer,
84753
84794
  CellPopoverStore,
84754
84795
  ComposerFocusStore,
@@ -84835,6 +84876,6 @@ exports.tokenColors = tokenColors;
84835
84876
  exports.tokenize = tokenize;
84836
84877
 
84837
84878
 
84838
- __info__.version = "18.5.0-alpha.3";
84839
- __info__.date = "2025-07-28T13:43:05.981Z";
84840
- __info__.hash = "53dfee8";
84879
+ __info__.version = "18.5.0-alpha.4";
84880
+ __info__.date = "2025-07-30T11:23:18.805Z";
84881
+ __info__.hash = "34a4ab3";