@odoo/o-spreadsheet 17.0.43 → 17.0.44

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.44
6
+ * @date 2024-12-19T07:46:10.942Z
7
+ * @hash 820f3cf
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -705,6 +705,7 @@
705
705
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
706
706
  */
707
707
  const whiteSpaceSpecialCharacters = [
708
+ " ",
708
709
  "\t",
709
710
  "\f",
710
711
  "\v",
@@ -719,17 +720,15 @@
719
720
  String.fromCharCode(parseInt("3000", 16)),
720
721
  String.fromCharCode(parseInt("feff", 16)),
721
722
  ];
722
- const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|") + "|(\r\n|\r|\n)", "g");
723
+ const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|"), "g");
724
+ const newLineRegexp = /(\r\n|\r)/g;
723
725
  /**
724
- * Replace all the special spaces in a string (non-breaking, tabs, ...) by normal spaces, and all the
725
- * different newlines types by \n.
726
+ * Replace all different newlines characters by \n
726
727
  */
727
- function replaceSpecialSpaces(text) {
728
+ function replaceNewLines(text) {
728
729
  if (!text)
729
730
  return "";
730
- if (!whiteSpaceRegexp.test(text))
731
- return text;
732
- return text.replace(whiteSpaceRegexp, (match, newLine) => (newLine ? NEWLINE : " "));
731
+ return text.replace(newLineRegexp, NEWLINE);
733
732
  }
734
733
  /**
735
734
  * Determine if the numbers are consecutive.
@@ -7472,7 +7471,7 @@
7472
7471
  const POSTFIX_UNARY_OPERATORS = ["%"];
7473
7472
  const OPERATORS = "+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(POSTFIX_UNARY_OPERATORS);
7474
7473
  function tokenize(str, locale = DEFAULT_LOCALE) {
7475
- str = replaceSpecialSpaces(str);
7474
+ str = replaceNewLines(str);
7476
7475
  const chars = new TokenizingChars(str);
7477
7476
  const result = [];
7478
7477
  while (!chars.isOver()) {
@@ -7619,12 +7618,12 @@
7619
7618
  if (length) {
7620
7619
  return { type: "SPACE", value: NEWLINE.repeat(length) };
7621
7620
  }
7622
- while (chars.current === " ") {
7623
- length++;
7624
- chars.shift();
7621
+ let spaces = "";
7622
+ while (chars.current && chars.current.match(whiteSpaceRegexp)) {
7623
+ spaces += chars.shift();
7625
7624
  }
7626
- if (length) {
7627
- return { type: "SPACE", value: " ".repeat(length) };
7625
+ if (spaces) {
7626
+ return { type: "SPACE", value: spaces };
7628
7627
  }
7629
7628
  return null;
7630
7629
  }
@@ -21819,15 +21818,23 @@
21819
21818
  }
21820
21819
  }
21821
21820
 
21821
+ /**
21822
+ * Start listening to pointer events and apply the given callbacks.
21823
+ *
21824
+ * @returns A function to remove the listeners.
21825
+ */
21822
21826
  function startDnd(onMouseMove, onMouseUp, onMouseDown = () => { }) {
21823
- const _onMouseUp = (ev) => {
21824
- onMouseUp(ev);
21827
+ const removeListeners = () => {
21825
21828
  window.removeEventListener("mousedown", onMouseDown);
21826
21829
  window.removeEventListener("mouseup", _onMouseUp);
21827
21830
  window.removeEventListener("dragstart", _onDragStart);
21828
21831
  window.removeEventListener("mousemove", onMouseMove);
21829
21832
  window.removeEventListener("wheel", onMouseMove);
21830
21833
  };
21834
+ const _onMouseUp = (ev) => {
21835
+ onMouseUp(ev);
21836
+ removeListeners();
21837
+ };
21831
21838
  function _onDragStart(ev) {
21832
21839
  ev.preventDefault();
21833
21840
  }
@@ -21839,6 +21846,7 @@
21839
21846
  // preventDefault() is not allowed in passive event handler.
21840
21847
  // https://chromestatus.com/feature/6662647093133312
21841
21848
  window.addEventListener("wheel", onMouseMove, { passive: false });
21849
+ return removeListeners;
21842
21850
  }
21843
21851
  /**
21844
21852
  * Function to be used during a mousedown event, this function allows to
@@ -28012,6 +28020,7 @@
28012
28020
  draggedFigure: undefined,
28013
28021
  horizontalSnap: undefined,
28014
28022
  verticalSnap: undefined,
28023
+ cancelDnd: undefined,
28015
28024
  });
28016
28025
  setup() {
28017
28026
  owl.onMounted(() => {
@@ -28024,12 +28033,28 @@
28024
28033
  // new rendering
28025
28034
  this.render();
28026
28035
  });
28036
+ owl.onWillUpdateProps(() => {
28037
+ const sheetId = this.env.model.getters.getActiveSheetId();
28038
+ const draggedFigureId = this.dnd.draggedFigure?.id;
28039
+ if (draggedFigureId && !this.env.model.getters.getFigure(sheetId, draggedFigureId)) {
28040
+ if (this.dnd.cancelDnd) {
28041
+ this.dnd.cancelDnd();
28042
+ }
28043
+ this.dnd.draggedFigure = undefined;
28044
+ this.dnd.horizontalSnap = undefined;
28045
+ this.dnd.verticalSnap = undefined;
28046
+ this.dnd.cancelDnd = undefined;
28047
+ }
28048
+ });
28027
28049
  }
28028
28050
  getVisibleFigures() {
28029
28051
  const visibleFigures = this.env.model.getters.getVisibleFigures();
28030
28052
  if (this.dnd.draggedFigure &&
28031
28053
  !visibleFigures.some((figure) => figure.id === this.dnd.draggedFigure?.id)) {
28032
- visibleFigures.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id));
28054
+ const draggedFigure = this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id);
28055
+ if (draggedFigure) {
28056
+ visibleFigures.push(draggedFigure);
28057
+ }
28033
28058
  }
28034
28059
  return visibleFigures;
28035
28060
  }
@@ -28148,7 +28173,7 @@
28148
28173
  this.dnd.verticalSnap = undefined;
28149
28174
  this.env.model.dispatch("UPDATE_FIGURE", { sheetId, id: figure.id, x, y });
28150
28175
  };
28151
- startDnd(onMouseMove, onMouseUp);
28176
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
28152
28177
  }
28153
28178
  /**
28154
28179
  * Initialize the resize of a figure with mouse movements
@@ -28196,7 +28221,7 @@
28196
28221
  this.dnd.horizontalSnap = undefined;
28197
28222
  this.dnd.verticalSnap = undefined;
28198
28223
  };
28199
- startDnd(onMouseMove, onMouseUp);
28224
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
28200
28225
  }
28201
28226
  getOtherFigures(figId) {
28202
28227
  return this.getVisibleFigures().filter((f) => f.id !== figId);
@@ -31492,7 +31517,7 @@
31492
31517
  vertical: style.verticalAlign
31493
31518
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
31494
31519
  : undefined,
31495
- wrapText: style.wrapping === "wrap",
31520
+ wrapText: style.wrapping === "wrap" || cell.content?.includes(NEWLINE) ? true : undefined,
31496
31521
  },
31497
31522
  };
31498
31523
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -31921,9 +31946,8 @@
31921
31946
  }
31922
31947
  return rows;
31923
31948
  }
31924
- /** Remove newlines (\n) in shared strings, We do not support them */
31925
31949
  function convertSharedStrings(xlsxSharedStrings) {
31926
- return xlsxSharedStrings.map((str) => str.replace(/\n/g, ""));
31950
+ return xlsxSharedStrings.map(replaceNewLines);
31927
31951
  }
31928
31952
  function convertCells(sheet, data, sheetDims, warningManager) {
31929
31953
  const cells = {};
@@ -32714,15 +32738,10 @@
32714
32738
  getSharedStrings() {
32715
32739
  return this.mapOnElements({ parent: this.rootFile.file.xml, query: "si" }, (ssElement) => {
32716
32740
  // Shared string can either be a simple text, or a rich text (text with formatting, possibly in multiple parts)
32717
- if (ssElement.children[0].tagName === "t") {
32718
- return this.extractTextContent(ssElement) || "";
32719
- }
32720
32741
  // We don't support rich text formatting, we'll only extract the text
32721
- else {
32722
- return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
32723
- return this.extractTextContent(textElement) || "";
32724
- }).join("");
32725
- }
32742
+ return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
32743
+ return this.extractTextContent(textElement) || "";
32744
+ }).join("");
32726
32745
  });
