@odoo/o-spreadsheet 16.0.47 → 16.0.49

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.
@@ -3346,7 +3346,7 @@ class DispatchResult {
3346
3346
  * Static helper which returns a successful DispatchResult
3347
3347
  */
3348
3348
  static get Success() {
3349
- return new DispatchResult();
3349
+ return SUCCESS;
3350
3350
  }
3351
3351
  get isSuccessful() {
3352
3352
  return this.reasons.length === 0;
@@ -3359,6 +3359,7 @@ class DispatchResult {
3359
3359
  return this.reasons.includes(reason);
3360
3360
  }
3361
3361
  }
3362
+ const SUCCESS = new DispatchResult();
3362
3363
  exports.CommandResult = void 0;
3363
3364
  (function (CommandResult) {
3364
3365
  CommandResult[CommandResult["Success"] = 0] = "Success";
@@ -4086,8 +4087,8 @@ function isCtrlKey(ev) {
4086
4087
  * Return the o-spreadsheet element position relative
4087
4088
  * to the browser viewport.
4088
4089
  */
4089
- function useSpreadsheetPosition() {
4090
- const position = owl.useState({ x: 0, y: 0 });
4090
+ function useSpreadsheetRect() {
4091
+ const position = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
4091
4092
  let spreadsheetElement = document.querySelector(".o-spreadsheet");
4092
4093
  updatePosition();
4093
4094
  function updatePosition() {
@@ -4095,9 +4096,11 @@ function useSpreadsheetPosition() {
4095
4096
  spreadsheetElement = document.querySelector(".o-spreadsheet");
4096
4097
  }
4097
4098
  if (spreadsheetElement) {
4098
- const { top, left } = spreadsheetElement.getBoundingClientRect();
4099
+ const { top, left, width, height } = spreadsheetElement.getBoundingClientRect();
4099
4100
  position.x = left;
4100
4101
  position.y = top;
4102
+ position.width = width;
4103
+ position.height = height;
4101
4104
  }
4102
4105
  }
4103
4106
  owl.onMounted(updatePosition);
@@ -4132,7 +4135,7 @@ function useAbsolutePosition(ref) {
4132
4135
  class Popover extends owl.Component {
4133
4136
  constructor() {
4134
4137
  super(...arguments);
4135
- this.spreadsheetPosition = useSpreadsheetPosition();
4138
+ this.spreadsheetRect = useSpreadsheetRect();
4136
4139
  }
4137
4140
  get maxHeight() {
4138
4141
  return Math.max(0, this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH);
@@ -4141,8 +4144,8 @@ class Popover extends owl.Component {
4141
4144
  // the props's position is expressed relative to the "body" element
4142
4145
  // but we teleport the element in ".o-spreadsheet" to keep everything
4143
4146
  // within our control and to avoid leaking into external DOM
4144
- const horizontalPosition = `left:${this.horizontalPosition() - this.spreadsheetPosition.x}`;
4145
- const verticalPosition = `top:${this.verticalPosition() - this.spreadsheetPosition.y}`;
4147
+ const horizontalPosition = `left:${this.horizontalPosition() - this.spreadsheetRect.x}`;
4148
+ const verticalPosition = `top:${this.verticalPosition() - this.spreadsheetRect.y}`;
4146
4149
  const maxHeight = this.maxHeight;
4147
4150
  const height = `max-height:${maxHeight}`;
4148
4151
  const shadow = maxHeight !== 0 ? "box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);" : "";
@@ -11375,7 +11378,7 @@ function getPredicate(descr, isQuery) {
11375
11378
  operand = descr;
11376
11379
  }
11377
11380
  }
11378
- if (isNumber(operand)) {
11381
+ if (isNumber(operand) || isDateTime(operand)) {
11379
11382
  operand = toNumber(operand);
11380
11383
  }
11381
11384
  else if (operand === "TRUE" || operand === "FALSE") {
@@ -11423,7 +11426,10 @@ function evaluatePredicate(value = "", criterion) {
11423
11426
  return false;
11424
11427
  }
11425
11428
  if (typeof operand === "number" && operator === "=") {
11426
- return toString(value) === toString(operand);
11429
+ if (typeof value === "string" && (isNumber(value) || isDateTime(value))) {
11430
+ return toNumber(value) === operand;
11431
+ }
11432
+ return value === operand;
11427
11433
  }
11428
11434
  if (operator === "<>" || operator === "=") {
11429
11435
  let result;
@@ -20432,6 +20438,7 @@ class Composer extends owl.Component {
20432
20438
  constructor() {
20433
20439
  super(...arguments);
20434
20440
  this.composerRef = owl.useRef("o_composer");
20441
+ this.spreadsheetRect = useSpreadsheetRect();
20435
20442
  this.contentHelper = new ContentEditableHelper(this.composerRef.el);
20436
20443
  this.composerState = owl.useState({
20437
20444
  positionStart: 0,
@@ -20467,24 +20474,28 @@ class Composer extends owl.Component {
20467
20474
  };
20468
20475
  }
20469
20476
  get assistantStyle() {
20477
+ const composerRect = this.composerRef.el.getBoundingClientRect();
20478
+ const assistantStyle = {
20479
+ width: `${ASSISTANT_WIDTH}px`,
20480
+ };
20470
20481
  if (this.props.delimitation && this.props.rect) {
20471
20482
  const { x: cellX, y: cellY, height: cellHeight } = this.props.rect;
20472
20483
  const remainingHeight = this.props.delimitation.height - (cellY + cellHeight);
20473
- let assistantStyle = "";
20474
20484
  if (cellY > remainingHeight) {
20475
20485
  // render top
20476
- assistantStyle += `
20477
- top: -8px;
20478
- transform: translate(0, -100%);
20479
- `;
20486
+ assistantStyle.top = "-8px";
20487
+ assistantStyle.transform = "translate(0, -100%)";
20480
20488
  }
20481
20489
  if (cellX + ASSISTANT_WIDTH > this.props.delimitation.width) {
20482
20490
  // render left
20483
- assistantStyle += `right:0px;`;
20491
+ assistantStyle.right = "0px";
20484
20492
  }
20485
- return (assistantStyle += `width:${ASSISTANT_WIDTH}px;`);
20493
+ return cssPropertiesToCss(assistantStyle);
20494
+ }
20495
+ if (composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
20496
+ assistantStyle.right = "0px";
20486
20497
  }
20487
- return `width:${ASSISTANT_WIDTH}px;`;
20498
+ return cssPropertiesToCss(assistantStyle);
20488
20499
  }
20489
20500
  setup() {
20490
20501
  owl.onMounted(() => {
@@ -21622,10 +21633,13 @@ function useCellHovered(env, gridRef, callback) {
21622
21633
  row: undefined,
21623
21634
  };
21624
21635
  const { Date } = window;
21625
- let x = 0;
21626
- let y = 0;
21636
+ let x = undefined;
21637
+ let y = undefined;
21627
21638
  let lastMoved = 0;
21628
21639
  function getPosition() {
21640
+ if (x === undefined || y === undefined) {
21641
+ return { col: -1, row: -1 };
21642
+ }
21629
21643
  const col = env.model.getters.getColIndex(x);
21630
21644
  const row = env.model.getters.getRowIndex(y);
21631
21645
  return { col, row };
@@ -27465,12 +27479,13 @@ class BordersPlugin extends CorePlugin {
27465
27479
  this.clearBorders(cmd.sheetId, cmd.target);
27466
27480
  break;
27467
27481
  case "REMOVE_COLUMNS_ROWS":
27468
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
27482
+ const elements = [...cmd.elements].sort((a, b) => b - a);
27483
+ for (const group of groupConsecutive(elements)) {
27469
27484
  if (cmd.dimension === "COL") {
27470
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
27485
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
27471
27486
  }
27472
27487
  else {
27473
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
27488
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
27474
27489
  }
27475
27490
  }
27476
27491
  break;
@@ -30967,12 +30982,7 @@ class SheetPlugin extends CorePlugin {
30967
30982
  });
30968
30983
  }
30969
30984
  if (colIndex > deletedColumn) {
30970
- this.dispatch("UPDATE_CELL_POSITION", {
30971
- sheetId: sheet.id,
30972
- cellId: cellId,
30973
- col: colIndex - 1,
30974
- row: rowIndex,
30975
- });
30985
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
30976
30986
  }
30977
30987
  }
30978
30988
  }
@@ -30982,7 +30992,7 @@ class SheetPlugin extends CorePlugin {
30982
30992
  * Move the cells after a column or rows insertion
30983
30993
  */
30984
30994
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
30985
- const commands = [];
30995
+ const updates = [];
30986
30996
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
30987
30997
  const row = sheet.rows[rowIndex];
30988
30998
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -30991,20 +31001,20 @@ class SheetPlugin extends CorePlugin {
30991
31001
  const cellId = row.cells[i];
30992
31002
  if (cellId) {
30993
31003
  if (dimension === "rows" || colIndex >= addedElement) {
30994
- commands.push({
30995
- type: "UPDATE_CELL_POSITION",
31004
+ updates.push({
30996
31005
  sheetId: sheet.id,
30997
31006
  cellId: cellId,
30998
31007
  col: colIndex + (dimension === "columns" ? quantity : 0),
30999
31008
  row: rowIndex + (dimension === "rows" ? quantity : 0),
31009
+ type: "UPDATE_CELL_POSITION",
31000
31010
  });
31001
31011
  }
31002
31012
  }
31003
31013
  }
31004
31014
  }
31005
31015
  }
31006
- for (let cmd of commands.reverse()) {
31007
- this.dispatch(cmd.type, cmd);
31016
+ for (let update of updates.reverse()) {
31017
+ this.updateCellPosition(update);
31008
31018
  }
31009
31019
  }
31010
31020
  /**
@@ -31037,12 +31047,7 @@ class SheetPlugin extends CorePlugin {
31037
31047
  const colIndex = Number(i);
31038
31048
  const cellId = row.cells[i];
31039
31049
  if (cellId) {
31040
- this.dispatch("UPDATE_CELL_POSITION", {
31041
- sheetId: sheet.id,
31042
- cellId: cellId,
31043
- col: colIndex,
31044
- row: rowIndex - numberRows,
31045
- });
31050
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
31046
31051
  }
31047
31052
  }
31048
31053
  }
@@ -43436,6 +43441,6 @@ exports.setTranslationMethod = setTranslationMethod;
43436
43441
  exports.tokenize = tokenize;
43437
43442
 
43438
43443
 
43439
- __info__.version = '16.0.47';
43440
- __info__.date = '2024-07-08T05:37:37.541Z';
43441
- __info__.hash = 'f52ca6f';
43444
+ __info__.version = '16.0.49';
43445
+ __info__.date = '2024-08-02T08:18:43.387Z';
43446
+ __info__.hash = '97d415b';
@@ -5287,7 +5287,7 @@ declare class Popover extends Component<Props$o, SpreadsheetChildEnv> {
5287
5287
  onMouseWheel: () => void;
5288
5288
  zIndex: ComponentsImportance;
5289
5289
  };
5290
- private spreadsheetPosition;
5290
+ private spreadsheetRect;
5291
5291
  get maxHeight(): number;
5292
5292
  get style(): string;
5293
5293
  private get viewportDimension();
@@ -5574,6 +5574,7 @@ declare class Composer extends Component<ComposerProps, SpreadsheetChildEnv> {
5574
5574
  el: HTMLElement | null;
5575
5575
  };
5576
5576
  private autocompleteAPI?;
5577
+ private spreadsheetRect;
5577
5578
  contentHelper: ContentEditableHelper;
5578
5579
  composerState: ComposerState$1;
5579
5580
  autoCompleteState: AutoCompleteState;
@@ -3342,7 +3342,7 @@ class DispatchResult {
3342
3342
  * Static helper which returns a successful DispatchResult
3343
3343
  */
3344
3344
  static get Success() {
3345
- return new DispatchResult();
3345
+ return SUCCESS;
3346
3346
  }
3347
3347
  get isSuccessful() {
3348
3348
  return this.reasons.length === 0;
@@ -3355,6 +3355,7 @@ class DispatchResult {
3355
3355
  return this.reasons.includes(reason);
3356
3356
  }
3357
3357
  }
3358
+ const SUCCESS = new DispatchResult();
3358
3359
  var CommandResult;
3359
3360
  (function (CommandResult) {
3360
3361
  CommandResult[CommandResult["Success"] = 0] = "Success";
@@ -4082,8 +4083,8 @@ function isCtrlKey(ev) {
4082
4083
  * Return the o-spreadsheet element position relative
4083
4084
  * to the browser viewport.
4084
4085
  */
4085
- function useSpreadsheetPosition() {
4086
- const position = useState({ x: 0, y: 0 });
4086
+ function useSpreadsheetRect() {
4087
+ const position = useState({ x: 0, y: 0, width: 0, height: 0 });
4087
4088
  let spreadsheetElement = document.querySelector(".o-spreadsheet");
4088
4089
  updatePosition();
4089
4090
  function updatePosition() {
@@ -4091,9 +4092,11 @@ function useSpreadsheetPosition() {
4091
4092
  spreadsheetElement = document.querySelector(".o-spreadsheet");
4092
4093
  }
4093
4094
  if (spreadsheetElement) {
4094
- const { top, left } = spreadsheetElement.getBoundingClientRect();
4095
+ const { top, left, width, height } = spreadsheetElement.getBoundingClientRect();
4095
4096
  position.x = left;
4096
4097
  position.y = top;
4098
+ position.width = width;
4099
+ position.height = height;
4097
4100
  }
4098
4101
  }
4099
4102
  onMounted(updatePosition);
@@ -4128,7 +4131,7 @@ function useAbsolutePosition(ref) {
4128
4131
  class Popover extends Component {
4129
4132
  constructor() {
4130
4133
  super(...arguments);
4131
- this.spreadsheetPosition = useSpreadsheetPosition();
4134
+ this.spreadsheetRect = useSpreadsheetRect();
4132
4135
  }
4133
4136
  get maxHeight() {
4134
4137
  return Math.max(0, this.viewportDimension.height - BOTTOMBAR_HEIGHT - SCROLLBAR_WIDTH);
@@ -4137,8 +4140,8 @@ class Popover extends Component {
4137
4140
  // the props's position is expressed relative to the "body" element
4138
4141
  // but we teleport the element in ".o-spreadsheet" to keep everything
4139
4142
  // within our control and to avoid leaking into external DOM
4140
- const horizontalPosition = `left:${this.horizontalPosition() - this.spreadsheetPosition.x}`;
4141
- const verticalPosition = `top:${this.verticalPosition() - this.spreadsheetPosition.y}`;
4143
+ const horizontalPosition = `left:${this.horizontalPosition() - this.spreadsheetRect.x}`;
4144
+ const verticalPosition = `top:${this.verticalPosition() - this.spreadsheetRect.y}`;
4142
4145
  const maxHeight = this.maxHeight;
4143
4146
  const height = `max-height:${maxHeight}`;
4144
4147
  const shadow = maxHeight !== 0 ? "box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);" : "";
@@ -11371,7 +11374,7 @@ function getPredicate(descr, isQuery) {
11371
11374
  operand = descr;
11372
11375
  }
11373
11376
  }
11374
- if (isNumber(operand)) {
11377
+ if (isNumber(operand) || isDateTime(operand)) {
11375
11378
  operand = toNumber(operand);
11376
11379
  }
11377
11380
  else if (operand === "TRUE" || operand === "FALSE") {
@@ -11419,7 +11422,10 @@ function evaluatePredicate(value = "", criterion) {
11419
11422
  return false;
11420
11423
  }
11421
11424
  if (typeof operand === "number" && operator === "=") {
11422
- return toString(value) === toString(operand);
11425
+ if (typeof value === "string" && (isNumber(value) || isDateTime(value))) {
11426
+ return toNumber(value) === operand;
11427
+ }
11428
+ return value === operand;
11423
11429
  }
11424
11430
  if (operator === "<>" || operator === "=") {
11425
11431
  let result;
@@ -20428,6 +20434,7 @@ class Composer extends Component {
20428
20434
  constructor() {
20429
20435
  super(...arguments);
20430
20436
  this.composerRef = useRef("o_composer");
20437
+ this.spreadsheetRect = useSpreadsheetRect();
20431
20438
  this.contentHelper = new ContentEditableHelper(this.composerRef.el);
20432
20439
  this.composerState = useState({
20433
20440
  positionStart: 0,
@@ -20463,24 +20470,28 @@ class Composer extends Component {
20463
20470
  };
20464
20471
  }
20465
20472
  get assistantStyle() {
20473
+ const composerRect = this.composerRef.el.getBoundingClientRect();
20474
+ const assistantStyle = {
20475
+ width: `${ASSISTANT_WIDTH}px`,
20476
+ };
20466
20477
  if (this.props.delimitation && this.props.rect) {
20467
20478
  const { x: cellX, y: cellY, height: cellHeight } = this.props.rect;
20468
20479
  const remainingHeight = this.props.delimitation.height - (cellY + cellHeight);
20469
- let assistantStyle = "";
20470
20480
  if (cellY > remainingHeight) {
20471
20481
  // render top
20472
- assistantStyle += `
20473
- top: -8px;
20474
- transform: translate(0, -100%);
20475
- `;
20482
+ assistantStyle.top = "-8px";
20483
+ assistantStyle.transform = "translate(0, -100%)";
20476
20484
  }
20477
20485
  if (cellX + ASSISTANT_WIDTH > this.props.delimitation.width) {
20478
20486
  // render left
20479
- assistantStyle += `right:0px;`;
20487
+ assistantStyle.right = "0px";
20480
20488
  }
20481
- return (assistantStyle += `width:${ASSISTANT_WIDTH}px;`);
20489
+ return cssPropertiesToCss(assistantStyle);
20490
+ }
20491
+ if (composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
20492
+ assistantStyle.right = "0px";
20482
20493
  }
20483
- return `width:${ASSISTANT_WIDTH}px;`;
20494
+ return cssPropertiesToCss(assistantStyle);
20484
20495
  }
20485
20496
  setup() {
20486
20497
  onMounted(() => {
@@ -21618,10 +21629,13 @@ function useCellHovered(env, gridRef, callback) {
21618
21629
  row: undefined,
21619
21630
  };
21620
21631
  const { Date } = window;
21621
- let x = 0;
21622
- let y = 0;
21632
+ let x = undefined;
21633
+ let y = undefined;
21623
21634
  let lastMoved = 0;
21624
21635
  function getPosition() {
21636
+ if (x === undefined || y === undefined) {
21637
+ return { col: -1, row: -1 };
21638
+ }
21625
21639
  const col = env.model.getters.getColIndex(x);
21626
21640
  const row = env.model.getters.getRowIndex(y);
21627
21641
  return { col, row };
@@ -27461,12 +27475,13 @@ class BordersPlugin extends CorePlugin {
27461
27475
  this.clearBorders(cmd.sheetId, cmd.target);
27462
27476
  break;
27463
27477
  case "REMOVE_COLUMNS_ROWS":
27464
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
27478
+ const elements = [...cmd.elements].sort((a, b) => b - a);
27479
+ for (const group of groupConsecutive(elements)) {
27465
27480
  if (cmd.dimension === "COL") {
27466
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
27481
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
27467
27482
  }
27468
27483
  else {
27469
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
27484
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
27470
27485
  }
27471
27486
  }
27472
27487
  break;
@@ -30963,12 +30978,7 @@ class SheetPlugin extends CorePlugin {
30963
30978
  });
30964
30979
  }
30965
30980
  if (colIndex > deletedColumn) {
30966
- this.dispatch("UPDATE_CELL_POSITION", {
30967
- sheetId: sheet.id,
30968
- cellId: cellId,
30969
- col: colIndex - 1,
30970
- row: rowIndex,
30971
- });
30981
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
30972
30982
  }
30973
30983
  }
30974
30984
  }
@@ -30978,7 +30988,7 @@ class SheetPlugin extends CorePlugin {
30978
30988
  * Move the cells after a column or rows insertion
30979
30989
  */
30980
30990
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
30981
- const commands = [];
30991
+ const updates = [];
30982
30992
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
30983
30993
  const row = sheet.rows[rowIndex];
30984
30994
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -30987,20 +30997,20 @@ class SheetPlugin extends CorePlugin {
30987
30997
  const cellId = row.cells[i];
30988
30998
  if (cellId) {
30989
30999
  if (dimension === "rows" || colIndex >= addedElement) {
30990
- commands.push({
30991
- type: "UPDATE_CELL_POSITION",
31000
+ updates.push({
30992
31001
  sheetId: sheet.id,
30993
31002
  cellId: cellId,
30994
31003
  col: colIndex + (dimension === "columns" ? quantity : 0),
30995
31004
  row: rowIndex + (dimension === "rows" ? quantity : 0),
31005
+ type: "UPDATE_CELL_POSITION",
30996
31006
  });
30997
31007
  }
30998
31008
  }
30999
31009
  }
31000
31010
  }
31001
31011
  }
31002
- for (let cmd of commands.reverse()) {
31003
- this.dispatch(cmd.type, cmd);
31012
+ for (let update of updates.reverse()) {
31013
+ this.updateCellPosition(update);
31004
31014
  }
31005
31015
  }
31006
31016
  /**
@@ -31033,12 +31043,7 @@ class SheetPlugin extends CorePlugin {
31033
31043
  const colIndex = Number(i);
31034
31044
  const cellId = row.cells[i];
31035
31045
  if (cellId) {
31036
- this.dispatch("UPDATE_CELL_POSITION", {
31037
- sheetId: sheet.id,
31038
- cellId: cellId,
31039
- col: colIndex,
31040
- row: rowIndex - numberRows,
31041
- });
31046
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
31042
31047
  }
31043
31048
  }
31044
31049
  }
@@ -43404,6 +43409,6 @@ function addFunction(functionName, functionDescription) {
43404
43409
  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 };
43405
43410
 
43406
43411
 
43407
- __info__.version = '16.0.47';
43408
- __info__.date = '2024-07-08T05:37:37.541Z';
43409
- __info__.hash = 'f52ca6f';
43412
+ __info__.version = '16.0.49';
43413
+ __info__.date = '2024-08-02T08:18:43.387Z';
43414
+ __info__.hash = '97d415b';