@univerjs/sheets 1.0.0-alpha.8 → 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.
@@ -17,7 +17,7 @@ const locale = { sheets: {
17
17
  nameSheetConflict: "名称与工作表名称冲突",
18
18
  formulaOrRefStringEmpty: "公式或引用字符串不能为空",
19
19
  nameConflict: "名称与函数名称冲突",
20
- defaultName: "DefinedName"
20
+ defaultName: "定义名称"
21
21
  },
22
22
  permission: { dialog: {
23
23
  autoFillErr: "该范围已被保护,目前无自动填充权限。如需自动填充,请联系创建者。",
@@ -17,7 +17,7 @@ const locale = { sheets: {
17
17
  nameSheetConflict: "名稱與工作表名稱衝突",
18
18
  formulaOrRefStringEmpty: "公式或引用字串不能為空",
19
19
  nameConflict: "名稱與函數名稱衝突",
20
- defaultName: "DefinedName"
20
+ defaultName: "定義名稱"
21
21
  },
22
22
  permission: { dialog: {
23
23
  autoFillErr: "範圍已被保護,目前無自動填入權限。如需自動填充,請聯絡建立者。 ",
@@ -17,7 +17,7 @@ const locale = { sheets: {
17
17
  nameSheetConflict: "名稱與工作表名稱衝突",
18
18
  formulaOrRefStringEmpty: "公式或引用字串不能為空",
19
19
  nameConflict: "名稱與函數名稱衝突",
20
- defaultName: "DefinedName"
20
+ defaultName: "定義名稱"
21
21
  },
22
22
  permission: { dialog: {
23
23
  autoFillErr: "範圍已被保護,目前無自動填入權限。如需自動填充,請聯絡建立者。 ",
package/lib/facade.js CHANGED
@@ -190,9 +190,9 @@ let FDefinedNameBuilder = class FDefinedNameBuilder {
190
190
  setRefByRange(row, column, numRows, numColumns) {
191
191
  this._definedNameParam.formulaOrRefString = serializeRange({
192
192
  startRow: row,
193
- endRow: row + (numRows !== null && numRows !== void 0 ? numRows : 1) - 1,
193
+ endRow: row + (numRows ?? 1) - 1,
194
194
  startColumn: column,
195
- endColumn: column + (numColumns !== null && numColumns !== void 0 ? numColumns : 1) - 1
195
+ endColumn: column + (numColumns ?? 1) - 1
196
196
  });
197
197
  return this;
198
198
  }
@@ -432,9 +432,9 @@ let FDefinedName = class FDefinedName extends FBase {
432
432
  setRefByRange(row, column, numRows, numColumns) {
433
433
  this._definedNameParam.formulaOrRefString = serializeRange({
434
434
  startRow: row,
435
- endRow: row + (numRows !== null && numRows !== void 0 ? numRows : 1) - 1,
435
+ endRow: row + (numRows ?? 1) - 1,
436
436
  startColumn: column,
437
- endColumn: column + (numColumns !== null && numColumns !== void 0 ? numColumns : 1) - 1
437
+ endColumn: column + (numColumns ?? 1) - 1
438
438
  });
439
439
  this._apply();
440
440
  }
@@ -1618,10 +1618,9 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
1618
1618
  if (!this.canEdit()) return false;
1619
1619
  const rules = this._rangeProtectionRuleModel.getSubunitRuleList(this._unitId, this._subUnitId);
1620
1620
  for (const rule of rules) for (const range of rule.ranges) if (row >= range.startRow && row <= range.endRow && col >= range.startColumn && col <= range.endColumn) {
1621
- var _permission$value;
1622
1621
  const permissionPoint = new RangeProtectionPermissionEditPoint(this._unitId, this._subUnitId, rule.permissionId);
1623
1622
  const permission = this._permissionService.getPermissionPoint(permissionPoint.id);
1624
- return (_permission$value = permission === null || permission === void 0 ? void 0 : permission.value) !== null && _permission$value !== void 0 ? _permission$value : false;
1623
+ return (permission === null || permission === void 0 ? void 0 : permission.value) ?? false;
1625
1624
  }
1626
1625
  return true;
1627
1626
  }
@@ -1660,10 +1659,9 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
1660
1659
  if (!this.canView()) return false;
1661
1660
  const rules = this._rangeProtectionRuleModel.getSubunitRuleList(this._unitId, this._subUnitId);
1662
1661
  for (const rule of rules) for (const range of rule.ranges) if (row >= range.startRow && row <= range.endRow && col >= range.startColumn && col <= range.endColumn) {
1663
- var _permission$value2;
1664
1662
  const permissionPoint = new RangeProtectionPermissionViewPoint(this._unitId, this._subUnitId, rule.permissionId);
1665
1663
  const permission = this._permissionService.getPermissionPoint(permissionPoint.id);
1666
- return (_permission$value2 = permission === null || permission === void 0 ? void 0 : permission.value) !== null && _permission$value2 !== void 0 ? _permission$value2 : false;
1664
+ return (permission === null || permission === void 0 ? void 0 : permission.value) ?? false;
1667
1665
  }
1668
1666
  return true;
1669
1667
  }
@@ -1682,12 +1680,11 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
1682
1680
  * ```
1683
1681
  */
1684
1682
  getPoint(point) {
1685
- var _permissionPoint$valu;
1686
1683
  const PointClass = WORKSHEET_PERMISSION_POINT_MAP[point];
1687
1684
  if (!PointClass) throw new Error(`Unknown worksheet permission point: ${point}`);
1688
1685
  const instance = new PointClass(this._unitId, this._subUnitId);
1689
1686
  const permissionPoint = this._permissionService.getPermissionPoint(instance.id);
1690
- return (_permissionPoint$valu = permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) !== null && _permissionPoint$valu !== void 0 ? _permissionPoint$valu : true;
1687
+ return (permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) ?? true;
1691
1688
  }
1692
1689
  /**
1693
1690
  * Get a snapshot of all permission points.
@@ -2019,6 +2016,11 @@ function covertToColRange(range, worksheet) {
2019
2016
  //#endregion
2020
2017
  //#region src/facade/f-worksheet.ts
2021
2018
  var _FWorksheet;
2019
+ function assertValidRowInsertion(methodName, rowIndex, rowCount, howMany) {
2020
+ if (!Number.isInteger(howMany) || howMany <= 0) throw new RangeError(`${methodName}(): row count ${howMany} must be a positive integer.`);
2021
+ const lastRowIndex = rowCount - 1;
2022
+ 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}).`);
2023
+ }
2022
2024
  let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2023
2025
  /**
2024
2026
  * Creates a new worksheet facade instance
@@ -2299,9 +2301,9 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2299
2301
  sheet = this._worksheet;
2300
2302
  range = {
2301
2303
  startRow: rowOrA1Notation,
2302
- endRow: rowOrA1Notation + (numRows !== null && numRows !== void 0 ? numRows : 1) - 1,
2304
+ endRow: rowOrA1Notation + (numRows ?? 1) - 1,
2303
2305
  startColumn: column,
2304
- endColumn: column + (numColumns !== null && numColumns !== void 0 ? numColumns : 1) - 1,
2306
+ endColumn: column + (numColumns ?? 1) - 1,
2305
2307
  unitId: this._workbook.getUnitId(),
2306
2308
  sheetId: this._worksheet.getSheetId()
2307
2309
  };
@@ -2338,7 +2340,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2338
2340
  }
2339
2341
  /**
2340
2342
  * Inserts a row after the given row position.
2341
- * @param {number} afterPosition - The row after which the new row should be added, starting at 0 for the first row.
2343
+ * @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`.
2342
2344
  * @returns {FWorksheet} This sheet, for chaining.
2343
2345
  * @example
2344
2346
  * ```typescript
@@ -2355,7 +2357,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2355
2357
  }
2356
2358
  /**
2357
2359
  * Inserts a row before the given row position.
2358
- * @param {number} beforePosition - The row before which the new row should be added, starting at 0 for the first row.
2360
+ * @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`.
2359
2361
  * @returns {FWorksheet} This sheet, for chaining.
2360
2362
  * @example
2361
2363
  * ```typescript
@@ -2372,8 +2374,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2372
2374
  }
2373
2375
  /**
2374
2376
  * Inserts one or more consecutive blank rows in a sheet starting at the specified location.
2375
- * @param {number} rowIndex - The index indicating where to insert a row, starting at 0 for the first row.
2376
- * @param {number} numRows - The number of rows to insert.
2377
+ * @param {number} rowIndex - The existing row before which rows are inserted. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
2378
+ * @param {number} numRows - The positive number of rows to insert.
2377
2379
  * @returns {FWorksheet} This sheet, for chaining.
2378
2380
  * @example
2379
2381
  * ```typescript
@@ -2386,12 +2388,13 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2386
2388
  * ```
2387
2389
  */
2388
2390
  insertRows(rowIndex, numRows = 1) {
2391
+ assertValidRowInsertion("insertRows", rowIndex, this.getMaxRows(), numRows);
2389
2392
  return this.insertRowsBefore(rowIndex, numRows);
2390
2393
  }
2391
2394
  /**
2392
2395
  * Inserts a number of rows after the given row position.
2393
- * @param {number} afterPosition - The row after which the new rows should be added, starting at 0 for the first row.
2394
- * @param {number} howMany - The number of rows to insert.
2396
+ * @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`.
2397
+ * @param {number} howMany - The positive number of rows to insert.
2395
2398
  * @returns {FWorksheet} This sheet, for chaining.
2396
2399
  * @example
2397
2400
  * ```typescript
@@ -2404,6 +2407,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2404
2407
  * ```
2405
2408
  */
2406
2409
  insertRowsAfter(afterPosition, howMany) {
2410
+ assertValidRowInsertion("insertRowsAfter", afterPosition, this.getMaxRows(), howMany);
2407
2411
  const unitId = this._workbook.getUnitId();
2408
2412
  const subUnitId = this._worksheet.getSheetId();
2409
2413
  const direction = Direction.DOWN;
@@ -2428,8 +2432,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2428
2432
  }
2429
2433
  /**
2430
2434
  * Inserts a number of rows before the given row position.
2431
- * @param {number} beforePosition - The row before which the new rows should be added, starting at 0 for the first row.
2432
- * @param {number} howMany - The number of rows to insert.
2435
+ * @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`.
2436
+ * @param {number} howMany - The positive number of rows to insert.
2433
2437
  * @returns {FWorksheet} This sheet, for chaining.
2434
2438
  * @example
2435
2439
  * ```typescript
@@ -2442,6 +2446,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2442
2446
  * ```
2443
2447
  */
2444
2448
  insertRowsBefore(beforePosition, howMany) {
2449
+ assertValidRowInsertion("insertRowsBefore", beforePosition, this.getMaxRows(), howMany);
2445
2450
  const unitId = this._workbook.getUnitId();
2446
2451
  const subUnitId = this._worksheet.getSheetId();
2447
2452
  const direction = Direction.UP;
@@ -4145,7 +4150,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4145
4150
  return this._worksheet.getColumnManager().getCustomMetadata(index);
4146
4151
  }
4147
4152
  /**
4148
- * 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.
4153
+ * Appends a row to the bottom of the current data region in the sheet. If the destination row is already within the worksheet capacity,
4154
+ * this method writes into that row without increasing `getMaxRows()`. If a cell's content begins with =, it's interpreted as a formula.
4149
4155
  * @param {CellValue[]} rowContents - An array of values for the new row.
4150
4156
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining.
4151
4157
  * @example
@@ -4650,8 +4656,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4650
4656
  * ```
4651
4657
  */
4652
4658
  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;
4659
+ var _this$getCellStyleDat;
4660
+ return ((_this$getCellStyleDat = this.getCellStyleData(type)) === null || _this$getCellStyleDat === void 0 ? void 0 : _this$getCellStyleDat.ff) ?? null;
4655
4661
  }
4656
4662
  /**
4657
4663
  * Get the font size of the cell.
@@ -4672,8 +4678,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4672
4678
  * ```
4673
4679
  */
4674
4680
  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;
4681
+ var _this$getCellStyleDat2;
4682
+ return ((_this$getCellStyleDat2 = this.getCellStyleData(type)) === null || _this$getCellStyleDat2 === void 0 ? void 0 : _this$getCellStyleDat2.fs) ?? null;
4677
4683
  }
4678
4684
  /**
4679
4685
  * Return first cell style in this range.
@@ -4723,9 +4729,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4723
4729
  }));
4724
4730
  }
4725
4731
  getValue(includeRichText) {
4726
- var _this$_worksheet$getC, _this$_worksheet$getC2;
4732
+ var _this$_worksheet$getC;
4727
4733
  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;
4734
+ 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
4735
  }
4730
4736
  /**
4731
4737
  * Returns the raw value of the top-left cell in the range. Empty cells return `null`.
@@ -4780,8 +4786,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4780
4786
  for (let r = startRow; r <= endRow; r++) {
4781
4787
  const row = [];
4782
4788
  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);
4789
+ var _this$_worksheet$getC2;
4790
+ row.push(((_this$_worksheet$getC2 = this._worksheet.getCell(r, c)) === null || _this$_worksheet$getC2 === void 0 ? void 0 : _this$_worksheet$getC2.v) ?? null);
4785
4791
  }
4786
4792
  range.push(row);
4787
4793
  }
@@ -4913,8 +4919,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4913
4919
  * ```
4914
4920
  */
4915
4921
  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;
4922
+ return this._worksheet.getCell(this._range.startRow, this._range.startColumn) ?? null;
4918
4923
  }
4919
4924
  /**
4920
4925
  * Alias for getCellDataGrid.
@@ -5035,8 +5040,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5035
5040
  * ```
5036
5041
  */
5037
5042
  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 : "";
5043
+ return this._formulaDataModel.getFormulaStringByCell(this._range.startRow, this._range.startColumn, this._worksheet.getSheetId(), this._workbook.getUnitId()) ?? "";
5040
5044
  }
5041
5045
  /**
5042
5046
  * 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 +5086,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5082
5086
  }
5083
5087
  /** Gets whether the top-left cell shrinks its font size to fit the cell width. */
5084
5088
  getShrinkToFit() {
5085
- var _this$_worksheet$getC6;
5089
+ var _this$_worksheet$getC3;
5086
5090
  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) === BooleanNumber.TRUE;
5091
+ return ((_this$_worksheet$getC3 = this._worksheet.getComposedCellStyle(startRow, startColumn)) === null || _this$_worksheet$getC3 === void 0 ? void 0 : _this$_worksheet$getC3.stf) === BooleanNumber.TRUE;
5088
5092
  }
5089
5093
  /**
5090
5094
  * Gets whether text wrapping is enabled for cells in the range.
@@ -5244,10 +5248,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5244
5248
  * ```
5245
5249
  */
5246
5250
  getCustomMetaData() {
5247
- var _cell$custom;
5248
5251
  this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5249
5252
  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;
5253
+ return (cell === null || cell === void 0 ? void 0 : cell.custom) ?? null;
5251
5254
  }
5252
5255
  /**
5253
5256
  * Returns the custom meta data for the cells in the range.
@@ -5263,10 +5266,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5263
5266
  */
5264
5267
  getCustomMetaDatas() {
5265
5268
  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
- }));
5269
+ return this.getCellDataGrid().map((row) => row.map((data) => (data === null || data === void 0 ? void 0 : data.custom) ?? null));
5270
5270
  }
