@hw-component/table 0.0.5-beta-v1 → 0.0.5-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/es/HTableBody/RowSelection.d.ts +4 -3
- package/es/HTableBody/RowSelection.js +25 -11
- package/es/HTableBody/hooks.js +8 -4
- package/es/HTableBody/index.d.ts +1 -1
- package/es/HTableBody/index.js +0 -1
- package/es/modal.d.ts +2 -2
- package/lib/HTableBody/RowSelection.d.ts +4 -3
- package/lib/HTableBody/RowSelection.js +25 -11
- package/lib/HTableBody/hooks.js +8 -4
- package/lib/HTableBody/index.d.ts +1 -1
- package/lib/HTableBody/index.js +0 -1
- package/lib/modal.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/HTableBody/RowSelection.tsx +46 -22
- package/src/components/HTableBody/hooks.tsx +18 -6
- package/src/components/HTableBody/index.tsx +12 -8
- package/src/components/TableCustomize.tsx +2 -2
- package/src/components/modal.ts +5 -5
- package/src/pages/Table/index.tsx +3 -5
- package/src/pages/TableCustomize/index.tsx +5 -0
- package/src/routes.tsx +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { HRowSelection } from "../modal";
|
|
2
|
-
export declare const RowSelectionTitle: ({ allPageCheck, onChange }: HRowSelection) => JSX.Element;
|
|
1
|
+
import type { HRowSelection } from "../modal";
|
|
2
|
+
export declare const RowSelectionTitle: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
|
|
3
3
|
interface RowSelectionBoxProps {
|
|
4
4
|
data: any;
|
|
5
5
|
onChange?: HRowSelection["onChange"];
|
|
6
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
6
7
|
}
|
|
7
|
-
export declare const RowSelectionBox: ({ data, onChange }: RowSelectionBoxProps) => JSX.Element;
|
|
8
|
+
export declare const RowSelectionBox: ({ data, onChange, getCheckboxProps, }: RowSelectionBoxProps) => JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
2
|
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
3
4
|
import _keysInstanceProperty from '@babel/runtime-corejs3/core-js/instance/keys';
|
|
4
5
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
5
6
|
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/index-of';
|
|
@@ -12,7 +13,8 @@ import { useMemo } from 'react';
|
|
|
12
13
|
var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
13
14
|
var _ref$allPageCheck = _ref.allPageCheck,
|
|
14
15
|
allPageCheck = _ref$allPageCheck === void 0 ? true : _ref$allPageCheck,
|
|
15
|
-
onChange = _ref.onChange
|
|
16
|
+
onChange = _ref.onChange,
|
|
17
|
+
getCheckboxProps = _ref.getCheckboxProps;
|
|
16
18
|
var _useHTableContext = useHTableContext(),
|
|
17
19
|
data = _useHTableContext.data,
|
|
18
20
|
selectedRowData = _useHTableContext.selectedRowData,
|
|
@@ -23,14 +25,20 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
23
25
|
var _ref2 = data || {},
|
|
24
26
|
_ref2$records = _ref2.records,
|
|
25
27
|
records = _ref2$records === void 0 ? [] : _ref2$records;
|
|
28
|
+
var newData = records === null || records === void 0 ? void 0 : _filterInstanceProperty(records).call(records, function (item) {
|
|
29
|
+
var _ref3 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
30
|
+
_ref3$disabled = _ref3.disabled,
|
|
31
|
+
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
|
|
32
|
+
return !disabled;
|
|
33
|
+
});
|
|
26
34
|
var keys = _keysInstanceProperty(selectedRowData),
|
|
27
35
|
selectAll = selectedRowData.selectAll;
|
|
28
36
|
var allCheck = function allCheck() {
|
|
29
|
-
var setKeys = _mapInstanceProperty(
|
|
37
|
+
var setKeys = _mapInstanceProperty(newData).call(newData, function (item) {
|
|
30
38
|
return item[rowKey];
|
|
31
39
|
});
|
|
32
|
-
rowOnChange(setKeys,
|
|
33
|
-
onChange === null || onChange === void 0 || onChange(setKeys,
|
|
40
|
+
rowOnChange(setKeys, newData);
|
|
41
|
+
onChange === null || onChange === void 0 || onChange(setKeys, newData);
|
|
34
42
|
};
|
|
35
43
|
var allCancel = function allCancel() {
|
|
36
44
|
rowOnChange([], []);
|
|
@@ -44,8 +52,8 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
44
52
|
}
|
|
45
53
|
allCancel();
|
|
46
54
|
};
|
|
47
|
-
var change = function change(
|
|
48
|
-
var key =
|
|
55
|
+
var change = function change(_ref4) {
|
|
56
|
+
var key = _ref4.key;
|
|
49
57
|
if (key === "check") {
|
|
50
58
|
allCheck();
|
|
51
59
|
return;
|
|
@@ -63,7 +71,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
63
71
|
onChange === null || onChange === void 0 || onChange([], []);
|
|
64
72
|
};
|
|
65
73
|
var len = (keys === null || keys === void 0 ? void 0 : keys.length) || 0;
|
|
66
|
-
var dataLen = (
|
|
74
|
+
var dataLen = (newData === null || newData === void 0 ? void 0 : newData.length) || 0;
|
|
67
75
|
var checked = len === dataLen && len !== 0;
|
|
68
76
|
var configItems = useMemo(function () {
|
|
69
77
|
var fsArray = checked ? {
|
|
@@ -90,6 +98,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
90
98
|
});
|
|
91
99
|
};
|
|
92
100
|
var disabled = dataLen === 0;
|
|
101
|
+
console.log(dataLen, "dadada");
|
|
93
102
|
if (allPageCheck) {
|
|
94
103
|
return jsx(Dropdown, {
|
|
95
104
|
overlay: menu,
|
|
@@ -109,9 +118,10 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
109
118
|
disabled: disabled
|
|
110
119
|
});
|
|
111
120
|
};
|
|
112
|
-
var RowSelectionBox = function RowSelectionBox(
|
|
113
|
-
var data =
|
|
114
|
-
onChange =
|
|
121
|
+
var RowSelectionBox = function RowSelectionBox(_ref5) {
|
|
122
|
+
var data = _ref5.data,
|
|
123
|
+
onChange = _ref5.onChange,
|
|
124
|
+
getCheckboxProps = _ref5.getCheckboxProps;
|
|
115
125
|
var _useHTableContext2 = useHTableContext(),
|
|
116
126
|
selectedRowData = _useHTableContext2.selectedRowData,
|
|
117
127
|
rowOnChange = _useHTableContext2.rowOnChange,
|
|
@@ -139,9 +149,13 @@ var RowSelectionBox = function RowSelectionBox(_ref4) {
|
|
|
139
149
|
rowOnChange(newKeys, newRowData);
|
|
140
150
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
141
151
|
};
|
|
152
|
+
var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
153
|
+
_ref6$disabled = _ref6.disabled,
|
|
154
|
+
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
|
|
142
155
|
return jsx(Checkbox, {
|
|
143
156
|
checked: _indexOfInstanceProperty(keys).call(keys, key) !== -1,
|
|
144
|
-
onChange: check
|
|
157
|
+
onChange: check,
|
|
158
|
+
disabled: disabled
|
|
145
159
|
});
|
|
146
160
|
};
|
|
147
161
|
|
package/es/HTableBody/hooks.js
CHANGED
|
@@ -22,17 +22,21 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
22
22
|
var rowSelectionCol = function rowSelectionCol(rowSelection) {
|
|
23
23
|
var _ref = rowSelection || {},
|
|
24
24
|
allPageCheck = _ref.allPageCheck,
|
|
25
|
-
onChange = _ref.onChange
|
|
25
|
+
onChange = _ref.onChange,
|
|
26
|
+
getCheckboxProps = _ref.getCheckboxProps;
|
|
26
27
|
return {
|
|
27
28
|
title: jsx(RowSelectionTitle, {
|
|
28
29
|
allPageCheck: allPageCheck,
|
|
29
|
-
onChange: onChange
|
|
30
|
+
onChange: onChange,
|
|
31
|
+
getCheckboxProps: getCheckboxProps
|
|
30
32
|
}),
|
|
31
33
|
dataIndex: "rowSelectionTitle",
|
|
32
34
|
width: 32,
|
|
33
35
|
render: function render(dom, data) {
|
|
34
36
|
return jsx(RowSelectionBox, {
|
|
35
|
-
data: data
|
|
37
|
+
data: data,
|
|
38
|
+
onChange: onChange,
|
|
39
|
+
getCheckboxProps: getCheckboxProps
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
};
|
|
@@ -57,7 +61,7 @@ var useCols = function useCols(_ref2) {
|
|
|
57
61
|
}
|
|
58
62
|
});
|
|
59
63
|
});
|
|
60
|
-
}, [configData, table]);
|
|
64
|
+
}, [configData, table, rowSelection]);
|
|
61
65
|
};
|
|
62
66
|
var useSynchronousKeys = function useSynchronousKeys(_ref3) {
|
|
63
67
|
var selectedRowKeys = _ref3.selectedRowKeys,
|
package/es/HTableBody/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ProTableProps } from "@ant-design/pro-table";
|
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { HTableInstance } from "../modal";
|
|
5
|
-
import { HRowSelection } from "../modal";
|
|
5
|
+
import type { HRowSelection } from "../modal";
|
|
6
6
|
interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
|
|
7
7
|
configData?: ConfigDataModal;
|
|
8
8
|
onPageChange?: (params: ParamsModal) => void;
|
package/es/HTableBody/index.js
CHANGED
|
@@ -52,7 +52,6 @@ var Body = (function (_ref) {
|
|
|
52
52
|
actionRender = _ref.actionRender,
|
|
53
53
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
54
54
|
var selectedRowKeys = rowSelection.selectedRowKeys;
|
|
55
|
-
rowSelection.onChange;
|
|
56
55
|
var _useHTableContext = useHTableContext(),
|
|
57
56
|
tableInstance = _useHTableContext.tableInstance,
|
|
58
57
|
contextConfigData = _useHTableContext.configData,
|
package/es/modal.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal
|
|
|
4
4
|
import type { ColProps } from "antd";
|
|
5
5
|
import type React from "react";
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
|
-
import { TableProps } from "antd/lib/table";
|
|
7
|
+
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
export interface RowObj {
|
|
9
9
|
keys?: React.Key[];
|
|
10
10
|
rowData?: any[];
|
|
@@ -34,7 +34,7 @@ export type actionFn = (...arg: any[]) => void;
|
|
|
34
34
|
export interface RowSelectionOuter {
|
|
35
35
|
allPageCheck?: boolean;
|
|
36
36
|
}
|
|
37
|
-
export type HRowSelection = RowSelectionOuter & (TableProps<any>[
|
|
37
|
+
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
38
38
|
alwaysShowAlert?: boolean;
|
|
39
39
|
});
|
|
40
40
|
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowKey" | "rowSelection"> {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { HRowSelection } from "../modal";
|
|
2
|
-
export declare const RowSelectionTitle: ({ allPageCheck, onChange }: HRowSelection) => JSX.Element;
|
|
1
|
+
import type { HRowSelection } from "../modal";
|
|
2
|
+
export declare const RowSelectionTitle: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
|
|
3
3
|
interface RowSelectionBoxProps {
|
|
4
4
|
data: any;
|
|
5
5
|
onChange?: HRowSelection["onChange"];
|
|
6
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
6
7
|
}
|
|
7
|
-
export declare const RowSelectionBox: ({ data, onChange }: RowSelectionBoxProps) => JSX.Element;
|
|
8
|
+
export declare const RowSelectionBox: ({ data, onChange, getCheckboxProps, }: RowSelectionBoxProps) => JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
4
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
4
5
|
var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/keys');
|
|
5
6
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
6
7
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/index-of');
|
|
@@ -13,7 +14,8 @@ var React = require('react');
|
|
|
13
14
|
var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
14
15
|
var _ref$allPageCheck = _ref.allPageCheck,
|
|
15
16
|
allPageCheck = _ref$allPageCheck === void 0 ? true : _ref$allPageCheck,
|
|
16
|
-
onChange = _ref.onChange
|
|
17
|
+
onChange = _ref.onChange,
|
|
18
|
+
getCheckboxProps = _ref.getCheckboxProps;
|
|
17
19
|
var _useHTableContext = context.useHTableContext(),
|
|
18
20
|
data = _useHTableContext.data,
|
|
19
21
|
selectedRowData = _useHTableContext.selectedRowData,
|
|
@@ -24,14 +26,20 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
24
26
|
var _ref2 = data || {},
|
|
25
27
|
_ref2$records = _ref2.records,
|
|
26
28
|
records = _ref2$records === void 0 ? [] : _ref2$records;
|
|
29
|
+
var newData = records === null || records === void 0 ? void 0 : _filterInstanceProperty(records).call(records, function (item) {
|
|
30
|
+
var _ref3 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
31
|
+
_ref3$disabled = _ref3.disabled,
|
|
32
|
+
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
|
|
33
|
+
return !disabled;
|
|
34
|
+
});
|
|
27
35
|
var keys = _keysInstanceProperty(selectedRowData),
|
|
28
36
|
selectAll = selectedRowData.selectAll;
|
|
29
37
|
var allCheck = function allCheck() {
|
|
30
|
-
var setKeys = _mapInstanceProperty(
|
|
38
|
+
var setKeys = _mapInstanceProperty(newData).call(newData, function (item) {
|
|
31
39
|
return item[rowKey];
|
|
32
40
|
});
|
|
33
|
-
rowOnChange(setKeys,
|
|
34
|
-
onChange === null || onChange === void 0 || onChange(setKeys,
|
|
41
|
+
rowOnChange(setKeys, newData);
|
|
42
|
+
onChange === null || onChange === void 0 || onChange(setKeys, newData);
|
|
35
43
|
};
|
|
36
44
|
var allCancel = function allCancel() {
|
|
37
45
|
rowOnChange([], []);
|
|
@@ -45,8 +53,8 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
45
53
|
}
|
|
46
54
|
allCancel();
|
|
47
55
|
};
|
|
48
|
-
var change = function change(
|
|
49
|
-
var key =
|
|
56
|
+
var change = function change(_ref4) {
|
|
57
|
+
var key = _ref4.key;
|
|
50
58
|
if (key === "check") {
|
|
51
59
|
allCheck();
|
|
52
60
|
return;
|
|
@@ -64,7 +72,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
64
72
|
onChange === null || onChange === void 0 || onChange([], []);
|
|
65
73
|
};
|
|
66
74
|
var len = (keys === null || keys === void 0 ? void 0 : keys.length) || 0;
|
|
67
|
-
var dataLen = (
|
|
75
|
+
var dataLen = (newData === null || newData === void 0 ? void 0 : newData.length) || 0;
|
|
68
76
|
var checked = len === dataLen && len !== 0;
|
|
69
77
|
var configItems = React.useMemo(function () {
|
|
70
78
|
var fsArray = checked ? {
|
|
@@ -91,6 +99,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
91
99
|
});
|
|
92
100
|
};
|
|
93
101
|
var disabled = dataLen === 0;
|
|
102
|
+
console.log(dataLen, "dadada");
|
|
94
103
|
if (allPageCheck) {
|
|
95
104
|
return jsxRuntime.jsx(antd.Dropdown, {
|
|
96
105
|
overlay: menu,
|
|
@@ -110,9 +119,10 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
|
110
119
|
disabled: disabled
|
|
111
120
|
});
|
|
112
121
|
};
|
|
113
|
-
var RowSelectionBox = function RowSelectionBox(
|
|
114
|
-
var data =
|
|
115
|
-
onChange =
|
|
122
|
+
var RowSelectionBox = function RowSelectionBox(_ref5) {
|
|
123
|
+
var data = _ref5.data,
|
|
124
|
+
onChange = _ref5.onChange,
|
|
125
|
+
getCheckboxProps = _ref5.getCheckboxProps;
|
|
116
126
|
var _useHTableContext2 = context.useHTableContext(),
|
|
117
127
|
selectedRowData = _useHTableContext2.selectedRowData,
|
|
118
128
|
rowOnChange = _useHTableContext2.rowOnChange,
|
|
@@ -140,9 +150,13 @@ var RowSelectionBox = function RowSelectionBox(_ref4) {
|
|
|
140
150
|
rowOnChange(newKeys, newRowData);
|
|
141
151
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
142
152
|
};
|
|
153
|
+
var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
154
|
+
_ref6$disabled = _ref6.disabled,
|
|
155
|
+
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
|
|
143
156
|
return jsxRuntime.jsx(antd.Checkbox, {
|
|
144
157
|
checked: _indexOfInstanceProperty(keys).call(keys, key) !== -1,
|
|
145
|
-
onChange: check
|
|
158
|
+
onChange: check,
|
|
159
|
+
disabled: disabled
|
|
146
160
|
});
|
|
147
161
|
};
|
|
148
162
|
|
package/lib/HTableBody/hooks.js
CHANGED
|
@@ -23,17 +23,21 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
23
23
|
var rowSelectionCol = function rowSelectionCol(rowSelection) {
|
|
24
24
|
var _ref = rowSelection || {},
|
|
25
25
|
allPageCheck = _ref.allPageCheck,
|
|
26
|
-
onChange = _ref.onChange
|
|
26
|
+
onChange = _ref.onChange,
|
|
27
|
+
getCheckboxProps = _ref.getCheckboxProps;
|
|
27
28
|
return {
|
|
28
29
|
title: jsxRuntime.jsx(RowSelection.RowSelectionTitle, {
|
|
29
30
|
allPageCheck: allPageCheck,
|
|
30
|
-
onChange: onChange
|
|
31
|
+
onChange: onChange,
|
|
32
|
+
getCheckboxProps: getCheckboxProps
|
|
31
33
|
}),
|
|
32
34
|
dataIndex: "rowSelectionTitle",
|
|
33
35
|
width: 32,
|
|
34
36
|
render: function render(dom, data) {
|
|
35
37
|
return jsxRuntime.jsx(RowSelection.RowSelectionBox, {
|
|
36
|
-
data: data
|
|
38
|
+
data: data,
|
|
39
|
+
onChange: onChange,
|
|
40
|
+
getCheckboxProps: getCheckboxProps
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
};
|
|
@@ -58,7 +62,7 @@ var useCols = function useCols(_ref2) {
|
|
|
58
62
|
}
|
|
59
63
|
});
|
|
60
64
|
});
|
|
61
|
-
}, [configData, table]);
|
|
65
|
+
}, [configData, table, rowSelection]);
|
|
62
66
|
};
|
|
63
67
|
var useSynchronousKeys = function useSynchronousKeys(_ref3) {
|
|
64
68
|
var selectedRowKeys = _ref3.selectedRowKeys,
|
|
@@ -2,7 +2,7 @@ import type { ProTableProps } from "@ant-design/pro-table";
|
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { HTableInstance } from "../modal";
|
|
5
|
-
import { HRowSelection } from "../modal";
|
|
5
|
+
import type { HRowSelection } from "../modal";
|
|
6
6
|
interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
|
|
7
7
|
configData?: ConfigDataModal;
|
|
8
8
|
onPageChange?: (params: ParamsModal) => void;
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -55,7 +55,6 @@ var Body = (function (_ref) {
|
|
|
55
55
|
actionRender = _ref.actionRender,
|
|
56
56
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
57
|
var selectedRowKeys = rowSelection.selectedRowKeys;
|
|
58
|
-
rowSelection.onChange;
|
|
59
58
|
var _useHTableContext = context.useHTableContext(),
|
|
60
59
|
tableInstance = _useHTableContext.tableInstance,
|
|
61
60
|
contextConfigData = _useHTableContext.configData,
|
package/lib/modal.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal
|
|
|
4
4
|
import type { ColProps } from "antd";
|
|
5
5
|
import type React from "react";
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
|
-
import { TableProps } from "antd/lib/table";
|
|
7
|
+
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
export interface RowObj {
|
|
9
9
|
keys?: React.Key[];
|
|
10
10
|
rowData?: any[];
|
|
@@ -34,7 +34,7 @@ export type actionFn = (...arg: any[]) => void;
|
|
|
34
34
|
export interface RowSelectionOuter {
|
|
35
35
|
allPageCheck?: boolean;
|
|
36
36
|
}
|
|
37
|
-
export type HRowSelection = RowSelectionOuter & (TableProps<any>[
|
|
37
|
+
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
38
38
|
alwaysShowAlert?: boolean;
|
|
39
39
|
});
|
|
40
40
|
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowKey" | "rowSelection"> {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useHTableContext } from "../context";
|
|
2
2
|
import { Checkbox, Dropdown, Menu } from "antd";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import {HRowSelection} from "../modal";
|
|
4
|
+
import type { HRowSelection } from "../modal";
|
|
5
5
|
export const RowSelectionTitle = ({
|
|
6
6
|
allPageCheck = true,
|
|
7
|
-
onChange
|
|
7
|
+
onChange,
|
|
8
|
+
getCheckboxProps,
|
|
8
9
|
}: HRowSelection) => {
|
|
9
10
|
const {
|
|
10
11
|
data,
|
|
@@ -14,17 +15,21 @@ export const RowSelectionTitle = ({
|
|
|
14
15
|
rowKey = "id",
|
|
15
16
|
} = useHTableContext();
|
|
16
17
|
const { records = [] } = data || {};
|
|
18
|
+
const newData = records?.filter((item) => {
|
|
19
|
+
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
20
|
+
return !disabled;
|
|
21
|
+
});
|
|
17
22
|
const { keys, selectAll } = selectedRowData;
|
|
18
23
|
const allCheck = () => {
|
|
19
|
-
const setKeys =
|
|
24
|
+
const setKeys = newData.map((item) => {
|
|
20
25
|
return item[rowKey];
|
|
21
26
|
});
|
|
22
|
-
rowOnChange(setKeys,
|
|
23
|
-
onChange?.(setKeys,
|
|
27
|
+
rowOnChange(setKeys, newData);
|
|
28
|
+
onChange?.(setKeys, newData);
|
|
24
29
|
};
|
|
25
30
|
const allCancel = () => {
|
|
26
31
|
rowOnChange([], []);
|
|
27
|
-
onChange?.([],[]);
|
|
32
|
+
onChange?.([], []);
|
|
28
33
|
};
|
|
29
34
|
const checkChange = (e) => {
|
|
30
35
|
const checked = e.target.checked;
|
|
@@ -45,14 +50,14 @@ export const RowSelectionTitle = ({
|
|
|
45
50
|
}
|
|
46
51
|
if (key === "checkAll") {
|
|
47
52
|
allSelectChange?.(true);
|
|
48
|
-
onChange?.([],[]);
|
|
53
|
+
onChange?.([], []);
|
|
49
54
|
return;
|
|
50
55
|
}
|
|
51
56
|
allSelectChange?.(false);
|
|
52
|
-
onChange?.([],[]);
|
|
57
|
+
onChange?.([], []);
|
|
53
58
|
};
|
|
54
|
-
const len = keys?.length||0;
|
|
55
|
-
const dataLen=
|
|
59
|
+
const len = keys?.length || 0;
|
|
60
|
+
const dataLen = newData?.length || 0;
|
|
56
61
|
const checked = len === dataLen && len !== 0;
|
|
57
62
|
const configItems = useMemo(() => {
|
|
58
63
|
const fsArray = checked
|
|
@@ -76,26 +81,38 @@ export const RowSelectionTitle = ({
|
|
|
76
81
|
return [fsArray, enArray];
|
|
77
82
|
}, [checked, selectAll]);
|
|
78
83
|
|
|
79
|
-
const menu = ()=>{
|
|
80
|
-
const MenuEle=
|
|
81
|
-
return <MenuEle onClick={change} items={configItems}/>;
|
|
82
|
-
}
|
|
83
|
-
const disabled=dataLen===0;
|
|
84
|
+
const menu = () => {
|
|
85
|
+
const MenuEle = Menu as any;
|
|
86
|
+
return <MenuEle onClick={change} items={configItems} />;
|
|
87
|
+
};
|
|
88
|
+
const disabled = dataLen === 0;
|
|
89
|
+
console.log(dataLen, "dadada");
|
|
84
90
|
if (allPageCheck) {
|
|
85
91
|
return (
|
|
86
92
|
<Dropdown overlay={menu} arrow placement={"bottom"} disabled={disabled}>
|
|
87
|
-
<Checkbox
|
|
93
|
+
<Checkbox
|
|
94
|
+
checked={checked}
|
|
95
|
+
onChange={checkChange}
|
|
96
|
+
disabled={disabled}
|
|
97
|
+
/>
|
|
88
98
|
</Dropdown>
|
|
89
99
|
);
|
|
90
100
|
}
|
|
91
|
-
return
|
|
101
|
+
return (
|
|
102
|
+
<Checkbox checked={checked} onChange={checkChange} disabled={disabled} />
|
|
103
|
+
);
|
|
92
104
|
};
|
|
93
105
|
|
|
94
106
|
interface RowSelectionBoxProps {
|
|
95
107
|
data: any;
|
|
96
|
-
onChange?:HRowSelection["onChange"]
|
|
108
|
+
onChange?: HRowSelection["onChange"];
|
|
109
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
97
110
|
}
|
|
98
|
-
export const RowSelectionBox = ({
|
|
111
|
+
export const RowSelectionBox = ({
|
|
112
|
+
data,
|
|
113
|
+
onChange,
|
|
114
|
+
getCheckboxProps,
|
|
115
|
+
}: RowSelectionBoxProps) => {
|
|
99
116
|
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
100
117
|
const { rowData = [], keys = [] } = selectedRowData;
|
|
101
118
|
const key = data[rowKey];
|
|
@@ -107,14 +124,21 @@ export const RowSelectionBox = ({ data ,onChange}: RowSelectionBoxProps) => {
|
|
|
107
124
|
newKeys.push(key);
|
|
108
125
|
newRowData.push(data);
|
|
109
126
|
rowOnChange(newKeys, newRowData);
|
|
110
|
-
onChange?.(newKeys,newRowData);
|
|
127
|
+
onChange?.(newKeys, newRowData);
|
|
111
128
|
return;
|
|
112
129
|
}
|
|
113
130
|
const index = newKeys.indexOf(key);
|
|
114
131
|
newKeys.splice(index, 1);
|
|
115
132
|
newRowData.splice(index, 1);
|
|
116
133
|
rowOnChange(newKeys, newRowData);
|
|
117
|
-
onChange?.(newKeys,newRowData);
|
|
134
|
+
onChange?.(newKeys, newRowData);
|
|
118
135
|
};
|
|
119
|
-
|
|
136
|
+
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
137
|
+
return (
|
|
138
|
+
<Checkbox
|
|
139
|
+
checked={keys.indexOf(key) !== -1}
|
|
140
|
+
onChange={check}
|
|
141
|
+
disabled={disabled}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
120
144
|
};
|
|
@@ -4,15 +4,27 @@ import { useEffect, useMemo } from "react";
|
|
|
4
4
|
import { useHTableContext } from "../context";
|
|
5
5
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
6
6
|
import { RowSelectionBox, RowSelectionTitle } from "./RowSelection";
|
|
7
|
-
import {HRowSelection} from "../modal";
|
|
8
|
-
const rowSelectionCol = (rowSelection?:HRowSelection) => {
|
|
9
|
-
const { allPageCheck ,
|
|
7
|
+
import type { HRowSelection } from "../modal";
|
|
8
|
+
const rowSelectionCol = (rowSelection?: HRowSelection) => {
|
|
9
|
+
const { allPageCheck, onChange, getCheckboxProps } = rowSelection || {};
|
|
10
10
|
return {
|
|
11
|
-
title:
|
|
11
|
+
title: (
|
|
12
|
+
<RowSelectionTitle
|
|
13
|
+
allPageCheck={allPageCheck}
|
|
14
|
+
onChange={onChange}
|
|
15
|
+
getCheckboxProps={getCheckboxProps}
|
|
16
|
+
/>
|
|
17
|
+
),
|
|
12
18
|
dataIndex: "rowSelectionTitle",
|
|
13
19
|
width: 32,
|
|
14
20
|
render: (dom, data) => {
|
|
15
|
-
return
|
|
21
|
+
return (
|
|
22
|
+
<RowSelectionBox
|
|
23
|
+
data={data}
|
|
24
|
+
onChange={onChange}
|
|
25
|
+
getCheckboxProps={getCheckboxProps}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
16
28
|
},
|
|
17
29
|
};
|
|
18
30
|
};
|
|
@@ -34,7 +46,7 @@ export const useCols = ({ configData, rowSelection, table }: HTableProps) => {
|
|
|
34
46
|
},
|
|
35
47
|
};
|
|
36
48
|
});
|
|
37
|
-
}, [configData, table]);
|
|
49
|
+
}, [configData, table, rowSelection]);
|
|
38
50
|
};
|
|
39
51
|
interface FilterKeysModal {
|
|
40
52
|
selectedRowKeys?: React.Key[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
2
2
|
import ProTable from "@ant-design/pro-table";
|
|
3
|
-
import type {ActionRenderFn, ConfigDataModal, ParamsModal} from "../modal";
|
|
3
|
+
import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
|
|
4
4
|
import { useCols, useSynchronousKeys } from "./hooks";
|
|
5
5
|
import { useHTableContext } from "../context";
|
|
6
6
|
import type { DetailedReactHTMLElement } from "react";
|
|
@@ -11,8 +11,9 @@ import { useHTableConfigContext } from "../TableConfig";
|
|
|
11
11
|
import HTablePagination from "../HTablePagination";
|
|
12
12
|
import { useClassName } from "../hooks";
|
|
13
13
|
import AlertMsg from "./AlertMsg";
|
|
14
|
-
import {HRowSelection} from "../modal";
|
|
15
|
-
interface HTableBodyProps
|
|
14
|
+
import type { HRowSelection } from "../modal";
|
|
15
|
+
interface HTableBodyProps
|
|
16
|
+
extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
|
|
16
17
|
configData?: ConfigDataModal;
|
|
17
18
|
onPageChange?: (params: ParamsModal) => void;
|
|
18
19
|
emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
@@ -22,8 +23,8 @@ interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource"|"ro
|
|
|
22
23
|
) => React.ReactNode;
|
|
23
24
|
tableStyle?: React.CSSProperties;
|
|
24
25
|
paginationStyle?: React.CSSProperties;
|
|
25
|
-
actionRender?:ActionRenderFn
|
|
26
|
-
rowSelection?:HRowSelection
|
|
26
|
+
actionRender?: ActionRenderFn;
|
|
27
|
+
rowSelection?: HRowSelection;
|
|
27
28
|
}
|
|
28
29
|
const defaultRender = () => {
|
|
29
30
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
|
@@ -45,11 +46,11 @@ export default ({
|
|
|
45
46
|
paginationStyle,
|
|
46
47
|
headerTitle,
|
|
47
48
|
options,
|
|
48
|
-
|
|
49
|
+
actionRender,
|
|
49
50
|
...props
|
|
50
51
|
}: HTableBodyProps) => {
|
|
51
52
|
// @ts-ignore
|
|
52
|
-
const { selectedRowKeys
|
|
53
|
+
const { selectedRowKeys } = rowSelection;
|
|
53
54
|
const {
|
|
54
55
|
tableInstance,
|
|
55
56
|
configData: contextConfigData,
|
|
@@ -99,7 +100,10 @@ export default ({
|
|
|
99
100
|
)}
|
|
100
101
|
{alwaysShowAlert && (
|
|
101
102
|
<div style={contentStyle}>
|
|
102
|
-
<Alert
|
|
103
|
+
<Alert
|
|
104
|
+
message={<AlertMsg actionRender={actionRender} />}
|
|
105
|
+
type="info"
|
|
106
|
+
/>
|
|
103
107
|
</div>
|
|
104
108
|
)}
|
|
105
109
|
<ProTable
|
|
@@ -12,7 +12,7 @@ const Index: React.FC<HTableProps> = ({
|
|
|
12
12
|
table,
|
|
13
13
|
action = {},
|
|
14
14
|
children,
|
|
15
|
-
|
|
15
|
+
rowKey,
|
|
16
16
|
...props
|
|
17
17
|
}) => {
|
|
18
18
|
const { run, loading, data, error, saveParams } = useReq({
|
|
@@ -57,7 +57,7 @@ const Index: React.FC<HTableProps> = ({
|
|
|
57
57
|
},
|
|
58
58
|
onPageChange: tableInstance.table.reloadWithParams,
|
|
59
59
|
setSelectedRowData,
|
|
60
|
-
|
|
60
|
+
rowKey,
|
|
61
61
|
}}
|
|
62
62
|
>
|
|
63
63
|
{children}
|
package/src/components/modal.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
import type { ColProps } from "antd";
|
|
8
8
|
import type React from "react";
|
|
9
9
|
import type { ModalProps } from "antd";
|
|
10
|
-
import {TableProps} from "antd/lib/table";
|
|
10
|
+
import type { TableProps } from "antd/lib/table";
|
|
11
11
|
|
|
12
12
|
export interface RowObj {
|
|
13
13
|
keys?: React.Key[];
|
|
@@ -58,9 +58,9 @@ export interface RowSelectionOuter {
|
|
|
58
58
|
allPageCheck?: boolean;
|
|
59
59
|
}
|
|
60
60
|
export type HRowSelection = RowSelectionOuter &
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
(TableProps<any>["rowSelection"] & {
|
|
62
|
+
alwaysShowAlert?: boolean;
|
|
63
|
+
});
|
|
64
64
|
export interface HTableProps
|
|
65
65
|
extends Omit<
|
|
66
66
|
ProTableProps<any, any>,
|
|
@@ -89,7 +89,7 @@ export interface HTableProps
|
|
|
89
89
|
paginationStyle?: React.CSSProperties;
|
|
90
90
|
rowKey?: string;
|
|
91
91
|
allPageCheck?: boolean;
|
|
92
|
-
rowSelection?: HRowSelection|false;
|
|
92
|
+
rowSelection?: HRowSelection | false;
|
|
93
93
|
}
|
|
94
94
|
export interface TableInstance {
|
|
95
95
|
reload: (params?: ParamsModal) => Promise<any>;
|
|
@@ -36,16 +36,14 @@ export default () => {
|
|
|
36
36
|
configData={configData}
|
|
37
37
|
rowKey={"id"}
|
|
38
38
|
table={hTable}
|
|
39
|
-
rowSelection={{
|
|
40
|
-
|
|
41
|
-
}}
|
|
39
|
+
rowSelection={{}}
|
|
42
40
|
options={{
|
|
43
41
|
reload: false,
|
|
44
42
|
setting: false,
|
|
45
43
|
density: false,
|
|
46
44
|
}}
|
|
47
|
-
actionRender={()=>{
|
|
48
|
-
return <Button>你大爷</Button
|
|
45
|
+
actionRender={() => {
|
|
46
|
+
return <Button>你大爷</Button>;
|
|
49
47
|
}}
|
|
50
48
|
headerTitle={<Button type={"primary"}>操作</Button>}
|
|
51
49
|
request={(params) => {
|
package/src/routes.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Navigate } from "react-router-dom";
|
|
3
3
|
import Table from "./pages/Table";
|
|
4
4
|
import ModalTable from "./pages/ModalTable";
|
|
5
|
-
import TableCustomize from
|
|
5
|
+
import TableCustomize from "./pages/TableCustomize";
|
|
6
6
|
export interface RouteModal {
|
|
7
7
|
path?: string;
|
|
8
8
|
name?: string;
|