@univerjs/sheets-table 1.1.0 → 1.3.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 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.153.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.153.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.153.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.153.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
  /**
@@ -1339,35 +1339,13 @@ function getTableRecordValue(sheet, row, column) {
1339
1339
  };
1340
1340
  throw new TypeError("Invalid table record cell value.");
1341
1341
  }
1342
- function getTableRecordValueKey(_value) {
1343
- const value = _value;
1344
- if (!isRecord(value) || typeof value.type !== "string") throw new TypeError("Invalid table record value.");
1345
- switch (value.type) {
1346
- case _univerjs_core.RecordValueType.Blank:
1347
- if ("value" in value) throw new TypeError("Blank table record values cannot have a value.");
1348
- return "[\"blank\"]";
1349
- case _univerjs_core.RecordValueType.String:
1350
- case _univerjs_core.RecordValueType.Error:
1351
- if (typeof value.value !== "string") throw new TypeError("Invalid table record value.");
1352
- return JSON.stringify([value.type, value.value]);
1353
- case _univerjs_core.RecordValueType.Boolean:
1354
- if (typeof value.value !== "boolean") throw new TypeError("Invalid table record value.");
1355
- return JSON.stringify([value.type, value.value]);
1356
- case _univerjs_core.RecordValueType.Number:
1357
- case _univerjs_core.RecordValueType.Date:
1358
- if (typeof value.value !== "number") throw new TypeError("Invalid table record value.");
1359
- if (!Number.isFinite(value.value)) throw new RangeError("Table record numeric values must be finite.");
1360
- return JSON.stringify([value.type, value.value === 0 ? 0 : value.value]);
1361
- default: throw new TypeError("Unknown table record value type.");
1362
- }
1363
- }
1364
1342
  function compileTableRecordFilter(_filter) {
1365
1343
  const filter = _filter;
1366
1344
  if (!isRecord(filter) || filter.filterType !== "record") throw new TypeError("Invalid table record filter.");
1367
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.");
1368
- const keys = new Set(filter.values.map((value) => getTableRecordValueKey(value)));
1369
- if (filter.mode === _univerjs_core.FilterSelectionMode.Include) return (value) => keys.has(getTableRecordValueKey(value));
1370
- return (value) => !keys.has(getTableRecordValueKey(value));
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));
1371
1349
  }
1372
1350
  function cloneTableRecordFilter(filter) {
1373
1351
  compileTableRecordFilter(filter);
@@ -2310,13 +2288,19 @@ const AddSheetTableCommand = {
2310
2288
  const undos = [];
2311
2289
  const { unitId, subUnitId, range } = params;
2312
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
+ });
2313
2296
  redos.push({
2314
2297
  id: AddSheetTableMutation.id,
2315
2298
  params: {
2316
2299
  ...params,
2317
2300
  tableId,
2318
2301
  name: tableName,
2319
- header
2302
+ header,
2303
+ options
2320
2304
  }
2321
2305
  });
2322
2306
  undos.push({
@@ -3955,7 +3939,7 @@ SheetsTableThemeController = __decorate([
3955
3939
  //#endregion
3956
3940
  //#region package.json
3957
3941
  var name = "@univerjs/sheets-table";
3958
- var version = "1.1.0";
3942
+ var version = "1.3.0";
3959
3943
 
3960
3944
  //#endregion
3961
3945
  //#region src/commands/mutations/move-sheet-table.mutation.ts
@@ -4994,7 +4978,6 @@ exports.compileTableRecordFilter = compileTableRecordFilter;
4994
4978
  exports.customEmptyThemeWithBorderStyle = customEmptyThemeWithBorderStyle;
4995
4979
  exports.getExistingNamesSet = getExistingNamesSet;
4996
4980
  exports.getTableRecordValue = getTableRecordValue;
4997
- exports.getTableRecordValueKey = getTableRecordValueKey;
4998
4981
  exports.isColorTableFilter = isColorTableFilter;
4999
4982
  exports.isConditionFilter = isConditionFilter;
5000
4983
  exports.isManualTableFilter = isManualTableFilter;
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BooleanNumber, BorderStyleTypes, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DateSystem, DependentOn, Disposable, ErrorService, FilterSelectionMode, FormulaType, ICommandService, IConfigService, ILogService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RTree, RecordValueType, Rectangle, UniverInstanceType, customNameCharacterCheck, excelSerialToDateTime, generateRandomId, getColorStyle, merge, numfmt, regexp, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
1
+ import { BooleanNumber, BorderStyleTypes, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DateSystem, DependentOn, Disposable, ErrorService, FilterSelectionMode, FormulaType, ICommandService, IConfigService, ILogService, IPermissionService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RTree, RecordValueType, Rectangle, Tools, UniverInstanceType, customNameCharacterCheck, excelSerialToDateTime, generateRandomId, getColorStyle, getRecordValueKey, merge, numfmt, regexp, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import { IActiveDirtyManagerService, IDefinedNamesService, ISheetRowFilteredService, LexerTreeBuilder, RemoveSuperTableMutation, SetSuperTableMutation, extractFormulaError, serializeRange } from "@univerjs/engine-formula";
3
3
  import { AddRangeThemeMutation, CopySheetCommand, IExclusiveRangeService, INTERCEPTOR_POINT, InsertColCommand, InsertColMutation, InsertRowCommand, InsertRowMutation, MoveRangeCommand, RangeThemeStyle, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRangeThemeMutation, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetRangeThemeModel, SheetRangeThemeService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, ZebraCrossingCacheController, checkRangesEditablePermission, getMoveRangeCommandMutations, getMoveRangeUndoRedoMutations, getSheetCommandTarget } from "@univerjs/sheets";
4
4
  import { BehaviorSubject, Subject, filter, switchMap } from "rxjs";
@@ -130,6 +130,113 @@ let SheetsTableSortStateEnum = /* @__PURE__ */ function(SheetsTableSortStateEnum
130
130
  return SheetsTableSortStateEnum;
131
131
  }({});
