@odoo/o-spreadsheet 17.4.33 → 17.4.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 17.4.33
6
- * @date 2025-05-02T12:30:31.263Z
7
- * @hash 3ba00e6
5
+ * @version 17.4.34
6
+ * @date 2025-05-12T05:23:37.387Z
7
+ * @hash e3ac48a
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -5191,6 +5191,25 @@
5191
5191
  })
5192
5192
  .filter(isDefined);
5193
5193
  }
5194
+ function getNextSheetName(existingNames, baseName = "Sheet") {
5195
+ let i = 1;
5196
+ let name = `${baseName}${i}`;
5197
+ while (existingNames.includes(name)) {
5198
+ name = `${baseName}${i}`;
5199
+ i++;
5200
+ }
5201
+ return name;
5202
+ }
5203
+ function getDuplicateSheetName(nameToDuplicate, existingNames) {
5204
+ let i = 1;
5205
+ const baseName = _t("Copy of %s", nameToDuplicate);
5206
+ let name = baseName.toString();
5207
+ while (existingNames.includes(name)) {
5208
+ name = `${baseName} (${i})`;
5209
+ i++;
5210
+ }
5211
+ return name;
5212
+ }
5194
5213
 
5195
5214
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
5196
5215
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
@@ -6394,6 +6413,24 @@
6394
6413
  return `${normalizedValue}`;
6395
6414
  },
6396
6415
  };
6416
+ /**
6417
+ * normalizes month number + year
6418
+ */
6419
+ const monthAdapter = {
6420
+ normalizeFunctionValue(value) {
6421
+ const date = toNumber(value, DEFAULT_LOCALE);
6422
+ return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
6423
+ },
6424
+ toValueAndFormat(normalizedValue) {
6425
+ return {
6426
+ value: toNumber(normalizedValue, DEFAULT_LOCALE),
6427
+ format: "mmmm yyyy",
6428
+ };
6429
+ },
6430
+ toFunctionValue(normalizedValue) {
6431
+ return `"${normalizedValue}"`;
6432
+ },
6433
+ };
6397
6434
  /**
6398
6435
  * normalizes quarter number
6399
6436
  */
@@ -6461,6 +6498,7 @@
6461
6498
  .add("day_of_month", nullHandlerDecorator(dayOfMonthAdapter))
6462
6499
  .add("iso_week_number", nullHandlerDecorator(isoWeekNumberAdapter))
6463
6500
  .add("month_number", nullHandlerDecorator(monthNumberAdapter))
6501
+ .add("month", nullHandlerDecorator(monthAdapter))
6464
6502
  .add("quarter_number", nullHandlerDecorator(quarterNumberAdapter));
6465
6503
 
6466
6504
  const AGGREGATOR_NAMES = {
@@ -6641,10 +6679,7 @@
6641
6679
  return normalizer(groupValueString, dimension.granularity);
6642
6680
  }
6643
6681
  function normalizeDateTime(value, granularity) {
6644
- if (!granularity) {
6645
- throw new Error("Missing granularity");
6646
- }
6647
- return pivotTimeAdapter(granularity).normalizeFunctionValue(value);
6682
+ return pivotTimeAdapter(granularity ?? "month").normalizeFunctionValue(value);
6648
6683
  }
6649
6684
  function toFunctionPivotValue(value, dimension) {
6650
6685
  if (value === null) {
@@ -6656,10 +6691,7 @@
6656
6691
  return pivotToFunctionValueRegistry.get(dimension.type)(value, dimension.granularity);
6657
6692
  }
6658
6693
  function toFunctionValueDateTime(value, granularity) {
6659
- if (!granularity) {
6660
- throw new Error("Missing granularity");
6661
- }
6662
- return pivotTimeAdapter(granularity).toFunctionValue(value);
6694
+ return pivotTimeAdapter(granularity ?? "month").toFunctionValue(value);
6663
6695
  }
6664
6696
  const pivotNormalizationValueRegistry = new Registry();
6665
6697
  pivotNormalizationValueRegistry
@@ -19383,7 +19415,7 @@ stores.inject(MyMetaStore, storeInstance);
19383
19415
  return { value: "" };
19384
19416
  }
19385
19417
  if (result.value === null) {
19386
- result.value = "";
19418
+ return { ...result, value: "" };
19387
19419
  }
19388
19420
  return result;
19389
19421
  },
@@ -19404,7 +19436,7 @@ stores.inject(MyMetaStore, storeInstance);
19404
19436
  return { value: "" };
19405
19437
  }
