@odoo/o-spreadsheet 19.0.1 → 19.0.3

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 19.0.1
6
- * @date 2025-09-11T08:45:47.109Z
7
- * @hash bd79eea
5
+ * @version 19.0.3
6
+ * @date 2025-09-19T07:26:41.356Z
7
+ * @hash 84f3b74
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -889,6 +889,7 @@
889
889
  ARG_SEPARATOR: functionColor,
890
890
  ORPHAN_RIGHT_PAREN: "#ff0000",
891
891
  };
892
+ const DRAG_THRESHOLD = 5; // in pixels, to avoid unwanted drag when clicking
892
893
 
893
894
  //------------------------------------------------------------------------------
894
895
  // Miscellaneous
@@ -1367,8 +1368,19 @@
1367
1368
  },
1368
1369
  }[funcName];
1369
1370
  }
1371
+ /**
1372
+ * Removes the specified indexes from the array.
1373
+ * Sparse (empty) elements are transformed to undefined (unless their index is explicitly removed).
1374
+ */
1370
1375
  function removeIndexesFromArray(array, indexes) {
1371
- return array.filter((_, index) => !indexes.includes(index));
1376
+ const toRemove = new Set(indexes);
1377
+ const newArray = [];
1378
+ for (let i = 0; i < array.length; i++) {
1379
+ if (!toRemove.has(i)) {
1380
+ newArray.push(array[i]);
1381
+ }
1382
+ }
1383
+ return newArray;
1372
1384
  }
1373
1385
  function insertItemsAtIndex(array, items, index) {
1374
1386
  const newArray = [...array];
@@ -16083,8 +16095,9 @@ stores.inject(MyMetaStore, storeInstance);
16083
16095
  }
16084
16096
 
16085
16097
  function sortMatrix(matrix, locale, ...criteria) {
16086
- for (const [i, value] of criteria.entries()) {
16087
- assert(value !== undefined, _t("Value for parameter %d is missing, while the function [[FUNCTION_NAME]] expect a number or a range.", i + 1));
16098
+ for (let i = 0; i < criteria.length; i++) {
16099
+ const param = i % 2 === 0 ? "sort_column" : "is_ascending";
16100
+ assert(criteria[i] !== undefined, _t("Value for parameter %s is missing in [[FUNCTION_NAME]].", param));
16088
16101
  }
16089
16102
  const sortingOrders = [];
16090
16103
  const sortColumns = [];
@@ -32379,7 +32392,11 @@ stores.inject(MyMetaStore, storeInstance);
32379
32392
  onFigureDeleted: Function,
32380
32393
  editFigureStyle: { type: Function, optional: true },
32381
32394
  };
32382
- static components = { ChartDashboardMenu };
32395
+ static components = { ChartDashboardMenu, MenuPopover };
32396
+ carouselTabsRef = owl.useRef("carouselTabs");
32397
+ carouselTabsDropdownRef = owl.useRef("carouselTabsDropdown");
32398
+ menuState = owl.useState({ isOpen: false, anchorRect: null, menuItems: [] });
32399
+ hiddenItems = [];
32383
32400
  animationStore;
32384
32401
  setup() {
32385
32402
  this.animationStore = useStore(ChartAnimationStore);
@@ -32390,6 +32407,7 @@ stores.inject(MyMetaStore, storeInstance);
32390
32407
  else {
32391
32408
  this.props.editFigureStyle?.({ "pointer-events": "auto" });
32392
32409
  }
32410
+ this.updateTabsVisibility();
32393
32411
  });
32394
32412
  }
32395
32413
  get carousel() {
@@ -32449,6 +32467,49 @@ stores.inject(MyMetaStore, storeInstance);
32449
32467
  const style = { ...DEFAULT_CAROUSEL_TITLE_STYLE, ...this.carousel.title };
32450
32468
  return cssPropertiesToCss(cellTextStyleToCss(chartStyleToCellStyle(style)));
32451
32469
  }
