@odoo/o-spreadsheet 17.0.8 → 17.0.9

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.8
6
- * @date 2024-01-17T10:27:32.736Z
7
- * @hash 0f2d46e
5
+ * @version 17.0.9
6
+ * @date 2024-01-29T13:53:22.963Z
7
+ * @hash 3c1209a
8
8
  */
9
9
 
10
10
  'use strict';
@@ -2122,6 +2122,7 @@ exports.CommandResult = void 0;
2122
2122
  CommandResult["BlockingValidationRule"] = "BlockingValidationRule";
2123
2123
  CommandResult["InvalidCopyPasteSelection"] = "InvalidCopyPasteSelection";
2124
2124
  CommandResult["NoChanges"] = "NoChanges";
2125
+ CommandResult["InvalidInputId"] = "InvalidInputId";
2125
2126
  })(exports.CommandResult || (exports.CommandResult = {}));
2126
2127
 
2127
2128
  const DEFAULT_LOCALES = [
@@ -3266,27 +3267,30 @@ function roundFormat(format) {
3266
3267
  }
3267
3268
  function createLargeNumberFormat(format, magnitude, postFix, locale) {
3268
3269
  const internalFormat = parseFormat(format || "#,##0");
3269
- const largeNumberFormat = internalFormat
3270
- .map((formatPart) => {
3271
- if (formatPart.type === "NUMBER") {
3272
- return [
3273
- {
3274
- ...formatPart,
3275
- format: {
3276
- ...formatPart.format,
3277
- magnitude,
3278
- decimalPart: undefined,
3279
- },
3280
- },
3281
- {
3282
- type: "STRING",
3283
- format: postFix,
3284
- },
3285
- ];
3270
+ const largeNumberFormat = [];
3271
+ for (let i = 0; i < internalFormat.length; i++) {
3272
+ const formatPart = internalFormat[i];
3273
+ if (formatPart.type !== "NUMBER") {
3274
+ largeNumberFormat.push(formatPart);
3275
+ continue;
3286
3276
  }
3287
- return formatPart;
3288
- })
3289
- .flat();
3277
+ largeNumberFormat.push({
3278
+ ...formatPart,
3279
+ format: {
3280
+ ...formatPart.format,
3281
+ magnitude,
3282
+ decimalPart: undefined,
3283
+ },
3284
+ });
3285
+ largeNumberFormat.push({
3286
+ type: "STRING",
3287
+ format: postFix,
3288
+ });
3289
+ const nextFormatPart = internalFormat[i + 1];
3290
+ if (nextFormatPart?.type === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
3291
+ i++;
3292
+ }
3293
+ }
3290
3294
  return convertInternalFormatToFormat(largeNumberFormat);
3291
3295
  }
3292
3296
  function changeDecimalPlaces(format, step, locale) {
@@ -26808,6 +26812,9 @@ class Composer extends owl.Component {
26808
26812
  const token = tokens.filter((token) => token.value.includes(currentSelectedText) &&
26809
26813
  token.start <= currentSelection.start &&
26810
26814
  token.end >= currentSelection.end)[0];
26815
+ if (!token) {
26816
+ return;
26817
+ }
26811
26818
  if (token.type === "REFERENCE") {
26812
26819
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", {
26813
26820
  start: token.start,
@@ -39838,22 +39845,17 @@ class CompilationParametersBuilder {
39838
39845
  * The `compute` of the formula's function must process it completely
39839
39846
  */
39840
39847
  refFn(range, isMeta, functionName, paramNumber) {
39848
+ this.assertRangeValid(range);
39841
39849
  if (isMeta) {
39842
39850
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
39843
39851
  return { value: zoneToXc(range.zone) };
39844
39852
  }
39845
- if (!isZoneValid(range.zone)) {
39846
- throw new InvalidReferenceError();
39847
- }
39848
39853
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
39849
39854
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
39850
39855
  throw new Error(paramNumber
39851
39856
  ? _t("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
39852
39857
  : _t("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
39853
39858
  }
39854
- if (range.invalidSheetName) {
39855
- throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39856
- }
39857
39859
  const position = { sheetId: range.sheetId, col: range.zone.left, row: range.zone.top };
39858
39860
  return this.readCell(position);
39859
39861
  }
@@ -39888,10 +39890,10 @@ class CompilationParametersBuilder {
39888
39890
  * Note that each col is possibly sparse: it only contain the values of cells
39889
39891
  * that are actually present in the grid.
39890
39892
  */
39891
- range({ sheetId, zone }) {
39892
- if (!isZoneValid(zone)) {
39893
- throw new InvalidReferenceError();
39894
- }
39893
+ range(range) {
39894
+ this.assertRangeValid(range);
39895
+ const sheetId = range.sheetId;
39896
+ const zone = range.zone;
39895
39897
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
39896
39898
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
39897
39899
  const sheetZone = this.getters.getSheetZone(sheetId);
@@ -39928,6 +39930,14 @@ class CompilationParametersBuilder {
39928
39930
  this.rangeCache[cacheKey] = matrix;
39929
39931
  return matrix;
39930
39932
  }
39933
+ assertRangeValid(range) {
39934
+ if (!isZoneValid(range.zone)) {
39935
+ throw new InvalidReferenceError();
39936
+ }
39937
+ if (range.invalidSheetName) {
39938
+ throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39939
+ }
39940
+ }
39931
39941
  }
39932
39942
 
39933
39943
  function quickselect(arr, k, left, right, compare) {
@@ -46000,27 +46010,6 @@ class SelectionInputPlugin extends UIPlugin {
46000
46010
  // ---------------------------------------------------------------------------
46001
46011
  // Command Handling
46002
46012
  // ---------------------------------------------------------------------------
46003
- allowDispatch(cmd) {
46004
- switch (cmd.type) {
46005
- case "ADD_RANGE":
46006
- case "ADD_EMPTY_RANGE":
46007
- if (this.inputHasSingleRange && this.ranges.length === 1) {
46008
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46009
- }
46010
- break;
46011
- case "REMOVE_RANGE":
46012
- if (this.ranges.length === 1) {
46013
- return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46014
- }
46015
- break;
46016
- case "CHANGE_RANGE":
46017
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
46018
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46019
- }
46020
- break;
46021
- }
46022
- return "Success" /* CommandResult.Success */;
46023
- }
46024
46013
  handleEvent(event) {
46025
46014
  if (this.focusedRangeIndex === null) {
46026
46015
  return;
@@ -46258,6 +46247,15 @@ class SelectionInputsManagerPlugin extends UIPlugin {
46258
46247
  // Command Handling
46259
46248
  // ---------------------------------------------------------------------------
46260
46249
  allowDispatch(cmd) {
46250
+ switch (cmd.type) {
46251
+ case "FOCUS_RANGE":
46252
+ case "CHANGE_RANGE":
46253
+ case "ADD_EMPTY_RANGE":
46254
+ case "REMOVE_RANGE":
46255
+ if (!this.inputs[cmd.id]) {
46256
+ return "InvalidInputId" /* CommandResult.InvalidInputId */;
46257
+ }
46258
+ }
46261
46259
  switch (cmd.type) {
46262
46260
  case "FOCUS_RANGE":
46263
46261
  const index = this.currentInput?.getIndex(cmd.rangeId);
@@ -46265,9 +46263,25 @@ class SelectionInputsManagerPlugin extends UIPlugin {
46265
46263
  return "InputAlreadyFocused" /* CommandResult.InputAlreadyFocused */;
46266
46264
  }
46267
46265
  break;
46268
- }
46269
- if (this.currentInput) {
46270
- return this.currentInput.allowDispatch(cmd);
46266
+ case "ADD_RANGE":
46267
+ case "ADD_EMPTY_RANGE":
46268
+ const input = this.inputs[cmd.id];
46269
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
46270
+ return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46271
+ }
46272
+ break;
46273
+ case "REMOVE_RANGE":
46274
+ if (this.inputs[cmd.id].ranges.length === 1) {
46275
+ return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46276
+ }
46277
+ break;
46278
+ case "CHANGE_RANGE": {
46279
+ const input = this.inputs[cmd.id];
46280
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
46281
+ return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46282
+ }
46283
+ break;
46284
+ }
46271
46285
  }
46272
46286
  return "Success" /* CommandResult.Success */;
46273
46287
  }
@@ -48576,9 +48590,10 @@ class EditionPlugin extends UIPlugin {
48576
48590
  */
48577
48591
  getReferencedRanges() {
48578
48592
  const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
48579
- return this.currentTokens
48593
+ const referenceRanges = this.currentTokens
48580
48594
  .filter((token) => token.type === "REFERENCE")
48581
48595
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
48596
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
48582
48597
  }
48583
48598
  getAutoCompleteDataValidationValues() {
48584
48599
  if (this.mode === "inactive") {
@@ -56770,6 +56785,6 @@ exports.setTranslationMethod = setTranslationMethod;
56770
56785
  exports.tokenize = tokenize;
56771
56786
 
56772
56787
 
56773
- __info__.version = "17.0.8";
56774
- __info__.date = "2024-01-17T10:27:32.736Z";
56775
- __info__.hash = "0f2d46e";
56788
+ __info__.version = "17.0.9";
56789
+ __info__.date = "2024-01-29T13:53:22.963Z";
56790
+ __info__.hash = "3c1209a";
@@ -2531,7 +2531,8 @@ declare const enum CommandResult {
2531
2531
  InvalidNumberOfCriterionValues = "InvalidNumberOfCriterionValues",
2532
2532
  BlockingValidationRule = "BlockingValidationRule",
2533
2533
  InvalidCopyPasteSelection = "InvalidCopyPasteSelection",
2534
- NoChanges = "NoChanges"
2534
+ NoChanges = "NoChanges",
2535
+ InvalidInputId = "InvalidInputId"
2535
2536
  }
2536
2537
  interface CommandHandler<T> {
2537
2538
  allowDispatch(command: T): CommandResult | CommandResult[];
@@ -4603,14 +4604,13 @@ interface RangeInputValue {
4603
4604
  * This plugin handles this internal state.
4604
4605
  */
4605
4606
  declare class SelectionInputPlugin extends UIPlugin implements StreamCallbacks<SelectionEvent> {
4606
- private readonly inputHasSingleRange;
4607
+ readonly inputHasSingleRange: boolean;
4607
4608
  static layers: LAYERS[];
4608
4609
  static getters: never[];
4609
4610
  ranges: RangeInputValue[];
4610
4611
  focusedRangeIndex: number | null;
4611
4612
  private inputSheetId;
4612
4613
  constructor(config: UIPluginConfig, initialRanges: string[], inputHasSingleRange: boolean);
4613
- allowDispatch(cmd: LocalCommand): CommandResult;
4614
4614
  handleEvent(event: SelectionEvent): void;
4615
4615
  handle(cmd: Command): void;
4616
4616
  getSelectionInputValue(): string[];
@@ -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.8
6
- * @date 2024-01-17T10:27:32.736Z
7
- * @hash 0f2d46e
5
+ * @version 17.0.9
6
+ * @date 2024-01-29T13:53:22.963Z
7
+ * @hash 3c1209a
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillUnmount, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -2120,6 +2120,7 @@ var CommandResult;
2120
2120
  CommandResult["BlockingValidationRule"] = "BlockingValidationRule";
2121
2121
  CommandResult["InvalidCopyPasteSelection"] = "InvalidCopyPasteSelection";
2122
2122
  CommandResult["NoChanges"] = "NoChanges";
2123
+ CommandResult["InvalidInputId"] = "InvalidInputId";
2123
2124
  })(CommandResult || (CommandResult = {}));
2124
2125
 
2125
2126
  const DEFAULT_LOCALES = [
@@ -3264,27 +3265,30 @@ function roundFormat(format) {
3264
3265
  }
3265
3266
  function createLargeNumberFormat(format, magnitude, postFix, locale) {
3266
3267
  const internalFormat = parseFormat(format || "#,##0");
3267
- const largeNumberFormat = internalFormat
3268
- .map((formatPart) => {
3269
- if (formatPart.type === "NUMBER") {
3270
- return [
3271
- {
3272
- ...formatPart,
3273
- format: {
3274
- ...formatPart.format,
3275
- magnitude,
3276
- decimalPart: undefined,
3277
- },
3278
- },
3279
- {
3280
- type: "STRING",
3281
- format: postFix,
3282
- },
3283
- ];
3268
+ const largeNumberFormat = [];
3269
+ for (let i = 0; i < internalFormat.length; i++) {
3270
+ const formatPart = internalFormat[i];
3271
+ if (formatPart.type !== "NUMBER") {
3272
+ largeNumberFormat.push(formatPart);
3273
+ continue;
3284
3274
  }
3285
- return formatPart;
3286
- })
3287
- .flat();
3275
+ largeNumberFormat.push({
3276
+ ...formatPart,
3277
+ format: {
3278
+ ...formatPart.format,
3279
+ magnitude,
3280
+ decimalPart: undefined,
3281
+ },
3282
+ });
3283
+ largeNumberFormat.push({
3284
+ type: "STRING",
3285
+ format: postFix,
3286
+ });
3287
+ const nextFormatPart = internalFormat[i + 1];
3288
+ if (nextFormatPart?.type === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
3289
+ i++;
3290
+ }
3291
+ }
3288
3292
  return convertInternalFormatToFormat(largeNumberFormat);
3289
3293
  }
3290
3294
  function changeDecimalPlaces(format, step, locale) {
@@ -26806,6 +26810,9 @@ class Composer extends Component {
26806
26810
  const token = tokens.filter((token) => token.value.includes(currentSelectedText) &&
26807
26811
  token.start <= currentSelection.start &&
26808
26812
  token.end >= currentSelection.end)[0];
26813
+ if (!token) {
26814
+ return;
26815
+ }
26809
26816
  if (token.type === "REFERENCE") {
26810
26817
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", {
26811
26818
  start: token.start,
@@ -39836,22 +39843,17 @@ class CompilationParametersBuilder {
39836
39843
  * The `compute` of the formula's function must process it completely
39837
39844
  */
39838
39845
  refFn(range, isMeta, functionName, paramNumber) {
39846
+ this.assertRangeValid(range);
39839
39847
  if (isMeta) {
39840
39848
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
39841
39849
  return { value: zoneToXc(range.zone) };
39842
39850
  }
39843
- if (!isZoneValid(range.zone)) {
39844
- throw new InvalidReferenceError();
39845
- }
39846
39851
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
39847
39852
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
39848
39853
  throw new Error(paramNumber
39849
39854
  ? _t("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
39850
39855
  : _t("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
39851
39856
  }
39852
- if (range.invalidSheetName) {
39853
- throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39854
- }
39855
39857
  const position = { sheetId: range.sheetId, col: range.zone.left, row: range.zone.top };
39856
39858
  return this.readCell(position);
39857
39859
  }
@@ -39886,10 +39888,10 @@ class CompilationParametersBuilder {
39886
39888
  * Note that each col is possibly sparse: it only contain the values of cells
39887
39889
  * that are actually present in the grid.
39888
39890
  */
39889
- range({ sheetId, zone }) {
39890
- if (!isZoneValid(zone)) {
39891
- throw new InvalidReferenceError();
39892
- }
39891
+ range(range) {
39892
+ this.assertRangeValid(range);
39893
+ const sheetId = range.sheetId;
39894
+ const zone = range.zone;
39893
39895
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
39894
39896
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
39895
39897
  const sheetZone = this.getters.getSheetZone(sheetId);
@@ -39926,6 +39928,14 @@ class CompilationParametersBuilder {
39926
39928
  this.rangeCache[cacheKey] = matrix;
39927
39929
  return matrix;
39928
39930
  }
39931
+ assertRangeValid(range) {
39932
+ if (!isZoneValid(range.zone)) {
39933
+ throw new InvalidReferenceError();
39934
+ }
39935
+ if (range.invalidSheetName) {
39936
+ throw new Error(_t("Invalid sheet name: %s", range.invalidSheetName));
39937
+ }
39938
+ }
39929
39939
  }
39930
39940
 
39931
39941
  function quickselect(arr, k, left, right, compare) {
@@ -45998,27 +46008,6 @@ class SelectionInputPlugin extends UIPlugin {
45998
46008
  // ---------------------------------------------------------------------------
45999
46009
  // Command Handling
46000
46010
  // ---------------------------------------------------------------------------
46001
- allowDispatch(cmd) {
46002
- switch (cmd.type) {
46003
- case "ADD_RANGE":
46004
- case "ADD_EMPTY_RANGE":
46005
- if (this.inputHasSingleRange && this.ranges.length === 1) {
46006
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46007
- }
46008
- break;
46009
- case "REMOVE_RANGE":
46010
- if (this.ranges.length === 1) {
46011
- return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46012
- }
46013
- break;
46014
- case "CHANGE_RANGE":
46015
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
46016
- return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46017
- }
46018
- break;
46019
- }
46020
- return "Success" /* CommandResult.Success */;
46021
- }
46022
46011
  handleEvent(event) {
46023
46012
  if (this.focusedRangeIndex === null) {
46024
46013
  return;
@@ -46256,6 +46245,15 @@ class SelectionInputsManagerPlugin extends UIPlugin {
46256
46245
  // Command Handling
46257
46246
  // ---------------------------------------------------------------------------
46258
46247
  allowDispatch(cmd) {
46248
+ switch (cmd.type) {
46249
+ case "FOCUS_RANGE":
46250
+ case "CHANGE_RANGE":
46251
+ case "ADD_EMPTY_RANGE":
46252
+ case "REMOVE_RANGE":
46253
+ if (!this.inputs[cmd.id]) {
46254
+ return "InvalidInputId" /* CommandResult.InvalidInputId */;
46255
+ }
46256
+ }
46259
46257
  switch (cmd.type) {
46260
46258
  case "FOCUS_RANGE":
46261
46259
  const index = this.currentInput?.getIndex(cmd.rangeId);
@@ -46263,9 +46261,25 @@ class SelectionInputsManagerPlugin extends UIPlugin {
46263
46261
  return "InputAlreadyFocused" /* CommandResult.InputAlreadyFocused */;
46264
46262
  }
46265
46263
  break;
46266
- }
46267
- if (this.currentInput) {
46268
- return this.currentInput.allowDispatch(cmd);
46264
+ case "ADD_RANGE":
46265
+ case "ADD_EMPTY_RANGE":
46266
+ const input = this.inputs[cmd.id];
46267
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
46268
+ return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46269
+ }
46270
+ break;
46271
+ case "REMOVE_RANGE":
46272
+ if (this.inputs[cmd.id].ranges.length === 1) {
46273
+ return "MinimumRangesReached" /* CommandResult.MinimumRangesReached */;
46274
+ }
46275
+ break;
46276
+ case "CHANGE_RANGE": {
46277
+ const input = this.inputs[cmd.id];
46278
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
46279
+ return "MaximumRangesReached" /* CommandResult.MaximumRangesReached */;
46280
+ }
46281
+ break;
46282
+ }
46269
46283
  }
46270
46284
  return "Success" /* CommandResult.Success */;
46271
46285
  }
@@ -48574,9 +48588,10 @@ class EditionPlugin extends UIPlugin {
48574
48588
  */
48575
48589
  getReferencedRanges() {
48576
48590
  const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
48577
- return this.currentTokens
48591
+ const referenceRanges = this.currentTokens
48578
48592
  .filter((token) => token.type === "REFERENCE")
48579
48593
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
48594
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
48580
48595
  }
48581
48596
  getAutoCompleteDataValidationValues() {
48582
48597
  if (this.mode === "inactive") {
@@ -56733,6 +56748,6 @@ const constants = {
56733
56748
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
56734
56749
 
56735
56750
 
56736
- __info__.version = "17.0.8";
56737
- __info__.date = "2024-01-17T10:27:32.736Z";
56738
- __info__.hash = "0f2d46e";
56751
+ __info__.version = "17.0.9";
56752
+ __info__.date = "2024-01-29T13:53:22.963Z";
56753
+ __info__.hash = "3c1209a";