@odoo/o-spreadsheet 17.4.14 → 17.4.16

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.4.14
6
- * @date 2024-11-28T09:08:12.462Z
7
- * @hash 81bf386
5
+ * @version 17.4.16
6
+ * @date 2024-12-19T07:50:04.021Z
7
+ * @hash 6b827fc
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -305,8 +305,8 @@
305
305
  const DEBOUNCE_TIME = 200;
306
306
  const MESSAGE_VERSION = 1;
307
307
  // Sheets
308
- const FORBIDDEN_SHEET_CHARS = ["'", "*", "?", "/", "\\", "[", "]"];
309
- const FORBIDDEN_IN_EXCEL_REGEX = /'|\*|\?|\/|\\|\[|\]/;
308
+ const FORBIDDEN_SHEETNAME_CHARS = ["'", "*", "?", "/", "\\", "[", "]"];
309
+ const FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX = /'|\*|\?|\/|\\|\[|\]/;
310
310
  // Cells
311
311
  const FORMULA_REF_IDENTIFIER = "|";
312
312
  // Components
@@ -352,6 +352,7 @@
352
352
  //------------------------------------------------------------------------------
353
353
  // Miscellaneous
354
354
  //------------------------------------------------------------------------------
355
+ const sanitizeSheetNameRegex = new RegExp(FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX, "g");
355
356
  /**
356
357
  * Remove quotes from a quoted string
357
358
  * ```js
@@ -447,6 +448,10 @@
447
448
  }
448
449
  return sheetName;
449
450
  }
451
+ /** Replace the excel-excluded characters of a sheetName */
452
+ function sanitizeSheetName(sheetName, replacementChar = " ") {
453
+ return sheetName.replace(sanitizeSheetNameRegex, replacementChar);
454
+ }
450
455
  function clip(val, min, max) {
451
456
  return val < min ? min : val > max ? max : val;
452
457
  }
@@ -762,6 +767,7 @@
762
767
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
763
768
  */
764
769
  const whiteSpaceSpecialCharacters = [
770
+ " ",
765
771
  "\t",
766
772
  "\f",
767
773
  "\v",
@@ -776,17 +782,15 @@
776
782
  String.fromCharCode(parseInt("3000", 16)),
777
783
  String.fromCharCode(parseInt("feff", 16)),
778
784
  ];
779
- const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|") + "|(\r\n|\r|\n)", "g");
785
+ const whiteSpaceRegexp = new RegExp(whiteSpaceSpecialCharacters.join("|"), "g");
786
+ const newLineRegexp = /(\r\n|\r)/g;
780
787
  /**
781
- * Replace all the special spaces in a string (non-breaking, tabs, ...) by normal spaces, and all the
782
- * different newlines types by \n.
788
+ * Replace all different newlines characters by \n
783
789
  */
