@odoo/o-spreadsheet 17.2.29 → 17.2.31

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.29
7
- * @date 2024-12-05T10:39:14.167Z
8
- * @hash 7b4b898
6
+ * @version 17.2.31
7
+ * @date 2025-01-14T11:31:09.035Z
8
+ * @hash 306dbf7
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -625,6 +625,7 @@
625
625
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
626
626
  */
627
627
  const whiteSpaceSpecialCharacters = [
628
+ " ",
628
629
  "\t",
629
630
  "\f",
630
631
  "\v",
@@ -639,17 +640,15 @@
639
640
  String.fromCharCode(parseInt("3000", 16)),
640
641
  String.fromCharCode(parseInt("feff", 16)),
641
642
  ];
642
- const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|") + "|(\r\n|\r|\n)", "g");
643
+ const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|"), "g");
644
+ const newLineRegexp = /(\r\n|\r)/g;
643
645
  /**
644
- * Replace all the special spaces in a string (non-breaking, tabs, ...) by normal spaces, and all the
645
- * different newlines types by \n.
646
+ * Replace all different newlines characters by \n
646
647
  */
647
- function replaceSpecialSpaces(text) {
648
+ function replaceNewLines(text) {
648
649
  if (!text)
649
650
  return "";
650
- if (!whiteSpaceRegexp.test(text))
651
- return text;
652
- return text.replace(whiteSpaceRegexp, (match, newLine) => (newLine ? NEWLINE : " "));
651
+ return text.replace(newLineRegexp, NEWLINE);
653
652
  }
654
653
  /**
655
654
  * Determine if the numbers are consecutive.
@@ -5162,7 +5161,7 @@
5162
5161
  const POSTFIX_UNARY_OPERATORS = ["%"];
5163
5162
  const OPERATORS = "+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(POSTFIX_UNARY_OPERATORS);
5164
5163
  function tokenize(str, locale = DEFAULT_LOCALE) {
5165
- str = replaceSpecialSpaces(str);
5164
+ str = replaceNewLines(str);
5166
5165
  const chars = new TokenizingChars(str);
5167
5166
  const result = [];
5168
5167
  while (!chars.isOver()) {
@@ -5309,12 +5308,12 @@
5309
5308
  if (length) {
5310
5309
  return { type: "SPACE", value: NEWLINE.repeat(length) };
5311
5310
  }
5312
- while (chars.current === " ") {
5313
- length++;
5314
- chars.shift();
5311
+ let spaces = "";
5312
+ while (chars.current && chars.current.match(whiteSpaceRegexp)) {
5313
+ spaces += chars.shift();
5315
5314
  }
5316
- if (length) {
5317
- return { type: "SPACE", value: " ".repeat(length) };
5315
+ if (spaces) {
5316
+ return { type: "SPACE", value: spaces };
5318
5317
  }
5319
5318
  return null;
5320
5319
  }
@@ -20245,7 +20244,7 @@ stores.inject(MyMetaStore, storeInstance);
20245
20244
  colors.push(chartColors.upperColor);
20246
20245
  return {
20247
20246
  background: getters.getStyleOfSingleCellChart(chart.background, dataRange).background,
20248
- title: chart.title,
20247
+ title: _t(chart.title),
20249
20248
  minValue: {
20250
20249
  value: minValue,
20251
20250
  label: formatValue(minValue, { locale, format }),
@@ -31582,14 +31581,11 @@ stores.inject(MyMetaStore, storeInstance);
31582
31581
  });
31583
31582
 
31584
31583
  class DOMFocusableElementStore {
31585
- mutators = ["setFocusableElement", "focus"];
31584
+ mutators = ["setFocusableElement"];
31586
31585
  focusableElement = undefined;
31587
31586
  setFocusableElement(element) {
31588
31587
  this.focusableElement = element;
31589
31588
  }
31590
- focus() {
31591
- this.focusableElement?.focus();
31592
- }
31593
31589
  }
31594
31590
 
31595
31591
  // -----------------------------------------------------------------------------
@@ -32929,7 +32925,7 @@ stores.inject(MyMetaStore, storeInstance);
32929
32925
  this.isEditing = isEditing;
32930
32926
  if (!isEditing) {
32931
32927
  this.rect = this.defaultRect;
32932
- this.DOMFocusableElementStore.focus();
32928
+ this.DOMFocusableElementStore.focusableElement?.focus();
32933
32929
  return;
32934
32930
  }
32935
32931
  const position = this.env.model.getters.getActivePosition();
@@ -33527,6 +33523,7 @@ stores.inject(MyMetaStore, storeInstance);
33527
33523
  draggedFigure: undefined,
33528
33524
  horizontalSnap: undefined,
33529
33525
  verticalSnap: undefined,
33526
+ cancelDnd: undefined,
33530
33527
  });
33531
33528
  setup() {
33532
33529
  owl.onMounted(() => {
@@ -33539,12 +33536,28 @@ stores.inject(MyMetaStore, storeInstance);
33539
33536
  // new rendering
33540
33537
  this.render();
33541
33538
  });
33539
+ owl.onWillUpdateProps(() => {
33540
+ const sheetId = this.env.model.getters.getActiveSheetId();
33541
+ const draggedFigureId = this.dnd.draggedFigure?.id;
33542
+ if (draggedFigureId && !this.env.model.getters.getFigure(sheetId, draggedFigureId)) {
33543
+ if (this.dnd.cancelDnd) {
33544
+ this.dnd.cancelDnd();
33545
+ }
33546
+ this.dnd.draggedFigure = undefined;
33547
+ this.dnd.horizontalSnap = undefined;
33548
+ this.dnd.verticalSnap = undefined;
33549
+ this.dnd.cancelDnd = undefined;
33550
+ }
33551
+ });
33542
33552
  }
33543
33553
  getVisibleFigures() {
33544
33554
  const visibleFigures = this.env.model.getters.getVisibleFigures();
33545
33555
  if (this.dnd.draggedFigure &&
33546
33556
  !visibleFigures.some((figure) => figure.id === this.dnd.draggedFigure?.id)) {
33547
- visibleFigures.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id));
33557
+ const draggedFigure = this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id);
33558
+ if (draggedFigure) {
33559
+ visibleFigures.push(draggedFigure);
33560
+ }
33548
33561
  }
33549
33562
  return visibleFigures;
33550
33563
  }
@@ -33663,7 +33676,7 @@ stores.inject(MyMetaStore, storeInstance);
33663
33676
  this.dnd.verticalSnap = undefined;
33664
33677
  this.env.model.dispatch("UPDATE_FIGURE", { sheetId, id: figure.id, x, y });
33665
33678
  };
33666
- startDnd(onMouseMove, onMouseUp);
33679
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
33667
33680
  }
33668
33681
  /**
33669
33682
  * Initialize the resize of a figure with mouse movements
@@ -33711,7 +33724,7 @@ stores.inject(MyMetaStore, storeInstance);
33711
33724
  this.dnd.horizontalSnap = undefined;
33712
33725
  this.dnd.verticalSnap = undefined;
33713
33726
  };
33714
- startDnd(onMouseMove, onMouseUp);
33727
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
33715
33728
  }
33716
33729
  getOtherFigures(figId) {
33717
33730
  return this.getVisibleFigures().filter((f) => f.id !== figId);
@@ -35848,7 +35861,7 @@ stores.inject(MyMetaStore, storeInstance);
35848
35861
  this.cellPopovers = useStore(CellPopoverStore);
35849
35862
  owl.useEffect(() => {
35850
35863
  if (!this.sidePanel.isOpen) {
35851
- this.DOMFocusableElementStore.focus();
35864
+ this.DOMFocusableElementStore.focusableElement?.focus();
35852
35865
  }
35853
35866
  }, () => [this.sidePanel.isOpen]);
35854
35867
  }
@@ -36052,7 +36065,7 @@ stores.inject(MyMetaStore, storeInstance);
36052
36065
  focusDefaultElement() {
36053
36066
  if (!this.env.model.getters.getSelectedFigureId() &&
36054
36067
  this.composerStore.editionMode === "inactive") {
36055
- this.DOMFocusableElementStore.focus();
36068
+ this.DOMFocusableElementStore.focusableElement?.focus();
36056
36069
  }
36057
36070
  }
36058
36071
  get gridEl() {
@@ -37671,7 +37684,7 @@ stores.inject(MyMetaStore, storeInstance);
37671
37684
  vertical: style.verticalAlign
37672
37685
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
37673
37686
  : undefined,
37674
- wrapText: style.wrapping === "wrap",
37687
+ wrapText: style.wrapping === "wrap" || cell.content?.includes(NEWLINE) ? true : undefined,
37675
37688
  },
37676
37689
  };
37677
37690
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -37894,7 +37907,7 @@ stores.inject(MyMetaStore, storeInstance);
37894
37907
  return undefined;
37895
37908
  }
37896
37909
  function isChartData(data) {
37897
- return "dataSets" in data;
37910
+ return "dataSets" in data && data.dataSets.length > 0;
37898
37911
  }
37899
37912
  function isImageData(data) {
37900
37913
  return "imageSrc" in data;
@@ -38123,9 +38136,8 @@ stores.inject(MyMetaStore, storeInstance);
38123
38136
  }
38124
38137
  return rows;
38125
38138
  }
38126
- /** Remove newlines (\n) in shared strings, We do not support them */
38127
38139
  function convertSharedStrings(xlsxSharedStrings) {
38128
- return xlsxSharedStrings.map((str) => str.replace(/\n/g, ""));
38140
+ return xlsxSharedStrings.map(replaceNewLines);
38129
38141
  }
38130
38142
  function convertCells(sheet, data, sheetDims, warningManager) {
38131
38143
  const cells = {};
@@ -38967,15 +38979,10 @@ stores.inject(MyMetaStore, storeInstance);
38967
38979
  getSharedStrings() {
38968
38980
  return this.mapOnElements({ parent: this.rootFile.file.xml, query: "si" }, (ssElement) => {
38969
38981
  // Shared string can either be a simple text, or a rich text (text with formatting, possibly in multiple parts)
38970
- if (ssElement.children[0].tagName === "t") {
38971
- return this.extractTextContent(ssElement) || "";
38972
- }
38973
38982
  // We don't support rich text formatting, we'll only extract the text
38974
- else {
38975
- return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
38976
- return this.extractTextContent(textElement) || "";
38977
- }).join("");
38978
- }
38983
+ return this.mapOnElements({ parent: ssElement, query: "t" }, (textElement) => {
38984
+ return this.extractTextContent(textElement) || "";
38985
+ }).join("");
38979
38986
  });
38980
38987
  }
