@odoo/o-spreadsheet 17.0.43 → 17.0.45

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.43
6
- * @date 2024-12-05T10:36:19.412Z
7
- * @hash 8344531
5
+ * @version 17.0.45
6
+ * @date 2025-01-14T11:30:44.730Z
7
+ * @hash 94f8ef9
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillUnmount, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -704,6 +704,7 @@ function removeFalsyAttributes(obj) {
704
704
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
705
705
  */
706
706
  const whiteSpaceSpecialCharacters = [
707
+ " ",
707
708
  "\t",
708
709
  "\f",
709
710
  "\v",
@@ -718,17 +719,15 @@ const whiteSpaceSpecialCharacters = [
718
719
  String.fromCharCode(parseInt("3000", 16)),
719
720
  String.fromCharCode(parseInt("feff", 16)),
720
721
  ];
721
- const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|") + "|(\r\n|\r|\n)", "g");
722
+ const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|"), "g");
723
+ const newLineRegexp = /(\r\n|\r)/g;
722
724
  /**
723
- * Replace all the special spaces in a string (non-breaking, tabs, ...) by normal spaces, and all the
724
- * different newlines types by \n.
725
+ * Replace all different newlines characters by \n
725
726
  */
726
- function replaceSpecialSpaces(text) {
727
+ function replaceNewLines(text) {
727
728
  if (!text)
728
729
  return "";
729
- if (!whiteSpaceRegexp.test(text))
730
- return text;
731
- return text.replace(whiteSpaceRegexp, (match, newLine) => (newLine ? NEWLINE : " "));
730
+ return text.replace(newLineRegexp, NEWLINE);
732
731
  }
733
732
  /**
734
733
  * Determine if the numbers are consecutive.
@@ -7471,7 +7470,7 @@ LinkDisplay.props = {
7471
7470
  const POSTFIX_UNARY_OPERATORS = ["%"];
7472
7471
  const OPERATORS = "+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(POSTFIX_UNARY_OPERATORS);
7473
7472
  function tokenize(str, locale = DEFAULT_LOCALE) {
7474
- str = replaceSpecialSpaces(str);
7473
+ str = replaceNewLines(str);
7475
7474
  const chars = new TokenizingChars(str);
7476
7475
  const result = [];
7477
7476
  while (!chars.isOver()) {
@@ -7618,12 +7617,12 @@ function tokenizeSpace(chars) {
7618
7617
  if (length) {
7619
7618
  return { type: "SPACE", value: NEWLINE.repeat(length) };
7620
7619
  }
7621
- while (chars.current === " ") {
7622
- length++;
7623
- chars.shift();
7620
+ let spaces = "";
7621
+ while (chars.current && chars.current.match(whiteSpaceRegexp)) {
7622
+ spaces += chars.shift();
7624
7623
  }
7625
- if (length) {
7626
- return { type: "SPACE", value: " ".repeat(length) };
7624
+ if (spaces) {
7625
+ return { type: "SPACE", value: spaces };
7627
7626
  }
7628
7627
  return null;
7629
7628
  }
@@ -21818,15 +21817,23 @@ class BarConfigPanel extends LineBarPieConfigPanel {
21818
21817
  }
21819
21818
  }
21820
21819
 
21820
+ /**
21821
+ * Start listening to pointer events and apply the given callbacks.
21822
+ *
21823
+ * @returns A function to remove the listeners.
21824
+ */
21821
21825
  function startDnd(onMouseMove, onMouseUp, onMouseDown = () => { }) {
21822
- const _onMouseUp = (ev) => {
21823
- onMouseUp(ev);
21826
+ const removeListeners = () => {
21824
21827
  window.removeEventListener("mousedown", onMouseDown);
21825
21828
  window.removeEventListener("mouseup", _onMouseUp);
21826
21829
  window.removeEventListener("dragstart", _onDragStart);
21827
21830
  window.removeEventListener("mousemove", onMouseMove);
21828
21831
  window.removeEventListener("wheel", onMouseMove);
21829
21832
  };
21833
+ const _onMouseUp = (ev) => {
21834
+ onMouseUp(ev);
21835
+ removeListeners();
21836
+ };
21830
21837
  function _onDragStart(ev) {
21831
21838
  ev.preventDefault();
21832
21839
  }
@@ -21838,6 +21845,7 @@ function startDnd(onMouseMove, onMouseUp, onMouseDown = () => { }) {
21838
21845
  // preventDefault() is not allowed in passive event handler.
21839
21846
  // https://chromestatus.com/feature/6662647093133312
21840
21847
  window.addEventListener("wheel", onMouseMove, { passive: false });
21848
+ return removeListeners;
21841
21849
  }
21842
21850
  /**
21843
21851
  * Function to be used during a mousedown event, this function allows to
@@ -28011,6 +28019,7 @@ class FiguresContainer extends Component {
28011
28019
  draggedFigure: undefined,
28012
28020
  horizontalSnap: undefined,
28013
28021
  verticalSnap: undefined,
28022
+ cancelDnd: undefined,
28014
28023
  });
28015
28024
  setup() {
28016
28025
  onMounted(() => {
@@ -28023,12 +28032,28 @@ class FiguresContainer extends Component {
28023
28032
  // new rendering
28024
28033
  this.render();
28025
28034
  });
28035
+ onWillUpdateProps(() => {
28036
+ const sheetId = this.env.model.getters.getActiveSheetId();
28037
+ const draggedFigureId = this.dnd.draggedFigure?.id;
28038
+ if (draggedFigureId && !this.env.model.getters.getFigure(sheetId, draggedFigureId)) {
28039
+ if (this.dnd.cancelDnd) {
28040
+ this.dnd.cancelDnd();
28041
+ }
28042
+ this.dnd.draggedFigure = undefined;
28043
+ this.dnd.horizontalSnap = undefined;
28044
+ this.dnd.verticalSnap = undefined;
28045
+ this.dnd.cancelDnd = undefined;
28046
+ }
28047
+ });
28026
28048
  }
28027
28049
  getVisibleFigures() {
28028
28050
  const visibleFigures = this.env.model.getters.getVisibleFigures();
28029
28051
  if (this.dnd.draggedFigure &&
28030
28052
  !visibleFigures.some((figure) => figure.id === this.dnd.draggedFigure?.id)) {
28031
- visibleFigures.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id));
28053
+ const draggedFigure = this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id);
28054
+ if (draggedFigure) {
28055
+ visibleFigures.push(draggedFigure);
28056
+ }
28032
28057
  }
28033
28058
  return visibleFigures;
28034
28059
  }
@@ -28147,7 +28172,7 @@ class FiguresContainer extends Component {
28147
28172
  this.dnd.verticalSnap = undefined;
28148
28173
  this.env.model.dispatch("UPDATE_FIGURE", { sheetId, id: figure.id, x, y });
28149
28174
  };
28150
- startDnd(onMouseMove, onMouseUp);
28175
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
28151
28176
  }
28152
28177
  /**
28153
28178
  * Initialize the resize of a figure with mouse movements
@@ -28195,7 +28220,7 @@ class FiguresContainer extends Component {
28195
28220
  this.dnd.horizontalSnap = undefined;
28196
28221
  this.dnd.verticalSnap = undefined;
28197
28222
  };
28198
- startDnd(onMouseMove, onMouseUp);
28223
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
28199
28224
  }
28200
28225
  getOtherFigures(figId) {
28201
28226
  return this.getVisibleFigures().filter((f) => f.id !== figId);
@@ -31491,7 +31516,7 @@ function extractStyle(cell, data) {
31491
31516
  vertical: style.verticalAlign
31492
31517
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
31493
31518
  : undefined,
31494
- wrapText: style.wrapping === "wrap",
31519
+ wrapText: style.wrapping === "wrap" || cell.content?.includes(NEWLINE) ? true : undefined,
31495
31520
  },
31496
31521
  };
31497
31522
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -31708,7 +31733,7 @@ function convertFigure(figure, id, sheetData) {
31708
31733
  return undefined;
31709
31734
  }
31710
31735
  function isChartData(data) {
31711
- return "dataSets" in data;
31736
+ return "dataSets" in data && data.dataSets.length > 0;
31712
31737
  }
31713
31738
  function isImageData(data) {
31714
31739
  return "imageSrc" in data;
@@ -31920,9 +31945,8 @@ function convertRows(sheet, numberOfRows) {
31920
31945
  }
31921
31946
  return rows;
31922
31947
  }
31923
- /** Remove newlines (\n) in shared strings, We do not support them */
31924
31948
  function convertSharedStrings(xlsxSharedStrings) {
31925
- return xlsxSharedStrings.map((str) => str.replace(/\n/g, ""));
31949
+ return xlsxSharedStrings.map(replaceNewLines);
31926
31950
  }
31927
31951
  function convertCells(sheet, data, sheetDims, warningManager) {
31928
31952
  const cells = {};
@@ -32713,15 +32737,10 @@ class XlsxMiscExtractor extends XlsxBaseExtractor {
32713
32737
  getSharedStrings() {
32714
32738
  return this.mapOnElements({ parent: this.rootFile.file.xml, query: "si" }, (ssElement) => {
32715
32739
  // Shared string can either be a simple text, or a rich text (text with formatting, possibly in multiple parts)
32716
- if (ssElement.children[0].tagName === "t") {
32717
- return this.extractTextContent(ssElement) || "";
32718
- }
32719
32740
  // We don't support rich text formatting, we'll only extract the text
32720
- else {
32721
- return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
32722
- return this.extractTextContent(textElement) || "";
32723
- }).join("");
32724
- }
32741
+ return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
32742
+ return this.extractTextContent(textElement) || "";
32743
+ }).join("");
32725
32744
  });
32726
32745
  }
32727
32746
  }
@@ -34528,10 +34547,34 @@ class BordersPlugin extends CorePlugin {
34528
34547
  const elements = [...cmd.elements].sort((a, b) => b - a);
34529
34548
  for (const group of groupConsecutive(elements)) {
34530
34549
  if (cmd.dimension === "COL") {
34531
- this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34550
+ if (group[0] >= this.getters.getNumberCols(cmd.sheetId)) {
34551
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
34552
+ this.history.update("borders", cmd.sheetId, group[0] + 1, row, "vertical", undefined);
34553
+ }
34554
+ }
34555
+ if (group[group.length - 1] === 0) {
34556
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
34557
+ this.history.update("borders", cmd.sheetId, 0, row, "vertical", undefined);
34558
+ }
34559
+ }
34560
+ const zone = this.getters.getColsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
34561
+ this.clearInsideBorders(cmd.sheetId, [zone]);
34562
+ this.shiftBordersHorizontally(cmd.sheetId, group[0] + 1, -group.length);
34532
34563
  }
34533
34564
  else {
34534
- this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34565
+ if (group[0] >= this.getters.getNumberRows(cmd.sheetId)) {
34566
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
34567
+ this.history.update("borders", cmd.sheetId, col, group[0] + 1, "horizontal", undefined);
34568
+ }
34569
+ }
34570
+ if (group[group.length - 1] === 0) {
34571
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
34572
+ this.history.update("borders", cmd.sheetId, col, 0, "horizontal", undefined);
34573
+ }
34574
+ }
34575
+ const zone = this.getters.getRowsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
34576
+ this.clearInsideBorders(cmd.sheetId, [zone]);
34577
+ this.shiftBordersVertically(cmd.sheetId, group[0] + 1, -group.length);
34535
34578
  }
