@odoo/o-spreadsheet 17.0.42 → 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.42
6
- * @date 2024-11-28T09:02:39.394Z
7
- * @hash aa06a38
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
  }
@@ -19441,6 +19440,18 @@
19441
19440
  },
19442
19441
  isExported: true,
19443
19442
  };
19443
+ // -----------------------------------------------------------------------------
19444
+ // VALUE
19445
+ // -----------------------------------------------------------------------------
19446
+ const VALUE = {
19447
+ description: _t("Converts a string to a numeric value."),
19448
+ args: [arg("value (number)", _t("the string to be converted"))],
19449
+ returns: ["NUMBER"],
19450
+ compute: function (value) {
19451
+ return toNumber(value, this.locale);
19452
+ },
19453
+ isExported: true,
19454
+ };
19444
19455
 
19445
19456
  var text = /*#__PURE__*/Object.freeze({
19446
19457
  __proto__: null,
@@ -19463,7 +19474,8 @@
19463
19474
  TEXT: TEXT,
19464
19475
  TEXTJOIN: TEXTJOIN,
19465
19476
  TRIM: TRIM,
19466
- UPPER: UPPER
19477
+ UPPER: UPPER,
19478
+ VALUE: VALUE
19467
19479
  });
19468
19480
 
19469
19481
  // -----------------------------------------------------------------------------
@@ -21806,15 +21818,23 @@
21806
21818
  }
21807
21819
  }
21808
21820
 
21821
+ /**
21822
+ * Start listening to pointer events and apply the given callbacks.
21823
+ *
21824
+ * @returns A function to remove the listeners.
21825
+ */
21809
21826
  function startDnd(onMouseMove, onMouseUp, onMouseDown = () => { }) {
21810
- const _onMouseUp = (ev) => {
21811
- onMouseUp(ev);
21827
+ const removeListeners = () => {
21812
21828
  window.removeEventListener("mousedown", onMouseDown);
21813
21829
  window.removeEventListener("mouseup", _onMouseUp);
21814
21830
  window.removeEventListener("dragstart", _onDragStart);
21815
21831
  window.removeEventListener("mousemove", onMouseMove);
21816
21832
  window.removeEventListener("wheel", onMouseMove);
21817
21833
  };
21834
+ const _onMouseUp = (ev) => {
21835
+ onMouseUp(ev);
21836
+ removeListeners();
21837
+ };
21818
21838
  function _onDragStart(ev) {
21819
21839
  ev.preventDefault();
21820
21840
  }
@@ -21826,6 +21846,7 @@
21826
21846
  // preventDefault() is not allowed in passive event handler.
21827
21847
  // https://chromestatus.com/feature/6662647093133312
21828
21848
  window.addEventListener("wheel", onMouseMove, { passive: false });
21849
+ return removeListeners;
21829
21850
  }
21830
21851
  /**
21831
21852
  * Function to be used during a mousedown event, this function allows to
@@ -27999,6 +28020,7 @@
27999
28020
  draggedFigure: undefined,
28000
28021
  horizontalSnap: undefined,
28001
28022
  verticalSnap: undefined,
28023
+ cancelDnd: undefined,
28002
28024
  });
28003
28025
  setup() {
28004
28026
  owl.onMounted(() => {
@@ -28011,12 +28033,28 @@
28011
28033
  // new rendering
28012
28034
  this.render();
28013
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
+ });
28014
28049
  }
28015
28050
  getVisibleFigures() {
28016
28051
  const visibleFigures = this.env.model.getters.getVisibleFigures();
28017
28052
  if (this.dnd.draggedFigure &&
28018
28053
  !visibleFigures.some((figure) => figure.id === this.dnd.draggedFigure?.id)) {
28019
- 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
+ }
28020
28058
  }
28021
28059
  return visibleFigures;
28022
28060
  }
@@ -28135,7 +28173,7 @@
28135
28173
  this.dnd.verticalSnap = undefined;
28136
28174
  this.env.model.dispatch("UPDATE_FIGURE", { sheetId, id: figure.id, x, y });
28137
28175
  };
28138
- startDnd(onMouseMove, onMouseUp);
28176
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
28139
28177
  }
28140
28178
  /**
28141
28179
  * Initialize the resize of a figure with mouse movements
@@ -28183,7 +28221,7 @@
28183
28221
  this.dnd.horizontalSnap = undefined;
28184
28222
  this.dnd.verticalSnap = undefined;
28185
28223
  };
28186
- startDnd(onMouseMove, onMouseUp);
28224
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
28187
28225
  }
28188
28226
  getOtherFigures(figId) {
28189
28227
  return this.getVisibleFigures().filter((f) => f.id !== figId);
@@ -31479,7 +31517,7 @@
31479
31517
  vertical: style.verticalAlign
31480
31518
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
31481
31519
  : undefined,
31482
- wrapText: style.wrapping === "wrap",
31520
+ wrapText: style.wrapping === "wrap" || cell.content?.includes(NEWLINE) ? true : undefined,
31483
31521
  },
31484
31522
  };
31485
31523
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -31908,9 +31946,8 @@
31908
31946
  }
31909
31947
  return rows;
31910
31948
  }
31911
- /** Remove newlines (\n) in shared strings, We do not support them */
31912
31949
  function convertSharedStrings(xlsxSharedStrings) {
31913
- return xlsxSharedStrings.map((str) => str.replace(/\n/g, ""));
31950
+ return xlsxSharedStrings.map(replaceNewLines);
31914
31951
  }
31915
31952
  function convertCells(sheet, data, sheetDims, warningManager) {
31916
31953
  const cells = {};
@@ -32701,15 +32738,10 @@
32701
32738
  getSharedStrings() {
32702
32739
  return this.mapOnElements({ parent: this.rootFile.file.xml, query: "si" }, (ssElement) => {
32703
32740
  // Shared string can either be a simple text, or a rich text (text with formatting, possibly in multiple parts)
32704
- if (ssElement.children[0].tagName === "t") {
32705
- return this.extractTextContent(ssElement) || "";
32706
- }
32707
32741
  // We don't support rich text formatting, we'll only extract the text
32708
- else {
32709
- return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
32710
- return this.extractTextContent(textElement) || "";
32711
- }).join("");
32712
- }
32742
+ return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
32743
+ return this.extractTextContent(textElement) || "";
32744
+ }).join("");
32713
32745
  });