38981
38988
  }
@@ -40697,10 +40704,34 @@ stores.inject(MyMetaStore, storeInstance);
40697
40704
  const elements = [...cmd.elements].sort((a, b) => b - a);
40698
40705
  for (const group of groupConsecutive(elements)) {
40699
40706
  if (cmd.dimension === "COL") {
40700
- this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
40707
+ if (group[0] >= this.getters.getNumberCols(cmd.sheetId)) {
40708
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
40709
+ this.history.update("borders", cmd.sheetId, group[0] + 1, row, "vertical", undefined);
40710
+ }
40711
+ }
40712
+ if (group[group.length - 1] === 0) {
40713
+ for (let row = 0; row < this.getters.getNumberRows(cmd.sheetId); row++) {
40714
+ this.history.update("borders", cmd.sheetId, 0, row, "vertical", undefined);
40715
+ }
40716
+ }
40717
+ const zone = this.getters.getColsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
40718
+ this.clearInsideBorders(cmd.sheetId, [zone]);
40719
+ this.shiftBordersHorizontally(cmd.sheetId, group[0] + 1, -group.length);
40701
40720
  }
40702
40721
  else {
40703
- this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
40722
+ if (group[0] >= this.getters.getNumberRows(cmd.sheetId)) {
40723
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
40724
+ this.history.update("borders", cmd.sheetId, col, group[0] + 1, "horizontal", undefined);
40725
+ }
40726
+ }
40727
+ if (group[group.length - 1] === 0) {
40728
+ for (let col = 0; col < this.getters.getNumberCols(cmd.sheetId); col++) {
40729
+ this.history.update("borders", cmd.sheetId, col, 0, "horizontal", undefined);
40730
+ }
40731
+ }
40732
+ const zone = this.getters.getRowsZone(cmd.sheetId, group[group.length - 1] + 1, group[0]);
40733
+ this.clearInsideBorders(cmd.sheetId, [zone]);
40734
+ this.shiftBordersVertically(cmd.sheetId, group[0] + 1, -group.length);
40704
40735
  }
