@univerjs/sheets 1.0.0-alpha.8 → 1.0.0-beta.1

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.
Files changed (90) hide show
  1. package/lib/cjs/facade.js +57 -59
  2. package/lib/cjs/index.js +286 -312
  3. package/lib/cjs/locale/ar-SA.js +1 -2
  4. package/lib/cjs/locale/ca-ES.js +1 -2
  5. package/lib/cjs/locale/de-DE.js +1 -2
  6. package/lib/cjs/locale/en-US.js +1 -2
  7. package/lib/cjs/locale/es-ES.js +1 -2
  8. package/lib/cjs/locale/fa-IR.js +1 -2
  9. package/lib/cjs/locale/fr-FR.js +1 -2
  10. package/lib/cjs/locale/id-ID.js +1 -2
  11. package/lib/cjs/locale/it-IT.js +1 -2
  12. package/lib/cjs/locale/ja-JP.js +1 -2
  13. package/lib/cjs/locale/ko-KR.js +1 -2
  14. package/lib/cjs/locale/pl-PL.js +1 -2
  15. package/lib/cjs/locale/pt-BR.js +1 -2
  16. package/lib/cjs/locale/ru-RU.js +1 -2
  17. package/lib/cjs/locale/sk-SK.js +1 -2
  18. package/lib/cjs/locale/vi-VN.js +1 -2
  19. package/lib/cjs/locale/zh-CN.js +2 -3
  20. package/lib/cjs/locale/zh-HK.js +2 -3
  21. package/lib/cjs/locale/zh-TW.js +2 -3
  22. package/lib/es/facade.js +57 -59
  23. package/lib/es/index.js +287 -314
  24. package/lib/es/locale/ar-SA.js +1 -2
  25. package/lib/es/locale/ca-ES.js +1 -2
  26. package/lib/es/locale/de-DE.js +1 -2
  27. package/lib/es/locale/en-US.js +1 -2
  28. package/lib/es/locale/es-ES.js +1 -2
  29. package/lib/es/locale/fa-IR.js +1 -2
  30. package/lib/es/locale/fr-FR.js +1 -2
  31. package/lib/es/locale/id-ID.js +1 -2
  32. package/lib/es/locale/it-IT.js +1 -2
  33. package/lib/es/locale/ja-JP.js +1 -2
  34. package/lib/es/locale/ko-KR.js +1 -2
  35. package/lib/es/locale/pl-PL.js +1 -2
  36. package/lib/es/locale/pt-BR.js +1 -2
  37. package/lib/es/locale/ru-RU.js +1 -2
  38. package/lib/es/locale/sk-SK.js +1 -2
  39. package/lib/es/locale/vi-VN.js +1 -2
  40. package/lib/es/locale/zh-CN.js +2 -3
  41. package/lib/es/locale/zh-HK.js +2 -3
  42. package/lib/es/locale/zh-TW.js +2 -3
  43. package/lib/facade.js +57 -59
  44. package/lib/index.js +287 -314
  45. package/lib/locale/ar-SA.js +1 -2
  46. package/lib/locale/ca-ES.js +1 -2
  47. package/lib/locale/de-DE.js +1 -2
  48. package/lib/locale/en-US.js +1 -2
  49. package/lib/locale/es-ES.js +1 -2
  50. package/lib/locale/fa-IR.js +1 -2
  51. package/lib/locale/fr-FR.js +1 -2
  52. package/lib/locale/id-ID.js +1 -2
  53. package/lib/locale/it-IT.js +1 -2
  54. package/lib/locale/ja-JP.js +1 -2
  55. package/lib/locale/ko-KR.js +1 -2
  56. package/lib/locale/pl-PL.js +1 -2
  57. package/lib/locale/pt-BR.js +1 -2
  58. package/lib/locale/ru-RU.js +1 -2
  59. package/lib/locale/sk-SK.js +1 -2
  60. package/lib/locale/vi-VN.js +1 -2
  61. package/lib/locale/zh-CN.js +2 -3
  62. package/lib/locale/zh-HK.js +2 -3
  63. package/lib/locale/zh-TW.js +2 -3
  64. package/lib/types/basics/cell-type.d.ts +2 -1
  65. package/lib/types/facade/f-worksheet.d.ts +10 -9
  66. package/lib/types/index.d.ts +1 -1
  67. package/lib/types/locale/en-US.d.ts +0 -1
  68. package/lib/types/services/ref-range/ref-range.service.d.ts +2 -0
  69. package/lib/umd/facade.js +1 -1
  70. package/lib/umd/index.js +2 -2
  71. package/lib/umd/locale/ar-SA.js +1 -1
  72. package/lib/umd/locale/ca-ES.js +1 -1
  73. package/lib/umd/locale/de-DE.js +1 -1
  74. package/lib/umd/locale/en-US.js +1 -1
  75. package/lib/umd/locale/es-ES.js +1 -1
  76. package/lib/umd/locale/fa-IR.js +1 -1
  77. package/lib/umd/locale/fr-FR.js +1 -1
  78. package/lib/umd/locale/id-ID.js +1 -1
  79. package/lib/umd/locale/it-IT.js +1 -1
  80. package/lib/umd/locale/ja-JP.js +1 -1
  81. package/lib/umd/locale/ko-KR.js +1 -1
  82. package/lib/umd/locale/pl-PL.js +1 -1
  83. package/lib/umd/locale/pt-BR.js +1 -1
  84. package/lib/umd/locale/ru-RU.js +1 -1
  85. package/lib/umd/locale/sk-SK.js +1 -1
  86. package/lib/umd/locale/vi-VN.js +1 -1
  87. package/lib/umd/locale/zh-CN.js +1 -1
  88. package/lib/umd/locale/zh-HK.js +1 -1
  89. package/lib/umd/locale/zh-TW.js +1 -1
  90. package/package.json +8 -8
