@univerjs/sheets-table 1.0.4 → 1.2.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/index.js +175 -180
- package/lib/es/index.js +172 -176
- package/lib/index.js +172 -176
- package/lib/types/index.d.ts +3 -3
- package/lib/types/models/filter-util/record-filter.d.ts +4 -5
- package/lib/types/types/type.d.ts +2 -17
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -131,6 +131,113 @@ let SheetsTableSortStateEnum = /* @__PURE__ */ function(SheetsTableSortStateEnum
|
|
|
131
131
|
return SheetsTableSortStateEnum;
|
|
132
132
|
}({});
|
|
133
133
|
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
136
|
+
function _typeof(o) {
|
|
137
|
+
"@babel/helpers - typeof";
|
|
138
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
139
|
+
return typeof o;
|
|
140
|
+
} : function(o) {
|
|
141
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
142
|
+
}, _typeof(o);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
147
|
+
function toPrimitive(t, r) {
|
|
148
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
149
|
+
var e = t[Symbol.toPrimitive];
|
|
150
|
+
if (void 0 !== e) {
|
|
151
|
+
var i = e.call(t, r || "default");
|
|
152
|
+
if ("object" != _typeof(i)) return i;
|
|
153
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
154
|
+
}
|
|
155
|
+
return ("string" === r ? String : Number)(t);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
160
|
+
function toPropertyKey(t) {
|
|
161
|
+
var i = toPrimitive(t, "string");
|
|
162
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
167
|
+
function _defineProperty(e, r, t) {
|
|
168
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
169
|
+
value: t,
|
|
170
|
+
enumerable: !0,
|
|
171
|
+
configurable: !0,
|
|
172
|
+
writable: !0
|
|
173
|
+
}) : e[r] = t, e;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/models/table-column.ts
|
|
178
|
+
var TableColumn = class {
|
|
179
|
+
constructor(id, name) {
|
|
180
|
+
_defineProperty(this, "dataType", void 0);
|
|
181
|
+
_defineProperty(this, "id", void 0);
|
|
182
|
+
_defineProperty(this, "displayName", void 0);
|
|
183
|
+
_defineProperty(this, "formula", void 0);
|
|
184
|
+
_defineProperty(this, "formulaIsArray", void 0);
|
|
185
|
+
_defineProperty(this, "totalsRowLabel", void 0);
|
|
186
|
+
_defineProperty(this, "totalsRowFunction", void 0);
|
|
187
|
+
_defineProperty(this, "totalsRowFormula", void 0);
|
|
188
|
+
_defineProperty(this, "showFilterButton", void 0);
|
|
189
|
+
_defineProperty(this, "meta", void 0);
|
|
190
|
+
_defineProperty(this, "style", void 0);
|
|
191
|
+
this.id = id;
|
|
192
|
+
this.displayName = name;
|
|
193
|
+
this.dataType = "string";
|
|
194
|
+
this.formula = "";
|
|
195
|
+
this.showFilterButton = true;
|
|
196
|
+
this.meta = {};
|
|
197
|
+
this.style = {};
|
|
198
|
+
}
|
|
199
|
+
getMeta() {
|
|
200
|
+
return this.meta;
|
|
201
|
+
}
|
|
202
|
+
setMeta(meta) {
|
|
203
|
+
this.meta = meta;
|
|
204
|
+
}
|
|
205
|
+
getDisplayName() {
|
|
206
|
+
return this.displayName;
|
|
207
|
+
}
|
|
208
|
+
toJSON() {
|
|
209
|
+
return {
|
|
210
|
+
id: this.id,
|
|
211
|
+
displayName: this.displayName,
|
|
212
|
+
dataType: this.dataType,
|
|
213
|
+
formula: this.formula,
|
|
214
|
+
formulaIsArray: this.formulaIsArray,
|
|
215
|
+
totalsRowLabel: this.totalsRowLabel,
|
|
216
|
+
totalsRowFunction: this.totalsRowFunction,
|
|
217
|
+
totalsRowFormula: this.totalsRowFormula,
|
|
218
|
+
showFilterButton: this.showFilterButton,
|
|
219
|
+
meta: this.meta,
|
|
220
|
+
style: this.style
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
fromJSON(json) {
|
|
224
|
+
this.id = json.id;
|
|
225
|
+
this.displayName = json.displayName;
|
|
226
|
+
this.dataType = json.dataType;
|
|
227
|
+
this.formula = json.formula;
|
|
228
|
+
this.formulaIsArray = json.formulaIsArray;
|
|
229
|
+
this.totalsRowLabel = json.totalsRowLabel;
|
|
230
|
+
this.totalsRowFunction = json.totalsRowFunction;
|
|
231
|
+
this.totalsRowFormula = json.totalsRowFormula;
|
|
232
|
+
this.showFilterButton = json.showFilterButton ?? true;
|
|
233
|
+
this.meta = json.meta;
|
|
234
|
+
this.style = json.style;
|
|
235
|
+
}
|
|
236
|
+
isShowFilterButton() {
|
|
237
|
+
return this.showFilterButton;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
134
241
|
//#endregion
|
|
135
242
|
//#region src/util.ts
|
|
136
243
|
function getColumnName(columnIndex, columnText) {
|
|
@@ -316,113 +423,6 @@ const tableThemeConfig = tableDefaultThemeStyleArr.map((item, index) => {
|
|
|
316
423
|
};
|
|
317
424
|
});
|
|
318
425
|
|
|
319
|
-
//#endregion
|
|
320
|
-
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
321
|
-
function _typeof(o) {
|
|
322
|
-
"@babel/helpers - typeof";
|
|
323
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
324
|
-
return typeof o;
|
|
325
|
-
} : function(o) {
|
|
326
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
327
|
-
}, _typeof(o);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
//#endregion
|
|
331
|
-
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
332
|
-
function toPrimitive(t, r) {
|
|
333
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
334
|
-
var e = t[Symbol.toPrimitive];
|
|
335
|
-
if (void 0 !== e) {
|
|
336
|
-
var i = e.call(t, r || "default");
|
|
337
|
-
if ("object" != _typeof(i)) return i;
|
|
338
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
339
|
-
}
|
|
340
|
-
return ("string" === r ? String : Number)(t);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
//#endregion
|
|
344
|
-
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
345
|
-
function toPropertyKey(t) {
|
|
346
|
-
var i = toPrimitive(t, "string");
|
|
347
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
//#endregion
|
|
351
|
-
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
352
|
-
function _defineProperty(e, r, t) {
|
|
353
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
354
|
-
value: t,
|
|
355
|
-
enumerable: !0,
|
|
356
|
-
configurable: !0,
|
|
357
|
-
writable: !0
|
|
358
|
-
}) : e[r] = t, e;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/models/table-column.ts
|
|
363
|
-
var TableColumn = class {
|
|
364
|
-
constructor(id, name) {
|
|
365
|
-
_defineProperty(this, "dataType", void 0);
|
|
366
|
-
_defineProperty(this, "id", void 0);
|
|
367
|
-
_defineProperty(this, "displayName", void 0);
|
|
368
|
-
_defineProperty(this, "formula", void 0);
|
|
369
|
-
_defineProperty(this, "formulaIsArray", void 0);
|
|
370
|
-
_defineProperty(this, "totalsRowLabel", void 0);
|
|
371
|
-
_defineProperty(this, "totalsRowFunction", void 0);
|
|
372
|
-
_defineProperty(this, "totalsRowFormula", void 0);
|
|
373
|
-
_defineProperty(this, "showFilterButton", void 0);
|
|
374
|
-
_defineProperty(this, "meta", void 0);
|
|
375
|
-
_defineProperty(this, "style", void 0);
|
|
376
|
-
this.id = id;
|
|
377
|
-
this.displayName = name;
|
|
378
|
-
this.dataType = "string";
|
|
379
|
-
this.formula = "";
|
|
380
|
-
this.showFilterButton = true;
|
|
381
|
-
this.meta = {};
|
|
382
|
-
this.style = {};
|
|
383
|
-
}
|
|
384
|
-
getMeta() {
|
|
385
|
-
return this.meta;
|
|
386
|
-
}
|
|
387
|
-
setMeta(meta) {
|
|
388
|
-
this.meta = meta;
|
|
389
|
-
}
|
|
390
|
-
getDisplayName() {
|
|
391
|
-
return this.displayName;
|
|
392
|
-
}
|
|
393
|
-
toJSON() {
|
|
394
|
-
return {
|
|
395
|
-
id: this.id,
|
|
396
|
-
displayName: this.displayName,
|
|
397
|
-
dataType: this.dataType,
|
|
398
|
-
formula: this.formula,
|
|
399
|
-
formulaIsArray: this.formulaIsArray,
|
|
400
|
-
totalsRowLabel: this.totalsRowLabel,
|
|
401
|
-
totalsRowFunction: this.totalsRowFunction,
|
|
402
|
-
totalsRowFormula: this.totalsRowFormula,
|
|
403
|
-
showFilterButton: this.showFilterButton,
|
|
404
|
-
meta: this.meta,
|
|
405
|
-
style: this.style
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
fromJSON(json) {
|
|
409
|
-
this.id = json.id;
|
|
410
|
-
this.displayName = json.displayName;
|
|
411
|
-
this.dataType = json.dataType;
|
|
412
|
-
this.formula = json.formula;
|
|
413
|
-
this.formulaIsArray = json.formulaIsArray;
|
|
414
|
-
this.totalsRowLabel = json.totalsRowLabel;
|
|
415
|
-
this.totalsRowFunction = json.totalsRowFunction;
|
|
416
|
-
this.totalsRowFormula = json.totalsRowFormula;
|
|
417
|
-
this.showFilterButton = json.showFilterButton ?? true;
|
|
418
|
-
this.meta = json.meta;
|
|
419
|
-
this.style = json.style;
|
|
420
|
-
}
|
|
421
|
-
isShowFilterButton() {
|
|
422
|
-
return this.showFilterButton;
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
|
|
426
426
|
//#endregion
|
|
427
427
|
//#region src/const.ts
|
|
428
428
|
/**
|
|
@@ -621,7 +621,6 @@ const getWeekStart = (date) => {
|
|
|
621
621
|
weekStart.setDate(diff);
|
|
622
622
|
return weekStart;
|
|
623
623
|
};
|
|
624
|
-
const perWeek = 6048e5;
|
|
625
624
|
/**
|
|
626
625
|
* The provided date is in the current week.
|
|
627
626
|
* @param {Date} date - The date to compare.
|
|
@@ -641,7 +640,8 @@ const thisWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
641
640
|
*/
|
|
642
641
|
const nextWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
643
642
|
const weekStart = getWeekStart(date);
|
|
644
|
-
const anchorTimeNextWeekStart =
|
|
643
|
+
const anchorTimeNextWeekStart = getWeekStart(anchorTime);
|
|
644
|
+
anchorTimeNextWeekStart.setDate(anchorTimeNextWeekStart.getDate() + 7);
|
|
645
645
|
return weekStart.toDateString() === anchorTimeNextWeekStart.toDateString();
|
|
646
646
|
};
|
|
647
647
|
/**
|
|
@@ -652,7 +652,8 @@ const nextWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
652
652
|
*/
|
|
653
653
|
const lastWeek = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
654
654
|
const weekStart = getWeekStart(date);
|
|
655
|
-
const anchorTimeLastWeekStart =
|
|
655
|
+
const anchorTimeLastWeekStart = getWeekStart(anchorTime);
|
|
656
|
+
anchorTimeLastWeekStart.setDate(anchorTimeLastWeekStart.getDate() - 7);
|
|
656
657
|
return weekStart.toDateString() === anchorTimeLastWeekStart.toDateString();
|
|
657
658
|
};
|
|
658
659
|
/**
|
|
@@ -686,7 +687,7 @@ const nextMonth = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
686
687
|
nextMonthStart.setHours(0, 0, 0, 0);
|
|
687
688
|
nextMonthStart.setMonth(nextMonthStart.getMonth() + 1, 1);
|
|
688
689
|
const monthEnd = new Date(nextMonthStart);
|
|
689
|
-
monthEnd.setMonth(monthEnd.getMonth() + 1
|
|
690
|
+
monthEnd.setMonth(monthEnd.getMonth() + 1);
|
|
690
691
|
const dateTime = date.getTime();
|
|
691
692
|
return dateTime >= nextMonthStart.getTime() && dateTime < monthEnd.getTime();
|
|
692
693
|
};
|
|
@@ -697,9 +698,9 @@ const nextMonth = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
697
698
|
* @returns {boolean} return the date is match
|
|
698
699
|
*/
|
|
699
700
|
const lastMonth = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
700
|
-
const
|
|
701
|
-
const
|
|
702
|
-
|
|
701
|
+
const monthEnd = getMonthStart(anchorTime);
|
|
702
|
+
const lastMonthStart = new Date(monthEnd);
|
|
703
|
+
lastMonthStart.setMonth(lastMonthStart.getMonth() - 1);
|
|
703
704
|
const dateTime = date.getTime();
|
|
704
705
|
return dateTime >= lastMonthStart.getTime() && dateTime < monthEnd.getTime();
|
|
705
706
|
};
|
|
@@ -740,7 +741,7 @@ const nextQuarter = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
740
741
|
const nextQuarterStart = new Date(quarterStart);
|
|
741
742
|
nextQuarterStart.setMonth(nextQuarterStart.getMonth() + 3);
|
|
742
743
|
const nextQuarterEnd = new Date(nextQuarterStart);
|
|
743
|
-
nextQuarterEnd.setMonth(nextQuarterEnd.getMonth() + 3
|
|
744
|
+
nextQuarterEnd.setMonth(nextQuarterEnd.getMonth() + 3);
|
|
744
745
|
const dateTime = date.getTime();
|
|
745
746
|
return dateTime >= nextQuarterStart.getTime() && dateTime < nextQuarterEnd.getTime();
|
|
746
747
|
};
|
|
@@ -754,10 +755,8 @@ const lastQuarter = (date, anchorTime = /* @__PURE__ */ new Date()) => {
|
|
|
754
755
|
const quarterStart = getQuarterStart(anchorTime);
|
|
755
756
|
const lastQuarterStart = new Date(quarterStart);
|
|
756
757
|
lastQuarterStart.setMonth(lastQuarterStart.getMonth() - 3);
|
|
757
|
-
const lastQuarterEnd = new Date(quarterStart);
|
|
758
|
-
lastQuarterEnd.setDate(0);
|
|
759
758
|
const dateTime = date.getTime();
|
|
760
|
-
return dateTime >= lastQuarterStart.getTime() && dateTime <
|
|
759
|
+
return dateTime >= lastQuarterStart.getTime() && dateTime < quarterStart.getTime();
|
|
761
760
|
};
|
|
762
761
|
/**
|
|
763
762
|
* The provided date is in the current year.
|
|
@@ -1340,35 +1339,13 @@ function getTableRecordValue(sheet, row, column) {
|
|
|
1340
1339
|
};
|
|
1341
1340
|
throw new TypeError("Invalid table record cell value.");
|
|
1342
1341
|
}
|
|
1343
|
-
function getTableRecordValueKey(_value) {
|
|
1344
|
-
const value = _value;
|
|
1345
|
-
if (!isRecord(value) || typeof value.type !== "string") throw new TypeError("Invalid table record value.");
|
|
1346
|
-
switch (value.type) {
|
|
1347
|
-
case _univerjs_core.RecordValueType.Blank:
|
|
1348
|
-
if ("value" in value) throw new TypeError("Blank table record values cannot have a value.");
|
|
1349
|
-
return "[\"blank\"]";
|
|
1350
|
-
case _univerjs_core.RecordValueType.String:
|
|
1351
|
-
case _univerjs_core.RecordValueType.Error:
|
|
1352
|
-
if (typeof value.value !== "string") throw new TypeError("Invalid table record value.");
|
|
1353
|
-
return JSON.stringify([value.type, value.value]);
|
|
1354
|
-
case _univerjs_core.RecordValueType.Boolean:
|
|
1355
|
-
if (typeof value.value !== "boolean") throw new TypeError("Invalid table record value.");
|
|
1356
|
-
return JSON.stringify([value.type, value.value]);
|
|
1357
|
-
case _univerjs_core.RecordValueType.Number:
|
|
1358
|
-
case _univerjs_core.RecordValueType.Date:
|
|
1359
|
-
if (typeof value.value !== "number") throw new TypeError("Invalid table record value.");
|
|
1360
|
-
if (!Number.isFinite(value.value)) throw new RangeError("Table record numeric values must be finite.");
|
|
1361
|
-
return JSON.stringify([value.type, value.value === 0 ? 0 : value.value]);
|
|
1362
|
-
default: throw new TypeError("Unknown table record value type.");
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
1342
|
function compileTableRecordFilter(_filter) {
|
|
1366
1343
|
const filter = _filter;
|
|
1367
1344
|
if (!isRecord(filter) || filter.filterType !== "record") throw new TypeError("Invalid table record filter.");
|
|
1368
1345
|
if (filter.mode !== _univerjs_core.FilterSelectionMode.Include && filter.mode !== _univerjs_core.FilterSelectionMode.Exclude || !Array.isArray(filter.values)) throw new TypeError("Invalid table record filter.");
|
|
1369
|
-
const keys = new Set(filter.values.map((value) =>
|
|
1370
|
-
if (filter.mode === _univerjs_core.FilterSelectionMode.Include) return (value) => keys.has(
|
|
1371
|
-
return (value) => !keys.has(
|
|
1346
|
+
const keys = new Set(filter.values.map((value) => (0, _univerjs_core.getRecordValueKey)(value)));
|
|
1347
|
+
if (filter.mode === _univerjs_core.FilterSelectionMode.Include) return (value) => keys.has((0, _univerjs_core.getRecordValueKey)(value));
|
|
1348
|
+
return (value) => !keys.has((0, _univerjs_core.getRecordValueKey)(value));
|
|
1372
1349
|
}
|
|
1373
1350
|
function cloneTableRecordFilter(filter) {
|
|
1374
1351
|
compileTableRecordFilter(filter);
|
|
@@ -1496,7 +1473,7 @@ var TableFilters = class {
|
|
|
1496
1473
|
}
|
|
1497
1474
|
getExecuteFunc(sheet, range, columnIndex, filter) {
|
|
1498
1475
|
if (filter.filterType === "manual") {
|
|
1499
|
-
const valuesSet = new Set(filter.values);
|
|
1476
|
+
const valuesSet = new Set(filter.values.map(String));
|
|
1500
1477
|
return (value) => {
|
|
1501
1478
|
if (value == null) return valuesSet.has(TABLE_FILTER_EMPTY_VALUE);
|
|
1502
1479
|
return valuesSet.has(String(value));
|
|
@@ -1725,10 +1702,7 @@ var Table = class {
|
|
|
1725
1702
|
return this._tableFilters.getFilterStates(range);
|
|
1726
1703
|
}
|
|
1727
1704
|
toJSON() {
|
|
1728
|
-
const columns =
|
|
1729
|
-
this._columns.forEach((column) => {
|
|
1730
|
-
columns.push(column.toJSON());
|
|
1731
|
-
});
|
|
1705
|
+
const columns = this._columnOrder.map((columnId) => this._columns.get(columnId).toJSON());
|
|
1732
1706
|
return {
|
|
1733
1707
|
id: this._id,
|
|
1734
1708
|
name: this._name,
|
|
@@ -1778,7 +1752,7 @@ var Table = class {
|
|
|
1778
1752
|
};
|
|
1779
1753
|
|
|
1780
1754
|
//#endregion
|
|
1781
|
-
//#region \0@oxc-project+runtime@0.
|
|
1755
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
1782
1756
|
function __decorateParam(paramIndex, decorator) {
|
|
1783
1757
|
return function(target, key) {
|
|
1784
1758
|
decorator(target, key, paramIndex);
|
|
@@ -1786,7 +1760,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
1786
1760
|
}
|
|
1787
1761
|
|
|
1788
1762
|
//#endregion
|
|
1789
|
-
//#region \0@oxc-project+runtime@0.
|
|
1763
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
1790
1764
|
function __decorate(decorators, target, key, desc) {
|
|
1791
1765
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1792
1766
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2314,13 +2288,19 @@ const AddSheetTableCommand = {
|
|
|
2314
2288
|
const undos = [];
|
|
2315
2289
|
const { unitId, subUnitId, range } = params;
|
|
2316
2290
|
const header = tableManager.getColumnHeader(unitId, subUnitId, range, localeService.t("sheets-table.columnPrefix"));
|
|
2291
|
+
const options = _univerjs_core.Tools.deepClone(params.options ?? {});
|
|
2292
|
+
options.columns = header.map((name, index) => {
|
|
2293
|
+
var _options$columns;
|
|
2294
|
+
return ((_options$columns = options.columns) === null || _options$columns === void 0 ? void 0 : _options$columns[index]) ?? new TableColumn((0, _univerjs_core.generateRandomId)(), name).toJSON();
|
|
2295
|
+
});
|
|
2317
2296
|
redos.push({
|
|
2318
2297
|
id: AddSheetTableMutation.id,
|
|
2319
2298
|
params: {
|
|
2320
2299
|
...params,
|
|
2321
2300
|
tableId,
|
|
2322
2301
|
name: tableName,
|
|
2323
|
-
header
|
|
2302
|
+
header,
|
|
2303
|
+
options
|
|
2324
2304
|
}
|
|
2325
2305
|
});
|
|
2326
2306
|
undos.push({
|
|
@@ -2416,12 +2396,35 @@ const AddTableThemeCommand = {
|
|
|
2416
2396
|
}
|
|
2417
2397
|
};
|
|
2418
2398
|
|
|
2399
|
+
//#endregion
|
|
2400
|
+
//#region src/commands/mutations/set-table-filter.mutation.ts
|
|
2401
|
+
const SetSheetTableFilterMutation = {
|
|
2402
|
+
id: "sheet.mutation.set-table-filter",
|
|
2403
|
+
type: _univerjs_core.CommandType.MUTATION,
|
|
2404
|
+
handler: (accessor, params) => {
|
|
2405
|
+
const { tableId, unitId, column, tableFilter } = params;
|
|
2406
|
+
const tableManager = accessor.get(TableManager);
|
|
2407
|
+
const table = tableManager.getTable(unitId, tableId);
|
|
2408
|
+
tableManager.addFilter(unitId, tableId, column, tableFilter);
|
|
2409
|
+
if (table) {
|
|
2410
|
+
var _tableManager$toJSON$;
|
|
2411
|
+
const tableFilters = table.getTableFilters();
|
|
2412
|
+
if (params.filterOutRows) tableFilters.setFilterOutRows(params.filterOutRows);
|
|
2413
|
+
else params.filterOutRows = [...tableFilters.getFilterOutRows()];
|
|
2414
|
+
params.subUnitId = table.getSubunitId();
|
|
2415
|
+
params.tableFilteredOutRows = ((_tableManager$toJSON$ = tableManager.toJSON(unitId)[params.subUnitId]) === null || _tableManager$toJSON$ === void 0 ? void 0 : _tableManager$toJSON$.tableFilteredOutRows) ?? [];
|
|
2416
|
+
}
|
|
2417
|
+
return true;
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
|
|
2419
2421
|
//#endregion
|
|
2420
2422
|
//#region src/commands/commands/delete-sheet-table.command.ts
|
|
2421
2423
|
const DeleteSheetTableCommand = {
|
|
2422
2424
|
id: "sheet.command.delete-table",
|
|
2423
2425
|
type: _univerjs_core.CommandType.COMMAND,
|
|
2424
2426
|
handler: (accessor, params) => {
|
|
2427
|
+
var _tableConfig$filters$;
|
|
2425
2428
|
if (!params) return false;
|
|
2426
2429
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
2427
2430
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -2460,6 +2463,17 @@ const DeleteSheetTableCommand = {
|
|
|
2460
2463
|
options: tableConfig.options
|
|
2461
2464
|
}
|
|
2462
2465
|
});
|
|
2466
|
+
(_tableConfig$filters$ = tableConfig.filters.tableColumnFilterList) === null || _tableConfig$filters$ === void 0 || _tableConfig$filters$.forEach((tableFilter, column) => {
|
|
2467
|
+
if (tableFilter) undos.push({
|
|
2468
|
+
id: SetSheetTableFilterMutation.id,
|
|
2469
|
+
params: {
|
|
2470
|
+
unitId: params.unitId,
|
|
2471
|
+
tableId: params.tableId,
|
|
2472
|
+
column,
|
|
2473
|
+
tableFilter
|
|
2474
|
+
}
|
|
2475
|
+
});
|
|
2476
|
+
});
|
|
2463
2477
|
undos.push(...interceptorCommands.undos);
|
|
2464
2478
|
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
2465
2479
|
undoRedoService.pushUndoRedo({
|
|
@@ -2802,28 +2816,6 @@ const SetSheetTableCommand = {
|
|
|
2802
2816
|
}
|
|
2803
2817
|
};
|
|
2804
2818
|
|
|
2805
|
-
//#endregion
|
|
2806
|
-
//#region src/commands/mutations/set-table-filter.mutation.ts
|
|
2807
|
-
const SetSheetTableFilterMutation = {
|
|
2808
|
-
id: "sheet.mutation.set-table-filter",
|
|
2809
|
-
type: _univerjs_core.CommandType.MUTATION,
|
|
2810
|
-
handler: (accessor, params) => {
|
|
2811
|
-
const { tableId, unitId, column, tableFilter } = params;
|
|
2812
|
-
const tableManager = accessor.get(TableManager);
|
|
2813
|
-
const table = tableManager.getTable(unitId, tableId);
|
|
2814
|
-
tableManager.addFilter(unitId, tableId, column, tableFilter);
|
|
2815
|
-
if (table) {
|
|
2816
|
-
var _tableManager$toJSON$;
|
|
2817
|
-
const tableFilters = table.getTableFilters();
|
|
2818
|
-
if (params.filterOutRows) tableFilters.setFilterOutRows(params.filterOutRows);
|
|
2819
|
-
else params.filterOutRows = [...tableFilters.getFilterOutRows()];
|
|
2820
|
-
params.subUnitId = table.getSubunitId();
|
|
2821
|
-
params.tableFilteredOutRows = ((_tableManager$toJSON$ = tableManager.toJSON(unitId)[params.subUnitId]) === null || _tableManager$toJSON$ === void 0 ? void 0 : _tableManager$toJSON$.tableFilteredOutRows) ?? [];
|
|
2822
|
-
}
|
|
2823
|
-
return true;
|
|
2824
|
-
}
|
|
2825
|
-
};
|
|
2826
|
-
|
|
2827
2819
|
//#endregion
|
|
2828
2820
|
//#region src/commands/commands/set-table-filter.command.ts
|
|
2829
2821
|
const SetSheetTableFilterCommand = {
|
|
@@ -3947,7 +3939,7 @@ SheetsTableThemeController = __decorate([
|
|
|
3947
3939
|
//#endregion
|
|
3948
3940
|
//#region package.json
|
|
3949
3941
|
var name = "@univerjs/sheets-table";
|
|
3950
|
-
var version = "1.0
|
|
3942
|
+
var version = "1.2.0";
|
|
3951
3943
|
|
|
3952
3944
|
//#endregion
|
|
3953
3945
|
//#region src/commands/mutations/move-sheet-table.mutation.ts
|
|
@@ -4800,6 +4792,10 @@ let TableFilterController = class TableFilterController extends _univerjs_core.D
|
|
|
4800
4792
|
}));
|
|
4801
4793
|
}
|
|
4802
4794
|
registerFilterChangeEvent() {
|
|
4795
|
+
this.disposeWithMe(this._tableManager.tableDelete$.subscribe(({ unitId, subUnitId }) => {
|
|
4796
|
+
this._refreshTableFilteredOutRows(unitId, subUnitId);
|
|
4797
|
+
this._zebraCrossingCacheController.updateZebraCrossingCache(unitId, subUnitId);
|
|
4798
|
+
}));
|
|
4803
4799
|
this.disposeWithMe(this._tableManager.tableFilterChanged$.subscribe((event) => {
|
|
4804
4800
|
const { unitId, subUnitId, tableId, oldSubUnitId } = event;
|
|
4805
4801
|
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
@@ -4939,21 +4935,21 @@ exports.SheetTableInsertRowCommand = SheetTableInsertRowCommand;
|
|
|
4939
4935
|
exports.SheetTableRemoveColCommand = SheetTableRemoveColCommand;
|
|
4940
4936
|
exports.SheetTableRemoveColumnAtCommand = SheetTableRemoveColumnAtCommand;
|
|
4941
4937
|
exports.SheetTableRemoveRowCommand = SheetTableRemoveRowCommand;
|
|
4942
|
-
Object.defineProperty(exports,
|
|
4938
|
+
Object.defineProperty(exports, "SheetTableService", {
|
|
4943
4939
|
enumerable: true,
|
|
4944
4940
|
get: function () {
|
|
4945
4941
|
return SheetTableService;
|
|
4946
4942
|
}
|
|
4947
4943
|
});
|
|
4948
4944
|
exports.SheetsTableButtonStateEnum = SheetsTableButtonStateEnum;
|
|
4949
|
-
Object.defineProperty(exports,
|
|
4945
|
+
Object.defineProperty(exports, "SheetsTableController", {
|
|
4950
4946
|
enumerable: true,
|
|
4951
4947
|
get: function () {
|
|
4952
4948
|
return SheetsTableController;
|
|
4953
4949
|
}
|
|
4954
4950
|
});
|
|
4955
4951
|
exports.SheetsTableSortStateEnum = SheetsTableSortStateEnum;
|
|
4956
|
-
Object.defineProperty(exports,
|
|
4952
|
+
Object.defineProperty(exports, "SheetsTableThemeController", {
|
|
4957
4953
|
enumerable: true,
|
|
4958
4954
|
get: function () {
|
|
4959
4955
|
return SheetsTableThemeController;
|
|
@@ -4964,7 +4960,7 @@ exports.TableColumnDataTypeEnum = TableColumnDataTypeEnum;
|
|
|
4964
4960
|
exports.TableColumnFilterTypeEnum = TableColumnFilterTypeEnum;
|
|
4965
4961
|
exports.TableConditionTypeEnum = TableConditionTypeEnum;
|
|
4966
4962
|
exports.TableDateCompareTypeEnum = TableDateCompareTypeEnum;
|
|
4967
|
-
Object.defineProperty(exports,
|
|
4963
|
+
Object.defineProperty(exports, "TableManager", {
|
|
4968
4964
|
enumerable: true,
|
|
4969
4965
|
get: function () {
|
|
4970
4966
|
return TableManager;
|
|
@@ -4972,7 +4968,7 @@ Object.defineProperty(exports, 'TableManager', {
|
|
|
4972
4968
|
});
|
|
4973
4969
|
exports.TableNumberCompareTypeEnum = TableNumberCompareTypeEnum;
|
|
4974
4970
|
exports.TableStringCompareTypeEnum = TableStringCompareTypeEnum;
|
|
4975
|
-
Object.defineProperty(exports,
|
|
4971
|
+
Object.defineProperty(exports, "UniverSheetsTablePlugin", {
|
|
4976
4972
|
enumerable: true,
|
|
4977
4973
|
get: function () {
|
|
4978
4974
|
return UniverSheetsTablePlugin;
|
|
@@ -4982,7 +4978,6 @@ exports.compileTableRecordFilter = compileTableRecordFilter;
|
|
|
4982
4978
|
exports.customEmptyThemeWithBorderStyle = customEmptyThemeWithBorderStyle;
|
|
4983
4979
|
exports.getExistingNamesSet = getExistingNamesSet;
|
|
4984
4980
|
exports.getTableRecordValue = getTableRecordValue;
|
|
4985
|
-
exports.getTableRecordValueKey = getTableRecordValueKey;
|
|
4986
4981
|
exports.isColorTableFilter = isColorTableFilter;
|
|
4987
4982
|
exports.isConditionFilter = isConditionFilter;
|
|
4988
4983
|
exports.isManualTableFilter = isManualTableFilter;
|