40705
40736
  }
40706
40737
  break;
@@ -41007,6 +41038,18 @@ stores.inject(MyMetaStore, storeInstance);
41007
41038
  }
41008
41039
  }
41009
41040
  }
41041
+ /**
41042
+ * Remove the borders inside of a zone
41043
+ */
41044
+ clearInsideBorders(sheetId, zones) {
41045
+ for (let zone of zones) {
41046
+ for (let row = zone.top; row <= zone.bottom; row++) {
41047
+ for (let col = zone.left; col <= zone.right; col++) {
41048
+ this.history.update("borders", sheetId, col, row, undefined);
41049
+ }
41050
+ }
41051
+ }
41052
+ }
41010
41053
  /**
41011
41054
  * Add a border to the existing one to a cell
41012
41055
  */
@@ -41869,7 +41912,7 @@ stores.inject(MyMetaStore, storeInstance);
41869
41912
  const before = this.getters.getCell({ sheetId, col, row });
41870
41913
  const hasContent = "content" in after || "formula" in after;
41871
41914
  // Compute the new cell properties
41872
- const afterContent = hasContent ? replaceSpecialSpaces(after?.content) : before?.content || "";
41915
+ const afterContent = hasContent ? replaceNewLines(after?.content) : before?.content || "";
41873
41916
  let style;
