@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
  (function (exports, owl) {
@@ -6103,6 +6103,25 @@
6103
6103
  })
6104
6104
  .filter(isDefined);
6105
6105
  }
6106
+ function getNextSheetName(existingNames, baseName = "Sheet") {
6107
+ let i = 1;
6108
+ let name = `${baseName}${i}`;
6109
+ while (existingNames.includes(name)) {
6110
+ name = `${baseName}${i}`;
6111
+ i++;
6112
+ }
6113
+ return name;
6114
+ }
6115
+ function getDuplicateSheetName(nameToDuplicate, existingNames) {
6116
+ let i = 1;
6117
+ const baseName = _t("Copy of %s", nameToDuplicate);
6118
+ let name = baseName.toString();
6119
+ while (existingNames.includes(name)) {
6120
+ name = `${baseName} (${i})`;
6121
+ i++;
6122
+ }
6123
+ return name;
6124
+ }
6106
6125
 
6107
6126
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
6108
6127
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
@@ -7791,6 +7810,24 @@
7791
7810
  return `${normalizedValue}`;
7792
7811
  },
7793
7812
  };
7813
+ /**
7814
+ * normalizes month number + year
7815
+ */
7816
+ const monthAdapter = {
7817
+ normalizeFunctionValue(value) {
7818
+ const date = toNumber(value, DEFAULT_LOCALE);
7819
+ return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
7820
+ },
7821
+ toValueAndFormat(normalizedValue) {
7822
+ return {
7823
+ value: toNumber(normalizedValue, DEFAULT_LOCALE),
7824
+ format: "mmmm yyyy",
7825
+ };
7826
+ },
7827
+ toFunctionValue(normalizedValue) {
7828
+ return `"${normalizedValue}"`;
7829
+ },
7830
+ };
7794
7831
  /**
7795
7832
  * normalizes quarter number
7796
7833
  */
@@ -7921,6 +7958,7 @@
7921
7958
  .add("day_of_month", nullHandlerDecorator(dayOfMonthAdapter))
7922
7959
  .add("iso_week_number", nullHandlerDecorator(isoWeekNumberAdapter))
7923
7960
  .add("month_number", nullHandlerDecorator(monthNumberAdapter))
7961
+ .add("month", nullHandlerDecorator(monthAdapter))
7924
7962
  .add("quarter_number", nullHandlerDecorator(quarterNumberAdapter))
7925
7963
  .add("day_of_week", nullHandlerDecorator(dayOfWeekAdapter))
7926
7964
  .add("hour_number", nullHandlerDecorator(hourNumberAdapter))
@@ -8101,10 +8139,7 @@
8101
8139
  return normalizer(groupValueString, dimension.granularity);
8102
8140
  }
8103
8141
  function normalizeDateTime(value, granularity) {
8104
- if (!granularity) {
8105
- throw new Error("Missing granularity");
8106
- }
8107
- return pivotTimeAdapter(granularity).normalizeFunctionValue(value);
8142
+ return pivotTimeAdapter(granularity ?? "month").normalizeFunctionValue(value);
8108
8143
  }
8109
8144
  function toFunctionPivotValue(value, dimension) {
8110
8145
  if (value === null) {
@@ -8116,10 +8151,7 @@
8116
8151
  return pivotToFunctionValueRegistry.get(dimension.type)(value, dimension.granularity);
8117
8152
  }
8118
8153
  function toFunctionValueDateTime(value, granularity) {
8119
- if (!granularity) {
8120
- throw new Error("Missing granularity");
8121
- }
8122
- return pivotTimeAdapter(granularity).toFunctionValue(value);
8154
+ return pivotTimeAdapter(granularity ?? "month").toFunctionValue(value);
8123
8155
  }
8124
8156
  const pivotNormalizationValueRegistry = new Registry();
8125
8157
  pivotNormalizationValueRegistry
@@ -15252,6 +15284,7 @@ stores.inject(MyMetaStore, storeInstance);
15252
15284
  initialMessages = dropCommands(initialMessages, "SORT_CELLS");
15253
15285
  initialMessages = dropCommands(initialMessages, "SET_DECIMAL");
15254
15286
  initialMessages = fixChartDefinitions(data, initialMessages);
15287
+ initialMessages = fixTranslatedDuplicateSheetName(data, initialMessages);
15255
15288
  return initialMessages;
15256
15289
  }
