@odoo/o-spreadsheet 16.1.12 → 16.1.14

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.
@@ -1707,27 +1707,36 @@ function removeTrailingZeroes(numberString) {
1707
1707
  }
1708
1708
  return numberString.slice(0, i + 1) || undefined;
1709
1709
  }
1710
+ const leadingZeroesRegexp = /^0+/;
1710
1711
  /**
1711
1712
  * Limit the size of the decimal part of a number to the given number of digits.
1712
1713
  */
1713
1714
  function limitDecimalDigits(decimalDigits, maxDecimals) {
1715
+ var _a;
1714
1716
  let integerDigits = "0";
1715
1717
  let resultDecimalDigits = decimalDigits;
1716
1718
  // Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
1717
1719
  // but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
1718
1720
  let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
1719
1721
  const i = maxDecimals;
1720
- if (Number(Number(decimalDigits[i]) < 5)) {
1722
+ if (Number(decimalDigits[i]) < 5) {
1721
1723
  return { integerDigits, decimalDigits: slicedDecimalDigits };
1722
1724
  }
1723
1725
  // round up
1726
+ const leadingZeroes = ((_a = slicedDecimalDigits.match(leadingZeroesRegexp)) === null || _a === void 0 ? void 0 : _a[0]) || "";
1724
1727
  const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
1725
- if (slicedRoundedUp.length > slicedDecimalDigits.length) {
1726
- integerDigits = (Number(integerDigits) + 1).toString();
1728
+ const withoutLeadingZeroes = slicedDecimalDigits.slice(leadingZeroes.length);
1729
+ // e.g. carry over from 99 to 100
1730
+ const carryOver = slicedRoundedUp.length > withoutLeadingZeroes.length;
1731
+ if (carryOver && !leadingZeroes) {
1732
+ integerDigits = "1";
1727
1733
  resultDecimalDigits = undefined;
1728
1734
  }
1735
+ else if (carryOver) {
1736
+ resultDecimalDigits = leadingZeroes.slice(0, -1) + slicedRoundedUp;
1737
+ }
1729
1738
  else {
1730
- resultDecimalDigits = slicedRoundedUp;
1739
+ resultDecimalDigits = leadingZeroes + slicedRoundedUp;
1731
1740
  }
1732
1741
  return { integerDigits, decimalDigits: resultDecimalDigits };
1733
1742
  }
@@ -17345,6 +17354,7 @@ class Composer extends owl.Component {
17345
17354
  (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
17346
17355
  }
17347
17356
  }
17357
+ this.updateCursorIfNeeded();
17348
17358
  }
17349
17359
  processTabKey(ev) {
17350
17360
  var _a;
@@ -17403,9 +17413,12 @@ class Composer extends owl.Component {
17403
17413
  }
17404
17414
  else {
17405
17415
  ev.stopPropagation();
17416
+ this.updateCursorIfNeeded();
17406
17417
  }
17407
- const { start, end } = this.contentHelper.getCurrentSelection();
17418
+ }
17419
+ updateCursorIfNeeded() {
17408
17420
  if (!this.env.model.getters.isSelectingForComposer()) {
17421
+ const { start, end } = this.contentHelper.getCurrentSelection();
17409
17422
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
17410
17423
  this.isKeyStillDown = true;
17411
17424
  }
@@ -19943,7 +19956,7 @@ class LineBarPieConfigPanel extends owl.Component {
19943
19956
  return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
19944
19957
  }
19945
19958
  onUpdateDataSetsHaveTitle(ev) {
19946
- this.props.updateChart({
19959
+ this.props.updateChart(this.props.figureId, {
19947
19960
  dataSetsHaveTitle: ev.target.checked,
19948
19961
  });
19949
19962
  }
@@ -19955,7 +19968,7 @@ class LineBarPieConfigPanel extends owl.Component {
19955
19968
  this.dataSeriesRanges = ranges;
19956
19969
  }
19957
19970
  onDataSeriesConfirmed() {
19958
- this.state.datasetDispatchResult = this.props.updateChart({
19971
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
19959
19972
  dataSets: this.dataSeriesRanges,
19960
19973
  });
19961
19974
  }
@@ -19967,12 +19980,12 @@ class LineBarPieConfigPanel extends owl.Component {
19967
19980
  this.labelRange = ranges[0];
19968
19981
  }
19969
19982
  onLabelRangeConfirmed() {
19970
- this.state.labelsDispatchResult = this.props.updateChart({
19983
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
19971
19984
  labelRange: this.labelRange,
19972
19985
  });
19973
19986
  }
19974
19987
  onUpdateAggregated(ev) {
19975
- this.props.updateChart({
19988
+ this.props.updateChart(this.props.figureId, {
19976
19989
  aggregated: ev.target.checked,
19977
19990
  });
19978
19991
  }
@@ -19987,12 +20000,12 @@ LineBarPieConfigPanel.props = {
19987
20000
 
19988
20001
  class BarConfigPanel extends LineBarPieConfigPanel {
19989
20002
  onUpdateStacked(ev) {
19990
- this.props.updateChart({
20003
+ this.props.updateChart(this.props.figureId, {
19991
20004
  stacked: ev.target.checked,
19992
20005
  });
19993
20006
  }
19994
20007
  onUpdateAggregated(ev) {
19995
- this.props.updateChart({
20008
+ this.props.updateChart(this.props.figureId, {
19996
20009
  aggregated: ev.target.checked,
19997
20010
  });
19998
20011
  }
@@ -20036,6 +20049,7 @@ css /* scss */ `
20036
20049
  .o-color-picker-toggler {
20037
20050
  display: flex;
20038
20051
  .o-color-picker-toggler-sign {
20052
+ display: flex;
20039
20053
  margin: auto auto;
20040
20054
  width: 55%;
20041
20055
  height: 55%;
@@ -20270,17 +20284,17 @@ class LineBarPieDesignPanel extends owl.Component {
20270
20284
  this.state.fillColorTool = !this.state.fillColorTool;
20271
20285
  }
20272
20286
  updateBackgroundColor(color) {
20273
- this.props.updateChart({
20287
+ this.props.updateChart(this.props.figureId, {
20274
20288
  background: color,
20275
20289
  });
20276
20290
  }
20277
20291
  updateTitle(ev) {
20278
- this.props.updateChart({
20292
+ this.props.updateChart(this.props.figureId, {
20279
20293
  title: ev.target.value,
20280
20294
  });
20281
20295
  }
20282
20296
  updateSelect(attr, ev) {
20283
- this.props.updateChart({
20297
+ this.props.updateChart(this.props.figureId, {
20284
20298
  [attr]: ev.target.value,
20285
20299
  });
20286
20300
  }
@@ -20318,7 +20332,7 @@ class GaugeChartConfigPanel extends owl.Component {
20318
20332
  this.dataRange = ranges[0];
20319
20333
  }
20320
20334
  updateDataRange() {
20321
- this.state.dataRangeDispatchResult = this.props.updateChart({
20335
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
20322
20336
  dataRange: this.dataRange,
20323
20337
  });
20324
20338
  }
@@ -20393,12 +20407,12 @@ class GaugeChartDesignPanel extends owl.Component {
20393
20407
  }
20394
20408
  updateBackgroundColor(color) {
20395
20409
  this.state.openedMenu = undefined;
20396
- this.props.updateChart({
20410
+ this.props.updateChart(this.props.figureId, {
20397
20411
  background: color,
20398
20412
  });
20399
20413
  }
20400
20414
  updateTitle(ev) {
20401
- this.props.updateChart({
20415
+ this.props.updateChart(this.props.figureId, {
20402
20416
  title: ev.target.value,
20403
20417
  });
20404
20418
  }
@@ -20467,7 +20481,7 @@ class GaugeChartDesignPanel extends owl.Component {
20467
20481
  }
20468
20482
  }
20469
20483
  updateSectionRule(sectionRule) {
20470
- this.state.sectionRuleDispatchResult = this.props.updateChart({
20484
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
20471
20485
  sectionRule,
20472
20486
  });
20473
20487
  }
@@ -20492,17 +20506,17 @@ class LineConfigPanel extends LineBarPieConfigPanel {
20492
20506
  return false;
20493
20507
  }
20494
20508
  onUpdateLabelsAsText(ev) {
20495
- this.props.updateChart({
20509
+ this.props.updateChart(this.props.figureId, {
20496
20510
  labelsAsText: ev.target.checked,
20497
20511
  });
20498
20512
  }
20499
20513
  onUpdateStacked(ev) {
20500
- this.props.updateChart({
20514
+ this.props.updateChart(this.props.figureId, {
20501
20515
  stacked: ev.target.checked,
20502
20516
  });
20503
20517
  }
20504
20518
  onUpdateAggregated(ev) {
20505
- this.props.updateChart({
20519
+ this.props.updateChart(this.props.figureId, {
20506
20520
  aggregated: ev.target.checked,
20507
20521
  });
20508
20522
  }
@@ -20543,7 +20557,7 @@ class ScorecardChartConfigPanel extends owl.Component {
20543
20557
  this.keyValue = ranges[0];
20544
20558
  }
20545
20559
  updateKeyValueRange() {
20546
- this.state.keyValueDispatchResult = this.props.updateChart({
20560
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
20547
20561
  keyValue: this.keyValue,
20548
20562
  });
20549
20563
  }
@@ -20551,12 +20565,12 @@ class ScorecardChartConfigPanel extends owl.Component {
20551
20565
  this.baseline = ranges[0];
20552
20566
  }
20553
20567
  updateBaselineRange() {
20554
- this.state.baselineDispatchResult = this.props.updateChart({
20568
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
20555
20569
  baseline: this.baseline,
20556
20570
  });
20557
20571
  }
20558
20572
  updateBaselineMode(ev) {
20559
- this.props.updateChart({ baselineMode: ev.target.value });
20573
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
20560
20574
  }
20561
20575
  }
20562
20576
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
@@ -20581,12 +20595,12 @@ class ScorecardChartDesignPanel extends owl.Component {
20581
20595
  owl.useExternalListener(window, "click", this.onClick);
20582
20596
  }
20583
20597
  updateTitle(ev) {
20584
- this.props.updateChart({
20598
+ this.props.updateChart(this.props.figureId, {
20585
20599
  title: ev.target.value,
20586
20600
  });
20587
20601
  }
20588
20602
  updateBaselineDescr(ev) {
20589
- this.props.updateChart({ baselineDescr: ev.target.value });
20603
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
20590
20604
  }
20591
20605
  openColorPicker(colorPickerId) {
20592
20606
  this.state.openedColorPicker = colorPickerId;
@@ -20594,13 +20608,13 @@ class ScorecardChartDesignPanel extends owl.Component {
20594
20608
  setColor(color, colorPickerId) {
20595
20609
  switch (colorPickerId) {
20596
20610
  case "backgroundColor":
20597
- this.props.updateChart({ background: color });
20611
+ this.props.updateChart(this.props.figureId, { background: color });
20598
20612
  break;
20599
20613
  case "baselineColorDown":
20600
- this.props.updateChart({ baselineColorDown: color });
20614
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
20601
20615
  break;
20602
20616
  case "baselineColorUp":
20603
- this.props.updateChart({ baselineColorUp: color });
20617
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
20604
20618
  break;
20605
20619
  }
20606
20620
  this.state.openedColorPicker = undefined;
@@ -20669,16 +20683,9 @@ css /* scss */ `
20669
20683
  }
20670
20684
  `;
20671
20685
  class ChartPanel extends owl.Component {
20672
- constructor() {
20673
- super(...arguments);
20674
- this.shouldUpdateChart = true;
20675
- }
20676
20686
  get figureId() {
20677
20687
  return this.state.figureId;
20678
20688
  }
20679
- get sheetId() {
20680
- return this.state.sheetId;
20681
- }
20682
20689
  setup() {
20683
20690
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
20684
20691
  if (!selectedFigureId) {
@@ -20687,17 +20694,11 @@ class ChartPanel extends owl.Component {
20687
20694
  this.state = owl.useState({
20688
20695
  panel: "configuration",
20689
20696
  figureId: selectedFigureId,
20690
- sheetId: this.env.model.getters.getActiveSheetId(),
20691
20697
  });
20692
20698
  owl.onWillUpdateProps(() => {
20693
20699
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
20694
20700
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
20695
20701
  this.state.figureId = selectedFigureId;
20696
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
20697
- this.shouldUpdateChart = false;
20698
- }
20699
- else {
20700
- this.shouldUpdateChart = true;
20701
20702
  }
20702
20703
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
20703
20704
  this.props.onCloseSidePanel();
@@ -20705,8 +20706,8 @@ class ChartPanel extends owl.Component {
20705
20706
  }
20706
20707
  });
20707
20708
  }
20708
- updateChart(updateDefinition) {
20709
- if (!this.shouldUpdateChart) {
20709
+ updateChart(figureId, updateDefinition) {
20710
+ if (figureId !== this.figureId) {
20710
20711
  return;
20711
20712
  }
20712
20713
  const definition = {
@@ -20715,8 +20716,8 @@ class ChartPanel extends owl.Component {
20715
20716
  };
20716
20717
  return this.env.model.dispatch("UPDATE_CHART", {
20717
20718
  definition,
20718
- id: this.figureId,
20719
- sheetId: this.sheetId,
20719
+ id: figureId,
20720
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
20720
20721
  });
20721
20722
  }
20722
20723
  onTypeChange(type) {
@@ -20728,7 +20729,7 @@ class ChartPanel extends owl.Component {
20728
20729
  this.env.model.dispatch("UPDATE_CHART", {
20729
20730
  definition,
20730
20731
  id: this.figureId,
20731
- sheetId: this.sheetId,
20732
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
20732
20733
  });
20733
20734
  }
20734
20735
  get chartPanel() {
@@ -44271,6 +44272,6 @@ exports.setTranslationMethod = setTranslationMethod;
44271
44272
  exports.tokenize = tokenize;
44272
44273
 
44273
44274
 
44274
- __info__.version = '16.1.12';
44275
- __info__.date = '2023-05-25T12:56:29.735Z';
44276
- __info__.hash = 'b80dc51';
44275
+ __info__.version = '16.1.14';
44276
+ __info__.date = '2023-06-12T13:50:13.693Z';
44277
+ __info__.hash = 'a51d9fa';
@@ -5025,7 +5025,7 @@ declare class SelectionInput extends Component<Props$x, SpreadsheetChildEnv> {
5025
5025
  interface Props$w {
5026
5026
  figureId: UID;
5027
5027
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
5028
- updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
5028
+ updateChart: (figureId: UID, definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => DispatchResult;
5029
5029
  }
5030
5030
  declare class LineBarPieConfigPanel extends Component<Props$w, SpreadsheetChildEnv> {
5031
5031
  static template: string;
@@ -5091,7 +5091,7 @@ declare class ColorPicker extends Component<ColorPickerProps, SpreadsheetChildEn
5091
5091
  interface Props$v {
5092
5092
  figureId: UID;
5093
5093
  definition: LineChartDefinition | BarChartDefinition | PieChartDefinition;
5094
- updateChart: (definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => CommandResult | CommandResult[];
5094
+ updateChart: (figureId: UID, definition: Partial<LineChartDefinition | BarChartDefinition | PieChartDefinition>) => CommandResult | CommandResult[];
5095
5095
  }
5096
5096
  declare class LineBarPieDesignPanel extends Component<Props$v, SpreadsheetChildEnv> {
5097
5097
  static template: string;
@@ -5110,7 +5110,7 @@ declare class LineBarPieDesignPanel extends Component<Props$v, SpreadsheetChildE
5110
5110
  interface Props$u {
5111
5111
  figureId: UID;
5112
5112
  definition: GaugeChartDefinition;
5113
- updateChart: (definition: Partial<GaugeChartDefinition>) => DispatchResult;
5113
+ updateChart: (figureId: UID, definition: Partial<GaugeChartDefinition>) => DispatchResult;
5114
5114
  }
5115
5115
  declare class GaugeChartConfigPanel extends Component<Props$u, SpreadsheetChildEnv> {
5116
5116
  static template: string;
@@ -5129,7 +5129,7 @@ declare type GaugeMenu = "backgroundColor" | "sectionColor-lowerColor" | "sectio
5129
5129
  interface Props$t {
5130
5130
  figureId: UID;
5131
5131
  definition: GaugeChartDefinition;
5132
- updateChart: (definition: Partial<GaugeChartDefinition>) => DispatchResult;
5132
+ updateChart: (figureId: UID, definition: Partial<GaugeChartDefinition>) => DispatchResult;
5133
5133
  }
5134
5134
  declare class GaugeChartDesignPanel extends Component<Props$t, SpreadsheetChildEnv> {
5135
5135
  static template: string;
@@ -5167,7 +5167,7 @@ declare class LineConfigPanel extends LineBarPieConfigPanel {
5167
5167
  interface Props$s {
5168
5168
  figureId: UID;
5169
5169
  definition: ScorecardChartDefinition;
5170
- updateChart: (definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5170
+ updateChart: (figureId: UID, definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5171
5171
  }
5172
5172
  declare class ScorecardChartConfigPanel extends Component<Props$s, SpreadsheetChildEnv> {
5173
5173
  static template: string;
@@ -5191,7 +5191,7 @@ declare type ColorPickerId = undefined | "backgroundColor" | "baselineColorUp" |
5191
5191
  interface Props$r {
5192
5192
  figureId: UID;
5193
5193
  definition: ScorecardChartDefinition;
5194
- updateChart: (definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5194
+ updateChart: (figureId: UID, definition: Partial<ScorecardChartDefinition>) => DispatchResult;
5195
5195
  }
5196
5196
  declare class ScorecardChartDesignPanel extends Component<Props$r, SpreadsheetChildEnv> {
5197
5197
  static template: string;
@@ -5668,6 +5668,7 @@ declare class Composer extends Component<Props$j, SpreadsheetChildEnv> {
5668
5668
  onCompositionStart(): void;
5669
5669
  onCompositionEnd(): void;
5670
5670
  onKeydown(ev: KeyboardEvent): void;
5671
+ private updateCursorIfNeeded;
5671
5672
  onInput(): void;
5672
5673
  onKeyup(ev: KeyboardEvent): void;
5673
5674
  showAutocomplete(searchTerm: string): void;
@@ -6462,11 +6463,9 @@ interface Props {
6462
6463
  declare class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
6463
6464
  static template: string;
6464
6465
  private state;
6465
- private shouldUpdateChart;
6466
6466
  get figureId(): UID;
6467
- get sheetId(): UID;
6468
6467
  setup(): void;
6469
- updateChart<T extends ChartDefinition>(updateDefinition: Partial<T>): DispatchResult | undefined;
6468
+ updateChart<T extends ChartDefinition>(figureId: UID, updateDefinition: Partial<T>): DispatchResult | undefined;
6470
6469
  onTypeChange(type: ChartType): void;
6471
6470
  get chartPanel(): ChartSidePanel;
6472
6471
  private getChartDefinition;