@univerjs/sheets 1.0.3 → 1.1.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 +80 -40
- package/lib/cjs/index.js +148 -62
- package/lib/es/facade.js +76 -36
- package/lib/es/index.js +123 -39
- package/lib/facade.js +76 -36
- package/lib/index.js +123 -39
- package/lib/types/commands/commands/set-style.command.d.ts +2 -2
- package/lib/types/commands/commands/set-workbook-calculation-settings.command.d.ts +18 -0
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +3 -1
- package/lib/types/commands/mutations/set-workbook-calculation-settings.mutation.d.ts +21 -0
- package/lib/types/config/config.d.ts +8 -0
- package/lib/types/controllers/calculate-result-apply.controller.d.ts +1 -0
- package/lib/types/facade/f-range.d.ts +2 -1
- package/lib/types/facade/f-workbook.d.ts +31 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/services/permission/workbook-permission/util.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +9 -9
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.
|
|
27
|
+
//#region \0@oxc-project+runtime@0.153.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.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.153.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.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.153.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.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.153.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.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.153.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.
|
|
77
|
+
//#region \0@oxc-project+runtime@0.153.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);
|
|
@@ -6546,6 +6546,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6546
6546
|
* Returns a copy of the range expanded `Direction.UP` and `Direction.DOWN` if the specified dimension is `Dimension.ROWS`, or `Direction.NEXT` and `Direction.PREVIOUS` if the dimension is `Dimension.COLUMNS`.
|
|
6547
6547
|
* The expansion of the range is based on detecting data next to the range that is organized like a table.
|
|
6548
6548
|
* The expanded range covers all adjacent cells with data in them along the specified dimension including the table boundaries.
|
|
6549
|
+
* Cells connected only diagonally do not cause the range to expand.
|
|
6549
6550
|
* If the original range is surrounded by empty cells along the specified dimension, the range itself is returned.
|
|
6550
6551
|
* @param {Dimension} [dimension] - The dimension along which to expand the range. If not provided, the range will be expanded in both dimensions.
|
|
6551
6552
|
* @returns {FRange} The range's data region or a range covering each column or each row spanned by the original range.
|
|
@@ -6566,7 +6567,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6566
6567
|
* fWorksheet.getRange('D3').setValue(100);
|
|
6567
6568
|
* fWorksheet.getRange('C4').setValue(100);
|
|
6568
6569
|
*
|
|
6569
|
-
* // Get C3 data region along the rows dimension, the range will be C2:
|
|
6570
|
+
* // Get C3 data region along the rows dimension, the range will be C2:C4
|
|
6570
6571
|
* const range = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.ROWS);
|
|
6571
6572
|
* console.log(range.getA1Notation()); // C2:C4
|
|
6572
6573
|
*
|
|
@@ -6580,41 +6581,43 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6580
6581
|
* ```
|
|
6581
6582
|
*/
|
|
6582
6583
|
getDataRegion(dimension) {
|
|
6583
|
-
|
|
6584
|
+
let { startRow, startColumn, endRow, endColumn } = this._range;
|
|
6584
6585
|
const maxRows = this._worksheet.getMaxRows();
|
|
6585
6586
|
const maxColumns = this._worksheet.getMaxColumns();
|
|
6586
6587
|
const cellMatrix = this._worksheet.getCellMatrix();
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
let
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6588
|
+
const rowHasData = (row) => {
|
|
6589
|
+
for (let c = startColumn; c <= endColumn; c++) if (!(0, _univerjs_core.isNullCell)(cellMatrix.getValue(row, c))) return true;
|
|
6590
|
+
return false;
|
|
6591
|
+
};
|
|
6592
|
+
const columnHasData = (column) => {
|
|
6593
|
+
for (let r = startRow; r <= endRow; r++) if (!(0, _univerjs_core.isNullCell)(cellMatrix.getValue(r, column))) return true;
|
|
6594
|
+
return false;
|
|
6595
|
+
};
|
|
6596
|
+
let expanded = true;
|
|
6597
|
+
while (expanded) {
|
|
6598
|
+
expanded = false;
|
|
6599
|
+
while (dimension !== _univerjs_core.Dimension.COLUMNS && startRow > 0 && rowHasData(startRow - 1)) {
|
|
6600
|
+
startRow--;
|
|
6601
|
+
expanded = true;
|
|
6598
6602
|
}
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6603
|
+
while (dimension !== _univerjs_core.Dimension.COLUMNS && endRow < maxRows - 1 && rowHasData(endRow + 1)) {
|
|
6604
|
+
endRow++;
|
|
6605
|
+
expanded = true;
|
|
6606
|
+
}
|
|
6607
|
+
while (dimension !== _univerjs_core.Dimension.ROWS && startColumn > 0 && columnHasData(startColumn - 1)) {
|
|
6608
|
+
startColumn--;
|
|
6609
|
+
expanded = true;
|
|
6610
|
+
}
|
|
6611
|
+
while (dimension !== _univerjs_core.Dimension.ROWS && endColumn < maxColumns - 1 && columnHasData(endColumn + 1)) {
|
|
6612
|
+
endColumn++;
|
|
6613
|
+
expanded = true;
|
|
6609
6614
|
}
|
|
6610
|
-
if (leftColumnHasValue) newStartColumn = startColumn - 1;
|
|
6611
|
-
if (rightColumnHasValue) newEndColumn = endColumn + 1;
|
|
6612
6615
|
}
|
|
6613
6616
|
return this._injector.createInstance(_FRange, this._workbook, this._worksheet, {
|
|
6614
|
-
startRow
|
|
6615
|
-
startColumn
|
|
6616
|
-
endRow
|
|
6617
|
-
endColumn
|
|
6617
|
+
startRow,
|
|
6618
|
+
startColumn,
|
|
6619
|
+
endRow,
|
|
6620
|
+
endColumn
|
|
6618
6621
|
});
|
|
6619
6622
|
}
|
|
6620
6623
|
/**
|
|
@@ -8111,6 +8114,43 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
8111
8114
|
removeStyles(styleKeys) {
|
|
8112
8115
|
this._workbook.removeStyles(styleKeys);
|
|
8113
8116
|
}
|
|
8117
|
+
/**
|
|
8118
|
+
* Get the workbook's iterative calculation settings.
|
|
8119
|
+
* Missing or invalid settings use the defaults: iteration disabled, 100 iterations and a maximum change of 0.001.
|
|
8120
|
+
* @returns {IWorkbookCalculationSettings} A copy of the normalized workbook calculation settings.
|
|
8121
|
+
* @example
|
|
8122
|
+
* ```ts
|
|
8123
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
8124
|
+
* const settings = fWorkbook.getCalculationSettings();
|
|
8125
|
+
* console.log(settings.iterativeCalculation, settings.maxIterations, settings.maxChange);
|
|
8126
|
+
* ```
|
|
8127
|
+
*/
|
|
8128
|
+
getCalculationSettings() {
|
|
8129
|
+
return this._workbook.getCalculationSettings();
|
|
8130
|
+
}
|
|
8131
|
+
/**
|
|
8132
|
+
* Set iterative calculation settings for the entire workbook through an undoable command.
|
|
8133
|
+
* @param {IWorkbookCalculationSettings} settings The complete calculation settings.
|
|
8134
|
+
* Set `iterativeCalculation` to enable or disable iterative evaluation of circular references.
|
|
8135
|
+
* `maxIterations` must be an integer from 1 to 32767, and `maxChange` must be a finite positive number.
|
|
8136
|
+
* @returns {boolean} Whether the settings command succeeded. Returns false if the workbook cannot be edited or found.
|
|
8137
|
+
* @example
|
|
8138
|
+
* ```ts
|
|
8139
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
8140
|
+
* const success = fWorkbook.setCalculationSettings({
|
|
8141
|
+
* iterativeCalculation: true,
|
|
8142
|
+
* maxIterations: 100,
|
|
8143
|
+
* maxChange: 0.001,
|
|
8144
|
+
* });
|
|
8145
|
+
* console.log('Calculation settings updated:', success);
|
|
8146
|
+
* ```
|
|
8147
|
+
*/
|
|
8148
|
+
setCalculationSettings(settings) {
|
|
8149
|
+
return this._commandService.syncExecuteCommand(_univerjs_sheets.SetWorkbookCalculationSettingsCommand.id, {
|
|
8150
|
+
unitId: this.id,
|
|
8151
|
+
settings
|
|
8152
|
+
});
|
|
8153
|
+
}
|
|
8114
8154
|
};
|
|
8115
8155
|
FWorkbook = __decorate([
|
|
8116
8156
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
@@ -8591,13 +8631,13 @@ var FSheetsEventNameMixin = class extends _univerjs_core_facade.FEventName {
|
|
|
8591
8631
|
_univerjs_core_facade.FEventName.extend(FSheetsEventNameMixin);
|
|
8592
8632
|
|
|
8593
8633
|
//#endregion
|
|
8594
|
-
Object.defineProperty(exports,
|
|
8634
|
+
Object.defineProperty(exports, "FRange", {
|
|
8595
8635
|
enumerable: true,
|
|
8596
8636
|
get: function () {
|
|
8597
8637
|
return FRange;
|
|
8598
8638
|
}
|
|
8599
8639
|
});
|
|
8600
|
-
Object.defineProperty(exports,
|
|
8640
|
+
Object.defineProperty(exports, "FSelection", {
|
|
8601
8641
|
enumerable: true,
|
|
8602
8642
|
get: function () {
|
|
8603
8643
|
return FSelection;
|
|
@@ -8605,19 +8645,19 @@ Object.defineProperty(exports, 'FSelection', {
|
|
|
8605
8645
|
});
|
|
8606
8646
|
exports.FSheetsEnumMixin = FSheetsEnumMixin;
|
|
8607
8647
|
exports.FSheetsEventNameMixin = FSheetsEventNameMixin;
|
|
8608
|
-
Object.defineProperty(exports,
|
|
8648
|
+
Object.defineProperty(exports, "FWorkbook", {
|
|
8609
8649
|
enumerable: true,
|
|
8610
8650
|
get: function () {
|
|
8611
8651
|
return FWorkbook;
|
|
8612
8652
|
}
|
|
8613
8653
|
});
|
|
8614
|
-
Object.defineProperty(exports,
|
|
8654
|
+
Object.defineProperty(exports, "FWorkbookPermission", {
|
|
8615
8655
|
enumerable: true,
|
|
8616
8656
|
get: function () {
|
|
8617
8657
|
return FWorkbookPermission;
|
|
8618
8658
|
}
|
|
8619
8659
|
});
|
|
8620
|
-
Object.defineProperty(exports,
|
|
8660
|
+
Object.defineProperty(exports, "FWorksheet", {
|
|
8621
8661
|
enumerable: true,
|
|
8622
8662
|
get: function () {
|
|
8623
8663
|
return FWorksheet;
|