15257
15290
  /**
@@ -15351,6 +15384,40 @@ stores.inject(MyMetaStore, storeInstance);
15351
15384
  }
15352
15385
  return messages;
15353
15386
  }
15387
+ function fixTranslatedDuplicateSheetName(data, initialMessages) {
15388
+ const sheetNames = {};
15389
+ for (const sheet of data.sheets || []) {
15390
+ sheetNames[sheet.id] = sheet.name;
15391
+ }
15392
+ const messages = [];
15393
+ for (const message of initialMessages) {
15394
+ if (message.type === "REMOTE_REVISION") {
15395
+ const commands = [];
15396
+ for (const cmd of message.commands) {
15397
+ switch (cmd.type) {
15398
+ case "DUPLICATE_SHEET":
15399
+ cmd.sheetNameTo =
15400
+ cmd.sheetNameTo ??
15401
+ getDuplicateSheetName(sheetNames[cmd.sheetId], Object.values(sheetNames));
15402
+ break;
15403
+ case "CREATE_SHEET":
15404
+ case "RENAME_SHEET":
15405
+ sheetNames[cmd.sheetId] = cmd.name || getNextSheetName(Object.values(sheetNames));
15406
+ break;
15407
+ }
15408
+ commands.push(cmd);
15409
+ }
15410
+ messages.push({
15411
+ ...message,
15412
+ commands,
15413
+ });
15414
+ }
15415
+ else {
15416
+ messages.push(message);
15417
+ }
15418
+ }
15419
+ return initialMessages;
15420
+ }
15354
15421
  // -----------------------------------------------------------------------------
15355
15422
  // Helpers
15356
15423
  // -----------------------------------------------------------------------------
@@ -24366,7 +24433,7 @@ stores.inject(MyMetaStore, storeInstance);
24366
24433
  return { value: "" };
24367
24434
  }
24368
24435
  if (result.value === null) {
24369
- result.value = "";
24436
+ return { ...result, value: "" };
24370
24437
  }
24371
24438
  return result;
24372
24439
  },
@@ -24387,7 +24454,7 @@ stores.inject(MyMetaStore, storeInstance);
24387
24454
  return { value: "" };
24388
24455
  }
24389
24456
  if (result.value === null) {
24390
- result.value = "";
24457
+ return { ...result, value: "" };
24391
24458
  }
24392
24459
  return result;
24393
24460
  },
@@ -24408,7 +24475,7 @@ stores.inject(MyMetaStore, storeInstance);
24408
24475
  return { value: "" };
24409
24476
  }
24410
24477
  if (result.value === null) {
24411
- result.value = "";
24478
+ return { ...result, value: "" };
24412
24479
  }
24413
24480
  return result;
24414
24481
  },
@@ -24434,7 +24501,7 @@ stores.inject(MyMetaStore, storeInstance);
24434
24501
  return { value: "" };
24435
24502
  }
24436
24503
  if (result.value === null) {
24437
- result.value = "";
24504
+ return { ...result, value: "" };
24438
24505
  }
24439
24506
  return result;
24440
24507
  }
@@ -24552,6 +24619,11 @@ stores.inject(MyMetaStore, storeInstance);
24552
24619
  if (range === undefined || range.invalidXc || range.invalidSheetName) {
24553
24620
  throw new InvalidReferenceError();
24554
24621
  }
24622
+ if (evalContext.__originCellPosition &&
24623
+ range.sheetId === evalContext.__originSheetId &&
24624
+ isZoneInside(positionToZone(evalContext.__originCellPosition), zone)) {
24625
+ throw new CircularDependencyError();
24626
+ }
24555
24627
  dependencies.push(range);
24556
24628
  }
24557
24629
  for (const measure of forMeasures) {
@@ -27559,6 +27631,13 @@ stores.inject(MyMetaStore, storeInstance);
27559
27631
  openAssistant() {
27560
27632
  this.assistant.forcedClosed = false;
27561
27633
  }
27634
+ onWheel(event) {
27635
+ // detect if scrollbar is available
27636
+ if (this.composerRef.el &&
27637
+ this.composerRef.el.scrollHeight > this.composerRef.el.clientHeight) {
27638
+ event.stopPropagation();
27639
+ }
27640
+ }
27562
27641
  // ---------------------------------------------------------------------------
27563
27642
  // Private
27564
27643
  // ---------------------------------------------------------------------------
@@ -32558,10 +32637,13 @@ stores.inject(MyMetaStore, storeInstance);
32558
32637
  name: _t("Duplicate"),
32559
32638
  execute: (env) => {
32560
32639
  const sheetIdFrom = env.model.getters.getActiveSheetId();
32640
+ const sheetNameFrom = env.model.getters.getSheetName(sheetIdFrom);
32561
32641
  const sheetIdTo = env.model.uuidGenerator.smallUuid();
32642
+ const sheetNameTo = env.model.getters.getDuplicateSheetName(sheetNameFrom);
32562
32643
  env.model.dispatch("DUPLICATE_SHEET", {
32563
32644
  sheetId: sheetIdFrom,
32564
32645
  sheetIdTo,
32646
+ sheetNameTo,
32565
32647
  });
32566
32648
  env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom, sheetIdTo });
32567
32649
  },
@@ -43900,8 +43982,8 @@ stores.inject(MyMetaStore, storeInstance);
43900
43982
 
43901
43983
  const NULL_SYMBOL = Symbol("NULL");
43902
43984
  function createDate(dimension, value, locale) {
43903
- const granularity = dimension.granularity;
43904
- if (!granularity || !(granularity in MAP_VALUE_DIMENSION_DATE)) {
43985
+ const granularity = dimension.granularity || "month";
43986
+ if (!(granularity in MAP_VALUE_DIMENSION_DATE)) {
43905
43987
  throw new Error(`Unknown date granularity: ${granularity}`);
43906
43988
  }
43907
43989
  const keyInMap = typeof value === "number" || typeof value === "string" ? value : NULL_SYMBOL;
@@ -43920,6 +44002,9 @@ stores.inject(MyMetaStore, storeInstance);
43920
44002
  case "month_number":
43921
44003
  number = date.getMonth() + 1;
43922
44004
  break;
44005
+ case "month":
44006
+ number = Math.floor(toNumber(value, locale));
44007
+ break;
43923
44008
  case "iso_week_number":
43924
44009
  number = date.getIsoWeek();
43925
44010
  break;
@@ -44013,6 +44098,10 @@ stores.inject(MyMetaStore, storeInstance);
44013
44098
  set: new Set(),
44014
44099
  values: {},
44015
44100
  },
44101
+ month: {
44102
+ set: new Set(),
44103
+ values: {},
44104
+ },
44016
44105
  iso_week_number: {
44017
44106
  set: new Set(),
44018
44107
  values: {},
@@ -44223,7 +44312,7 @@ stores.inject(MyMetaStore, storeInstance);
44223
44312
  const cells = this.filterDataEntriesFromDomain(this.dataEntries, domain);
44224
44313
  const finalCell = cells[0]?.[dimension.nameWithGranularity];
44225
44314
  if (dimension.type === "datetime") {
44226
- const adapter = pivotTimeAdapter(dimension.granularity);
44315
+ const adapter = pivotTimeAdapter((dimension.granularity || "month"));
44227
44316
  return adapter.toValueAndFormat(lastNode.value, this.getters.getLocale());
44228
44317
  }
44229
44318
  if (!finalCell) {
@@ -44341,7 +44430,7 @@ stores.inject(MyMetaStore, storeInstance);
44341
44430
  if (nonEmptyCells.length === 0) {
44342
44431
  return "integer";
44343
44432
  }
44344
- if (nonEmptyCells.every((cell) => cell.format && isDateTimeFormat(cell.format))) {
44433
+ if (nonEmptyCells.every((cell) => cell.type === CellValueType.number && cell.format && isDateTimeFormat(cell.format))) {
44345
44434
  return "datetime";
44346
44435
  }
44347
44436
  if (nonEmptyCells.every((cell) => cell.type === CellValueType.boolean)) {
@@ -44436,7 +44525,7 @@ stores.inject(MyMetaStore, storeInstance);
44436
44525
  for (const entry of dataEntries) {
44437
44526
  for (const dimension of dateDimensions) {
44438
44527
  const value = createDate(dimension, entry[dimension.fieldName]?.value || null, this.getters.getLocale());
44439
- const adapter = pivotTimeAdapter(dimension.granularity);
44528
+ const adapter = pivotTimeAdapter((dimension.granularity || "month"));
44440
44529
  const { format, value: valueToFormat } = adapter.toValueAndFormat(value, locale);
44441
44530
  entry[dimension.nameWithGranularity] = {
44442
44531
  value,
@@ -44456,6 +44545,7 @@ stores.inject(MyMetaStore, storeInstance);
44456
44545
  "year",
44457
44546
  "quarter_number",
44458
44547
  "month_number",
44548
+ "month",
44459
44549
  "iso_week_number",
44460
44550
  "day_of_month",
44461
44551
  "day",
@@ -44696,7 +44786,7 @@ stores.inject(MyMetaStore, storeInstance);
44696
44786
  : this.datetimeGranularities);
44697
44787
  }
44698
44788
  for (const field of dateFields) {
44699
- granularitiesPerFields[field.fieldName].delete(field.granularity);
44789
+ granularitiesPerFields[field.fieldName].delete(field.granularity || "month");
44700
44790
  }
44701
44791
  return granularitiesPerFields;
44702
44792
  }
@@ -46854,6 +46944,8 @@ stores.inject(MyMetaStore, storeInstance);
46854
46944
  }
46855
46945
  get composerProps() {
46856
46946
  const { width, height } = this.env.model.getters.getSheetViewDimensionWithHeaders();
46947
+ // Remove the wrapper border width
46948
+ const maxHeight = this.props.gridDims.height - this.rect.y - 2 * COMPOSER_BORDER_WIDTH;
46857
46949
  return {
46858
46950
  rect: { ...this.rect },
46859
46951
  delimitation: {
@@ -46871,6 +46963,7 @@ stores.inject(MyMetaStore, storeInstance);
46871
46963
  }),
46872
46964
  onInputContextMenu: this.props.onInputContextMenu,
46873
46965
  composerStore: this.composerStore,
46966
+ inputStyle: `max-height: ${maxHeight}px;`,
46874
46967
  };
46875
46968
  }
46876
46969
  get containerStyle() {
@@ -52270,9 +52363,7 @@ stores.inject(MyMetaStore, storeInstance);
52270
52363
  : "Success" /* CommandResult.Success */;
