@ecoding/components.antd 0.2.25 → 0.2.27
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.
|
@@ -117,9 +117,9 @@ const AsyncSlect = memo((props) => {
|
|
|
117
117
|
});
|
|
118
118
|
timeout = setTimeout(innerEx, 300);
|
|
119
119
|
});
|
|
120
|
-
const changeHandler = (v,
|
|
120
|
+
const changeHandler = (v, opts) => {
|
|
121
121
|
props.onChange(v);
|
|
122
|
-
props.
|
|
122
|
+
props.onChangeOpts && props.onChangeOpts(opts);
|
|
123
123
|
};
|
|
124
124
|
const children = useMemo(() => {
|
|
125
125
|
return (options &&
|
|
@@ -2,11 +2,12 @@ import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { Popover, Button, Typography, Table } from 'antd';
|
|
3
3
|
import { FilterOutlined, MenuOutlined } from '@ant-design/icons';
|
|
4
4
|
import TableProColumns from "./columns";
|
|
5
|
-
const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered, columnsTitle, filterTitle }) => {
|
|
5
|
+
const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered, selectChangeHandler, selectType, columnsTitle, filterTitle }) => {
|
|
6
6
|
const ref = useRef(null);
|
|
7
7
|
const disColumnRef = useRef([]);
|
|
8
8
|
const [y, setY] = useState('100%');
|
|
9
9
|
const [innerColumns, setColumns] = useState(columns);
|
|
10
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
10
11
|
const flexColumnStyle = {
|
|
11
12
|
display: 'flex',
|
|
12
13
|
height: '100%',
|
|
@@ -29,6 +30,15 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
|
|
|
29
30
|
}
|
|
30
31
|
return [];
|
|
31
32
|
}, [innerColumns, dataSource]);
|
|
33
|
+
const onSelectChange = (newSelectedRowKeys) => {
|
|
34
|
+
setSelectedRowKeys(newSelectedRowKeys);
|
|
35
|
+
selectChangeHandler && selectChangeHandler(newSelectedRowKeys);
|
|
36
|
+
};
|
|
37
|
+
const rowSelection = {
|
|
38
|
+
type: selectType,
|
|
39
|
+
selectedRowKeys,
|
|
40
|
+
onChange: onSelectChange,
|
|
41
|
+
};
|
|
32
42
|
useEffect(() => {
|
|
33
43
|
if (disColumnRef.current && disColumnRef.current.length > 0 && columns.length > 0) {
|
|
34
44
|
setColumns(columns.map((c) => {
|
|
@@ -46,14 +56,16 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
|
|
|
46
56
|
useEffect(() => {
|
|
47
57
|
if (ref.current && innerColumns.length > 0) {
|
|
48
58
|
const thead = ref.current.querySelector('thead');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (thead) {
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
if (offsetY && offsetY > 0) {
|
|
62
|
+
setY(ref.current.clientHeight - offsetY);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
setY(ref.current.clientHeight - (thead.clientHeight && thead.clientHeight + (pagination ? 64 : 20)));
|
|
66
|
+
}
|
|
67
|
+
}, 100);
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
}, [header, loading, innerColumns]);
|
|
59
71
|
return (React.createElement("div", { style: flexColumnStyle, className: className || '' },
|
|
@@ -71,7 +83,7 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
|
|
|
71
83
|
} },
|
|
72
84
|
React.createElement(Button, { type: "text", icon: React.createElement(MenuOutlined, null) }, columnsTitle))) : null)),
|
|
73
85
|
dataSource ? (React.createElement("div", { style: { height: '100%', overflow: 'hidden' }, ref: ref },
|
|
74
|
-
React.createElement(Table, { bordered: bordered, rowKey: rowKey, columns: showColumns, dataSource: dataSource, scroll: { y }, loading: loading, pagination: pagination || false }))) : null));
|
|
86
|
+
React.createElement(Table, { rowSelection: selectType ? rowSelection : undefined, bordered: bordered, rowKey: rowKey, columns: showColumns, dataSource: dataSource, scroll: { y }, loading: loading, pagination: pagination || false }))) : null));
|
|
75
87
|
});
|
|
76
88
|
TablePro.defaultProps = {
|
|
77
89
|
filterTitle: "筛选",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"react-quill": "^2.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "33d2b463df5bd1ca90fb49b964d671b5e152262e"
|
|
48
48
|
}
|