132
132
 
133
+ //#endregion
134
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
135
+ function _typeof(o) {
136
+ "@babel/helpers - typeof";
137
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
138
+ return typeof o;
139
+ } : function(o) {
140
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
141
+ }, _typeof(o);
142
+ }
143
+
144
+ //#endregion
145
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
146
+ function toPrimitive(t, r) {
147
+ if ("object" != _typeof(t) || !t) return t;
148
+ var e = t[Symbol.toPrimitive];
149
+ if (void 0 !== e) {
150
+ var i = e.call(t, r || "default");
151
+ if ("object" != _typeof(i)) return i;
152
+ throw new TypeError("@@toPrimitive must return a primitive value.");
153
+ }
154
+ return ("string" === r ? String : Number)(t);
155
+ }
156
+
157
+ //#endregion
158
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
159
+ function toPropertyKey(t) {
160
+ var i = toPrimitive(t, "string");
161
+ return "symbol" == _typeof(i) ? i : i + "";
162
+ }
163
+
164
+ //#endregion
165
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
166
+ function _defineProperty(e, r, t) {
167
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
168
+ value: t,
169
+ enumerable: !0,
170
+ configurable: !0,
171
+ writable: !0
172
+ }) : e[r] = t, e;
173
+ }
174
+
175
+ //#endregion
176
+ //#region src/models/table-column.ts
177
+ var TableColumn = class {
178
+ constructor(id, name) {
179
+ _defineProperty(this, "dataType", void 0);
180
+ _defineProperty(this, "id", void 0);
181
+ _defineProperty(this, "displayName", void 0);
182
+ _defineProperty(this, "formula", void 0);
183
+ _defineProperty(this, "formulaIsArray", void 0);
184
+ _defineProperty(this, "totalsRowLabel", void 0);
185
+ _defineProperty(this, "totalsRowFunction", void 0);
186
+ _defineProperty(this, "totalsRowFormula", void 0);
187
+ _defineProperty(this, "showFilterButton", void 0);
188
+ _defineProperty(this, "meta", void 0);
189
+ _defineProperty(this, "style", void 0);
190
+ this.id = id;
191
+ this.displayName = name;
192
+ this.dataType = "string";
193
+ this.formula = "";
194
+ this.showFilterButton = true;
195
+ this.meta = {};
196
+ this.style = {};
197
+ }
198
+ getMeta() {
199
+ return this.meta;
200
+ }
201
+ setMeta(meta) {
202
+ this.meta = meta;
203
+ }
204
+ getDisplayName() {
205
+ return this.displayName;
206
+ }
207
+ toJSON() {
208
+ return {
209
+ id: this.id,
210
+ displayName: this.displayName,
211
+ dataType: this.dataType,
212
+ formula: this.formula,
213
+ formulaIsArray: this.formulaIsArray,
214
+ totalsRowLabel: this.totalsRowLabel,
215
+ totalsRowFunction: this.totalsRowFunction,
216
+ totalsRowFormula: this.totalsRowFormula,
217
+ showFilterButton: this.showFilterButton,
218
+ meta: this.meta,
219
+ style: this.style
220
+ };
221
+ }
222
+ fromJSON(json) {
223
+ this.id = json.id;
224
+ this.displayName = json.displayName;
225
+ this.dataType = json.dataType;
226
+ this.formula = json.formula;
227
+ this.formulaIsArray = json.formulaIsArray;
228
+ this.totalsRowLabel = json.totalsRowLabel;
229
+ this.totalsRowFunction = json.totalsRowFunction;
230
+ this.totalsRowFormula = json.totalsRowFormula;
231
+ this.showFilterButton = json.showFilterButton ?? true;
232
+ this.meta = json.meta;
233
+ this.style = json.style;
234
+ }
235
+ isShowFilterButton() {
236
+ return this.showFilterButton;
237
+ }
238
+ };
239
+
133
240
  //#endregion
