@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
@@ -14,6 +14,9 @@
|
|
14
14
|
height: 60px;
|
15
15
|
line-height: 60px;
|
16
16
|
}
|
17
|
+
.@{ant-prefix}-drawer-header-title {
|
18
|
+
overflow: hidden;
|
19
|
+
}
|
17
20
|
}
|
18
21
|
|
19
22
|
.@{sdk-prefix}-drawer-size-small {
|
@@ -46,3 +49,13 @@
|
|
46
49
|
.@{sdk-prefix}-drawer-close-icon {
|
47
50
|
margin-left: 24px;
|
48
51
|
}
|
52
|
+
|
53
|
+
.@{sdk-prefix}-drawer-header-full-icon {
|
54
|
+
margin-left: 24px;
|
55
|
+
color: @font-color-7;
|
56
|
+
font-size: 14px;
|
57
|
+
}
|
58
|
+
|
59
|
+
.@{sdk-prefix}-drawer-no-mask {
|
60
|
+
background-color: @normal-color;
|
61
|
+
}
|
@@ -377,12 +377,19 @@ span.ant-radio + * {
|
|
377
377
|
.ant-radio-button-wrapper.ant-radio-button-wrapper-rtl.ant-radio-button-wrapper-disabled:first-child {
|
378
378
|
border-right-color: #e5e5e5;
|
379
379
|
}
|
380
|
+
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper:not(.pandora-sdk-solid-radio-group .ant-radio-button-wrapper-checked)::before {
|
381
|
+
background-color: #bfbfbf;
|
382
|
+
}
|
380
383
|
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper {
|
381
384
|
padding: 0 12px;
|
382
385
|
}
|
383
386
|
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper:not(.pandora-sdk-solid-radio-group .ant-radio-button-wrapper-checked) {
|
384
387
|
border-color: #bfbfbf;
|
385
388
|
}
|
389
|
+
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper:focus-within {
|
390
|
+
-webkit-box-shadow: unset;
|
391
|
+
box-shadow: unset;
|
392
|
+
}
|
386
393
|
.pandora-sdk-solid-radio-group .ant-radio:not(.pandora-sdk-solid-radio-group .ant-radio-checked) .ant-radio-inner {
|
387
394
|
border-color: #bfbfbf;
|
388
395
|
}
|
@@ -2,11 +2,20 @@
|
|
2
2
|
@import '../../style/theme.less';
|
3
3
|
|
4
4
|
.@{sdk-prefix}-solid-radio-group {
|
5
|
+
.@{ant-prefix}-radio-button-wrapper:not(.@{sdk-prefix}-solid-radio-group
|
6
|
+
.@{ant-prefix}-radio-button-wrapper-checked) {
|
7
|
+
&::before {
|
8
|
+
background-color: @border-color-2;
|
9
|
+
}
|
10
|
+
}
|
5
11
|
.@{ant-prefix}-radio-button-wrapper {
|
6
12
|
padding: 0 12px;
|
7
13
|
&:not(&-checked) {
|
8
14
|
border-color: @input-border-color;
|
9
15
|
}
|
16
|
+
&:focus-within {
|
17
|
+
box-shadow: unset;
|
18
|
+
}
|
10
19
|
}
|
11
20
|
|
12
21
|
.@{ant-prefix}-radio {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export declare const All = "_all";
|
3
|
+
export interface IOption {
|
4
|
+
label: string | React.ReactNode;
|
5
|
+
value: string;
|
6
|
+
}
|
7
|
+
export interface ISettingBtnProps {
|
8
|
+
overlayClass?: string;
|
9
|
+
onHiddenKeysChange?: (value: string[]) => void;
|
10
|
+
hiddenKeys?: string[];
|
11
|
+
options?: IOption[];
|
12
|
+
loading?: boolean;
|
13
|
+
}
|
14
|
+
export declare function ColumnSetting(props: ISettingBtnProps): JSX.Element;
|
15
|
+
declare const _default: React.MemoExoticComponent<typeof ColumnSetting>;
|
16
|
+
export default _default;
|
@@ -0,0 +1,104 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
4
|
+
if (!m) return o;
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
6
|
+
try {
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
8
|
+
}
|
9
|
+
catch (error) { e = { error: error }; }
|
10
|
+
finally {
|
11
|
+
try {
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
13
|
+
}
|
14
|
+
finally { if (e) throw e.error; }
|
15
|
+
}
|
16
|
+
return ar;
|
17
|
+
};
|
18
|
+
var __spread = (this && this.__spread) || function () {
|
19
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
20
|
+
return ar;
|
21
|
+
};
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
23
|
+
if (mod && mod.__esModule) return mod;
|
24
|
+
var result = {};
|
25
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
26
|
+
result["default"] = mod;
|
27
|
+
return result;
|
28
|
+
};
|
29
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
30
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
31
|
+
};
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
33
|
+
var react_1 = __importStar(require("react"));
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
35
|
+
var lodash_1 = require("lodash");
|
36
|
+
var antd_1 = require("antd");
|
37
|
+
var icons_1 = require("@ant-design/icons");
|
38
|
+
var config_provider_1 = require("antd/es/config-provider");
|
39
|
+
var language_1 = require("../../../utils/language");
|
40
|
+
var type_1 = require("../../../constants/language/table/type");
|
41
|
+
var style_1 = require("../../../constants/style");
|
42
|
+
var NameLimiter_1 = __importDefault(require("../../NameLimiter"));
|
43
|
+
var Input_1 = __importDefault(require("../../Input"));
|
44
|
+
exports.All = '_all';
|
45
|
+
function ColumnSetting(props) {
|
46
|
+
var overlayClass = props.overlayClass, _a = props.hiddenKeys, hiddenKeys = _a === void 0 ? [] : _a, onHiddenKeysChange = props.onHiddenKeysChange, _b = props.options, options = _b === void 0 ? [] : _b, loading = props.loading;
|
47
|
+
var locale = react_1.useContext(config_provider_1.ConfigContext).locale;
|
48
|
+
var _c = __read(react_1.useState(''), 2), prefix = _c[0], setPrefix = _c[1];
|
49
|
+
var allKeys = react_1.useMemo(function () {
|
50
|
+
return options.map(function (item) { return item.value; });
|
51
|
+
}, [options]);
|
52
|
+
var realOptions = react_1.useMemo(function () {
|
53
|
+
if (!prefix || prefix.length === 0)
|
54
|
+
return options;
|
55
|
+
return options.filter(function (item) {
|
56
|
+
if (typeof item.label === 'string' &&
|
57
|
+
item.label.toLowerCase().indexOf(prefix.toLowerCase()) !== -1) {
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
return false;
|
61
|
+
});
|
62
|
+
}, [prefix, options]);
|
63
|
+
var realValues = react_1.useMemo(function () {
|
64
|
+
return allKeys.filter(function (item) { return !lodash_1.includes(hiddenKeys, item); });
|
65
|
+
}, [hiddenKeys, allKeys]);
|
66
|
+
var allCheckChange = react_1.useCallback(function (e) {
|
67
|
+
if (e.target.checked) {
|
68
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange([]);
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange(allKeys);
|
72
|
+
}, [onHiddenKeysChange, allKeys]);
|
73
|
+
var handlePrefixChange = react_1.useCallback(function (value) {
|
74
|
+
setPrefix(value || '');
|
75
|
+
}, [setPrefix]);
|
76
|
+
var handleChange = react_1.useCallback(function (e) {
|
77
|
+
var v = e.target.value;
|
78
|
+
var checked = e.target.checked;
|
79
|
+
// 添加
|
80
|
+
if (checked) {
|
81
|
+
var checkedValues_1 = Array.from(new Set(__spread(realValues, [v])));
|
82
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange(allKeys.filter(function (item) { return !lodash_1.includes(checkedValues_1, item); }));
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
// 删除
|
86
|
+
var restValues = realValues.filter(function (item) { return item !== v; });
|
87
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange(allKeys.filter(function (item) { return !lodash_1.includes(restValues, item); }));
|
88
|
+
}, [onHiddenKeysChange, realValues, allKeys]);
|
89
|
+
return (react_1.default.createElement(antd_1.Popover, { trigger: "click", placement: "bottomRight", content: react_1.default.createElement(antd_1.Spin, { spinning: !!loading },
|
90
|
+
react_1.default.createElement("div", { className: classnames_1.default(style_1.SDK_PREFIX + "-table-column-setting-popover", overlayClass) },
|
91
|
+
react_1.default.createElement("div", { className: style_1.SDK_PREFIX + "-table-column-setting-header" },
|
92
|
+
react_1.default.createElement(antd_1.Checkbox, { value: exports.All, checked: hiddenKeys.length === 0, onChange: allCheckChange, className: style_1.SDK_PREFIX + "-table-column-setting-all-check" }, language_1.formatString(type_1.TableLocale.check_all, locale)),
|
93
|
+
react_1.default.createElement(Input_1.default, { value: prefix, allowClear: true, onChange: handlePrefixChange, placeholder: language_1.formatString(type_1.TableLocale.search, locale), className: style_1.SDK_PREFIX + "-table-column-setting-search-input" })),
|
94
|
+
react_1.default.createElement("div", null,
|
95
|
+
react_1.default.createElement("div", { className: style_1.SDK_PREFIX + "-table-column-setting-content" }, realOptions.map(function (item) {
|
96
|
+
return (react_1.default.createElement("div", { key: item.value },
|
97
|
+
react_1.default.createElement("div", { className: style_1.SDK_PREFIX + "-table-column-setting-checkbox-container" },
|
98
|
+
react_1.default.createElement(antd_1.Checkbox, { checked: !!realValues.find(function (v) { return v === item.value; }), value: item.value, className: style_1.SDK_PREFIX + "-table-column-setting-checkbox", onChange: handleChange },
|
99
|
+
react_1.default.createElement("span", { className: style_1.SDK_PREFIX + "-table-column-setting-value" }, typeof item.label === 'string' ? (react_1.default.createElement(NameLimiter_1.default, { name: item.label })) : (item.label))))));
|
100
|
+
}))))) },
|
101
|
+
react_1.default.createElement(icons_1.SettingOutlined, { className: style_1.SDK_PREFIX + "-table-column-setting-icon" })));
|
102
|
+
}
|
103
|
+
exports.ColumnSetting = ColumnSetting;
|
104
|
+
exports.default = react_1.default.memo(ColumnSetting);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
.pandora-sdk-table-column-setting-popover {
|
2
|
+
padding: 10px;
|
3
|
+
width: 100%;
|
4
|
+
width: 600px;
|
5
|
+
max-height: 300px;
|
6
|
+
overflow-y: auto;
|
7
|
+
}
|
8
|
+
.pandora-sdk-table-column-setting-popover .pandora-sdk-table-column-setting-header {
|
9
|
+
border-bottom: 1px solid #e5e5e5;
|
10
|
+
display: -webkit-box;
|
11
|
+
display: -ms-flexbox;
|
12
|
+
display: flex;
|
13
|
+
padding-bottom: 10px;
|
14
|
+
}
|
15
|
+
.pandora-sdk-table-column-setting-popover .pandora-sdk-table-column-setting-header .pandora-sdk-table-column-setting-all-check {
|
16
|
+
line-height: 32px;
|
17
|
+
}
|
18
|
+
.pandora-sdk-table-column-setting-popover .pandora-sdk-table-column-setting-header .pandora-sdk-table-column-setting-search-input {
|
19
|
+
width: 200px;
|
20
|
+
}
|
21
|
+
.pandora-sdk-table-column-setting-icon {
|
22
|
+
color: #333;
|
23
|
+
}
|
24
|
+
.pandora-sdk-table-column-setting-content {
|
25
|
+
display: -webkit-box;
|
26
|
+
display: -ms-flexbox;
|
27
|
+
display: flex;
|
28
|
+
-ms-flex-wrap: wrap;
|
29
|
+
flex-wrap: wrap;
|
30
|
+
}
|
31
|
+
.pandora-sdk-table-column-setting-content > div {
|
32
|
+
-webkit-box-flex: 0;
|
33
|
+
-ms-flex: 0 0 33.33%;
|
34
|
+
flex: 0 0 33.33%;
|
35
|
+
-webkit-box-sizing: border-box;
|
36
|
+
box-sizing: border-box;
|
37
|
+
position: relative;
|
38
|
+
overflow: hidden;
|
39
|
+
text-overflow: ellipsis;
|
40
|
+
}
|
41
|
+
.pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-checkbox {
|
42
|
+
width: 100%;
|
43
|
+
overflow: hidden;
|
44
|
+
}
|
45
|
+
.pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-checkbox > span:nth-child(2) {
|
46
|
+
overflow: hidden;
|
47
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
@import '../../../style/theme.less';
|
2
|
+
|
3
|
+
.@{sdk-prefix}-table-column-setting-popover {
|
4
|
+
padding: 10px;
|
5
|
+
width: 100%;
|
6
|
+
width: 600px;
|
7
|
+
.@{sdk-prefix}-table-column-setting-header {
|
8
|
+
border-bottom: 1px solid @border-color-base;
|
9
|
+
display: flex;
|
10
|
+
padding-bottom: 10px;
|
11
|
+
.@{sdk-prefix}-table-column-setting-all-check {
|
12
|
+
line-height: 32px;
|
13
|
+
}
|
14
|
+
.@{sdk-prefix}-table-column-setting-search-input {
|
15
|
+
width: 200px;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
max-height: 300px;
|
19
|
+
overflow-y: auto;
|
20
|
+
}
|
21
|
+
|
22
|
+
.@{sdk-prefix}-table-column-setting-icon {
|
23
|
+
color: @font-color-7;
|
24
|
+
}
|
25
|
+
|
26
|
+
.@{sdk-prefix}-table-column-setting-content {
|
27
|
+
display: flex;
|
28
|
+
flex-wrap: wrap;
|
29
|
+
}
|
30
|
+
|
31
|
+
.@{sdk-prefix}-table-column-setting-content > div {
|
32
|
+
flex: 0 0 33.33%;
|
33
|
+
box-sizing: border-box;
|
34
|
+
position: relative;
|
35
|
+
overflow: hidden;
|
36
|
+
text-overflow: ellipsis;
|
37
|
+
.@{sdk-prefix}-table-column-setting-checkbox-container {
|
38
|
+
.@{sdk-prefix}-table-column-setting-checkbox {
|
39
|
+
width: 100%;
|
40
|
+
overflow: hidden;
|
41
|
+
}
|
42
|
+
.@{sdk-prefix}-table-column-setting-checkbox > span:nth-child(2) {
|
43
|
+
overflow: hidden;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { TableProps } from 'antd/es/table';
|
2
|
+
import { TableProps, ColumnType, ColumnGroupType } from 'antd/es/table';
|
3
3
|
import { TableRowSelection } from 'antd/es/table/interface';
|
4
|
+
import { IOption } from './ColumnSetting';
|
4
5
|
/**
|
5
6
|
* 表格提供自定义多选, 通过 rowSelection对象的selectedRowKeys和onChange来控制多选的状态
|
6
7
|
* 需要注意的是, 当在外部进行增删改或者外部需要控制选择状态时, 例如删除之后清空全选状态, 需要受控
|
@@ -20,7 +21,17 @@ export interface IOptionItem {
|
|
20
21
|
*/
|
21
22
|
disabled?: boolean | ((selectItems: any[]) => boolean);
|
22
23
|
}
|
23
|
-
export interface
|
24
|
+
export interface IColumnType<T> extends ColumnType<T> {
|
25
|
+
colTitle?: string | React.ReactNode;
|
26
|
+
configurable?: boolean;
|
27
|
+
}
|
28
|
+
export interface IColumnGroupType<T> extends ColumnGroupType<T> {
|
29
|
+
colTitle?: string | React.ReactNode;
|
30
|
+
configurable?: boolean;
|
31
|
+
}
|
32
|
+
export declare type IColumnsType<T> = Array<IColumnGroupType<T> | IColumnType<T>>;
|
33
|
+
export interface ITableProps<T> extends Omit<TableProps<T>, 'columns'> {
|
34
|
+
columns?: IColumnsType<T>;
|
24
35
|
/**
|
25
36
|
* 设置selectedRow选项, 可以获取当前选中的所有
|
26
37
|
* 数据.
|
@@ -30,6 +41,10 @@ export interface ITableProps<T> extends TableProps<T> {
|
|
30
41
|
/** 如果支持多选,则batchOptions为多选时的一些批量操作,如删除、添加等 */
|
31
42
|
batchOptions?: IOptionItem[];
|
32
43
|
emptyText?: React.ReactNode;
|
44
|
+
showColumnSetting?: boolean;
|
45
|
+
hiddenColumns?: string[];
|
46
|
+
onHiddenColumnsChange?: (keys: string[]) => void;
|
47
|
+
columnSettingOverlayClass?: string;
|
33
48
|
}
|
34
49
|
/**
|
35
50
|
* pandora2.0风格的表格
|
@@ -44,15 +59,25 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
44
59
|
static contextType: React.Context<import("antd/es/config-provider").ConfigConsumerProps>;
|
45
60
|
indeterminate: boolean;
|
46
61
|
checkAll: boolean;
|
62
|
+
hiddenColumn: string[] | undefined;
|
47
63
|
UNSAFE_componentWillReceiveProps(nextProps: ITableProps<T>): void;
|
48
64
|
get selectedRowKeys(): React.ReactText[];
|
49
65
|
get rowSelection(): TableRowSelection<T> | undefined;
|
50
66
|
get undisabledData(): readonly T[];
|
51
67
|
get keysOfCurrentPage(): any[];
|
52
68
|
get emptyTextComp(): {};
|
69
|
+
get columnsSettingOptions(): IOption[];
|
70
|
+
get columnKeys(): {
|
71
|
+
allKeys: string[];
|
72
|
+
unconfigableKeys: string[];
|
73
|
+
resetKeys: string[];
|
74
|
+
};
|
75
|
+
handleHideColumnsChange(keys: string[]): Promise<void> | undefined;
|
76
|
+
getColumns(): IColumnsType<T> | undefined;
|
53
77
|
getRowKey(row: any, index: number): any;
|
54
78
|
setIndeterminate(indeterminate: boolean): void;
|
55
79
|
setCheckAll(checkAll: boolean): void;
|
80
|
+
setHiddenColumn(hiddenColumn?: string[]): void;
|
56
81
|
setCheckboxStatus(selectedRowsOfCurrentPage?: T[], dataSource?: T[]): void;
|
57
82
|
handleSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
|
58
83
|
onRowSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
|
@@ -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),
|
@@ -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
|
};
|