@odoo/o-spreadsheet 17.0.44 → 17.0.46

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.0.44
6
- * @date 2024-12-19T07:46:10.942Z
7
- * @hash 820f3cf
5
+ * @version 17.0.46
6
+ * @date 2025-01-27T10:00:20.499Z
7
+ * @hash 1df062c
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -2696,15 +2696,18 @@
2696
2696
  let currentIndex;
2697
2697
  let currentVal;
2698
2698
  let currentType;
2699
+ const getValue = sortOrder === "desc"
2700
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2701
+ : (i) => normalizeValue(getValueInData(data, i));
2699
2702
  while (indexRight - indexLeft >= 0) {
2700
2703
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2701
2704
  currentIndex = indexMedian;
2702
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2705
+ currentVal = getValue(currentIndex);
2703
2706
  currentType = typeof currentVal;
2704
2707
  // 1 - linear search to find value with the same type
2705
2708
  while (indexLeft < currentIndex && targetType !== currentType) {
2706
2709
  currentIndex--;
2707
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2710
+ currentVal = getValue(currentIndex);
2708
2711
  currentType = typeof currentVal;
2709
2712
  }
2710
2713
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2720,8 +2723,7 @@
2720
2723
  if (matchVal === undefined ||
2721
2724
  matchVal === null ||
2722
2725
  matchVal < currentVal ||
2723
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2724
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2726
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2725
2727
  matchVal = currentVal;
2726
2728
  matchValIndex = currentIndex;
2727
2729
  }
@@ -2729,15 +2731,13 @@
2729
2731
  else if (mode === "nextGreater" && currentVal >= _target) {
2730
2732
  if (matchVal === undefined ||
2731
2733
  matchVal > currentVal ||
2732
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2733
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2734
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2734
2735
  matchVal = currentVal;
2735
2736
  matchValIndex = currentIndex;
2736
2737
  }
2737
2738
  }
2738
2739
  // 3 - give new indexes for the Binary search
2739
- if ((sortOrder === "asc" && currentVal > _target) ||
2740
- (sortOrder === "desc" && currentVal <= _target)) {
2740
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2741
2741
  indexRight = currentIndex - 1;
2742
2742
  }
2743
2743
  else {
@@ -2745,7 +2745,10 @@
2745
2745
  }
2746
2746
  }
2747
2747
  // note that valMinIndex could be 0
2748
- return matchValIndex !== undefined ? matchValIndex : -1;
2748
+ if (matchValIndex === undefined) {
2749
+ return -1;
2750
+ }
2751
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2749
2752
  }
