@odoo/o-spreadsheet 16.3.9 → 16.3.11

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.
@@ -1030,13 +1030,17 @@ function getAddHeaderStartIndex(position, base) {
1030
1030
  return position === "after" ? base + 1 : base;
1031
1031
  }
1032
1032
  /**
1033
- * Compare two objects.
1033
+ * Compares two objects.
1034
1034
  */
1035
1035
  function deepEquals(o1, o2) {
1036
1036
  if (o1 === o2)
1037
1037
  return true;
1038
1038
  if ((o1 && !o2) || (o2 && !o1))
1039
1039
  return false;
1040
+ if (typeof o1 !== typeof o2)
1041
+ return false;
1042
+ if (typeof o1 !== "object")
1043
+ return o1 === o2;
1040
1044
  // Objects can have different keys if the values are undefined
1041
1045
  const keys = new Set();
1042
1046
  Object.keys(o1).forEach((key) => keys.add(key));
@@ -4802,6 +4806,7 @@ css /* scss */ `
4802
4806
  padding: 10px;
4803
4807
  width: ${ERROR_TOOLTIP_WIDTH}px;
4804
4808
  box-sizing: border-box !important;
4809
+ overflow-wrap: break-word;
4805
4810
  }
4806
4811
  `;
4807
4812
  class ErrorToolTip extends Component {
@@ -7462,6 +7467,7 @@ class LineChart extends AbstractChart {
7462
7467
  aggregated;
7463
7468
  type = "line";
7464
7469
  dataSetsHaveTitle;
7470
+ cumulative;
7465
7471
  constructor(definition, sheetId, getters) {
7466
7472
  super(definition, sheetId, getters);
7467
7473
  this.dataSets = createDataSets(this.getters, definition.dataSets, sheetId, definition.dataSetsHaveTitle);
@@ -7473,6 +7479,7 @@ class LineChart extends AbstractChart {
7473
7479
  this.stacked = definition.stacked;
7474
7480
  this.aggregated = definition.aggregated;
7475
7481
  this.dataSetsHaveTitle = definition.dataSetsHaveTitle;
7482
+ this.cumulative = definition.cumulative;
7476
7483
  }
7477
7484
  static validateChartDefinition(validator, definition) {
7478
7485
  return validator.checkValidations(definition, checkDataset, checkLabelRange);
@@ -7493,6 +7500,7 @@ class LineChart extends AbstractChart {
7493
7500
  labelRange: context.auxiliaryRange || undefined,
7494
7501
  stacked: false,
7495
7502
  aggregated: false,
7503
+ cumulative: false,
7496
7504
  };
7497
7505
  }
7498
7506
  getDefinition() {
@@ -7513,6 +7521,7 @@ class LineChart extends AbstractChart {
7513
7521
  labelsAsText: this.labelsAsText,
7514
7522
  stacked: this.stacked,
7515
7523
  aggregated: this.aggregated,
7524
+ cumulative: this.cumulative,
7516
7525
  };
7517
7526
  }
7518
7527
  getContextCreation() {
@@ -7721,6 +7730,16 @@ function createLineChartRuntime(chart, getters) {
7721
7730
  if (chart.stacked) {
7722
7731
  backgroundRGBA.a = LINE_FILL_TRANSPARENCY;
7723
7732
  }
7733
+ if (chart.cumulative) {
7734
+ let accumulator = 0;
7735
+ data = data.map((value) => {
7736
+ if (!isNaN(value)) {
7737
+ accumulator += parseFloat(value);
7738
+ return accumulator;
7739
+ }
7740
+ return value;
7741
+ });
7742
+ }
7724
7743
  const backgroundColor = rgbaToHex(backgroundRGBA);
7725
7744
  const dataset = {
7726
7745
  label,
@@ -8542,6 +8561,7 @@ function getSmartChartDefinition(zone, getters) {
8542
8561
  labelsAsText: false,
8543
8562
  stacked: false,
8544
8563
  aggregated: false,
8564
+ cumulative: false,
8545
8565
  labelRange: labelRangeXc,
8546
8566
  type: "line",
8547
8567
  dataSetsHaveTitle,
@@ -8904,6 +8924,13 @@ const REMOVE_ROWS_ACTION = (env) => {
8904
8924
  elements: rows,
8905
8925
  });
8906
8926
  };
8927
+ const CAN_REMOVE_COLUMNS_ROWS = (dimension, env) => {
8928
+ const sheetId = env.model.getters.getActiveSheetId();
8929
+ const selectedElements = env.model.getters.getElementsFromSelection(dimension);
8930
+ const includesAllVisibleHeaders = env.model.getters.checkElementsIncludeAllVisibleHeaders(sheetId, dimension, selectedElements);
8931
+ const includesAllNonFrozenHeaders = env.model.getters.checkElementsIncludeAllNonFrozenHeaders(sheetId, dimension, selectedElements);
8932
+ return !includesAllVisibleHeaders && !includesAllNonFrozenHeaders;
8933
+ };
8907
8934
  const REMOVE_COLUMNS_NAME = (env) => {
8908
8935
  if (env.model.getters.getSelectedZones().length > 1) {
8909
8936
  return _lt("Delete columns");
@@ -8928,7 +8955,7 @@ const REMOVE_COLUMNS_NAME = (env) => {
8928
8955
  const NOT_ALL_VISIBLE_ROWS_SELECTED = (env) => {
8929
8956
  const sheetId = env.model.getters.getActiveSheetId();
8930
8957
  const selectedRows = env.model.getters.getElementsFromSelection("ROW");
8931
- return env.model.getters.canRemoveHeaders(sheetId, "ROW", selectedRows);
8958
+ return !env.model.getters.checkElementsIncludeAllVisibleHeaders(sheetId, "ROW", selectedRows);
8932
8959
  };
8933
8960
  const REMOVE_COLUMNS_ACTION = (env) => {
8934
8961
  let columns = [...env.model.getters.getActiveCols()];
@@ -8947,7 +8974,7 @@ const REMOVE_COLUMNS_ACTION = (env) => {
8947
8974
  const NOT_ALL_VISIBLE_COLS_SELECTED = (env) => {
8948
8975
  const sheetId = env.model.getters.getActiveSheetId();
8949
8976
  const selectedCols = env.model.getters.getElementsFromSelection("COL");
8950
- return env.model.getters.canRemoveHeaders(sheetId, "COL", selectedCols);
8977
+ return !env.model.getters.checkElementsIncludeAllVisibleHeaders(sheetId, "COL", selectedCols);
8951
8978
  };
8952
8979
  const INSERT_CELL_SHIFT_DOWN = (env) => {
8953
8980
  const zone = env.model.getters.getSelectedZone();
@@ -9404,7 +9431,7 @@ const deleteValues = {
9404
9431
  const deleteRows = {
9405
9432
  name: REMOVE_ROWS_NAME,
9406
9433
  execute: REMOVE_ROWS_ACTION,
9407
- isVisible: NOT_ALL_VISIBLE_ROWS_SELECTED,
9434
+ isVisible: (env) => CAN_REMOVE_COLUMNS_ROWS("ROW", env),
9408
9435
  };
9409
9436
  const deleteRow = {
9410
9437
  ...deleteRows,
@@ -9417,7 +9444,7 @@ const clearRows = {
9417
9444
  const deleteCols = {
9418
9445
  name: REMOVE_COLUMNS_NAME,
9419
9446
  execute: REMOVE_COLUMNS_ACTION,
9420
- isVisible: NOT_ALL_VISIBLE_COLS_SELECTED,
9447
+ isVisible: (env) => CAN_REMOVE_COLUMNS_ROWS("COL", env),
9421
9448
  };
9422
9449
  const deleteCol = {
9423
9450
  ...deleteCols,
@@ -18465,6 +18492,11 @@ class LineConfigPanel extends LineBarPieConfigPanel {
18465
18492
  aggregated: ev.target.checked,
18466
18493
  });
18467
18494
  }
18495
+ onUpdateCumulative(ev) {
18496
+ this.props.updateChart(this.props.figureId, {
18497
+ cumulative: ev.target.checked,
18498
+ });
18499
+ }
18468
18500
  }
18469
18501
 
18470
18502
  class LineChartDesignPanel extends LineBarPieDesignPanel {
@@ -22190,9 +22222,11 @@ function useCellHovered(env, gridRef, callback) {
22190
22222
  }
22191
22223
  }
22192
22224
  function updateMousePosition(e) {
22193
- x = e.offsetX;
22194
- y = e.offsetY;
22195
- lastMoved = Date.now();
22225
+ if (gridRef.el === e.target) {
22226
+ x = e.offsetX;
22227
+ y = e.offsetY;
22228
+ lastMoved = Date.now();
22229
+ }
22196
22230
  }
22197
22231
  function recompute() {
22198
22232
  const { col, row } = getPosition();
@@ -26404,6 +26438,7 @@ function convertChartData(chartData) {
26404
26438
  legendPosition: chartData.legendPosition,
26405
26439
  stacked: chartData.stacked || false,
26406
26440
  aggregated: false,
26441
+ cumulative: chartData.cumulative || false,
26407
26442
  labelsAsText: false,
26408
26443
  };
26409
26444
  }
@@ -31084,7 +31119,7 @@ class HeaderSizePlugin extends CorePlugin {
31084
31119
 
31085
31120
  class HeaderVisibilityPlugin extends CorePlugin {
31086
31121
  static getters = [
31087
- "canRemoveHeaders",
31122
+ "checkElementsIncludeAllVisibleHeaders",
31088
31123
  "getHiddenColsGroups",
31089
31124
  "getHiddenRowsGroups",
31090
31125
  "isRowHiddenByUser",
@@ -31118,7 +31153,7 @@ class HeaderVisibilityPlugin extends CorePlugin {
31118
31153
  if (!this.getters.tryGetSheet(cmd.sheetId)) {
31119
31154
  return 27 /* CommandResult.InvalidSheetId */;
31120
31155
  }
31121
- if (!this.canRemoveHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
31156
+ if (this.checkElementsIncludeAllVisibleHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
31122
31157
  return 8 /* CommandResult.NotEnoughElements */;
31123
31158
  }
31124
31159
  return 0 /* CommandResult.Success */;
@@ -31168,9 +31203,9 @@ class HeaderVisibilityPlugin extends CorePlugin {
31168
31203
  }
31169
31204
  return;
31170
31205
  }
31171
- canRemoveHeaders(sheetId, dimension, elements) {
31206
+ checkElementsIncludeAllVisibleHeaders(sheetId, dimension, elements) {
31172
31207
  const visibleHeaders = this.getAllVisibleHeaders(sheetId, dimension);
31173
- return !includesAll(elements, visibleHeaders);
31208
+ return includesAll(elements, visibleHeaders);
31174
31209
  }
31175
31210
  isRowHiddenByUser(sheetId, index) {
31176
31211
  return this.hiddenHeaders[sheetId].ROW[index];
@@ -32257,6 +32292,7 @@ class SheetPlugin extends CorePlugin {
32257
32292
  "getPaneDivisions",
32258
32293
  "checkZonesExistInSheet",
32259
32294
  "getCommandZones",
32295
+ "checkElementsIncludeAllNonFrozenHeaders",
32260
32296
  ];
32261
32297
  sheetIdsMapName = {};
32262
32298
  orderedSheetIds = [];
@@ -32313,6 +32349,9 @@ class SheetPlugin extends CorePlugin {
32313
32349
  if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
32314
32350
  return 86 /* CommandResult.InvalidHeaderIndex */;
32315
32351
  }
32352
+ else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
32353
+ return 8 /* CommandResult.NotEnoughElements */;
32354
+ }
32316
32355
  else {
32317
32356
  return 0 /* CommandResult.Success */;
32318
32357
  }
@@ -32595,6 +32634,20 @@ class SheetPlugin extends CorePlugin {
32595
32634
  }
32596
32635
  this.history.update("sheets", sheetId, "panes", panes);
32597
32636
  }
32637
+ /**
32638
+ * Checks if all non-frozen header indices are present in the provided elements of selected rows/columns.
32639
+ * This validation ensures that all rows or columns cannot be deleted when frozen panes exist.
32640
+ */
32641
+ checkElementsIncludeAllNonFrozenHeaders(sheetId, dimension, elements) {
32642
+ const paneDivisions = this.getters.getPaneDivisions(sheetId);
32643
+ const startIndex = dimension === "ROW" ? paneDivisions.ySplit : paneDivisions.xSplit;
32644
+ const endIndex = this.getters.getNumberHeaders(sheetId, dimension);
32645
+ if (!startIndex) {
32646
+ return false;
32647
+ }
32648
+ const indicesToCheck = range(startIndex, endIndex);
32649
+ return includesAll(elements, indicesToCheck);
32650
+ }
32598
32651
  // ---------------------------------------------------------------------------
32599
32652
  // Row/Col manipulation
32600
32653
  // ---------------------------------------------------------------------------
@@ -33673,6 +33726,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
33673
33726
  // stores the computed styles in the format of computedStyles.sheetName[col][row] = Style
33674
33727
  computedStyles = {};
33675
33728
  computedIcons = {};
33729
+ uuidGenerator = new UuidGenerator();
33676
33730
  // ---------------------------------------------------------------------------
33677
33731
  // Command Handling
33678
33732
  // ---------------------------------------------------------------------------
@@ -34020,13 +34074,20 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34020
34074
  this.adaptRules(origin.sheetId, cf, [xc], toRemoveRange);
34021
34075
  }
34022
34076
  else {
34023
- this.adaptRules(target.sheetId, cf, [xc], []);
34024
34077
  this.adaptRules(origin.sheetId, cf, [], toRemoveRange);
34078
+ const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
34079
+ this.adaptRules(target.sheetId, cfToCopyTo, [xc], []);
34025
34080
  }
34026
34081
  }
34027
34082
  }
34028
34083
  }
34029
34084
  }
34085
+ getCFToCopyTo(targetSheetId, originCF) {
34086
+ const cfInTarget = this.getters
34087
+ .getConditionalFormats(targetSheetId)
34088
+ .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
34089
+ return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
34090
+ }
34030
34091
  }
34031
34092
 
34032
34093
  class FilterEvaluationPlugin extends UIPlugin {
@@ -34559,6 +34620,9 @@ class InternalViewport {
34559
34620
  const sheetId = this.sheetId;
34560
34621
  this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
34561
34622
  this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
34623
+ if (this.left === -1) {
34624
+ this.left = this.boundaries.left;
34625
+ }
34562
34626
  if (this.right === -1) {
34563
34627
  this.right = this.getters.getNumberCols(sheetId) - 1;
34564
34628
  }
@@ -34572,6 +34636,9 @@ class InternalViewport {
34572
34636
  const sheetId = this.sheetId;
34573
34637
  this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
34574
34638
  this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
34639
+ if (this.top === -1) {
34640
+ this.top = this.boundaries.top;
34641
+ }
34575
34642
  if (this.bottom === -1) {
34576
34643
  this.bottom = this.getters.getNumberRows(sheetId) - 1;
34577
34644
  }
@@ -40138,7 +40205,7 @@ class ClipboardPlugin extends UIPlugin {
40138
40205
  allowDispatch(cmd) {
40139
40206
  switch (cmd.type) {
40140
40207
  case "CUT":
40141
- const zones = cmd.cutTarget || this.getters.getSelectedZones();
40208
+ const zones = this.getters.getSelectedZones();
40142
40209
  const state = this.getClipboardState(zones, cmd.type);
40143
40210
  return state.isCutAllowed(zones);
40144
40211
  case "PASTE":
@@ -40168,7 +40235,7 @@ class ClipboardPlugin extends UIPlugin {
40168
40235
  switch (cmd.type) {
40169
40236
  case "COPY":
40170
40237
  case "CUT":
40171
- const zones = ("cutTarget" in cmd && cmd.cutTarget) || this.getters.getSelectedZones();
40238
+ const zones = this.getters.getSelectedZones();
40172
40239
  this.state = this.getClipboardState(zones, cmd.type);
40173
40240
  this.status = "visible";
40174
40241
  break;
@@ -41588,26 +41655,24 @@ class GridSelectionPlugin extends UIPlugin {
41588
41655
  const isBasedBefore = cmd.base < start;
41589
41656
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
41590
41657
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
41591
- this.dispatch("CUT", {
41592
- cutTarget: [
41593
- {
41594
- left: isCol ? start + deltaCol : 0,
41595
- right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41596
- top: !isCol ? start + deltaRow : 0,
41597
- bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41598
- },
41599
- ],
41600
- });
41601
- this.dispatch("PASTE", {
41602
- target: [
41603
- {
41604
- left: isCol ? cmd.base : 0,
41605
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41606
- top: !isCol ? cmd.base : 0,
41607
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41608
- },
41609
- ],
41610
- });
41658
+ const target = [
41659
+ {
41660
+ left: isCol ? start + deltaCol : 0,
41661
+ right: isCol ? end + deltaCol : this.getters.getNumberCols(cmd.sheetId) - 1,
41662
+ top: !isCol ? start + deltaRow : 0,
41663
+ bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
41664
+ },
41665
+ ];
41666
+ const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
41667
+ const pasteTarget = [
41668
+ {
41669
+ left: isCol ? cmd.base : 0,
41670
+ right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
41671
+ top: !isCol ? cmd.base : 0,
41672
+ bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
41673
+ },
41674
+ ];
41675
+ state.paste(pasteTarget, { selectTarget: true });
41611
41676
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
41612
41677
  let currentIndex = cmd.base;
41613
41678
  for (const element of toRemove) {
@@ -47623,6 +47688,6 @@ function addFunction(functionName, functionDescription) {
47623
47688
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
47624
47689
 
47625
47690
 
47626
- __info__.version = '16.3.9';
47627
- __info__.date = '2023-08-29T13:54:26.065Z';
47628
- __info__.hash = '79cedd4';
47691
+ __info__.version = '16.3.11';
47692
+ __info__.date = '2023-09-21T15:56:40.754Z';
47693
+ __info__.hash = '245df8c';