@odoo/o-spreadsheet 18.0.26 → 18.0.27

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.26
6
- * @date 2025-05-02T12:30:31.966Z
7
- * @hash 5bdf504
5
+ * @version 18.0.27
6
+ * @date 2025-05-12T05:25:47.149Z
7
+ * @hash 9b36340
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -6102,6 +6102,25 @@ function moveHeaderIndexesOnHeaderDeletion(deletedHeaders, headers) {
6102
6102
  })
6103
6103
  .filter(isDefined);
6104
6104
  }
6105
+ function getNextSheetName(existingNames, baseName = "Sheet") {
6106
+ let i = 1;
6107
+ let name = `${baseName}${i}`;
6108
+ while (existingNames.includes(name)) {
6109
+ name = `${baseName}${i}`;
6110
+ i++;
6111
+ }
6112
+ return name;
6113
+ }
6114
+ function getDuplicateSheetName(nameToDuplicate, existingNames) {
6115
+ let i = 1;
6116
+ const baseName = _t("Copy of %s", nameToDuplicate);
6117
+ let name = baseName.toString();
6118
+ while (existingNames.includes(name)) {
6119
+ name = `${baseName} (${i})`;
6120
+ i++;
6121
+ }
6122
+ return name;
6123
+ }
6105
6124
 
6106
6125
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
6107
6126
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
@@ -7790,6 +7809,24 @@ const monthNumberAdapter = {
7790
7809
  return `${normalizedValue}`;
7791
7810
  },
7792
7811
  };
7812
+ /**
7813
+ * normalizes month number + year
7814
+ */
7815
+ const monthAdapter = {
7816
+ normalizeFunctionValue(value) {
7817
+ const date = toNumber(value, DEFAULT_LOCALE);
7818
+ return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
7819
+ },
7820
+ toValueAndFormat(normalizedValue) {
7821
+ return {
7822
+ value: toNumber(normalizedValue, DEFAULT_LOCALE),
7823
+ format: "mmmm yyyy",
7824
+ };
7825
+ },
7826
+ toFunctionValue(normalizedValue) {
7827
+ return `"${normalizedValue}"`;
7828
+ },
7829
+ };
7793
7830
  /**
7794
7831
  * normalizes quarter number
7795
7832
  */
@@ -7920,6 +7957,7 @@ pivotTimeAdapterRegistry
7920
7957
  .add("day_of_month", nullHandlerDecorator(dayOfMonthAdapter))
7921
7958
  .add("iso_week_number", nullHandlerDecorator(isoWeekNumberAdapter))
7922
7959
  .add("month_number", nullHandlerDecorator(monthNumberAdapter))
7960
+ .add("month", nullHandlerDecorator(monthAdapter))
7923
7961
  .add("quarter_number", nullHandlerDecorator(quarterNumberAdapter))
7924
7962
  .add("day_of_week", nullHandlerDecorator(dayOfWeekAdapter))
7925
7963
  .add("hour_number", nullHandlerDecorator(hourNumberAdapter))
@@ -8100,10 +8138,7 @@ function toNormalizedPivotValue(dimension, groupValue) {
8100
8138
  return normalizer(groupValueString, dimension.granularity);
8101
8139
  }
8102
8140
  function normalizeDateTime(value, granularity) {
8103
- if (!granularity) {
8104
- throw new Error("Missing granularity");
8105
- }
8106
- return pivotTimeAdapter(granularity).normalizeFunctionValue(value);
8141
+ return pivotTimeAdapter(granularity ?? "month").normalizeFunctionValue(value);
8107
8142
  }
