@odoo/o-spreadsheet 16.3.3 → 16.3.4

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.
@@ -754,12 +754,20 @@ function getDefaultCellHeight(cell) {
754
754
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
755
755
  }
756
756
  function computeTextWidth(context, text, style) {
757
- context.save();
758
- context.font = computeTextFont(style);
759
- const textWidth = context.measureText(text).width;
760
- context.restore();
761
- return textWidth;
757
+ const font = computeTextFont(style);
758
+ if (!textWidthCache[font]) {
759
+ textWidthCache[font] = {};
760
+ }
761
+ if (textWidthCache[font][text] === undefined) {
762
+ context.save();
763
+ context.font = font;
764
+ const textWidth = context.measureText(text).width;
765
+ context.restore();
766
+ textWidthCache[font][text] = textWidth;
767
+ }
768
+ return textWidthCache[font][text];
762
769
  }
770
+ const textWidthCache = {};
763
771
  function fontSizeInPixels(fontSize) {
764
772
  return Math.round((fontSize * 96) / 72);
765
773
  }
@@ -9519,9 +9527,9 @@ const ARG_TYPES = [
9519
9527
  "META",
9520
9528
  ];
9521
9529
  function arg(definition, description = "") {
9522
- return makeArg(`${definition} ${description}`);
9530
+ return makeArg(definition, description);
9523
9531
  }
9524
- function makeArg(str) {
9532
+ function makeArg(str, description) {
9525
9533
  let parts = str.match(ARG_REGEXP);
9526
9534
  let name = parts[1].trim();
9527
9535
  let types = [];
@@ -9551,7 +9559,6 @@ function makeArg(str) {
9551
9559
  defaultValue = param.trim().slice(8);
9552
9560
  }
9553
9561
  }
9554
- let description = parts[3].trim();
9555
9562
  const result = {
9556
9563
  name,
9557
9564
  description,
@@ -20932,6 +20939,7 @@ class Composer extends owl.Component {
20932
20939
  (this.autoCompleteState.selectedIndex + 1) % this.autoCompleteState.values.length;
20933
20940
  }
20934
20941
  }
20942
+ this.updateCursorIfNeeded();
20935
20943
  }
20936
20944
  processTabKey(ev) {
20937
20945
  ev.preventDefault();
@@ -21000,10 +21008,12 @@ class Composer extends owl.Component {
21000
21008
  }
21001
21009
  else {
21002
21010
  ev.stopPropagation();
21011
+ this.updateCursorIfNeeded();
21003
21012
  }
21004
- const { start, end } = this.contentHelper.getCurrentSelection();
21005
- if (!this.env.model.getters.isSelectingForComposer() &&
21006
- !(ev.key === "Enter" && (ev.altKey || ev.ctrlKey))) {
21013
+ }
21014
+ updateCursorIfNeeded() {
21015
+ if (!this.env.model.getters.isSelectingForComposer()) {
21016
+ const { start, end } = this.contentHelper.getCurrentSelection();
21007
21017
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
21008
21018
  this.isKeyStillDown = true;
21009
21019
  }
@@ -21061,7 +21071,12 @@ class Composer extends owl.Component {
21061
21071
  };
21062
21072
  });
21063
21073
  if (searchTerm) {
21064
- values = fuzzyLookup(searchTerm, values, (t) => t.text);
21074
+ if (searchTerm.toLowerCase() === "true" || searchTerm.toLowerCase() === "false") {
21075
+ values = [];
21076
+ }
21077
+ else {
21078
+ values = fuzzyLookup(searchTerm, values, (t) => t.text);
21079
+ }
21065
21080
  }