package/lib/cjs/facade.js CHANGED
@@ -191,9 +191,9 @@ let FDefinedNameBuilder = class FDefinedNameBuilder {
191
191
  setRefByRange(row, column, numRows, numColumns) {
192
192
  this._definedNameParam.formulaOrRefString = (0, _univerjs_engine_formula.serializeRange)({
193
193
  startRow: row,
194
- endRow: row + (numRows !== null && numRows !== void 0 ? numRows : 1) - 1,
194
+ endRow: row + (numRows ?? 1) - 1,
195
195
  startColumn: column,
196
- endColumn: column + (numColumns !== null && numColumns !== void 0 ? numColumns : 1) - 1
196
+ endColumn: column + (numColumns ?? 1) - 1
197
197
  });
198
198
  return this;
199
199
  }
@@ -433,9 +433,9 @@ let FDefinedName = class FDefinedName extends _univerjs_core_facade.FBase {
433
433
  setRefByRange(row, column, numRows, numColumns) {
434
434
  this._definedNameParam.formulaOrRefString = (0, _univerjs_engine_formula.serializeRange)({
435
435
  startRow: row,
436
- endRow: row + (numRows !== null && numRows !== void 0 ? numRows : 1) - 1,
436
+ endRow: row + (numRows ?? 1) - 1,
437
437
  startColumn: column,
438
- endColumn: column + (numColumns !== null && numColumns !== void 0 ? numColumns : 1) - 1
438
+ endColumn: column + (numColumns ?? 1) - 1
439
439
  });
440
440
  this._apply();
441
441
  }
@@ -1619,10 +1619,9 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
1619
1619
  if (!this.canEdit()) return false;
1620
1620
  const rules = this._rangeProtectionRuleModel.getSubunitRuleList(this._unitId, this._subUnitId);
1621
1621
  for (const rule of rules) for (const range of rule.ranges) if (row >= range.startRow && row <= range.endRow && col >= range.startColumn && col <= range.endColumn) {
1622
- var _permission$value;
1623
1622
  const permissionPoint = new _univerjs_sheets.RangeProtectionPermissionEditPoint(this._unitId, this._subUnitId, rule.permissionId);
1624
1623
  const permission = this._permissionService.getPermissionPoint(permissionPoint.id);
1625
- return (_permission$value = permission === null || permission === void 0 ? void 0 : permission.value) !== null && _permission$value !== void 0 ? _permission$value : false;
1624
+ return (permission === null || permission === void 0 ? void 0 : permission.value) ?? false;
1626
1625
  }
1627
1626
  return true;
1628
1627
  }
@@ -1661,10 +1660,9 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
1661
1660
  if (!this.canView()) return false;
1662
1661
  const rules = this._rangeProtectionRuleModel.getSubunitRuleList(this._unitId, this._subUnitId);
1663
1662
  for (const rule of rules) for (const range of rule.ranges) if (row >= range.startRow && row <= range.endRow && col >= range.startColumn && col <= range.endColumn) {
1664
- var _permission$value2;
1665
1663
  const permissionPoint = new _univerjs_sheets.RangeProtectionPermissionViewPoint(this._unitId, this._subUnitId, rule.permissionId);
1666
1664
  const permission = this._permissionService.getPermissionPoint(permissionPoint.id);
1667
- return (_permission$value2 = permission === null || permission === void 0 ? void 0 : permission.value) !== null && _permission$value2 !== void 0 ? _permission$value2 : false;
1665
+ return (permission === null || permission === void 0 ? void 0 : permission.value) ?? false;
1668
1666
  }
1669
1667
  return true;
1670
1668
  }