2750
2753
  /**
2751
2754
  * Perform a linear search and return the index of the match.
@@ -6939,6 +6942,10 @@
6939
6942
  this.currentDisplayValue = newDisplay;
6940
6943
  if (!anchor)
6941
6944
  return;
6945
+ el.style.top = "";
6946
+ el.style.left = "";
6947
+ el.style["max-height"] = "";
6948
+ el.style["max-width"] = "";
6942
6949
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6943
6950
  let elDims = {
6944
6951
  width: el.getBoundingClientRect().width,
@@ -27453,7 +27460,7 @@
27453
27460
  return;
27454
27461
  }
27455
27462
  const sheetId = this.env.model.getters.getActiveSheetId();
27456
- const zone = this.env.model.getters.getSelectedZone();
27463
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
27457
27464
  const rect = this.env.model.getters.getVisibleRect(zone);
27458
27465
  if (!deepEquals(rect, this.rect) ||
27459
27466
  sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
@@ -31734,7 +31741,7 @@
31734
31741
  return undefined;
31735
31742
  }
31736
31743
  function isChartData(data) {
31737
- return "dataSets" in data;
31744
+ return "dataSets" in data && data.dataSets.length > 0;
31738
31745
  }
31739
31746
  function isImageData(data) {
31740
31747
  return "imageSrc" in data;
@@ -34548,10 +34555,34 @@
34548
34555
  const elements = [...cmd.elements].sort((a, b) => b - a);
34549
34556
  for (const group of groupConsecutive(elements)) {
34550
34557
  if (cmd.dimension === "COL") {
34551
- this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34558
+ if (group[0] >= this.getters.getNumberCols(cmd.sheetId)) {
34559
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
34560
+ this.history.update("borders", cmd.sheetId, group[0] + 1, row, "vertical", undefined);
34561
+ }
34562
+ }
34563
+ if (group[group.length - 1] === 0) {
34564
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
34565
+ this.history.update("borders", cmd.sheetId, 0, row, "vertical", undefined);
34566
+ }
34567
+ }
34568
+ const zone = this.getters.getColsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
34569
+ this.clearInsideBorders(cmd.sheetId, [zone]);
34570
+ this.shiftBordersHorizontally(cmd.sheetId, group[0] + 1, -group.length);
34552
34571
  }
34553
34572
  else {
34554
- this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34573
+ if (group[0] >= this.getters.getNumberRows(cmd.sheetId)) {
34574
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
34575
+ this.history.update("borders", cmd.sheetId, col, group[0] + 1, "horizontal", undefined);
34576
+ }
34577
+ }
34578
+ if (group[group.length - 1] === 0) {
34579
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
34580
+ this.history.update("borders", cmd.sheetId, col, 0, "horizontal", undefined);
34581
+ }
34582
+ }
34583
+ const zone = this.getters.getRowsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
34584
+ this.clearInsideBorders(cmd.sheetId, [zone]);
34585
+ this.shiftBordersVertically(cmd.sheetId, group[0] + 1, -group.length);
34555
34586
  }
34556
34587
  }
34557
34588
  break;
@@ -34858,6 +34889,18 @@
34858
34889
  }
34859
34890
  }
34860
34891
  }
34892
+ /**
34893
+ * Remove the borders inside of a zone
34894
+ */
34895
+ clearInsideBorders(sheetId, zones) {
34896
+ for (let zone of zones) {
34897
+ for (let row = zone.top; row <= zone.bottom; row++) {
34898
+ for (let col = zone.left; col <= zone.right; col++) {
34899
+ this.history.update("borders", sheetId, col, row, undefined);
34900
+ }
34901
+ }
34902
+ }
34903
+ }
34861
34904
  /**
34862
34905
  * Add a border to the existing one to a cell
34863
34906
  */
@@ -46224,13 +46267,23 @@
46224
46267
  drawGrid(renderingContext, layer) {
46225
46268
  switch (layer) {
46226
46269
  case 0 /* LAYERS.Background */:
46227
- this.boxes = this.getGridBoxes();
46228
- this.drawBackground(renderingContext);
46229
- this.drawOverflowingCellBackground(renderingContext);
46230
- this.drawCellBackground(renderingContext);
46231
- this.drawBorders(renderingContext);
46232
- this.drawTexts(renderingContext);
46233
- this.drawIcon(renderingContext);
46270
+ this.drawGlobalBackground(renderingContext);
46271
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
46272
+ const { ctx } = renderingContext;
46273
+ ctx.save();
46274
+ ctx.beginPath();
46275
+ const rect = this.getters.getVisibleRect(zone);
46276
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
46277
+ ctx.clip();
46278
+ this.boxes = this.getGridBoxes(zone);
46279
+ this.drawBackground(renderingContext);
46280
+ this.drawOverflowingCellBackground(renderingContext);
46281
+ this.drawCellBackground(renderingContext);
46282
+ this.drawBorders(renderingContext);
46283
+ this.drawTexts(renderingContext);
46284
+ this.drawIcon(renderingContext);
46285
+ ctx.restore();
46286
+ }
46234
46287
  this.drawFrozenPanes(renderingContext);
46235
46288
  break;
46236
46289
  case 7 /* LAYERS.Headers */:
@@ -46241,12 +46294,15 @@
46241
46294
  break;
46242
46295
  }
46243
46296
  }