34536
34579
  }
34537
34580
  break;
@@ -34838,6 +34881,18 @@ class BordersPlugin extends CorePlugin {
34838
34881
  }
34839
34882
  }
34840
34883
  }
34884
+ /**
34885
+ * Remove the borders inside of a zone
34886
+ */
34887
+ clearInsideBorders(sheetId, zones) {
34888
+ for (let zone of zones) {
34889
+ for (let row = zone.top; row <= zone.bottom; row++) {
34890
+ for (let col = zone.left; col <= zone.right; col++) {
34891
+ this.history.update("borders", sheetId, col, row, undefined);
34892
+ }
34893
+ }
34894
+ }
34895
+ }
34841
34896
  /**
34842
34897
  * Add a border to the existing one to a cell
34843
34898
  */
@@ -36094,7 +36149,7 @@ class CellPlugin extends CorePlugin {
36094
36149
  const before = this.getters.getCell({ sheetId, col, row });
36095
36150
  const hasContent = "content" in after || "formula" in after;
36096
36151
  // Compute the new cell properties
36097
- const afterContent = hasContent ? replaceSpecialSpaces(after?.content) : before?.content || "";
36152
+ const afterContent = hasContent ? replaceNewLines(after?.content) : before?.content || "";
36098
36153
  let style;
36099
36154
  if (after.style !== undefined) {
36100
36155
  style = after.style || undefined;
@@ -50914,6 +50969,7 @@ class SheetViewPlugin extends UIPlugin {
50914
50969
  break;
50915
50970
  case "DELETE_SHEET":
50916
50971
  this.cleanViewports();
50972
+ this.sheetsWithDirtyViewports.delete(cmd.sheetId);
50917
50973
  break;
50918
50974
  case "ACTIVATE_SHEET":
50919
50975
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
@@ -51836,17 +51892,17 @@ class BottomBarSheet extends Component {
51836
51892
  sheetNameRef = useRef("sheetNameSpan");
51837
51893
  editionState = "initializing";
51838
51894
  setup() {
51839
- onMounted(() => {
51840
- if (this.isSheetActive) {
51841
- this.scrollToSheet();
51842
- }
51843
- });
51844
51895
  onPatched(() => {
51845
51896
  if (this.sheetNameRef.el && this.state.isEditing && this.editionState === "initializing") {
51846
51897
  this.editionState = "editing";
51847
51898
  this.focusInputAndSelectContent();
51848
51899
  }
51849
51900
  });
51901
+ useEffect((sheetId) => {
51902
+ if (this.props.sheetId === sheetId) {
51903
+ this.scrollToSheet();
51904
+ }
51905
+ }, () => [this.env.model.getters.getActiveSheetId()]);
51850
51906
  }
51851
51907
  focusInputAndSelectContent() {
51852
51908
  if (!this.state.isEditing || !this.sheetNameRef.el)
@@ -51858,7 +51914,10 @@ class BottomBarSheet extends Component {
51858
51914
  }
51859
51915
  }
51860
51916
  scrollToSheet() {
51861
- this.sheetDivRef.el?.scrollIntoView?.();
51917
+ this.sheetDivRef.el?.scrollIntoView?.({
51918
+ behavior: "smooth",
51919
+ inline: "nearest",
51920
+ });
51862
51921
  }
51863
51922
  onFocusOut() {
51864
51923
  if (this.state.isEditing && this.editionState !== "initializing") {
@@ -53135,7 +53194,6 @@ css /* scss */ `
53135
53194
  height: fit-content;
53136
53195
  margin-top: -1px;
53137
53196
  border: 1px solid;
53138
- z-index: ${ComponentsImportance.TopBarComposer};
53139
53197
 
53140
53198
  .o-composer:empty:not(:focus):not(.active)::before {
53141
53199
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
@@ -53169,6 +53227,7 @@ class TopBarComposer extends Component {
53169
53227
  }
53170
53228
  return cssPropertiesToCss({
53171
53229
  "border-color": SELECTION_BORDER_COLOR,
53230
+ "z-index": String(ComponentsImportance.TopBarComposer),
53172
53231
  });
53173
53232
  }
53174
53233
  }
@@ -56971,7 +57030,12 @@ function createSharedStrings(strings) {
56971
57030
  ["count", strings.length],
56972
57031
  ["uniqueCount", strings.length],
56973
57032
  ];
56974
- const stringNodes = strings.map((string) => escapeXml /*xml*/ `<si><t>${string}</t></si>`);
57033
+ const stringNodes = strings.map((string) => {
57034
+ if (string.trim() !== string) {
57035
+ return escapeXml /*xml*/ `<si><t xml:space="preserve">${string}</t></si>`;
57036
+ }
57037
+ return escapeXml /*xml*/ `<si><t>${string}</t></si>`;
57038
+ });
56975
57039
  const xml = escapeXml /*xml*/ `
56976
57040
  <sst ${formatAttributes(namespaces)}>
56977
57041
  ${joinXmlNodes(stringNodes)}
@@ -57604,6 +57668,8 @@ const helpers = {
57604
57668
  createActions,
57605
57669
  transformRangeData,
57606
57670
  deepEquals,
57671
+ isNumber,
57672
+ isDateTime,
57607
57673
  };
57608
57674
  const links = {
57609
57675
  isMarkdownLink,
@@ -57647,6 +57713,6 @@ const constants = {
57647
57713
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
57648
57714
 
57649
57715
 
57650
- __info__.version = "17.0.43";
57651
- __info__.date = "2024-12-05T10:36:19.412Z";
57652
- __info__.hash = "8344531";
57716
+ __info__.version = "17.0.45";
57717
+ __info__.date = "2025-01-14T11:30:44.730Z";
57718
+ __info__.hash = "94f8ef9";