@@ -1683,12 +1681,11 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
1683
1681
  * ```
1684
1682
  */
1685
1683
  getPoint(point) {
1686
- var _permissionPoint$valu;
1687
1684
  const PointClass = WORKSHEET_PERMISSION_POINT_MAP[point];
1688
1685
  if (!PointClass) throw new Error(`Unknown worksheet permission point: ${point}`);
1689
1686
  const instance = new PointClass(this._unitId, this._subUnitId);
1690
1687
  const permissionPoint = this._permissionService.getPermissionPoint(instance.id);
1691
- return (_permissionPoint$valu = permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) !== null && _permissionPoint$valu !== void 0 ? _permissionPoint$valu : true;
1688
+ return (permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) ?? true;
1692
1689
  }
1693
1690
  /**
1694
1691
  * Get a snapshot of all permission points.
@@ -2020,6 +2017,11 @@ function covertToColRange(range, worksheet) {
2020
2017
  //#endregion
2021
2018
  //#region src/facade/f-worksheet.ts
2022
2019
  var _FWorksheet;
2020
+ function assertValidRowInsertion(methodName, rowIndex, rowCount, howMany) {
2021
+ if (!Number.isInteger(howMany) || howMany <= 0) throw new RangeError(`${methodName}(): row count ${howMany} must be a positive integer.`);
2022
+ const lastRowIndex = rowCount - 1;
2023
+ if (!Number.isInteger(rowIndex) || rowIndex < 0 || rowIndex > lastRowIndex) throw new RangeError(`${methodName}(): row index ${rowIndex} is out of bounds. The worksheet has ${rowCount} rows; expected an integer from 0 to ${lastRowIndex}. To insert ${howMany} row(s) at the bottom, use insertRowsAfter(${lastRowIndex}, ${howMany}). To resize the worksheet directly, use setRowCount(${rowCount + howMany}).`);
2024
+ }
2023
2025
  let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FBaseInitialable {
2024
2026
  /**
2025
2027
  * Creates a new worksheet facade instance
@@ -2300,9 +2302,9 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2300
2302
  sheet = this._worksheet;
2301
2303
  range = {
2302
2304
  startRow: rowOrA1Notation,
2303
- endRow: rowOrA1Notation + (numRows !== null && numRows !== void 0 ? numRows : 1) - 1,
2305
+ endRow: rowOrA1Notation + (numRows ?? 1) - 1,
2304
2306
  startColumn: column,
2305
- endColumn: column + (numColumns !== null && numColumns !== void 0 ? numColumns : 1) - 1,
2307
+ endColumn: column + (numColumns ?? 1) - 1,
2306
2308
  unitId: this._workbook.getUnitId(),
2307
2309
  sheetId: this._worksheet.getSheetId()
2308
2310
  };
@@ -2339,7 +2341,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2339
2341
  }
2340
2342
  /**
2341
2343
  * Inserts a row after the given row position.
2342
- * @param {number} afterPosition - The row after which the new row should be added, starting at 0 for the first row.
2344
+ * @param {number} afterPosition - The existing row after which the new row should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
2343
2345
  * @returns {FWorksheet} This sheet, for chaining.
2344
2346
  * @example
2345
2347
  * ```typescript
