@hw-component/table 1.9.93 → 1.9.95
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.d.ts +4 -3
- package/es/DialogTable/Content.js +52 -3
- package/es/DialogTable/DwEditTable.d.ts +5 -0
- package/es/DialogTable/DwEditTable.js +134 -0
- package/es/DialogTable/DwTable.js +2 -2
- package/es/DialogTable/ModalEditTable.d.ts +5 -0
- package/es/DialogTable/ModalEditTable.js +120 -0
- package/es/DialogTable/ModalTable.js +2 -2
- package/es/DialogTable/hooks.d.ts +4 -15
- package/es/DialogTable/hooks.js +9 -2
- package/es/EditTable/hooks.d.ts +9 -0
- package/es/EditTable/hooks.js +76 -0
- package/es/EditTable/index.d.ts +4 -0
- package/es/EditTable/index.js +181 -0
- package/es/EditTable/modal.d.ts +19 -0
- package/es/HTableBody/defaultRender.d.ts +7 -1
- package/es/HTableBody/defaultRender.js +11 -4
- package/es/HTableBody/index.js +4 -1
- package/es/HTableBody/modal.d.ts +3 -3
- package/es/HTablePagination/index.d.ts +2 -1
- package/es/HTablePagination/index.js +6 -4
- package/es/TableConfig.d.ts +5 -5
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/modal.d.ts +18 -7
- package/es/render/Text.d.ts +0 -1
- package/lib/DialogTable/Content.d.ts +4 -3
- package/lib/DialogTable/Content.js +53 -5
- package/lib/DialogTable/DwEditTable.d.ts +5 -0
- package/lib/DialogTable/DwEditTable.js +137 -0
- package/lib/DialogTable/DwTable.js +1 -1
- package/lib/DialogTable/ModalEditTable.d.ts +5 -0
- package/lib/DialogTable/ModalEditTable.js +123 -0
- package/lib/DialogTable/ModalTable.js +1 -1
- package/lib/DialogTable/hooks.d.ts +4 -15
- package/lib/DialogTable/hooks.js +9 -2
- package/lib/EditTable/hooks.d.ts +9 -0
- package/lib/EditTable/hooks.js +78 -0
- package/lib/EditTable/index.d.ts +4 -0
- package/lib/EditTable/index.js +184 -0
- package/lib/EditTable/modal.d.ts +19 -0
- package/lib/HTableBody/defaultRender.d.ts +7 -1
- package/lib/HTableBody/defaultRender.js +11 -4
- package/lib/HTableBody/index.js +4 -1
- package/lib/HTableBody/modal.d.ts +3 -3
- package/lib/HTablePagination/index.d.ts +2 -1
- package/lib/HTablePagination/index.js +6 -4
- package/lib/TableConfig.d.ts +5 -5
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/lib/modal.d.ts +18 -7
- package/lib/render/Text.d.ts +0 -1
- package/package.json +4 -3
- package/src/components/DialogTable/Content.tsx +25 -2
- package/src/components/DialogTable/DwEditTable.tsx +111 -0
- package/src/components/DialogTable/DwTable.tsx +3 -2
- package/src/components/DialogTable/ModalEditTable.tsx +99 -0
- package/src/components/DialogTable/ModalTable.tsx +3 -2
- package/src/components/DialogTable/hooks.ts +15 -4
- package/src/components/EditTable/hooks.ts +43 -0
- package/src/components/EditTable/index.tsx +118 -0
- package/src/components/EditTable/modal.ts +26 -0
- package/src/components/HTableBody/defaultRender.tsx +17 -7
- package/src/components/HTableBody/index.tsx +1 -1
- package/src/components/HTableBody/modal.ts +6 -7
- package/src/components/HTablePagination/index.tsx +7 -3
- package/src/components/Table.tsx +1 -0
- package/src/components/TableConfig.tsx +7 -3
- package/src/components/index.tsx +3 -0
- package/src/components/modal.ts +24 -10
- package/src/components/render/index.tsx +1 -0
- package/src/pages/DwTable/index.tsx +1 -0
- package/src/pages/EditTable/index.tsx +70 -0
- package/src/pages/ModalEditTable/index.tsx +84 -0
- package/src/pages/Table/index.tsx +14 -15
- package/src/routes.tsx +12 -0
package/src/components/modal.ts
CHANGED
|
@@ -12,7 +12,8 @@ import type { TableProps } from "antd/lib/table";
|
|
|
12
12
|
import type { AffixProps } from "antd/lib/affix";
|
|
13
13
|
import type { OptionModal } from "./HTableBody/modal";
|
|
14
14
|
import type { DrawerProps } from "antd";
|
|
15
|
-
import type { IPaginationProps } from "
|
|
15
|
+
import type { IPaginationProps } from "./HTablePagination";
|
|
16
|
+
import { EditTableProps } from "./EditTable/modal";
|
|
16
17
|
|
|
17
18
|
export interface RowObj {
|
|
18
19
|
keys?: React.Key[];
|
|
@@ -89,11 +90,8 @@ export interface HTableProps
|
|
|
89
90
|
searchSpan?: ColProps;
|
|
90
91
|
table?: HTableInstance;
|
|
91
92
|
actionRender?: ActionRenderFn;
|
|
92
|
-
emptyRender?:
|
|
93
|
-
errorRender?:
|
|
94
|
-
tableInstance: HTableInstance,
|
|
95
|
-
error: Error
|
|
96
|
-
) => React.ReactNode;
|
|
93
|
+
emptyRender?: EmptyPageRender;
|
|
94
|
+
errorRender?: ErrorPageRender;
|
|
97
95
|
hideHeader?: boolean;
|
|
98
96
|
action?: Record<string, actionFn>;
|
|
99
97
|
headerStyle?: React.CSSProperties;
|
|
@@ -156,24 +154,29 @@ export interface HDiaLogTableInstance {
|
|
|
156
154
|
hide: () => void;
|
|
157
155
|
params: any;
|
|
158
156
|
}
|
|
159
|
-
export interface DwTableProps
|
|
157
|
+
export interface DwTableProps<T = HTableProps["configData"]>
|
|
158
|
+
extends DrawerProps {
|
|
160
159
|
tableProps?: Omit<HTableProps, "configData" | "request">;
|
|
161
160
|
dialogTable?: HDiaLogTableInstance;
|
|
162
161
|
params?: Record<string, any>;
|
|
163
|
-
configData?:
|
|
162
|
+
configData?: T;
|
|
164
163
|
request?: HTableProps["request"];
|
|
165
164
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
165
|
+
editTableProps?: Omit<EditTableProps, "configData" | "request">;
|
|
166
|
+
dataSource?: any[];
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
export interface ModalTableProps
|
|
169
|
+
export interface ModalTableProps<T = HTableProps["configData"]>
|
|
170
|
+
extends Omit<ModalProps, "onOk"> {
|
|
169
171
|
tableProps?: Omit<HTableProps, "configData" | "request">;
|
|
170
172
|
dialogTable?: HDiaLogTableInstance;
|
|
171
173
|
params?: Record<string, any>;
|
|
172
|
-
configData?:
|
|
174
|
+
configData?: T;
|
|
173
175
|
request?: HTableProps["request"];
|
|
174
176
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
175
177
|
dataSource?: any[];
|
|
176
178
|
onOk?: (e?: React.MouseEvent<HTMLElement>) => void;
|
|
179
|
+
editTableProps?: Omit<EditTableProps, "configData" | "request">;
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
export type ValueTypeConfigRenderFn = (
|
|
@@ -183,3 +186,14 @@ export type ValueTypeConfigRenderFn = (
|
|
|
183
186
|
tableInstance: HTableInstance
|
|
184
187
|
) => React.ReactNode;
|
|
185
188
|
export type ValueTypeConfigModal = Record<string, ValueTypeConfigRenderFn>;
|
|
189
|
+
|
|
190
|
+
interface ErrorRenderParams {
|
|
191
|
+
error: Error;
|
|
192
|
+
tableInstance?: HTableInstance;
|
|
193
|
+
reload?: VoidFunction;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type ErrorPageRender = (params: ErrorRenderParams) => React.ReactNode;
|
|
197
|
+
export type EmptyPageRender = (
|
|
198
|
+
tableInstance?: HTableInstance
|
|
199
|
+
) => React.ReactNode;
|
|
@@ -2,6 +2,7 @@ import type { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import config from "./config";
|
|
4
4
|
import type { ValueTypeConfigModal } from "../modal";
|
|
5
|
+
|
|
5
6
|
export default (
|
|
6
7
|
item: ConfigItemModal,
|
|
7
8
|
tableInstance: HTableInstance,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { EditTable } from "@/components";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import type { ActionType } from "@ant-design/pro-table";
|
|
4
|
+
|
|
5
|
+
const dataSource = [
|
|
6
|
+
{
|
|
7
|
+
id: 1,
|
|
8
|
+
title: "1",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 2,
|
|
12
|
+
title: "2",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 3,
|
|
16
|
+
title: "3",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 4,
|
|
20
|
+
title: "4",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 5,
|
|
24
|
+
title: "5",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
export default () => {
|
|
28
|
+
const defaultActionRef = useRef<ActionType>();
|
|
29
|
+
const [cuData, setCuData] = useState(dataSource);
|
|
30
|
+
return (
|
|
31
|
+
<EditTable
|
|
32
|
+
actionRef={defaultActionRef}
|
|
33
|
+
onAdd={async (data) => {
|
|
34
|
+
const newData = [...cuData];
|
|
35
|
+
newData.push({
|
|
36
|
+
id: newData.length + 1,
|
|
37
|
+
...data,
|
|
38
|
+
});
|
|
39
|
+
setCuData(newData);
|
|
40
|
+
}}
|
|
41
|
+
onEdit={async (data) => {
|
|
42
|
+
const index = cuData.findIndex((e) => e.id === data.id);
|
|
43
|
+
cuData[index] = data;
|
|
44
|
+
setCuData([...cuData]);
|
|
45
|
+
}}
|
|
46
|
+
dataSource={cuData}
|
|
47
|
+
configData={[
|
|
48
|
+
{ title: "标题", dataIndex: "title" },
|
|
49
|
+
{ title: "标题2", dataIndex: "title1" },
|
|
50
|
+
{
|
|
51
|
+
title: "操作",
|
|
52
|
+
valueType: "option",
|
|
53
|
+
align: "center",
|
|
54
|
+
render: (text: any, record: any, _: any, action: any) => [
|
|
55
|
+
<a
|
|
56
|
+
key="editable"
|
|
57
|
+
type={"link"}
|
|
58
|
+
onClick={() => {
|
|
59
|
+
console.log(action);
|
|
60
|
+
action?.startEditable?.(record.id);
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
编辑
|
|
64
|
+
</a>,
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
]}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { HDwEditTable, useHDialogTable } from "@/components";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
const dataSource = [
|
|
5
|
+
{
|
|
6
|
+
id: 1,
|
|
7
|
+
title: "1",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: 2,
|
|
11
|
+
title: "2",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 3,
|
|
15
|
+
title: "3",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 4,
|
|
19
|
+
title: "4",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 5,
|
|
23
|
+
title: "5",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default () => {
|
|
28
|
+
const dialogTable = useHDialogTable();
|
|
29
|
+
const [cuData, setCuData] = useState(dataSource);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<div
|
|
34
|
+
onClick={() => {
|
|
35
|
+
dialogTable.show();
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
点我
|
|
39
|
+
</div>
|
|
40
|
+
<HDwEditTable
|
|
41
|
+
title="编辑"
|
|
42
|
+
dataSource={cuData}
|
|
43
|
+
editTableProps={{
|
|
44
|
+
onAdd: async (data) => {
|
|
45
|
+
console.log("addd");
|
|
46
|
+
const newData = [...cuData];
|
|
47
|
+
newData.push({
|
|
48
|
+
id: newData.length + 1,
|
|
49
|
+
...data,
|
|
50
|
+
});
|
|
51
|
+
setCuData(newData);
|
|
52
|
+
},
|
|
53
|
+
onEdit: async (data) => {
|
|
54
|
+
const index = cuData.findIndex((e) => e.id === data.id);
|
|
55
|
+
cuData[index] = data;
|
|
56
|
+
setCuData([...cuData]);
|
|
57
|
+
},
|
|
58
|
+
}}
|
|
59
|
+
dialogTable={dialogTable}
|
|
60
|
+
configData={[
|
|
61
|
+
{ title: "标题", dataIndex: "title" },
|
|
62
|
+
{ title: "标题2", dataIndex: "title1" },
|
|
63
|
+
{
|
|
64
|
+
title: "操作",
|
|
65
|
+
valueType: "option",
|
|
66
|
+
align: "center",
|
|
67
|
+
render: (text: any, record: any, _: any, action: any) => [
|
|
68
|
+
<a
|
|
69
|
+
key="editable"
|
|
70
|
+
type={"link"}
|
|
71
|
+
onClick={() => {
|
|
72
|
+
console.log(action);
|
|
73
|
+
action?.startEditable?.(record.id);
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
编辑
|
|
77
|
+
</a>,
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
]}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -52,24 +52,24 @@ const Testd = (props) => {
|
|
|
52
52
|
};
|
|
53
53
|
export const configData = [
|
|
54
54
|
{
|
|
55
|
-
title:
|
|
56
|
-
dataIndex:
|
|
55
|
+
title: "订单编号",
|
|
56
|
+
dataIndex: "childOrderNo",
|
|
57
57
|
showSearch: true,
|
|
58
|
-
valueType:
|
|
58
|
+
valueType: "copy",
|
|
59
59
|
width: 120,
|
|
60
|
-
searchType:
|
|
61
|
-
name:
|
|
60
|
+
searchType: "selectInput",
|
|
61
|
+
name: "selectInput",
|
|
62
62
|
itemProps: {
|
|
63
|
-
placeholder:
|
|
63
|
+
placeholder: "请输入",
|
|
64
64
|
selectProps: {
|
|
65
|
-
options:[
|
|
65
|
+
options: [
|
|
66
66
|
{
|
|
67
|
-
label:
|
|
68
|
-
value:
|
|
67
|
+
label: "订单编号",
|
|
68
|
+
value: "orderNo",
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
label:
|
|
72
|
-
value:
|
|
71
|
+
label: "用户id",
|
|
72
|
+
value: "userId",
|
|
73
73
|
},
|
|
74
74
|
],
|
|
75
75
|
style: { width: 88 },
|
|
@@ -213,12 +213,11 @@ export default () => {
|
|
|
213
213
|
persistenceType: "localStorage",
|
|
214
214
|
}}
|
|
215
215
|
formInitValues={{
|
|
216
|
-
select:
|
|
216
|
+
select: "orderNo",
|
|
217
217
|
}}
|
|
218
|
-
|
|
219
218
|
dataSource={[{}, {}, {}]}
|
|
220
|
-
request={(params)=>{
|
|
221
|
-
|
|
219
|
+
request={(params) => {
|
|
220
|
+
console.log(params);
|
|
222
221
|
return Promise.resolve({});
|
|
223
222
|
}}
|
|
224
223
|
headerTitle={
|
package/src/routes.tsx
CHANGED
|
@@ -4,6 +4,8 @@ import Table from "./pages/Table";
|
|
|
4
4
|
import ModalTable from "./pages/ModalTable";
|
|
5
5
|
import TableCustomize from "./pages/TableCustomize";
|
|
6
6
|
import DwTable from "./pages/DwTable";
|
|
7
|
+
import EditTable from "./pages/EditTable";
|
|
8
|
+
import ModalEditTable from "./pages/ModalEditTable";
|
|
7
9
|
|
|
8
10
|
export interface RouteModal {
|
|
9
11
|
path?: string;
|
|
@@ -39,6 +41,16 @@ const routes: RouteModal[] = [
|
|
|
39
41
|
name: "dwTable",
|
|
40
42
|
element: <DwTable />,
|
|
41
43
|
},
|
|
44
|
+
{
|
|
45
|
+
path: "/editTable",
|
|
46
|
+
name: "editTable",
|
|
47
|
+
element: <EditTable />,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
path: "/modalEditTable",
|
|
51
|
+
name: "modalEditTable",
|
|
52
|
+
element: <ModalEditTable />,
|
|
53
|
+
},
|
|
42
54
|
];
|
|
43
55
|
|
|
44
56
|
export default routes;
|