@qn-pandora/pandora-component 4.1.7 → 4.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.
Files changed (43) hide show
  1. package/CHANGELOG.json +7 -10
  2. package/CHANGELOG.md +5 -5
  3. package/es/components/Drawer/index.d.ts +20 -1
  4. package/es/components/Drawer/index.js +53 -9
  5. package/es/components/Drawer/style.css +8 -0
  6. package/es/components/Drawer/style.less +9 -0
  7. package/es/components/RadioGroup/style.css +7 -0
  8. package/es/components/RadioGroup/style.less +9 -0
  9. package/es/components/Table/ColumnSetting/index.d.ts +16 -0
  10. package/es/components/Table/ColumnSetting/index.js +91 -0
  11. package/es/components/Table/ColumnSetting/style.css +47 -0
  12. package/es/components/Table/ColumnSetting/style.less +46 -0
  13. package/es/components/Table/index.d.ts +27 -2
  14. package/es/components/Table/index.js +127 -3
  15. package/es/components/Table/style.css +4 -0
  16. package/es/components/Table/style.less +7 -0
  17. package/es/constants/language/table/en.js +4 -1
  18. package/es/constants/language/table/type.d.ts +3 -0
  19. package/es/constants/language/table/zh.js +4 -1
  20. package/es/index.css +2891 -2825
  21. package/es/index.less +8 -7
  22. package/es/style/theme.less +5 -0
  23. package/lib/components/Drawer/index.d.ts +20 -1
  24. package/lib/components/Drawer/index.js +53 -9
  25. package/lib/components/Drawer/style.css +8 -0
  26. package/lib/components/Drawer/style.less +9 -0
  27. package/lib/components/RadioGroup/style.css +7 -0
  28. package/lib/components/RadioGroup/style.less +9 -0
  29. package/lib/components/Table/ColumnSetting/index.d.ts +16 -0
  30. package/lib/components/Table/ColumnSetting/index.js +104 -0
  31. package/lib/components/Table/ColumnSetting/style.css +47 -0
  32. package/lib/components/Table/ColumnSetting/style.less +46 -0
  33. package/lib/components/Table/index.d.ts +27 -2
  34. package/lib/components/Table/index.js +126 -2
  35. package/lib/components/Table/style.css +4 -0
  36. package/lib/components/Table/style.less +7 -0
  37. package/lib/constants/language/table/en.js +4 -1
  38. package/lib/constants/language/table/type.d.ts +3 -0
  39. package/lib/constants/language/table/zh.js +4 -1
  40. package/lib/index.css +2293 -2227
  41. package/lib/index.less +3 -2
  42. package/lib/style/theme.less +5 -0
  43. package/package.json +6 -5
@@ -66,15 +66,17 @@ import * as React from 'react';
66
66
  import classnames from 'classnames';
67
67
  import { observer } from 'mobx-react';
68
68
  import { observable, action, computed } from 'mobx';
69
- import { size, xor, union, unionBy, differenceBy, get, isEqual } from 'lodash';
69
+ import { size, xor, union, unionBy, differenceBy, get, isEqual, includes } from 'lodash';
70
70
  import { Table as AntTable, Checkbox } from 'antd';
71
71
  import { ConfigContext } from 'antd/es/config-provider';
72
+ import { toaster as toasterStore } from '@qn-pandora/app-sdk';
72
73
  import { EmptyIcon } from '@qn-pandora/pandora-component-icons';
73
74
  import bind from '../../utils/bind';
74
75
  import { formatString } from '../../utils/language';
75
76
  import { SDK_PREFIX } from '../../constants/style';
76
77
  import { TableLocale } from '../../constants/language/table/type';
77
78
  import { ColumnTag } from './ColumnTag/ColumnTag';
79
+ import ColumnSetting from './ColumnSetting';
78
80
  /**
79
81
  * pandora2.0风格的表格
80
82
  */
@@ -84,6 +86,7 @@ var Table = /** @class */ (function (_super) {
84
86
  var _this = _super !== null && _super.apply(this, arguments) || this;
85
87
  _this.indeterminate = false;
86
88
  _this.checkAll = false;
89
+ _this.hiddenColumn = _this.props.hiddenColumns;
87
90
  return _this;
88
91
  }
89
92
  Table.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
@@ -114,6 +117,9 @@ var Table = /** @class */ (function (_super) {
114
117
  : selectedRowsOfCurrentPage);
115
118
  }
116
119
  }
120
+ if (isEqual(nextProps.hiddenColumns, this.props.hiddenColumns)) {
121
+ this.setHiddenColumn(nextProps.hiddenColumns);
122
+ }
117
123
  };
