@hw-component/table 1.9.62 → 1.9.64
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/.eslintcache +1 -1
- package/es/HTableBody/RowCheckBox/RowItem.d.ts +10 -0
- package/es/HTableBody/RowCheckBox/RowItem.js +62 -0
- package/es/HTableBody/RowCheckBox/Title.d.ts +4 -0
- package/es/HTableBody/RowCheckBox/Title.js +81 -0
- package/es/HTableBody/RowCheckBox/hooks.d.ts +9 -0
- package/es/HTableBody/RowCheckBox/hooks.js +77 -0
- package/es/HTableBody/hooks/colsMk.js +2 -1
- package/es/render/Text.d.ts +1 -0
- package/lib/HTableBody/RowCheckBox/RowItem.d.ts +10 -0
- package/lib/HTableBody/RowCheckBox/RowItem.js +65 -0
- package/lib/HTableBody/RowCheckBox/Title.d.ts +4 -0
- package/lib/HTableBody/RowCheckBox/Title.js +84 -0
- package/lib/HTableBody/RowCheckBox/hooks.d.ts +9 -0
- package/lib/HTableBody/RowCheckBox/hooks.js +79 -0
- package/lib/HTableBody/hooks/colsMk.js +4 -3
- package/lib/render/Text.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/HTableBody/RowCheckBox/RowItem.tsx +49 -0
- package/src/components/HTableBody/RowCheckBox/Title.tsx +66 -0
- package/src/components/HTableBody/RowCheckBox/hooks.ts +68 -0
- package/src/components/HTableBody/hooks/colsMk.tsx +2 -2
- package/src/pages/DwTable/index.tsx +7 -2
- package/src/pages/Table/index.tsx +0 -2
- package/es/HTableBody/RowCheckBoxSelection.d.ts +0 -11
- package/es/HTableBody/RowCheckBoxSelection.js +0 -172
- package/lib/HTableBody/RowCheckBoxSelection.d.ts +0 -11
- package/lib/HTableBody/RowCheckBoxSelection.js +0 -174
- package/src/components/HTableBody/RowCheckBoxSelection.tsx +0 -151
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { useHTableContext } from "../context";
|
|
2
|
-
import { Checkbox, Dropdown, Menu } from "antd";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import type { HRowSelection } from "../modal";
|
|
5
|
-
|
|
6
|
-
export const RowCheckBoxSelectionTitle = ({
|
|
7
|
-
allPageCheck = true,
|
|
8
|
-
onChange,
|
|
9
|
-
getCheckboxProps,
|
|
10
|
-
}: HRowSelection) => {
|
|
11
|
-
const {
|
|
12
|
-
data,
|
|
13
|
-
selectedRowData,
|
|
14
|
-
rowOnChange,
|
|
15
|
-
allSelectChange,
|
|
16
|
-
rowKey = "id",
|
|
17
|
-
} = useHTableContext();
|
|
18
|
-
const { records = [] } = data || {};
|
|
19
|
-
const newData = records?.filter((item) => {
|
|
20
|
-
const { disabled = false } = getCheckboxProps?.(item) || {};
|
|
21
|
-
return !disabled;
|
|
22
|
-
});
|
|
23
|
-
const { keys, selectAll } = selectedRowData;
|
|
24
|
-
const allCheck = () => {
|
|
25
|
-
const setKeys = newData.map((item, index) => {
|
|
26
|
-
return typeof rowKey === "function"
|
|
27
|
-
? rowKey(item, index)
|
|
28
|
-
: item[rowKey as string];
|
|
29
|
-
});
|
|
30
|
-
rowOnChange(setKeys, newData);
|
|
31
|
-
onChange?.(setKeys, newData);
|
|
32
|
-
};
|
|
33
|
-
const allCancel = () => {
|
|
34
|
-
rowOnChange([], []);
|
|
35
|
-
onChange?.([], []);
|
|
36
|
-
};
|
|
37
|
-
const checkChange = (e) => {
|
|
38
|
-
const checked = e.target.checked;
|
|
39
|
-
if (checked) {
|
|
40
|
-
allCheck();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
allCancel();
|
|
44
|
-
};
|
|
45
|
-
const change = ({ key }) => {
|
|
46
|
-
if (key === "check") {
|
|
47
|
-
allCheck();
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (key === "cancel") {
|
|
51
|
-
allCancel();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (key === "checkAll") {
|
|
55
|
-
allSelectChange?.(true);
|
|
56
|
-
onChange?.([], []);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
allSelectChange?.(false);
|
|
60
|
-
onChange?.([], []);
|
|
61
|
-
};
|
|
62
|
-
const len = keys?.length || 0;
|
|
63
|
-
const dataLen = newData?.length || 0;
|
|
64
|
-
const checked = len === dataLen && len !== 0;
|
|
65
|
-
const configItems = useMemo(() => {
|
|
66
|
-
const fsArray = checked
|
|
67
|
-
? {
|
|
68
|
-
label: "取消此页数据",
|
|
69
|
-
key: "cancel",
|
|
70
|
-
}
|
|
71
|
-
: {
|
|
72
|
-
label: "选择此页数据",
|
|
73
|
-
key: "check",
|
|
74
|
-
};
|
|
75
|
-
const enArray = selectAll
|
|
76
|
-
? {
|
|
77
|
-
label: "取消全部数据",
|
|
78
|
-
key: "cancelAll",
|
|
79
|
-
}
|
|
80
|
-
: {
|
|
81
|
-
label: "选择全部数据",
|
|
82
|
-
key: "checkAll",
|
|
83
|
-
};
|
|
84
|
-
return [fsArray, enArray];
|
|
85
|
-
}, [checked, selectAll]);
|
|
86
|
-
|
|
87
|
-
const menu = () => {
|
|
88
|
-
const MenuEle = Menu as any;
|
|
89
|
-
return <MenuEle onClick={change} items={configItems} />;
|
|
90
|
-
};
|
|
91
|
-
const disabled = dataLen === 0;
|
|
92
|
-
if (allPageCheck) {
|
|
93
|
-
return (
|
|
94
|
-
<Dropdown overlay={menu} arrow placement={"bottom"} disabled={disabled}>
|
|
95
|
-
<Checkbox
|
|
96
|
-
checked={checked}
|
|
97
|
-
onChange={checkChange}
|
|
98
|
-
disabled={disabled}
|
|
99
|
-
/>
|
|
100
|
-
</Dropdown>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
return (
|
|
104
|
-
<Checkbox checked={checked} onChange={checkChange} disabled={disabled} />
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
interface RowSelectionBoxProps {
|
|
109
|
-
data: any;
|
|
110
|
-
onChange?: HRowSelection["onChange"];
|
|
111
|
-
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
112
|
-
index: number;
|
|
113
|
-
}
|
|
114
|
-
export const RowCheckBoxSelection = ({
|
|
115
|
-
data,
|
|
116
|
-
onChange,
|
|
117
|
-
index,
|
|
118
|
-
getCheckboxProps,
|
|
119
|
-
}: RowSelectionBoxProps) => {
|
|
120
|
-
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
121
|
-
const { rowData = [], keys = [] } = selectedRowData;
|
|
122
|
-
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
123
|
-
const add = () => {
|
|
124
|
-
const newKeys = [...keys];
|
|
125
|
-
const newRowData = [...rowData];
|
|
126
|
-
newKeys.push(key);
|
|
127
|
-
newRowData.push(data);
|
|
128
|
-
rowOnChange(newKeys, newRowData);
|
|
129
|
-
onChange?.(newKeys, newRowData);
|
|
130
|
-
};
|
|
131
|
-
const cancel = () => {
|
|
132
|
-
const newKeys = [...keys];
|
|
133
|
-
const newRowData = [...rowData];
|
|
134
|
-
const keyIndex = newKeys.indexOf(key);
|
|
135
|
-
newKeys.splice(keyIndex, 1);
|
|
136
|
-
newRowData.splice(keyIndex, 1);
|
|
137
|
-
rowOnChange(newKeys, newRowData);
|
|
138
|
-
onChange?.(newKeys, newRowData);
|
|
139
|
-
};
|
|
140
|
-
const check = (e) => {
|
|
141
|
-
const checked = e.target.checked;
|
|
142
|
-
if (checked) {
|
|
143
|
-
add();
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
cancel();
|
|
147
|
-
};
|
|
148
|
-
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
149
|
-
const checked = keys.indexOf(key) !== -1;
|
|
150
|
-
return <Checkbox checked={checked} onChange={check} disabled={disabled} />;
|
|
151
|
-
};
|