@qn-pandora/pandora-component 4.1.7 → 4.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/CHANGELOG.json +25 -8
- package/CHANGELOG.md +12 -5
- package/es/components/DateTimePicker/Base/index.d.ts +6 -1
- package/es/components/DateTimePicker/Base/index.js +44 -17
- package/es/components/DateTimePicker/Base/relativeTimePicker.js +10 -7
- package/es/components/DateTimePicker/constants.d.ts +57 -1
- package/es/components/DateTimePicker/constants.js +3 -5
- package/es/components/DateTimePicker/time.js +2 -2
- package/es/components/DateTimePicker/transform.d.ts +5 -1
- package/es/components/DateTimePicker/transform.js +3 -2
- package/es/components/Drawer/index.d.ts +21 -1
- package/es/components/Drawer/index.js +74 -13
- package/es/components/Drawer/style.css +11 -0
- package/es/components/Drawer/style.less +13 -0
- package/es/components/RadioGroup/style.css +7 -0
- package/es/components/RadioGroup/style.less +9 -0
- package/es/components/Table/ColumnSetting/index.d.ts +16 -0
- package/es/components/Table/ColumnSetting/index.js +91 -0
- package/es/components/Table/ColumnSetting/style.css +47 -0
- package/es/components/Table/ColumnSetting/style.less +46 -0
- package/es/components/Table/index.d.ts +27 -2
- package/es/components/Table/index.js +127 -3
- package/es/components/Table/style.css +4 -0
- package/es/components/Table/style.less +7 -0
- package/es/constants/language/table/en.js +4 -1
- package/es/constants/language/table/type.d.ts +3 -0
- package/es/constants/language/table/zh.js +4 -1
- package/es/index.css +2758 -2689
- package/es/index.less +5 -4
- package/es/style/theme.less +5 -0
- package/lib/components/DateTimePicker/Base/index.d.ts +6 -1
- package/lib/components/DateTimePicker/Base/index.js +43 -16
- package/lib/components/DateTimePicker/Base/relativeTimePicker.js +8 -5
- package/lib/components/DateTimePicker/constants.d.ts +57 -1
- package/lib/components/DateTimePicker/constants.js +3 -5
- package/lib/components/DateTimePicker/time.js +1 -1
- package/lib/components/DateTimePicker/transform.d.ts +5 -1
- package/lib/components/DateTimePicker/transform.js +3 -2
- package/lib/components/Drawer/index.d.ts +21 -1
- package/lib/components/Drawer/index.js +74 -13
- package/lib/components/Drawer/style.css +11 -0
- package/lib/components/Drawer/style.less +13 -0
- package/lib/components/RadioGroup/style.css +7 -0
- package/lib/components/RadioGroup/style.less +9 -0
- package/lib/components/Table/ColumnSetting/index.d.ts +16 -0
- package/lib/components/Table/ColumnSetting/index.js +104 -0
- package/lib/components/Table/ColumnSetting/style.css +47 -0
- package/lib/components/Table/ColumnSetting/style.less +46 -0
- package/lib/components/Table/index.d.ts +27 -2
- package/lib/components/Table/index.js +126 -2
- package/lib/components/Table/style.css +4 -0
- package/lib/components/Table/style.less +7 -0
- package/lib/constants/language/table/en.js +4 -1
- package/lib/constants/language/table/type.d.ts +3 -0
- package/lib/constants/language/table/zh.js +4 -1
- package/lib/index.css +2295 -2226
- package/lib/index.less +3 -2
- package/lib/style/theme.less +5 -0
- 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),
|