@qn-pandora/pandora-component 4.1.6 → 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 (55) hide show
  1. package/CHANGELOG.json +20 -0
  2. package/CHANGELOG.md +8 -1
  3. package/es/components/Collapse/index.js +3 -2
  4. package/es/components/Collapse/style.css +1 -0
  5. package/es/components/Collapse/style.less +1 -0
  6. package/es/components/Descriptions/style.css +1 -0
  7. package/es/components/Descriptions/style.less +1 -0
  8. package/es/components/Drawer/index.d.ts +20 -1
  9. package/es/components/Drawer/index.js +53 -9
  10. package/es/components/Drawer/style.css +8 -0
  11. package/es/components/Drawer/style.less +9 -0
  12. package/es/components/RadioGroup/style.css +7 -0
  13. package/es/components/RadioGroup/style.less +9 -0
  14. package/es/components/Table/ColumnSetting/index.d.ts +16 -0
  15. package/es/components/Table/ColumnSetting/index.js +91 -0
  16. package/es/components/Table/ColumnSetting/style.css +47 -0
  17. package/es/components/Table/ColumnSetting/style.less +46 -0
  18. package/es/components/Table/index.d.ts +27 -2
  19. package/es/components/Table/index.js +127 -3
  20. package/es/components/Table/style.css +4 -0
  21. package/es/components/Table/style.less +7 -0
  22. package/es/constants/language/datetime/en.js +37 -37
  23. package/es/constants/language/table/en.js +4 -1
  24. package/es/constants/language/table/type.d.ts +3 -0
  25. package/es/constants/language/table/zh.js +4 -1
  26. package/es/index.css +108 -40
  27. package/es/index.less +4 -3
  28. package/es/style/theme.less +13 -2
  29. package/lib/components/Collapse/index.js +3 -2
  30. package/lib/components/Collapse/style.css +1 -0
  31. package/lib/components/Collapse/style.less +1 -0
  32. package/lib/components/Descriptions/style.css +1 -0
  33. package/lib/components/Descriptions/style.less +1 -0
  34. package/lib/components/Drawer/index.d.ts +20 -1
  35. package/lib/components/Drawer/index.js +53 -9
  36. package/lib/components/Drawer/style.css +8 -0
  37. package/lib/components/Drawer/style.less +9 -0
  38. package/lib/components/RadioGroup/style.css +7 -0
  39. package/lib/components/RadioGroup/style.less +9 -0
  40. package/lib/components/Table/ColumnSetting/index.d.ts +16 -0
  41. package/lib/components/Table/ColumnSetting/index.js +104 -0
  42. package/lib/components/Table/ColumnSetting/style.css +47 -0
  43. package/lib/components/Table/ColumnSetting/style.less +46 -0
  44. package/lib/components/Table/index.d.ts +27 -2
  45. package/lib/components/Table/index.js +126 -2
  46. package/lib/components/Table/style.css +4 -0
  47. package/lib/components/Table/style.less +7 -0
  48. package/lib/constants/language/datetime/en.js +37 -37
  49. package/lib/constants/language/table/en.js +4 -1
  50. package/lib/constants/language/table/type.d.ts +3 -0
  51. package/lib/constants/language/table/zh.js +4 -1
  52. package/lib/index.css +3481 -3413
  53. package/lib/index.less +4 -3
  54. package/lib/style/theme.less +13 -2
  55. package/package.json +5 -4
@@ -81,12 +81,14 @@ var mobx_1 = require("mobx");
81
81
  var lodash_1 = require("lodash");
82
82
  var antd_1 = require("antd");
83
83
  var config_provider_1 = require("antd/es/config-provider");
84
+ var app_sdk_1 = require("@qn-pandora/app-sdk");
84
85
  var pandora_component_icons_1 = require("@qn-pandora/pandora-component-icons");
85
86
  var bind_1 = __importDefault(require("../../utils/bind"));
86
87
  var language_1 = require("../../utils/language");
87
88
  var style_1 = require("../../constants/style");
88
89
  var type_1 = require("../../constants/language/table/type");
89
90
  var ColumnTag_1 = require("./ColumnTag/ColumnTag");
91
+ var ColumnSetting_1 = __importDefault(require("./ColumnSetting"));
90
92
  /**
91
93
  * pandora2.0风格的表格
92
94
  */