@@ -2356,7 +2358,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2356
2358
  }
2357
2359
  /**
2358
2360
  * Inserts a row before the given row position.
2359
- * @param {number} beforePosition - The row before which the new row should be added, starting at 0 for the first row.
2361
+ * @param {number} beforePosition - The existing row before which the new row should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
2360
2362
  * @returns {FWorksheet} This sheet, for chaining.
2361
2363
  * @example
2362
2364
  * ```typescript
@@ -2373,8 +2375,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2373
2375
  }
2374
2376
  /**
2375
2377
  * Inserts one or more consecutive blank rows in a sheet starting at the specified location.
2376
- * @param {number} rowIndex - The index indicating where to insert a row, starting at 0 for the first row.
2377
- * @param {number} numRows - The number of rows to insert.
2378
+ * @param {number} rowIndex - The existing row before which rows are inserted. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
2379
+ * @param {number} numRows - The positive number of rows to insert.
2378
2380
  * @returns {FWorksheet} This sheet, for chaining.
2379
2381
  * @example
2380
2382
  * ```typescript
@@ -2387,12 +2389,13 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2387
2389
  * ```
2388
2390
  */
2389
2391
  insertRows(rowIndex, numRows = 1) {
2392
+ assertValidRowInsertion("insertRows", rowIndex, this.getMaxRows(), numRows);
2390
2393
  return this.insertRowsBefore(rowIndex, numRows);
2391
2394
  }
2392
2395
  /**
2393
2396
  * Inserts a number of rows after the given row position.
2394
- * @param {number} afterPosition - The row after which the new rows should be added, starting at 0 for the first row.
2395
- * @param {number} howMany - The number of rows to insert.
2397
+ * @param {number} afterPosition - The existing row after which the new rows should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
2398
+ * @param {number} howMany - The positive number of rows to insert.
2396
2399
  * @returns {FWorksheet} This sheet, for chaining.
2397
2400
  * @example
2398
2401
  * ```typescript
@@ -2405,6 +2408,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2405
2408
  * ```
2406
2409
  */
2407
2410
  insertRowsAfter(afterPosition, howMany) {
2411
+ assertValidRowInsertion("insertRowsAfter", afterPosition, this.getMaxRows(), howMany);
2408
2412
  const unitId = this._workbook.getUnitId();
2409
2413
  const subUnitId = this._worksheet.getSheetId();
2410
2414
  const direction = _univerjs_core.Direction.DOWN;
@@ -2429,8 +2433,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2429
2433
  }
2430
2434
  /**
2431
2435
  * Inserts a number of rows before the given row position.
2432
- * @param {number} beforePosition - The row before which the new rows should be added, starting at 0 for the first row.
2433
- * @param {number} howMany - The number of rows to insert.
2436
+ * @param {number} beforePosition - The existing row before which the new rows should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
2437
+ * @param {number} howMany - The positive number of rows to insert.
2434
2438
  * @returns {FWorksheet} This sheet, for chaining.
2435
2439
  * @example
2436
2440
  * ```typescript
@@ -2443,6 +2447,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
2443
2447
  * ```
2444
2448
  */
