@hw-component/table 1.9.92 → 1.9.94
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/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/Options/hooks.d.ts +1 -1
- 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/Table.js +1 -1
- package/es/TableConfig.d.ts +5 -5
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/modal.d.ts +14 -5
- package/lib/DialogTable/Content.d.ts +4 -3
- package/lib/DialogTable/Content.js +53 -5
- 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/Options/hooks.d.ts +1 -1
- 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/Table.js +1 -1
- package/lib/TableConfig.d.ts +5 -5
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -0
- package/lib/modal.d.ts +14 -5
- package/package.json +4 -3
- package/src/components/DialogTable/Content.tsx +25 -2
- 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/Options/Content.tsx +11 -11
- package/src/components/HTableBody/Options/ContentTree.tsx +1 -5
- package/src/components/HTableBody/Options/hooks.tsx +5 -8
- 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 +2 -2
- package/src/components/TableConfig.tsx +7 -3
- package/src/components/index.tsx +2 -0
- package/src/components/modal.ts +19 -8
- 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 +30 -1
- package/src/routes.tsx +12 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
6
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
7
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
9
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
10
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
11
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
12
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
13
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
14
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
15
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
16
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
17
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
18
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
19
|
+
var ProTable = require('@ant-design/pro-table');
|
|
20
|
+
var index = require('../hooks/index.js');
|
|
21
|
+
var index$1 = require('../HTablePagination/index.js');
|
|
22
|
+
var antd = require('antd');
|
|
23
|
+
var defaultRender = require('../HTableBody/defaultRender.js');
|
|
24
|
+
var TableConfig = require('../TableConfig.js');
|
|
25
|
+
var hooks = require('./hooks.js');
|
|
26
|
+
|
|
27
|
+
var _excluded = ["configData", "rowKey", "creatorButtonText", "recordCreatorProps", "defaultRecordValue", "pagination", "editable", "dataSource", "request", "manual", "emptyRender", "errorRender", "onAdd", "onEdit", "actionRef", "editableFormRef"],
|
|
28
|
+
_excluded2 = ["index", "id"];
|
|
29
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
|
+
var EditTable = (function (_ref) {
|
|
32
|
+
var configData = _ref.configData,
|
|
33
|
+
_ref$rowKey = _ref.rowKey,
|
|
34
|
+
rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey,
|
|
35
|
+
_ref$creatorButtonTex = _ref.creatorButtonText,
|
|
36
|
+
creatorButtonText = _ref$creatorButtonTex === void 0 ? "新增一列" : _ref$creatorButtonTex,
|
|
37
|
+
_ref$recordCreatorPro = _ref.recordCreatorProps,
|
|
38
|
+
recordCreatorProps = _ref$recordCreatorPro === void 0 ? {} : _ref$recordCreatorPro;
|
|
39
|
+
_ref.defaultRecordValue;
|
|
40
|
+
var pagination = _ref.pagination,
|
|
41
|
+
_ref$editable = _ref.editable,
|
|
42
|
+
editable = _ref$editable === void 0 ? {} : _ref$editable,
|
|
43
|
+
dataSource = _ref.dataSource,
|
|
44
|
+
request = _ref.request,
|
|
45
|
+
manual = _ref.manual,
|
|
46
|
+
emptyRender = _ref.emptyRender,
|
|
47
|
+
errorRender = _ref.errorRender,
|
|
48
|
+
onAdd = _ref.onAdd,
|
|
49
|
+
onEdit = _ref.onEdit,
|
|
50
|
+
actionRef = _ref.actionRef,
|
|
51
|
+
editableFormRef = _ref.editableFormRef,
|
|
52
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
53
|
+
var tableBody = index.useClassName("hw-table-body");
|
|
54
|
+
var _useListRequest = hooks.useListRequest({
|
|
55
|
+
request: request,
|
|
56
|
+
dataSource: dataSource
|
|
57
|
+
}),
|
|
58
|
+
loading = _useListRequest.loading,
|
|
59
|
+
data = _useListRequest.data,
|
|
60
|
+
error = _useListRequest.error,
|
|
61
|
+
run = _useListRequest.run;
|
|
62
|
+
var _useHTableConfigConte = TableConfig.useHTableConfigContext({
|
|
63
|
+
emptyRender: emptyRender,
|
|
64
|
+
errorRender: errorRender
|
|
65
|
+
}),
|
|
66
|
+
_useHTableConfigConte2 = _useHTableConfigConte.emptyRender,
|
|
67
|
+
tableEmptyRender = _useHTableConfigConte2 === void 0 ? defaultRender.emptyDefaultRender : _useHTableConfigConte2,
|
|
68
|
+
_useHTableConfigConte3 = _useHTableConfigConte.errorRender,
|
|
69
|
+
tableErrorRender = _useHTableConfigConte3 === void 0 ? defaultRender.errorDefaultRender : _useHTableConfigConte3;
|
|
70
|
+
var isLocalData = _Array$isArray(data);
|
|
71
|
+
var values = isLocalData ? data : data === null || data === void 0 ? void 0 : data.record;
|
|
72
|
+
var _useCuRef = hooks.useCuRef({
|
|
73
|
+
actionRef: actionRef,
|
|
74
|
+
editableFormRef: editableFormRef
|
|
75
|
+
}),
|
|
76
|
+
cuActionRef = _useCuRef.cuActionRef,
|
|
77
|
+
cuEditableFormRef = _useCuRef.cuEditableFormRef;
|
|
78
|
+
return jsxRuntime.jsxs("div", {
|
|
79
|
+
className: tableBody,
|
|
80
|
+
children: [jsxRuntime.jsx(antd.ConfigProvider, {
|
|
81
|
+
renderEmpty: function renderEmpty() {
|
|
82
|
+
if (error) {
|
|
83
|
+
return tableErrorRender === null || tableErrorRender === void 0 ? void 0 : tableErrorRender({
|
|
84
|
+
reload: cuActionRef.current.reload,
|
|
85
|
+
error: error
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return tableEmptyRender === null || tableEmptyRender === void 0 ? void 0 : tableEmptyRender();
|
|
89
|
+
},
|
|
90
|
+
children: jsxRuntime.jsx(ProTable.EditableProTable, _objectSpread({
|
|
91
|
+
columns: configData,
|
|
92
|
+
loading: loading,
|
|
93
|
+
rowKey: rowKey,
|
|
94
|
+
editableFormRef: cuEditableFormRef,
|
|
95
|
+
manualRequest: manual,
|
|
96
|
+
request: run,
|
|
97
|
+
actionRef: cuActionRef,
|
|
98
|
+
value: values,
|
|
99
|
+
recordCreatorProps: _objectSpread({
|
|
100
|
+
position: "bottom",
|
|
101
|
+
record: function record() {
|
|
102
|
+
return {
|
|
103
|
+
id: "add"
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
creatorButtonText: creatorButtonText
|
|
107
|
+
}, recordCreatorProps),
|
|
108
|
+
editable: _objectSpread({
|
|
109
|
+
type: "single",
|
|
110
|
+
onCancel: function () {
|
|
111
|
+
var _onCancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keys) {
|
|
112
|
+
var _cuEditableFormRef$cu;
|
|
113
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
114
|
+
while (1) switch (_context.prev = _context.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
(_cuEditableFormRef$cu = cuEditableFormRef.current) === null || _cuEditableFormRef$cu === void 0 || _cuEditableFormRef$cu.resetFields([keys]);
|
|
117
|
+
case 1:
|
|
118
|
+
case "end":
|
|
119
|
+
return _context.stop();
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
}));
|
|
123
|
+
function onCancel(_x) {
|
|
124
|
+
return _onCancel.apply(this, arguments);
|
|
125
|
+
}
|
|
126
|
+
return onCancel;
|
|
127
|
+
}(),
|
|
128
|
+
actionRender: function actionRender(trow, tconfig, defaultDoms) {
|
|
129
|
+
return [defaultDoms.save, defaultDoms.cancel];
|
|
130
|
+
},
|
|
131
|
+
onSave: function () {
|
|
132
|
+
var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key, row) {
|
|
133
|
+
var _cuEditableFormRef$cu3, _cuActionRef$current2;
|
|
134
|
+
var id, oRow, _cuEditableFormRef$cu2, _cuActionRef$current;
|
|
135
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
136
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
row.index, id = row.id, oRow = _objectWithoutProperties(row, _excluded2);
|
|
139
|
+
if (!(key === "add")) {
|
|
140
|
+
_context2.next = 7;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
_context2.next = 4;
|
|
144
|
+
return onAdd === null || onAdd === void 0 ? void 0 : onAdd(oRow);
|
|
145
|
+
case 4:
|
|
146
|
+
(_cuEditableFormRef$cu2 = cuEditableFormRef.current) === null || _cuEditableFormRef$cu2 === void 0 || _cuEditableFormRef$cu2.resetFields(["add"]);
|
|
147
|
+
(_cuActionRef$current = cuActionRef.current) === null || _cuActionRef$current === void 0 || _cuActionRef$current.reload();
|
|
148
|
+
return _context2.abrupt("return");
|
|
149
|
+
case 7:
|
|
150
|
+
_context2.next = 9;
|
|
151
|
+
return onEdit === null || onEdit === void 0 ? void 0 : onEdit(_objectSpread({
|
|
152
|
+
id: id
|
|
153
|
+
}, oRow));
|
|
154
|
+
case 9:
|
|
155
|
+
(_cuEditableFormRef$cu3 = cuEditableFormRef.current) === null || _cuEditableFormRef$cu3 === void 0 || _cuEditableFormRef$cu3.resetFields(["key"]);
|
|
156
|
+
(_cuActionRef$current2 = cuActionRef.current) === null || _cuActionRef$current2 === void 0 || _cuActionRef$current2.reload();
|
|
157
|
+
case 11:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context2.stop();
|
|
160
|
+
}
|
|
161
|
+
}, _callee2);
|
|
162
|
+
}));
|
|
163
|
+
function onSave(_x2, _x3) {
|
|
164
|
+
return _onSave.apply(this, arguments);
|
|
165
|
+
}
|
|
166
|
+
return onSave;
|
|
167
|
+
}()
|
|
168
|
+
}, editable)
|
|
169
|
+
}, props))
|
|
170
|
+
}), jsxRuntime.jsx(index$1.default, _objectSpread(_objectSpread({
|
|
171
|
+
data: isLocalData ? null : data
|
|
172
|
+
}, pagination), {}, {
|
|
173
|
+
onChange: function onChange(page, pageSize) {
|
|
174
|
+
run({
|
|
175
|
+
size: pageSize,
|
|
176
|
+
current: page
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}))]
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
exports.default = EditTable;
|
|
184
|
+
// powered by h
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditableProTableProps } from "@ant-design/pro-table/lib/components/EditableTable";
|
|
2
|
+
import { ParamsType } from "@ant-design/pro-provider";
|
|
3
|
+
import { IPaginationProps } from "../HTablePagination";
|
|
4
|
+
import { EmptyPageRender, ErrorPageRender } from "../modal";
|
|
5
|
+
import { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
6
|
+
export interface EditTableProps<T = any> extends Omit<EditableProTableProps<T, ParamsType>, "recordCreatorProps" | "request" | "pagination"> {
|
|
7
|
+
creatorButtonText?: string;
|
|
8
|
+
defaultRecordValue?: T;
|
|
9
|
+
recordCreatorProps?: Partial<EditableProTableProps<T, ParamsType>["recordCreatorProps"]>;
|
|
10
|
+
dataSource?: any[];
|
|
11
|
+
request?: (params: Record<string, any>) => Promise<T>;
|
|
12
|
+
pagination?: IPaginationProps;
|
|
13
|
+
manual?: boolean;
|
|
14
|
+
emptyRender?: EmptyPageRender;
|
|
15
|
+
errorRender?: ErrorPageRender;
|
|
16
|
+
onAdd?: (data: T) => Promise<void>;
|
|
17
|
+
onEdit?: (data: T) => Promise<void>;
|
|
18
|
+
configData?: ProColumns<T>[];
|
|
19
|
+
}
|
|
@@ -15,5 +15,5 @@ interface UseTreeKeysModal {
|
|
|
15
15
|
treeData: ColDataNode[];
|
|
16
16
|
checkKeys: string[];
|
|
17
17
|
}
|
|
18
|
-
export declare const useTreeKeys: ({ treeData, checkKeys
|
|
18
|
+
export declare const useTreeKeys: ({ treeData, checkKeys }: UseTreeKeysModal) => string[];
|
|
19
19
|
export {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HTableInstance } from "../modal";
|
|
3
3
|
export declare const emptyDefaultRender: () => JSX.Element;
|
|
4
|
-
|
|
4
|
+
interface errorDefaultRenderParams {
|
|
5
|
+
reload?: () => void;
|
|
6
|
+
error: Error;
|
|
7
|
+
tableInstance?: HTableInstance;
|
|
8
|
+
}
|
|
9
|
+
export declare const errorDefaultRender: ({ error, tableInstance, reload, }: errorDefaultRenderParams) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -30,7 +30,16 @@ var emptyDefaultRender = function emptyDefaultRender() {
|
|
|
30
30
|
description: "\u6682\u65E0\u6570\u636E~"
|
|
31
31
|
}, pubProps));
|
|
32
32
|
};
|
|
33
|
-
var errorDefaultRender = function errorDefaultRender(
|
|
33
|
+
var errorDefaultRender = function errorDefaultRender(_ref) {
|
|
34
|
+
var error = _ref.error,
|
|
35
|
+
tableInstance = _ref.tableInstance,
|
|
36
|
+
reload = _ref.reload;
|
|
37
|
+
var pageReload = function pageReload() {
|
|
38
|
+
if (tableInstance) {
|
|
39
|
+
return tableInstance.table.reloadWithParams();
|
|
40
|
+
}
|
|
41
|
+
return reload === null || reload === void 0 ? void 0 : reload();
|
|
42
|
+
};
|
|
34
43
|
return jsxRuntime.jsx(antd.Empty, _objectSpread(_objectSpread({
|
|
35
44
|
image: error_bg.default,
|
|
36
45
|
description: error.message
|
|
@@ -41,9 +50,7 @@ var errorDefaultRender = function errorDefaultRender(tableInstance, error) {
|
|
|
41
50
|
style: {
|
|
42
51
|
borderRadius: 16
|
|
43
52
|
},
|
|
44
|
-
onClick:
|
|
45
|
-
tableInstance.table.reloadWithParams();
|
|
46
|
-
},
|
|
53
|
+
onClick: pageReload,
|
|
47
54
|
children: "\u5237\u65B0"
|
|
48
55
|
})
|
|
49
56
|
}));
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -158,7 +158,10 @@ var Body = (function (bodyProps) {
|
|
|
158
158
|
}), jsxRuntime.jsxs(antd.ConfigProvider, {
|
|
159
159
|
renderEmpty: function renderEmpty() {
|
|
160
160
|
if (error) {
|
|
161
|
-
return tableErrorRender === null || tableErrorRender === void 0 ? void 0 : tableErrorRender(
|
|
161
|
+
return tableErrorRender === null || tableErrorRender === void 0 ? void 0 : tableErrorRender({
|
|
162
|
+
tableInstance: tableInstance,
|
|
163
|
+
error: error
|
|
164
|
+
});
|
|
162
165
|
}
|
|
163
166
|
return tableEmptyRender === null || tableEmptyRender === void 0 ? void 0 : tableEmptyRender(tableInstance);
|
|
164
167
|
},
|
|
@@ -2,7 +2,7 @@ import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar"
|
|
|
2
2
|
import type { Key } from "react";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
5
|
-
import
|
|
5
|
+
import { ActionRenderFn, ConfigDataModal, EmptyPageRender, ErrorPageRender, HRowSelection, HTableInstance, ParamsModal } from "../modal";
|
|
6
6
|
import type { AffixProps } from "antd/lib/affix";
|
|
7
7
|
import type { IPaginationProps } from "@/components/HTablePagination";
|
|
8
8
|
export interface OptionModal extends OptionConfig {
|
|
@@ -11,8 +11,8 @@ export interface OptionModal extends OptionConfig {
|
|
|
11
11
|
export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection" | "options" | "pagination"> {
|
|
12
12
|
configData?: ConfigDataModal;
|
|
13
13
|
onPageChange?: (params: ParamsModal) => void;
|
|
14
|
-
emptyRender?:
|
|
15
|
-
errorRender?:
|
|
14
|
+
emptyRender?: EmptyPageRender;
|
|
15
|
+
errorRender?: ErrorPageRender;
|
|
16
16
|
tableStyle?: React.CSSProperties;
|
|
17
17
|
paginationStyle?: React.CSSProperties;
|
|
18
18
|
actionRender?: ActionRenderFn;
|
|
@@ -10,6 +10,7 @@ export interface IPaginationProps extends Omit<PaginationProps, "showTotal"> {
|
|
|
10
10
|
actionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
11
11
|
table?: HTableInstance;
|
|
12
12
|
showTotal?: false | PaginationProps["showTotal"];
|
|
13
|
+
data?: Record<string, any>;
|
|
13
14
|
}
|
|
14
|
-
declare const _default: ({ onPageChange, paginationStyle, affixProps, goTop, actionRender, table, showTotal, ...props }: IPaginationProps) => JSX.Element;
|
|
15
|
+
declare const _default: ({ onPageChange, paginationStyle, affixProps, goTop, actionRender, table, showTotal, data, ...props }: IPaginationProps) => JSX.Element;
|
|
15
16
|
export default _default;
|
|
@@ -23,7 +23,7 @@ var React = require('react');
|
|
|
23
23
|
var index$1 = require('../GoTop/index.js');
|
|
24
24
|
var TableConfig = require('../TableConfig.js');
|
|
25
25
|
|
|
26
|
-
var _excluded = ["onPageChange", "paginationStyle", "affixProps", "goTop", "actionRender", "table", "showTotal"],
|
|
26
|
+
var _excluded = ["onPageChange", "paginationStyle", "affixProps", "goTop", "actionRender", "table", "showTotal", "data"],
|
|
27
27
|
_excluded2 = ["offsetBottom"];
|
|
28
28
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
29
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -43,18 +43,20 @@ var HTablePagination = (function (_ref3) {
|
|
|
43
43
|
table = _ref3.table,
|
|
44
44
|
_ref3$showTotal = _ref3.showTotal,
|
|
45
45
|
showTotal = _ref3$showTotal === void 0 ? defaultShowTotal : _ref3$showTotal,
|
|
46
|
+
data = _ref3.data,
|
|
46
47
|
props = _objectWithoutProperties(_ref3, _excluded);
|
|
47
48
|
var _useHTableContext = context.useHTableContext(),
|
|
48
49
|
contextOnPageChange = _useHTableContext.onPageChange,
|
|
49
|
-
|
|
50
|
+
contextData = _useHTableContext.data,
|
|
50
51
|
contextTableInstance = _useHTableContext.tableInstance;
|
|
51
52
|
var _useHTableConfigConte = TableConfig.useHTableConfigContext({
|
|
52
53
|
paginationStyle: paginationStyle
|
|
53
54
|
}),
|
|
54
55
|
defaultPaginationStyle = _useHTableConfigConte.paginationStyle;
|
|
56
|
+
var cuData = data || contextData;
|
|
55
57
|
var tableInstance = table || contextTableInstance;
|
|
56
58
|
var tableOnPageChange = onPageChange || contextOnPageChange;
|
|
57
|
-
var _ref4 =
|
|
59
|
+
var _ref4 = cuData || {},
|
|
58
60
|
size = _ref4.size,
|
|
59
61
|
current = _ref4.current,
|
|
60
62
|
total = _ref4.total;
|
|
@@ -67,7 +69,7 @@ var HTablePagination = (function (_ref3) {
|
|
|
67
69
|
style = _useState2[0],
|
|
68
70
|
setStyle = _useState2[1];
|
|
69
71
|
var cuShowTotal = showTotal === false ? undefined : showTotal;
|
|
70
|
-
if (!
|
|
72
|
+
if (!cuData) {
|
|
71
73
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
72
74
|
}
|
|
73
75
|
if (affixProps === false) {
|
package/lib/Table.js
CHANGED
|
@@ -114,7 +114,7 @@ var Table = (function (_ref) {
|
|
|
114
114
|
configData: configData,
|
|
115
115
|
onFinish: function onFinish(value) {
|
|
116
116
|
rowSelectionReload();
|
|
117
|
-
return run(_objectSpread(_objectSpread(
|
|
117
|
+
return run(_objectSpread(_objectSpread({}, value), {}, {
|
|
118
118
|
current: 1
|
|
119
119
|
}));
|
|
120
120
|
},
|
package/lib/TableConfig.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { EmptyPageRender, ErrorPageRender, ValueTypeConfigModal } from "./modal";
|
|
3
3
|
interface HTableConfigContextModal {
|
|
4
|
-
emptyRender?:
|
|
5
|
-
errorRender?:
|
|
4
|
+
emptyRender?: EmptyPageRender;
|
|
5
|
+
errorRender?: ErrorPageRender;
|
|
6
6
|
headerStyle?: React.CSSProperties;
|
|
7
7
|
tableStyle?: React.CSSProperties;
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
|
@@ -11,8 +11,8 @@ interface HTableConfigContextModal {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
13
13
|
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle, }: HTableConfigContextModal) => {
|
|
14
|
-
errorRender:
|
|
15
|
-
emptyRender:
|
|
14
|
+
errorRender: ErrorPageRender | undefined;
|
|
15
|
+
emptyRender: EmptyPageRender | undefined;
|
|
16
16
|
headerStyle: React.CSSProperties | undefined;
|
|
17
17
|
tableStyle: React.CSSProperties | undefined;
|
|
18
18
|
paginationStyle: React.CSSProperties | undefined;
|
package/lib/index.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export { default as HModalTable } from "./DialogTable/ModalTable";
|
|
|
12
12
|
export { useHDialogTable } from "./DialogTable/hooks";
|
|
13
13
|
export { default as HDwTable } from "./DialogTable/DwTable";
|
|
14
14
|
export { DefaultSubComponent as HTableHeaderSubBtn } from "./HTableHeader/defaultSubComponent";
|
|
15
|
+
export { default as EditTable } from "./EditTable";
|
|
16
|
+
export { default as ModalEditTable } from "./DialogTable/ModalEditTable";
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,8 @@ var ModalTable = require('./DialogTable/ModalTable.js');
|
|
|
12
12
|
var hooks = require('./DialogTable/hooks.js');
|
|
13
13
|
var DwTable = require('./DialogTable/DwTable.js');
|
|
14
14
|
var defaultSubComponent = require('./HTableHeader/defaultSubComponent.js');
|
|
15
|
+
var index$4 = require('./EditTable/index.js');
|
|
16
|
+
var ModalEditTable = require('./DialogTable/ModalEditTable.js');
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
|
|
@@ -27,4 +29,6 @@ exports.HModalTable = ModalTable.default;
|
|
|
27
29
|
exports.useHDialogTable = hooks.useHDialogTable;
|
|
28
30
|
exports.HDwTable = DwTable.default;
|
|
29
31
|
exports.HTableHeaderSubBtn = defaultSubComponent.DefaultSubComponent;
|
|
32
|
+
exports.EditTable = index$4.default;
|
|
33
|
+
exports.ModalEditTable = ModalEditTable.default;
|
|
30
34
|
// powered by h
|
package/lib/modal.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import type { TableProps } from "antd/lib/table";
|
|
|
9
9
|
import type { AffixProps } from "antd/lib/affix";
|
|
10
10
|
import type { OptionModal } from "./HTableBody/modal";
|
|
11
11
|
import type { DrawerProps } from "antd";
|
|
12
|
-
import type { IPaginationProps } from "
|
|
12
|
+
import type { IPaginationProps } from "./HTablePagination";
|
|
13
|
+
import { EditTableProps } from "./EditTable/modal";
|
|
13
14
|
export interface RowObj {
|
|
14
15
|
keys?: React.Key[];
|
|
15
16
|
rowData?: any[];
|
|
@@ -56,8 +57,8 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
56
57
|
searchSpan?: ColProps;
|
|
57
58
|
table?: HTableInstance;
|
|
58
59
|
actionRender?: ActionRenderFn;
|
|
59
|
-
emptyRender?:
|
|
60
|
-
errorRender?:
|
|
60
|
+
emptyRender?: EmptyPageRender;
|
|
61
|
+
errorRender?: ErrorPageRender;
|
|
61
62
|
hideHeader?: boolean;
|
|
62
63
|
action?: Record<string, actionFn>;
|
|
63
64
|
headerStyle?: React.CSSProperties;
|
|
@@ -128,16 +129,24 @@ export interface DwTableProps extends DrawerProps {
|
|
|
128
129
|
request?: HTableProps["request"];
|
|
129
130
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
130
131
|
}
|
|
131
|
-
export interface ModalTableProps extends Omit<ModalProps, "onOk"> {
|
|
132
|
+
export interface ModalTableProps<T = HTableProps["configData"]> extends Omit<ModalProps, "onOk"> {
|
|
132
133
|
tableProps?: Omit<HTableProps, "configData" | "request">;
|
|
133
134
|
dialogTable?: HDiaLogTableInstance;
|
|
134
135
|
params?: Record<string, any>;
|
|
135
|
-
configData?:
|
|
136
|
+
configData?: T;
|
|
136
137
|
request?: HTableProps["request"];
|
|
137
138
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
138
139
|
dataSource?: any[];
|
|
139
140
|
onOk?: (e?: React.MouseEvent<HTMLElement>) => void;
|
|
141
|
+
editTableProps?: Omit<EditTableProps, "configData" | "request">;
|
|
140
142
|
}
|
|
141
143
|
export type ValueTypeConfigRenderFn = (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
|
|
142
144
|
export type ValueTypeConfigModal = Record<string, ValueTypeConfigRenderFn>;
|
|
145
|
+
interface ErrorRenderParams {
|
|
146
|
+
error: Error;
|
|
147
|
+
tableInstance?: HTableInstance;
|
|
148
|
+
reload?: VoidFunction;
|
|
149
|
+
}
|
|
150
|
+
export type ErrorPageRender = (params: ErrorRenderParams) => React.ReactNode;
|
|
151
|
+
export type EmptyPageRender = (tableInstance?: HTableInstance) => React.ReactNode;
|
|
143
152
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/table",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.94",
|
|
4
4
|
"description": "基于antd二次开发table组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"table"
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
24
|
},
|
|
25
25
|
"lint-staged": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"src/**/*.less": "npm run lint:style",
|
|
27
|
+
"src/**/*.{js,jsx,ts,tsx}": "npm run lint:js",
|
|
28
|
+
"src/**/*.{js,jsx,tsx,ts,less,md,json}": [
|
|
28
29
|
"prettier --write"
|
|
29
30
|
]
|
|
30
31
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Table from "@/components/Table";
|
|
2
|
-
import type { ModalTableProps } from "
|
|
2
|
+
import type { ModalTableProps } from "../modal";
|
|
3
|
+
import { EditTable } from "@/components";
|
|
4
|
+
import { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
3
5
|
|
|
4
|
-
export
|
|
6
|
+
export const TableContent = ({
|
|
5
7
|
tableProps,
|
|
6
8
|
configData,
|
|
7
9
|
dialogTable,
|
|
@@ -21,3 +23,24 @@ export default ({
|
|
|
21
23
|
);
|
|
22
24
|
return <>{contentRender ? contentRender(node) : node}</>;
|
|
23
25
|
};
|
|
26
|
+
|
|
27
|
+
export const EditTableContent = ({
|
|
28
|
+
editTableProps,
|
|
29
|
+
configData,
|
|
30
|
+
request,
|
|
31
|
+
contentRender,
|
|
32
|
+
dataSource,
|
|
33
|
+
}: ModalTableProps<ProColumns[]>) => {
|
|
34
|
+
const node = (
|
|
35
|
+
<EditTable
|
|
36
|
+
{...editTableProps}
|
|
37
|
+
configData={configData || []}
|
|
38
|
+
request={request}
|
|
39
|
+
pagination={{
|
|
40
|
+
affixProps: false,
|
|
41
|
+
}}
|
|
42
|
+
dataSource={dataSource}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
return <>{contentRender ? contentRender(node) : node}</>;
|
|
46
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Drawer } from "antd";
|
|
2
2
|
import type { DwTableProps } from "../modal";
|
|
3
3
|
import { useCurrentTable, useTableProps, useVisible } from "./hooks";
|
|
4
|
-
import
|
|
4
|
+
import { TableContent } from "./Content";
|
|
5
5
|
import { CloseOutlined } from "@ant-design/icons";
|
|
6
6
|
import { useClassName } from "../hooks";
|
|
7
|
+
|
|
7
8
|
export default ({
|
|
8
9
|
configData: configDataProps,
|
|
9
10
|
request: requestProps,
|
|
@@ -96,7 +97,7 @@ export default ({
|
|
|
96
97
|
afterVisibleChange?.(changeVisible);
|
|
97
98
|
}}
|
|
98
99
|
>
|
|
99
|
-
<
|
|
100
|
+
<TableContent
|
|
100
101
|
contentRender={contentRender}
|
|
101
102
|
tableProps={tableProps}
|
|
102
103
|
configData={configData || []}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Modal } from "antd";
|
|
2
|
+
import type { ModalTableProps } from "../modal";
|
|
3
|
+
import { useCurrentTable, useTableProps, useVisible } from "./hooks";
|
|
4
|
+
import { EditTableContent } from "./Content";
|
|
5
|
+
import { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
6
|
+
|
|
7
|
+
export default ({
|
|
8
|
+
configData: configDataProps,
|
|
9
|
+
request: requestProps,
|
|
10
|
+
editTableProps = {},
|
|
11
|
+
dialogTable,
|
|
12
|
+
visible = false,
|
|
13
|
+
onCancel,
|
|
14
|
+
bodyStyle = {},
|
|
15
|
+
afterClose,
|
|
16
|
+
contentRender,
|
|
17
|
+
width = 666,
|
|
18
|
+
footer = null,
|
|
19
|
+
...props
|
|
20
|
+
}: ModalTableProps<ProColumns[]>) => {
|
|
21
|
+
const { modalVisible, setModalVisible } = useVisible(visible);
|
|
22
|
+
const { modalTableParams, setModalTableParams } = useTableProps<ProColumns[]>(
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
configData: configDataProps,
|
|
26
|
+
request: requestProps,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
const currentTable = useCurrentTable({
|
|
30
|
+
show: (showParams) => {
|
|
31
|
+
if (showParams) {
|
|
32
|
+
setModalTableParams((oldParams) => {
|
|
33
|
+
const {
|
|
34
|
+
configData,
|
|
35
|
+
request,
|
|
36
|
+
title,
|
|
37
|
+
params: oldP,
|
|
38
|
+
dataSource: oldDataSource,
|
|
39
|
+
} = oldParams;
|
|
40
|
+
const {
|
|
41
|
+
title: showTitle = title,
|
|
42
|
+
configData: showConfigData = configData,
|
|
43
|
+
request: showReq = request,
|
|
44
|
+
dataSource = oldDataSource,
|
|
45
|
+
params = oldP,
|
|
46
|
+
} = showParams;
|
|
47
|
+
currentTable.params = params;
|
|
48
|
+
return {
|
|
49
|
+
title: showTitle,
|
|
50
|
+
request: showReq,
|
|
51
|
+
configData: showConfigData as any,
|
|
52
|
+
params,
|
|
53
|
+
dataSource,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
setModalVisible(true);
|
|
58
|
+
},
|
|
59
|
+
hide: () => {
|
|
60
|
+
setModalVisible(false);
|
|
61
|
+
},
|
|
62
|
+
dialogTable,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const { configData, dataSource, request, title, params } = modalTableParams;
|
|
66
|
+
const req = request
|
|
67
|
+
? (reqParams) => {
|
|
68
|
+
return request({ ...params, ...reqParams });
|
|
69
|
+
}
|
|
70
|
+
: undefined;
|
|
71
|
+
return (
|
|
72
|
+
<Modal
|
|
73
|
+
{...props}
|
|
74
|
+
footer={footer}
|
|
75
|
+
visible={modalVisible}
|
|
76
|
+
onCancel={(e) => {
|
|
77
|
+
setModalVisible(false);
|
|
78
|
+
onCancel?.(e);
|
|
79
|
+
}}
|
|
80
|
+
destroyOnClose
|
|
81
|
+
title={title}
|
|
82
|
+
width={width}
|
|
83
|
+
bodyStyle={{ padding: "0px 0px 12px", ...bodyStyle }}
|
|
84
|
+
afterClose={() => {
|
|
85
|
+
currentTable.form.resetFields();
|
|
86
|
+
afterClose?.();
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<EditTableContent
|
|
90
|
+
contentRender={contentRender}
|
|
91
|
+
editTableProps={editTableProps}
|
|
92
|
+
configData={configData || []}
|
|
93
|
+
dialogTable={currentTable}
|
|
94
|
+
request={req}
|
|
95
|
+
dataSource={dataSource}
|
|
96
|
+
/>
|
|
97
|
+
</Modal>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Modal } from "antd";
|
|
2
2
|
import type { ModalTableProps } from "../modal";
|
|
3
3
|
import { useCurrentTable, useTableProps, useVisible } from "./hooks";
|
|
4
|
-
import
|
|
4
|
+
import { TableContent } from "./Content";
|
|
5
|
+
|
|
5
6
|
export default ({
|
|
6
7
|
configData: configDataProps,
|
|
7
8
|
request: requestProps,
|
|
@@ -82,7 +83,7 @@ export default ({
|
|
|
82
83
|
afterClose?.();
|
|
83
84
|
}}
|
|
84
85
|
>
|
|
85
|
-
<
|
|
86
|
+
<TableContent
|
|
86
87
|
contentRender={contentRender}
|
|
87
88
|
tableProps={tableProps}
|
|
88
89
|
configData={configData || []}
|