41874
41917
  if (after.style !== undefined) {
41875
41918
  style = after.style || undefined;
@@ -50588,6 +50631,9 @@ stores.inject(MyMetaStore, storeInstance);
50588
50631
  }
50589
50632
  }
50590
50633
  this.acknowledge(message);
50634
+ if (message.type === "REMOTE_REVISION" && message.clientId === this.clientId) {
50635
+ return;
50636
+ }
50591
50637
  this.trigger("collaborative-event-received");
50592
50638
  }
50593
50639
  onClientMoved(message) {
@@ -54191,6 +54237,7 @@ stores.inject(MyMetaStore, storeInstance);
54191
54237
  break;
54192
54238
  case "DELETE_SHEET":
54193
54239
  this.cleanViewports();
54240
+ this.sheetsWithDirtyViewports.delete(cmd.sheetId);
54194
54241
  break;
54195
54242
  case "ACTIVATE_SHEET":
54196
54243
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
@@ -55138,11 +55185,6 @@ stores.inject(MyMetaStore, storeInstance);
55138
55185
  editionState = "initializing";
55139
55186
  DOMFocusableElementStore;
55140
55187
  setup() {
55141
- owl.onMounted(() => {
55142
- if (this.isSheetActive) {
55143
- this.scrollToSheet();
55144
- }
55145
- });
55146
55188
  owl.onPatched(() => {
55147
55189
  if (this.sheetNameRef.el && this.state.isEditing && this.editionState === "initializing") {
55148
55190
  this.editionState = "editing";
@@ -55150,6 +55192,11 @@ stores.inject(MyMetaStore, storeInstance);
55150
55192
  }
55151
55193
  });
55152
55194
  this.DOMFocusableElementStore = useStore(DOMFocusableElementStore);
55195
+ owl.useEffect((sheetId) => {
55196
+ if (this.props.sheetId === sheetId) {
55197
+ this.scrollToSheet();
55198
+ }
55199
+ }, () => [this.env.model.getters.getActiveSheetId()]);
55153
55200
  }
55154
55201
  focusInputAndSelectContent() {
55155
55202
  if (!this.state.isEditing || !this.sheetNameRef.el)
@@ -55161,7 +55208,10 @@ stores.inject(MyMetaStore, storeInstance);
55161
55208
  }
55162
55209
  }