2445
2449
  insertRowsBefore(beforePosition, howMany) {
2450
+ assertValidRowInsertion("insertRowsBefore", beforePosition, this.getMaxRows(), howMany);
2446
2451
  const unitId = this._workbook.getUnitId();
2447
2452
  const subUnitId = this._worksheet.getSheetId();
2448
2453
  const direction = _univerjs_core.Direction.UP;
@@ -4146,7 +4151,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
4146
4151
  return this._worksheet.getColumnManager().getCustomMetadata(index);
4147
4152
  }
4148
4153
  /**
4149
- * Appends a row to the bottom of the current data region in the sheet. If a cell's content begins with =, it's interpreted as a formula.
4154
+ * Appends a row to the bottom of the current data region in the sheet. If the destination row is already within the worksheet capacity,
4155
+ * this method writes into that row without increasing `getMaxRows()`. If a cell's content begins with =, it's interpreted as a formula.
4150
4156
  * @param {CellValue[]} rowContents - An array of values for the new row.
4151
4157
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining.
4152
4158
  * @example
@@ -4651,8 +4657,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4651
4657
  * ```
4652
4658
  */
4653
4659
  getFontFamily(type = "row") {
4654
- var _this$getCellStyleDat, _this$getCellStyleDat2;
4655
- return (_this$getCellStyleDat = (_this$getCellStyleDat2 = this.getCellStyleData(type)) === null || _this$getCellStyleDat2 === void 0 ? void 0 : _this$getCellStyleDat2.ff) !== null && _this$getCellStyleDat !== void 0 ? _this$getCellStyleDat : null;
4660
+ var _this$getCellStyleDat;
4661
+ return ((_this$getCellStyleDat = this.getCellStyleData(type)) === null || _this$getCellStyleDat === void 0 ? void 0 : _this$getCellStyleDat.ff) ?? null;
4656
4662
  }
4657
4663
  /**
4658
4664
  * Get the font size of the cell.
@@ -4673,8 +4679,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4673
4679
  * ```
4674
4680
  */
4675
4681
  getFontSize(type = "row") {
4676
- var _this$getCellStyleDat3, _this$getCellStyleDat4;
4677
- return (_this$getCellStyleDat3 = (_this$getCellStyleDat4 = this.getCellStyleData(type)) === null || _this$getCellStyleDat4 === void 0 ? void 0 : _this$getCellStyleDat4.fs) !== null && _this$getCellStyleDat3 !== void 0 ? _this$getCellStyleDat3 : null;
4682
+ var _this$getCellStyleDat2;
4683
+ return ((_this$getCellStyleDat2 = this.getCellStyleData(type)) === null || _this$getCellStyleDat2 === void 0 ? void 0 : _this$getCellStyleDat2.fs) ?? null;
4678
4684
  }
4679
4685
  /**
4680
4686
  * Return first cell style in this range.
@@ -4724,9 +4730,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4724
4730
  }));
4725
4731
  }
4726
4732
  getValue(includeRichText) {
4727
- var _this$_worksheet$getC, _this$_worksheet$getC2;
4733
+ var _this$_worksheet$getC;
4728
4734
  if (includeRichText) return this.getValueAndRichTextValue();
4729
- return (_this$_worksheet$getC = (_this$_worksheet$getC2 = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) === null || _this$_worksheet$getC2 === void 0 ? void 0 : _this$_worksheet$getC2.v) !== null && _this$_worksheet$getC !== void 0 ? _this$_worksheet$getC : null;
4735
+ return ((_this$_worksheet$getC = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) === null || _this$_worksheet$getC === void 0 ? void 0 : _this$_worksheet$getC.v) ?? null;
4730
4736
  }
4731
4737
  /**
4732
4738
  * Returns the raw value of the top-left cell in the range. Empty cells return `null`.
@@ -4781,8 +4787,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4781
4787
  for (let r = startRow; r <= endRow; r++) {
4782
4788
  const row = [];
4783
4789
  for (let c = startColumn; c <= endColumn; c++) {
4784
- var _this$_worksheet$getC3, _this$_worksheet$getC4;
4785
- row.push((_this$_worksheet$getC3 = (_this$_worksheet$getC4 = this._worksheet.getCell(r, c)) === null || _this$_worksheet$getC4 === void 0 ? void 0 : _this$_worksheet$getC4.v) !== null && _this$_worksheet$getC3 !== void 0 ? _this$_worksheet$getC3 : null);
4790
+ var _this$_worksheet$getC2;
4791
+ row.push(((_this$_worksheet$getC2 = this._worksheet.getCell(r, c)) === null || _this$_worksheet$getC2 === void 0 ? void 0 : _this$_worksheet$getC2.v) ?? null);
4786
4792
  }
4787
4793
  range.push(row);
4788
4794
  }
@@ -4914,8 +4920,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4914
4920
  * ```
4915
4921
  */