52271
52364
  }
52272
52365
  checkChartExists(cmd) {
52273
- return this.getters.getFigureSheetId(cmd.id)
52274
- ? "Success" /* CommandResult.Success */
52275
- : "ChartDoesNotExist" /* CommandResult.ChartDoesNotExist */;
52366
+ return this.isChartDefined(cmd.id) ? "Success" /* CommandResult.Success */ : "ChartDoesNotExist" /* CommandResult.ChartDoesNotExist */;
52276
52367
  }
52277
52368
  }
52278
52369
 
@@ -54533,6 +54624,7 @@ stores.inject(MyMetaStore, storeInstance);
54533
54624
  "getCommandZones",
54534
54625
  "getUnboundedZone",
54535
54626
  "checkElementsIncludeAllNonFrozenHeaders",
54627
+ "getDuplicateSheetName",
54536
54628
  ];
54537
54629
  sheetIdsMapName = {};
54538
54630
  orderedSheetIds = [];
@@ -54557,7 +54649,11 @@ stores.inject(MyMetaStore, storeInstance);
54557
54649
  return this.checkValidations(cmd, this.checkSheetName, this.checkSheetPosition);
54558
54650
  }
54559
54651
  case "DUPLICATE_SHEET": {
54560
- return this.sheets[cmd.sheetIdTo] ? "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */ : "Success" /* CommandResult.Success */;
54652
+ if (this.sheets[cmd.sheetIdTo])
54653
+ return "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */;
54654
+ if (this.orderedSheetIds.map(this.getSheetName.bind(this)).includes(cmd.sheetNameTo))
54655
+ return "DuplicatedSheetName" /* CommandResult.DuplicatedSheetName */;
54656
+ return "Success" /* CommandResult.Success */;
54561
54657
  }