19406
19438
  if (result.value === null) {
19407
- result.value = "";
19439
+ return { ...result, value: "" };
19408
19440
  }
19409
19441
  return result;
19410
19442
  },
@@ -19425,7 +19457,7 @@ stores.inject(MyMetaStore, storeInstance);
19425
19457
  return { value: "" };
19426
19458
  }
19427
19459
  if (result.value === null) {
19428
- result.value = "";
19460
+ return { ...result, value: "" };
19429
19461
  }
19430
19462
  return result;
19431
19463
  },
@@ -19451,7 +19483,7 @@ stores.inject(MyMetaStore, storeInstance);
19451
19483
  return { value: "" };
19452
19484
  }
19453
19485
  if (result.value === null) {
19454
- result.value = "";
19486
+ return { ...result, value: "" };
19455
19487
  }
19456
19488
  return result;
19457
19489
  }
@@ -22622,10 +22654,13 @@ stores.inject(MyMetaStore, storeInstance);
22622
22654
  name: _t("Duplicate"),
22623
22655
  execute: (env) => {
22624
22656
  const sheetIdFrom = env.model.getters.getActiveSheetId();
22657
+ const sheetNameFrom = env.model.getters.getSheetName(sheetIdFrom);
22625
22658
  const sheetIdTo = env.model.uuidGenerator.smallUuid();
22659
+ const sheetNameTo = env.model.getters.getDuplicateSheetName(sheetNameFrom);
22626
22660
  env.model.dispatch("DUPLICATE_SHEET", {
22627
22661
  sheetId: sheetIdFrom,
22628
22662
  sheetIdTo,
22663
+ sheetNameTo,
22629
22664
  });
22630
22665
  env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom, sheetIdTo });
22631
22666
  },
@@ -24070,6 +24105,13 @@ stores.inject(MyMetaStore, storeInstance);
24070
24105
  this.props.onInputContextMenu?.(ev);
24071
24106
  }
24072
24107
  }
24108
+ onWheel(event) {
24109
+ // detect if scrollbar is available
24110
+ if (this.composerRef.el &&
24111
+ this.composerRef.el.scrollHeight > this.composerRef.el.clientHeight) {
24112
+ event.stopPropagation();
24113
+ }
24114
+ }
24073
24115
  // ---------------------------------------------------------------------------
24074
24116
  // Private
24075
24117
  // ---------------------------------------------------------------------------
@@ -29358,7 +29400,7 @@ stores.inject(MyMetaStore, storeInstance);
29358
29400
  if (!pivot.isValid()) {
29359
29401
  return;
29360
29402
  }