4916
4922
  getCellData() {
4917
- var _this$_worksheet$getC5;
4918
- return (_this$_worksheet$getC5 = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) !== null && _this$_worksheet$getC5 !== void 0 ? _this$_worksheet$getC5 : null;
4923
+ return this._worksheet.getCell(this._range.startRow, this._range.startColumn) ?? null;
4919
4924
  }
4920
4925
  /**
4921
4926
  * Alias for getCellDataGrid.
@@ -5036,8 +5041,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5036
5041
  * ```
5037
5042
  */
5038
5043
  getFormula() {
5039
- var _this$_formulaDataMod;
5040
- return (_this$_formulaDataMod = this._formulaDataModel.getFormulaStringByCell(this._range.startRow, this._range.startColumn, this._worksheet.getSheetId(), this._workbook.getUnitId())) !== null && _this$_formulaDataMod !== void 0 ? _this$_formulaDataMod : "";
5044
+ return this._formulaDataModel.getFormulaStringByCell(this._range.startRow, this._range.startColumn, this._worksheet.getSheetId(), this._workbook.getUnitId()) ?? "";
5041
5045
  }
5042
5046
  /**
5043
5047
  * Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
@@ -5083,9 +5087,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5083
5087
  }
5084
5088
  /** Gets whether the top-left cell shrinks its font size to fit the cell width. */
5085
5089
  getShrinkToFit() {
5086
- var _this$_worksheet$getC6;
5090
+ var _this$_worksheet$getC3;
5087
5091
  const { startRow, startColumn } = this._range;
5088
- return ((_this$_worksheet$getC6 = this._worksheet.getComposedCellStyle(startRow, startColumn)) === null || _this$_worksheet$getC6 === void 0 ? void 0 : _this$_worksheet$getC6.stf) === _univerjs_core.BooleanNumber.TRUE;
5092
+ return ((_this$_worksheet$getC3 = this._worksheet.getComposedCellStyle(startRow, startColumn)) === null || _this$_worksheet$getC3 === void 0 ? void 0 : _this$_worksheet$getC3.stf) === _univerjs_core.BooleanNumber.TRUE;
5089
5093
  }
5090
5094
  /**
5091
5095
  * Gets whether text wrapping is enabled for cells in the range.
@@ -5245,10 +5249,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5245
5249
  * ```
5246
5250
  */
5247
5251
  getCustomMetaData() {
5248
- var _cell$custom;
5249
5252
  this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5250
5253
  const cell = this.getCellData();
5251
- return (_cell$custom = cell === null || cell === void 0 ? void 0 : cell.custom) !== null && _cell$custom !== void 0 ? _cell$custom : null;
5254
+ return (cell === null || cell === void 0 ? void 0 : cell.custom) ?? null;
5252
5255
  }
5253
5256
  /**
5254
5257
  * Returns the custom meta data for the cells in the range.
@@ -5264,10 +5267,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5264
5267
  */
5265
5268
  getCustomMetaDatas() {
5266
5269
  this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5267
- return this.getCellDataGrid().map((row) => row.map((data) => {
5268
- var _data$custom;
5269
- return (_data$custom = data === null || data === void 0 ? void 0 : data.custom) !== null && _data$custom !== void 0 ? _data$custom : null;
5270
- }));
5270
+ return this.getCellDataGrid().map((row) => row.map((data) => (data === null || data === void 0 ? void 0 : data.custom) ?? null));
5271
5271
  }