784
- function replaceSpecialSpaces(text) {
790
+ function replaceNewLines(text) {
785
791
  if (!text)
786
792
  return "";
787
- if (!whiteSpaceRegexp.test(text))
788
- return text;
789
- return text.replace(whiteSpaceRegexp, (match, newLine) => (newLine ? NEWLINE : " "));
793
+ return text.replace(newLineRegexp, NEWLINE);
790
794
  }
791
795
  /**
792
796
  * Determine if the numbers are consecutive.
@@ -5678,7 +5682,7 @@
5678
5682
  const POSTFIX_UNARY_OPERATORS = ["%"];
5679
5683
  const OPERATORS = "+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(POSTFIX_UNARY_OPERATORS);
5680
5684
  function tokenize(str, locale = DEFAULT_LOCALE) {
5681
- str = replaceSpecialSpaces(str);
5685
+ str = replaceNewLines(str);
5682
5686
  const chars = new TokenizingChars(str);
5683
5687
  const result = [];
5684
5688
  while (!chars.isOver()) {
@@ -5825,12 +5829,12 @@
5825
5829
  if (length) {
5826
5830
  return { type: "SPACE", value: NEWLINE.repeat(length) };
5827
5831
  }
5828
- while (chars.current === " ") {
5829
- length++;
5830
- chars.shift();
5832
+ let spaces = "";
5833
+ while (chars.current && chars.current.match(whiteSpaceRegexp)) {
5834
+ spaces += chars.shift();
5831
5835
  }
5832
- if (length) {
5833
- return { type: "SPACE", value: " ".repeat(length) };
5836
+ if (spaces) {
5837
+ return { type: "SPACE", value: spaces };
5834
5838
  }
5835
5839
  return null;
5836
5840
  }
@@ -38560,6 +38564,7 @@ stores.inject(MyMetaStore, storeInstance);
38560
38564
  }
38561
38565
  }
38562
38566
  `;
38567
+ const DEFAULT_TABLE_STYLE_COLOR = "#3C78D8";
38563
38568
  class TableStyleEditorPanel extends owl.Component {
38564
38569
  static template = "o-spreadsheet-TableStyleEditorPanel";
38565
38570
  static components = { Section, RoundColorPicker, TableStylePreview };
@@ -38578,7 +38583,7 @@ stores.inject(MyMetaStore, storeInstance);
38578
38583
  : null;
38579
38584
  return {
38580
38585
  pickerOpened: false,
38581
- primaryColor: editedStyle?.primaryColor || "#3C78D8",
38586
+ primaryColor: editedStyle?.primaryColor || DEFAULT_TABLE_STYLE_COLOR,
38582
38587
  selectedTemplateName: editedStyle?.templateName || "lightColoredText",
38583
38588
  styleName: editedStyle?.displayName || this.env.model.getters.getNewCustomTableStyleName(),
38584
38589
  };
@@ -38587,7 +38592,7 @@ stores.inject(MyMetaStore, storeInstance);
38587
38592
  this.state.pickerOpened = !this.state.pickerOpened;
38588
38593
  }
38589
38594
  onColorPicked(color) {
38590
- this.state.primaryColor = color;
38595
+ this.state.primaryColor = isColorValid(color) ? color : DEFAULT_TABLE_STYLE_COLOR;
38591
38596
  this.state.pickerOpened = false;
38592
38597
  }
38593
38598
  onTemplatePicked(templateName) {
@@ -39934,6 +39939,7 @@ stores.inject(MyMetaStore, storeInstance);
39934
39939
  draggedFigure: undefined,
39935
39940
  horizontalSnap: undefined,
39936
39941
  verticalSnap: undefined,
39942
+ cancelDnd: undefined,
39937
39943
  });
39938
39944
  setup() {
39939
39945
  owl.onMounted(() => {
@@ -39946,12 +39952,28 @@ stores.inject(MyMetaStore, storeInstance);
39946
39952
  // new rendering
39947
39953
  this.render();
39948
39954
  });
39955
+ owl.onWillUpdateProps(() => {
39956
+ const sheetId = this.env.model.getters.getActiveSheetId();
39957
+ const draggedFigureId = this.dnd.draggedFigure?.id;
39958
+ if (draggedFigureId && !this.env.model.getters.getFigure(sheetId, draggedFigureId)) {
39959
+ if (this.dnd.cancelDnd) {
39960
+ this.dnd.cancelDnd();
39961
+ }
39962
+ this.dnd.draggedFigure = undefined;
39963
+ this.dnd.horizontalSnap = undefined;
39964
+ this.dnd.verticalSnap = undefined;
39965
+ this.dnd.cancelDnd = undefined;
39966
+ }
39967
+ });
39949
39968
  }
39950
39969
  getVisibleFigures() {
39951
39970
  const visibleFigures = this.env.model.getters.getVisibleFigures();
39952
39971
  if (this.dnd.draggedFigure &&
39953
39972
  !visibleFigures.some((figure) => figure.id === this.dnd.draggedFigure?.id)) {
39954
- visibleFigures.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id));
39973
+ const draggedFigure = this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(), this.dnd.draggedFigure?.id);
39974
+ if (draggedFigure) {
39975
+ visibleFigures.push(draggedFigure);
39976
+ }
39955
39977
  }
39956
39978
  return visibleFigures;
39957
39979
  }
@@ -40070,7 +40092,7 @@ stores.inject(MyMetaStore, storeInstance);
40070
40092
  this.dnd.verticalSnap = undefined;
40071
40093
  this.env.model.dispatch("UPDATE_FIGURE", { sheetId, id: figure.id, x, y });
40072
40094
  };
40073
- startDnd(onMouseMove, onMouseUp);
40095
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
40074
40096
  }
40075
40097
  /**
40076
40098
  * Initialize the resize of a figure with mouse movements
@@ -40118,7 +40140,7 @@ stores.inject(MyMetaStore, storeInstance);
40118
40140
  this.dnd.horizontalSnap = undefined;
40119
40141
  this.dnd.verticalSnap = undefined;
40120
40142
  };
40121
- startDnd(onMouseMove, onMouseUp);
40143
+ this.dnd.cancelDnd = startDnd(onMouseMove, onMouseUp);
40122
40144
  }
40123
40145
  getOtherFigures(figId) {
40124
40146
  return this.getVisibleFigures().filter((f) => f.id !== figId);
@@ -46726,13 +46748,12 @@ stores.inject(MyMetaStore, storeInstance);
46726
46748
  to: 8,
46727
46749
  applyMigration(data) {
46728
46750
  const namesTaken = [];
46729
- const globalForbiddenInExcel = new RegExp(FORBIDDEN_IN_EXCEL_REGEX, "g");
46730
46751
  for (let sheet of data.sheets || []) {
46731
46752
  if (!sheet.name) {
46732
46753
  continue;
46733
46754
  }
46734
46755
  const oldName = sheet.name;
46735
- const escapedName = oldName.replace(globalForbiddenInExcel, "_");
46756
+ const escapedName = sanitizeSheetName(oldName, "_");
46736
46757
  let i = 1;
46737
46758
  let newName = escapedName;
46738
46759
  while (namesTaken.includes(newName)) {
@@ -48231,7 +48252,7 @@ stores.inject(MyMetaStore, storeInstance);
48231
48252
  const before = this.getters.getCell({ sheetId, col, row });
48232
48253
  const hasContent = "content" in after || "formula" in after;
48233
48254
  // Compute the new cell properties
48234
- const afterContent = hasContent ? replaceSpecialSpaces(after?.content) : before?.content || "";
48255
+ const afterContent = hasContent ? replaceNewLines(after?.content) : before?.content || "";
48235
48256
  let style;
48236
48257
  if (after.style !== undefined) {
48237
48258
  style = after.style || undefined;
@@ -51092,6 +51113,9 @@ stores.inject(MyMetaStore, storeInstance);
51092
51113
  };
51093
51114
  }
51094
51115
  getUnboundedZone(sheetId, zone) {
51116
+ if (zone.bottom === undefined || zone.right === undefined) {
51117
+ return zone;
51118
+ }
51095
51119
  const isFullRow = zone.left === 0 && zone.right === this.getNumberCols(sheetId) - 1;
51096
51120
  const isFullCol = zone.top === 0 && zone.bottom === this.getNumberRows(sheetId) - 1;
51097
51121
  return {
@@ -51257,7 +51281,7 @@ stores.inject(MyMetaStore, storeInstance);
51257
51281
  if (orderedSheetIds.find((id) => sheets[id]?.name.toLowerCase() === name && id !== cmd.sheetId)) {
51258
51282
  return "DuplicatedSheetName" /* CommandResult.DuplicatedSheetName */;
51259
51283
  }