134
241
  //#region src/util.ts
135
242
  function getColumnName(columnIndex, columnText) {
@@ -315,113 +422,6 @@ const tableThemeConfig = tableDefaultThemeStyleArr.map((item, index) => {
315
422
  };
316
423
  });
317
424
 
318
- //#endregion
319
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
320
- function _typeof(o) {
321
- "@babel/helpers - typeof";
322
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
323
- return typeof o;
324
- } : function(o) {
325
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
326
- }, _typeof(o);
327
- }
328
-
329
- //#endregion
330
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
331
- function toPrimitive(t, r) {
332
- if ("object" != _typeof(t) || !t) return t;
333
- var e = t[Symbol.toPrimitive];
334
- if (void 0 !== e) {
335
- var i = e.call(t, r || "default");
336
- if ("object" != _typeof(i)) return i;
337
- throw new TypeError("@@toPrimitive must return a primitive value.");
338
- }
339
- return ("string" === r ? String : Number)(t);
340
- }
341
-
342
- //#endregion
343
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
344
- function toPropertyKey(t) {
345
- var i = toPrimitive(t, "string");
346
- return "symbol" == _typeof(i) ? i : i + "";
347
- }
348
-
349
- //#endregion
350
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
351
- function _defineProperty(e, r, t) {
352
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
353
- value: t,
354
- enumerable: !0,
355
- configurable: !0,
356
- writable: !0
357
- }) : e[r] = t, e;
358
- }
359
-
360
- //#endregion
361
- //#region src/models/table-column.ts
362
- var TableColumn = class {
363
- constructor(id, name) {
364
- _defineProperty(this, "dataType", void 0);
365
- _defineProperty(this, "id", void 0);
366
- _defineProperty(this, "displayName", void 0);
367
- _defineProperty(this, "formula", void 0);
368
- _defineProperty(this, "formulaIsArray", void 0);
369
- _defineProperty(this, "totalsRowLabel", void 0);
370
- _defineProperty(this, "totalsRowFunction", void 0);
371
- _defineProperty(this, "totalsRowFormula", void 0);
372
- _defineProperty(this, "showFilterButton", void 0);
373
- _defineProperty(this, "meta", void 0);
374
- _defineProperty(this, "style", void 0);
375
- this.id = id;
376
- this.displayName = name;
377
- this.dataType = "string";
378
- this.formula = "";
379
- this.showFilterButton = true;
380
- this.meta = {};
381
- this.style = {};
382
- }
383
- getMeta() {
384
- return this.meta;
385
- }
386
- setMeta(meta) {
387
- this.meta = meta;
388
- }
389
- getDisplayName() {
390
- return this.displayName;
391
- }
392
- toJSON() {
393
- return {
394
- id: this.id,
395
- displayName: this.displayName,
396
- dataType: this.dataType,
397
- formula: this.formula,
398
- formulaIsArray: this.formulaIsArray,
399
- totalsRowLabel: this.totalsRowLabel,
400
- totalsRowFunction: this.totalsRowFunction,
401
- totalsRowFormula: this.totalsRowFormula,
402
- showFilterButton: this.showFilterButton,
403
- meta: this.meta,
404
- style: this.style
405
- };
406
- }
407
- fromJSON(json) {
408
- this.id = json.id;
409
- this.displayName = json.displayName;
410
- this.dataType = json.dataType;
411
- this.formula = json.formula;
412
- this.formulaIsArray = json.formulaIsArray;
413
- this.totalsRowLabel = json.totalsRowLabel;
414
- this.totalsRowFunction = json.totalsRowFunction;
415
- this.totalsRowFormula = json.totalsRowFormula;
416
- this.showFilterButton = json.showFilterButton ?? true;
417
- this.meta = json.meta;
418
- this.style = json.style;
419
- }
420
- isShowFilterButton() {
421
- return this.showFilterButton;
422
- }
423
- };
424
-
425
425
  //#endregion