32714
32746
  }
32715
32747
  }
@@ -36082,7 +36114,7 @@
36082
36114
  const before = this.getters.getCell({ sheetId, col, row });
36083
36115
  const hasContent = "content" in after || "formula" in after;
36084
36116
  // Compute the new cell properties
36085
- const afterContent = hasContent ? replaceSpecialSpaces(after?.content) : before?.content || "";
36117
+ const afterContent = hasContent ? replaceNewLines(after?.content) : before?.content || "";
36086
36118
  let style;
36087
36119
  if (after.style !== undefined) {
36088
36120
  style = after.style || undefined;
@@ -50902,6 +50934,7 @@
50902
50934
  break;
50903
50935
  case "DELETE_SHEET":
50904
50936
  this.cleanViewports();
50937
+ this.sheetsWithDirtyViewports.delete(cmd.sheetId);
50905
50938
  break;
50906
50939
  case "ACTIVATE_SHEET":
50907
50940
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
@@ -52849,7 +52882,7 @@
52849
52882
  setup() {
52850
52883
  owl.onWillUpdateProps((nextProps) => {
52851
52884
  if (nextProps.action !== this.props.action) {
52852
- this.actionButton = createAction(this.props.action);
52885
+ this.actionButton = createAction(nextProps.action);
52853
52886
  }
52854
52887
  });
52855
52888
  }
@@ -53123,7 +53156,6 @@
53123
53156
  height: fit-content;
53124
53157
  margin-top: -1px;
53125
53158
  border: 1px solid;
53126
- z-index: ${ComponentsImportance.TopBarComposer};
53127
53159
 
53128
53160
  .o-composer:empty:not(:focus):not(.active)::before {
53129
53161
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
@@ -53157,6 +53189,7 @@
53157
53189
  }
53158
53190
  return cssPropertiesToCss({
53159
53191
  "border-color": SELECTION_BORDER_COLOR,
53192
+ "z-index": String(ComponentsImportance.TopBarComposer),
53160
53193
  });
53161
53194
  }
53162
53195
  }
@@ -56959,7 +56992,12 @@
56959
56992
  ["count", strings.length],
56960
56993
  ["uniqueCount", strings.length],
56961
56994
  ];
56962
- 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
+ });
56963
57001
  const xml = escapeXml /*xml*/ `
56964
57002
  <sst ${formatAttributes(namespaces)}>
56965
57003
  ${joinXmlNodes(stringNodes)}
@@ -57670,9 +57708,9 @@
57670
57708
  exports.tokenize = tokenize;
57671
57709
 
57672
57710
 
57673
- __info__.version = "17.0.42";
57674
- __info__.date = "2024-11-28T09:02:39.394Z";
57675
- __info__.hash = "aa06a38";
57711
+ __info__.version = "17.0.44";
57712
+ __info__.date = "2024-12-19T07:46:10.942Z";
57713
+ __info__.hash = "820f3cf";
57676
57714
 
57677
57715
 
57678
57716
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);