@odoo/o-spreadsheet 16.0.19 → 16.0.21

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.
@@ -319,7 +319,16 @@ const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
319
319
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
320
320
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
321
321
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
322
+ const CACHE = {};
322
323
  function parseDateTime(str) {
324
+ if (CACHE[str]) {
325
+ return CACHE[str];
326
+ }
327
+ const date = _parseDateTime(str);
328
+ CACHE[str] = date;
329
+ return date;
330
+ }
331
+ function _parseDateTime(str) {
323
332
  str = str.trim();
324
333
  let time;
325
334
  const timeMatch = str.match(timeRegexp);
@@ -2045,8 +2054,9 @@ class RangeImpl {
2045
2054
  }
2046
2055
  get zone() {
2047
2056
  const { left, top, bottom, right } = this._zone;
2048
- if (right !== undefined && bottom !== undefined)
2049
- return { left, top, right, bottom };
2057
+ if (right !== undefined && bottom !== undefined) {
2058
+ return this._zone;
2059
+ }
2050
2060
  else if (bottom === undefined && right !== undefined) {
2051
2061
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).height - 1 };
2052
2062
  }
@@ -3297,6 +3307,9 @@ exports.CommandResult = void 0;
3297
3307
  CommandResult[CommandResult["InvalidQuantity"] = 86] = "InvalidQuantity";
3298
3308
  })(exports.CommandResult || (exports.CommandResult = {}));
3299
3309
 
3310
+ function isMatrix(x) {
3311
+ return Array.isArray(x) && Array.isArray(x[0]);
3312
+ }
3300
3313
  var DIRECTION;
3301
3314
  (function (DIRECTION) {
3302
3315
  DIRECTION["UP"] = "up";
@@ -3693,6 +3706,9 @@ class FilterMenu extends owl.Component {
3693
3706
  });
3694
3707
  this.state.values = this.getFilterValues(this.props.filterPosition);
3695
3708
  }
3709
+ get isReadonly() {
3710
+ return this.env.model.getters.isReadonly();
3711
+ }
3696
3712
  getFilterValues(position) {
3697
3713
  const sheetId = this.env.model.getters.getActiveSheetId();
3698
3714
  const filter = this.env.model.getters.getFilter(sheetId, position.col, position.row);
@@ -10011,9 +10027,9 @@ class FindAndReplacePanel extends owl.Component {
10011
10027
  }
10012
10028
  setup() {
10013
10029
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
10014
- this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
10015
10030
  owl.onMounted(() => this.focusInput());
10016
10031
  owl.onWillUnmount(() => {
10032
+ clearTimeout(this.debounceTimeoutId);
10017
10033
  this.env.model.dispatch("CLEAR_SEARCH");
10018
10034
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
10019
10035
  });
@@ -10056,6 +10072,13 @@ class FindAndReplacePanel extends owl.Component {
10056
10072
  searchOptions: this.state.searchOptions,
10057
10073
  });
10058
10074
  }