32727
32746
  }
32728
32747
  }
@@ -36095,7 +36114,7 @@
36095
36114
  const before = this.getters.getCell({ sheetId, col, row });
36096
36115
  const hasContent = "content" in after || "formula" in after;
36097
36116
  // Compute the new cell properties
36098
- const afterContent = hasContent ? replaceSpecialSpaces(after?.content) : before?.content || "";
36117
+ const afterContent = hasContent ? replaceNewLines(after?.content) : before?.content || "";
36099
36118
  let style;
36100
36119
  if (after.style !== undefined) {
36101
36120
  style = after.style || undefined;
@@ -50915,6 +50934,7 @@
50915
50934
  break;
50916
50935
  case "DELETE_SHEET":
50917
50936
  this.cleanViewports();
50937
+ this.sheetsWithDirtyViewports.delete(cmd.sheetId);
50918
50938
  break;
50919
50939
  case "ACTIVATE_SHEET":
50920
50940
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
@@ -53136,7 +53156,6 @@
53136
53156
  height: fit-content;
53137
53157
  margin-top: -1px;
53138
53158
  border: 1px solid;
53139
- z-index: ${ComponentsImportance.TopBarComposer};
53140
53159
 
53141
53160
  .o-composer:empty:not(:focus):not(.active)::before {
53142
53161
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
@@ -53170,6 +53189,7 @@
53170
53189
  }
53171
53190
  return cssPropertiesToCss({
53172
53191
  "border-color": SELECTION_BORDER_COLOR,
53192
+ "z-index": String(ComponentsImportance.TopBarComposer),
53173
53193
  });
53174
53194
  }
