@univerjs/sheets 1.0.0-alpha.7 → 1.0.0-beta.0

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.
package/lib/cjs/facade.js CHANGED
@@ -24,7 +24,7 @@ let _univerjs_protocol = require("@univerjs/protocol");
24
24
  const SHEETS_CUSTOM_FIELD_WARNING_MESSAGE = "[Facade]: The sheets custom field is not recommended for external use. Use it at your own risk.";
25
25
 
26
26
  //#endregion
27
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
27
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
28
28
  function _typeof(o) {
29
29
  "@babel/helpers - typeof";
30
30
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -35,7 +35,7 @@ function _typeof(o) {
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
38
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
39
39
  function toPrimitive(t, r) {
40
40
  if ("object" != _typeof(t) || !t) return t;
41
41
  var e = t[Symbol.toPrimitive];
@@ -48,14 +48,14 @@ function toPrimitive(t, r) {
48
48
  }
49
49
 
50
50
  //#endregion
51
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
51
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
52
52
  function toPropertyKey(t) {
53
53
  var i = toPrimitive(t, "string");
54
54
  return "symbol" == _typeof(i) ? i : i + "";
55
55
  }
56
56
 
57
57
  //#endregion
58
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
58
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
59
59
  function _defineProperty(e, r, t) {
60
60
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
61
61
  value: t,
@@ -66,7 +66,7 @@ function _defineProperty(e, r, t) {
66
66
  }
67
67
 
68
68
  //#endregion
69
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
69
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
70
70
  function __decorateParam(paramIndex, decorator) {
71
71
  return function(target, key) {
72
72
  decorator(target, key, paramIndex);
@@ -74,7 +74,7 @@ function __decorateParam(paramIndex, decorator) {
74
74
  }
75
75
 
76
76
  //#endregion
77
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
77
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
78
78
  function __decorate(decorators, target, key, desc) {
79
79
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
80
80
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -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
@@ -4421,7 +4427,8 @@ FRangePermission = __decorate([
4421
4427
 
4422
4428
  //#endregion
4423
4429
  //#region src/facade/f-range.ts
4424
- var _FRange, _FRange2;
4430
+ var _FRange;
4431
+ var _FRange2;
4425
4432
  let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialable {
4426
4433
  constructor(_workbook, _worksheet, _range, _injector, _commandService, _formulaDataModel, _logService) {
4427
4434
  super(_injector);
@@ -4650,8 +4657,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4650
4657
  * ```
4651
4658
  */
4652
4659
  getFontFamily(type = "row") {
4653
- var _this$getCellStyleDat, _this$getCellStyleDat2;
4654
- 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;
4655
4662
  }
4656
4663
  /**
4657
4664
  * Get the font size of the cell.
@@ -4672,8 +4679,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4672
4679
  * ```
4673
4680
  */
4674
4681
  getFontSize(type = "row") {
4675
- var _this$getCellStyleDat3, _this$getCellStyleDat4;
4676
- 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;
4677
4684
  }
4678
4685
  /**
4679
4686
  * Return first cell style in this range.
@@ -4723,9 +4730,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4723
4730
  }));
4724
4731
  }
4725
4732
  getValue(includeRichText) {
4726
- var _this$_worksheet$getC, _this$_worksheet$getC2;
4733
+ var _this$_worksheet$getC;
4727
4734
  if (includeRichText) return this.getValueAndRichTextValue();
4728
- 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;
4729
4736
  }
4730
4737
  /**
4731
4738
  * Returns the raw value of the top-left cell in the range. Empty cells return `null`.
@@ -4780,8 +4787,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4780
4787
  for (let r = startRow; r <= endRow; r++) {
4781
4788
  const row = [];
4782
4789
  for (let c = startColumn; c <= endColumn; c++) {
4783
- var _this$_worksheet$getC3, _this$_worksheet$getC4;
4784
- 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);
4785
4792
  }
4786
4793
  range.push(row);
4787
4794
  }
@@ -4913,8 +4920,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
4913
4920
  * ```
4914
4921
  */
4915
4922
  getCellData() {
4916
- var _this$_worksheet$getC5;
4917
- 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;
4918
4924
  }
4919
4925
  /**
4920
4926
  * Alias for getCellDataGrid.
@@ -5035,8 +5041,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5035
5041
  * ```
5036
5042
  */
5037
5043
  getFormula() {
5038
- var _this$_formulaDataMod;
5039
- 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()) ?? "";
5040
5045
  }
5041
5046
  /**
5042
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.
@@ -5082,9 +5087,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5082
5087
  }
5083
5088
  /** Gets whether the top-left cell shrinks its font size to fit the cell width. */
5084
5089
  getShrinkToFit() {
5085
- var _this$_worksheet$getC6;
5090
+ var _this$_worksheet$getC3;
5086
5091
  const { startRow, startColumn } = this._range;
5087
- 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;
5088
5093
  }
5089
5094
  /**
5090
5095
  * Gets whether text wrapping is enabled for cells in the range.
@@ -5244,10 +5249,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5244
5249
  * ```
5245
5250
  */
5246
5251
  getCustomMetaData() {
5247
- var _cell$custom;
5248
5252
  this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5249
5253
  const cell = this.getCellData();
5250
- 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;
5251
5255
  }
5252
5256
  /**
5253
5257
  * Returns the custom meta data for the cells in the range.
@@ -5263,10 +5267,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5263
5267
  */
5264
5268
  getCustomMetaDatas() {
5265
5269
  this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5266
- return this.getCellDataGrid().map((row) => row.map((data) => {
5267
- var _data$custom;
5268
- return (_data$custom = data === null || data === void 0 ? void 0 : data.custom) !== null && _data$custom !== void 0 ? _data$custom : null;
5269
- }));
5270
+ return this.getCellDataGrid().map((row) => row.map((data) => (data === null || data === void 0 ? void 0 : data.custom) ?? null));
5270
5271
  }
5271
5272
  /**
5272
5273
  * Sets basic border properties for the current range.
@@ -5309,9 +5310,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5309
5310
  * ```
5310
5311
  */
5311
5312
  getBackground() {
5312
- var _style$background$rgb, _style$background;
5313
+ var _style$background;
5313
5314
  const style = this.getCellStyle();
5314
- 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;
5315
5316
  }
5316
5317
  /**
5317
5318
  * Returns the background colors of the cells in the range.
@@ -5327,8 +5328,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
5327
5328
  */
5328
5329
  getBackgrounds() {
5329
5330
  return this.getCellStyles().map((row) => row.map((style) => {
5330
- var _style$background$rgb2, _style$background2;
5331
- 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;
5332
5333
  }));
5333
5334
  }
5334
5335
  /**
@@ -6870,12 +6871,11 @@ let FWorkbookPermission = class FWorkbookPermission extends _univerjs_core_facad
6870
6871
  * ```
6871
6872
  */
6872
6873
  getPoint(point) {
6873
- var _permissionPoint$valu;
6874
6874
  const PointClass = WORKBOOK_PERMISSION_POINT_MAP[point];
6875
6875
  if (!PointClass) throw new Error(`Unknown workbook permission point: ${point}`);
6876
6876
  const instance = new PointClass(this._unitId);
6877
6877
  const permissionPoint = this._permissionService.getPermissionPoint(instance.id);
6878
- 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;
6879
6879
  }
6880
6880
  /**
6881
6881
  * Get a snapshot of all permission points.
@@ -7209,13 +7209,13 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7209
7209
  * ```
7210
7210
  */
7211
7211
  create(name, rows, columns, options) {
7212
- var _options$sheet, _options$sheet2, _options$index;
7213
- 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) ?? {}));
7214
7214
  newSheet.name = name;
7215
7215
  newSheet.rowCount = rows;
7216
7216
  newSheet.columnCount = columns;
7217
- newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
7218
- 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;
7219
7219
  this._commandService.syncExecuteCommand(_univerjs_sheets.InsertSheetCommand.id, {
7220
7220
  unitId: this.id,
7221
7221
  index: newSheetIndex,
@@ -7322,12 +7322,12 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7322
7322
  * ```
7323
7323
  */
7324
7324
  insertSheet(sheetName, options) {
7325
- var _options$sheet3, _options$sheet4, _options$index2;
7326
- 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) ?? {}));
7327
7327
  if (sheetName !== void 0) newSheet.name = sheetName;
7328
7328
  else delete newSheet.name;
7329
- newSheet.id = options === null || options === void 0 || (_options$sheet4 = options.sheet) === null || _options$sheet4 === void 0 ? void 0 : _options$sheet4.id;
7330
- 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;
7331
7331
  this._commandService.syncExecuteCommand(_univerjs_sheets.InsertSheetCommand.id, {
7332
7332
  unitId: this.id,
7333
7333
  index: newSheetIndex,
@@ -8204,12 +8204,11 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
8204
8204
  })));
8205
8205
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineEnableChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8206
8206
  if (commandInfo.id === _univerjs_sheets.ToggleGridlinesCommand.id) {
8207
- var _params$showGridlines;
8208
8207
  const params = commandInfo.params;
8209
8208
  const target = this.getSheetCommandTarget(params);
8210
8209
  if (!target) return;
8211
8210
  const { workbook, worksheet } = target;
8212
- const showGridlines = (_params$showGridlines = params.showGridlines) !== null && _params$showGridlines !== void 0 ? _params$showGridlines : !worksheet.hasHiddenGridLines();
8211
+ const showGridlines = params.showGridlines ?? !worksheet.hasHiddenGridLines();
8213
8212
  const eventParams = {
8214
8213
  workbook,
8215
8214
  worksheet,
@@ -8236,12 +8235,12 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
8236
8235
  })));
8237
8236
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetCreated, () => commandService.onCommandExecuted((commandInfo) => {
8238
8237
  if (commandInfo.id === _univerjs_sheets.InsertSheetCommand.id) {
8239
- var _params$sheet, _params$index;
8238
+ var _params$sheet;
8240
8239
  const params = commandInfo.params;
8241
8240
  const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? this.getWorkbook(params.unitId) : this.getActiveWorkbook();
8242
8241
  if (!workbook) return;
8243
8242
  const sheets = workbook.getSheets();
8244
- 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];
8245
8244
  if (!worksheet) return;
8246
8245
  const eventParams = {
8247
8246
  workbook,