@ecoding/components.antd 0.3.37 → 0.3.39
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/LICENSE.md
ADDED
|
File without changes
|
|
@@ -7,15 +7,15 @@ 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, Col } from 'antd';
|
|
12
|
-
const FiltersHorizontal = ({ items, onFinish, onClear, y, setY }) => {
|
|
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);
|
|
16
16
|
const [showMore, setShowMore] = useState(false);
|
|
17
17
|
const [moreFlag, setMoreFlag] = useState(false);
|
|
18
|
-
const [wrapH, setWrapH] = useState(items && items.length >
|
|
18
|
+
const [wrapH, setWrapH] = useState(items && items.length > overMax ? 110 : 'auto');
|
|
19
19
|
const finish = (v) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
onFinish && (yield onFinish(v));
|
|
21
21
|
});
|
|
@@ -38,14 +38,16 @@ const FiltersHorizontal = ({ items, onFinish, onClear, y, setY }) => {
|
|
|
38
38
|
}, 50);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
const colProps = useMemo(() => {
|
|
42
|
+
const colProps = colOpts ? colOpts : { span: 6 };
|
|
43
|
+
return colProps;
|
|
44
|
+
}, [colOpts]);
|
|
41
45
|
useEffect(() => {
|
|
42
46
|
if (ref.current) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}, 200);
|
|
47
|
+
if (items && items.length > overMax) {
|
|
48
|
+
setShowMore(true);
|
|
49
|
+
setWrapH(110);
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
}, []);
|
|
51
53
|
useEffect(() => {
|
|
@@ -53,13 +55,18 @@ const FiltersHorizontal = ({ items, onFinish, onClear, y, setY }) => {
|
|
|
53
55
|
refInitY.current = y;
|
|
54
56
|
}
|
|
55
57
|
}, [y]);
|
|
56
|
-
return (React.createElement(Form, { form: form, onFinish: finish, style: { width: '100%',
|
|
57
|
-
React.createElement(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
React.createElement(
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
return (React.createElement(Form, { form: form, onFinish: finish, style: { width: '100%', position: "relative" } },
|
|
59
|
+
React.createElement("div", { style: { display: "flex" } },
|
|
60
|
+
React.createElement(Row, { gutter: 20, style: { overflow: "hidden", width: '100%', height: Number(wrapH) > 0 ? wrapH : 'auto' }, ref: ref }, items && items.map((item) => {
|
|
61
|
+
return (React.createElement(Col, Object.assign({}, colProps), item));
|
|
62
|
+
})),
|
|
63
|
+
React.createElement(Space, { direction: "vertical", size: "small", style: { textAlign: "right", width: 90 } },
|
|
64
|
+
React.createElement(Button, { type: "primary", size: 'small', htmlType: "submit" }, "\u641C\u7D22"),
|
|
65
|
+
React.createElement(Button, { size: 'small', onClick: clear }, "\u6E05\u7A7A"))),
|
|
66
|
+
showMore ? (React.createElement(Button, { type: 'link', onClick: switchShow, style: { fontSize: 12, position: "absolute", bottom: -10, left: '50%', transform: "translateX(-50%)" }, size: 'small' }, moreFlag ? "收起" : "展开更多")) : null));
|
|
67
|
+
};
|
|
68
|
+
FiltersHorizontal.defaultProps = {
|
|
69
|
+
items: [],
|
|
70
|
+
overMax: 8,
|
|
64
71
|
};
|
|
65
72
|
export default FiltersHorizontal;
|
|
@@ -1,10 +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?: {
|
|
9
|
+
overMax?: number;
|
|
10
|
+
colOpts?: ColProps;
|
|
8
11
|
items: React.ReactElement[];
|
|
9
12
|
onFinish?: (v: any) => Promise<void>;
|
|
10
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.39",
|
|
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": "85e72aba0357ed01704cb1a1e73356415e0f85aa"
|
|
47
47
|
}
|