426
426
  //#region src/const.ts
427
427
  /**
@@ -1338,35 +1338,13 @@ function getTableRecordValue(sheet, row, column) {
1338
1338
  };
1339
1339
  throw new TypeError("Invalid table record cell value.");
1340
1340
  }
1341
- function getTableRecordValueKey(_value) {
1342
- const value = _value;
1343
- if (!isRecord(value) || typeof value.type !== "string") throw new TypeError("Invalid table record value.");
1344
- switch (value.type) {
1345
- case RecordValueType.Blank:
1346
- if ("value" in value) throw new TypeError("Blank table record values cannot have a value.");
1347
- return "[\"blank\"]";
1348
- case RecordValueType.String:
1349
- case RecordValueType.Error:
1350
- if (typeof value.value !== "string") throw new TypeError("Invalid table record value.");
1351
- return JSON.stringify([value.type, value.value]);
1352
- case RecordValueType.Boolean:
1353
- if (typeof value.value !== "boolean") throw new TypeError("Invalid table record value.");
1354
- return JSON.stringify([value.type, value.value]);
1355
- case RecordValueType.Number:
1356
- case RecordValueType.Date:
1357
- if (typeof value.value !== "number") throw new TypeError("Invalid table record value.");
1358
- if (!Number.isFinite(value.value)) throw new RangeError("Table record numeric values must be finite.");
1359
- return JSON.stringify([value.type, value.value === 0 ? 0 : value.value]);
1360
- default: throw new TypeError("Unknown table record value type.");
1361
- }
1362
- }
1363
1341
  function compileTableRecordFilter(_filter) {
1364
1342
  const filter = _filter;
1365
1343
  if (!isRecord(filter) || filter.filterType !== "record") throw new TypeError("Invalid table record filter.");
1366
1344
  if (filter.mode !== FilterSelectionMode.Include && filter.mode !== FilterSelectionMode.Exclude || !Array.isArray(filter.values)) throw new TypeError("Invalid table record filter.");
1367
- const keys = new Set(filter.values.map((value) => getTableRecordValueKey(value)));
1368
- if (filter.mode === FilterSelectionMode.Include) return (value) => keys.has(getTableRecordValueKey(value));
1369
- return (value) => !keys.has(getTableRecordValueKey(value));
1345
+ const keys = new Set(filter.values.map((value) => getRecordValueKey(value)));
1346
+ if (filter.mode === FilterSelectionMode.Include) return (value) => keys.has(getRecordValueKey(value));
1347
+ return (value) => !keys.has(getRecordValueKey(value));
1370
1348
  }
1371
1349
  function cloneTableRecordFilter(filter) {
1372
1350
  compileTableRecordFilter(filter);
@@ -2309,13 +2287,19 @@ const AddSheetTableCommand = {
2309
2287
  const undos = [];
2310
2288
  const { unitId, subUnitId, range } = params;
2311
2289
  const header = tableManager.getColumnHeader(unitId, subUnitId, range, localeService.t("sheets-table.columnPrefix"));
2290
+ const options = Tools.deepClone(params.options ?? {});
2291
+ options.columns = header.map((name, index) => {
2292
+ var _options$columns;
2293
+ return ((_options$columns = options.columns) === null || _options$columns === void 0 ? void 0 : _options$columns[index]) ?? new TableColumn(generateRandomId(), name).toJSON();
2294
+ });
2312
2295
  redos.push({
2313
2296
  id: AddSheetTableMutation.id,
2314
2297
  params: {
2315
2298
  ...params,
2316
2299
  tableId,
2317
2300
  name: tableName,
2318
- header
2301
+ header,
2302
+ options
2319
2303
  }
2320
2304
  });
2321
2305
  undos.push({
@@ -3954,7 +3938,7 @@ SheetsTableThemeController = __decorate([
3954
3938
  //#endregion
3955
3939
  //#region package.json
3956
3940
  var name = "@univerjs/sheets-table";
3957
- var version = "1.1.0";
3941
+ var version = "1.3.0";
3958
3942
 
3959
3943
  //#endregion
3960
3944
  //#region src/commands/mutations/move-sheet-table.mutation.ts
@@ -4931,4 +4915,4 @@ UniverSheetsTablePlugin = __decorate([
4931
4915
  ], UniverSheetsTablePlugin);
4932
4916
 
4933
4917
  //#endregion
4934
- export { AddSheetTableCommand, AddSheetTableMutation, AddTableThemeCommand, DeleteSheetTableCommand, DeleteSheetTableMutation, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SetSheetTableFilterMutation, SetSheetTableMutation, SetSheetTableSortStateCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableButtonStateEnum, SheetsTableController, SheetsTableSortStateEnum, SheetsTableThemeController, TABLE_FILTER_EMPTY_VALUE, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, compileTableRecordFilter, customEmptyThemeWithBorderStyle, getExistingNamesSet, getTableRecordValue, getTableRecordValueKey, isColorTableFilter, isConditionFilter, isManualTableFilter, isRecordTableFilter, processStyleWithBorderStyle, validateSheetTableName };
4918
+ export { AddSheetTableCommand, AddSheetTableMutation, AddTableThemeCommand, DeleteSheetTableCommand, DeleteSheetTableMutation, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SetSheetTableFilterMutation, SetSheetTableMutation, SetSheetTableSortStateCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableButtonStateEnum, SheetsTableController, SheetsTableSortStateEnum, SheetsTableThemeController, TABLE_FILTER_EMPTY_VALUE, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, compileTableRecordFilter, customEmptyThemeWithBorderStyle, getExistingNamesSet, getTableRecordValue, isColorTableFilter, isConditionFilter, isManualTableFilter, isRecordTableFilter, processStyleWithBorderStyle, validateSheetTableName };