118
124
  Object.defineProperty(Table.prototype, "selectedRowKeys", {
119
125
  get: function () {
@@ -174,6 +180,88 @@ var Table = /** @class */ (function (_super) {
174
180
  enumerable: true,
175
181
  configurable: true
176
182
  });
183
+ Object.defineProperty(Table.prototype, "columnsSettingOptions", {
184
+ // 列设置 options
185
+ get: function () {
186
+ var options = [];
187
+ var _a = this.props.columns, columns = _a === void 0 ? [] : _a;
188
+ columns.forEach(function (col) {
189
+ if (col.key &&
190
+ col.key.toString().length > 0 &&
191
+ col.configurable !== false) {
192
+ options.push({
193
+ label: col.colTitle || col.title,
194
+ value: col.key.toString()
195
+ });
196
+ }
197
+ });
198
+ return options;
199
+ },
200
+ enumerable: true,
201
+ configurable: true
202
+ });
203
+ Object.defineProperty(Table.prototype, "columnKeys", {
204
+ get: function () {
205
+ var _a = this.props.columns, columns = _a === void 0 ? [] : _a;
206
+ var allKeys = [];
207
+ var unconfigableKeys = [];
208
+ var resetKeys = [];
209
+ columns.forEach(function (col) {
210
+ if (col.key) {
211
+ if (col.configurable === false) {
212
+ unconfigableKeys.push(col.key.toString());
213
+ }
214
+ else {
215
+ resetKeys.push(col.key.toString());
216
+ }
217
+ allKeys.push(col.key.toString());
218
+ }
219
+ });
220
+ return {
221
+ allKeys: allKeys,
222
+ unconfigableKeys: unconfigableKeys,
223
+ resetKeys: resetKeys
224
+ };
225
+ },
226
+ enumerable: true,
227
+ configurable: true
228
+ });
229
+ // 隐藏key
230
+ Table.prototype.handleHideColumnsChange = function (keys) {
231
+ var _a, _b;
232
+ var _c = this.columnKeys, resetKeys = _c.resetKeys, unconfigableKeys = _c.unconfigableKeys;
233
+ if (unconfigableKeys.length === 0 && isEqual(keys, resetKeys)) {
234
+ // 提示。至少需要勾选一列
235
+ return toasterStore.warning(formatString(TableLocale.hide_column_tooltip, this.context.locale));
236
+ }
237
+ this.setHiddenColumn(keys);
238
+ (_b = (_a = this.props).onHiddenColumnsChange) === null || _b === void 0 ? void 0 : _b.call(_a, keys);
239
+ };
240
+ Table.prototype.getColumns = function () {
241
+ var _a = this.props, showColumnSetting = _a.showColumnSetting, columns = _a.columns, columnSettingOverlayClass = _a.columnSettingOverlayClass;
242
+ var hiddenColumn = this.hiddenColumn || [];
243
+ if (!showColumnSetting) {
244
+ return columns;
245
+ }
246
+ // 获取到列设置的options
247
+ var columnsSettingOptions = this.columnsSettingOptions;
248
+ var selectedCols = __spread((columns || []).filter(function (item) {
249
+ if (item.configurable === false || !includes(hiddenColumn, item.key)) {
250
+ return true;
251
+ }
252
+ return false;
253
+ }));
254
+ var length = selectedCols.length;
255
+ if (length > 0) {
256
+ var lastCol = selectedCols.pop();
257
+ var title = (React.createElement("span", { className: SDK_PREFIX + "-last-column-title" },
258
+ lastCol.title,
259
+ React.createElement("span", { className: SDK_PREFIX + "-last-column-setting" },
260
+ React.createElement(ColumnSetting, { options: columnsSettingOptions, hiddenKeys: this.hiddenColumn, onHiddenKeysChange: this.handleHideColumnsChange, overlayClass: columnSettingOverlayClass }))));
261
+ selectedCols.push(__assign(__assign({}, lastCol), { title: title }));
262
+ }
263
+ return selectedCols;
264
+ };
177
265
  Table.prototype.getRowKey = function (row, index) {
178
266
  var rowKey = this.props.rowKey;
179
267
  if (typeof rowKey === 'function') {
@@ -187,6 +275,9 @@ var Table = /** @class */ (function (_super) {
187
275
  Table.prototype.setCheckAll = function (checkAll) {
188
276
  this.checkAll = checkAll;
189
277
  };
278
+ Table.prototype.setHiddenColumn = function (hiddenColumn) {
279
+ this.hiddenColumn = hiddenColumn;
280
+ };
190
281
  // 设置全选checkout的状态
191
282
  Table.prototype.setCheckboxStatus = function (selectedRowsOfCurrentPage, dataSource) {
192
283
  if (selectedRowsOfCurrentPage === void 0) { selectedRowsOfCurrentPage = []; }
@@ -258,9 +349,9 @@ var Table = /** @class */ (function (_super) {
258
349
  Table.prototype.render = function () {
259
350
  var _a, _b;
260
351
  var _this = this;
261
- var _c = this.props, className = _c.className, batchOptions = _c.batchOptions, scroll = _c.scroll, locale = _c.locale, emptyText = _c.emptyText, restProps = __rest(_c, ["className", "batchOptions", "scroll", "locale", "emptyText"]);
352
+ var _c = this.props, className = _c.className, batchOptions = _c.batchOptions, scroll = _c.scroll, locale = _c.locale, emptyText = _c.emptyText, columns = _c.columns, restProps = __rest(_c, ["className", "batchOptions", "scroll", "locale", "emptyText", "columns"]);
262
353
  return (React.createElement("div", null,
263
- React.createElement(AntTable, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale) }, restProps, { className: classnames(SDK_PREFIX + "-table-wrapper", (_a = {}, _a[SDK_PREFIX + "-table-scrollX"] = get(scroll, 'x'), _a), (_b = {}, _b[SDK_PREFIX + "-table-scrollY"] = get(scroll, 'y'), _b), className),
354
+ React.createElement(AntTable, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale), columns: this.getColumns() }, restProps, { className: classnames(SDK_PREFIX + "-table-wrapper", (_a = {}, _a[SDK_PREFIX + "-table-scrollX"] = get(scroll, 'x'), _a), (_b = {}, _b[SDK_PREFIX + "-table-scrollY"] = get(scroll, 'y'), _b), className),
264
355
  // 涉及到权限
265
356
  // getCheckboxProps只能放到tableBatchWrapper里,因为selectedRowKeys在那个组件计算
266
357
  rowSelection: batchOptions && this.props.rowSelection
@@ -294,6 +385,10 @@ var Table = /** @class */ (function (_super) {
294
385
  observable,
295
386
  __metadata("design:type", Object)
296
387
  ], Table.prototype, "checkAll", void 0);
388
+ __decorate([
389
+ observable.ref,
390
+ __metadata("design:type", Object)
391
+ ], Table.prototype, "hiddenColumn", void 0);
297
392
  __decorate([
298
393
  computed,
299
394
  __metadata("design:type", Object),
@@ -319,6 +414,28 @@ var Table = /** @class */ (function (_super) {
319
414
  __metadata("design:type", Object),
320
415
  __metadata("design:paramtypes", [])
321
416
  ], Table.prototype, "emptyTextComp", null);
417
+ __decorate([
418
+ computed,
419
+ __metadata("design:type", Object),
420
+ __metadata("design:paramtypes", [])
421
+ ], Table.prototype, "columnsSettingOptions", null);
422
+ __decorate([
423
+ computed,
424
+ __metadata("design:type", Object),
425
+ __metadata("design:paramtypes", [])
426
+ ], Table.prototype, "columnKeys", null);
427
+ __decorate([
428
+ bind,
429
+ __metadata("design:type", Function),
430
+ __metadata("design:paramtypes", [Array]),
431
+ __metadata("design:returntype", void 0)
432
+ ], Table.prototype, "handleHideColumnsChange", null);
433
+ __decorate([
434
+ bind,
435
+ __metadata("design:type", Function),
436
+ __metadata("design:paramtypes", []),
437
+ __metadata("design:returntype", void 0)
438
+ ], Table.prototype, "getColumns", null);
322
439
  __decorate([
323
440
  bind,
324
441
  __metadata("design:type", Function),
@@ -339,6 +456,13 @@ var Table = /** @class */ (function (_super) {
339
456
  __metadata("design:paramtypes", [Boolean]),
340
457
  __metadata("design:returntype", void 0)
341
458
  ], Table.prototype, "setCheckAll", null);
459
+ __decorate([
460
+ bind,
461
+ action,
462
+ __metadata("design:type", Function),
463
+ __metadata("design:paramtypes", [Array]),
464
+ __metadata("design:returntype", void 0)
465
+ ], Table.prototype, "setHiddenColumn", null);
342
466
  __decorate([
343
467
  bind,
344
468
  __metadata("design:type", Function),
@@ -1722,3 +1722,7 @@ textarea.ant-pagination-options-quick-jumper input {
1722
1722
  .ant-empty .ant-empty-description {
1723
1723
  color: #bfbfbf;
1724
1724
  }
1725
+ .pandora-sdk-last-column-title .pandora-sdk-last-column-setting {
1726
+ position: absolute;
1727
+ right: 12px;
1728
+ }
@@ -312,3 +312,10 @@
312
312
  color: @input-placeholder-color;
313
313
  }
314
314
  }
315
+
316
+ .@{sdk-prefix}-last-column-title {
317
+ .@{sdk-prefix}-last-column-setting {
318
+ position: absolute;
319
+ right: 12px;
320
+ }
321
+ }
@@ -1,4 +1,7 @@
1
1
  export var table_en = {
2
2
  empty: 'No Data',
3
- selected: 'Selected'
3
+ selected: 'Selected',
4
+ check_all: 'Check All',
5
+ search: 'Search',
6
+ hide_column_tooltip: 'At least one column needs to be checked!'
4
7
  };
@@ -1,5 +1,8 @@
1
1
  export interface ITableLocale {
2
2
  empty: string;
3
3
  selected: string;
4
+ check_all: string;
5
+ search: string;
6
+ hide_column_tooltip: string;
4
7
  }
5
8
  export declare const TableLocale: ITableLocale;
@@ -1,4 +1,7 @@
1
1
  export var table_zh = {
2
2
  empty: '暂无数据',
3
- selected: '已选'
3
+ selected: '已选',
4
+ check_all: '全选',
5
+ search: '搜索',
6
+ hide_column_tooltip: '至少需要勾选一列!'
4
7
  };