@hw-component/table 1.9.13 → 1.9.14
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/es/DialogTable/Content.d.ts +2 -1
- package/es/DialogTable/Content.js +4 -2
- package/es/DialogTable/DwTable.d.ts +1 -0
- package/es/DialogTable/DwTable.js +10 -4
- package/es/DialogTable/ModalTable.d.ts +1 -0
- package/es/DialogTable/ModalTable.js +9 -3
- package/es/DialogTable/hooks.d.ts +3 -1
- package/es/DialogTable/hooks.js +4 -2
- package/es/Table.d.ts +1 -1
- package/es/Table.js +6 -2
- package/es/hooks/useReq.d.ts +3 -3
- package/es/hooks/useReq.js +82 -19
- package/es/modal.d.ts +3 -1
- package/es/render/Text.d.ts +0 -1
- package/lib/DialogTable/Content.d.ts +2 -1
- package/lib/DialogTable/Content.js +4 -2
- package/lib/DialogTable/DwTable.d.ts +1 -0
- package/lib/DialogTable/DwTable.js +10 -4
- package/lib/DialogTable/ModalTable.d.ts +1 -0
- package/lib/DialogTable/ModalTable.js +9 -3
- package/lib/DialogTable/hooks.d.ts +3 -1
- package/lib/DialogTable/hooks.js +4 -2
- package/lib/Table.d.ts +1 -1
- package/lib/Table.js +6 -2
- package/lib/hooks/useReq.d.ts +3 -3
- package/lib/hooks/useReq.js +81 -18
- package/lib/modal.d.ts +3 -1
- package/lib/render/Text.d.ts +0 -1
- package/package.json +15 -14
- package/src/components/DialogTable/Content.tsx +2 -0
- package/src/components/DialogTable/DwTable.tsx +10 -2
- package/src/components/DialogTable/ModalTable.tsx +11 -2
- package/src/components/DialogTable/hooks.ts +2 -0
- package/src/components/Table.tsx +4 -0
- package/src/components/hooks/useReq.ts +57 -8
- package/src/components/modal.ts +3 -1
- package/src/pages/DwTable/index.tsx +16 -2
- package/src/pages/ModalTable/index.tsx +14 -2
- package/src/pages/Table/index.tsx +27 -32
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { ModalTableProps } from "@/components/modal";
|
|
2
|
-
declare const _default: ({ tableProps, configData, dialogTable, request, contentRender, }: ModalTableProps) => JSX.Element;
|
|
3
|
+
declare const _default: ({ tableProps, configData, dialogTable, request, contentRender, dataSource, }: ModalTableProps) => JSX.Element;
|
|
3
4
|
export default _default;
|
|
@@ -18,12 +18,14 @@ var Content = (function (_ref) {
|
|
|
18
18
|
configData = _ref.configData,
|
|
19
19
|
dialogTable = _ref.dialogTable,
|
|
20
20
|
request = _ref.request,
|
|
21
|
-
contentRender = _ref.contentRender
|
|
21
|
+
contentRender = _ref.contentRender,
|
|
22
|
+
dataSource = _ref.dataSource;
|
|
22
23
|
var node = jsx(Table, _objectSpread(_objectSpread({}, tableProps), {}, {
|
|
23
24
|
configData: configData || [],
|
|
24
25
|
table: dialogTable,
|
|
25
26
|
request: request,
|
|
26
|
-
affixProps: false
|
|
27
|
+
affixProps: false,
|
|
28
|
+
dataSource: dataSource
|
|
27
29
|
}));
|
|
28
30
|
return jsx(Fragment, {
|
|
29
31
|
children: contentRender ? contentRender(node) : node
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { DwTableProps } from "../modal";
|
|
2
3
|
declare const _default: ({ configData: configDataProps, request: requestProps, tableProps, dialogTable, visible, bodyStyle, onClose, afterVisibleChange, contentRender, width, footer, ...props }: DwTableProps) => JSX.Element;
|
|
3
4
|
export default _default;
|
|
@@ -54,7 +54,8 @@ var DwTable = (function (_ref) {
|
|
|
54
54
|
var configData = oldParams.configData,
|
|
55
55
|
request = oldParams.request,
|
|
56
56
|
title = oldParams.title,
|
|
57
|
-
oldP = oldParams.params
|
|
57
|
+
oldP = oldParams.params,
|
|
58
|
+
oldDataSource = oldParams.dataSource;
|
|
58
59
|
var _showParams$title = showParams.title,
|
|
59
60
|
showTitle = _showParams$title === void 0 ? title : _showParams$title,
|
|
60
61
|
_showParams$configDat = showParams.configData,
|
|
@@ -62,13 +63,16 @@ var DwTable = (function (_ref) {
|
|
|
62
63
|
_showParams$request = showParams.request,
|
|
63
64
|
showReq = _showParams$request === void 0 ? request : _showParams$request,
|
|
64
65
|
_showParams$params = showParams.params,
|
|
65
|
-
params = _showParams$params === void 0 ? oldP : _showParams$params
|
|
66
|
+
params = _showParams$params === void 0 ? oldP : _showParams$params,
|
|
67
|
+
_showParams$dataSourc = showParams.dataSource,
|
|
68
|
+
dataSource = _showParams$dataSourc === void 0 ? oldDataSource : _showParams$dataSourc;
|
|
66
69
|
currentTable.params = params;
|
|
67
70
|
return {
|
|
68
71
|
title: showTitle,
|
|
69
72
|
request: showReq,
|
|
70
73
|
configData: showConfigData,
|
|
71
|
-
params: params
|
|
74
|
+
params: params,
|
|
75
|
+
dataSource: dataSource
|
|
72
76
|
};
|
|
73
77
|
});
|
|
74
78
|
}
|
|
@@ -81,6 +85,7 @@ var DwTable = (function (_ref) {
|
|
|
81
85
|
});
|
|
82
86
|
var configData = modalTableParams.configData,
|
|
83
87
|
request = modalTableParams.request,
|
|
88
|
+
dataSource = modalTableParams.dataSource,
|
|
84
89
|
title = modalTableParams.title,
|
|
85
90
|
params = modalTableParams.params;
|
|
86
91
|
var req = request ? function (reqParams) {
|
|
@@ -119,7 +124,8 @@ var DwTable = (function (_ref) {
|
|
|
119
124
|
tableProps: tableProps,
|
|
120
125
|
configData: configData || [],
|
|
121
126
|
dialogTable: currentTable,
|
|
122
|
-
request: req
|
|
127
|
+
request: req,
|
|
128
|
+
dataSource: dataSource
|
|
123
129
|
})
|
|
124
130
|
}));
|
|
125
131
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { ModalTableProps } from "../modal";
|
|
2
3
|
declare const _default: ({ configData: configDataProps, request: requestProps, tableProps, dialogTable, visible, onCancel, bodyStyle, afterClose, contentRender, width, footer, ...props }: ModalTableProps) => JSX.Element;
|
|
3
4
|
export default _default;
|
|
@@ -51,13 +51,16 @@ var ModalTable = (function (_ref) {
|
|
|
51
51
|
var configData = oldParams.configData,
|
|
52
52
|
request = oldParams.request,
|
|
53
53
|
title = oldParams.title,
|
|
54
|
-
oldP = oldParams.params
|
|
54
|
+
oldP = oldParams.params,
|
|
55
|
+
oldDataSource = oldParams.dataSource;
|
|
55
56
|
var _showParams$title = showParams.title,
|
|
56
57
|
showTitle = _showParams$title === void 0 ? title : _showParams$title,
|
|
57
58
|
_showParams$configDat = showParams.configData,
|
|
58
59
|
showConfigData = _showParams$configDat === void 0 ? configData : _showParams$configDat,
|
|
59
60
|
_showParams$request = showParams.request,
|
|
60
61
|
showReq = _showParams$request === void 0 ? request : _showParams$request,
|
|
62
|
+
_showParams$dataSourc = showParams.dataSource,
|
|
63
|
+
dataSource = _showParams$dataSourc === void 0 ? oldDataSource : _showParams$dataSourc,
|
|
61
64
|
_showParams$params = showParams.params,
|
|
62
65
|
params = _showParams$params === void 0 ? oldP : _showParams$params;
|
|
63
66
|
currentTable.params = params;
|
|
@@ -65,7 +68,8 @@ var ModalTable = (function (_ref) {
|
|
|
65
68
|
title: showTitle,
|
|
66
69
|
request: showReq,
|
|
67
70
|
configData: showConfigData,
|
|
68
|
-
params: params
|
|
71
|
+
params: params,
|
|
72
|
+
dataSource: dataSource
|
|
69
73
|
};
|
|
70
74
|
});
|
|
71
75
|
}
|
|
@@ -77,6 +81,7 @@ var ModalTable = (function (_ref) {
|
|
|
77
81
|
dialogTable: dialogTable
|
|
78
82
|
});
|
|
79
83
|
var configData = modalTableParams.configData,
|
|
84
|
+
dataSource = modalTableParams.dataSource,
|
|
80
85
|
request = modalTableParams.request,
|
|
81
86
|
title = modalTableParams.title,
|
|
82
87
|
params = modalTableParams.params;
|
|
@@ -106,7 +111,8 @@ var ModalTable = (function (_ref) {
|
|
|
106
111
|
tableProps: tableProps,
|
|
107
112
|
configData: configData || [],
|
|
108
113
|
dialogTable: currentTable,
|
|
109
|
-
request: req
|
|
114
|
+
request: req,
|
|
115
|
+
dataSource: dataSource
|
|
110
116
|
})
|
|
111
117
|
}));
|
|
112
118
|
});
|
|
@@ -4,18 +4,20 @@ export declare const useHDialogTable: () => HDiaLogTableInstance;
|
|
|
4
4
|
interface ParamsModal extends HOnDiaLogTableInstance {
|
|
5
5
|
dialogTable?: HDiaLogTableInstance;
|
|
6
6
|
}
|
|
7
|
-
export declare const useTableProps: ({ configData, params, title, request, }: Omit<ModalTableProps, "tableProps">) => {
|
|
7
|
+
export declare const useTableProps: ({ configData, params, title, request, dataSource, }: Omit<ModalTableProps, "tableProps">) => {
|
|
8
8
|
modalTableParams: {
|
|
9
9
|
params: Record<string, any> | undefined;
|
|
10
10
|
title: import("react").ReactNode;
|
|
11
11
|
configData: import("../modal").ConfigDataModal | undefined;
|
|
12
12
|
request: ((params: import("../modal").ParamsModal) => Promise<import("../modal").ResultModal>) | undefined;
|
|
13
|
+
dataSource: any[] | undefined;
|
|
13
14
|
};
|
|
14
15
|
setModalTableParams: import("react").Dispatch<import("react").SetStateAction<{
|
|
15
16
|
params: Record<string, any> | undefined;
|
|
16
17
|
title: import("react").ReactNode;
|
|
17
18
|
configData: import("../modal").ConfigDataModal | undefined;
|
|
18
19
|
request: ((params: import("../modal").ParamsModal) => Promise<import("../modal").ResultModal>) | undefined;
|
|
20
|
+
dataSource: any[] | undefined;
|
|
19
21
|
}>>;
|
|
20
22
|
};
|
|
21
23
|
export declare const useCurrentTable: ({ show, hide, dialogTable }: ParamsModal) => HDiaLogTableInstance;
|
package/es/DialogTable/hooks.js
CHANGED
|
@@ -28,12 +28,14 @@ var useTableProps = function useTableProps(_ref) {
|
|
|
28
28
|
var configData = _ref.configData,
|
|
29
29
|
params = _ref.params,
|
|
30
30
|
title = _ref.title,
|
|
31
|
-
request = _ref.request
|
|
31
|
+
request = _ref.request,
|
|
32
|
+
dataSource = _ref.dataSource;
|
|
32
33
|
var _useState = useState({
|
|
33
34
|
params: params,
|
|
34
35
|
title: title,
|
|
35
36
|
configData: configData,
|
|
36
|
-
request: request
|
|
37
|
+
request: request,
|
|
38
|
+
dataSource: dataSource
|
|
37
39
|
}),
|
|
38
40
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
41
|
modalTableParams = _useState2[0],
|
package/es/Table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HTableProps } from "./modal";
|
|
3
|
-
declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, onFinish, manual, formInitValues, hideLabel, labelWidth, onReset, style, ...props }: HTableProps) => JSX.Element;
|
|
3
|
+
declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, onFinish, manual, formInitValues, hideLabel, labelWidth, onReset, style, dataSource, reload, ...props }: HTableProps) => JSX.Element;
|
|
4
4
|
export default _default;
|
package/es/Table.js
CHANGED
|
@@ -23,7 +23,7 @@ import useDispatch from './hooks/useDispatch.js';
|
|
|
23
23
|
import { useState } from 'react';
|
|
24
24
|
import { useClassName } from './hooks/index.js';
|
|
25
25
|
|
|
26
|
-
var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish", "manual", "formInitValues", "hideLabel", "labelWidth", "onReset", "style"];
|
|
26
|
+
var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish", "manual", "formInitValues", "hideLabel", "labelWidth", "onReset", "style", "dataSource", "reload"];
|
|
27
27
|
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; }
|
|
28
28
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
29
|
var Table = (function (_ref) {
|
|
@@ -49,11 +49,15 @@ var Table = (function (_ref) {
|
|
|
49
49
|
labelWidth = _ref.labelWidth,
|
|
50
50
|
onReset = _ref.onReset,
|
|
51
51
|
style = _ref.style,
|
|
52
|
+
dataSource = _ref.dataSource,
|
|
53
|
+
reload = _ref.reload,
|
|
52
54
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
53
55
|
var _useReq = useReq({
|
|
54
56
|
request: request,
|
|
55
57
|
manual: manual,
|
|
56
|
-
formInitValues: formInitValues
|
|
58
|
+
formInitValues: formInitValues,
|
|
59
|
+
dataSource: dataSource,
|
|
60
|
+
reload: reload
|
|
57
61
|
}),
|
|
58
62
|
run = _useReq.run,
|
|
59
63
|
loading = _useReq.loading,
|
package/es/hooks/useReq.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface IParamsModal {
|
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
error?: Error;
|
|
6
6
|
reload?: (params: any) => Promise<any>;
|
|
7
|
-
dataSource?: any;
|
|
7
|
+
dataSource?: ResultModal | any[];
|
|
8
8
|
manual?: boolean;
|
|
9
9
|
formInitValues?: Record<string, any>;
|
|
10
10
|
}
|
|
@@ -28,8 +28,8 @@ declare const _default: ({ request, loading, error, reload, dataSource, manual,
|
|
|
28
28
|
} | {
|
|
29
29
|
loading: boolean | undefined;
|
|
30
30
|
error: Error | undefined;
|
|
31
|
-
data:
|
|
32
|
-
run: (params?: Record<string, any>) => Promise<
|
|
31
|
+
data: ResultModal;
|
|
32
|
+
run: (params?: Record<string, any>) => Promise<void>;
|
|
33
33
|
saveParams: {
|
|
34
34
|
old: {};
|
|
35
35
|
};
|
package/es/hooks/useReq.js
CHANGED
|
@@ -7,53 +7,116 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/fo
|
|
|
7
7
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
8
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
9
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
11
10
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
12
11
|
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
12
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
13
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
13
14
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
14
|
-
import
|
|
15
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
16
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
|
17
|
+
import _Number$parseInt from '@babel/runtime-corejs3/core-js/number/parse-int';
|
|
18
|
+
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js/instance/slice';
|
|
19
|
+
import _Array$isArray from '@babel/runtime-corejs3/core-js/array/is-array';
|
|
20
|
+
import { useMemo, useEffect, useState } from 'react';
|
|
15
21
|
import { useRequest } from 'ahooks';
|
|
16
22
|
|
|
17
23
|
var _excluded = ["size", "current"],
|
|
18
24
|
_excluded2 = ["size", "current"];
|
|
19
25
|
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; }
|
|
20
26
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
var defaultDataSource = {
|
|
28
|
+
records: [],
|
|
29
|
+
total: "0",
|
|
30
|
+
size: "0",
|
|
31
|
+
current: "1"
|
|
32
|
+
};
|
|
33
|
+
var useDataSource = function useDataSource(_ref) {
|
|
34
|
+
var reload = _ref.reload,
|
|
35
|
+
dataSource = _ref.dataSource;
|
|
36
|
+
var _useState = useState(_objectSpread({}, defaultDataSource)),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
cpDataSource = _useState2[0],
|
|
39
|
+
setCpDataSource = _useState2[1];
|
|
40
|
+
var localMaker = function localMaker(params) {
|
|
41
|
+
var size = params.size,
|
|
42
|
+
current = params.current;
|
|
43
|
+
var ps = _Number$parseInt(size);
|
|
44
|
+
var pn = _Number$parseInt(current);
|
|
45
|
+
var prvPn = pn - 1;
|
|
46
|
+
var arrDataSource = dataSource;
|
|
47
|
+
var records = _sliceInstanceProperty(arrDataSource).call(arrDataSource, prvPn * ps, pn * ps);
|
|
48
|
+
var total = arrDataSource.length;
|
|
49
|
+
return {
|
|
50
|
+
records: records,
|
|
51
|
+
size: size,
|
|
52
|
+
current: current,
|
|
53
|
+
total: total.toString()
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
var defaultReload = function defaultReload(params) {
|
|
57
|
+
if (_Array$isArray(dataSource)) {
|
|
58
|
+
console.warn("@hw-component/table:非受控模式reload将不起作用");
|
|
59
|
+
setCpDataSource(localMaker(params));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
reload === null || reload === void 0 || reload(params);
|
|
63
|
+
};
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
if (_Array$isArray(dataSource)) {
|
|
66
|
+
setCpDataSource(function (old) {
|
|
67
|
+
return localMaker(old);
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
setCpDataSource(dataSource || _objectSpread({}, defaultDataSource));
|
|
72
|
+
}, [dataSource]);
|
|
73
|
+
return {
|
|
74
|
+
reload: defaultReload,
|
|
75
|
+
dataSource: cpDataSource
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var useReq = (function (_ref2) {
|
|
79
|
+
var request = _ref2.request,
|
|
80
|
+
loading = _ref2.loading,
|
|
81
|
+
error = _ref2.error,
|
|
82
|
+
reload = _ref2.reload,
|
|
83
|
+
dataSource = _ref2.dataSource,
|
|
84
|
+
_ref2$manual = _ref2.manual,
|
|
85
|
+
manual = _ref2$manual === void 0 ? false : _ref2$manual,
|
|
86
|
+
_ref2$formInitValues = _ref2.formInitValues,
|
|
87
|
+
formInitValues = _ref2$formInitValues === void 0 ? {} : _ref2$formInitValues;
|
|
31
88
|
var saveParams = useMemo(function () {
|
|
32
89
|
return {
|
|
33
90
|
old: {}
|
|
34
91
|
};
|
|
35
92
|
}, []);
|
|
93
|
+
var _useDataSource = useDataSource({
|
|
94
|
+
reload: reload,
|
|
95
|
+
dataSource: dataSource
|
|
96
|
+
}),
|
|
97
|
+
localReload = _useDataSource.reload,
|
|
98
|
+
localDataSource = _useDataSource.dataSource;
|
|
36
99
|
var reloadFn = /*#__PURE__*/function () {
|
|
37
|
-
var
|
|
100
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
38
101
|
var params,
|
|
39
102
|
_params$size,
|
|
40
103
|
size,
|
|
41
104
|
_params$current,
|
|
42
105
|
current,
|
|
43
106
|
oParams,
|
|
44
|
-
|
|
107
|
+
requestParams,
|
|
45
108
|
_args = arguments;
|
|
46
109
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
47
110
|
while (1) switch (_context.prev = _context.next) {
|
|
48
111
|
case 0:
|
|
49
112
|
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
50
113
|
_params$size = params.size, size = _params$size === void 0 ? "10" : _params$size, _params$current = params.current, current = _params$current === void 0 ? "1" : _params$current, oParams = _objectWithoutProperties(params, _excluded);
|
|
51
|
-
|
|
114
|
+
requestParams = _objectSpread({
|
|
52
115
|
size: size,
|
|
53
116
|
current: current
|
|
54
117
|
}, oParams);
|
|
55
|
-
saveParams.old =
|
|
56
|
-
return _context.abrupt("return",
|
|
118
|
+
saveParams.old = requestParams;
|
|
119
|
+
return _context.abrupt("return", localReload(requestParams));
|
|
57
120
|
case 5:
|
|
58
121
|
case "end":
|
|
59
122
|
return _context.stop();
|
|
@@ -61,7 +124,7 @@ var useReq = (function (_ref) {
|
|
|
61
124
|
}, _callee);
|
|
62
125
|
}));
|
|
63
126
|
return function reloadFn() {
|
|
64
|
-
return
|
|
127
|
+
return _ref3.apply(this, arguments);
|
|
65
128
|
};
|
|
66
129
|
}();
|
|
67
130
|
var resultAction = useRequest(function () {
|
|
@@ -98,7 +161,7 @@ var useReq = (function (_ref) {
|
|
|
98
161
|
return {
|
|
99
162
|
loading: loading,
|
|
100
163
|
error: error,
|
|
101
|
-
data:
|
|
164
|
+
data: localDataSource,
|
|
102
165
|
run: reloadFn,
|
|
103
166
|
saveParams: saveParams
|
|
104
167
|
};
|
package/es/modal.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
65
65
|
error?: Error;
|
|
66
66
|
reload?: (params: any) => Promise<any>;
|
|
67
67
|
manual?: boolean;
|
|
68
|
-
dataSource?: ResultModal;
|
|
68
|
+
dataSource?: ResultModal | any[];
|
|
69
69
|
paginationStyle?: React.CSSProperties;
|
|
70
70
|
allPageCheck?: boolean;
|
|
71
71
|
rowSelection?: HRowSelection | false;
|
|
@@ -103,6 +103,7 @@ export interface DialogParamsModal {
|
|
|
103
103
|
request?: HTableProps["request"];
|
|
104
104
|
params?: Record<string, any>;
|
|
105
105
|
title?: string | React.ReactNode;
|
|
106
|
+
dataSource?: any[];
|
|
106
107
|
}
|
|
107
108
|
export interface HOnDiaLogTableInstance {
|
|
108
109
|
show: (params?: DialogParamsModal) => void;
|
|
@@ -130,6 +131,7 @@ export interface ModalTableProps extends ModalProps {
|
|
|
130
131
|
configData?: HTableProps["configData"];
|
|
131
132
|
request?: HTableProps["request"];
|
|
132
133
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
134
|
+
dataSource?: any[];
|
|
133
135
|
}
|
|
134
136
|
export type ValueTypeConfigRenderFn = (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
|
|
135
137
|
export type ValueTypeConfigModal = Record<string, ValueTypeConfigRenderFn>;
|
package/es/render/Text.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { ModalTableProps } from "@/components/modal";
|
|
2
|
-
declare const _default: ({ tableProps, configData, dialogTable, request, contentRender, }: ModalTableProps) => JSX.Element;
|
|
3
|
+
declare const _default: ({ tableProps, configData, dialogTable, request, contentRender, dataSource, }: ModalTableProps) => JSX.Element;
|
|
3
4
|
export default _default;
|
|
@@ -21,12 +21,14 @@ var Content = (function (_ref) {
|
|
|
21
21
|
configData = _ref.configData,
|
|
22
22
|
dialogTable = _ref.dialogTable,
|
|
23
23
|
request = _ref.request,
|
|
24
|
-
contentRender = _ref.contentRender
|
|
24
|
+
contentRender = _ref.contentRender,
|
|
25
|
+
dataSource = _ref.dataSource;
|
|
25
26
|
var node = jsxRuntime.jsx(Table.default, _objectSpread(_objectSpread({}, tableProps), {}, {
|
|
26
27
|
configData: configData || [],
|
|
27
28
|
table: dialogTable,
|
|
28
29
|
request: request,
|
|
29
|
-
affixProps: false
|
|
30
|
+
affixProps: false,
|
|
31
|
+
dataSource: dataSource
|
|
30
32
|
}));
|
|
31
33
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
32
34
|
children: contentRender ? contentRender(node) : node
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { DwTableProps } from "../modal";
|
|
2
3
|
declare const _default: ({ configData: configDataProps, request: requestProps, tableProps, dialogTable, visible, bodyStyle, onClose, afterVisibleChange, contentRender, width, footer, ...props }: DwTableProps) => JSX.Element;
|
|
3
4
|
export default _default;
|
|
@@ -57,7 +57,8 @@ var DwTable = (function (_ref) {
|
|
|
57
57
|
var configData = oldParams.configData,
|
|
58
58
|
request = oldParams.request,
|
|
59
59
|
title = oldParams.title,
|
|
60
|
-
oldP = oldParams.params
|
|
60
|
+
oldP = oldParams.params,
|
|
61
|
+
oldDataSource = oldParams.dataSource;
|
|
61
62
|
var _showParams$title = showParams.title,
|
|
62
63
|
showTitle = _showParams$title === void 0 ? title : _showParams$title,
|
|
63
64
|
_showParams$configDat = showParams.configData,
|
|
@@ -65,13 +66,16 @@ var DwTable = (function (_ref) {
|
|
|
65
66
|
_showParams$request = showParams.request,
|
|
66
67
|
showReq = _showParams$request === void 0 ? request : _showParams$request,
|
|
67
68
|
_showParams$params = showParams.params,
|
|
68
|
-
params = _showParams$params === void 0 ? oldP : _showParams$params
|
|
69
|
+
params = _showParams$params === void 0 ? oldP : _showParams$params,
|
|
70
|
+
_showParams$dataSourc = showParams.dataSource,
|
|
71
|
+
dataSource = _showParams$dataSourc === void 0 ? oldDataSource : _showParams$dataSourc;
|
|
69
72
|
currentTable.params = params;
|
|
70
73
|
return {
|
|
71
74
|
title: showTitle,
|
|
72
75
|
request: showReq,
|
|
73
76
|
configData: showConfigData,
|
|
74
|
-
params: params
|
|
77
|
+
params: params,
|
|
78
|
+
dataSource: dataSource
|
|
75
79
|
};
|
|
76
80
|
});
|
|
77
81
|
}
|
|
@@ -84,6 +88,7 @@ var DwTable = (function (_ref) {
|
|
|
84
88
|
});
|
|
85
89
|
var configData = modalTableParams.configData,
|
|
86
90
|
request = modalTableParams.request,
|
|
91
|
+
dataSource = modalTableParams.dataSource,
|
|
87
92
|
title = modalTableParams.title,
|
|
88
93
|
params = modalTableParams.params;
|
|
89
94
|
var req = request ? function (reqParams) {
|
|
@@ -122,7 +127,8 @@ var DwTable = (function (_ref) {
|
|
|
122
127
|
tableProps: tableProps,
|
|
123
128
|
configData: configData || [],
|
|
124
129
|
dialogTable: currentTable,
|
|
125
|
-
request: req
|
|
130
|
+
request: req,
|
|
131
|
+
dataSource: dataSource
|
|
126
132
|
})
|
|
127
133
|
}));
|
|
128
134
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { ModalTableProps } from "../modal";
|
|
2
3
|
declare const _default: ({ configData: configDataProps, request: requestProps, tableProps, dialogTable, visible, onCancel, bodyStyle, afterClose, contentRender, width, footer, ...props }: ModalTableProps) => JSX.Element;
|
|
3
4
|
export default _default;
|
|
@@ -54,13 +54,16 @@ var ModalTable = (function (_ref) {
|
|
|
54
54
|
var configData = oldParams.configData,
|
|
55
55
|
request = oldParams.request,
|
|
56
56
|
title = oldParams.title,
|
|
57
|
-
oldP = oldParams.params
|
|
57
|
+
oldP = oldParams.params,
|
|
58
|
+
oldDataSource = oldParams.dataSource;
|
|
58
59
|
var _showParams$title = showParams.title,
|
|
59
60
|
showTitle = _showParams$title === void 0 ? title : _showParams$title,
|
|
60
61
|
_showParams$configDat = showParams.configData,
|
|
61
62
|
showConfigData = _showParams$configDat === void 0 ? configData : _showParams$configDat,
|
|
62
63
|
_showParams$request = showParams.request,
|
|
63
64
|
showReq = _showParams$request === void 0 ? request : _showParams$request,
|
|
65
|
+
_showParams$dataSourc = showParams.dataSource,
|
|
66
|
+
dataSource = _showParams$dataSourc === void 0 ? oldDataSource : _showParams$dataSourc,
|
|
64
67
|
_showParams$params = showParams.params,
|
|
65
68
|
params = _showParams$params === void 0 ? oldP : _showParams$params;
|
|
66
69
|
currentTable.params = params;
|
|
@@ -68,7 +71,8 @@ var ModalTable = (function (_ref) {
|
|
|
68
71
|
title: showTitle,
|
|
69
72
|
request: showReq,
|
|
70
73
|
configData: showConfigData,
|
|
71
|
-
params: params
|
|
74
|
+
params: params,
|
|
75
|
+
dataSource: dataSource
|
|
72
76
|
};
|
|
73
77
|
});
|
|
74
78
|
}
|
|
@@ -80,6 +84,7 @@ var ModalTable = (function (_ref) {
|
|
|
80
84
|
dialogTable: dialogTable
|
|
81
85
|
});
|
|
82
86
|
var configData = modalTableParams.configData,
|
|
87
|
+
dataSource = modalTableParams.dataSource,
|
|
83
88
|
request = modalTableParams.request,
|
|
84
89
|
title = modalTableParams.title,
|
|
85
90
|
params = modalTableParams.params;
|
|
@@ -109,7 +114,8 @@ var ModalTable = (function (_ref) {
|
|
|
109
114
|
tableProps: tableProps,
|
|
110
115
|
configData: configData || [],
|
|
111
116
|
dialogTable: currentTable,
|
|
112
|
-
request: req
|
|
117
|
+
request: req,
|
|
118
|
+
dataSource: dataSource
|
|
113
119
|
})
|
|
114
120
|
}));
|
|
115
121
|
});
|
|
@@ -4,18 +4,20 @@ export declare const useHDialogTable: () => HDiaLogTableInstance;
|
|
|
4
4
|
interface ParamsModal extends HOnDiaLogTableInstance {
|
|
5
5
|
dialogTable?: HDiaLogTableInstance;
|
|
6
6
|
}
|
|
7
|
-
export declare const useTableProps: ({ configData, params, title, request, }: Omit<ModalTableProps, "tableProps">) => {
|
|
7
|
+
export declare const useTableProps: ({ configData, params, title, request, dataSource, }: Omit<ModalTableProps, "tableProps">) => {
|
|
8
8
|
modalTableParams: {
|
|
9
9
|
params: Record<string, any> | undefined;
|
|
10
10
|
title: import("react").ReactNode;
|
|
11
11
|
configData: import("../modal").ConfigDataModal | undefined;
|
|
12
12
|
request: ((params: import("../modal").ParamsModal) => Promise<import("../modal").ResultModal>) | undefined;
|
|
13
|
+
dataSource: any[] | undefined;
|
|
13
14
|
};
|
|
14
15
|
setModalTableParams: import("react").Dispatch<import("react").SetStateAction<{
|
|
15
16
|
params: Record<string, any> | undefined;
|
|
16
17
|
title: import("react").ReactNode;
|
|
17
18
|
configData: import("../modal").ConfigDataModal | undefined;
|
|
18
19
|
request: ((params: import("../modal").ParamsModal) => Promise<import("../modal").ResultModal>) | undefined;
|
|
20
|
+
dataSource: any[] | undefined;
|
|
19
21
|
}>>;
|
|
20
22
|
};
|
|
21
23
|
export declare const useCurrentTable: ({ show, hide, dialogTable }: ParamsModal) => HDiaLogTableInstance;
|
package/lib/DialogTable/hooks.js
CHANGED
|
@@ -29,12 +29,14 @@ var useTableProps = function useTableProps(_ref) {
|
|
|
29
29
|
var configData = _ref.configData,
|
|
30
30
|
params = _ref.params,
|
|
31
31
|
title = _ref.title,
|
|
32
|
-
request = _ref.request
|
|
32
|
+
request = _ref.request,
|
|
33
|
+
dataSource = _ref.dataSource;
|
|
33
34
|
var _useState = React.useState({
|
|
34
35
|
params: params,
|
|
35
36
|
title: title,
|
|
36
37
|
configData: configData,
|
|
37
|
-
request: request
|
|
38
|
+
request: request,
|
|
39
|
+
dataSource: dataSource
|
|
38
40
|
}),
|
|
39
41
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
42
|
modalTableParams = _useState2[0],
|
package/lib/Table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HTableProps } from "./modal";
|
|
3
|
-
declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, onFinish, manual, formInitValues, hideLabel, labelWidth, onReset, style, ...props }: HTableProps) => JSX.Element;
|
|
3
|
+
declare const _default: ({ request, configData, searchSpan, table, hideHeader, headerStyle, tableStyle, action, spaceSize, className, paginationStyle, rowKey, onFinish, manual, formInitValues, hideLabel, labelWidth, onReset, style, dataSource, reload, ...props }: HTableProps) => JSX.Element;
|
|
4
4
|
export default _default;
|
package/lib/Table.js
CHANGED
|
@@ -26,7 +26,7 @@ var useDispatch = require('./hooks/useDispatch.js');
|
|
|
26
26
|
var React = require('react');
|
|
27
27
|
var index = require('./hooks/index.js');
|
|
28
28
|
|
|
29
|
-
var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish", "manual", "formInitValues", "hideLabel", "labelWidth", "onReset", "style"];
|
|
29
|
+
var _excluded = ["request", "configData", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish", "manual", "formInitValues", "hideLabel", "labelWidth", "onReset", "style", "dataSource", "reload"];
|
|
30
30
|
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; }
|
|
31
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
32
|
var Table = (function (_ref) {
|
|
@@ -52,11 +52,15 @@ var Table = (function (_ref) {
|
|
|
52
52
|
labelWidth = _ref.labelWidth,
|
|
53
53
|
onReset = _ref.onReset,
|
|
54
54
|
style = _ref.style,
|
|
55
|
+
dataSource = _ref.dataSource,
|
|
56
|
+
reload = _ref.reload,
|
|
55
57
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
58
|
var _useReq = useReq.default({
|
|
57
59
|
request: request,
|
|
58
60
|
manual: manual,
|
|
59
|
-
formInitValues: formInitValues
|
|
61
|
+
formInitValues: formInitValues,
|
|
62
|
+
dataSource: dataSource,
|
|
63
|
+
reload: reload
|
|
60
64
|
}),
|
|
61
65
|
run = _useReq.run,
|
|
62
66
|
loading = _useReq.loading,
|
package/lib/hooks/useReq.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface IParamsModal {
|
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
error?: Error;
|
|
6
6
|
reload?: (params: any) => Promise<any>;
|
|
7
|
-
dataSource?: any;
|
|
7
|
+
dataSource?: ResultModal | any[];
|
|
8
8
|
manual?: boolean;
|
|
9
9
|
formInitValues?: Record<string, any>;
|
|
10
10
|
}
|
|
@@ -28,8 +28,8 @@ declare const _default: ({ request, loading, error, reload, dataSource, manual,
|
|
|
28
28
|
} | {
|
|
29
29
|
loading: boolean | undefined;
|
|
30
30
|
error: Error | undefined;
|
|
31
|
-
data:
|
|
32
|
-
run: (params?: Record<string, any>) => Promise<
|
|
31
|
+
data: ResultModal;
|
|
32
|
+
run: (params?: Record<string, any>) => Promise<void>;
|
|
33
33
|
saveParams: {
|
|
34
34
|
old: {};
|
|
35
35
|
};
|