5271
5271
  /**
5272
5272
  * Sets basic border properties for the current range.
@@ -5309,9 +5309,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5309
5309
  * ```
5310
5310
  */
5311
5311
  getBackground() {
5312
- var _style$background$rgb, _style$background;
5312
+ var _style$background;
5313
5313
  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 : DEFAULT_STYLES.bg.rgb;
5314
+ return (style === null || style === void 0 || (_style$background = style.background) === null || _style$background === void 0 ? void 0 : _style$background.rgb) ?? DEFAULT_STYLES.bg.rgb;
5315
5315
  }
5316
5316
  /**
5317
5317
  * Returns the background colors of the cells in the range.
@@ -5327,8 +5327,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5327
5327
  */
5328
5328
  getBackgrounds() {
5329
5329
  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 : DEFAULT_STYLES.bg.rgb;
5330
+ var _style$background2;
5331
+ return (style === null || style === void 0 || (_style$background2 = style.background) === null || _style$background2 === void 0 ? void 0 : _style$background2.rgb) ?? DEFAULT_STYLES.bg.rgb;
5332
5332
  }));
5333
5333
  }
5334
5334
  /**
@@ -6870,12 +6870,11 @@ let FWorkbookPermission = class FWorkbookPermission extends FBase {
6870
6870
  * ```
6871
6871
  */