8108
8143
  function toFunctionPivotValue(value, dimension) {
8109
8144
  if (value === null) {
@@ -8115,10 +8150,7 @@ function toFunctionPivotValue(value, dimension) {
8115
8150
  return pivotToFunctionValueRegistry.get(dimension.type)(value, dimension.granularity);
8116
8151
  }
8117
8152
  function toFunctionValueDateTime(value, granularity) {
8118
- if (!granularity) {
8119
- throw new Error("Missing granularity");
8120
- }
8121
- return pivotTimeAdapter(granularity).toFunctionValue(value);
8153
+ return pivotTimeAdapter(granularity ?? "month").toFunctionValue(value);
8122
8154
  }
8123
8155
  const pivotNormalizationValueRegistry = new Registry();
8124
8156
  pivotNormalizationValueRegistry
@@ -15251,6 +15283,7 @@ function repairInitialMessages(data, initialMessages) {
15251
15283
  initialMessages = dropCommands(initialMessages, "SORT_CELLS");
15252
15284
  initialMessages = dropCommands(initialMessages, "SET_DECIMAL");
15253
15285
  initialMessages = fixChartDefinitions(data, initialMessages);
15286
+ initialMessages = fixTranslatedDuplicateSheetName(data, initialMessages);
15254
15287
  return initialMessages;
15255
15288
  }
15256
15289
  /**
@@ -15350,6 +15383,40 @@ function fixChartDefinitions(data, initialMessages) {
15350
15383
  }
15351
15384
  return messages;
15352
15385
  }
15386
+ function fixTranslatedDuplicateSheetName(data, initialMessages) {
15387
+ const sheetNames = {};
15388
+ for (const sheet of data.sheets || []) {
15389
+ sheetNames[sheet.id] = sheet.name;
15390
+ }
15391
+ const messages = [];
15392
+ for (const message of initialMessages) {
15393
+ if (message.type === "REMOTE_REVISION") {
15394
+ const commands = [];
15395
+ for (const cmd of message.commands) {
15396
+ switch (cmd.type) {
15397
+ case "DUPLICATE_SHEET":
15398
+ cmd.sheetNameTo =
15399
+ cmd.sheetNameTo ??
15400
+ getDuplicateSheetName(sheetNames[cmd.sheetId], Object.values(sheetNames));
15401
+ break;
15402
+ case "CREATE_SHEET":
15403
+ case "RENAME_SHEET":
15404
+ sheetNames[cmd.sheetId] = cmd.name || getNextSheetName(Object.values(sheetNames));
15405
+ break;
15406
+ }
15407
+ commands.push(cmd);
15408
+ }
15409
+ messages.push({
15410
+ ...message,
15411
+ commands,
15412
+ });
15413
+ }
15414
+ else {
15415
+ messages.push(message);
15416
+ }
15417
+ }
15418
+ return initialMessages;
15419
+ }
15353
15420
  // -----------------------------------------------------------------------------
15354
15421
  // Helpers
15355
15422
  // -----------------------------------------------------------------------------
@@ -24365,7 +24432,7 @@ const IF = {
24365
24432
  return { value: "" };
24366
24433
  }
24367
24434
  if (result.value === null) {
24368
- result.value = "";
24435
+ return { ...result, value: "" };
24369
24436
  }
24370
24437
  return result;
24371
24438
  },
@@ -24386,7 +24453,7 @@ const IFERROR = {
24386
24453
  return { value: "" };
24387
24454
  }
24388
24455
  if (result.value === null) {
24389
- result.value = "";
24456
+ return { ...result, value: "" };
24390
24457
  }
24391
24458
  return result;
24392
24459
  },
@@ -24407,7 +24474,7 @@ const IFNA = {
24407
24474
  return { value: "" };
24408
24475
  }
24409
24476
  if (result.value === null) {
24410
- result.value = "";
24477
+ return { ...result, value: "" };
24411
24478
  }
24412
24479
  return result;
24413
24480
  },
@@ -24433,7 +24500,7 @@ const IFS = {
24433
24500
  return { value: "" };
24434
24501
  }
24435
24502
  if (result.value === null) {
24436
- result.value = "";
24503
+ return { ...result, value: "" };
24437
24504
  }
24438
24505
  return result;
24439
24506
  }
@@ -24551,6 +24618,11 @@ function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
24551
24618
  if (range === undefined || range.invalidXc || range.invalidSheetName) {
24552
24619
  throw new InvalidReferenceError();
24553
24620
  }
24621
+ if (evalContext.__originCellPosition &&
24622
+ range.sheetId === evalContext.__originSheetId &&
24623
+ isZoneInside(positionToZone(evalContext.__originCellPosition), zone)) {
24624
+ throw new CircularDependencyError();
24625
+ }
24554
24626
  dependencies.push(range);
24555
24627
  }
24556
24628
  for (const measure of forMeasures) {
@@ -27558,6 +27630,13 @@ class Composer extends Component {
27558
27630
  openAssistant() {
27559
27631
  this.assistant.forcedClosed = false;
27560
27632
  }
27633
+ onWheel(event) {
27634
+ // detect if scrollbar is available
27635
+ if (this.composerRef.el &&
27636
+ this.composerRef.el.scrollHeight > this.composerRef.el.clientHeight) {
27637
+ event.stopPropagation();
27638
+ }
27639
+ }
27561
27640
  // ---------------------------------------------------------------------------
27562
27641
  // Private
27563
27642
  // ---------------------------------------------------------------------------
@@ -32557,10 +32636,13 @@ const duplicateSheet = {
32557
32636
  name: _t("Duplicate"),
32558
32637
  execute: (env) => {
32559
32638
  const sheetIdFrom = env.model.getters.getActiveSheetId();
32639
+ const sheetNameFrom = env.model.getters.getSheetName(sheetIdFrom);
32560
32640
  const sheetIdTo = env.model.uuidGenerator.smallUuid();
32641
+ const sheetNameTo = env.model.getters.getDuplicateSheetName(sheetNameFrom);
32561
32642
  env.model.dispatch("DUPLICATE_SHEET", {
32562
32643
  sheetId: sheetIdFrom,
32563
32644
  sheetIdTo,
32645
+ sheetNameTo,
32564
32646
  });
32565
32647
  env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom, sheetIdTo });
32566
32648
  },
@@ -43899,8 +43981,8 @@ function compareDimensionValues(dimension, a, b) {
43899
43981
 
43900
43982
  const NULL_SYMBOL = Symbol("NULL");
43901
43983
  function createDate(dimension, value, locale) {
43902
- const granularity = dimension.granularity;
43903
- if (!granularity || !(granularity in MAP_VALUE_DIMENSION_DATE)) {
43984
+ const granularity = dimension.granularity || "month";
43985
+ if (!(granularity in MAP_VALUE_DIMENSION_DATE)) {
43904
43986
  throw new Error(`Unknown date granularity: ${granularity}`);
43905
43987
  }
43906
43988
  const keyInMap = typeof value === "number" || typeof value === "string" ? value : NULL_SYMBOL;
@@ -43919,6 +44001,9 @@ function createDate(dimension, value, locale) {
43919
44001
  case "month_number":
43920
44002
  number = date.getMonth() + 1;
43921
44003
  break;
44004
+ case "month":
44005
+ number = Math.floor(toNumber(value, locale));
44006
+ break;
43922
44007
  case "iso_week_number":
43923
44008
  number = date.getIsoWeek();
43924
44009
  break;
@@ -44012,6 +44097,10 @@ const MAP_VALUE_DIMENSION_DATE = {
44012
44097
  set: new Set(),
44013
44098
  values: {},
44014
44099
  },
44100
+ month: {
44101
+ set: new Set(),
44102
+ values: {},
44103
+ },
44015
44104
  iso_week_number: {
44016
44105
  set: new Set(),
44017
44106
  values: {},
@@ -44222,7 +44311,7 @@ class SpreadsheetPivot {
44222
44311
  const cells = this.filterDataEntriesFromDomain(this.dataEntries, domain);
44223
44312
  const finalCell = cells[0]?.[dimension.nameWithGranularity];
44224
44313
  if (dimension.type === "datetime") {
44225
- const adapter = pivotTimeAdapter(dimension.granularity);
44314
+ const adapter = pivotTimeAdapter((dimension.granularity || "month"));
44226
44315
  return adapter.toValueAndFormat(lastNode.value, this.getters.getLocale());
44227
44316
  }
44228
44317
  if (!finalCell) {
@@ -44340,7 +44429,7 @@ class SpreadsheetPivot {
44340
44429
  if (nonEmptyCells.length === 0) {
44341
44430
  return "integer";
44342
44431
  }
44343
- if (nonEmptyCells.every((cell) => cell.format && isDateTimeFormat(cell.format))) {
44432
+ if (nonEmptyCells.every((cell) => cell.type === CellValueType.number && cell.format && isDateTimeFormat(cell.format))) {
44344
44433
  return "datetime";
44345
44434
  }
44346
44435
  if (nonEmptyCells.every((cell) => cell.type === CellValueType.boolean)) {
@@ -44435,7 +44524,7 @@ class SpreadsheetPivot {
44435
44524
  for (const entry of dataEntries) {
44436
44525
  for (const dimension of dateDimensions) {
44437
44526
  const value = createDate(dimension, entry[dimension.fieldName]?.value || null, this.getters.getLocale());
44438
- const adapter = pivotTimeAdapter(dimension.granularity);
44527
+ const adapter = pivotTimeAdapter((dimension.granularity || "month"));
44439
44528
  const { format, value: valueToFormat } = adapter.toValueAndFormat(value, locale);
44440
44529
  entry[dimension.nameWithGranularity] = {
44441
44530
  value,
@@ -44455,6 +44544,7 @@ const dateGranularities = [
44455
44544
  "year",
44456
44545
  "quarter_number",
44457
44546
  "month_number",
44547
+ "month",
44458
44548
  "iso_week_number",
44459
44549
  "day_of_month",
44460
44550
  "day",
@@ -44695,7 +44785,7 @@ class PivotSidePanelStore extends SpreadsheetStore {
44695
44785
  : this.datetimeGranularities);
44696
44786
  }
44697
44787
  for (const field of dateFields) {
44698
- granularitiesPerFields[field.fieldName].delete(field.granularity);
44788
+ granularitiesPerFields[field.fieldName].delete(field.granularity || "month");
44699
44789
  }
44700
44790
  return granularitiesPerFields;
44701
44791
  }
@@ -46853,6 +46943,8 @@ class GridComposer extends Component {
46853
46943
  }
46854
46944
  get composerProps() {
46855
46945
  const { width, height } = this.env.model.getters.getSheetViewDimensionWithHeaders();
46946
+ // Remove the wrapper border width
46947
+ const maxHeight = this.props.gridDims.height - this.rect.y - 2 * COMPOSER_BORDER_WIDTH;
46856
46948
  return {
46857
46949
  rect: { ...this.rect },
46858
46950
  delimitation: {
@@ -46870,6 +46962,7 @@ class GridComposer extends Component {
46870
46962
  }),
46871
46963
  onInputContextMenu: this.props.onInputContextMenu,
46872
46964
  composerStore: this.composerStore,
46965
+ inputStyle: `max-height: ${maxHeight}px;`,
46873
46966
  };
46874
46967
  }
46875
46968
  get containerStyle() {
@@ -52269,9 +52362,7 @@ class ChartPlugin extends CorePlugin {
52269
52362
  : "Success" /* CommandResult.Success */;
52270
52363
  }
52271
52364
  checkChartExists(cmd) {
52272
- return this.getters.getFigureSheetId(cmd.id)
52273
- ? "Success" /* CommandResult.Success */
52274
- : "ChartDoesNotExist" /* CommandResult.ChartDoesNotExist */;
52365
+ return this.isChartDefined(cmd.id) ? "Success" /* CommandResult.Success */ : "ChartDoesNotExist" /* CommandResult.ChartDoesNotExist */;
52275
52366
  }
52276
52367
  }
