@hw-component/table 0.0.3-beta-v1 → 0.0.3-beta-v2
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/package.json +2 -2
- package/src/components/HTableBody/index.tsx +12 -8
- package/src/components/HTableFooter/index.tsx +9 -3
- package/src/components/HTableHeader/index.tsx +1 -1
- package/src/components/HTableHeader/utils.ts +1 -1
- package/src/components/Table.tsx +2 -2
- package/src/components/context.ts +2 -2
- package/src/components/hooks/useRowObj.ts +7 -7
- package/src/components/index.tsx +0 -1
- package/src/components/modal.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/table",
|
|
3
|
-
"version": "0.0.3-beta-
|
|
3
|
+
"version": "0.0.3-beta-v2",
|
|
4
4
|
"description": "基于antd二次开发table组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"table"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ant-design/pro-table": "2.70.0",
|
|
34
|
-
"@hw-component/form": "0.0.9-beta-
|
|
34
|
+
"@hw-component/form": "0.0.9-beta-v10",
|
|
35
35
|
"ahooks": "2.10.9",
|
|
36
36
|
"antd": "4.20.7",
|
|
37
37
|
"core-js": "3",
|
|
@@ -34,7 +34,7 @@ export default ({
|
|
|
34
34
|
}: HTableBodyProps) => {
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
const { selectedRowKeys, onChange } = rowSelection;
|
|
37
|
-
const { tableInstance, data, selectedRowData, rowOnChange, error,loading } =
|
|
37
|
+
const { tableInstance, data, selectedRowData, rowOnChange, error, loading } =
|
|
38
38
|
useHTableContext();
|
|
39
39
|
const {
|
|
40
40
|
emptyRender: tableEmptyRender = defaultRender,
|
|
@@ -79,13 +79,17 @@ export default ({
|
|
|
79
79
|
const { pageSize: ps, current: pn } = paginationData;
|
|
80
80
|
onPageChange?.({ size: ps, current: pn });
|
|
81
81
|
}}
|
|
82
|
-
pagination={
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
pagination={
|
|
83
|
+
pagination === false
|
|
84
|
+
? pagination
|
|
85
|
+
: {
|
|
86
|
+
current: Number.parseInt(current || "1", 10),
|
|
87
|
+
total: Number.parseInt(total || "0", 10),
|
|
88
|
+
pageSize: Number.parseInt(size || "10", 10),
|
|
89
|
+
showQuickJumper: true,
|
|
90
|
+
...pagination,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
89
93
|
/>
|
|
90
94
|
</ConfigProvider>
|
|
91
95
|
</div>
|
|
@@ -2,7 +2,7 @@ import { Card, Affix, Row, Space, Button } from "antd";
|
|
|
2
2
|
import { Typography } from "antd";
|
|
3
3
|
import type { ActionRenderFn } from "../modal";
|
|
4
4
|
import { useHTableContext } from "../context";
|
|
5
|
-
import React, {useEffect, useState} from "react";
|
|
5
|
+
import React, { useEffect, useState } from "react";
|
|
6
6
|
import type { HTableInstance, ResultModal, RowObj } from "../modal";
|
|
7
7
|
|
|
8
8
|
const { Text, Link } = Typography;
|
|
@@ -16,11 +16,17 @@ interface IFooterProps {
|
|
|
16
16
|
footerStyle?: React.CSSProperties;
|
|
17
17
|
}
|
|
18
18
|
export default ({ actionRender, footerRender, footerStyle }: IFooterProps) => {
|
|
19
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
data,
|
|
21
|
+
selectedRowData = {},
|
|
22
|
+
allSelectChange,
|
|
23
|
+
tableInstance,
|
|
24
|
+
error,
|
|
25
|
+
} = useHTableContext();
|
|
20
26
|
const { total = "0" } = data || {};
|
|
21
27
|
const totalNum = Number.parseInt(total, 10);
|
|
22
28
|
const showTotalNum = Number.isNaN(totalNum) ? 0 : totalNum;
|
|
23
|
-
const {keys=[],selectAll=false}=selectedRowData;
|
|
29
|
+
const { keys = [], selectAll = false } = selectedRowData;
|
|
24
30
|
const num = selectAll ? showTotalNum : keys.length;
|
|
25
31
|
if (footerRender) {
|
|
26
32
|
return <>{footerRender(tableInstance, selectedRowData, data)}</>;
|
|
@@ -21,7 +21,7 @@ export default ({
|
|
|
21
21
|
searchSpan = { span: 6 },
|
|
22
22
|
headerStyle,
|
|
23
23
|
}: IHeaderProps) => {
|
|
24
|
-
const { tableInstance
|
|
24
|
+
const { tableInstance, loading } = useHTableContext();
|
|
25
25
|
const { form } = tableInstance;
|
|
26
26
|
|
|
27
27
|
const nConfigData: HItemProps[] = useMemo(
|
package/src/components/Table.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export default ({
|
|
|
39
39
|
const fn = action[key];
|
|
40
40
|
fn?.(params);
|
|
41
41
|
};
|
|
42
|
-
const { selectedRowData, rowOnChange
|
|
42
|
+
const { selectedRowData, rowOnChange, allSelectChange } = useRowObj();
|
|
43
43
|
const tableInstance = useCurrentTable({
|
|
44
44
|
table,
|
|
45
45
|
reload: (params) => {
|
|
@@ -58,7 +58,7 @@ export default ({
|
|
|
58
58
|
data,
|
|
59
59
|
error,
|
|
60
60
|
loading,
|
|
61
|
-
allSelectChange
|
|
61
|
+
allSelectChange,
|
|
62
62
|
}}
|
|
63
63
|
>
|
|
64
64
|
<Space
|
|
@@ -7,8 +7,8 @@ interface HContextModal {
|
|
|
7
7
|
selectedRowData: RowObj;
|
|
8
8
|
rowOnChange: (keys: React.Key[], rowData: any[]) => void;
|
|
9
9
|
error?: Error;
|
|
10
|
-
loading?:boolean;
|
|
11
|
-
allSelectChange?:VoidFunction;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
allSelectChange?: VoidFunction;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const HTableContext = React.createContext<HContextModal | null>(null);
|
|
@@ -4,21 +4,21 @@ import type { RowObj } from "../modal";
|
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
6
|
const [selectedRowData, setSelectedRowData] = useState<RowObj>({});
|
|
7
|
-
const {selectAll=false}=selectedRowData;
|
|
7
|
+
const { selectAll = false } = selectedRowData;
|
|
8
8
|
const rowOnChange = (keys: React.Key[], rowData: any[]) => {
|
|
9
9
|
setSelectedRowData({
|
|
10
10
|
keys,
|
|
11
11
|
rowData,
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
-
const allSelectChange=()=>{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
14
|
+
const allSelectChange = () => {
|
|
15
|
+
setSelectedRowData({
|
|
16
|
+
selectAll: !selectAll,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
19
|
return {
|
|
20
20
|
rowOnChange,
|
|
21
21
|
selectedRowData,
|
|
22
|
-
allSelectChange
|
|
22
|
+
allSelectChange,
|
|
23
23
|
};
|
|
24
24
|
};
|
package/src/components/index.tsx
CHANGED