@ecoding/components.antd 0.4.18 → 0.4.20
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/lib/core/async-select/index.d.ts +1 -1
- package/lib/core/async-select/index.js +0 -1
- package/lib/core/drawer/index.js +1 -1
- package/lib/core/form.list/index.d.ts +1 -0
- package/lib/core/form.list/index.js +10 -3
- package/lib/core/modal/index.js +1 -1
- package/lib/core/table-pro/index.d.ts +4 -2
- package/lib/core/table-pro/index.js +22 -7
- package/package.json +2 -2
- package/LICENSE.md +0 -0
|
@@ -30,7 +30,7 @@ interface IProps extends SelectProps<any> {
|
|
|
30
30
|
searchIface?: IFace;
|
|
31
31
|
emptyType?: 'null' | 'undefined' | '';
|
|
32
32
|
onChange?: any;
|
|
33
|
-
|
|
33
|
+
labelInValue?: boolean;
|
|
34
34
|
}
|
|
35
35
|
declare const AsyncSelect: React.FC<IProps>;
|
|
36
36
|
export default AsyncSelect;
|
package/lib/core/drawer/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export class Drawers extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
render() {
|
|
51
51
|
// if (!this.props.visible) return null;
|
|
52
|
-
return (React.createElement(Drawer, { className: this.state.className, placement: this.state.placement, height: this.state.height, open: this.state.open,
|
|
52
|
+
return (React.createElement(Drawer, { className: this.state.className, placement: this.state.placement, height: this.state.height, open: this.state.open, destroyOnHidden: true, maskClosable: this.state.maskClosable, keyboard: false, title: this.state.title, extra: this.state.extra === null ? null : this.state.extra ? (this.state.extra) : (React.createElement("div", { className: "tac" },
|
|
53
53
|
this.state.addonBefore ? this.state.addonBefore : null,
|
|
54
54
|
React.createElement(Button, Object.assign({}, this.state.cancelButtonProps, { className: "mr10", key: "back", onClick: this.cancel }), this.state.cancelText),
|
|
55
55
|
React.createElement(Button, Object.assign({}, this.state.okButtonProps, { danger: this.state.okDanger, key: "submit", type: this.state.okType, loading: this.state.loading, onClick: this.ok }), this.state.okText),
|
|
@@ -58,6 +58,10 @@ const SortableItem = (props) => {
|
|
|
58
58
|
} }, i18n ? i18n.$t("global.del", '删除') : '删除')))));
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
+
if (column.noStyleHidden) {
|
|
62
|
+
return (React.createElement("td", { style: { display: "none" } },
|
|
63
|
+
React.createElement(Form.Item, { noStyle: true, hidden: true, name: [field.name, column.name] }, column.render(field, index, { add, remove }))));
|
|
64
|
+
}
|
|
61
65
|
return (React.createElement("td", { style: tdStyle },
|
|
62
66
|
React.createElement(Form.Item, { style: { marginBottom: 0 }, name: [field.name, column.name], rules: column.rules || [] }, column.render(field, index, { add, remove }))));
|
|
63
67
|
}
|
|
@@ -85,6 +89,9 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
|
|
|
85
89
|
const widths = useMemo(() => {
|
|
86
90
|
let w = 60;
|
|
87
91
|
columns.forEach((column) => {
|
|
92
|
+
if (column.noStyleHidden) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
88
95
|
w += column.width || 200;
|
|
89
96
|
});
|
|
90
97
|
if (operation) {
|
|
@@ -105,7 +112,7 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
|
|
|
105
112
|
if (column.type == "operation") {
|
|
106
113
|
return null;
|
|
107
114
|
}
|
|
108
|
-
return (React.createElement("col", { style: Object.assign({}, { width: column.width || 200 }) }));
|
|
115
|
+
return (React.createElement("col", { style: Object.assign({}, { width: column.width || 200 }, column.noStyleHidden ? { display: "none" } : {}) }));
|
|
109
116
|
}),
|
|
110
117
|
(operation === null || operation === void 0 ? void 0 : operation.hide) ? null : (React.createElement("col", { style: Object.assign({}, { width: (operation === null || operation === void 0 ? void 0 : operation.width) || 150 }) }))),
|
|
111
118
|
React.createElement("thead", null, hideHeader ? null : (React.createElement("tr", null,
|
|
@@ -115,13 +122,13 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
|
|
|
115
122
|
return null;
|
|
116
123
|
}
|
|
117
124
|
if (column.require) {
|
|
118
|
-
return (React.createElement("th", { style: thStyle },
|
|
125
|
+
return (React.createElement("th", { style: Object.assign({}, thStyle, column.noStyleHidden ? { display: "none" } : {}) },
|
|
119
126
|
React.createElement("span", { style: { color: '#ff4d4f' } }, "*"),
|
|
120
127
|
column.title,
|
|
121
128
|
column.tooltip ? (React.createElement(Tooltip, { placement: "top", title: column.tooltip || undefined },
|
|
122
129
|
React.createElement(QuestionCircleOutlined, { style: { paddingLeft: 4, color: "rgba(0, 0, 0, 0.45)" } }))) : null));
|
|
123
130
|
}
|
|
124
|
-
return (React.createElement("th", { style: thStyle },
|
|
131
|
+
return (React.createElement("th", { style: Object.assign({}, thStyle, column.noStyleHidden ? { display: "none" } : {}) },
|
|
125
132
|
column.title,
|
|
126
133
|
column.tooltip ? (React.createElement(Tooltip, { placement: "top", title: column.tooltip || undefined },
|
|
127
134
|
React.createElement(QuestionCircleOutlined, { style: { paddingLeft: 4, color: "rgba(0, 0, 0, 0.45)" } }))) : null));
|
package/lib/core/modal/index.js
CHANGED
|
@@ -46,7 +46,7 @@ export class Modals extends React.Component {
|
|
|
46
46
|
}
|
|
47
47
|
render() {
|
|
48
48
|
// if (!this.props.visible) return null;
|
|
49
|
-
return (React.createElement(Modal, { className: this.state.className, wrapClassName: this.state.wrapClassName, open: this.state.open, style: this.state.style, width: this.state.width, zIndex: this.state.zIndex, mask: this.state.mask, title: typeof this.state.title === "string" ? (React.createElement("div", { style: { boxShadow: "inset 0px -1px 0px #F0F0F0", marginBottom: "20px", paddingBottom: "12px" } }, this.state.title)) : (this.state.title), closable: this.state.closable, maskClosable: this.state.maskClosable, onCancel: this.cancel,
|
|
49
|
+
return (React.createElement(Modal, { className: this.state.className, wrapClassName: this.state.wrapClassName, open: this.state.open, style: this.state.style, width: this.state.width, height: this.state.height ? this.state.height : undefined, zIndex: this.state.zIndex, mask: this.state.mask, title: typeof this.state.title === "string" ? (React.createElement("div", { style: { boxShadow: "inset 0px -1px 0px #F0F0F0", marginBottom: "20px", paddingBottom: "12px" } }, this.state.title)) : (this.state.title), closable: this.state.closable, maskClosable: this.state.maskClosable, onCancel: this.cancel, destroyOnHidden: true, keyboard: false, footer: this.state.footer === null ? null : this.state.footer ? (this.state.footer) : (React.createElement(React.Fragment, null,
|
|
50
50
|
this.state.addonBefore ? this.state.addonBefore : null,
|
|
51
51
|
React.createElement(Button, Object.assign({}, this.state.cancelButtonProps, { key: "back", onClick: this.cancel }), this.state.cancelText),
|
|
52
52
|
React.createElement(Button, Object.assign({}, this.state.okButtonProps, { danger: this.state.okDanger, key: "submit", type: this.state.okType, loading: this.state.loading, onClick: this.ok }), this.state.okText),
|
|
@@ -3,7 +3,8 @@ import type { FilterValue, SorterResult, TableCurrentDataSource, TablePagination
|
|
|
3
3
|
import type { ColProps } from 'antd/lib/col';
|
|
4
4
|
interface TableProRef {
|
|
5
5
|
clear: () => void;
|
|
6
|
-
setSelectedRowKeys: (key:
|
|
6
|
+
setSelectedRowKeys: (key: React.Key[]) => void;
|
|
7
|
+
getSelectedRowKeys: () => React.Key[];
|
|
7
8
|
}
|
|
8
9
|
interface IProps {
|
|
9
10
|
className?: string;
|
|
@@ -27,6 +28,7 @@ interface IProps {
|
|
|
27
28
|
bordered?: boolean;
|
|
28
29
|
dataSource: any;
|
|
29
30
|
columns: any[];
|
|
31
|
+
selectKeys?: React.Key[];
|
|
30
32
|
operationColumn?: any[];
|
|
31
33
|
pagination?: any;
|
|
32
34
|
offsetY?: number;
|
|
@@ -35,7 +37,7 @@ interface IProps {
|
|
|
35
37
|
filterTitle?: string;
|
|
36
38
|
columnsTitle?: string;
|
|
37
39
|
selectType?: "checkbox" | "radio";
|
|
38
|
-
selectChangeHandler?: any;
|
|
40
|
+
selectChangeHandler?: (keys: React.Key[], selectedRows: any[]) => void;
|
|
39
41
|
i18n?: any;
|
|
40
42
|
locale?: TableLocale;
|
|
41
43
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React, { memo, useEffect, useMemo, useRef, useState, useImperativeHandle, forwardRef } from 'react';
|
|
2
2
|
import { Popover, Button, Typography, Table } from 'antd';
|
|
3
3
|
import { FilterOutlined, MenuOutlined } from '@ant-design/icons';
|
|
4
|
+
import { isEqual } from "@ecoding/helper.is";
|
|
4
5
|
import TableProColumns from "./columns";
|
|
5
6
|
import { getDelateTargetByClassName } from "../../helpers/dom";
|
|
6
7
|
import FilterHorizontal from "./filters.horizontal";
|
|
7
|
-
const TablePro = ({ className, header, buttonArea, filterArea, filters, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered = false, selectChangeHandler, selectType, onChange, expandable, columnsTitle, filterTitle, locale, scrollY = '100%', scrollX, i18n, }, ref) => {
|
|
8
|
+
const TablePro = ({ className, header, buttonArea, filterArea, filters, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered = false, selectChangeHandler, selectType, selectKeys, onChange, expandable, columnsTitle, filterTitle, locale, scrollY = '100%', scrollX, i18n, }, ref) => {
|
|
8
9
|
const tableRef = useRef(null);
|
|
9
10
|
const disColumnRef = useRef([]);
|
|
10
11
|
const [y, setY] = useState(scrollY);
|
|
11
12
|
const [innerColumns, setColumns] = useState(columns);
|
|
12
13
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
14
|
+
const [selectedRows, setSelectedRows] = useState([]);
|
|
13
15
|
const flexColumnStyle = {
|
|
14
16
|
display: 'flex',
|
|
15
17
|
height: '100%',
|
|
@@ -51,7 +53,7 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
|
|
|
51
53
|
tempKeys.splice(index, 1);
|
|
52
54
|
}
|
|
53
55
|
setSelectedRowKeys(tempKeys);
|
|
54
|
-
selectChangeHandler && selectChangeHandler(tempKeys);
|
|
56
|
+
selectChangeHandler && selectChangeHandler(tempKeys, selectedRows);
|
|
55
57
|
};
|
|
56
58
|
const onSelectAll = (selected, selectedRows, changeRows) => {
|
|
57
59
|
let tempKeys = selectedRowKeys.concat([]);
|
|
@@ -68,15 +70,20 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
|
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
setSelectedRowKeys(tempKeys);
|
|
71
|
-
selectChangeHandler && selectChangeHandler(tempKeys);
|
|
73
|
+
selectChangeHandler && selectChangeHandler(tempKeys, selectedRows);
|
|
72
74
|
};
|
|
73
|
-
const rowSelection = {
|
|
75
|
+
const rowSelection = Object.assign({}, {
|
|
74
76
|
type: selectType,
|
|
75
77
|
selectedRowKeys,
|
|
78
|
+
}, selectType === 'checkbox' ? {
|
|
76
79
|
onSelect: onSelect,
|
|
77
80
|
onSelectAll: onSelectAll
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
} : {}, selectType === 'radio' ? {
|
|
82
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
83
|
+
setSelectedRowKeys(selectedRowKeys);
|
|
84
|
+
selectChangeHandler && selectChangeHandler(selectedRowKeys, selectedRows);
|
|
85
|
+
}
|
|
86
|
+
} : {});
|
|
80
87
|
useEffect(() => {
|
|
81
88
|
if (disColumnRef.current && disColumnRef.current.length > 0 && columns.length > 0) {
|
|
82
89
|
setColumns(columns.map((c) => {
|
|
@@ -108,12 +115,20 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
|
|
|
108
115
|
}, 100);
|
|
109
116
|
}
|
|
110
117
|
}, [header, loading, innerColumns]);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (selectKeys && selectKeys.length > 0 && !isEqual(selectedRowKeys, selectKeys)) {
|
|
120
|
+
setSelectedRowKeys(selectKeys);
|
|
121
|
+
}
|
|
122
|
+
}, [selectKeys]);
|
|
111
123
|
useImperativeHandle(ref, () => ({
|
|
112
124
|
clear: () => {
|
|
113
125
|
setSelectedRowKeys([]);
|
|
114
126
|
},
|
|
115
127
|
setSelectedRowKeys: (keys) => {
|
|
116
128
|
setSelectedRowKeys(keys);
|
|
129
|
+
},
|
|
130
|
+
getSelectedRowKeys: () => {
|
|
131
|
+
return selectedRowKeys;
|
|
117
132
|
}
|
|
118
133
|
}));
|
|
119
134
|
return (React.createElement("div", { style: flexColumnStyle, className: className || '' },
|
|
@@ -121,7 +136,7 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
|
|
|
121
136
|
filters ? (React.createElement(FilterHorizontal, Object.assign({ y: y, setY: setY }, filters, { i18n: i18n }))) : null,
|
|
122
137
|
React.createElement("div", { style: operationWrap },
|
|
123
138
|
buttonArea ? React.createElement("div", null, buttonArea) : React.createElement("div", null),
|
|
124
|
-
React.createElement("div",
|
|
139
|
+
React.createElement("div", { style: { display: 'flex' } },
|
|
125
140
|
searchInputArea ? searchInputArea : null,
|
|
126
141
|
filterArea ? (React.createElement(Popover, { placement: "leftBottom", title: React.createElement(Typography.Title, { level: 5 }, filterTitleStr), content: React.cloneElement(filterArea, { hide: hideOpenFilter }), trigger: "click", open: openFilter, onOpenChange: (newOpen) => {
|
|
127
142
|
setOpenFilter(newOpen);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.20",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"antd": "5.27.0",
|
|
48
48
|
"axios": "^1.1.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "571168c21c039e8eed8da932957c8b567fa22abb"
|
|
51
51
|
}
|
package/LICENSE.md
DELETED
|
File without changes
|