@hw-component/form 0.0.8-beta-v6 → 0.0.8-beta-v7
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/DialogForm/DrawerForm/index.d.ts +1 -1
- package/es/DialogForm/DrawerForm/index.js +42 -40
- package/es/DialogForm/ModalForm.d.ts +1 -1
- package/es/DialogForm/ModalForm.js +41 -39
- package/es/DialogForm/modal.d.ts +2 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +1 -1
- package/lib/DialogForm/DrawerForm/index.js +42 -40
- package/lib/DialogForm/ModalForm.d.ts +1 -1
- package/lib/DialogForm/ModalForm.js +41 -39
- package/lib/DialogForm/modal.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +20 -18
- package/src/components/DialogForm/ModalForm.tsx +19 -17
- package/src/components/DialogForm/modal.ts +2 -0
- package/src/pages/ModalForm/index.tsx +6 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "../modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, contentRender, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -18,7 +18,7 @@ import Title from './Title.js';
|
|
|
18
18
|
import Footer from './Footer.js';
|
|
19
19
|
import Index, { useFormConfigContext } from '../../Form/Context/FormConfigProvider.js';
|
|
20
20
|
|
|
21
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear"];
|
|
21
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender"];
|
|
22
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
24
|
var DrawerForm = (function (_ref) {
|
|
@@ -43,6 +43,7 @@ var DrawerForm = (function (_ref) {
|
|
|
43
43
|
onValuesChange = _ref.onValuesChange,
|
|
44
44
|
_ref$autoClear = _ref.autoClear,
|
|
45
45
|
autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
|
|
46
|
+
contentRender = _ref.contentRender,
|
|
46
47
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
47
48
|
var currentForm = useCurrentForm(dialogForm);
|
|
48
49
|
var providerConfig = useFormConfigContext();
|
|
@@ -86,6 +87,45 @@ var DrawerForm = (function (_ref) {
|
|
|
86
87
|
confirmLoading: loading
|
|
87
88
|
});
|
|
88
89
|
};
|
|
90
|
+
var node = jsx(HForm, _objectSpread(_objectSpread({
|
|
91
|
+
configData: modalFormData,
|
|
92
|
+
initialValues: initValue,
|
|
93
|
+
onValuesChange: onValuesChange
|
|
94
|
+
}, props), {}, {
|
|
95
|
+
form: currentForm,
|
|
96
|
+
params: formParams,
|
|
97
|
+
onFinish: function () {
|
|
98
|
+
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
99
|
+
var result, close;
|
|
100
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
101
|
+
while (1) switch (_context.prev = _context.next) {
|
|
102
|
+
case 0:
|
|
103
|
+
_context.next = 2;
|
|
104
|
+
return run(values, subParams);
|
|
105
|
+
case 2:
|
|
106
|
+
result = _context.sent;
|
|
107
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
108
|
+
if (!(close === false)) {
|
|
109
|
+
_context.next = 6;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return _context.abrupt("return");
|
|
113
|
+
case 6:
|
|
114
|
+
cancel();
|
|
115
|
+
case 7:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee);
|
|
120
|
+
}));
|
|
121
|
+
function onFinish(_x, _x2) {
|
|
122
|
+
return _onFinish.apply(this, arguments);
|
|
123
|
+
}
|
|
124
|
+
return onFinish;
|
|
125
|
+
}(),
|
|
126
|
+
infoRequest: infoRequest,
|
|
127
|
+
labelWidth: labelWidth
|
|
128
|
+
}));
|
|
89
129
|
return jsx(Drawer, _objectSpread(_objectSpread({
|
|
90
130
|
visible: modalVisible,
|
|
91
131
|
title: jsx(Title, {
|
|
@@ -99,45 +139,7 @@ var DrawerForm = (function (_ref) {
|
|
|
99
139
|
destroyOnClose: true,
|
|
100
140
|
footer: footerComponent(),
|
|
101
141
|
children: jsx(Index, _objectSpread(_objectSpread({}, providerConfig), {}, {
|
|
102
|
-
children:
|
|
103
|
-
configData: modalFormData,
|
|
104
|
-
initialValues: initValue,
|
|
105
|
-
onValuesChange: onValuesChange
|
|
106
|
-
}, props), {}, {
|
|
107
|
-
form: currentForm,
|
|
108
|
-
params: formParams,
|
|
109
|
-
onFinish: function () {
|
|
110
|
-
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
111
|
-
var result, close;
|
|
112
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
113
|
-
while (1) switch (_context.prev = _context.next) {
|
|
114
|
-
case 0:
|
|
115
|
-
_context.next = 2;
|
|
116
|
-
return run(values, subParams);
|
|
117
|
-
case 2:
|
|
118
|
-
result = _context.sent;
|
|
119
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
120
|
-
if (!(close === false)) {
|
|
121
|
-
_context.next = 6;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
return _context.abrupt("return");
|
|
125
|
-
case 6:
|
|
126
|
-
cancel();
|
|
127
|
-
case 7:
|
|
128
|
-
case "end":
|
|
129
|
-
return _context.stop();
|
|
130
|
-
}
|
|
131
|
-
}, _callee);
|
|
132
|
-
}));
|
|
133
|
-
function onFinish(_x, _x2) {
|
|
134
|
-
return _onFinish.apply(this, arguments);
|
|
135
|
-
}
|
|
136
|
-
return onFinish;
|
|
137
|
-
}(),
|
|
138
|
-
infoRequest: infoRequest,
|
|
139
|
-
labelWidth: labelWidth
|
|
140
|
-
}))
|
|
142
|
+
children: contentRender ? contentRender(node, currentForm) : node
|
|
141
143
|
}))
|
|
142
144
|
}));
|
|
143
145
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, contentRender, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -16,7 +16,7 @@ import HForm from '../Form/index.js';
|
|
|
16
16
|
import Index, { useFormConfigContext } from '../Form/Context/FormConfigProvider.js';
|
|
17
17
|
import { useCurrentForm, useModifyProps, useSub } from './hooks.js';
|
|
18
18
|
|
|
19
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear"];
|
|
19
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear", "contentRender"];
|
|
20
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
21
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
22
|
var ModalForm = (function (_ref) {
|
|
@@ -35,6 +35,7 @@ var ModalForm = (function (_ref) {
|
|
|
35
35
|
onValuesChange = _ref.onValuesChange,
|
|
36
36
|
_ref$autoClear = _ref.autoClear,
|
|
37
37
|
autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
|
|
38
|
+
contentRender = _ref.contentRender,
|
|
38
39
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
40
|
var currentForm = useCurrentForm(dialogForm);
|
|
40
41
|
var providerConfig = useFormConfigContext();
|
|
@@ -65,6 +66,44 @@ var ModalForm = (function (_ref) {
|
|
|
65
66
|
}),
|
|
66
67
|
loading = _useSub.loading,
|
|
67
68
|
run = _useSub.run;
|
|
69
|
+
var node = jsx(HForm, _objectSpread(_objectSpread({
|
|
70
|
+
configData: modalFormData,
|
|
71
|
+
initialValues: initValue,
|
|
72
|
+
onValuesChange: onValuesChange,
|
|
73
|
+
onFinish: function () {
|
|
74
|
+
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
75
|
+
var result, close;
|
|
76
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
_context.next = 2;
|
|
80
|
+
return run(values, outParams);
|
|
81
|
+
case 2:
|
|
82
|
+
result = _context.sent;
|
|
83
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
84
|
+
if (!(close === false)) {
|
|
85
|
+
_context.next = 6;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
return _context.abrupt("return");
|
|
89
|
+
case 6:
|
|
90
|
+
cancel();
|
|
91
|
+
case 7:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _callee);
|
|
96
|
+
}));
|
|
97
|
+
function onFinish(_x, _x2) {
|
|
98
|
+
return _onFinish.apply(this, arguments);
|
|
99
|
+
}
|
|
100
|
+
return onFinish;
|
|
101
|
+
}()
|
|
102
|
+
}, props), {}, {
|
|
103
|
+
params: formParams,
|
|
104
|
+
form: currentForm,
|
|
105
|
+
infoRequest: infoRequest
|
|
106
|
+
}));
|
|
68
107
|
return jsx(Modal, _objectSpread(_objectSpread({
|
|
69
108
|
title: modalTitle,
|
|
70
109
|
visible: modalVisible,
|
|
@@ -80,44 +119,7 @@ var ModalForm = (function (_ref) {
|
|
|
80
119
|
onOk: currentForm.submit,
|
|
81
120
|
destroyOnClose: true,
|
|
82
121
|
children: jsx(Index, _objectSpread(_objectSpread({}, providerConfig), {}, {
|
|
83
|
-
children:
|
|
84
|
-
configData: modalFormData,
|
|
85
|
-
initialValues: initValue,
|
|
86
|
-
onValuesChange: onValuesChange,
|
|
87
|
-
onFinish: function () {
|
|
88
|
-
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
89
|
-
var result, close;
|
|
90
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
91
|
-
while (1) switch (_context.prev = _context.next) {
|
|
92
|
-
case 0:
|
|
93
|
-
_context.next = 2;
|
|
94
|
-
return run(values, outParams);
|
|
95
|
-
case 2:
|
|
96
|
-
result = _context.sent;
|
|
97
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
98
|
-
if (!(close === false)) {
|
|
99
|
-
_context.next = 6;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
return _context.abrupt("return");
|
|
103
|
-
case 6:
|
|
104
|
-
cancel();
|
|
105
|
-
case 7:
|
|
106
|
-
case "end":
|
|
107
|
-
return _context.stop();
|
|
108
|
-
}
|
|
109
|
-
}, _callee);
|
|
110
|
-
}));
|
|
111
|
-
function onFinish(_x, _x2) {
|
|
112
|
-
return _onFinish.apply(this, arguments);
|
|
113
|
-
}
|
|
114
|
-
return onFinish;
|
|
115
|
-
}()
|
|
116
|
-
}, props), {}, {
|
|
117
|
-
params: formParams,
|
|
118
|
-
form: currentForm,
|
|
119
|
-
infoRequest: infoRequest
|
|
120
|
-
}))
|
|
122
|
+
children: contentRender ? contentRender === null || contentRender === void 0 ? void 0 : contentRender(node, currentForm) : node
|
|
121
123
|
}))
|
|
122
124
|
}));
|
|
123
125
|
});
|
package/es/DialogForm/modal.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModalProps } from "antd";
|
|
2
2
|
import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
import React from "react";
|
|
4
5
|
type RootProps = HFormProps & ModalProps;
|
|
5
6
|
export interface ModifyPropsModal<P = any> {
|
|
6
7
|
configData: HItemProps[];
|
|
@@ -32,5 +33,6 @@ export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFi
|
|
|
32
33
|
onOk?: (data: T, params: P) => boolean | void;
|
|
33
34
|
infoRequest?: (params: P) => Promise<T>;
|
|
34
35
|
autoClear?: boolean;
|
|
36
|
+
contentRender?: (dom: React.ReactNode, form: HDialogFormInstance) => React.ReactNode;
|
|
35
37
|
}
|
|
36
38
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "../modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, contentRender, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -21,7 +21,7 @@ var Title = require('./Title.js');
|
|
|
21
21
|
var Footer = require('./Footer.js');
|
|
22
22
|
var FormConfigProvider = require('../../Form/Context/FormConfigProvider.js');
|
|
23
23
|
|
|
24
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear"];
|
|
24
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender"];
|
|
25
25
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
26
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
27
|
var DrawerForm = (function (_ref) {
|
|
@@ -46,6 +46,7 @@ var DrawerForm = (function (_ref) {
|
|
|
46
46
|
onValuesChange = _ref.onValuesChange,
|
|
47
47
|
_ref$autoClear = _ref.autoClear,
|
|
48
48
|
autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
|
|
49
|
+
contentRender = _ref.contentRender,
|
|
49
50
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
51
|
var currentForm = hooks.useCurrentForm(dialogForm);
|
|
51
52
|
var providerConfig = FormConfigProvider.useFormConfigContext();
|
|
@@ -89,6 +90,45 @@ var DrawerForm = (function (_ref) {
|
|
|
89
90
|
confirmLoading: loading
|
|
90
91
|
});
|
|
91
92
|
};
|
|
93
|
+
var node = jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
94
|
+
configData: modalFormData,
|
|
95
|
+
initialValues: initValue,
|
|
96
|
+
onValuesChange: onValuesChange
|
|
97
|
+
}, props), {}, {
|
|
98
|
+
form: currentForm,
|
|
99
|
+
params: formParams,
|
|
100
|
+
onFinish: function () {
|
|
101
|
+
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
102
|
+
var result, close;
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
104
|
+
while (1) switch (_context.prev = _context.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
_context.next = 2;
|
|
107
|
+
return run(values, subParams);
|
|
108
|
+
case 2:
|
|
109
|
+
result = _context.sent;
|
|
110
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
111
|
+
if (!(close === false)) {
|
|
112
|
+
_context.next = 6;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context.abrupt("return");
|
|
116
|
+
case 6:
|
|
117
|
+
cancel();
|
|
118
|
+
case 7:
|
|
119
|
+
case "end":
|
|
120
|
+
return _context.stop();
|
|
121
|
+
}
|
|
122
|
+
}, _callee);
|
|
123
|
+
}));
|
|
124
|
+
function onFinish(_x, _x2) {
|
|
125
|
+
return _onFinish.apply(this, arguments);
|
|
126
|
+
}
|
|
127
|
+
return onFinish;
|
|
128
|
+
}(),
|
|
129
|
+
infoRequest: infoRequest,
|
|
130
|
+
labelWidth: labelWidth
|
|
131
|
+
}));
|
|
92
132
|
return jsxRuntime.jsx(antd.Drawer, _objectSpread(_objectSpread({
|
|
93
133
|
visible: modalVisible,
|
|
94
134
|
title: jsxRuntime.jsx(Title.default, {
|
|
@@ -102,45 +142,7 @@ var DrawerForm = (function (_ref) {
|
|
|
102
142
|
destroyOnClose: true,
|
|
103
143
|
footer: footerComponent(),
|
|
104
144
|
children: jsxRuntime.jsx(FormConfigProvider.default, _objectSpread(_objectSpread({}, providerConfig), {}, {
|
|
105
|
-
children:
|
|
106
|
-
configData: modalFormData,
|
|
107
|
-
initialValues: initValue,
|
|
108
|
-
onValuesChange: onValuesChange
|
|
109
|
-
}, props), {}, {
|
|
110
|
-
form: currentForm,
|
|
111
|
-
params: formParams,
|
|
112
|
-
onFinish: function () {
|
|
113
|
-
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
114
|
-
var result, close;
|
|
115
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
116
|
-
while (1) switch (_context.prev = _context.next) {
|
|
117
|
-
case 0:
|
|
118
|
-
_context.next = 2;
|
|
119
|
-
return run(values, subParams);
|
|
120
|
-
case 2:
|
|
121
|
-
result = _context.sent;
|
|
122
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
123
|
-
if (!(close === false)) {
|
|
124
|
-
_context.next = 6;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
return _context.abrupt("return");
|
|
128
|
-
case 6:
|
|
129
|
-
cancel();
|
|
130
|
-
case 7:
|
|
131
|
-
case "end":
|
|
132
|
-
return _context.stop();
|
|
133
|
-
}
|
|
134
|
-
}, _callee);
|
|
135
|
-
}));
|
|
136
|
-
function onFinish(_x, _x2) {
|
|
137
|
-
return _onFinish.apply(this, arguments);
|
|
138
|
-
}
|
|
139
|
-
return onFinish;
|
|
140
|
-
}(),
|
|
141
|
-
infoRequest: infoRequest,
|
|
142
|
-
labelWidth: labelWidth
|
|
143
|
-
}))
|
|
145
|
+
children: contentRender ? contentRender(node, currentForm) : node
|
|
144
146
|
}))
|
|
145
147
|
}));
|
|
146
148
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, contentRender, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -19,7 +19,7 @@ var index = require('../Form/index.js');
|
|
|
19
19
|
var FormConfigProvider = require('../Form/Context/FormConfigProvider.js');
|
|
20
20
|
var hooks = require('./hooks.js');
|
|
21
21
|
|
|
22
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear"];
|
|
22
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear", "contentRender"];
|
|
23
23
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
var ModalForm = (function (_ref) {
|
|
@@ -38,6 +38,7 @@ var ModalForm = (function (_ref) {
|
|
|
38
38
|
onValuesChange = _ref.onValuesChange,
|
|
39
39
|
_ref$autoClear = _ref.autoClear,
|
|
40
40
|
autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
|
|
41
|
+
contentRender = _ref.contentRender,
|
|
41
42
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
42
43
|
var currentForm = hooks.useCurrentForm(dialogForm);
|
|
43
44
|
var providerConfig = FormConfigProvider.useFormConfigContext();
|
|
@@ -68,6 +69,44 @@ var ModalForm = (function (_ref) {
|
|
|
68
69
|
}),
|
|
69
70
|
loading = _useSub.loading,
|
|
70
71
|
run = _useSub.run;
|
|
72
|
+
var node = jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
73
|
+
configData: modalFormData,
|
|
74
|
+
initialValues: initValue,
|
|
75
|
+
onValuesChange: onValuesChange,
|
|
76
|
+
onFinish: function () {
|
|
77
|
+
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
78
|
+
var result, close;
|
|
79
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
80
|
+
while (1) switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
_context.next = 2;
|
|
83
|
+
return run(values, outParams);
|
|
84
|
+
case 2:
|
|
85
|
+
result = _context.sent;
|
|
86
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
87
|
+
if (!(close === false)) {
|
|
88
|
+
_context.next = 6;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return _context.abrupt("return");
|
|
92
|
+
case 6:
|
|
93
|
+
cancel();
|
|
94
|
+
case 7:
|
|
95
|
+
case "end":
|
|
96
|
+
return _context.stop();
|
|
97
|
+
}
|
|
98
|
+
}, _callee);
|
|
99
|
+
}));
|
|
100
|
+
function onFinish(_x, _x2) {
|
|
101
|
+
return _onFinish.apply(this, arguments);
|
|
102
|
+
}
|
|
103
|
+
return onFinish;
|
|
104
|
+
}()
|
|
105
|
+
}, props), {}, {
|
|
106
|
+
params: formParams,
|
|
107
|
+
form: currentForm,
|
|
108
|
+
infoRequest: infoRequest
|
|
109
|
+
}));
|
|
71
110
|
return jsxRuntime.jsx(antd.Modal, _objectSpread(_objectSpread({
|
|
72
111
|
title: modalTitle,
|
|
73
112
|
visible: modalVisible,
|
|
@@ -83,44 +122,7 @@ var ModalForm = (function (_ref) {
|
|
|
83
122
|
onOk: currentForm.submit,
|
|
84
123
|
destroyOnClose: true,
|
|
85
124
|
children: jsxRuntime.jsx(FormConfigProvider.default, _objectSpread(_objectSpread({}, providerConfig), {}, {
|
|
86
|
-
children:
|
|
87
|
-
configData: modalFormData,
|
|
88
|
-
initialValues: initValue,
|
|
89
|
-
onValuesChange: onValuesChange,
|
|
90
|
-
onFinish: function () {
|
|
91
|
-
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
92
|
-
var result, close;
|
|
93
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
94
|
-
while (1) switch (_context.prev = _context.next) {
|
|
95
|
-
case 0:
|
|
96
|
-
_context.next = 2;
|
|
97
|
-
return run(values, outParams);
|
|
98
|
-
case 2:
|
|
99
|
-
result = _context.sent;
|
|
100
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
101
|
-
if (!(close === false)) {
|
|
102
|
-
_context.next = 6;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
return _context.abrupt("return");
|
|
106
|
-
case 6:
|
|
107
|
-
cancel();
|
|
108
|
-
case 7:
|
|
109
|
-
case "end":
|
|
110
|
-
return _context.stop();
|
|
111
|
-
}
|
|
112
|
-
}, _callee);
|
|
113
|
-
}));
|
|
114
|
-
function onFinish(_x, _x2) {
|
|
115
|
-
return _onFinish.apply(this, arguments);
|
|
116
|
-
}
|
|
117
|
-
return onFinish;
|
|
118
|
-
}()
|
|
119
|
-
}, props), {}, {
|
|
120
|
-
params: formParams,
|
|
121
|
-
form: currentForm,
|
|
122
|
-
infoRequest: infoRequest
|
|
123
|
-
}))
|
|
125
|
+
children: contentRender ? contentRender === null || contentRender === void 0 ? void 0 : contentRender(node, currentForm) : node
|
|
124
126
|
}))
|
|
125
127
|
}));
|
|
126
128
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModalProps } from "antd";
|
|
2
2
|
import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
import React from "react";
|
|
4
5
|
type RootProps = HFormProps & ModalProps;
|
|
5
6
|
export interface ModifyPropsModal<P = any> {
|
|
6
7
|
configData: HItemProps[];
|
|
@@ -32,5 +33,6 @@ export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFi
|
|
|
32
33
|
onOk?: (data: T, params: P) => boolean | void;
|
|
33
34
|
infoRequest?: (params: P) => Promise<T>;
|
|
34
35
|
autoClear?: boolean;
|
|
36
|
+
contentRender?: (dom: React.ReactNode, form: HDialogFormInstance) => React.ReactNode;
|
|
35
37
|
}
|
|
36
38
|
export {};
|
package/package.json
CHANGED
|
@@ -27,6 +27,7 @@ export default ({
|
|
|
27
27
|
params,
|
|
28
28
|
onValuesChange,
|
|
29
29
|
autoClear = true,
|
|
30
|
+
contentRender,
|
|
30
31
|
...props
|
|
31
32
|
}: DialogFormProps) => {
|
|
32
33
|
const currentForm = useCurrentForm(dialogForm);
|
|
@@ -71,6 +72,24 @@ export default ({
|
|
|
71
72
|
)
|
|
72
73
|
);
|
|
73
74
|
};
|
|
75
|
+
const node=<HForm
|
|
76
|
+
configData={modalFormData}
|
|
77
|
+
initialValues={initValue}
|
|
78
|
+
onValuesChange={onValuesChange}
|
|
79
|
+
{...props}
|
|
80
|
+
form={currentForm}
|
|
81
|
+
params={formParams}
|
|
82
|
+
onFinish={async (values, subParams) => {
|
|
83
|
+
const result = await run(values, subParams);
|
|
84
|
+
const close = onOk?.(result, subParams);
|
|
85
|
+
if (close === false) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
cancel();
|
|
89
|
+
}}
|
|
90
|
+
infoRequest={infoRequest}
|
|
91
|
+
labelWidth={labelWidth}
|
|
92
|
+
/>;
|
|
74
93
|
return (
|
|
75
94
|
<Drawer
|
|
76
95
|
visible={modalVisible}
|
|
@@ -82,24 +101,7 @@ export default ({
|
|
|
82
101
|
footer={footerComponent()}
|
|
83
102
|
>
|
|
84
103
|
<FormConfigProvider {...providerConfig}>
|
|
85
|
-
|
|
86
|
-
configData={modalFormData}
|
|
87
|
-
initialValues={initValue}
|
|
88
|
-
onValuesChange={onValuesChange}
|
|
89
|
-
{...props}
|
|
90
|
-
form={currentForm}
|
|
91
|
-
params={formParams}
|
|
92
|
-
onFinish={async (values, subParams) => {
|
|
93
|
-
const result = await run(values, subParams);
|
|
94
|
-
const close = onOk?.(result, subParams);
|
|
95
|
-
if (close === false) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
cancel();
|
|
99
|
-
}}
|
|
100
|
-
infoRequest={infoRequest}
|
|
101
|
-
labelWidth={labelWidth}
|
|
102
|
-
/>
|
|
104
|
+
{contentRender?contentRender(node,currentForm):node}
|
|
103
105
|
</FormConfigProvider>
|
|
104
106
|
</Drawer>
|
|
105
107
|
);
|
|
@@ -20,6 +20,7 @@ export default ({
|
|
|
20
20
|
onOk,
|
|
21
21
|
onValuesChange,
|
|
22
22
|
autoClear = true,
|
|
23
|
+
contentRender,
|
|
23
24
|
...props
|
|
24
25
|
}: DialogFormProps) => {
|
|
25
26
|
const currentForm = useCurrentForm(dialogForm);
|
|
@@ -47,6 +48,23 @@ export default ({
|
|
|
47
48
|
setModalVisible(false);
|
|
48
49
|
};
|
|
49
50
|
const { loading, run } = useSub({ request, onFinish });
|
|
51
|
+
const node=<HForm
|
|
52
|
+
configData={modalFormData}
|
|
53
|
+
initialValues={initValue}
|
|
54
|
+
onValuesChange={onValuesChange}
|
|
55
|
+
onFinish={async (values, outParams) => {
|
|
56
|
+
const result = await run(values, outParams);
|
|
57
|
+
const close = onOk?.(result, outParams);
|
|
58
|
+
if (close === false) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
cancel();
|
|
62
|
+
}}
|
|
63
|
+
{...props}
|
|
64
|
+
params={formParams}
|
|
65
|
+
form={currentForm}
|
|
66
|
+
infoRequest={infoRequest}
|
|
67
|
+
/>;
|
|
50
68
|
return (
|
|
51
69
|
<Modal
|
|
52
70
|
title={modalTitle}
|
|
@@ -64,23 +82,7 @@ export default ({
|
|
|
64
82
|
destroyOnClose={true}
|
|
65
83
|
>
|
|
66
84
|
<FormConfigProvider {...providerConfig}>
|
|
67
|
-
|
|
68
|
-
configData={modalFormData}
|
|
69
|
-
initialValues={initValue}
|
|
70
|
-
onValuesChange={onValuesChange}
|
|
71
|
-
onFinish={async (values, outParams) => {
|
|
72
|
-
const result = await run(values, outParams);
|
|
73
|
-
const close = onOk?.(result, outParams);
|
|
74
|
-
if (close === false) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
cancel();
|
|
78
|
-
}}
|
|
79
|
-
{...props}
|
|
80
|
-
params={formParams}
|
|
81
|
-
form={currentForm}
|
|
82
|
-
infoRequest={infoRequest}
|
|
83
|
-
/>
|
|
85
|
+
{contentRender?contentRender?.(node, currentForm):node}
|
|
84
86
|
</FormConfigProvider>
|
|
85
87
|
</Modal>
|
|
86
88
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModalProps } from "antd";
|
|
2
2
|
import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
import React from "react";
|
|
4
5
|
|
|
5
6
|
type RootProps = HFormProps & ModalProps;
|
|
6
7
|
|
|
@@ -36,4 +37,5 @@ export interface DialogFormProps<P = any, T = any>
|
|
|
36
37
|
onOk?: (data: T, params: P) => boolean | void;
|
|
37
38
|
infoRequest?: (params: P) => Promise<T>;
|
|
38
39
|
autoClear?: boolean;
|
|
40
|
+
contentRender?:(dom:React.ReactNode,form:HDialogFormInstance)=>React.ReactNode;
|
|
39
41
|
}
|
|
@@ -176,6 +176,12 @@ export default () => {
|
|
|
176
176
|
configData={data}
|
|
177
177
|
labelWidth={88}
|
|
178
178
|
autoClear={false}
|
|
179
|
+
contentRender={(node,form)=>{
|
|
180
|
+
return <div>
|
|
181
|
+
<div>测试一些</div>
|
|
182
|
+
{node}
|
|
183
|
+
</div>
|
|
184
|
+
}}
|
|
179
185
|
request={(val, params) => {
|
|
180
186
|
console.log(val, params);
|
|
181
187
|
}}
|