51260
- if (FORBIDDEN_IN_EXCEL_REGEX.test(name)) {
51284
+ if (FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX.test(name)) {
51261
51285
  return "ForbiddenCharactersInSheetName" /* CommandResult.ForbiddenCharactersInSheetName */;
51262
51286
  }
51263
51287
  return "Success" /* CommandResult.Success */;
@@ -56046,11 +56070,13 @@ stores.inject(MyMetaStore, storeInstance);
56046
56070
  return EMPTY_PIVOT_CELL;
56047
56071
  }
56048
56072
  if (functionName === "PIVOT") {
56049
- const includeTotal = args[2] === false ? false : undefined;
56050
- const includeColumnHeaders = args[3] === false ? false : undefined;
56073
+ const includeTotal = toScalar(args[2]);
56074
+ const shouldIncludeTotal = includeTotal === undefined ? true : toBoolean(includeTotal);
56075
+ const includeColumnHeaders = toScalar(args[3]);
56076
+ const shouldIncludeColumnHeaders = includeColumnHeaders === undefined ? true : toBoolean(includeColumnHeaders);
56051
56077
  const pivotCells = pivot
56052
56078
  .getTableStructure()
56053
- .getPivotCells(includeTotal, includeColumnHeaders);
56079
+ .getPivotCells(shouldIncludeTotal, shouldIncludeColumnHeaders);
56054
56080
  const pivotCol = position.col - mainPosition.col;
56055
56081
  const pivotRow = position.row - mainPosition.row;
56056
56082
  return pivotCells[pivotCol][pivotRow];
@@ -58155,7 +58181,7 @@ stores.inject(MyMetaStore, storeInstance);
58155
58181
  getPivotDuplicateSheetName(pivotName) {
58156
58182
  let i = 1;
58157
58183
  const names = this.getters.getSheetIds().map((id) => this.getters.getSheetName(id));
58158
- const sanitizedName = pivotName.replace(new RegExp(FORBIDDEN_IN_EXCEL_REGEX, "g"), " ");
58184
+ const sanitizedName = sanitizeSheetName(pivotName);
58159
58185
  let name = sanitizedName;
58160
58186
  while (names.includes(name)) {
58161
58187
  name = `${sanitizedName} (${i})`;
@@ -61299,6 +61325,7 @@ stores.inject(MyMetaStore, storeInstance);
61299
61325
  break;
61300
61326
  case "DELETE_SHEET":
61301
61327
  this.cleanViewports();
61328
+ this.sheetsWithDirtyViewports.delete(cmd.sheetId);
61302
61329
  break;
61303
61330
  case "ACTIVATE_SHEET":
61304
61331
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
@@ -62196,7 +62223,7 @@ stores.inject(MyMetaStore, storeInstance);
62196
62223
  env.raiseError(_t("A sheet with the name %s already exists. Please select another name.", name), errorCallback);
62197
62224
  }
62198
62225
  else if (result.reasons.includes("ForbiddenCharactersInSheetName" /* CommandResult.ForbiddenCharactersInSheetName */)) {
62199
- env.raiseError(_t("Some used characters are not allowed in a sheet name (Forbidden characters are %s).", FORBIDDEN_SHEET_CHARS.join(" ")), errorCallback);
62226
+ env.raiseError(_t("Some used characters are not allowed in a sheet name (Forbidden characters are %s).", FORBIDDEN_SHEETNAME_CHARS.join(" ")), errorCallback);
62200
62227
  }
62201
62228
  }
62202
62229
 
@@ -63455,7 +63482,7 @@ stores.inject(MyMetaStore, storeInstance);
63455
63482
  setup() {
63456
63483
  owl.onWillUpdateProps((nextProps) => {
63457
63484
  if (nextProps.action !== this.props.action) {
63458
- this.actionButton = createAction(this.props.action);
63485
+ this.actionButton = createAction(nextProps.action);
63459
63486
  }
63460
63487
  });
63461
63488
  }
@@ -63722,7 +63749,6 @@ stores.inject(MyMetaStore, storeInstance);
63722
63749
  height: fit-content;
63723
63750
  margin-top: -1px;
63724
63751
  border: 1px solid;
63725
- z-index: ${ComponentsImportance.TopBarComposer};
63726
63752
 
63727
63753
  .o-composer:empty:not(:focus):not(.active)::before {
63728
63754
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
@@ -63764,6 +63790,7 @@ stores.inject(MyMetaStore, storeInstance);
63764
63790
  }
63765
63791
  return cssPropertiesToCss({
63766
63792
  "border-color": SELECTION_BORDER_COLOR,
63793
+ "z-index": String(ComponentsImportance.TopBarComposer),
63767
63794
  });
63768
63795
  }
63769
63796
  get delimitation() {
@@ -68588,6 +68615,7 @@ stores.inject(MyMetaStore, storeInstance);
68588
68615
  createPivotFormula,
68589
68616
  areDomainArgsFieldsValid,
68590
68617
  formatTickValue,
68618
+ sanitizeSheetName,
68591
68619
  };
68592
68620
  const links = {
68593
68621
  isMarkdownLink,
@@ -68718,9 +68746,9 @@ stores.inject(MyMetaStore, storeInstance);
68718
68746
  exports.tokenize = tokenize;
68719
68747
 
68720
68748
 
68721
- __info__.version = "17.4.14";
68722
- __info__.date = "2024-11-28T09:08:12.462Z";
68723
- __info__.hash = "81bf386";
68749
+ __info__.version = "17.4.16";
68750
+ __info__.date = "2024-12-19T07:50:04.021Z";
68751
+ __info__.hash = "6b827fc";
68724
68752
 
68725
68753
 
68726
68754
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);