52277
52368
 
@@ -54532,6 +54623,7 @@ class SheetPlugin extends CorePlugin {
54532
54623
  "getCommandZones",
54533
54624
  "getUnboundedZone",
54534
54625
  "checkElementsIncludeAllNonFrozenHeaders",
54626
+ "getDuplicateSheetName",
54535
54627
  ];
54536
54628
  sheetIdsMapName = {};
54537
54629
  orderedSheetIds = [];
@@ -54556,7 +54648,11 @@ class SheetPlugin extends CorePlugin {
54556
54648
  return this.checkValidations(cmd, this.checkSheetName, this.checkSheetPosition);
54557
54649
  }
54558
54650
  case "DUPLICATE_SHEET": {
54559
- return this.sheets[cmd.sheetIdTo] ? "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */ : "Success" /* CommandResult.Success */;
54651
+ if (this.sheets[cmd.sheetIdTo])
54652
+ return "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */;
54653
+ if (this.orderedSheetIds.map(this.getSheetName.bind(this)).includes(cmd.sheetNameTo))
54654
+ return "DuplicatedSheetName" /* CommandResult.DuplicatedSheetName */;
54655
+ return "Success" /* CommandResult.Success */;
54560
54656
  }
54561
54657
  case "MOVE_SHEET":