46244
- drawBackground(renderingContext) {
46245
- const { ctx, thinLineWidth } = renderingContext;
46297
+ drawGlobalBackground(renderingContext) {
46298
+ const { ctx } = renderingContext;
46246
46299
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
46247
46300
  // white background
46248
46301
  ctx.fillStyle = "#ffffff";
46249
46302
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
46303
+ }
46304
+ drawBackground(renderingContext) {
46305
+ const { ctx, thinLineWidth } = renderingContext;
46250
46306
  const areGridLinesVisible = !this.getters.isDashboard() &&
46251
46307
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
46252
46308
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -46677,7 +46733,7 @@
46677
46733
  const position = { sheetId, col, row };
46678
46734
  const cell = this.getters.getEvaluatedCell(position);
46679
46735
  const showFormula = this.getters.shouldShowFormulas();
46680
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
46736
+ const { x, y, width, height } = this.getters.getRect(zone);
46681
46737
  const { verticalAlign } = this.getters.getCellStyle(position);
46682
46738
  const box = {
46683
46739
  x,
@@ -46792,12 +46848,16 @@
46792
46848
  }
46793
46849
  return box;
46794
46850
  }
46795
- getGridBoxes() {
46851
+ getGridBoxes(zone) {
46796
46852
  const boxes = [];
46797
- const visibleCols = this.getters.getSheetViewVisibleCols();
46853
+ const visibleCols = this.getters
46854
+ .getSheetViewVisibleCols()
46855
+ .filter((col) => col >= zone.left && col <= zone.right);
46798
46856
  const left = visibleCols[0];
46799
46857
  const right = visibleCols[visibleCols.length - 1];
46800
- const visibleRows = this.getters.getSheetViewVisibleRows();
46858
+ const visibleRows = this.getters
46859
+ .getSheetViewVisibleRows()
46860
+ .filter((row) => row >= zone.top && row <= zone.bottom);
46801
46861
  const top = visibleRows[0];
46802
46862
  const bottom = visibleRows[visibleRows.length - 1];
46803
46863
  const viewport = { left, right, top, bottom };
@@ -50324,7 +50384,7 @@
50324
50384
  ];
50325
50385
  state.paste(pasteTarget, { selectTarget: true });
50326
50386
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50327
- let currentIndex = cmd.base;
50387
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
50328
50388
  for (const element of toRemove) {
50329
50389
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
50330
50390
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -50615,7 +50675,7 @@
50615
50675
  * @param zone
50616
50676
  * @returns Computes the absolute coordinate of a given zone inside the viewport
50617
50677
  */
50618
- getRect(zone) {
50678
+ getVisibleRect(zone) {
50619
50679
  const targetZone = intersection(zone, this.zone);
50620
50680
  if (targetZone) {
50621
50681
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -50623,12 +50683,20 @@
50623
50683
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
50624
50684
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
50625
50685
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
50626
- return {
50627
- x,
50628
- y,
50629
- width,
50630
- height,
50631
- };
50686
+ return { x, y, width, height };
50687
+ }
50688
+ else {
50689
+ return undefined;
50690
+ }
50691
+ }
50692
+ getFullRect(zone) {
50693
+ const targetZone = intersection(zone, this.zone);
50694
+ if (targetZone) {
50695
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
50696
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
50697
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
50698
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
50699
+ return { x, y, width, height };
50632
50700
  }
50633
50701
  else {
50634
50702
  return undefined;
@@ -50812,6 +50880,8 @@
50812
50880
  "getSheetViewVisibleRows",
50813
50881
  "getFrozenSheetViewRatio",
50814
50882
  "isPositionVisible",
50883
+ "getAllActiveViewportsZones",
50884
+ "getRect",
50815
50885
  ];
50816
50886
  viewports = {};
50817
50887
  /**
@@ -51199,16 +51269,27 @@
51199
51269
  getVisibleRectWithoutHeaders(zone) {
51200
51270
  const sheetId = this.getters.getActiveSheetId();
51201
51271
  const viewportRects = this.getSubViewports(sheetId)
51202
- .map((viewport) => viewport.getRect(zone))
51272
+ .map((viewport) => viewport.getVisibleRect(zone))
51203
51273
  .filter(isDefined$1);
51204
51274
  if (viewportRects.length === 0) {
51205
51275
  return { x: 0, y: 0, width: 0, height: 0 };
51206
51276
  }
51207
- const x = Math.min(...viewportRects.map((rect) => rect.x));
51208
- const y = Math.min(...viewportRects.map((rect) => rect.y));
51209
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51210
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51211
- return { x, y, width, height };
51277
+ return this.recomposeRect(viewportRects);
51278
+ }
51279
+ /**
51280
+ * Computes the actual size and position (:Rect) of the zone on the canvas
51281
+ * regardless of the viewport dimensions.
51282
+ */
51283
+ getRect(zone) {
51284
+ const sheetId = this.getters.getActiveSheetId();
51285
+ const viewportRects = this.getSubViewports(sheetId)
51286
+ .map((viewport) => viewport.getFullRect(zone))
51287
+ .filter(isDefined$1);
51288
+ if (viewportRects.length === 0) {
51289
+ return { x: 0, y: 0, width: 0, height: 0 };
51290
+ }
51291
+ const rect = this.recomposeRect(viewportRects);
51292
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
51212
51293
  }
51213
51294
  /**
51214
51295
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -51222,6 +51303,10 @@
51222
51303
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
51223
51304
  return { x, y };
51224
51305
  }
51306
+ getAllActiveViewportsZones() {
51307
+ const sheetId = this.getters.getActiveSheetId();
51308
+ return this.getSubViewports(sheetId);
51309
+ }
51225
51310
  // ---------------------------------------------------------------------------
51226
51311
  // Private
51227
51312
  // ---------------------------------------------------------------------------
@@ -51406,6 +51491,13 @@
51406
51491
  const height = this.sheetViewHeight + this.gridOffsetY;
51407
51492
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
51408
51493
  }
51494
+ recomposeRect(viewportRects) {
51495
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
51496
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
51497
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51498
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51499
+ return { x, y, width, height };
51500
+ }
51409
51501
  }
51410
51502
 
51411
51503
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -51857,17 +51949,17 @@
51857
51949
  sheetNameRef = owl.useRef("sheetNameSpan");
51858
51950
  editionState = "initializing";
51859
51951
  setup() {
51860
- owl.onMounted(() => {
51861
- if (this.isSheetActive) {
51862
- this.scrollToSheet();
51863
- }
51864
- });
51865
51952
  owl.onPatched(() => {
51866
51953
  if (this.sheetNameRef.el && this.state.isEditing && this.editionState === "initializing") {
51867
51954
  this.editionState = "editing";
51868
51955
  this.focusInputAndSelectContent();
51869
51956
  }
51870
51957
  });
51958
+ owl.useEffect((sheetId) => {
51959
+ if (this.props.sheetId === sheetId) {
51960
+ this.scrollToSheet();
51961
+ }
51962
+ }, () => [this.env.model.getters.getActiveSheetId()]);
51871
51963
  }
51872
51964
  focusInputAndSelectContent() {
51873
51965
  if (!this.state.isEditing || !this.sheetNameRef.el)
@@ -51879,7 +51971,10 @@
51879
51971
  }
51880
51972
  }
51881
51973
  scrollToSheet() {
51882
- this.sheetDivRef.el?.scrollIntoView?.();
51974
+ this.sheetDivRef.el?.scrollIntoView?.({
51975
+ behavior: "smooth",
51976
+ inline: "nearest",
51977
+ });
51883
51978
  }
51884
51979
  onFocusOut() {
51885
51980
  if (this.state.isEditing && this.editionState !== "initializing") {
@@ -57630,6 +57725,8 @@
57630
57725
  createActions,
57631
57726
  transformRangeData,
57632
57727
  deepEquals,
57728
+ isNumber,
57729
+ isDateTime,
57633
57730
  };
57634
57731
  const links = {
57635
57732
  isMarkdownLink,
@@ -57708,9 +57805,9 @@
57708
57805
  exports.tokenize = tokenize;
57709
57806
 
57710
57807
 
57711
- __info__.version = "17.0.44";
57712
- __info__.date = "2024-12-19T07:46:10.942Z";
57713
- __info__.hash = "820f3cf";
57808
+ __info__.version = "17.0.46";
57809
+ __info__.date = "2025-01-27T10:00:20.499Z";
57810
+ __info__.hash = "1df062c";
57714
57811
 
57715
57812
 
57716
57813
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);