5272
5272
  /**
5273
5273
  * Sets basic border properties for the current range.
@@ -5310,9 +5310,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5310
5310
  * ```
5311
5311
  */
5312
5312
  getBackground() {
5313
- var _style$background$rgb, _style$background;
5313
+ var _style$background;
5314
5314
  const style = this.getCellStyle();
5315
- return (_style$background$rgb = style === null || style === void 0 || (_style$background = style.background) === null || _style$background === void 0 ? void 0 : _style$background.rgb) !== null && _style$background$rgb !== void 0 ? _style$background$rgb : _univerjs_core.DEFAULT_STYLES.bg.rgb;
5315
+ return (style === null || style === void 0 || (_style$background = style.background) === null || _style$background === void 0 ? void 0 : _style$background.rgb) ?? _univerjs_core.DEFAULT_STYLES.bg.rgb;
5316
5316
  }
5317
5317
  /**
5318
5318
  * Returns the background colors of the cells in the range.
@@ -5328,8 +5328,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5328
5328
  */
5329
5329
  getBackgrounds() {
5330
5330
  return this.getCellStyles().map((row) => row.map((style) => {
5331
- var _style$background$rgb2, _style$background2;
5332
- return (_style$background$rgb2 = style === null || style === void 0 || (_style$background2 = style.background) === null || _style$background2 === void 0 ? void 0 : _style$background2.rgb) !== null && _style$background$rgb2 !== void 0 ? _style$background$rgb2 : _univerjs_core.DEFAULT_STYLES.bg.rgb;
5331
+ var _style$background2;
5332
+ return (style === null || style === void 0 || (_style$background2 = style.background) === null || _style$background2 === void 0 ? void 0 : _style$background2.rgb) ?? _univerjs_core.DEFAULT_STYLES.bg.rgb;
5333
5333
  }));
5334
5334
  }
5335
5335
  /**
@@ -6871,12 +6871,11 @@ let FWorkbookPermission = class FWorkbookPermission extends _univerjs_core_facad
6871
6871
  * ```
6872
6872
  */
6873
6873
  getPoint(point) {
6874
- var _permissionPoint$valu;
6875
6874
  const PointClass = WORKBOOK_PERMISSION_POINT_MAP[point];
6876
6875
  if (!PointClass) throw new Error(`Unknown workbook permission point: ${point}`);
6877
6876
  const instance = new PointClass(this._unitId);
6878
6877
  const permissionPoint = this._permissionService.getPermissionPoint(instance.id);
6879
- return (_permissionPoint$valu = permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) !== null && _permissionPoint$valu !== void 0 ? _permissionPoint$valu : true;
6878
+ return (permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) ?? true;
6880
6879
  }
6881
6880
  /**
6882
6881
  * Get a snapshot of all permission points.
@@ -7210,13 +7209,13 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7210
7209
  * ```
7211
7210
  */