29361
- env.model.dispatch("INSERT_PIVOT", {
29403
+ env.model.dispatch("SPLIT_PIVOT_FORMULA", {
29362
29404
  sheetId,
29363
29405
  col,
29364
29406
  row,
@@ -36992,8 +37034,8 @@ stores.inject(MyMetaStore, storeInstance);
36992
37034
 
36993
37035
  const NULL_SYMBOL = Symbol("NULL");
36994
37036
  function createDate(dimension, value, locale) {
36995
- const granularity = dimension.granularity;
36996
- if (!granularity || !(granularity in MAP_VALUE_DIMENSION_DATE)) {
37037
+ const granularity = dimension.granularity || "month";
37038
+ if (!(granularity in MAP_VALUE_DIMENSION_DATE)) {
36997
37039
  throw new Error(`Unknown date granularity: ${granularity}`);
36998
37040
  }
36999
37041
  const keyInMap = typeof value === "number" || typeof value === "string" ? value : NULL_SYMBOL;
@@ -37012,6 +37054,9 @@ stores.inject(MyMetaStore, storeInstance);
37012
37054
  case "month_number":
37013
37055
  number = date.getMonth() + 1;
37014
37056
  break;
37057
+ case "month":
37058
+ number = Math.floor(toNumber(value, locale));
37059
+ break;
37015
37060
  case "iso_week_number":
37016
37061
  number = date.getIsoWeek();
37017
37062
  break;
@@ -37070,6 +37115,10 @@ stores.inject(MyMetaStore, storeInstance);
37070
37115
  set: new Set(),
37071
37116
  values: {},
37072
37117
  },
37118
+ month: {
37119
+ set: new Set(),
37120
+ values: {},
37121
+ },
37073
37122
  iso_week_number: {
37074
37123
  set: new Set(),
37075
37124
  values: {},
@@ -37246,7 +37295,7 @@ stores.inject(MyMetaStore, storeInstance);
37246
37295
  const cells = this.filterDataEntriesFromDomain(this.dataEntries, domain);
37247
37296
  const finalCell = cells[0]?.[dimension.nameWithGranularity];
37248
37297
  if (dimension.type === "date") {
37249
- const adapter = pivotTimeAdapter(dimension.granularity);
37298
+ const adapter = pivotTimeAdapter((dimension.granularity || "month"));
37250
37299
  return adapter.toValueAndFormat(lastNode.value, this.getters.getLocale());
37251
37300
  }
37252
37301
  if (!finalCell) {
@@ -37331,7 +37380,7 @@ stores.inject(MyMetaStore, storeInstance);
37331
37380
  if (nonEmptyCells.length === 0) {
37332
37381
  return "integer";
37333
37382
  }
37334
- if (nonEmptyCells.every((cell) => cell.format && isDateTimeFormat(cell.format))) {
37383
+ if (nonEmptyCells.every((cell) => cell.type === CellValueType.number && cell.format && isDateTimeFormat(cell.format))) {
37335
37384
  return "date";
37336
37385
  }
37337
37386
  if (nonEmptyCells.every((cell) => cell.type === CellValueType.boolean)) {
@@ -37446,6 +37495,7 @@ stores.inject(MyMetaStore, storeInstance);
37446
37495
  "year",
37447
37496
  "quarter_number",
37448
37497
  "month_number",
37498
+ "month",
37449
37499
  "iso_week_number",
37450
37500
  "day_of_month",
37451
37501
  "day",
@@ -37655,7 +37705,7 @@ stores.inject(MyMetaStore, storeInstance);
37655
37705
  granularitiesPerFields[field.name] = new Set(granularities);
37656
37706
  }
37657
37707
  for (const field of dateFields) {
37658
- granularitiesPerFields[field.name].delete(field.granularity);
37708
+ granularitiesPerFields[field.name].delete(field.granularity || "month");
37659
37709
  }
37660
37710
  return granularitiesPerFields;
37661
37711
  }
@@ -39542,12 +39592,15 @@ stores.inject(MyMetaStore, storeInstance);
39542
39592
  });
39543
39593
  }
39544
39594
  get composerProps() {
39595
+ // Remove the wrapper border width
39596
+ const maxHeight = this.props.gridDims.height - this.rect.y - 2 * COMPOSER_BORDER_WIDTH;
39545
39597
  return {
39546
39598
  focus: this.composerFocusStore.gridComposerFocus,
39547
39599
  isDefaultFocus: true,
39548
39600
  onComposerContentFocused: () => this.composerFocusStore.focusGridComposerContent(),
39549
39601
  onComposerCellFocused: (content) => this.composerFocusStore.focusGridComposerCell(content),
39550
39602
  onInputContextMenu: this.props.onInputContextMenu,
39603
+ inputStyle: `max-height: ${maxHeight}px;`,
39551
39604
  };
39552
39605
  }
39553
39606
  get containerStyle() {
@@ -47304,6 +47357,7 @@ stores.inject(MyMetaStore, storeInstance);
47304
47357
  initialMessages = dropCommands(initialMessages, "SORT_CELLS");
47305
47358
  initialMessages = dropCommands(initialMessages, "SET_DECIMAL");
47306
47359
  initialMessages = fixChartDefinitions(data, initialMessages);
47360
+ initialMessages = fixTranslatedDuplicateSheetName(data, initialMessages);
47307
47361
  return initialMessages;
47308
47362
  }
47309
47363
  /**
@@ -47423,6 +47477,40 @@ stores.inject(MyMetaStore, storeInstance);
47423
47477
  }
47424
47478
  return data;
47425
47479
  }
47480
+ function fixTranslatedDuplicateSheetName(data, initialMessages) {
47481
+ const sheetNames = {};
47482
+ for (const sheet of data.sheets || []) {
47483
+ sheetNames[sheet.id] = sheet.name;
47484
+ }
47485
+ const messages = [];
47486
+ for (const message of initialMessages) {
47487
+ if (message.type === "REMOTE_REVISION") {
47488
+ const commands = [];
47489
+ for (const cmd of message.commands) {
47490
+ switch (cmd.type) {
47491
+ case "DUPLICATE_SHEET":
47492
+ cmd.sheetNameTo =
47493
+ cmd.sheetNameTo ??
47494
+ getDuplicateSheetName(sheetNames[cmd.sheetId], Object.values(sheetNames));
47495
+ break;
47496
+ case "CREATE_SHEET":
47497
+ case "RENAME_SHEET":
47498
+ sheetNames[cmd.sheetId] = cmd.name || getNextSheetName(Object.values(sheetNames));
47499
+ break;
47500
+ }
47501
+ commands.push(cmd);
47502
+ }
47503
+ messages.push({
47504
+ ...message,
47505
+ commands,
47506
+ });
47507
+ }
47508
+ else {
47509
+ messages.push(message);
47510
+ }
47511
+ }
47512
+ return initialMessages;
47513
+ }
47426
47514
  // -----------------------------------------------------------------------------
47427
47515
  // Helpers
47428
47516
  // -----------------------------------------------------------------------------
@@ -48958,9 +49046,7 @@ stores.inject(MyMetaStore, storeInstance);
48958
49046
  : "Success" /* CommandResult.Success */;
48959
49047
  }
48960
49048
  checkChartExists(cmd) {
48961
- return this.getters.getFigureSheetId(cmd.id)
48962
- ? "Success" /* CommandResult.Success */
48963
- : "ChartDoesNotExist" /* CommandResult.ChartDoesNotExist */;
49049
+ return this.isChartDefined(cmd.id) ? "Success" /* CommandResult.Success */ : "ChartDoesNotExist" /* CommandResult.ChartDoesNotExist */;
48964
49050
  }
48965
49051
  }
48966
49052
 
@@ -51137,6 +51223,7 @@ stores.inject(MyMetaStore, storeInstance);
51137
51223
  "getCommandZones",
51138
51224
  "getUnboundedZone",
51139
51225
  "checkElementsIncludeAllNonFrozenHeaders",
51226
+ "getDuplicateSheetName",
51140
51227
  ];
51141
51228
  sheetIdsMapName = {};
51142
51229
  orderedSheetIds = [];
@@ -51161,7 +51248,11 @@ stores.inject(MyMetaStore, storeInstance);
51161
51248
  return this.checkValidations(cmd, this.checkSheetName, this.checkSheetPosition);
51162
51249
  }