10075
+ debouncedUpdateSearch() {
10076
+ clearTimeout(this.debounceTimeoutId);
10077
+ this.debounceTimeoutId = setTimeout(() => {
10078
+ this.updateSearch();
10079
+ this.debounceTimeoutId = undefined;
10080
+ }, 200);
10081
+ }
10059
10082
  replace() {
10060
10083
  this.env.model.dispatch("REPLACE_SEARCH", {
10061
10084
  replaceWith: this.state.replaceWith,
@@ -17059,6 +17082,36 @@ const HLOOKUP = {
17059
17082
  isExported: true,
17060
17083
  };
17061
17084
  // -----------------------------------------------------------------------------
17085
+ // INDEX
17086
+ // -----------------------------------------------------------------------------
17087
+ const INDEX = {
17088
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
17089
+ args: args(`
17090
+ reference (any, range) ${_lt("The range of cells from which the value is returned.")}
17091
+ row (number) ${_lt("The index of the row to be returned from within the reference range of cells.")}
17092
+ column (number) ${_lt("The index of the column to be returned from within the reference range of cells.")}
17093
+ `),
17094
+ returns: ["ANY"],
17095
+ computeFormat: (reference, row, column) => {
17096
+ var _a;
17097
+ const _row = toNumber(row.value);
17098
+ const _column = toNumber(column.value);
17099
+ return (_a = reference[_column - 1][_row - 1]) === null || _a === void 0 ? void 0 : _a.format;
17100
+ },
17101
+ compute: function (reference, row, column) {
17102
+ const _reference = isMatrix(reference) ? reference : [[reference]];
17103
+ const _row = toNumber(row);
17104
+ const _column = toNumber(column);
17105
+ assert(() => _column >= 0 &&
17106
+ _column - 1 < _reference.length &&
17107
+ _row >= 0 &&
17108
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
17109
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
17110
+ return _reference[_column - 1][_row - 1];
17111
+ },
17112
+ isExported: true,
17113
+ };
17114
+ // -----------------------------------------------------------------------------
17062
17115
  // LOOKUP
17063
17116
  // -----------------------------------------------------------------------------
17064
17117
  const LOOKUP = {
@@ -17247,6 +17300,7 @@ var lookup = /*#__PURE__*/Object.freeze({
17247
17300
  COLUMN: COLUMN,
17248
17301
  COLUMNS: COLUMNS,
17249
17302
  HLOOKUP: HLOOKUP,
17303
+ INDEX: INDEX,
17250
17304
  LOOKUP: LOOKUP,
17251
17305
  MATCH: MATCH,
17252
17306
  ROW: ROW,
@@ -21567,7 +21621,14 @@ class AbstractResizer extends owl.Component {
21567
21621
  return;
21568
21622
  }
21569
21623
  if (this.state.waitingForMove === true) {
21570
- this.startMovement(ev);
21624
+ if (!this.env.model.getters.isGridSelectionActive()) {
21625
+ this._selectElement(index, false);
21626
+ }
21627
+ else {
21628
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
21629
+ // a way to have the grid selection follow the other selections evolution
21630
+ this.startMovement(ev);
21631
+ }
21571
21632
  return;
21572
21633
  }
21573
21634
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -27722,10 +27783,11 @@ class CellPlugin extends CorePlugin {
27722
27783
  * Reconstructs the original formula string based on a normalized form and its dependencies
27723
27784
  */
27724
27785
  buildFormulaContent(sheetId, cell, dependencies) {
27725
- const ranges = dependencies || [...cell.dependencies];
27786
+ const ranges = dependencies || cell.dependencies;
27787
+ let rangeIndex = 0;
27726
27788
  return concat(cell.compiledFormula.tokens.map((token) => {
27727
27789
  if (token.type === "REFERENCE") {
27728
- const range = ranges.shift();
27790
+ const range = ranges[rangeIndex++];
27729
27791
  return this.getters.getRangeString(range, sheetId);
27730
27792
  }
27731
27793
  return token.value;
@@ -31657,7 +31719,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
31657
31719
  });
31658
31720
  for (const filterTable of this.copiedTables) {
31659
31721
  this.dispatch("REMOVE_FILTER_TABLE", {
31660
- sheetId: this.getters.getActiveSheetId(),
31722
+ sheetId: this.sheetId,
31661
31723
  target: [filterTable.zone],
31662
31724
  });
31663
31725
  }
@@ -34630,6 +34692,9 @@ class GridSelectionPlugin extends UIPlugin {
34630
34692
  // ---------------------------------------------------------------------------
34631
34693
  // Getters
34632
34694
  // ---------------------------------------------------------------------------
34695
+ isGridSelectionActive() {
34696
+ return this.selection.isListening(this);
34697
+ }
34633
34698
  getActiveSheet() {
34634
34699
  return this.activeSheet;
34635
34700
  }
@@ -35006,6 +35071,7 @@ GridSelectionPlugin.getters = [
35006
35071
  "getSheetPosition",
35007
35072
  "isSelected",
35008
35073
  "getElementsFromSelection",
35074
+ "isGridSelectionActive",
35009
35075
  ];
35010
35076
 
35011
35077
  const uuidGenerator = new UuidGenerator();
@@ -36316,30 +36382,26 @@ class InternalViewport {
36316
36382
  const { end } = this.getters.getColDimensions(sheetId, targetCol);
36317
36383
  const maxCol = this.getters.getNumberCols(sheetId);
36318
36384
  if (this.offsetX + this.offsetCorrectionX + this.viewportWidth < end) {
36319
- for (let col = this.left; this.offsetX + this.offsetCorrectionX + this.viewportWidth < end; col++) {
36320
- if (col > maxCol) {
36321
- break;
36322
- }
36323
- if (this.getters.isColHidden(sheetId, col)) {
36324
- continue;
36325
- }
36326
- this.offsetX = this.getters.getColDimensions(sheetId, col).end - this.offsetCorrectionX;
36327
- this.offsetScrollbarX = this.offsetX;
36328
- this.adjustViewportZoneX();
36385
+ let finalTarget = targetCol;
36386
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol < maxCol) {
36387
+ finalTarget++;
36329
36388
  }
36389
+ const finalTargetEnd = this.getters.getColDimensions(sheetId, finalTarget).end;
36390
+ const startIndex = this.searchHeaderIndex("COL", finalTargetEnd - this.viewportWidth - this.offsetCorrectionX, this.boundaries.left, true);
36391
+ this.offsetX =
36392
+ this.getters.getColDimensions(sheetId, startIndex).end - this.offsetCorrectionX;
36393
+ this.offsetScrollbarX = this.offsetX;
36394
+ this.adjustViewportZoneX();
36330
36395
  }
36331
36396
  else if (this.left > targetCol) {
36332
- for (let col = this.left; col >= targetCol; col--) {
36333
- if (col < 0) {
36334
- break;
36335
- }
36336
- if (this.getters.isColHidden(sheetId, col)) {
36337
- continue;
36338
- }
36339
- this.offsetX = this.getters.getColDimensions(sheetId, col).start - this.offsetCorrectionX;
36340
- this.offsetScrollbarX = this.offsetX;
36341
- this.adjustViewportZoneX();
36397
+ let finalTarget = targetCol;
36398
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol > 0) {
36399
+ finalTarget--;
36342
36400
  }
36401
+ this.offsetX =
36402
+ this.getters.getColDimensions(sheetId, finalTarget).start - this.offsetCorrectionX;
36403
+ this.offsetScrollbarX = this.offsetX;
36404
+ this.adjustViewportZoneX();
36343
36405
  }
36344
36406
  }
36345
36407
  adjustPositionY(targetRow) {
@@ -36347,30 +36409,26 @@ class InternalViewport {
36347
36409
  const { end } = this.getters.getRowDimensions(sheetId, targetRow);
36348
36410
  const maxRow = this.getters.getNumberRows(sheetId);
36349
36411
  if (this.offsetY + this.viewportHeight + this.offsetCorrectionY < end) {
36350
- for (let row = this.top; this.offsetY + this.viewportHeight + this.offsetCorrectionY < end; row++) {
36351
- if (row > maxRow) {
36352
- break;
36353
- }
36354
- if (this.getters.isRowHidden(sheetId, row)) {
36355
- continue;
36356
- }
36357
- this.offsetY = this.getters.getRowDimensions(sheetId, row).end - this.offsetCorrectionY;
36358
- this.offsetScrollbarY = this.offsetY;
36359
- this.adjustViewportZoneY();
36412
+ let finalTarget = targetRow;
36413
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow < maxRow) {
36414
+ finalTarget++;
36360
36415
  }
36416
+ const finalTargetEnd = this.getters.getRowDimensions(sheetId, finalTarget).end;
36417
+ const startIndex = this.searchHeaderIndex("ROW", finalTargetEnd - this.viewportHeight - this.offsetCorrectionY, this.boundaries.top, true);
36418
+ this.offsetY =
36419
+ this.getters.getRowDimensions(sheetId, startIndex).end - this.offsetCorrectionY;
36420
+ this.offsetScrollbarY = this.offsetY;
36421
+ this.adjustViewportZoneY();
36361
36422
  }
36362
36423
  else if (this.top > targetRow) {
36363
- for (let row = this.top; row >= targetRow; row--) {
36364
- if (row < 0) {
36365
- break;
36366
- }
36367
- if (this.getters.isRowHidden(sheetId, row)) {
36368
- continue;
36369
- }
36370
- this.offsetY = this.getters.getRowDimensions(sheetId, row).start - this.offsetCorrectionY;
36371
- this.offsetScrollbarY = this.offsetY;
36372
- this.adjustViewportZoneY();
36424
+ let finalTarget = targetRow;
36425
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow > 0) {
36426
+ finalTarget--;
36373
36427
  }
36428
+ this.offsetY =
36429
+ this.getters.getRowDimensions(sheetId, finalTarget).start - this.offsetCorrectionY;
36430
+ this.offsetScrollbarY = this.offsetY;
36431
+ this.adjustViewportZoneY();
36374
36432
  }
36375
36433
  }
36376
36434
  setViewportOffset(offsetX, offsetY) {
@@ -40725,6 +40783,9 @@ class SelectionStreamProcessor {
40725
40783
  anchor: { zone, cell: this.anchor.cell },
40726
40784
  });
40727
40785
  }
40786
+ isListening(owner) {
40787
+ return this.stream.isListening(owner);
40788
+ }
40728
40789
  /**
40729
40790
  * Process a new anchor selection event. If the new anchor is inside
40730
40791
  * the sheet boundaries, the event is pushed to the event stream to
@@ -42922,6 +42983,6 @@ exports.setTranslationMethod = setTranslationMethod;
42922
42983
  exports.tokenize = tokenize;
42923
42984
 
42924
42985
 
42925
- __info__.version = '16.0.19';
42926
- __info__.date = '2023-09-21T15:56:31.776Z';
42927
- __info__.hash = '229c563';
42986
+ __info__.version = '16.0.21';
42987
+ __info__.date = '2023-10-10T07:26:26.680Z';
42988
+ __info__.hash = '5f66b12';
@@ -278,7 +278,7 @@ declare class RangeImpl implements Range {
278
278
  constructor(args: ConstructorArgs, getSheetSize: (sheetId: UID) => ZoneDimension);
279
279
  static fromRange(range: Range, getters: CoreGetters): RangeImpl;
280
280
  get unboundedZone(): UnboundedZone;
281
- get zone(): Zone;
281
+ get zone(): Readonly<Zone>;
282
282
  static getRangeParts(xc: string, zone: UnboundedZone): RangePart[];
283
283
  get isFullCol(): boolean;
284
284
  get isFullRow(): boolean;
@@ -373,6 +373,7 @@ interface SelectionProcessor {
373
373
  selectRow(index: number, mode: "overrideSelection" | "updateAnchor" | "newAnchor"): DispatchResult;
374
374
  selectAll(): DispatchResult;
375
375
  loopSelection(): DispatchResult;
376
+ isListening(owner: unknown): boolean;
376
377
  }
377
378
  /**
378
379
  * Processes all selection updates (usually from user inputs) and emits an event
@@ -439,6 +440,7 @@ declare class SelectionStreamProcessor implements SelectionProcessor, StatefulSt
439
440
  * Select the entire sheet
440
441
  */
441
442
  selectAll(): DispatchResult;
443
+ isListening(owner: unknown): boolean;
442
444
  /**
443
445
  * Process a new anchor selection event. If the new anchor is inside
444
446
  * the sheet boundaries, the event is pushed to the event stream to
@@ -4047,7 +4049,7 @@ declare class RendererPlugin extends UIPlugin {
4047
4049
  */
4048
4050
  declare class GridSelectionPlugin extends UIPlugin {
4049
4051
  static layers: LAYERS[];
4050
- static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getPosition", "getSheetPosition", "isSelected", "getElementsFromSelection"];
4052
+ static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getPosition", "getSheetPosition", "isSelected", "getElementsFromSelection", "isGridSelectionActive"];
4051
4053
  private gridSelection;
4052
4054
  private selectedFigureId;
4053
4055
  private sheetsData;
@@ -4057,6 +4059,7 @@ declare class GridSelectionPlugin extends UIPlugin {
4057
4059
  allowDispatch(cmd: Command): CommandResult;
4058
4060
  private handleEvent;
4059
4061
  handle(cmd: Command): void;
4062
+ isGridSelectionActive(): boolean;
4060
4063
  getActiveSheet(): Readonly<Sheet>;
4061
4064
  getActiveSheetId(): UID;
4062
4065
  getActiveCell(): Cell | undefined;
@@ -315,7 +315,16 @@ const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
315
315
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
316
316
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
317
317
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
318
+ const CACHE = {};
318
319
  function parseDateTime(str) {
320
+ if (CACHE[str]) {
321
+ return CACHE[str];
322
+ }
323
+ const date = _parseDateTime(str);
324
+ CACHE[str] = date;
325
+ return date;
326
+ }
327
+ function _parseDateTime(str) {
319
328
  str = str.trim();
320
329
  let time;
321
330
  const timeMatch = str.match(timeRegexp);
@@ -2041,8 +2050,9 @@ class RangeImpl {
2041
2050
  }
2042
2051
  get zone() {
2043
2052
  const { left, top, bottom, right } = this._zone;
2044
- if (right !== undefined && bottom !== undefined)
2045
- return { left, top, right, bottom };
2053
+ if (right !== undefined && bottom !== undefined) {
2054
+ return this._zone;
2055
+ }
2046
2056
  else if (bottom === undefined && right !== undefined) {
2047
2057
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).height - 1 };
2048
2058
  }
@@ -3293,6 +3303,9 @@ var CommandResult;
3293
3303
  CommandResult[CommandResult["InvalidQuantity"] = 86] = "InvalidQuantity";
3294
3304
  })(CommandResult || (CommandResult = {}));
3295
3305
 
3306
+ function isMatrix(x) {
3307
+ return Array.isArray(x) && Array.isArray(x[0]);
3308
+ }
3296
3309
  var DIRECTION;
3297
3310
  (function (DIRECTION) {
3298
3311
  DIRECTION["UP"] = "up";
@@ -3689,6 +3702,9 @@ class FilterMenu extends Component {
3689
3702
  });
3690
3703
  this.state.values = this.getFilterValues(this.props.filterPosition);
3691
3704
  }
3705
+ get isReadonly() {
3706
+ return this.env.model.getters.isReadonly();
3707
+ }
3692
3708
  getFilterValues(position) {
3693
3709
  const sheetId = this.env.model.getters.getActiveSheetId();
3694
3710
  const filter = this.env.model.getters.getFilter(sheetId, position.col, position.row);
@@ -10007,9 +10023,9 @@ class FindAndReplacePanel extends Component {
10007
10023
  }
10008
10024
  setup() {
10009
10025
  this.showFormulaState = this.env.model.getters.shouldShowFormulas();
10010
- this.debouncedUpdateSearch = debounce(this.updateSearch.bind(this), 200);
10011
10026
  onMounted(() => this.focusInput());
10012
10027
  onWillUnmount(() => {
10028
+ clearTimeout(this.debounceTimeoutId);
10013
10029
  this.env.model.dispatch("CLEAR_SEARCH");
10014
10030
  this.env.model.dispatch("SET_FORMULA_VISIBILITY", { show: this.showFormulaState });
10015
10031
  });
@@ -10052,6 +10068,13 @@ class FindAndReplacePanel extends Component {
10052
10068
  searchOptions: this.state.searchOptions,
10053
10069
  });
10054
10070
  }
10071
+ debouncedUpdateSearch() {
10072
+ clearTimeout(this.debounceTimeoutId);
10073
+ this.debounceTimeoutId = setTimeout(() => {
10074
+ this.updateSearch();
10075
+ this.debounceTimeoutId = undefined;
10076
+ }, 200);
10077
+ }
10055
10078
  replace() {
10056
10079
  this.env.model.dispatch("REPLACE_SEARCH", {
10057
10080
  replaceWith: this.state.replaceWith,
@@ -17055,6 +17078,36 @@ const HLOOKUP = {
17055
17078
  isExported: true,
17056
17079
  };
17057
17080
  // -----------------------------------------------------------------------------
17081
+ // INDEX
17082
+ // -----------------------------------------------------------------------------
17083
+ const INDEX = {
17084
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
17085
+ args: args(`
17086
+ reference (any, range) ${_lt("The range of cells from which the value is returned.")}
17087
+ row (number) ${_lt("The index of the row to be returned from within the reference range of cells.")}
17088
+ column (number) ${_lt("The index of the column to be returned from within the reference range of cells.")}
17089
+ `),
17090
+ returns: ["ANY"],
17091
+ computeFormat: (reference, row, column) => {
17092
+ var _a;
17093
+ const _row = toNumber(row.value);
17094
+ const _column = toNumber(column.value);
17095
+ return (_a = reference[_column - 1][_row - 1]) === null || _a === void 0 ? void 0 : _a.format;
17096
+ },
17097
+ compute: function (reference, row, column) {
17098
+ const _reference = isMatrix(reference) ? reference : [[reference]];
17099
+ const _row = toNumber(row);
17100
+ const _column = toNumber(column);
17101
+ assert(() => _column >= 0 &&
17102
+ _column - 1 < _reference.length &&
17103
+ _row >= 0 &&
17104
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
17105
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
17106
+ return _reference[_column - 1][_row - 1];
17107
+ },
17108
+ isExported: true,
17109
+ };
17110
+ // -----------------------------------------------------------------------------
17058
17111
  // LOOKUP
17059
17112
  // -----------------------------------------------------------------------------
17060
17113
  const LOOKUP = {
@@ -17243,6 +17296,7 @@ var lookup = /*#__PURE__*/Object.freeze({
17243
17296
  COLUMN: COLUMN,
17244
17297
  COLUMNS: COLUMNS,
17245
17298
  HLOOKUP: HLOOKUP,
17299
+ INDEX: INDEX,
17246
17300
  LOOKUP: LOOKUP,
17247
17301
  MATCH: MATCH,
17248
17302
  ROW: ROW,
@@ -21563,7 +21617,14 @@ class AbstractResizer extends Component {
21563
21617
  return;
21564
21618
  }
21565
21619
  if (this.state.waitingForMove === true) {
21566
- this.startMovement(ev);
21620
+ if (!this.env.model.getters.isGridSelectionActive()) {
21621
+ this._selectElement(index, false);
21622
+ }
21623
+ else {
21624
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
21625
+ // a way to have the grid selection follow the other selections evolution
21626
+ this.startMovement(ev);
21627
+ }
21567
21628
  return;
21568
21629
  }
21569
21630
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -27718,10 +27779,11 @@ class CellPlugin extends CorePlugin {
27718
27779
  * Reconstructs the original formula string based on a normalized form and its dependencies
27719
27780
  */
27720
27781
  buildFormulaContent(sheetId, cell, dependencies) {
27721
- const ranges = dependencies || [...cell.dependencies];
27782
+ const ranges = dependencies || cell.dependencies;
27783
+ let rangeIndex = 0;
27722
27784
  return concat(cell.compiledFormula.tokens.map((token) => {
27723
27785
  if (token.type === "REFERENCE") {
27724
- const range = ranges.shift();
27786
+ const range = ranges[rangeIndex++];
27725
27787
  return this.getters.getRangeString(range, sheetId);
27726
27788
  }
27727
27789
  return token.value;
@@ -31653,7 +31715,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
31653
31715
  });
31654
31716
  for (const filterTable of this.copiedTables) {
31655
31717
  this.dispatch("REMOVE_FILTER_TABLE", {
31656
- sheetId: this.getters.getActiveSheetId(),
31718
+ sheetId: this.sheetId,
31657
31719
  target: [filterTable.zone],
31658
31720
  });
31659
31721
  }
@@ -34626,6 +34688,9 @@ class GridSelectionPlugin extends UIPlugin {
34626
34688
  // ---------------------------------------------------------------------------
34627
34689
  // Getters
34628
34690
  // ---------------------------------------------------------------------------
34691
+ isGridSelectionActive() {
34692
+ return this.selection.isListening(this);
34693
+ }
34629
34694
  getActiveSheet() {
34630
34695
  return this.activeSheet;
34631
34696
  }
@@ -35002,6 +35067,7 @@ GridSelectionPlugin.getters = [
35002
35067
  "getSheetPosition",
35003
35068
  "isSelected",
35004
35069
  "getElementsFromSelection",
35070
+ "isGridSelectionActive",
35005
35071
  ];
35006
35072
 
35007
35073
  const uuidGenerator = new UuidGenerator();
@@ -36312,30 +36378,26 @@ class InternalViewport {
36312
36378
  const { end } = this.getters.getColDimensions(sheetId, targetCol);
36313
36379
  const maxCol = this.getters.getNumberCols(sheetId);
36314
36380
  if (this.offsetX + this.offsetCorrectionX + this.viewportWidth < end) {
36315
- for (let col = this.left; this.offsetX + this.offsetCorrectionX + this.viewportWidth < end; col++) {
36316
- if (col > maxCol) {
36317
- break;
36318
- }
36319
- if (this.getters.isColHidden(sheetId, col)) {
36320
- continue;
36321
- }
36322
- this.offsetX = this.getters.getColDimensions(sheetId, col).end - this.offsetCorrectionX;
36323
- this.offsetScrollbarX = this.offsetX;
36324
- this.adjustViewportZoneX();
36381
+ let finalTarget = targetCol;
36382
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol < maxCol) {
36383
+ finalTarget++;
36325
36384
  }
36385
+ const finalTargetEnd = this.getters.getColDimensions(sheetId, finalTarget).end;
36386
+ const startIndex = this.searchHeaderIndex("COL", finalTargetEnd - this.viewportWidth - this.offsetCorrectionX, this.boundaries.left, true);
36387
+ this.offsetX =
36388
+ this.getters.getColDimensions(sheetId, startIndex).end - this.offsetCorrectionX;
36389
+ this.offsetScrollbarX = this.offsetX;
36390
+ this.adjustViewportZoneX();
36326
36391
  }
36327
36392
  else if (this.left > targetCol) {
36328
- for (let col = this.left; col >= targetCol; col--) {
36329
- if (col < 0) {
36330
- break;
36331
- }
36332
- if (this.getters.isColHidden(sheetId, col)) {
36333
- continue;
36334
- }
36335
- this.offsetX = this.getters.getColDimensions(sheetId, col).start - this.offsetCorrectionX;
36336
- this.offsetScrollbarX = this.offsetX;
36337
- this.adjustViewportZoneX();
36393
+ let finalTarget = targetCol;
36394
+ while (this.getters.isColHidden(sheetId, finalTarget) && targetCol > 0) {
36395
+ finalTarget--;
36338
36396
  }
36397
+ this.offsetX =
36398
+ this.getters.getColDimensions(sheetId, finalTarget).start - this.offsetCorrectionX;
36399
+ this.offsetScrollbarX = this.offsetX;
36400
+ this.adjustViewportZoneX();
36339
36401
  }
36340
36402
  }
36341
36403
  adjustPositionY(targetRow) {
@@ -36343,30 +36405,26 @@ class InternalViewport {
36343
36405
  const { end } = this.getters.getRowDimensions(sheetId, targetRow);
36344
36406
  const maxRow = this.getters.getNumberRows(sheetId);
36345
36407
  if (this.offsetY + this.viewportHeight + this.offsetCorrectionY < end) {
36346
- for (let row = this.top; this.offsetY + this.viewportHeight + this.offsetCorrectionY < end; row++) {
36347
- if (row > maxRow) {
36348
- break;
36349
- }
36350
- if (this.getters.isRowHidden(sheetId, row)) {
36351
- continue;
36352
- }
36353
- this.offsetY = this.getters.getRowDimensions(sheetId, row).end - this.offsetCorrectionY;
36354
- this.offsetScrollbarY = this.offsetY;
36355
- this.adjustViewportZoneY();
36408
+ let finalTarget = targetRow;
36409
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow < maxRow) {
36410
+ finalTarget++;
36356
36411
  }
36412
+ const finalTargetEnd = this.getters.getRowDimensions(sheetId, finalTarget).end;
36413
+ const startIndex = this.searchHeaderIndex("ROW", finalTargetEnd - this.viewportHeight - this.offsetCorrectionY, this.boundaries.top, true);
36414
+ this.offsetY =
36415
+ this.getters.getRowDimensions(sheetId, startIndex).end - this.offsetCorrectionY;
36416
+ this.offsetScrollbarY = this.offsetY;
36417
+ this.adjustViewportZoneY();
36357
36418
  }
36358
36419
  else if (this.top > targetRow) {
36359
- for (let row = this.top; row >= targetRow; row--) {
36360
- if (row < 0) {
36361
- break;
36362
- }
36363
- if (this.getters.isRowHidden(sheetId, row)) {
36364
- continue;
36365
- }
36366
- this.offsetY = this.getters.getRowDimensions(sheetId, row).start - this.offsetCorrectionY;
36367
- this.offsetScrollbarY = this.offsetY;
36368
- this.adjustViewportZoneY();
36420
+ let finalTarget = targetRow;
36421
+ while (this.getters.isRowHidden(sheetId, finalTarget) && targetRow > 0) {
36422
+ finalTarget--;
36369
36423
  }
36424
+ this.offsetY =
36425
+ this.getters.getRowDimensions(sheetId, finalTarget).start - this.offsetCorrectionY;
36426
+ this.offsetScrollbarY = this.offsetY;
36427
+ this.adjustViewportZoneY();
36370
36428
  }
36371
36429
  }
36372
36430
  setViewportOffset(offsetX, offsetY) {
@@ -40721,6 +40779,9 @@ class SelectionStreamProcessor {
40721
40779
  anchor: { zone, cell: this.anchor.cell },
40722
40780
  });
40723
40781
  }
40782
+ isListening(owner) {
40783
+ return this.stream.isListening(owner);
40784
+ }
40724
40785
  /**
40725
40786
  * Process a new anchor selection event. If the new anchor is inside
40726
40787
  * the sheet boundaries, the event is pushed to the event stream to
@@ -42890,6 +42951,6 @@ function addFunction(functionName, functionDescription) {
42890
42951
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
42891
42952
 
42892
42953
 
42893
- __info__.version = '16.0.19';
42894
- __info__.date = '2023-09-21T15:56:31.776Z';
42895
- __info__.hash = '229c563';
42954
+ __info__.version = '16.0.21';
42955
+ __info__.date = '2023-10-10T07:26:26.680Z';
42956
+ __info__.hash = '5f66b12';