55163
55210
  scrollToSheet() {
55164
- this.sheetDivRef.el?.scrollIntoView?.();
55211
+ this.sheetDivRef.el?.scrollIntoView?.({
55212
+ behavior: "smooth",
55213
+ inline: "nearest",
55214
+ });
55165
55215
  }
55166
55216
  onFocusOut() {
55167
55217
  if (this.state.isEditing && this.editionState !== "initializing") {
@@ -55191,11 +55241,11 @@ stores.inject(MyMetaStore, storeInstance);
55191
55241
  if (ev.key === "Enter") {
55192
55242
  ev.preventDefault();
55193
55243
  this.stopEdition();
55194
- this.DOMFocusableElementStore.focus();
55244
+ this.DOMFocusableElementStore.focusableElement?.focus();
55195
55245
  }
55196
55246
  if (ev.key === "Escape") {
55197
55247
  this.cancelEdition();
55198
- this.DOMFocusableElementStore.focus();
55248
+ this.DOMFocusableElementStore.focusableElement?.focus();
55199
55249
  }
55200
55250
  }
55201
55251
  onMouseEventSheetName(ev) {
@@ -56428,7 +56478,6 @@ stores.inject(MyMetaStore, storeInstance);
56428
56478
  height: fit-content;
56429
56479
  margin-top: -1px;
56430
56480
  border: 1px solid;
56431
- z-index: ${ComponentsImportance.TopBarComposer};
56432
56481
 
56433
56482
  .o-composer:empty:not(:focus):not(.active)::before {
56434
56483
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
@@ -56470,6 +56519,7 @@ stores.inject(MyMetaStore, storeInstance);
56470
56519
  }
56471
56520
  return cssPropertiesToCss({
56472
56521
  "border-color": SELECTION_BORDER_COLOR,
56522
+ "z-index": String(ComponentsImportance.TopBarComposer),
56473
56523
  });
56474
56524
  }
56475
56525
  get delimitation() {
@@ -60253,7 +60303,12 @@ stores.inject(MyMetaStore, storeInstance);
60253
60303
  ["count", strings.length],
60254
60304
  ["uniqueCount", strings.length],
60255
60305
  ];
60256
- const stringNodes = strings.map((string) => escapeXml /*xml*/ `<si><t>${string}</t></si>`);
60306
+ const stringNodes = strings.map((string) => {
60307
+ if (string.trim() !== string) {
60308
+ return escapeXml /*xml*/ `<si><t xml:space="preserve">${string}</t></si>`;
60309
+ }
60310
+ return escapeXml /*xml*/ `<si><t>${string}</t></si>`;
60311
+ });
60257
60312
  const xml = escapeXml /*xml*/ `
60258
60313
  <sst ${formatAttributes(namespaces)}>
60259
60314
  ${joinXmlNodes(stringNodes)}
@@ -60904,6 +60959,8 @@ stores.inject(MyMetaStore, storeInstance);
60904
60959
  expandZoneOnInsertion,
60905
60960
  reduceZoneOnDeletion,
60906
60961
  unquote,
60962
+ isNumber,
60963
+ isDateTime,
60907
60964
  };
60908
60965
  const links = {
60909
60966
  isMarkdownLink,
@@ -61018,9 +61075,9 @@ stores.inject(MyMetaStore, storeInstance);
61018
61075
  exports.tokenize = tokenize;
61019
61076
 
61020
61077
 
61021
- __info__.version = "17.2.29";
61022
- __info__.date = "2024-12-05T10:39:14.167Z";
61023
- __info__.hash = "7b4b898";
61078
+ __info__.version = "17.2.31";
61079
+ __info__.date = "2025-01-14T11:31:09.035Z";
61080
+ __info__.hash = "306dbf7";
61024
61081
 
61025
61082
 
61026
61083
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);