32470
+ updateTabsVisibility() {
32471
+ const tabsContainerEl = this.carouselTabsRef.el;
32472
+ const dropDownEl = this.carouselTabsDropdownRef.el;
32473
+ if (!tabsContainerEl || !dropDownEl) {
32474
+ return;
32475
+ }
32476
+ this.hiddenItems = [];
32477
+ const containerRect = getBoundingRectAsPOJO(tabsContainerEl);
32478
+ const tabs = Array.from(tabsContainerEl.children);
32479
+ for (const tab of tabs) {
32480
+ tab.style.display = "block";
32481
+ }
32482
+ const tabWidths = tabs.map((tab) => getBoundingRectAsPOJO(tab).width);
32483
+ let currentWidth = 0;
32484
+ for (let i = 0; i < tabs.length; i++) {
32485
+ const shouldBeHidden = currentWidth + tabWidths[i] > containerRect.width;
32486
+ currentWidth += tabWidths[i];
32487
+ if (shouldBeHidden) {
32488
+ tabs[i].style.display = "none";
32489
+ this.hiddenItems.push(this.carousel.items[i]);
32490
+ }
32491
+ }
32492
+ dropDownEl.style.display = this.hiddenItems.length ? "block" : "none";
32493
+ }
32494
+ get menuId() {
32495
+ return "carousel-tabs-menu-";
32496
+ }
32497
+ toggleMenu(ev) {
32498
+ if (ev.closedMenuId === this.menuId) {
32499
+ this.menuState.isOpen = false;
32500
+ return;
32501
+ }
32502
+ const rect = getRefBoundingRect(this.carouselTabsDropdownRef);
32503
+ const menuItems = this.hiddenItems.map((item) => ({
32504
+ name: this.getItemTitle(item),
32505
+ execute: () => this.onCarouselTabClick(item),
32506
+ isActive: () => this.isItemSelected(item),
32507
+ isReadonlyAllowed: true,
32508
+ }));
32509
+ this.menuState.isOpen = true;
32510
+ this.menuState.anchorRect = rect;
32511
+ this.menuState.menuItems = createActions(menuItems);
32512
+ }
32452
32513
  }
32453
32514
 
32454
32515
  class ChartFigure extends owl.Component {
@@ -50436,9 +50497,16 @@ stores.inject(MyMetaStore, storeInstance);
50436
50497
  maxX: this.env.model.getters.getColDimensions(sheetId, this.env.model.getters.getNumberCols(sheetId) - 1).end,
50437
50498
  maxY: this.env.model.getters.getRowDimensions(sheetId, this.env.model.getters.getNumberRows(sheetId) - 1).end,
50438
50499
  };
