@odoo/o-spreadsheet 18.0.32 → 18.0.34

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.0.32
6
- * @date 2025-06-06T09:29:16.581Z
7
- * @hash bef1e2b
5
+ * @version 18.0.34
6
+ * @date 2025-06-19T18:26:11.726Z
7
+ * @hash 5526881
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -5677,7 +5677,9 @@
5677
5677
  }
5678
5678
 
5679
5679
  function evaluateLiteral(literalCell, localeFormat) {
5680
- const value = isTextFormat(localeFormat.format) ? literalCell.content : literalCell.parsedValue;
5680
+ const value = isTextFormat(localeFormat.format) && literalCell.parsedValue !== null
5681
+ ? literalCell.content
5682
+ : literalCell.parsedValue;
5681
5683
  const functionResult = { value, format: localeFormat.format };
5682
5684
  return createEvaluatedCell(functionResult, localeFormat.locale);
5683
5685
  }
@@ -5726,6 +5728,9 @@
5726
5728
  if (isEvaluationError(value)) {
5727
5729
  return errorCell(value, message);
5728
5730
  }
5731
+ if (value === null) {
5732
+ return emptyCell(format);
5733
+ }
5729
5734
  if (isTextFormat(format)) {
5730
5735
  // TO DO:
5731
5736
  // with the next line, the value of the cell is transformed depending on the format.
@@ -5733,9 +5738,6 @@
5733
5738
  // to interpret the value as a number.
5734
5739
  return textCell(toString(value), format, formattedValue);
5735
5740
  }
5736
- if (value === null) {
5737
- return emptyCell(format);
5738
- }
5739
5741
  if (typeof value === "number") {
5740
5742
  if (isDateTimeFormat(format || "")) {
5741
5743
  return dateTimeCell(value, format, formattedValue);
@@ -10171,10 +10173,22 @@ stores.inject(MyMetaStore, storeInstance);
10171
10173
  const midAngle = (startAngle + endAngle) / 2;
10172
10174
  const midRadius = (innerRadius + outerRadius) / 2;
10173
10175
  const x = bar.x + midRadius * Math.cos(midAngle);
10174
- const y = bar.y + midRadius * Math.sin(midAngle) + 7;
10176
+ const y = bar.y + midRadius * Math.sin(midAngle);
10177
+ const displayValue = options.callback(value, dataset, i);
10178
+ const textHeight = 12; // ChartJS default
10179
+ const textWidth = computeTextWidth(ctx, displayValue, { fontSize: textHeight }, "px");
10180
+ const radius = outerRadius - innerRadius;
10181
+ // Check if the text fits in the slice. Not perfect, but good enough heuristic.
10182
+ if (textWidth >= radius || radius < textHeight) {
10183
+ continue;
10184
+ }
10185
+ const sliceAngle = endAngle - startAngle;
10186
+ const midWidth = 2 * midRadius * Math.tan(sliceAngle / 2);
10187
+ if (sliceAngle < Math.PI / 2 && (textWidth >= midWidth || midWidth < textHeight)) {
10188
+ continue;
10189
+ }
10175
10190
  ctx.fillStyle = chartFontColor(options.background);
10176
10191
  ctx.strokeStyle = options.background || "#ffffff";
10177
- const displayValue = options.callback(value, dataset, i);
10178
10192
  drawTextWithBackground(displayValue, x, y, ctx);
10179
10193
  }
10180
10194
  }
@@ -13391,7 +13405,7 @@ stores.inject(MyMetaStore, storeInstance);
13391
13405
  */