21066
21081
  else {
21067
21082
  // alphabetical order
@@ -30644,7 +30659,14 @@ class FiltersPlugin extends CorePlugin {
30644
30659
  this.history.update("tables", filterTables);
30645
30660
  break;
30646
30661
  case "DUPLICATE_SHEET":
30647
- this.history.update("tables", cmd.sheetIdTo, deepCopy(this.tables[cmd.sheetId]));
30662
+ const tables = {};
30663
+ for (const filterTable of Object.values(this.tables[cmd.sheetId] || {})) {
30664
+ if (filterTable) {
30665
+ const newFilterTable = deepCopy(filterTable);
30666
+ tables[newFilterTable.id] = newFilterTable;
30667
+ }
30668
+ }
30669
+ this.history.update("tables", cmd.sheetIdTo, tables);
30648
30670
  break;
30649
30671
  case "ADD_COLUMNS_ROWS":
30650
30672
  this.onAddColumnsRows(cmd);
@@ -34193,6 +34215,7 @@ class FilterEvaluationPlugin extends UIPlugin {
34193
34215
  }
34194
34216
  exportForExcel(data) {
34195
34217
  for (const sheetData of data.sheets) {
34218
+ const sheetId = sheetData.id;
34196
34219
  for (const tableData of sheetData.filterTables) {
34197
34220
  const tableZone = toZone(tableData.range);
34198
34221
  const filters = [];
@@ -34208,20 +34231,20 @@ class FilterEvaluationPlugin extends UIPlugin {
34208
34231
  if (!filter)
34209
34232
  continue;
34210
34233
  const valuesInFilterZone = filter.filteredZone
34211
- ? positions(filter.filteredZone)
34212
- .map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId: sheetData.id, col, row }))
34213
- .filter((cell) => cell.type !== CellValueType.empty)
34214
- .map((cell) => cell.formattedValue)
34234
+ ? positions(filter.filteredZone).map((position) => this.getters.getEvaluatedCell({ sheetId, ...position }).formattedValue)
34215
34235
  : [];
34216
- // In xlsx, filtered values = values that are displayed, not values that are hidden
34217
- const xlsxFilteredValues = valuesInFilterZone.filter((val) => !filteredValues.includes(val));
34218
- filters.push({ colId: i, filteredValues: [...new Set(xlsxFilteredValues)] });
34219
- // In xlsx, filter header should ALWAYS be a string and should be unique
34220
- const headerPosition = {
34221
- col: filter.col,
34222
- row: filter.zoneWithHeaders.top,
34223
- sheetId: sheetData.id,
34224
- };
34236
+ if (filteredValues.length) {
34237
+ const xlsxDisplayedValues = valuesInFilterZone
34238
+ .filter((val) => val)
34239
+ .filter((val) => !filteredValues.includes(val));
34240
+ filters.push({
34241
+ colId: i,
34242
+ displayedValues: [...new Set(xlsxDisplayedValues)],
34243
+ displayBlanks: !filteredValues.includes("") && valuesInFilterZone.some((val) => !val),
34244
+ });
34245
+ }
34246
+ // In xlsx, filter header should ALWAYS be a string and should be unique in the table
34247
+ const headerPosition = { col: filter.col, row: filter.zoneWithHeaders.top, sheetId };
34225
34248
  const headerString = this.getters.getEvaluatedCell(headerPosition).formattedValue;
34226
34249
  const headerName = this.getUniqueColNameForExcel(i, headerString, headerNames);
34227
34250
  headerNames.push(headerName);
@@ -43293,11 +43316,9 @@ TopBarComposer.props = {
43293
43316
  onComposerContentFocused: Function,
43294
43317
  };
43295
43318
 
43296
- // -----------------------------------------------------------------------------
43297
- // TopBar
43298
- // -----------------------------------------------------------------------------
43299
43319
  css /* scss */ `
43300
43320
  .o-font-size-editor {
43321
+ height: calc(100% - 4px);
43301
43322
  input.o-font-size {
43302
43323
  outline-color: ${SELECTION_BORDER_COLOR};
43303
43324
  height: 20px;
@@ -43310,13 +43331,13 @@ css /* scss */ `
43310
43331
  input::-webkit-inner-spin-button {
43311
43332
  -webkit-appearance: none;
43312
43333
  }
43313
-
43314
- .o-text-options > div {
43315
- line-height: 26px;
43316
- padding: 3px 12px;
43317
- &:hover {
43318
- background-color: rgba(0, 0, 0, 0.08);
43319
- }
43334
+ }
43335
+ .o-text-options > div {
43336
+ cursor: pointer;
43337
+ line-height: 26px;
43338
+ padding: 3px 12px;
43339
+ &:hover {
43340
+ background-color: rgba(0, 0, 0, 0.08);
43320
43341
  }
43321
43342
  }
43322
43343
  `;
@@ -43381,6 +43402,7 @@ class FontSizeEditor extends owl.Component {
43381
43402
  FontSizeEditor.props = {
43382
43403
  onToggle: Function,
43383
43404
  dropdownStyle: String,
43405
+ class: String,
43384
43406
  };
43385
43407
 
43386
43408
  // -----------------------------------------------------------------------------
@@ -46549,15 +46571,10 @@ function addAutoFilter(table) {
46549
46571
  `;
46550
46572
  }
46551
46573
  function addFilterColumns(table) {
46552
- const tableZone = toZone(table.range);
46553
46574
  const columns = [];
46554
- for (const i of range(0, zoneToDimension(tableZone).numberOfCols)) {
46555
- const filter = table.filters[i];
46556
- if (!filter || !filter.filteredValues.length) {
46557
- continue;
46558
- }
46575
+ for (const filter of table.filters) {
46559
46576
  const colXml = escapeXml /*xml*/ `
46560
- <filterColumn ${formatAttributes([["colId", i]])}>
46577
+ <filterColumn ${formatAttributes([["colId", filter.colId]])}>
46561
46578
  ${addFilter(filter)}
46562
46579
  </filterColumn>
46563
46580
  `;
@@ -46566,9 +46583,10 @@ function addFilterColumns(table) {
46566
46583
  return columns;
46567
46584
  }
46568
46585
  function addFilter(filter) {
46569
- const filterValues = filter.filteredValues.map((val) => escapeXml /*xml*/ `<filter ${formatAttributes([["val", val]])}/>`);
46586
+ const filterValues = filter.displayedValues.map((val) => escapeXml /*xml*/ `<filter ${formatAttributes([["val", val]])}/>`);
46587
+ const filterAttributes = filter.displayBlanks ? [["blank", 1]] : [];
46570
46588
  return escapeXml /*xml*/ `
46571
- <filters>
46589
+ <filters ${formatAttributes(filterAttributes)}>
46572
46590
  ${joinXmlNodes(filterValues)}
46573
46591
  </filters>
46574
46592
  `;
@@ -46687,8 +46705,13 @@ function addHyperlinks(construct, data, sheetIndex) {
46687
46705
  const sheetId = parseSheetUrl(url);
46688
46706
  const sheet = data.sheets.find((sheet) => sheet.id === sheetId);
46689
46707
  const location = sheet ? `${sheet.name}!A1` : INCORRECT_RANGE_STRING;
46708
+ const hyperlinkAttributes = [
46709
+ ["display", label],
46710
+ ["location", location],
46711
+ ["ref", xc],
46712
+ ];
46690
46713
  linkNodes.push(escapeXml /*xml*/ `
46691
- <hyperlink display="${label}" location="${location}" ref="${xc}"/>
46714
+ <hyperlink ${formatAttributes(hyperlinkAttributes)}/>
46692
46715
  `);
46693
46716
  }
46694
46717
  else {
@@ -46697,8 +46720,12 @@ function addHyperlinks(construct, data, sheetIndex) {
46697
46720
  type: XLSX_RELATION_TYPE.hyperlink,
46698
46721
  targetMode: "External",
46699
46722
  });
46723
+ const hyperlinkAttributes = [
46724
+ ["r:id", linkRelId],
46725
+ ["ref", xc],
46726
+ ];
46700
46727
  linkNodes.push(escapeXml /*xml*/ `
46701
- <hyperlink r:id="${linkRelId}" ref="${xc}"/>
46728
+ <hyperlink ${formatAttributes(hyperlinkAttributes)}/>
46702
46729
  `);
46703
46730
  }
46704
46731
  }
@@ -47606,6 +47633,6 @@ exports.setTranslationMethod = setTranslationMethod;
47606
47633
  exports.tokenize = tokenize;
47607
47634
 
47608
47635
 
47609
- __info__.version = '16.3.3';
47610
- __info__.date = '2023-06-12T13:50:01.114Z';
47611
- __info__.hash = 'd3ab96f';
47636
+ __info__.version = '16.3.4';
47637
+ __info__.date = '2023-06-26T14:34:27.019Z';
47638
+ __info__.hash = '94f9dcd';