53175
53195
  }
@@ -56972,7 +56992,12 @@
56972
56992
  ["count", strings.length],
56973
56993
  ["uniqueCount", strings.length],
56974
56994
  ];
56975
- const stringNodes = strings.map((string) => escapeXml /*xml*/ `<si><t>${string}</t></si>`);
56995
+ const stringNodes = strings.map((string) => {
56996
+ if (string.trim() !== string) {
56997
+ return escapeXml /*xml*/ `<si><t xml:space="preserve">${string}</t></si>`;
56998
+ }
56999
+ return escapeXml /*xml*/ `<si><t>${string}</t></si>`;
57000
+ });
56976
57001
  const xml = escapeXml /*xml*/ `
56977
57002
  <sst ${formatAttributes(namespaces)}>
56978
57003
  ${joinXmlNodes(stringNodes)}
@@ -57683,9 +57708,9 @@
57683
57708
  exports.tokenize = tokenize;
57684
57709
 
57685
57710
 
57686
- __info__.version = "17.0.43";
57687
- __info__.date = "2024-12-05T10:36:19.412Z";
57688
- __info__.hash = "8344531";
57711
+ __info__.version = "17.0.44";
57712
+ __info__.date = "2024-12-19T07:46:10.942Z";
57713
+ __info__.hash = "820f3cf";
57689
57714
 
57690
57715
 
57691
57716
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);