13392
13406
  handleMissingValue(parentElement, missingElementName, optionalArgs) {
13393
13407
  if (optionalArgs?.required) {
13394
- if (optionalArgs?.default) {
13408
+ if (optionalArgs?.default !== undefined) {
13395
13409
  this.warningManager.addParsingWarning(`Missing required ${missingElementName} in element <${parentElement.tagName}> of ${this.currentFile}, replacing it by the default value ${optionalArgs.default}`);
13396
13410
  }
13397
13411
  else {
@@ -32517,19 +32531,26 @@ stores.inject(MyMetaStore, storeInstance);
32517
32531
  .filter(({ row }) => !this.env.model.getters.isRowHidden(sheetId, row))
32518
32532
  .map(({ col, row }) => this.env.model.getters.getEvaluatedCell({ sheetId, col, row }).formattedValue);
32519
32533
  const filterValues = this.env.model.getters.getFilterHiddenValues({ sheetId, ...position });
32520
- const strValues = [...cellValues, ...filterValues];
32521
- const normalizedFilteredValues = filterValues.map(toLowerCase);
32522
- // Set with lowercase values to avoid duplicates
32523
- const normalizedValues = [...new Set(strValues.map(toLowerCase))];
32524
- const sortedValues = normalizedValues.sort((val1, val2) => val1.localeCompare(val2, undefined, { numeric: true, sensitivity: "base" }));
32525
- return sortedValues.map((normalizedValue) => {
32526
- const checked = normalizedFilteredValues.findIndex((filteredValue) => filteredValue === normalizedValue) ===
32527
- -1;
32528
- return {
32529
- checked,
32530
- string: strValues.find((val) => toLowerCase(val) === normalizedValue) || "",
32531
- };
32532
- });
32534
+ const normalizedFilteredValues = new Set(filterValues.map(toLowerCase));
32535
+ const set = new Set();
32536
+ const values = [];
32537
+ const addValue = (value) => {
32538
+ const normalizedValue = toLowerCase(value);
32539
+ if (!set.has(normalizedValue)) {
32540
+ values.push({
32541
+ string: value || "",
32542
+ checked: !normalizedFilteredValues.has(normalizedValue),
32543
+ normalizedValue,
32544
+ });
32545
+ set.add(normalizedValue);
32546
+ }
32547
+ };
32548
+ cellValues.forEach(addValue);
32549
+ filterValues.forEach(addValue);
32550
+ return values.sort((val1, val2) => val1.normalizedValue.localeCompare(val2.normalizedValue, undefined, {
32551
+ numeric: true,
32552
+ sensitivity: "base",
32553
+ }));
32533
32554
  }
32534
32555
  checkValue(value) {
32535
32556
  this.state.selectedValue = value.string;
@@ -33648,6 +33669,10 @@ stores.inject(MyMetaStore, storeInstance);
33648
33669
  });
33649
33670
  };
33650
33671
  const CAN_REMOVE_COLUMNS_ROWS = (dimension, env) => {
33672
+ if ((dimension === "COL" && env.model.getters.getActiveRows().size > 0) ||
33673
+ (dimension === "ROW" && env.model.getters.getActiveCols().size > 0)) {
33674
+ return false;
33675
+ }
33651
33676
  const sheetId = env.model.getters.getActiveSheetId();
33652
33677
  const selectedElements = env.model.getters.getElementsFromSelection(dimension);
33653
33678
  const includesAllVisibleHeaders = env.model.getters.checkElementsIncludeAllVisibleHeaders(sheetId, dimension, selectedElements);
@@ -36368,11 +36393,11 @@ stores.inject(MyMetaStore, storeInstance);
36368
36393
  * transformation function given
36369
36394
  */
36370
36395
  addTransformation(executed, toTransforms, fn) {
36371
- for (let toTransform of toTransforms) {
36372
- if (!this.content[toTransform]) {
36373
- this.content[toTransform] = new Map();
36374
- }
36375
- this.content[toTransform].set(executed, fn);
36396
+ if (!this.content[executed]) {
36397
+ this.content[executed] = new Map();
36398
+ }
36399
+ for (const toTransform of toTransforms) {
36400
+ this.content[executed].set(toTransform, fn);
36376
36401
  }
36377
36402
  return this;
36378
36403
  }
@@ -36381,7 +36406,7 @@ stores.inject(MyMetaStore, storeInstance);
36381
36406
  * that the executed command happened.
36382
36407
  */
36383
36408
  getTransformation(toTransform, executed) {
36384
- return this.content[toTransform] && this.content[toTransform].get(executed);
36409
+ return this.content[executed] && this.content[executed].get(toTransform);
36385
36410
  }
36386
36411
  }
36387
36412
  const otRegistry = new OTRegistry();
@@ -56028,7 +56053,9 @@ stores.inject(MyMetaStore, storeInstance);
56028
56053
  const ranges = cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData));
56029
56054
  const union = this.getters.getRangesUnion(ranges);
56030
56055
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, union.zone);
56031
- this.dispatch("REMOVE_MERGE", { sheetId: cmd.sheetId, target: mergesInTarget });
56056
+ if (mergesInTarget.length) {
56057
+ this.dispatch("REMOVE_MERGE", { sheetId: cmd.sheetId, target: mergesInTarget });
56058
+ }
56032
56059
  const id = this.uuidGenerator.smallUuid();
56033
56060
  const config = cmd.config || DEFAULT_TABLE_CONFIG;
56034
56061
  const newTable = cmd.tableType === "dynamic"
@@ -56139,14 +56166,16 @@ stores.inject(MyMetaStore, storeInstance);
56139
56166
  const zoneToCheckIfEmpty = direction === "down"
56140
56167
  ? { ...zone, bottom: zone.bottom + 1, top: zone.bottom + 1 }
56141
56168
  : { ...zone, right: zone.right + 1, left: zone.right + 1 };