50500
+ let hasStartedDnd = false;
50439
50501
  const onMouseMove = (ev) => {
50440
50502
  const getters = this.env.model.getters;
50441
50503
  const currentMousePosition = { x: ev.clientX, y: ev.clientY };
50504
+ const offsetX = Math.abs(currentMousePosition.x - initialMousePosition.x);
50505
+ const offsetY = Math.abs(currentMousePosition.y - initialMousePosition.y);
50506
+ if (!hasStartedDnd && offsetX < DRAG_THRESHOLD && offsetY < DRAG_THRESHOLD) {
50507
+ return; // add a small threshold to avoid dnd when just clicking
50508
+ }
50509
+ hasStartedDnd = true;
50442
50510
  const draggedFigure = dragFigureForMove(currentMousePosition, initialMousePosition, initialFigure, maxDimensions, initialScrollPosition, getters.getActiveSheetScrollInfo());
50443
50511
  const otherFigures = this.getOtherFigures(initialFigure.id);
50444
50512
  const overlappingCarousel = this.getCarouselOverlappingChart(draggedFigure, otherFigures);
@@ -58850,12 +58918,13 @@ stores.inject(MyMetaStore, storeInstance);
58850
58918
  addCalculatedMeasure() {
58851
58919
  const { measures } = this.props.definition;
58852
58920
  const measureName = this.env.model.getters.generateNewCalculatedMeasureName(measures);
58921
+ const aggregator = "sum";
58853
58922
  this.props.onDimensionsUpdated({
58854
58923
  measures: measures.concat([
58855
58924
  {
58856
- id: this.getMeasureId(measureName),
58925
+ id: this.getMeasureId(measureName, aggregator),
58857
58926
  fieldName: measureName,
58858
- aggregator: "sum",
58927
+ aggregator,
58859
58928
  computedBy: {
58860
58929
  sheetId: this.env.model.getters.getActiveSheetId(),
58861
58930
  formula: "=0",
@@ -71160,7 +71229,7 @@ stores.inject(MyMetaStore, storeInstance);
71160
71229
  return { value: 0 };
71161
71230
  }
71162
71231
  const { columns, rows } = super.definition;
71163
- if (columns.length + rows.length !== domain.length) {
71232
+ if (measure.aggregator && columns.length + rows.length !== domain.length) {
71164
71233
  const values = this.getValuesToAggregate(measure, domain);
71165
71234
  const aggregator = AGGREGATORS_FN[measure.aggregator];
71166
71235
  if (!aggregator) {
@@ -71179,11 +71248,17 @@ stores.inject(MyMetaStore, storeInstance);
71179
71248
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
71180
71249
  const { colDomain } = domainToColRowDomain(this, domain);
71181
71250
  const symbolIndex = colDomain.findIndex((node) => node.field === symbolName);
71251
+ if (symbolIndex === -1) {
71252
+ return new NotAvailableError();
71253
+ }
71182
71254
  return this.getPivotHeaderValueAndFormat(colDomain.slice(0, symbolIndex + 1));
71183
71255
  }
71184
71256
  if (rows.find((row) => row.nameWithGranularity === symbolName)) {
71185
71257
  const { rowDomain } = domainToColRowDomain(this, domain);
71186
71258
  const symbolIndex = rowDomain.findIndex((row) => row.field === symbolName);
71259
+ if (symbolIndex === -1) {
71260
+ return new NotAvailableError();
71261
+ }
71187
71262
  return this.getPivotHeaderValueAndFormat(rowDomain.slice(0, symbolIndex + 1));
71188
71263
  }
71189
71264
  return this.getPivotCellValueAndFormat(symbolName, domain);
@@ -77562,13 +77637,10 @@ stores.inject(MyMetaStore, storeInstance);
77562
77637
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
77563
77638
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
77564
77639
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
77565
- const originalSize = Object.fromEntries(toRemove.map((element) => {
77566
- const size = isCol
77567
- ? this.getters.getColSize(cmd.sheetId, element)
77568
- : this.getters.getUserRowSize(cmd.sheetId, element);
77569
- const isDefaultCol = isCol && size === DEFAULT_CELL_WIDTH;
77570
- return [element, isDefaultCol ? undefined : size];
77571
- }));
77640
+ const originalSize = {};
77641
+ for (const element of toRemove) {
77642
+ originalSize[element] = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
77643
+ }
77572
77644
  const target = [
77573
77645
  {
77574
77646
  left: isCol ? start + deltaCol : 0,
@@ -77612,11 +77684,11 @@ stores.inject(MyMetaStore, storeInstance);
77612
77684
  for (const element of toRemove) {
77613
77685
  const size = originalSize[element];
77614
77686
  const currentSize = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, currentIndex);
77615
- if (size && size !== currentSize) {
77687
+ if (size !== currentSize) {
77616
77688
  resizingGroups[size] ??= [];
77617
77689
  resizingGroups[size].push(currentIndex);
77618
- currentIndex += 1;
77619
77690
  }
77691
+ currentIndex += 1;
77620
77692
  }
77621
77693
  for (const size in resizingGroups) {
77622
77694
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -88456,9 +88528,9 @@ stores.inject(MyMetaStore, storeInstance);
88456
88528
  exports.tokenize = tokenize;
88457
88529
 
88458
88530
 
88459
- __info__.version = "19.0.1";
88460
- __info__.date = "2025-09-11T08:45:47.109Z";
88461
- __info__.hash = "bd79eea";
88531
+ __info__.version = "19.0.3";
88532
+ __info__.date = "2025-09-19T07:26:41.356Z";
88533
+ __info__.hash = "84f3b74";
88462
88534
 
88463
88535
 
88464
88536
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);