@hw-component/table 1.9.87 → 1.9.88
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/Options/utils.d.ts +5 -2
- package/es/HTableBody/RowCheckBox/RowItem.d.ts +2 -8
- package/es/HTableBody/RowCheckBox/hooks.d.ts +2 -2
- package/es/HTableBody/RowRadioBoxSelection.d.ts +1 -8
- package/es/HTableBody/hooks/useRowClassName.d.ts +4 -0
- package/es/HTableBody/hooks/useRowClassName.js +39 -0
- package/es/HTableBody/index.js +8 -25
- package/es/HTableBody/modal.d.ts +7 -1
- package/es/HTableBody/utils.d.ts +1 -0
- package/es/HTableHeader/RangePickerSearch.d.ts +1 -1
- package/es/TableConfig.d.ts +2 -0
- package/es/TableConfig.js +4 -2
- package/es/modal.d.ts +2 -1
- package/es/render/Text.d.ts +0 -1
- package/lib/HTableBody/Options/utils.d.ts +5 -2
- package/lib/HTableBody/RowCheckBox/RowItem.d.ts +2 -8
- package/lib/HTableBody/RowCheckBox/hooks.d.ts +2 -2
- package/lib/HTableBody/RowRadioBoxSelection.d.ts +1 -8
- package/lib/HTableBody/hooks/useRowClassName.d.ts +4 -0
- package/lib/HTableBody/hooks/useRowClassName.js +42 -0
- package/lib/HTableBody/index.js +7 -24
- package/lib/HTableBody/modal.d.ts +7 -1
- package/lib/HTableBody/utils.d.ts +1 -0
- package/lib/HTableHeader/RangePickerSearch.d.ts +1 -1
- package/lib/TableConfig.d.ts +2 -0
- package/lib/TableConfig.js +4 -2
- package/lib/modal.d.ts +2 -1
- package/lib/render/Text.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/HTableBody/RowCheckBox/RowItem.tsx +2 -8
- package/src/components/HTableBody/RowCheckBox/hooks.ts +2 -2
- package/src/components/HTableBody/RowRadioBoxSelection.tsx +1 -7
- package/src/components/HTableBody/hooks/useRowClassName.ts +33 -0
- package/src/components/HTableBody/index.tsx +3 -21
- package/src/components/HTableBody/modal.ts +8 -1
- package/src/components/HTableBody/utils.ts +5 -0
- package/src/components/TableConfig.tsx +3 -0
- package/src/components/hooks/useRowObj.ts +1 -1
- package/src/components/modal.ts +6 -1
- package/src/pages/Table/index.tsx +62 -60
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HTableBodyProps } from "@/components/HTableBody/modal";
|
|
2
|
+
import { useHTableContext } from "@/components/context";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { ConfigProvider } from "antd";
|
|
5
|
+
import type { RowClassName } from "rc-table/lib/interface";
|
|
6
|
+
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
7
|
+
|
|
8
|
+
export default ({
|
|
9
|
+
rowClassName,
|
|
10
|
+
rowKey = "id",
|
|
11
|
+
}: HTableBodyProps): RowClassName<any> => {
|
|
12
|
+
const { selectedRowData } = useHTableContext();
|
|
13
|
+
const { defaultSelectedRowClassName } = useHTableConfigContext({});
|
|
14
|
+
const { keys = [] } = selectedRowData;
|
|
15
|
+
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
|
|
16
|
+
|
|
17
|
+
return (record: any, index: number, indent: number) => {
|
|
18
|
+
const key =
|
|
19
|
+
typeof rowKey === "function" ? rowKey(record, index) : record[rowKey];
|
|
20
|
+
const propsRowClassName =
|
|
21
|
+
typeof rowClassName === "function"
|
|
22
|
+
? rowClassName(record, index, indent)
|
|
23
|
+
: rowClassName;
|
|
24
|
+
const relPropsRowClassName = propsRowClassName || "";
|
|
25
|
+
if (keys?.indexOf(key) === -1) {
|
|
26
|
+
return relPropsRowClassName;
|
|
27
|
+
}
|
|
28
|
+
if (typeof defaultSelectedRowClassName === "undefined") {
|
|
29
|
+
return `${getPrefixCls("table-row-selected")} ${relPropsRowClassName}`;
|
|
30
|
+
}
|
|
31
|
+
return `${defaultSelectedRowClassName || ""} ${relPropsRowClassName}`;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -17,8 +17,7 @@ import Options from "./Options";
|
|
|
17
17
|
import HeaderTitle from "./HeaderTitle";
|
|
18
18
|
import { errorDefaultRender, emptyDefaultRender } from "./defaultRender";
|
|
19
19
|
import type { HTableBodyProps } from "./modal";
|
|
20
|
-
import
|
|
21
|
-
const { ConfigContext } = ConfigProvider;
|
|
20
|
+
import useRowClassName from "@/components/HTableBody/hooks/useRowClassName";
|
|
22
21
|
|
|
23
22
|
export default (bodyProps: HTableBodyProps) => {
|
|
24
23
|
const {
|
|
@@ -110,9 +109,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
110
109
|
table: tableInstance,
|
|
111
110
|
localSorter,
|
|
112
111
|
});
|
|
113
|
-
const
|
|
114
|
-
const { getPrefixCls } = useContext(ConfigContext);
|
|
115
|
-
|
|
112
|
+
const rowClassNameFn = useRowClassName(bodyProps);
|
|
116
113
|
return (
|
|
117
114
|
<div style={defaultTableStyle} className={`hw_table_body ${className}`}>
|
|
118
115
|
<Space size={16} direction={"vertical"} style={{ width: "100%" }}>
|
|
@@ -134,22 +131,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
134
131
|
>
|
|
135
132
|
<ProTable
|
|
136
133
|
{...props}
|
|
137
|
-
rowClassName={(
|
|
138
|
-
const key =
|
|
139
|
-
typeof rowKey === "function"
|
|
140
|
-
? rowKey(record, index)
|
|
141
|
-
: record[rowKey];
|
|
142
|
-
const propsRowClassName =
|
|
143
|
-
typeof rowClassName === "function"
|
|
144
|
-
? rowClassName(record, index, indent)
|
|
145
|
-
: rowClassName;
|
|
146
|
-
if (keys?.indexOf(key) !== -1) {
|
|
147
|
-
return `${getPrefixCls(
|
|
148
|
-
"table-row-selected"
|
|
149
|
-
)} ${propsRowClassName}`;
|
|
150
|
-
}
|
|
151
|
-
return propsRowClassName;
|
|
152
|
-
}}
|
|
134
|
+
rowClassName={(rowClassNameFn as any)}
|
|
153
135
|
bordered={bordered}
|
|
154
136
|
columnsState={{
|
|
155
137
|
...selfColStatus,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
2
|
-
import
|
|
2
|
+
import React, {Key} from "react";
|
|
3
3
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
4
4
|
import type {
|
|
5
5
|
ActionRenderFn,
|
|
@@ -39,3 +39,10 @@ export interface HTableBodyProps
|
|
|
39
39
|
table?: HTableInstance;
|
|
40
40
|
pagination?: IPaginationProps | false;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
export interface RowRadioSelectionProps {
|
|
44
|
+
data: any;
|
|
45
|
+
onChange?:(keys:Key[],data:any[])=>void;
|
|
46
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
47
|
+
index: number;
|
|
48
|
+
}
|
|
@@ -8,6 +8,7 @@ interface HTableConfigContextModal {
|
|
|
8
8
|
tableStyle?: React.CSSProperties;
|
|
9
9
|
paginationStyle?: React.CSSProperties;
|
|
10
10
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
11
|
+
defaultSelectedRowClassName?: string | null;
|
|
11
12
|
}
|
|
12
13
|
export const HTableConfigContext =
|
|
13
14
|
React.createContext<HTableConfigContextModal | null>(null);
|
|
@@ -26,6 +27,7 @@ export const useHTableConfigContext = ({
|
|
|
26
27
|
tableStyle: configTableStyle,
|
|
27
28
|
paginationStyle: configPaginationStyle,
|
|
28
29
|
valueTypeConfig = {},
|
|
30
|
+
defaultSelectedRowClassName,
|
|
29
31
|
} = useContext(HTableConfigContext) || {};
|
|
30
32
|
|
|
31
33
|
return {
|
|
@@ -35,6 +37,7 @@ export const useHTableConfigContext = ({
|
|
|
35
37
|
tableStyle: tableStyle || configTableStyle,
|
|
36
38
|
paginationStyle: paginationStyle || configPaginationStyle,
|
|
37
39
|
valueTypeConfig,
|
|
40
|
+
defaultSelectedRowClassName,
|
|
38
41
|
};
|
|
39
42
|
};
|
|
40
43
|
const Index: React.FC<HTableConfigContextModal> = ({ children, ...props }) => {
|
package/src/components/modal.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
HFormInstance,
|
|
6
6
|
} from "@hw-component/form/es/Form/modal";
|
|
7
7
|
import type { ColProps, FormInstance } from "antd";
|
|
8
|
-
import
|
|
8
|
+
import React, {Key} from "react";
|
|
9
9
|
import type { ModalProps } from "antd";
|
|
10
10
|
import type { TableProps } from "antd/lib/table";
|
|
11
11
|
import type { AffixProps } from "antd/lib/affix";
|
|
@@ -54,7 +54,9 @@ interface BcItemModal {
|
|
|
54
54
|
export type ConfigItemModal = Omit<HItemProps, "render" | "type"> &
|
|
55
55
|
HColumns &
|
|
56
56
|
BcItemModal;
|
|
57
|
+
|
|
57
58
|
export type ConfigDataModal = ConfigItemModal[];
|
|
59
|
+
|
|
58
60
|
export type ActionRenderFn = (
|
|
59
61
|
selectedRowKeys: RowObj,
|
|
60
62
|
tableInstance: HTableInstance
|
|
@@ -65,9 +67,12 @@ export type FooterBtnRenderFn = (
|
|
|
65
67
|
selectedRowKeys: RowObj,
|
|
66
68
|
setAllCheck: (row: RowObj) => void
|
|
67
69
|
) => React.ReactNode;
|
|
70
|
+
|
|
68
71
|
export type actionFn = (...arg) => void;
|
|
72
|
+
|
|
69
73
|
export interface RowSelectionOuter {
|
|
70
74
|
allPageCheck?: boolean;
|
|
75
|
+
onChange?:(keys:Key[],data:any[])=>void;
|
|
71
76
|
}
|
|
72
77
|
export type HRowSelection = RowSelectionOuter &
|
|
73
78
|
(TableProps<any>["rowSelection"] & {
|
|
@@ -121,38 +121,47 @@ export default () => {
|
|
|
121
121
|
>
|
|
122
122
|
获取
|
|
123
123
|
</div>
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
<
|
|
124
|
+
<HTableConfig defaultSelectedRowClassName={null}>
|
|
125
|
+
<HTable
|
|
126
|
+
configData={configData}
|
|
127
|
+
rowKey={(rowData, index) => {
|
|
128
|
+
return index;
|
|
129
|
+
}}
|
|
130
|
+
table={hTable}
|
|
131
|
+
labelWidth={88}
|
|
132
|
+
action={{
|
|
133
|
+
test: (params) => {
|
|
134
|
+
console.log(params, "lllll");
|
|
135
|
+
},
|
|
136
|
+
}}
|
|
137
|
+
rowSelection={{
|
|
138
|
+
preserveSelectedRowKeys: true,
|
|
139
|
+
}}
|
|
140
|
+
affixProps={{
|
|
141
|
+
target: () => document.querySelector(".body"),
|
|
142
|
+
}}
|
|
143
|
+
scroll={{
|
|
144
|
+
x: 1000,
|
|
145
|
+
}}
|
|
146
|
+
columnsState={{
|
|
147
|
+
persistenceKey: "test",
|
|
148
|
+
persistenceType: "localStorage",
|
|
149
|
+
}}
|
|
150
|
+
formInitValues={{
|
|
151
|
+
deviceType: "1",
|
|
152
|
+
}}
|
|
153
|
+
dataSource={[{}, {}, {}]}
|
|
154
|
+
headerTitle={
|
|
155
|
+
<Space size={8}>
|
|
156
|
+
<div style={{ width: 1000 }}>
|
|
157
|
+
<Button
|
|
158
|
+
onClick={() => {
|
|
159
|
+
console.log(hTable.table.getColSettingKeys());
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
操作
|
|
163
|
+
</Button>
|
|
164
|
+
</div>
|
|
156
165
|
<Button
|
|
157
166
|
onClick={() => {
|
|
158
167
|
console.log(hTable.table.getColSettingKeys());
|
|
@@ -160,34 +169,27 @@ export default () => {
|
|
|
160
169
|
>
|
|
161
170
|
操作
|
|
162
171
|
</Button>
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
</
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<SettingOutlined width={24} />
|
|
185
|
-
</Tooltip>
|
|
186
|
-
);
|
|
187
|
-
},
|
|
188
|
-
}}
|
|
189
|
-
pagination={false}
|
|
190
|
-
/>
|
|
172
|
+
<Button
|
|
173
|
+
onClick={() => {
|
|
174
|
+
console.log(hTable.table.getColSettingKeys());
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
操作
|
|
178
|
+
</Button>
|
|
179
|
+
</Space>
|
|
180
|
+
}
|
|
181
|
+
options={{
|
|
182
|
+
settingRender: () => {
|
|
183
|
+
return (
|
|
184
|
+
<Tooltip title="321312312312321">
|
|
185
|
+
<SettingOutlined width={24} />
|
|
186
|
+
</Tooltip>
|
|
187
|
+
);
|
|
188
|
+
},
|
|
189
|
+
}}
|
|
190
|
+
pagination={false}
|
|
191
|
+
/>
|
|
192
|
+
</HTableConfig>
|
|
191
193
|
</div>
|
|
192
194
|
</HFormConfigProvider>
|
|
193
195
|
);
|