54562
54658
  try {
@@ -54633,7 +54729,7 @@ class SheetPlugin extends CorePlugin {
54633
54729
  this.showSheet(cmd.sheetId);
54634
54730
  break;
54635
54731
  case "DUPLICATE_SHEET":
54636
- this.duplicateSheet(cmd.sheetId, cmd.sheetIdTo);
54732
+ this.duplicateSheet(cmd.sheetId, cmd.sheetIdTo, cmd.sheetNameTo);
54637
54733
  break;
54638
54734
  case "DELETE_SHEET":
54639
54735
  this.deleteSheet(this.sheets[cmd.sheetId]);
@@ -54839,14 +54935,8 @@ class SheetPlugin extends CorePlugin {
54839
54935
  return dimension === "COL" ? this.getNumberCols(sheetId) : this.getNumberRows(sheetId);
54840
54936
  }
54841
54937
  getNextSheetName(baseName = "Sheet") {
54842
- let i = 1;
54843
54938
  const names = this.orderedSheetIds.map(this.getSheetName.bind(this));
54844
- let name = `${baseName}${i}`;
54845
- while (names.includes(name)) {
54846
- name = `${baseName}${i}`;
54847
- i++;
54848
- }
54849
- return name;
54939
+ return getNextSheetName(names, baseName);
54850
54940
  }
54851
54941
  getSheetSize(sheetId) {
54852
54942
  return {
@@ -55092,9 +55182,8 @@ class SheetPlugin extends CorePlugin {
55092
55182
  showSheet(sheetId) {
55093
55183
  this.history.update("sheets", sheetId, "isVisible", true);
55094
55184
  }
55095
- duplicateSheet(fromId, toId) {
55185
+ duplicateSheet(fromId, toId, toName) {
55096
55186
  const sheet = this.getSheet(fromId);
55097
- const toName = this.getDuplicateSheetName(sheet.name);
55098
55187
  const newSheet = deepCopy(sheet);
55099
55188
  newSheet.id = toId;
55100
55189
  newSheet.name = toName;
@@ -55126,15 +55215,8 @@ class SheetPlugin extends CorePlugin {
55126
55215
  this.history.update("sheetIdsMapName", sheetIdsMapName);
55127
55216
  }
55128
55217
  getDuplicateSheetName(sheetName) {
55129
- let i = 1;
55130
55218
  const names = this.orderedSheetIds.map(this.getSheetName.bind(this));
55131
- const baseName = _t("Copy of %s", sheetName);
55132
- let name = baseName.toString();
55133
- while (names.includes(name)) {
55134
- name = `${baseName} (${i})`;
55135
- i++;
55136
- }
55137
- return name;
55219
+ return getDuplicateSheetName(sheetName, names);
55138
55220
  }
55139
55221
  deleteSheet(sheet) {
55140
55222
  const name = sheet.name;
@@ -57960,8 +58042,8 @@ class SpreadingRelation {
57960
58042
  const EMPTY_ARRAY = [];
57961
58043
 
57962
58044
  const MAX_ITERATION = 30;
57963
- const ERROR_CYCLE_CELL = createEvaluatedCell(new CircularDependencyError());
57964
- const EMPTY_CELL = createEvaluatedCell({ value: null });
58045
+ const ERROR_CYCLE_CELL = Object.freeze(createEvaluatedCell(new CircularDependencyError()));
58046
+ const EMPTY_CELL = Object.freeze(createEvaluatedCell({ value: null }));
57965
58047
  class Evaluator {
57966
58048
  context;
57967
58049
  getters;
@@ -73749,6 +73831,6 @@ const constants = {
73749
73831
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
73750
73832
 
73751
73833
 
73752
- __info__.version = "18.0.26";
73753
- __info__.date = "2025-05-02T12:30:31.966Z";
73754
- __info__.hash = "5bdf504";
73834
+ __info__.version = "18.0.27";
73835
+ __info__.date = "2025-05-12T05:25:47.149Z";
73836
+ __info__.hash = "9b36340";