@@ -96,6 +98,7 @@ var Table = /** @class */ (function (_super) {
96
98
  var _this = _super !== null && _super.apply(this, arguments) || this;
97
99
  _this.indeterminate = false;
98
100
  _this.checkAll = false;
101
+ _this.hiddenColumn = _this.props.hiddenColumns;
99
102
  return _this;
100
103
  }
101
104
  Table.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
@@ -126,6 +129,9 @@ var Table = /** @class */ (function (_super) {
126
129
  : selectedRowsOfCurrentPage);
127
130
  }
128
131
  }
132
+ if (lodash_1.isEqual(nextProps.hiddenColumns, this.props.hiddenColumns)) {
133
+ this.setHiddenColumn(nextProps.hiddenColumns);
134
+ }
129
135
  };
130
136
  Object.defineProperty(Table.prototype, "selectedRowKeys", {
131
137
  get: function () {
@@ -186,6 +192,88 @@ var Table = /** @class */ (function (_super) {
186
192
  enumerable: true,
187
193
  configurable: true
188
194
  });
195
+ Object.defineProperty(Table.prototype, "columnsSettingOptions", {
196
+ // 列设置 options
197
+ get: function () {
198
+ var options = [];
199
+ var _a = this.props.columns, columns = _a === void 0 ? [] : _a;
200
+ columns.forEach(function (col) {
201
+ if (col.key &&
202
+ col.key.toString().length > 0 &&
203
+ col.configurable !== false) {
204
+ options.push({
205
+ label: col.colTitle || col.title,
206
+ value: col.key.toString()
207
+ });
208
+ }
209
+ });
210
+ return options;
211
+ },
212
+ enumerable: true,
213
+ configurable: true
214
+ });
215
+ Object.defineProperty(Table.prototype, "columnKeys", {
216
+ get: function () {
217
+ var _a = this.props.columns, columns = _a === void 0 ? [] : _a;
218
+ var allKeys = [];
219
+ var unconfigableKeys = [];
220
+ var resetKeys = [];
221
+ columns.forEach(function (col) {
222
+ if (col.key) {
223
+ if (col.configurable === false) {
224
+ unconfigableKeys.push(col.key.toString());
225
+ }
226
+ else {
227
+ resetKeys.push(col.key.toString());
228
+ }
229
+ allKeys.push(col.key.toString());
230
+ }
231
+ });
232
+ return {
233
+ allKeys: allKeys,
234
+ unconfigableKeys: unconfigableKeys,
235
+ resetKeys: resetKeys
236
+ };
237
+ },
238
+ enumerable: true,
239
+ configurable: true
240
+ });
241
+ // 隐藏key
242
+ Table.prototype.handleHideColumnsChange = function (keys) {
243
+ var _a, _b;
244
+ var _c = this.columnKeys, resetKeys = _c.resetKeys, unconfigableKeys = _c.unconfigableKeys;
245
+ if (unconfigableKeys.length === 0 && lodash_1.isEqual(keys, resetKeys)) {
246
+ // 提示。至少需要勾选一列
247
+ return app_sdk_1.toaster.warning(language_1.formatString(type_1.TableLocale.hide_column_tooltip, this.context.locale));
248
+ }
249
+ this.setHiddenColumn(keys);
250
+ (_b = (_a = this.props).onHiddenColumnsChange) === null || _b === void 0 ? void 0 : _b.call(_a, keys);
251
+ };
252
+ Table.prototype.getColumns = function () {
253
+ var _a = this.props, showColumnSetting = _a.showColumnSetting, columns = _a.columns, columnSettingOverlayClass = _a.columnSettingOverlayClass;
254
+ var hiddenColumn = this.hiddenColumn || [];
255
+ if (!showColumnSetting) {
256
+ return columns;
257
+ }
258
+ // 获取到列设置的options
259
+ var columnsSettingOptions = this.columnsSettingOptions;
260
+ var selectedCols = __spread((columns || []).filter(function (item) {
261
+ if (item.configurable === false || !lodash_1.includes(hiddenColumn, item.key)) {
262
+ return true;
263
+ }
264
+ return false;
265
+ }));
266
+ var length = selectedCols.length;
267
+ if (length > 0) {
268
+ var lastCol = selectedCols.pop();
269
+ var title = (React.createElement("span", { className: style_1.SDK_PREFIX + "-last-column-title" },
270
+ lastCol.title,
271
+ React.createElement("span", { className: style_1.SDK_PREFIX + "-last-column-setting" },
272
+ React.createElement(ColumnSetting_1.default, { options: columnsSettingOptions, hiddenKeys: this.hiddenColumn, onHiddenKeysChange: this.handleHideColumnsChange, overlayClass: columnSettingOverlayClass }))));
273
+ selectedCols.push(__assign(__assign({}, lastCol), { title: title }));
274
+ }
275
+ return selectedCols;
276
+ };
189
277
  Table.prototype.getRowKey = function (row, index) {
190
278
  var rowKey = this.props.rowKey;
191
279
  if (typeof rowKey === 'function') {
@@ -199,6 +287,9 @@ var Table = /** @class */ (function (_super) {
199
287
  Table.prototype.setCheckAll = function (checkAll) {
200
288
  this.checkAll = checkAll;
201
289
  };
290
+ Table.prototype.setHiddenColumn = function (hiddenColumn) {
291
+ this.hiddenColumn = hiddenColumn;
292
+ };
202
293
  // 设置全选checkout的状态
203
294
  Table.prototype.setCheckboxStatus = function (selectedRowsOfCurrentPage, dataSource) {
204
295
  if (selectedRowsOfCurrentPage === void 0) { selectedRowsOfCurrentPage = []; }
@@ -270,9 +361,9 @@ var Table = /** @class */ (function (_super) {
270
361
  Table.prototype.render = function () {
271
362
  var _a, _b;
272
363
  var _this = this;
273
- 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"]);
364
+ 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"]);
274
365
  return (React.createElement("div", null,
275
- React.createElement(antd_1.Table, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale) }, restProps, { className: classnames_1.default(style_1.SDK_PREFIX + "-table-wrapper", (_a = {}, _a[style_1.SDK_PREFIX + "-table-scrollX"] = lodash_1.get(scroll, 'x'), _a), (_b = {}, _b[style_1.SDK_PREFIX + "-table-scrollY"] = lodash_1.get(scroll, 'y'), _b), className),
366
+ React.createElement(antd_1.Table, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale), columns: this.getColumns() }, restProps, { className: classnames_1.default(style_1.SDK_PREFIX + "-table-wrapper", (_a = {}, _a[style_1.SDK_PREFIX + "-table-scrollX"] = lodash_1.get(scroll, 'x'), _a), (_b = {}, _b[style_1.SDK_PREFIX + "-table-scrollY"] = lodash_1.get(scroll, 'y'), _b), className),
276
367
  // 涉及到权限
277
368
  // getCheckboxProps只能放到tableBatchWrapper里,因为selectedRowKeys在那个组件计算
278
369
  rowSelection: batchOptions && this.props.rowSelection
@@ -306,6 +397,10 @@ var Table = /** @class */ (function (_super) {
306
397
  mobx_1.observable,
307
398
  __metadata("design:type", Object)
308
399
  ], Table.prototype, "checkAll", void 0);
400
+ __decorate([
401
+ mobx_1.observable.ref,
402
+ __metadata("design:type", Object)
403
+ ], Table.prototype, "hiddenColumn", void 0);
309
404
  __decorate([
310
405
  mobx_1.computed,
311
406
  __metadata("design:type", Object),
@@ -331,6 +426,28 @@ var Table = /** @class */ (function (_super) {
331
426
  __metadata("design:type", Object),
332
427
  __metadata("design:paramtypes", [])
333
428
  ], Table.prototype, "emptyTextComp", null);
429
+ __decorate([
430
+ mobx_1.computed,
431
+ __metadata("design:type", Object),
432
+ __metadata("design:paramtypes", [])
433
+ ], Table.prototype, "columnsSettingOptions", null);
434
+ __decorate([
435
+ mobx_1.computed,
436
+ __metadata("design:type", Object),
437
+ __metadata("design:paramtypes", [])
438
+ ], Table.prototype, "columnKeys", null);
439
+ __decorate([
440
+ bind_1.default,
441
+ __metadata("design:type", Function),
442
+ __metadata("design:paramtypes", [Array]),
443
+ __metadata("design:returntype", void 0)
444
+ ], Table.prototype, "handleHideColumnsChange", null);
445
+ __decorate([
446
+ bind_1.default,
447
+ __metadata("design:type", Function),
448
+ __metadata("design:paramtypes", []),
449
+ __metadata("design:returntype", void 0)
450
+ ], Table.prototype, "getColumns", null);
334
451
  __decorate([
335
452
  bind_1.default,
336
453
  __metadata("design:type", Function),
@@ -351,6 +468,13 @@ var Table = /** @class */ (function (_super) {
351
468
  __metadata("design:paramtypes", [Boolean]),
352
469
  __metadata("design:returntype", void 0)
353
470
  ], Table.prototype, "setCheckAll", null);
471
+ __decorate([
472
+ bind_1.default,
473
+ mobx_1.action,
474
+ __metadata("design:type", Function),
475
+ __metadata("design:paramtypes", [Array]),
476
+ __metadata("design:returntype", void 0)
477
+ ], Table.prototype, "setHiddenColumn", null);
354
478
  __decorate([
355
479
  bind_1.default,
356
480
  __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,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.datetime_en = {
4
- title: 'Time range',
5
- clear: 'Clear custom',
4
+ title: 'Time Range',
5
+ clear: 'Clear Custom',
6
6
  clart_text: 'Click to apply the global time range',
7
7
  confirm: 'Confirm',
8
8
  range: {
9
- title: 'Date & Time Range',
9
+ title: 'Absolute Time',
10
10
  beforeTime: 'Before',
11
11
  afterTime: 'Since',
12
12
  betweenTime: 'Between',
@@ -15,45 +15,45 @@ exports.datetime_en = {
15
15
  },
16
16
  preset: {
17
17
  title: 'Presets',
18
- m5: 'Last 5 minutes',
19
- m15: 'Last 15 minutes',
20
- m30: 'Last 30 minutes',
21
- m60: 'Last 60 minutes',
22
- h3: 'Last 3 hours',
23
- h4: 'Last 4 hours',
24
- h6: 'Last 6 hours',
25
- h12: 'Last 12 hours',
26
- h24: 'Last 24 hours',
27
- d3: 'Last 3 days',
28
- d7: 'Last 7 days',
29
- d30: 'Last 30 days',
18
+ m5: 'Last 5 Minutes',
19
+ m15: 'Last 15 Minutes',
20
+ m30: 'Last 30 Minutes',
21
+ m60: 'Last 60 Minutes',
22
+ h3: 'Last 3 Hours',
23
+ h4: 'Last 4 Hours',
24
+ h6: 'Last 6 Hours',
25
+ h12: 'Last 12 Hours',
26
+ h24: 'Last 24 Hours',
27
+ d3: 'Last 3 Days',
28
+ d7: 'Last 7 Days',
29
+ d30: 'Last 30 Days',
30
30
  today: 'Today',
31
- week: 'Week to date',
32
- month: 'Month to date',
33
- quarter: 'Quarter to date',
34
- year: 'Year to date',
31
+ week: 'This Week',
32
+ month: 'This Month',
33
+ quarter: 'This Quarter',
34
+ year: 'This Year',
35
35
  yesterDay: 'Yesterday',
36
- theDayBeforYesterDay: 'Day before Yesterday',
37
- previousWeek: 'Previous week',
38
- previousMonth: 'Previous month',
39
- previousQuarter: 'Previous quarter',
40
- previousYear: 'Previous year',
41
- AllTime: 'All time'
36
+ theDayBeforYesterDay: 'Day Before Yesterday',
37
+ previousWeek: 'Previous Week',
38
+ previousMonth: 'Previous Month',
39
+ previousQuarter: 'Previous Quarter',
40
+ previousYear: 'Previous Year',
41
+ AllTime: 'All Time'
42
42
  },
43
43
  relative: {
44
- title: 'Relative',
45
- change_time: 'Change time',
44
+ title: 'Relative Time',
45
+ change_time: 'Change Time',
46
46
  now_text: 'Now',
47
- now: 'Now (realtime)',
48
- 'now-static': 'Now (fixed)',
49
- s: ' seconds ago',
50
- m: ' minutes ago',
51
- h: ' hours ago',
52
- d: ' days ago',
53
- w: ' weeks ago',
54
- M: ' months ago',
55
- Q: ' quarters ago',
56
- y: ' years ago'
47
+ now: 'Now (Realtime)',
48
+ 'now-static': 'Now (Fixed)',
49
+ s: ' seconds Ago',
50
+ m: ' Minutes Ago',
51
+ h: ' Hours Ago',
52
+ d: ' Days Ago',
53
+ w: ' weeks Ago',
54
+ M: ' months Ago',
55
+ Q: ' quarters Ago',
56
+ y: ' years Ago'
57
57
  },
58
58
  quarter: {
59
59
  title: 'Quarter'
@@ -2,5 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.table_en = {
4
4
  empty: 'No Data',
5
- selected: 'Selected'
5
+ selected: 'Selected',
6
+ check_all: 'Check All',
7
+ search: 'Search',
8
+ hide_column_tooltip: 'At least one column needs to be checked!'
6
9
  };
@@ -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;
@@ -2,5 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.table_zh = {
4
4
  empty: '暂无数据',
5
- selected: '已选'
5
+ selected: '已选',
6
+ check_all: '全选',
7
+ search: '搜索',
8
+ hide_column_tooltip: '至少需要勾选一列!'
6
9
  };