54562
54658
  case "MOVE_SHEET":
54563
54659
  try {
@@ -54634,7 +54730,7 @@ stores.inject(MyMetaStore, storeInstance);
54634
54730
  this.showSheet(cmd.sheetId);
54635
54731
  break;
54636
54732
  case "DUPLICATE_SHEET":
54637
- this.duplicateSheet(cmd.sheetId, cmd.sheetIdTo);
54733
+ this.duplicateSheet(cmd.sheetId, cmd.sheetIdTo, cmd.sheetNameTo);
54638
54734
  break;
54639
54735
  case "DELETE_SHEET":
54640
54736
  this.deleteSheet(this.sheets[cmd.sheetId]);
@@ -54840,14 +54936,8 @@ stores.inject(MyMetaStore, storeInstance);
54840
54936
  return dimension === "COL" ? this.getNumberCols(sheetId) : this.getNumberRows(sheetId);
54841
54937
  }
54842
54938
  getNextSheetName(baseName = "Sheet") {
54843
- let i = 1;
54844
54939
  const names = this.orderedSheetIds.map(this.getSheetName.bind(this));
54845
- let name = `${baseName}${i}`;
54846
- while (names.includes(name)) {
54847
- name = `${baseName}${i}`;
54848
- i++;
54849
- }
54850
- return name;
54940
+ return getNextSheetName(names, baseName);
54851
54941
  }
