@qn-pandora/pandora-component 4.4.4 → 4.4.5

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
3
  "entries": [
4
+ {
5
+ "version": "4.4.5",
6
+ "tag": "@qn-pandora/pandora-component_v4.4.5",
7
+ "date": "Thu, 29 Feb 2024 08:29:44 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "2024-02-29发包"
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.4.4` to `^3.4.5`"
17
+ }
18
+ ]
19
+ }
20
+ },
4
21
  {
5
22
  "version": "4.4.4",
6
23
  "tag": "@qn-pandora/pandora-component_v4.4.4",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @qn-pandora/pandora-component
2
2
 
3
- This log was last generated on Tue, 27 Feb 2024 12:57:54 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 29 Feb 2024 08:29:44 GMT and should not be manually modified.
4
+
5
+ ## 4.4.5
6
+ Thu, 29 Feb 2024 08:29:44 GMT
7
+
8
+ ### Patches
9
+
10
+ - 2024-02-29发包
4
11
 
5
12
  ## 4.4.4
6
13
  Tue, 27 Feb 2024 12:57:54 GMT
@@ -84,6 +84,7 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
84
84
  };
85
85
  settingFields: ISaveFieldItem[];
86
86
  UNSAFE_componentWillReceiveProps(nextProps: ITableProps<T>): void;
87
+ componentWillUnmount(): void;
87
88
  get selectedRowKeys(): React.ReactText[];
88
89
  get rowSelection(): TableRowSelection<T> | undefined;
89
90
  get undisabledData(): readonly T[];
@@ -95,9 +96,16 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
95
96
  unconfigableKeys: string[];
96
97
  resetKeys: string[];
97
98
  };
98
- get resizable(): boolean;
99
+ get resizable(): false | ({
100
+ x?: string | number | true | undefined;
101
+ y?: string | number | undefined;
102
+ } & {
103
+ scrollToFirstRowOnChange?: boolean | undefined;
104
+ }) | undefined;
99
105
  get sortable(): boolean;
106
+ updateSettingConfig(columns: Array<IColumnType<T>>): void;
100
107
  initSettingConfig(): void;
108
+ updateSettingFields(columns: Array<IColumnType<T>>, settingFields: ISaveFieldItem[]): void;
101
109
  handleHideColumnsChange(keys: string[]): Promise<void> | undefined;
102
110
  getSortedColumns(): (IKeyValues<any> | undefined)[];
103
111
  getColumns(): (IKeyValues<any> | undefined)[];
@@ -134,10 +134,19 @@ var Table = /** @class */ (function (_super) {
134
134
  this.setHiddenColumn(nextProps.hiddenColumns);
135
135
  }
136
136
  if (nextProps.columns !== this.props.columns) {
137
- this.setColumns((nextProps.scroll && nextProps.draggable === true) ||
138
- nextProps.draggable === ETableSettingType.RESIZE
139
- ? this.getResizeColumns(nextProps.columns)
140
- : nextProps.columns);
137
+ if ((nextProps.scroll && nextProps.draggable === true) ||
138
+ nextProps.draggable === ETableSettingType.RESIZE) {
139
+ this.updateSettingConfig(nextProps.columns);
140
+ this.setColumns(this.getResizeColumns(nextProps.columns));
141
+ }
142
+ else {
143
+ this.setColumns(nextProps.columns || []);
144
+ }
145
+ }
146
+ };
147
+ Table.prototype.componentWillUnmount = function () {
148
+ if (this.props.saveSettingKey) {
149
+ localStorage.setItem(this.props.saveSettingKey, JSON.stringify(this.settingFields));
141
150
  }
142
151
  };
143
152
  Object.defineProperty(Table.prototype, "selectedRowKeys", {
@@ -250,8 +259,9 @@ var Table = /** @class */ (function (_super) {
250
259
  Object.defineProperty(Table.prototype, "resizable", {
251
260
  get: function () {
252
261
  var _a, _b;
253
- return (((_a = this.props) === null || _a === void 0 ? void 0 : _a.draggable) === true ||
254
- ((_b = this.props) === null || _b === void 0 ? void 0 : _b.draggable) === ETableSettingType.RESIZE);
262
+ return ((((_a = this.props) === null || _a === void 0 ? void 0 : _a.draggable) === true ||
263
+ ((_b = this.props) === null || _b === void 0 ? void 0 : _b.draggable) === ETableSettingType.RESIZE) &&
264
+ this.props.scroll);
255
265
  },
256
266
  enumerable: true,
257
267
  configurable: true
@@ -265,95 +275,80 @@ var Table = /** @class */ (function (_super) {
265
275
  enumerable: true,
266
276
  configurable: true
267
277
  });
278
+ Table.prototype.updateSettingConfig = function (columns) {
279
+ this.updateSettingFields(columns, this.settingFields);
280
+ };
268
281
  Table.prototype.initSettingConfig = function () {
269
- var _this = this;
270
- var _a = this.props, saveSettingKey = _a.saveSettingKey, _b = _a.hiddenColumns, hiddenColumns = _b === void 0 ? [] : _b;
282
+ var saveSettingKey = this.props.saveSettingKey;
271
283
  var settingFields = [];
284
+ if (saveSettingKey) {
285
+ var settingStr = localStorage.getItem(saveSettingKey);
286
+ var settingConfig = !!settingStr && JSON.parse(settingStr);
287
+ if (isArray(settingConfig)) {
288
+ settingFields = settingConfig;
289
+ }
290
+ }
291
+ this.updateSettingFields(this.props.columns, settingFields);
292
+ };
293
+ Table.prototype.updateSettingFields = function (columns, settingFields) {
294
+ var _a = this.props.hiddenColumns, hiddenColumns = _a === void 0 ? [] : _a;
272
295
  var sortableColumns = [];
273
296
  var leftColumns = [];
274
297
  var rightColumns = [];
275
298
  var hideKeys = [];
276
- if (saveSettingKey) {
277
- // 支持排序或拖拽
278
- var sizeStr = localStorage.getItem(saveSettingKey);
279
- settingFields = (!!sizeStr && JSON.parse(sizeStr)) || [];
280
- // 已配置的列和实际的对不上
281
- // 可能新增或者删除列的情况
282
- var newSettingFields = [];
283
- if ((settingFields === null || settingFields === void 0 ? void 0 : settingFields.length) && isArray(settingFields)) {
284
- // 已配置列
285
- // 旧类型数据为对象类型,未配置
286
- settingFields.map(function (field) {
287
- var find = _this.columns.find(function (column) { return column.dataIndex === field.field; });
288
- if (find) {
289
- if (field.hide) {
290
- hideKeys.push(field.field);
291
- }
292
- if (!find.fixed) {
293
- sortableColumns.push(field);
294
- }
295
- else if (find.fixed === 'left' || find.fixed === true) {
296
- leftColumns.push(field);
297
- }
298
- else {
299
- rightColumns.push(field);
300
- }
301
- }
302
- });
303
- // 未配置过的列
304
- this.columns
305
- .filter(function (f) { return !settingFields.find(function (field) { return field.field === f.dataIndex; }); })
306
- .map(function (column) {
307
- if (!column.fixed) {
308
- sortableColumns.push({
309
- field: column.dataIndex,
310
- fixed: column.fixed
311
- });
312
- }
313
- else if (column.fixed === 'left' || column.fixed === true) {
314
- leftColumns.push({
315
- field: column.dataIndex,
316
- fixed: column.fixed
317
- });
318
- }
319
- else {
320
- rightColumns.push({
321
- field: column.dataIndex,
322
- fixed: column.fixed
323
- });
324
- }
325
- });
299
+ // 已配置的列和实际的对不上
300
+ // 可能新增或者删除列的情况
301
+ var newSettingFields = [];
302
+ // 已配置列
303
+ // 旧类型数据为对象类型,未配置
304
+ settingFields.map(function (field) {
305
+ var find = columns.find(function (column) { var _a; return ((_a = column) === null || _a === void 0 ? void 0 : _a.dataIndex) === field.field; });
306
+ if (find) {
307
+ if (field.hide) {
308
+ hideKeys.push(field.field);
309
+ }
310
+ if (!find.fixed) {
311
+ sortableColumns.push(field);
312
+ }
313
+ else if (find.fixed === 'left' || find.fixed === true) {
314
+ leftColumns.push(field);
315
+ }
316
+ else {
317
+ rightColumns.push(field);
318
+ }
326
319
  }
327
- else {
328
- // 从未配置过的列
329
- this.columns.map(function (column) {
330
- if (!column.fixed) {
331
- sortableColumns.push({
332
- field: column.dataIndex,
333
- fixed: column.fixed
334
- });
335
- }
336
- else if (column.fixed === 'left' || column.fixed === true) {
337
- leftColumns.push({
338
- field: column.dataIndex,
339
- fixed: column.fixed
340
- });
341
- }
342
- else {
343
- rightColumns.push({
344
- field: column.dataIndex,
345
- fixed: column.fixed
346
- });
347
- }
348
- });
320
+ });
321
+ // 未配置过的列
322
+ columns
323
+ .filter(function (f) { return !settingFields.find(function (field) { return field.field === f.dataIndex; }); })
324
+ .map(function (column) {
325
+ if (column.dataIndex) {
326
+ if (!column.fixed) {
327
+ sortableColumns.push({
328
+ field: column.dataIndex.toString(),
329
+ fixed: column.fixed
330
+ });
331
+ }
332
+ else if (column.fixed === 'left' || column.fixed === true) {
333
+ leftColumns.push({
334
+ field: column.dataIndex.toString(),
335
+ fixed: column.fixed
336
+ });
337
+ }
338
+ else {
339
+ rightColumns.push({
340
+ field: column.dataIndex.toString(),
341
+ fixed: column.fixed
342
+ });
343
+ }
349
344
  }
350
- this.setFixedLeftKeys(leftColumns.map(function (t) { return t.field; }));
351
- this.setFixedRightKeys(rightColumns.map(function (t) { return t.field; }));
352
- this.setSortKeys(sortableColumns.map(function (t) { return t.field; }));
353
- this.setHiddenColumn(__spread(new Set(__spread(hiddenColumns, hideKeys))));
354
- newSettingFields = __spread(leftColumns, sortableColumns, rightColumns);
355
- this.setSettingFields(newSettingFields);
356
- }
345
+ });
346
+ this.setFixedLeftKeys(leftColumns.map(function (t) { return t.field; }));
347
+ this.setFixedRightKeys(rightColumns.map(function (t) { return t.field; }));
348
+ this.setSortKeys(sortableColumns.map(function (t) { return t.field; }));
349
+ this.setHiddenColumn(__spread(new Set(__spread(hiddenColumns, hideKeys))));
350
+ newSettingFields = __spread(leftColumns, sortableColumns, rightColumns);
351
+ this.setSettingFields(newSettingFields);
357
352
  };
358
353
  // 隐藏key
359
354
  Table.prototype.handleHideColumnsChange = function (keys) {
@@ -452,9 +447,6 @@ var Table = /** @class */ (function (_super) {
452
447
  this.sortConfig = __assign(__assign({}, this.sortConfig), { sortKeys: columns });
453
448
  };
454
449
  Table.prototype.setSettingFields = function (columns) {
455
- if (this.props.saveSettingKey) {
456
- localStorage.setItem(this.props.saveSettingKey, JSON.stringify(columns));
457
- }
458
450
  this.settingFields = columns;
459
451
  };
460
452
  Table.prototype.setFixedRightKeys = function (columns) {
@@ -560,18 +552,14 @@ var Table = /** @class */ (function (_super) {
560
552
  };
561
553
  Table.prototype.getResizeColumns = function (columns) {
562
554
  var _this = this;
563
- var fields;
564
- if (this.props.saveSettingKey) {
565
- var sizeStr = localStorage.getItem(this.props.saveSettingKey);
566
- fields = !!sizeStr && JSON.parse(sizeStr);
567
- if (fields) {
568
- columns = columns === null || columns === void 0 ? void 0 : columns.map(function (col) {
569
- var _a;
570
- var dataIndex = get(col, 'dataIndex');
571
- var width = (_a = fields.find(function (f) { return f.field === dataIndex; })) === null || _a === void 0 ? void 0 : _a.width;
572
- return isNumber(width) ? __assign(__assign({}, col), { width: width }) : col;
573
- });
574
- }
555
+ var fields = this.settingFields;
556
+ if ((fields === null || fields === void 0 ? void 0 : fields.length) && isArray(fields)) {
557
+ columns = columns === null || columns === void 0 ? void 0 : columns.map(function (col) {
558
+ var _a;
559
+ var dataIndex = get(col, 'dataIndex');
560
+ var width = (_a = fields === null || fields === void 0 ? void 0 : fields.find(function (f) { return f.field === dataIndex; })) === null || _a === void 0 ? void 0 : _a.width;
561
+ return isNumber(width) ? __assign(__assign({}, col), { width: width }) : col;
562
+ });
575
563
  }
576
564
  var transformColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (it) {
577
565
  if (get(it, 'resizable') && _this.resizable) {
@@ -591,12 +579,13 @@ var Table = /** @class */ (function (_super) {
591
579
  return transformColumns;
592
580
  };
593
581
  Table.prototype.componentDidMount = function () {
594
- this.setColumns(this.resizable && this.props.scroll
595
- ? this.getResizeColumns(this.props.columns)
596
- : this.props.columns);
582
+ var _a;
597
583
  if (this.sortable || this.resizable) {
598
584
  this.initSettingConfig();
599
585
  }
586
+ this.setColumns(this.resizable && ((_a = this.settingFields) === null || _a === void 0 ? void 0 : _a.length)
587
+ ? this.getResizeColumns(this.props.columns)
588
+ : this.props.columns);
600
589
  };
601
590
  Table.prototype.render = function () {
602
591
  var _a, _b;
@@ -608,7 +597,7 @@ var Table = /** @class */ (function (_super) {
608
597
  // getCheckboxProps只能放到tableBatchWrapper里,因为selectedRowKeys在那个组件计算
609
598
  rowSelection: batchOptions && this.props.rowSelection
610
599
  ? this.rowSelection
611
- : this.props.rowSelection, rowClassName: this.getRowClassName, components: __assign(__assign({}, (components || {})), (this.resizable && scroll
600
+ : this.props.rowSelection, rowClassName: this.getRowClassName, components: __assign(__assign({}, (components || {})), (this.resizable
612
601
  ? {
613
602
  header: {
614
603
  cell: ResizableTitle
@@ -704,6 +693,13 @@ var Table = /** @class */ (function (_super) {
704
693
  __metadata("design:type", Object),
705
694
  __metadata("design:paramtypes", [])
706
695
  ], Table.prototype, "sortable", null);
696
+ __decorate([
697
+ bind,
698
+ action,
699
+ __metadata("design:type", Function),
700
+ __metadata("design:paramtypes", [Array]),
701
+ __metadata("design:returntype", void 0)
702
+ ], Table.prototype, "updateSettingConfig", null);
707
703
  __decorate([
708
704
  bind,
709
705
  action,
@@ -711,6 +707,13 @@ var Table = /** @class */ (function (_super) {
711
707
  __metadata("design:paramtypes", []),
712
708
  __metadata("design:returntype", void 0)
713
709
  ], Table.prototype, "initSettingConfig", null);
710
+ __decorate([
711
+ bind,
712
+ action,
713
+ __metadata("design:type", Function),
714
+ __metadata("design:paramtypes", [Array, Array]),
715
+ __metadata("design:returntype", void 0)
716
+ ], Table.prototype, "updateSettingFields", null);
714
717
  __decorate([
715
718
  bind,
716
719
  __metadata("design:type", Function),