6872
6872
  getPoint(point) {
6873
- var _permissionPoint$valu;
6874
6873
  const PointClass = WORKBOOK_PERMISSION_POINT_MAP[point];
6875
6874
  if (!PointClass) throw new Error(`Unknown workbook permission point: ${point}`);
6876
6875
  const instance = new PointClass(this._unitId);
6877
6876
  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;
6877
+ return (permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) ?? true;
6879
6878
  }
6880
6879
  /**
6881
6880
  * Get a snapshot of all permission points.
@@ -7209,13 +7208,13 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7209
7208
  * ```
7210
7209
  */
7211
7210
  create(name, rows, columns, options) {
7212
- var _options$sheet, _options$sheet2, _options$index;
7213
- const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((_options$sheet = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet !== void 0 ? _options$sheet : {}));
7211
+ var _options$sheet;
7212
+ const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((options === null || options === void 0 ? void 0 : options.sheet) ?? {}));
7214
7213
  newSheet.name = name;
7215
7214
  newSheet.rowCount = rows;
7216
7215
  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;
7216
+ newSheet.id = options === null || options === void 0 || (_options$sheet = options.sheet) === null || _options$sheet === void 0 ? void 0 : _options$sheet.id;
7217
+ const newSheetIndex = (options === null || options === void 0 ? void 0 : options.index) ?? this._workbook.getSheets().length;
7219
7218
  this._commandService.syncExecuteCommand(InsertSheetCommand.id, {
7220
7219
  unitId: this.id,
7221
7220
  index: newSheetIndex,
@@ -7322,12 +7321,12 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7322
7321
  * ```
7323
7322
  */
7324
7323
  insertSheet(sheetName, options) {
7325
- var _options$sheet3, _options$sheet4, _options$index2;
7326
- const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((_options$sheet3 = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet3 !== void 0 ? _options$sheet3 : {}));
7324
+ var _options$sheet2;
7325
+ const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((options === null || options === void 0 ? void 0 : options.sheet) ?? {}));
7327
7326
  if (sheetName !== void 0) newSheet.name = sheetName;
7328
7327
  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;
7328
+ newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
7329
+ const newSheetIndex = (options === null || options === void 0 ? void 0 : options.index) ?? this._workbook.getSheets().length;
7331
7330
  this._commandService.syncExecuteCommand(InsertSheetCommand.id, {
7332
7331
  unitId: this.id,
7333
7332
  index: newSheetIndex,
@@ -8204,12 +8203,11 @@ var FUniverSheetsMixin = class extends FUniver {
8204
8203
  })));
8205
8204
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineEnableChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8206
8205
  if (commandInfo.id === ToggleGridlinesCommand.id) {
8207
- var _params$showGridlines;
8208
8206
  const params = commandInfo.params;
8209
8207
  const target = this.getSheetCommandTarget(params);
8210
8208
  if (!target) return;
8211
8209
  const { workbook, worksheet } = target;
8212
- const showGridlines = (_params$showGridlines = params.showGridlines) !== null && _params$showGridlines !== void 0 ? _params$showGridlines : !worksheet.hasHiddenGridLines();
8210
+ const showGridlines = params.showGridlines ?? !worksheet.hasHiddenGridLines();
8213
8211
  const eventParams = {
8214
8212
  workbook,
8215
8213
  worksheet,
@@ -8236,12 +8234,12 @@ var FUniverSheetsMixin = class extends FUniver {
8236
8234
  })));
8237
8235
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetCreated, () => commandService.onCommandExecuted((commandInfo) => {
8238
8236
  if (commandInfo.id === InsertSheetCommand.id) {
8239
- var _params$sheet, _params$index;
8237
+ var _params$sheet;
8240
8238
  const params = commandInfo.params;
8241
8239
  const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? this.getWorkbook(params.unitId) : this.getActiveWorkbook();
8242
8240
  if (!workbook) return;
8243
8241
  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];
8242
+ 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
8243
  if (!worksheet) return;
8246
8244
  const eventParams = {
8247
8245
  workbook,