51163
51250
  case "DUPLICATE_SHEET": {
51164
- return this.sheets[cmd.sheetIdTo] ? "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */ : "Success" /* CommandResult.Success */;
51251
+ if (this.sheets[cmd.sheetIdTo])
51252
+ return "DuplicatedSheetId" /* CommandResult.DuplicatedSheetId */;
51253
+ if (this.orderedSheetIds.map(this.getSheetName.bind(this)).includes(cmd.sheetNameTo))
51254
+ return "DuplicatedSheetName" /* CommandResult.DuplicatedSheetName */;
51255
+ return "Success" /* CommandResult.Success */;
51165
51256
  }
51166
51257
  case "MOVE_SHEET":
51167
51258
  try {
@@ -51231,7 +51322,7 @@ stores.inject(MyMetaStore, storeInstance);
51231
51322
  this.showSheet(cmd.sheetId);
51232
51323
  break;
51233
51324
  case "DUPLICATE_SHEET":
51234
- this.duplicateSheet(cmd.sheetId, cmd.sheetIdTo);
51325
+ this.duplicateSheet(cmd.sheetId, cmd.sheetIdTo, cmd.sheetNameTo);
51235
51326
  break;
51236
51327
  case "DELETE_SHEET":
51237
51328
  this.deleteSheet(this.sheets[cmd.sheetId]);
@@ -51431,14 +51522,8 @@ stores.inject(MyMetaStore, storeInstance);
51431
51522
  return dimension === "COL" ? this.getNumberCols(sheetId) : this.getNumberRows(sheetId);
51432
51523
  }
51433
51524
  getNextSheetName(baseName = "Sheet") {
51434
- let i = 1;
51435
51525
  const names = this.orderedSheetIds.map(this.getSheetName.bind(this));
51436
- let name = `${baseName}${i}`;
51437
- while (names.includes(name)) {
51438
- name = `${baseName}${i}`;
51439
- i++;
51440
- }
51441
- return name;
51526
+ return getNextSheetName(names, baseName);
51442
51527
  }