7212
7211
  create(name, rows, columns, options) {
7213
- var _options$sheet, _options$sheet2, _options$index;
7214
- const newSheet = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(_univerjs_core.Tools.deepClone((_options$sheet = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet !== void 0 ? _options$sheet : {}));
7212
+ var _options$sheet;
7213
+ const newSheet = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(_univerjs_core.Tools.deepClone((options === null || options === void 0 ? void 0 : options.sheet) ?? {}));
7215
7214
  newSheet.name = name;
7216
7215
  newSheet.rowCount = rows;
7217
7216
  newSheet.columnCount = columns;
7218
- newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
7219
- const newSheetIndex = (_options$index = options === null || options === void 0 ? void 0 : options.index) !== null && _options$index !== void 0 ? _options$index : this._workbook.getSheets().length;
7217
+ newSheet.id = options === null || options === void 0 || (_options$sheet = options.sheet) === null || _options$sheet === void 0 ? void 0 : _options$sheet.id;
7218
+ const newSheetIndex = (options === null || options === void 0 ? void 0 : options.index) ?? this._workbook.getSheets().length;
7220
7219
  this._commandService.syncExecuteCommand(_univerjs_sheets.InsertSheetCommand.id, {
7221
7220
  unitId: this.id,
7222
7221
  index: newSheetIndex,
@@ -7323,12 +7322,12 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7323
7322
  * ```
7324
7323
  */
7325
7324
  insertSheet(sheetName, options) {
7326
- var _options$sheet3, _options$sheet4, _options$index2;
7327
- const newSheet = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(_univerjs_core.Tools.deepClone((_options$sheet3 = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet3 !== void 0 ? _options$sheet3 : {}));
7325
+ var _options$sheet2;
7326
+ const newSheet = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(_univerjs_core.Tools.deepClone((options === null || options === void 0 ? void 0 : options.sheet) ?? {}));
7328
7327
  if (sheetName !== void 0) newSheet.name = sheetName;
7329
7328
  else delete newSheet.name;
7330
- newSheet.id = options === null || options === void 0 || (_options$sheet4 = options.sheet) === null || _options$sheet4 === void 0 ? void 0 : _options$sheet4.id;
7331
- const newSheetIndex = (_options$index2 = options === null || options === void 0 ? void 0 : options.index) !== null && _options$index2 !== void 0 ? _options$index2 : this._workbook.getSheets().length;
7329
+ newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
7330
+ const newSheetIndex = (options === null || options === void 0 ? void 0 : options.index) ?? this._workbook.getSheets().length;
7332
7331
  this._commandService.syncExecuteCommand(_univerjs_sheets.InsertSheetCommand.id, {
7333
7332
  unitId: this.id,
7334
7333
  index: newSheetIndex,
@@ -8205,12 +8204,11 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
8205
8204
  })));
8206
8205
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineEnableChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8207
8206
  if (commandInfo.id === _univerjs_sheets.ToggleGridlinesCommand.id) {
8208
- var _params$showGridlines;
8209
8207
  const params = commandInfo.params;
8210
8208
  const target = this.getSheetCommandTarget(params);
8211
8209
  if (!target) return;
8212
8210
  const { workbook, worksheet } = target;
8213
- const showGridlines = (_params$showGridlines = params.showGridlines) !== null && _params$showGridlines !== void 0 ? _params$showGridlines : !worksheet.hasHiddenGridLines();
8211
+ const showGridlines = params.showGridlines ?? !worksheet.hasHiddenGridLines();
8214
8212
  const eventParams = {
8215
8213
  workbook,
8216
8214
  worksheet,
@@ -8237,12 +8235,12 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
8237
8235
  })));
8238
8236
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetCreated, () => commandService.onCommandExecuted((commandInfo) => {
8239
8237
  if (commandInfo.id === _univerjs_sheets.InsertSheetCommand.id) {
8240
- var _params$sheet, _params$index;
8238
+ var _params$sheet;
8241
8239
  const params = commandInfo.params;
8242
8240
  const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? this.getWorkbook(params.unitId) : this.getActiveWorkbook();
8243
8241
  if (!workbook) return;
8244
8242
  const sheets = workbook.getSheets();
8245
- const worksheet = (params === null || params === void 0 || (_params$sheet = params.sheet) === null || _params$sheet === void 0 ? void 0 : _params$sheet.id) ? workbook.getSheetBySheetId(params.sheet.id) : sheets[(_params$index = params === null || params === void 0 ? void 0 : params.index) !== null && _params$index !== void 0 ? _params$index : sheets.length - 1];
8243
+ const worksheet = (params === null || params === void 0 || (_params$sheet = params.sheet) === null || _params$sheet === void 0 ? void 0 : _params$sheet.id) ? workbook.getSheetBySheetId(params.sheet.id) : sheets[(params === null || params === void 0 ? void 0 : params.index) ?? sheets.length - 1];
8246
8244
  if (!worksheet) return;
8247
8245
  const eventParams = {
8248
8246
  workbook,