56142
- for (const position of positions(zoneToCheckIfEmpty)) {
56143
- const cellPosition = { sheetId, ...position };
56144
- // Since this plugin is loaded before CellPlugin, the getters still give us the old cell content
56145
- const cellContent = this.getters.getCell(cellPosition)?.content;
56146
- if (cellContent ||
56147
- this.getters.isInMerge(cellPosition) ||
56148
- this.getTablesOverlappingZones(sheetId, [positionToZone(position)]).length) {
56149
- return "none";
56169
+ for (let row = zoneToCheckIfEmpty.top; row <= zoneToCheckIfEmpty.bottom; row++) {
56170
+ for (let col = zoneToCheckIfEmpty.left; col <= zoneToCheckIfEmpty.right; col++) {
56171
+ const cellPosition = { sheetId, col, row };
56172
+ // Since this plugin is loaded before CellPlugin, the getters still give us the old cell content
56173
+ const cellContent = this.getters.getCell(cellPosition)?.content;
56174
+ if (cellContent ||
56175
+ this.getters.isInMerge(cellPosition) ||
56176
+ this.getTablesOverlappingZones(sheetId, [positionToZone(cellPosition)]).length) {
56177
+ return "none";
56178
+ }
56150
56179
  }
56151
56180
  }
56152
56181
  return direction;
@@ -62176,10 +62205,20 @@ stores.inject(MyMetaStore, storeInstance);
62176
62205
  */
62177
62206
  function transformAll(toTransform, executed) {
62178
62207
  let transformedCommands = [...toTransform];
62208
+ const possibleTransformations = new Set(otRegistry.getKeys());
62179
62209
  for (const executedCommand of executed) {
62180
- transformedCommands = transformedCommands
62181
- .map((cmd) => transform(cmd, executedCommand))
62182
- .filter(isDefined);
62210
+ // If the executed command is not in the registry, we skip it
62211
+ // because we know there won't be any transformation impacting the
62212
+ // commands to transform.
62213
+ if (possibleTransformations.has(executedCommand.type)) {
62214
+ transformedCommands = transformedCommands.reduce((acc, cmd) => {
62215
+ const transformed = transform(cmd, executedCommand);
62216
+ if (transformed) {
62217
+ acc.push(transformed);
62218
+ }
62219
+ return acc;
62220
+ }, []);
62221
+ }
62183
62222
  }
62184
62223
  return transformedCommands;
62185
62224
  }
@@ -62665,7 +62704,6 @@ stores.inject(MyMetaStore, storeInstance);
62665
62704
  if (this.waitingAck) {
62666
62705
  return;
62667
62706
  }
62668
- this.waitingAck = true;
62669
62707
  this.sendPendingMessage();
62670
62708
  }
62671
62709
  /**
@@ -62695,6 +62733,7 @@ stores.inject(MyMetaStore, storeInstance);
62695
62733
  throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.
62696
62734
  ${JSON.stringify(message)}`);
62697
62735
  }
62736
+ this.waitingAck = true;
62698
62737
  this.transportService.sendMessage({
62699
62738
  ...message,
62700
62739
  serverRevisionId: this.serverRevisionId,
@@ -63835,7 +63874,7 @@ stores.inject(MyMetaStore, storeInstance);
63835
63874
  }
63836
63875
  const position = this.getters.getCellPosition(cell.id);
63837
63876
  const colSize = this.getters.getColSize(sheetId, position.col);
63838
- if (cell.isFormula) {
63877
+ if (cell.isFormula || this.getters.getArrayFormulaSpreadingOn(position)) {
63839
63878
  const content = this.getters.getEvaluatedCell(position).formattedValue;
63840
63879
  const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63841
63880
  if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
@@ -65471,9 +65510,10 @@ stores.inject(MyMetaStore, storeInstance);
65471
65510
  const filteredZone = filter.filteredRange?.zone;
65472
65511
  if (!filteredValues || !filteredZone)
65473
65512
  continue;
65513
+ const filteredValuesSet = new Set(filteredValues);
65474
65514
  for (let row = filteredZone.top; row <= filteredZone.bottom; row++) {
65475
65515
  const value = this.getCellValueAsString(sheetId, filter.col, row);
65476
- if (filteredValues.includes(value)) {
65516
+ if (filteredValuesSet.has(value)) {
65477
65517
  hiddenRows.add(row);
65478
65518
  }
65479
65519
  }
@@ -74420,9 +74460,9 @@ stores.inject(MyMetaStore, storeInstance);
74420
74460
  exports.tokenize = tokenize;
74421
74461
 
74422
74462
 
74423
- __info__.version = "18.0.32";
74424
- __info__.date = "2025-06-06T09:29:16.581Z";
74425
- __info__.hash = "bef1e2b";
74463
+ __info__.version = "18.0.34";
74464
+ __info__.date = "2025-06-19T18:26:11.726Z";
74465
+ __info__.hash = "5526881";
74426
74466
 
74427
74467
 
74428
74468
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);