51443
51528
  getSheetSize(sheetId) {
51444
51529
  return {
@@ -51684,9 +51769,8 @@ stores.inject(MyMetaStore, storeInstance);
51684
51769
  showSheet(sheetId) {
51685
51770
  this.history.update("sheets", sheetId, "isVisible", true);
51686
51771
  }
51687
- duplicateSheet(fromId, toId) {
51772
+ duplicateSheet(fromId, toId, toName) {
51688
51773
  const sheet = this.getSheet(fromId);
51689
- const toName = this.getDuplicateSheetName(sheet.name);
51690
51774
  const newSheet = deepCopy(sheet);
51691
51775
  newSheet.id = toId;
51692
51776
  newSheet.name = toName;
@@ -51718,15 +51802,8 @@ stores.inject(MyMetaStore, storeInstance);
51718
51802
  this.history.update("sheetIdsMapName", sheetIdsMapName);
51719
51803
  }
51720
51804
  getDuplicateSheetName(sheetName) {
51721
- let i = 1;
51722
51805
  const names = this.orderedSheetIds.map(this.getSheetName.bind(this));
51723
- const baseName = _t("Copy of %s", sheetName);
51724
- let name = baseName.toString();
51725
- while (names.includes(name)) {
51726
- name = `${baseName} (${i})`;
51727
- i++;
51728
- }
51729
- return name;
51806
+ return getDuplicateSheetName(sheetName, names);
51730
51807
  }
51731
51808
  deleteSheet(sheet) {
51732
51809
  const name = sheet.name;
@@ -54525,8 +54602,8 @@ stores.inject(MyMetaStore, storeInstance);
54525
54602
  const EMPTY_ARRAY = [];
54526
54603
 
54527
54604
  const MAX_ITERATION = 30;
54528
- const ERROR_CYCLE_CELL = createEvaluatedCell(new CircularDependencyError());
54529
- const EMPTY_CELL = createEvaluatedCell({ value: null });
54605
+ const ERROR_CYCLE_CELL = Object.freeze(createEvaluatedCell(new CircularDependencyError()));
54606
+ const EMPTY_CELL = Object.freeze(createEvaluatedCell({ value: null }));
54530
54607
  class Evaluator {
54531
54608
  context;
54532
54609
  getters;
@@ -58588,6 +58665,8 @@ stores.inject(MyMetaStore, storeInstance);
58588
58665
  case "INSERT_PIVOT_WITH_TABLE":
58589
58666
  this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table, cmd.pivotMode);
58590
58667
  break;
58668
+ case "SPLIT_PIVOT_FORMULA":
58669
+ this.splitPivotFormula(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table);
58591
58670
  }
58592
58671
  }
58593
58672
  insertNewPivot(pivotId, sheetId) {
@@ -58735,6 +58814,36 @@ stores.inject(MyMetaStore, storeInstance);
58735
58814
  });
58736
58815
  }
58737
58816
  }
58817
+ splitPivotFormula(sheetId, col, row, pivotId, pivotTableData) {
58818
+ this.dispatch("INSERT_PIVOT", {
58819
+ sheetId,
58820
+ col,
58821
+ row,
58822
+ pivotId,
58823
+ table: pivotTableData,
58824
+ });
58825
+ const table = this.getters.getCoreTable({ sheetId, col, row });
58826
+ if (table?.type === "dynamic") {
58827
+ const zone = positionToZone({ col, row });
58828
+ const { cols, rows, measures, fieldsType } = pivotTableData;
58829
+ const pivotTable = new SpreadsheetPivotTable(cols, rows, measures, fieldsType || {});
58830
+ const colNumber = pivotTable.getNumberOfDataColumns() + 1;
58831
+ const rowNumber = pivotTable.columns.length + pivotTable.rows.length;
58832
+ const tableZone = {
58833
+ left: col,
58834
+ top: row,
58835
+ right: col + colNumber - 1,
58836
+ bottom: row + rowNumber - 1,
58837
+ };
58838
+ const rangeData = this.getters.getRangeDataFromZone(sheetId, tableZone);
58839
+ this.dispatch("UPDATE_TABLE", {
58840
+ sheetId,
58841
+ zone,
58842
+ newTableRange: rangeData,
58843
+ tableType: "static",
58844
+ });
58845
+ }
58846
+ }
58738
58847
  }
58739
58848
 
58740
58849
  class SortPlugin extends UIPlugin {
@@ -69405,9 +69514,9 @@ stores.inject(MyMetaStore, storeInstance);
69405
69514
  exports.tokenize = tokenize;
69406
69515
 
69407
69516
 
69408
- __info__.version = "17.4.33";
69409
- __info__.date = "2025-05-02T12:30:31.263Z";
69410
- __info__.hash = "3ba00e6";
69517
+ __info__.version = "17.4.34";
69518
+ __info__.date = "2025-05-12T05:23:37.387Z";
69519
+ __info__.hash = "e3ac48a";
69411
69520
 
69412
69521
 
69413
69522
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);