@ecoding/components.antd 0.3.38 → 0.3.40
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.
|
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { useRef, useEffect, useState } from 'react';
|
|
11
|
-
import { Button, Form, Row } from 'antd';
|
|
12
|
-
const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax }) => {
|
|
10
|
+
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
11
|
+
import { Button, Form, Row, Col, Space } from 'antd';
|
|
12
|
+
const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax, colOpts }) => {
|
|
13
13
|
const [form] = Form.useForm(); // 该组件内form全局变量
|
|
14
14
|
const ref = useRef(null);
|
|
15
15
|
const refInitY = useRef(undefined);
|
|
@@ -38,14 +38,24 @@ const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax }) => {
|
|
|
38
38
|
}, 50);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
const colProps = useMemo(() => {
|
|
42
|
+
const colProps = colOpts ? colOpts : { span: 6 };
|
|
43
|
+
return colProps;
|
|
44
|
+
}, [colOpts]);
|
|
45
|
+
const isOpShowAfter = useMemo(() => {
|
|
46
|
+
const len = items.length;
|
|
47
|
+
const temp = Math.floor(24 / colProps.span);
|
|
48
|
+
if (len < temp) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}, []);
|
|
41
53
|
useEffect(() => {
|
|
42
54
|
if (ref.current) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}, 200);
|
|
55
|
+
if (items && items.length > overMax) {
|
|
56
|
+
setShowMore(true);
|
|
57
|
+
setWrapH(110);
|
|
58
|
+
}
|
|
49
59
|
}
|
|
50
60
|
}, []);
|
|
51
61
|
useEffect(() => {
|
|
@@ -53,17 +63,22 @@ const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax }) => {
|
|
|
53
63
|
refInitY.current = y;
|
|
54
64
|
}
|
|
55
65
|
}, [y]);
|
|
56
|
-
return (React.createElement(Form, { form: form, onFinish: finish, style: { width: '100%',
|
|
57
|
-
React.createElement(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
return (React.createElement(Form, { form: form, onFinish: finish, style: { width: '100%', position: "relative" } },
|
|
67
|
+
React.createElement("div", { style: { display: "flex" } },
|
|
68
|
+
React.createElement(Row, { gutter: 20, style: { overflow: "hidden", width: '100%', height: Number(wrapH) > 0 ? wrapH : 'auto' }, ref: ref },
|
|
69
|
+
items && items.map((item) => {
|
|
70
|
+
return (React.createElement(Col, Object.assign({}, colProps), item));
|
|
71
|
+
}),
|
|
72
|
+
isOpShowAfter ? (React.createElement(Col, Object.assign({}, colProps, { style: { paddingTop: 4 } }),
|
|
73
|
+
React.createElement(Button, { type: "primary", className: 'mr10', size: 'small', htmlType: "submit" }, "\u641C\u7D22"),
|
|
74
|
+
React.createElement(Button, { size: 'small', onClick: clear }, "\u6E05\u7A7A"))) : null),
|
|
75
|
+
!isOpShowAfter ? (React.createElement(Space, { direction: "vertical", size: "small", style: { textAlign: "right", width: 90 } },
|
|
76
|
+
React.createElement(Button, { type: "primary", size: 'small', htmlType: "submit" }, "\u641C\u7D22"),
|
|
77
|
+
React.createElement(Button, { size: 'small', onClick: clear }, "\u6E05\u7A7A"))) : null),
|
|
78
|
+
showMore ? (React.createElement(Button, { type: 'link', onClick: switchShow, style: { fontSize: 12, position: "absolute", bottom: -10, left: '50%', transform: "translateX(-50%)" }, size: 'small' }, moreFlag ? "收起" : "展开更多")) : null));
|
|
64
79
|
};
|
|
65
80
|
FiltersHorizontal.defaultProps = {
|
|
66
81
|
items: [],
|
|
67
|
-
overMax:
|
|
82
|
+
overMax: 8,
|
|
68
83
|
};
|
|
69
84
|
export default FiltersHorizontal;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FilterValue, SorterResult, TableCurrentDataSource, TablePaginationConfig } from 'antd/lib/table/interface';
|
|
3
|
+
import type { ColProps } from 'antd/lib/col';
|
|
3
4
|
interface IProps {
|
|
4
5
|
className?: string;
|
|
5
6
|
header?: React.ReactNode;
|
|
6
7
|
buttonArea?: React.ReactNode;
|
|
7
8
|
filters?: {
|
|
8
9
|
overMax?: number;
|
|
10
|
+
colOpts?: ColProps;
|
|
9
11
|
items: React.ReactElement[];
|
|
10
12
|
onFinish?: (v: any) => Promise<void>;
|
|
11
13
|
onClear?: () => Promise<void>;
|
|
@@ -19,7 +19,7 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, filters, sea
|
|
|
19
19
|
display: 'flex',
|
|
20
20
|
alignItems: 'center',
|
|
21
21
|
justifyContent: 'space-between',
|
|
22
|
-
marginBottom:
|
|
22
|
+
marginBottom: 8
|
|
23
23
|
};
|
|
24
24
|
const [openFilter, setOpenFilter] = useState(false);
|
|
25
25
|
const [openColumnFilter, setOpenColumnFilter] = useState(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.40",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"antd": "^5.8.4",
|
|
44
44
|
"axios": "^1.1.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2a24f42490bbd7c0ad1032588418c4593df21780"
|
|
47
47
|
}
|