@hw-component/table 1.10.5 → 1.10.7
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/DialogTable/Content.js +1 -0
- package/es/HTableBody/RowCheckBox/hooks.js +110 -11
- package/es/HTableBody/hooks/useColData.d.ts +2 -2
- package/es/HTableBody/hooks/useColData.js +4 -2
- package/es/HTableBody/index.js +12 -6
- package/es/HTableBody/modal.d.ts +2 -1
- package/es/Table.d.ts +1 -1
- package/es/Table.js +22 -30
- package/es/TableConfig.d.ts +4 -2
- package/es/TableConfig.js +6 -3
- package/es/TableCustomize.js +4 -2
- package/es/TableProvider.d.ts +6 -0
- package/es/TableProvider.js +57 -0
- package/es/context.d.ts +1 -2
- package/es/modal.d.ts +2 -0
- package/lib/DialogTable/Content.js +1 -0
- package/lib/HTableBody/RowCheckBox/hooks.js +110 -11
- package/lib/HTableBody/hooks/useColData.d.ts +2 -2
- package/lib/HTableBody/hooks/useColData.js +4 -2
- package/lib/HTableBody/index.js +12 -6
- package/lib/HTableBody/modal.d.ts +2 -1
- package/lib/Table.d.ts +1 -1
- package/lib/Table.js +22 -30
- package/lib/TableConfig.d.ts +4 -2
- package/lib/TableConfig.js +6 -3
- package/lib/TableCustomize.js +4 -2
- package/lib/TableProvider.d.ts +6 -0
- package/lib/TableProvider.js +60 -0
- package/lib/context.d.ts +1 -2
- package/lib/modal.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/EditTable/modal.ts +5 -6
- package/src/components/HTableBody/RowCheckBox/hooks.ts +77 -8
- package/src/components/HTableBody/hooks/useColData.tsx +12 -2
- package/src/components/HTableBody/index.tsx +13 -1
- package/src/components/HTableBody/modal.ts +2 -0
- package/src/components/Table.tsx +20 -27
- package/src/components/TableConfig.tsx +5 -0
- package/src/components/TableCustomize.tsx +2 -0
- package/src/components/TableProvider.tsx +55 -0
- package/src/components/context.ts +1 -1
- package/src/components/modal.ts +2 -0
- package/src/components/render/TagsComponent.tsx +10 -7
- package/src/pages/Table/index.tsx +30 -11
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HContextModal, HTableContext } from "./context";
|
|
2
|
+
import type { HTableProps } from "./modal";
|
|
3
|
+
import React from "react";
|
|
4
|
+
type ProviderProps = HTableProps & Omit<HContextModal, "onPageChange">;
|
|
5
|
+
|
|
6
|
+
const Index: React.FC<ProviderProps> = ({ children, ...props }) => {
|
|
7
|
+
const {
|
|
8
|
+
configData,
|
|
9
|
+
action = {},
|
|
10
|
+
rowKey = "id",
|
|
11
|
+
hideLabel,
|
|
12
|
+
labelWidth,
|
|
13
|
+
configItemRender,
|
|
14
|
+
tableInstance,
|
|
15
|
+
selectedRowData,
|
|
16
|
+
rowOnChange,
|
|
17
|
+
data,
|
|
18
|
+
error,
|
|
19
|
+
loading,
|
|
20
|
+
allSelectChange,
|
|
21
|
+
onFinish,
|
|
22
|
+
setSelectedRowData,
|
|
23
|
+
headerOpen,
|
|
24
|
+
setHeaderOpen,
|
|
25
|
+
rowSelection,
|
|
26
|
+
} = props;
|
|
27
|
+
return (
|
|
28
|
+
<HTableContext.Provider
|
|
29
|
+
value={{
|
|
30
|
+
selectedRowData,
|
|
31
|
+
rowOnChange,
|
|
32
|
+
data,
|
|
33
|
+
error,
|
|
34
|
+
loading,
|
|
35
|
+
allSelectChange,
|
|
36
|
+
action,
|
|
37
|
+
configData,
|
|
38
|
+
onFinish,
|
|
39
|
+
onPageChange: tableInstance.table.reloadWithParams,
|
|
40
|
+
setSelectedRowData,
|
|
41
|
+
rowKey,
|
|
42
|
+
headerOpen,
|
|
43
|
+
setHeaderOpen,
|
|
44
|
+
hideLabel,
|
|
45
|
+
labelWidth,
|
|
46
|
+
configItemRender,
|
|
47
|
+
tableInstance,
|
|
48
|
+
rowSelection,
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</HTableContext.Provider>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
export default Index;
|
|
@@ -2,7 +2,7 @@ import type { Dispatch, SetStateAction } from "react";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import type { HTableProps, ResultModal, RowObj, HTableInstance } from "./modal";
|
|
4
4
|
|
|
5
|
-
interface HContextModal extends Omit<HTableProps, "request"> {
|
|
5
|
+
export interface HContextModal extends Omit<HTableProps, "request"> {
|
|
6
6
|
tableInstance: HTableInstance;
|
|
7
7
|
data?: ResultModal;
|
|
8
8
|
selectedRowData: RowObj;
|
package/src/components/modal.ts
CHANGED
|
@@ -79,6 +79,7 @@ export interface RowSelectionOuter {
|
|
|
79
79
|
export type HRowSelection = RowSelectionOuter &
|
|
80
80
|
(TableProps<any>["rowSelection"] & {
|
|
81
81
|
alwaysShowAlert?: boolean;
|
|
82
|
+
allCheckType?: "batch" | "single";
|
|
82
83
|
});
|
|
83
84
|
export interface HTableProps
|
|
84
85
|
extends Omit<
|
|
@@ -87,6 +88,7 @@ export interface HTableProps
|
|
|
87
88
|
> {
|
|
88
89
|
request?: (params: ParamsModal) => Promise<ResultModal>;
|
|
89
90
|
configData: ConfigDataModal;
|
|
91
|
+
configItemRender?: (data: ConfigItemModal) => ConfigItemModal;
|
|
90
92
|
searchSpan?: ColProps;
|
|
91
93
|
table?: HTableInstance;
|
|
92
94
|
actionRender?: ActionRenderFn;
|
|
@@ -4,7 +4,7 @@ import type { TooltipProps } from "antd/lib/tooltip";
|
|
|
4
4
|
import type { HTableInstance } from "../modal";
|
|
5
5
|
|
|
6
6
|
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
7
|
-
type TooltipRender=(item:any)=>TooltipProps;
|
|
7
|
+
type TooltipRender = (item: any) => TooltipProps;
|
|
8
8
|
|
|
9
9
|
interface IProps {
|
|
10
10
|
data: any[];
|
|
@@ -12,7 +12,7 @@ interface IProps {
|
|
|
12
12
|
onClose?: CloseFn;
|
|
13
13
|
color?: string;
|
|
14
14
|
icon?: React.ReactNode;
|
|
15
|
-
tooltip?: boolean | TooltipProps|TooltipRender;
|
|
15
|
+
tooltip?: boolean | TooltipProps | TooltipRender;
|
|
16
16
|
fieldNames?: { label?: string; value?: string };
|
|
17
17
|
tableInstance?: HTableInstance;
|
|
18
18
|
maxLen?: number | null;
|
|
@@ -22,9 +22,9 @@ interface IProps {
|
|
|
22
22
|
}
|
|
23
23
|
const getTooltipProps = (
|
|
24
24
|
item: any,
|
|
25
|
-
tooltip?: boolean | TooltipProps|TooltipRender
|
|
25
|
+
tooltip?: boolean | TooltipProps | TooltipRender
|
|
26
26
|
): TooltipProps => {
|
|
27
|
-
const {title}=item;
|
|
27
|
+
const { title } = item;
|
|
28
28
|
if (!tooltip) {
|
|
29
29
|
return {
|
|
30
30
|
title: null,
|
|
@@ -36,7 +36,7 @@ const getTooltipProps = (
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
if (typeof tooltip === "function") {
|
|
39
|
-
|
|
39
|
+
return tooltip(item);
|
|
40
40
|
}
|
|
41
41
|
return {
|
|
42
42
|
...tooltip,
|
|
@@ -84,7 +84,7 @@ const TagsComponent = (props: IProps) => {
|
|
|
84
84
|
};
|
|
85
85
|
const indexKey = index.toString();
|
|
86
86
|
if (typeof tagItem === "string") {
|
|
87
|
-
const tooltipProps = getTooltipProps({title:tagItem}, tooltip);
|
|
87
|
+
const tooltipProps = getTooltipProps({ title: tagItem }, tooltip);
|
|
88
88
|
return (
|
|
89
89
|
<Tooltip {...tooltipProps}>
|
|
90
90
|
<Tag
|
|
@@ -101,7 +101,10 @@ const TagsComponent = (props: IProps) => {
|
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
const { [label]: tagLabel, [value]: tagValue, ...itemProps } = tagItem;
|
|
104
|
-
const tooltipProps =
|
|
104
|
+
const tooltipProps = getTooltipProps(
|
|
105
|
+
{ title: tagLabel, value: tagValue, ...itemProps },
|
|
106
|
+
tooltip
|
|
107
|
+
);
|
|
105
108
|
const cuTagProps = {
|
|
106
109
|
...tagProps,
|
|
107
110
|
...itemProps,
|
|
@@ -157,11 +157,14 @@ export default () => {
|
|
|
157
157
|
const [keys, setKeys] = useState([]);
|
|
158
158
|
return (
|
|
159
159
|
<HFormConfigProvider>
|
|
160
|
-
<TagsComponent
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
<TagsComponent
|
|
161
|
+
data={["213123"]}
|
|
162
|
+
tooltip={() => {
|
|
163
|
+
return {
|
|
164
|
+
title: "3123",
|
|
165
|
+
};
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
165
168
|
<div>
|
|
166
169
|
<div
|
|
167
170
|
onClick={() => {
|
|
@@ -173,8 +176,9 @@ export default () => {
|
|
|
173
176
|
<HTableConfig defaultSelectedRowClassName={null}>
|
|
174
177
|
<HTable
|
|
175
178
|
configData={configData}
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
configItemRender={(d1) => {
|
|
180
|
+
console.log(d1);
|
|
181
|
+
return d1;
|
|
178
182
|
}}
|
|
179
183
|
table={hTable}
|
|
180
184
|
labelWidth={88}
|
|
@@ -185,6 +189,11 @@ export default () => {
|
|
|
185
189
|
}}
|
|
186
190
|
rowSelection={{
|
|
187
191
|
preserveSelectedRowKeys: true,
|
|
192
|
+
allPageCheck: false,
|
|
193
|
+
onChange: (keys, data)=>{
|
|
194
|
+
console.log(keys, data);
|
|
195
|
+
},
|
|
196
|
+
allCheckType: "batch",
|
|
188
197
|
}}
|
|
189
198
|
affixProps={{
|
|
190
199
|
target: () => document.querySelector(".body"),
|
|
@@ -199,10 +208,21 @@ export default () => {
|
|
|
199
208
|
formInitValues={{
|
|
200
209
|
select: "orderNo",
|
|
201
210
|
}}
|
|
202
|
-
dataSource={[{}, {}, {}]}
|
|
203
211
|
request={(params) => {
|
|
204
|
-
|
|
205
|
-
|
|
212
|
+
const { current } = params;
|
|
213
|
+
const records = [];
|
|
214
|
+
for (let i = 0; i < 10; i += 1) {
|
|
215
|
+
records.push({
|
|
216
|
+
id: `${current}-${i}`,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
console.log(records);
|
|
220
|
+
return Promise.resolve({
|
|
221
|
+
current: "1",
|
|
222
|
+
size: "10",
|
|
223
|
+
total: "100",
|
|
224
|
+
records,
|
|
225
|
+
});
|
|
206
226
|
}}
|
|
207
227
|
headerTitle={
|
|
208
228
|
<Space size={8}>
|
|
@@ -221,7 +241,6 @@ export default () => {
|
|
|
221
241
|
</div>
|
|
222
242
|
</Space>
|
|
223
243
|
}
|
|
224
|
-
pagination={false}
|
|
225
244
|
/>
|
|
226
245
|
</HTableConfig>
|
|
227
246
|
</div>
|