54852
54942
  getSheetSize(sheetId) {
54853
54943
  return {
@@ -55093,9 +55183,8 @@ stores.inject(MyMetaStore, storeInstance);
55093
55183
  showSheet(sheetId) {
55094
55184
  this.history.update("sheets", sheetId, "isVisible", true);
55095
55185
  }
55096
- duplicateSheet(fromId, toId) {
55186
+ duplicateSheet(fromId, toId, toName) {
55097
55187
  const sheet = this.getSheet(fromId);
55098
- const toName = this.getDuplicateSheetName(sheet.name);
55099
55188
  const newSheet = deepCopy(sheet);
55100
55189
  newSheet.id = toId;
55101
55190
  newSheet.name = toName;
@@ -55127,15 +55216,8 @@ stores.inject(MyMetaStore, storeInstance);
55127
55216
  this.history.update("sheetIdsMapName", sheetIdsMapName);
55128
55217
  }
55129
55218
  getDuplicateSheetName(sheetName) {
55130
- let i = 1;
55131
55219
  const names = this.orderedSheetIds.map(this.getSheetName.bind(this));
55132
- const baseName = _t("Copy of %s", sheetName);
55133
- let name = baseName.toString();
55134
- while (names.includes(name)) {
55135
- name = `${baseName} (${i})`;
55136
- i++;
55137
- }
55138
- return name;
55220
+ return getDuplicateSheetName(sheetName, names);
55139
55221
  }
55140
55222
  deleteSheet(sheet) {
55141
55223
  const name = sheet.name;
@@ -57961,8 +58043,8 @@ stores.inject(MyMetaStore, storeInstance);
57961
58043
  const EMPTY_ARRAY = [];
57962
58044
 
57963
58045
  const MAX_ITERATION = 30;
57964
- const ERROR_CYCLE_CELL = createEvaluatedCell(new CircularDependencyError());
57965
- const EMPTY_CELL = createEvaluatedCell({ value: null });
58046
+ const ERROR_CYCLE_CELL = Object.freeze(createEvaluatedCell(new CircularDependencyError()));
58047
+ const EMPTY_CELL = Object.freeze(createEvaluatedCell({ value: null }));
57966
58048
  class Evaluator {
57967
58049
  context;
57968
58050
  getters;
@@ -73793,9 +73875,9 @@ stores.inject(MyMetaStore, storeInstance);
73793
73875
  exports.tokenize = tokenize;
73794
73876
 
73795
73877
 
73796
- __info__.version = "18.0.26";
73797
- __info__.date = "2025-05-02T12:30:31.966Z";
73798
- __info__.hash = "5bdf504";
73878
+ __info__.version = "18.0.27";
73879
+ __info__.date = "2025-05-12T05:25:47.149Z";
73880
+ __info__.hash = "9b36340";
73799
73881
 
73800
73882
 
73801
73883
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);