@univerjs/sheets-table 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.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/LICENSE +176 -0
- package/README.md +10 -2
- package/lib/cjs/index.js +89 -25
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/es/index.js +89 -27
- package/lib/es/locale/fa-IR.js +1 -1
- package/lib/index.js +89 -27
- package/lib/locale/fa-IR.js +1 -1
- package/lib/types/commands/commands/set-table-sort-state.command.d.ts +23 -0
- package/lib/types/index.d.ts +3 -2
- package/lib/types/models/filter-util/condition.d.ts +4 -3
- package/lib/types/models/table-filter.d.ts +6 -7
- package/lib/types/types/enum.d.ts +2 -1
- package/lib/types/types/type.d.ts +10 -1
- package/lib/types/util.d.ts +2 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/package.json +8 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
12
|
| --- | --- | :---: | :---: | :---: |
|
|
13
|
-
| `@univerjs/sheets-table` | `UniverSheetsTable` | No |
|
|
13
|
+
| `@univerjs/sheets-table` | `UniverSheetsTable` | No | Yes | Yes |
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -25,7 +25,16 @@ Keep all `@univerjs/*` packages on the same version.
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
|
+
import { LocaleType, mergeLocales, Univer } from '@univerjs/core';
|
|
28
29
|
import { UniverSheetsTablePlugin } from '@univerjs/sheets-table';
|
|
30
|
+
import EnUS from '@univerjs/sheets-table/locale/en-US';
|
|
31
|
+
|
|
32
|
+
const univer = new Univer({
|
|
33
|
+
locale: LocaleType.EN_US,
|
|
34
|
+
locales: {
|
|
35
|
+
[LocaleType.EN_US]: mergeLocales(EnUS),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
29
38
|
|
|
30
39
|
univer.registerPlugin(UniverSheetsTablePlugin);
|
|
31
40
|
```
|
|
@@ -39,4 +48,3 @@ Use this package with `@univerjs/sheets-table-ui` when users need table controls
|
|
|
39
48
|
- [Documentation](https://docs.univer.ai)
|
|
40
49
|
- [NPM package](https://npmjs.com/package/@univerjs/sheets-table)
|
|
41
50
|
- [GitHub repository](https://github.com/dream-num/univer)
|
|
42
|
-
|
package/lib/cjs/index.js
CHANGED
|
@@ -33,6 +33,7 @@ let TableColumnDataTypeEnum = /* @__PURE__ */ function(TableColumnDataTypeEnum)
|
|
|
33
33
|
let TableColumnFilterTypeEnum = /* @__PURE__ */ function(TableColumnFilterTypeEnum) {
|
|
34
34
|
TableColumnFilterTypeEnum["manual"] = "manual";
|
|
35
35
|
TableColumnFilterTypeEnum["condition"] = "condition";
|
|
36
|
+
TableColumnFilterTypeEnum["color"] = "color";
|
|
36
37
|
return TableColumnFilterTypeEnum;
|
|
37
38
|
}({});
|
|
38
39
|
let TableConditionTypeEnum = /* @__PURE__ */ function(TableConditionTypeEnum) {
|
|
@@ -181,6 +182,10 @@ function isManualTableFilter(filter) {
|
|
|
181
182
|
if (!filter) return false;
|
|
182
183
|
return filter.filterType === "manual";
|
|
183
184
|
}
|
|
185
|
+
function isColorTableFilter(filter) {
|
|
186
|
+
if (!filter) return false;
|
|
187
|
+
return filter.filterType === "color";
|
|
188
|
+
}
|
|
184
189
|
/**
|
|
185
190
|
* Get existing names including sheet names, table names and defined names to check for duplicates table name.
|
|
186
191
|
*/
|
|
@@ -1216,11 +1221,11 @@ function getConditionExecuteFunc(filter, calculatedOptions) {
|
|
|
1216
1221
|
default: return (value) => true;
|
|
1217
1222
|
}
|
|
1218
1223
|
}
|
|
1219
|
-
function getCellValueWithConditionType(sheet, row, col, conditionType) {
|
|
1224
|
+
function getCellValueWithConditionType(sheet, row, col, conditionType, dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
1220
1225
|
switch (conditionType) {
|
|
1221
1226
|
case "date": {
|
|
1222
1227
|
const dateNumber = getNumberCellValue(sheet, row, col);
|
|
1223
|
-
return dateNumber ?
|
|
1228
|
+
return dateNumber == null ? null : excelSerialToDateTimeLocal(dateNumber, dateSystem);
|
|
1224
1229
|
}
|
|
1225
1230
|
case "number": return getNumberCellValue(sheet, row, col);
|
|
1226
1231
|
case "string":
|
|
@@ -1256,13 +1261,10 @@ function getNumberCellValue(sheet, row, col) {
|
|
|
1256
1261
|
if (typeof v === "string" && t === _univerjs_core.CellValueType.NUMBER) return Number(sheet.getCellRaw(row, col).v);
|
|
1257
1262
|
return Number(v);
|
|
1258
1263
|
}
|
|
1259
|
-
function
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
if (dayDifference > (leapDayDate.getTime() - baseDate.getTime()) / (1e3 * 3600 * 24)) dayDifference -= 1;
|
|
1264
|
-
if (dayDifference < 0) dayDifference = serial;
|
|
1265
|
-
return new Date(baseDate.getTime() + dayDifference * (1e3 * 3600 * 24));
|
|
1264
|
+
function excelSerialToDateTimeLocal(serial, dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
1265
|
+
const utcDate = (0, _univerjs_core.excelSerialToDateTime)(serial, dateSystem);
|
|
1266
|
+
if (Number.isNaN(utcDate.getTime())) return utcDate;
|
|
1267
|
+
return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate(), utcDate.getUTCHours(), utcDate.getUTCMinutes(), utcDate.getUTCSeconds(), utcDate.getUTCMilliseconds());
|
|
1266
1268
|
}
|
|
1267
1269
|
|
|
1268
1270
|
//#endregion
|
|
@@ -1284,6 +1286,9 @@ var TableFilters = class {
|
|
|
1284
1286
|
sortState
|
|
1285
1287
|
};
|
|
1286
1288
|
}
|
|
1289
|
+
setSortInfo(sortInfo) {
|
|
1290
|
+
this._tableSortInfo = sortInfo;
|
|
1291
|
+
}
|
|
1287
1292
|
getColumnFilter(columnIndex) {
|
|
1288
1293
|
return this._tableColumnFilterList[columnIndex];
|
|
1289
1294
|
}
|
|
@@ -1304,24 +1309,29 @@ var TableFilters = class {
|
|
|
1304
1309
|
getFilterOutRows() {
|
|
1305
1310
|
return this._filterOutRows;
|
|
1306
1311
|
}
|
|
1307
|
-
doFilter(sheet, range) {
|
|
1312
|
+
doFilter(sheet, range, dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
1308
1313
|
const filterOutRows = /* @__PURE__ */ new Set();
|
|
1309
1314
|
const tableColumnFilterList = this._tableColumnFilterList;
|
|
1310
|
-
for (let i = 0; i < tableColumnFilterList.length; i++) if (tableColumnFilterList[i]) this.doColumnFilter(sheet, range, i, filterOutRows);
|
|
1315
|
+
for (let i = 0; i < tableColumnFilterList.length; i++) if (tableColumnFilterList[i]) this.doColumnFilter(sheet, range, i, filterOutRows, dateSystem);
|
|
1311
1316
|
this._filterOutRows = filterOutRows;
|
|
1312
1317
|
return filterOutRows;
|
|
1313
1318
|
}
|
|
1314
|
-
doColumnFilter(sheet, range, columnIndex, filterOutRows) {
|
|
1319
|
+
doColumnFilter(sheet, range, columnIndex, filterOutRows, dateSystem = _univerjs_core.DateSystem.Date1900) {
|
|
1315
1320
|
const filter = this._tableColumnFilterList[columnIndex];
|
|
1316
1321
|
if (filter && sheet) {
|
|
1317
1322
|
const { startRow, endRow, startColumn } = range;
|
|
1318
1323
|
const column = startColumn + columnIndex;
|
|
1319
1324
|
const executeFunc = this.getExecuteFunc(sheet, range, columnIndex, filter);
|
|
1320
1325
|
for (let row = startRow; row <= endRow; row++) {
|
|
1326
|
+
if (isColorTableFilter(filter)) {
|
|
1327
|
+
const cellData = sheet.getCell(row, column);
|
|
1328
|
+
if (!executeFunc(sheet.getComposedCellStyleByCellData(row, column, cellData))) filterOutRows.add(row);
|
|
1329
|
+
continue;
|
|
1330
|
+
}
|
|
1321
1331
|
const conditionType = isConditionFilter(filter) ? filter.filterInfo.conditionType : "string";
|
|
1322
|
-
const cellValue = getCellValueWithConditionType(sheet, row, column, conditionType);
|
|
1332
|
+
const cellValue = getCellValueWithConditionType(sheet, row, column, conditionType, dateSystem);
|
|
1323
1333
|
if (cellValue === null && !executeFunc(cellValue)) filterOutRows.add(row);
|
|
1324
|
-
else if (!executeFunc(getCellValueWithConditionType(sheet, row, column, conditionType))) filterOutRows.add(row);
|
|
1334
|
+
else if (!executeFunc(getCellValueWithConditionType(sheet, row, column, conditionType, dateSystem))) filterOutRows.add(row);
|
|
1325
1335
|
}
|
|
1326
1336
|
}
|
|
1327
1337
|
}
|
|
@@ -1352,9 +1362,20 @@ var TableFilters = class {
|
|
|
1352
1362
|
return valuesSet.has(value);
|
|
1353
1363
|
};
|
|
1354
1364
|
} else if (filter.filterType === "condition") return getConditionExecuteFunc(filter, isNumberDynamicFilter(filter.filterInfo.compareType) ? this._getNumberCalculatedOptions(sheet, range, columnIndex) : void 0);
|
|
1355
|
-
else
|
|
1365
|
+
else if (filter.filterType === "color") {
|
|
1366
|
+
const normalizeColor = (color) => color ? new _univerjs_core.ColorKit(color).toRgbString() : null;
|
|
1367
|
+
if (filter.cellFillColors) {
|
|
1368
|
+
const colors = new Set(filter.cellFillColors.map(normalizeColor));
|
|
1369
|
+
return (style) => colors.has(normalizeColor((0, _univerjs_core.getColorStyle)(style === null || style === void 0 ? void 0 : style.bg)));
|
|
1370
|
+
}
|
|
1371
|
+
if (filter.cellTextColors) {
|
|
1372
|
+
const colors = new Set(filter.cellTextColors.map(normalizeColor));
|
|
1373
|
+
return (style) => colors.has(normalizeColor((0, _univerjs_core.getColorStyle)(style === null || style === void 0 ? void 0 : style.cl) ?? (0, _univerjs_core.getColorStyle)(_univerjs_core.DEFAULT_STYLES.cl)));
|
|
1374
|
+
}
|
|
1375
|
+
} else return (_value) => {
|
|
1356
1376
|
return true;
|
|
1357
1377
|
};
|
|
1378
|
+
return () => true;
|
|
1358
1379
|
}
|
|
1359
1380
|
toJSON() {
|
|
1360
1381
|
return {
|
|
@@ -1672,9 +1693,9 @@ let TableManager = class TableManager extends _univerjs_core.Disposable {
|
|
|
1672
1693
|
tableStyleId: options === null || options === void 0 ? void 0 : options.tableStyleId
|
|
1673
1694
|
});
|
|
1674
1695
|
if (options === null || options === void 0 ? void 0 : options.filters) {
|
|
1675
|
-
|
|
1676
|
-
const worksheet =
|
|
1677
|
-
table.getTableFilters().doFilter(worksheet, range);
|
|
1696
|
+
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
1697
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
1698
|
+
table.getTableFilters().doFilter(worksheet, range, workbook === null || workbook === void 0 ? void 0 : workbook.getDateSystem());
|
|
1678
1699
|
this._tableFilterChanged$.next({
|
|
1679
1700
|
unitId,
|
|
1680
1701
|
subUnitId,
|
|
@@ -1873,7 +1894,7 @@ let TableManager = class TableManager extends _univerjs_core.Disposable {
|
|
|
1873
1894
|
const table = unitMap === null || unitMap === void 0 ? void 0 : unitMap.get(tableId);
|
|
1874
1895
|
if (!table) return;
|
|
1875
1896
|
const subUnitId = table.getSubunitId();
|
|
1876
|
-
const { name, updateRange, rowColOperation, theme, options } = config;
|
|
1897
|
+
const { name, updateRange, rowColOperation, theme, sortInfo, options } = config;
|
|
1877
1898
|
if (name) {
|
|
1878
1899
|
const oldTableName = table.getDisplayName();
|
|
1879
1900
|
table.setDisplayName(name);
|
|
@@ -1898,6 +1919,7 @@ let TableManager = class TableManager extends _univerjs_core.Disposable {
|
|
|
1898
1919
|
oldTheme
|
|
1899
1920
|
});
|
|
1900
1921
|
}
|
|
1922
|
+
if ("sortInfo" in config) table.getTableFilters().setSortInfo(sortInfo);
|
|
1901
1923
|
if (options) {
|
|
1902
1924
|
if (options.showHeader !== void 0) table.setShowHeader(options.showHeader);
|
|
1903
1925
|
}
|
|
@@ -1945,7 +1967,7 @@ let TableManager = class TableManager extends _univerjs_core.Disposable {
|
|
|
1945
1967
|
if (table.filters) {
|
|
1946
1968
|
const tableFilter = tableInstance.getTableFilters();
|
|
1947
1969
|
tableFilter.fromJSON(table.filters);
|
|
1948
|
-
tableFilter.doFilter(sheet, tableInstance.getTableFilterRange());
|
|
1970
|
+
tableFilter.doFilter(sheet, tableInstance.getTableFilterRange(), target.workbook.getDateSystem());
|
|
1949
1971
|
}
|
|
1950
1972
|
tableInstance.setSubunitId(subUnitId);
|
|
1951
1973
|
unitMap.set(table.id, tableInstance);
|
|
@@ -2454,10 +2476,13 @@ const SetSheetTableFilterCommand = {
|
|
|
2454
2476
|
id: "sheet.command.set-table-filter",
|
|
2455
2477
|
type: _univerjs_core.CommandType.COMMAND,
|
|
2456
2478
|
handler: (accessor, params) => {
|
|
2479
|
+
var _tableManager$getTabl;
|
|
2457
2480
|
if (!params) return false;
|
|
2458
2481
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
2459
2482
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
2483
|
+
const tableManager = accessor.get(TableManager);
|
|
2460
2484
|
const tableId = params.tableId || (0, _univerjs_core.generateRandomId)();
|
|
2485
|
+
const previousFilter = (_tableManager$getTabl = tableManager.getTable(params.unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getTableFilterColumn(params.column);
|
|
2461
2486
|
const redos = [];
|
|
2462
2487
|
const undos = [];
|
|
2463
2488
|
redos.push({
|
|
@@ -2472,7 +2497,7 @@ const SetSheetTableFilterCommand = {
|
|
|
2472
2497
|
params: {
|
|
2473
2498
|
...params,
|
|
2474
2499
|
tableId,
|
|
2475
|
-
tableFilter:
|
|
2500
|
+
tableFilter: previousFilter
|
|
2476
2501
|
}
|
|
2477
2502
|
});
|
|
2478
2503
|
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
@@ -2487,6 +2512,42 @@ const SetSheetTableFilterCommand = {
|
|
|
2487
2512
|
}
|
|
2488
2513
|
};
|
|
2489
2514
|
|
|
2515
|
+
//#endregion
|
|
2516
|
+
//#region src/commands/commands/set-table-sort-state.command.ts
|
|
2517
|
+
const SetSheetTableSortStateCommand = {
|
|
2518
|
+
id: "sheet.command.set-table-sort-state",
|
|
2519
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
2520
|
+
handler: (accessor, params) => {
|
|
2521
|
+
if (!params) return false;
|
|
2522
|
+
const table = accessor.get(TableManager).getTable(params.unitId, params.tableId);
|
|
2523
|
+
if (!table) return false;
|
|
2524
|
+
const previousSortInfo = table.getTableFilters().toJSON().tableSortInfo;
|
|
2525
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
2526
|
+
const mutationParams = {
|
|
2527
|
+
unitId: params.unitId,
|
|
2528
|
+
subUnitId: table.getSubunitId(),
|
|
2529
|
+
tableId: params.tableId,
|
|
2530
|
+
config: { sortInfo: params.sortInfo }
|
|
2531
|
+
};
|
|
2532
|
+
if (!commandService.syncExecuteCommand(SetSheetTableMutation.id, mutationParams)) return false;
|
|
2533
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
2534
|
+
unitID: params.unitId,
|
|
2535
|
+
undoMutations: [{
|
|
2536
|
+
id: SetSheetTableMutation.id,
|
|
2537
|
+
params: {
|
|
2538
|
+
...mutationParams,
|
|
2539
|
+
config: { sortInfo: previousSortInfo }
|
|
2540
|
+
}
|
|
2541
|
+
}],
|
|
2542
|
+
redoMutations: [{
|
|
2543
|
+
id: SetSheetTableMutation.id,
|
|
2544
|
+
params: mutationParams
|
|
2545
|
+
}]
|
|
2546
|
+
});
|
|
2547
|
+
return true;
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
|
|
2490
2551
|
//#endregion
|
|
2491
2552
|
//#region src/controllers/sheets-table.controller.ts
|
|
2492
2553
|
let SheetsTableController = class SheetsTableController extends _univerjs_core.Disposable {
|
|
@@ -3498,7 +3559,7 @@ SheetsTableThemeController = __decorate([
|
|
|
3498
3559
|
//#endregion
|
|
3499
3560
|
//#region package.json
|
|
3500
3561
|
var name = "@univerjs/sheets-table";
|
|
3501
|
-
var version = "1.0.0-
|
|
3562
|
+
var version = "1.0.0-rc.0";
|
|
3502
3563
|
|
|
3503
3564
|
//#endregion
|
|
3504
3565
|
//#region src/controllers/sheet-table-formula.controller.ts
|
|
@@ -4172,12 +4233,12 @@ let TableFilterController = class TableFilterController extends _univerjs_core.D
|
|
|
4172
4233
|
}
|
|
4173
4234
|
registerFilterChangeEvent() {
|
|
4174
4235
|
this.disposeWithMe(this._tableManager.tableFilterChanged$.subscribe((event) => {
|
|
4175
|
-
var _this$_univerInstance;
|
|
4176
4236
|
const { unitId, subUnitId, tableId } = event;
|
|
4177
|
-
const
|
|
4237
|
+
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
4238
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
4178
4239
|
const table = this._tableManager.getTable(unitId, tableId);
|
|
4179
4240
|
if (!worksheet || !table) return;
|
|
4180
|
-
table.getTableFilters().doFilter(worksheet, table.getTableFilterRange());
|
|
4241
|
+
table.getTableFilters().doFilter(worksheet, table.getTableFilterRange(), workbook === null || workbook === void 0 ? void 0 : workbook.getDateSystem());
|
|
4181
4242
|
this._refreshTableFilteredOutRows(unitId, subUnitId);
|
|
4182
4243
|
this._zebraCrossingCacheController.updateZebraCrossingCache(unitId, subUnitId);
|
|
4183
4244
|
}));
|
|
@@ -4255,6 +4316,7 @@ let UniverSheetsTablePlugin = class UniverSheetsTablePlugin extends _univerjs_co
|
|
|
4255
4316
|
DeleteSheetTableMutation,
|
|
4256
4317
|
SetSheetTableFilterMutation,
|
|
4257
4318
|
SetSheetTableFilterCommand,
|
|
4319
|
+
SetSheetTableSortStateCommand,
|
|
4258
4320
|
SetSheetTableCommand,
|
|
4259
4321
|
SetSheetTableMutation,
|
|
4260
4322
|
AddTableThemeCommand,
|
|
@@ -4292,6 +4354,7 @@ exports.SetSheetTableCommand = SetSheetTableCommand;
|
|
|
4292
4354
|
exports.SetSheetTableFilterCommand = SetSheetTableFilterCommand;
|
|
4293
4355
|
exports.SetSheetTableFilterMutation = SetSheetTableFilterMutation;
|
|
4294
4356
|
exports.SetSheetTableMutation = SetSheetTableMutation;
|
|
4357
|
+
exports.SetSheetTableSortStateCommand = SetSheetTableSortStateCommand;
|
|
4295
4358
|
exports.SheetTableInsertColCommand = SheetTableInsertColCommand;
|
|
4296
4359
|
exports.SheetTableInsertColumnAtCommand = SheetTableInsertColumnAtCommand;
|
|
4297
4360
|
exports.SheetTableInsertRowAtCommand = SheetTableInsertRowAtCommand;
|
|
@@ -4340,6 +4403,7 @@ Object.defineProperty(exports, 'UniverSheetsTablePlugin', {
|
|
|
4340
4403
|
});
|
|
4341
4404
|
exports.customEmptyThemeWithBorderStyle = customEmptyThemeWithBorderStyle;
|
|
4342
4405
|
exports.getExistingNamesSet = getExistingNamesSet;
|
|
4406
|
+
exports.isColorTableFilter = isColorTableFilter;
|
|
4343
4407
|
exports.isConditionFilter = isConditionFilter;
|
|
4344
4408
|
exports.isManualTableFilter = isManualTableFilter;
|
|
4345
4409
|
exports.processStyleWithBorderStyle = processStyleWithBorderStyle;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const locale = { "sheets-table": {
|
|
4
4
|
columnPrefix: "ستون",
|
|
5
5
|
tablePrefix: "جدول",
|
|
6
|
-
tableNameError: "
|
|
6
|
+
tableNameError: "نام جدول نمیتواند شامل فاصله باشد، نمیتواند با عدد شروع شود و نمیتواند با نام جدولهای موجود تکراری باشد"
|
|
7
7
|
} };
|
|
8
8
|
|
|
9
9
|
//#endregion
|