@hw-component/form 0.0.1-beta-v6 → 0.0.1-beta-v8
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/CheckboxGroup/index.d.ts +1 -1
- package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Footer.js +23 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Title.js +18 -0
- package/es/DialogForm/DrawerForm/index.d.ts +4 -0
- package/es/DialogForm/DrawerForm/index.js +111 -0
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/{ModalForm/index.js → DialogForm/ModalForm.js} +39 -9
- package/es/DialogForm/hooks.d.ts +15 -0
- package/es/{ModalForm → DialogForm}/hooks.js +58 -13
- package/es/{ModalForm → DialogForm}/modal.d.ts +7 -4
- package/es/Form/HFormConnect.d.ts +1 -2
- package/es/Form/HFormConnect.js +8 -15
- package/es/Form/config.d.ts +4 -4
- package/es/Form/config.js +4 -4
- package/es/Form/modal.d.ts +7 -1
- package/es/Input/SelectInput.d.ts +1 -1
- package/es/TDPicker/RangePicker.d.ts +1 -1
- package/es/Upload/UrlUpload/index.d.ts +2 -2
- package/es/Upload/UrlUpload/index.js +3 -3
- package/es/Upload/index.d.ts +1 -2
- package/es/Upload/index.js +39 -5
- package/es/Upload/modal.d.ts +2 -0
- package/es/index.d.ts +7 -6
- package/es/index.js +5 -3
- package/lib/CheckboxGroup/index.d.ts +1 -1
- package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Footer.js +26 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Title.js +21 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/index.js +114 -0
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/{ModalForm/index.js → DialogForm/ModalForm.js} +38 -8
- package/lib/DialogForm/hooks.d.ts +15 -0
- package/lib/{ModalForm → DialogForm}/hooks.js +59 -13
- package/lib/{ModalForm → DialogForm}/modal.d.ts +7 -4
- package/lib/Form/HFormConnect.d.ts +1 -2
- package/lib/Form/HFormConnect.js +8 -15
- package/lib/Form/config.d.ts +4 -4
- package/lib/Form/modal.d.ts +7 -1
- package/lib/Input/SelectInput.d.ts +1 -1
- package/lib/TDPicker/RangePicker.d.ts +1 -1
- package/lib/Upload/UrlUpload/index.d.ts +2 -2
- package/lib/Upload/UrlUpload/index.js +3 -3
- package/lib/Upload/index.d.ts +1 -2
- package/lib/Upload/index.js +39 -5
- package/lib/Upload/modal.d.ts +2 -0
- package/lib/index.d.ts +7 -6
- package/lib/index.js +7 -4
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
- package/src/components/{ModalForm/index.tsx → DialogForm/ModalForm.tsx} +14 -6
- package/src/components/{ModalForm → DialogForm}/hooks.ts +36 -11
- package/src/components/{ModalForm → DialogForm}/modal.ts +7 -4
- package/src/components/Form/HFormConnect.tsx +21 -7
- package/src/components/Form/config.ts +2 -2
- package/src/components/Form/modal.ts +7 -1
- package/src/components/Input/SelectInput.tsx +1 -0
- package/src/components/TDPicker/modal.ts +0 -1
- package/src/components/Upload/UrlUpload/index.tsx +2 -2
- package/src/components/Upload/index.tsx +39 -7
- package/src/components/Upload/modal.ts +2 -0
- package/src/components/index.tsx +5 -4
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +3 -0
- package/src/pages/ModalForm/index.tsx +2 -2
- package/src/routes.tsx +7 -0
- package/es/ModalForm/hooks.d.ts +0 -12
- package/es/ModalForm/index.d.ts +0 -4
- package/lib/ModalForm/hooks.d.ts +0 -12
- package/lib/ModalForm/index.d.ts +0 -4
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare const _default:
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
3
3
|
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Row, Space, Button } from 'antd';
|
|
4
|
+
|
|
5
|
+
var Footer = (function (_ref) {
|
|
6
|
+
var onCancel = _ref.onCancel,
|
|
7
|
+
onOk = _ref.onOk,
|
|
8
|
+
confirmLoading = _ref.confirmLoading;
|
|
9
|
+
return /*#__PURE__*/React.createElement(Row, {
|
|
10
|
+
justify: "end"
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
12
|
+
size: "middle"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
14
|
+
onClick: onCancel
|
|
15
|
+
}, "\u5173\u95ED"), /*#__PURE__*/React.createElement(Button, {
|
|
16
|
+
type: "primary",
|
|
17
|
+
onClick: onOk,
|
|
18
|
+
loading: confirmLoading
|
|
19
|
+
}, "\u786E\u5B9A")));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { Footer as default };
|
|
23
|
+
// powered by hdj
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Row } from 'antd';
|
|
4
|
+
import { CloseOutlined } from '@ant-design/icons';
|
|
5
|
+
|
|
6
|
+
var Title = (function (_ref) {
|
|
7
|
+
var title = _ref.title,
|
|
8
|
+
closable = _ref.closable,
|
|
9
|
+
onCancel = _ref.onCancel;
|
|
10
|
+
return /*#__PURE__*/React.createElement(Row, {
|
|
11
|
+
justify: "space-between"
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", null, title), closable && /*#__PURE__*/React.createElement(CloseOutlined, {
|
|
13
|
+
onClick: onCancel
|
|
14
|
+
}));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { Title as default };
|
|
18
|
+
// powered by hdj
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
3
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: DialogFormProps) => JSX.Element;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
5
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
6
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
7
|
+
import { Drawer } from 'antd';
|
|
8
|
+
import { useCurrentForm, useModifyProps, useSub } from '../hooks.js';
|
|
9
|
+
import HForm from '../../Form/index.js';
|
|
10
|
+
import Title from './Title.js';
|
|
11
|
+
import Footer from './Footer.js';
|
|
12
|
+
|
|
13
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer"];
|
|
14
|
+
var DrawerForm = (function (_ref) {
|
|
15
|
+
var visible = _ref.visible,
|
|
16
|
+
title = _ref.title,
|
|
17
|
+
onCancel = _ref.onCancel,
|
|
18
|
+
configData = _ref.configData,
|
|
19
|
+
infoRequest = _ref.infoRequest,
|
|
20
|
+
request = _ref.request;
|
|
21
|
+
_ref.afterClose;
|
|
22
|
+
var dialogForm = _ref.dialogForm,
|
|
23
|
+
_ref$closable = _ref.closable,
|
|
24
|
+
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
25
|
+
_ref$initialValues = _ref.initialValues,
|
|
26
|
+
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
27
|
+
labelWidth = _ref.labelWidth;
|
|
28
|
+
_ref.onOk;
|
|
29
|
+
var onFinish = _ref.onFinish;
|
|
30
|
+
_ref.size;
|
|
31
|
+
_ref.form;
|
|
32
|
+
var footer = _ref.footer,
|
|
33
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
var currentForm = useCurrentForm(dialogForm);
|
|
35
|
+
var _useModifyProps = useModifyProps({
|
|
36
|
+
configData: configData,
|
|
37
|
+
visible: visible,
|
|
38
|
+
initialValues: initialValues,
|
|
39
|
+
dialogForm: currentForm
|
|
40
|
+
}),
|
|
41
|
+
modalVisible = _useModifyProps.modalVisible,
|
|
42
|
+
modalFormData = _useModifyProps.modalFormData,
|
|
43
|
+
setModalVisible = _useModifyProps.setModalVisible,
|
|
44
|
+
initValue = _useModifyProps.initValue,
|
|
45
|
+
onAfterClose = _useModifyProps.onAfterClose;
|
|
46
|
+
var cancel = function cancel(e) {
|
|
47
|
+
onAfterClose();
|
|
48
|
+
if (onCancel) {
|
|
49
|
+
return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
|
|
50
|
+
}
|
|
51
|
+
setModalVisible(false);
|
|
52
|
+
};
|
|
53
|
+
var _useSub = useSub({
|
|
54
|
+
request: request,
|
|
55
|
+
onFinish: onFinish
|
|
56
|
+
}),
|
|
57
|
+
loading = _useSub.loading,
|
|
58
|
+
run = _useSub.run;
|
|
59
|
+
var footerComponent = function footerComponent() {
|
|
60
|
+
if (footer === null) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return footer || /*#__PURE__*/React.createElement(Footer, {
|
|
64
|
+
onCancel: cancel,
|
|
65
|
+
onOk: currentForm.submit,
|
|
66
|
+
confirmLoading: loading
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/React.createElement(Drawer, _extends({
|
|
70
|
+
visible: modalVisible,
|
|
71
|
+
title: /*#__PURE__*/React.createElement(Title, {
|
|
72
|
+
title: title,
|
|
73
|
+
closable: closable,
|
|
74
|
+
onCancel: cancel
|
|
75
|
+
})
|
|
76
|
+
}, props, {
|
|
77
|
+
onClose: cancel,
|
|
78
|
+
closable: false,
|
|
79
|
+
destroyOnClose: true,
|
|
80
|
+
footer: footerComponent()
|
|
81
|
+
}), /*#__PURE__*/React.createElement(HForm, _extends({
|
|
82
|
+
configData: modalFormData,
|
|
83
|
+
initialValues: initValue
|
|
84
|
+
}, props, {
|
|
85
|
+
form: currentForm,
|
|
86
|
+
onFinish: /*#__PURE__*/function () {
|
|
87
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
88
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
89
|
+
while (1) switch (_context.prev = _context.next) {
|
|
90
|
+
case 0:
|
|
91
|
+
_context.next = 2;
|
|
92
|
+
return run(values);
|
|
93
|
+
case 2:
|
|
94
|
+
setModalVisible(false);
|
|
95
|
+
case 3:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee);
|
|
100
|
+
}));
|
|
101
|
+
return function (_x) {
|
|
102
|
+
return _ref2.apply(this, arguments);
|
|
103
|
+
};
|
|
104
|
+
}(),
|
|
105
|
+
infoRequest: infoRequest,
|
|
106
|
+
labelWidth: labelWidth
|
|
107
|
+
})));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export { DrawerForm as default };
|
|
111
|
+
// powered by hdj
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
3
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: DialogFormProps) => JSX.Element;
|
|
4
|
+
export default _default;
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
4
5
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
6
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
5
7
|
import { Modal } from 'antd';
|
|
6
8
|
import HForm from '../Form/index.js';
|
|
7
|
-
import { useCurrentForm, useModifyProps } from './hooks.js';
|
|
9
|
+
import { useCurrentForm, useModifyProps, useSub } from './hooks.js';
|
|
8
10
|
|
|
9
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "
|
|
11
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish"];
|
|
10
12
|
var ModalForm = (function (_ref) {
|
|
11
13
|
var visible = _ref.visible,
|
|
12
14
|
title = _ref.title,
|
|
13
15
|
onCancel = _ref.onCancel,
|
|
14
16
|
configData = _ref.configData,
|
|
15
|
-
infoRequest = _ref.infoRequest
|
|
16
|
-
_ref.request
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
infoRequest = _ref.infoRequest,
|
|
18
|
+
request = _ref.request,
|
|
19
|
+
_afterClose = _ref.afterClose,
|
|
20
|
+
dialogForm = _ref.dialogForm,
|
|
19
21
|
_ref$initialValues = _ref.initialValues,
|
|
20
22
|
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
23
|
+
onFinish = _ref.onFinish,
|
|
21
24
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
-
var currentForm = useCurrentForm(
|
|
25
|
+
var currentForm = useCurrentForm(dialogForm);
|
|
23
26
|
var _useModifyProps = useModifyProps({
|
|
24
27
|
configData: configData,
|
|
25
28
|
visible: visible,
|
|
26
29
|
initialValues: initialValues,
|
|
27
|
-
|
|
30
|
+
dialogForm: currentForm
|
|
28
31
|
}),
|
|
29
32
|
modalVisible = _useModifyProps.modalVisible,
|
|
30
33
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -36,19 +39,46 @@ var ModalForm = (function (_ref) {
|
|
|
36
39
|
}
|
|
37
40
|
setModalVisible(false);
|
|
38
41
|
};
|
|
42
|
+
var _useSub = useSub({
|
|
43
|
+
request: request,
|
|
44
|
+
onFinish: onFinish
|
|
45
|
+
}),
|
|
46
|
+
loading = _useSub.loading,
|
|
47
|
+
run = _useSub.run;
|
|
39
48
|
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
40
49
|
title: title,
|
|
41
50
|
visible: modalVisible,
|
|
42
51
|
onCancel: cancel,
|
|
52
|
+
confirmLoading: loading,
|
|
43
53
|
afterClose: function afterClose() {
|
|
44
54
|
currentForm.resetFields();
|
|
45
55
|
_afterClose === null || _afterClose === void 0 ? void 0 : _afterClose();
|
|
46
56
|
}
|
|
47
57
|
}, props, {
|
|
58
|
+
onOk: currentForm.submit,
|
|
48
59
|
destroyOnClose: true
|
|
49
60
|
}), /*#__PURE__*/React.createElement(HForm, _extends({
|
|
50
61
|
configData: modalFormData,
|
|
51
|
-
initialValues: initValue
|
|
62
|
+
initialValues: initValue,
|
|
63
|
+
onFinish: /*#__PURE__*/function () {
|
|
64
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
65
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
66
|
+
while (1) switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
_context.next = 2;
|
|
69
|
+
return run(values);
|
|
70
|
+
case 2:
|
|
71
|
+
setModalVisible(false);
|
|
72
|
+
case 3:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
75
|
+
}
|
|
76
|
+
}, _callee);
|
|
77
|
+
}));
|
|
78
|
+
return function (_x) {
|
|
79
|
+
return _ref2.apply(this, arguments);
|
|
80
|
+
};
|
|
81
|
+
}()
|
|
52
82
|
}, props, {
|
|
53
83
|
form: currentForm,
|
|
54
84
|
infoRequest: infoRequest
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { HDialogFormInstance, ModifyPropsModal } from "@/components/DialogForm/modal";
|
|
3
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
4
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, }: ModifyPropsModal) => {
|
|
5
|
+
modalFormData: import("../Form/modal").HItemProps[];
|
|
6
|
+
modalVisible: boolean | undefined;
|
|
7
|
+
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
|
8
|
+
setModalFormData: import("react").Dispatch<import("react").SetStateAction<import("../Form/modal").HItemProps[]>>;
|
|
9
|
+
initValue: Record<string, any> | undefined;
|
|
10
|
+
setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
|
|
11
|
+
onAfterClose: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const useHDialogForm: () => HDialogFormInstance;
|
|
14
|
+
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance;
|
|
15
|
+
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any]>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
4
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
5
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
6
|
+
import _setTimeout from '@babel/runtime-corejs3/core-js/set-timeout';
|
|
2
7
|
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
3
8
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
4
9
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
@@ -7,18 +12,18 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/fo
|
|
|
7
12
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
13
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
14
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
11
|
-
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
12
15
|
import { useMemo, useState, useEffect } from 'react';
|
|
13
16
|
import useHForm from '../Form/hooks/useHForm.js';
|
|
17
|
+
import { useRequest } from 'ahooks';
|
|
14
18
|
|
|
15
19
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
21
|
var useModifyProps = function useModifyProps(_ref) {
|
|
18
22
|
var visible = _ref.visible,
|
|
19
23
|
configData = _ref.configData,
|
|
20
24
|
initialValues = _ref.initialValues,
|
|
21
|
-
|
|
25
|
+
dialogForm = _ref.dialogForm,
|
|
26
|
+
afterClose = _ref.afterClose;
|
|
22
27
|
var _useState = useState(visible),
|
|
23
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
24
29
|
modalVisible = _useState2[0],
|
|
@@ -31,6 +36,12 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
31
36
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
32
37
|
initValue = _useState6[0],
|
|
33
38
|
setInitValue = _useState6[1];
|
|
39
|
+
var onAfterClose = function onAfterClose() {
|
|
40
|
+
_setTimeout(function () {
|
|
41
|
+
dialogForm.resetFields();
|
|
42
|
+
afterClose === null || afterClose === void 0 ? void 0 : afterClose();
|
|
43
|
+
}, 0);
|
|
44
|
+
};
|
|
34
45
|
useEffect(function () {
|
|
35
46
|
setModalVisible(visible);
|
|
36
47
|
}, [visible]);
|
|
@@ -38,7 +49,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
38
49
|
setModalFormData(configData);
|
|
39
50
|
}, [configData]);
|
|
40
51
|
useEffect(function () {
|
|
41
|
-
|
|
52
|
+
dialogForm.show = function (_ref2) {
|
|
42
53
|
var changeConfigData = _ref2.configData,
|
|
43
54
|
changeInitialValues = _ref2.initialValues;
|
|
44
55
|
if (!!changeConfigData) {
|
|
@@ -47,20 +58,22 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
47
58
|
setInitValue(changeInitialValues);
|
|
48
59
|
setModalVisible(true);
|
|
49
60
|
};
|
|
50
|
-
|
|
61
|
+
dialogForm.hide = function () {
|
|
51
62
|
setModalVisible(false);
|
|
63
|
+
onAfterClose();
|
|
52
64
|
};
|
|
53
|
-
}, []);
|
|
65
|
+
}, [afterClose]);
|
|
54
66
|
return {
|
|
55
67
|
modalFormData: modalFormData,
|
|
56
68
|
modalVisible: modalVisible,
|
|
57
69
|
setModalVisible: setModalVisible,
|
|
58
70
|
setModalFormData: setModalFormData,
|
|
59
71
|
initValue: initValue,
|
|
60
|
-
setInitValue: setInitValue
|
|
72
|
+
setInitValue: setInitValue,
|
|
73
|
+
onAfterClose: onAfterClose
|
|
61
74
|
};
|
|
62
75
|
};
|
|
63
|
-
var
|
|
76
|
+
var useHDialogForm = function useHDialogForm() {
|
|
64
77
|
var hForm = useHForm();
|
|
65
78
|
return useMemo(function () {
|
|
66
79
|
return _objectSpread(_objectSpread({}, hForm), {}, {
|
|
@@ -69,10 +82,42 @@ var useHModalForm = function useHModalForm() {
|
|
|
69
82
|
});
|
|
70
83
|
}, []);
|
|
71
84
|
};
|
|
72
|
-
var useCurrentForm = function useCurrentForm(
|
|
73
|
-
var defaultHModalForm =
|
|
74
|
-
return
|
|
85
|
+
var useCurrentForm = function useCurrentForm(hDialogForm) {
|
|
86
|
+
var defaultHModalForm = useHDialogForm();
|
|
87
|
+
return hDialogForm || defaultHModalForm;
|
|
88
|
+
};
|
|
89
|
+
var useSub = function useSub(_ref3) {
|
|
90
|
+
var request = _ref3.request,
|
|
91
|
+
onFinish = _ref3.onFinish;
|
|
92
|
+
return useRequest( /*#__PURE__*/function () {
|
|
93
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
94
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
95
|
+
while (1) switch (_context.prev = _context.next) {
|
|
96
|
+
case 0:
|
|
97
|
+
if (!onFinish) {
|
|
98
|
+
_context.next = 2;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return _context.abrupt("return", onFinish(values));
|
|
102
|
+
case 2:
|
|
103
|
+
if (!request) {
|
|
104
|
+
_context.next = 4;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
return _context.abrupt("return", request(values));
|
|
108
|
+
case 4:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
111
|
+
}
|
|
112
|
+
}, _callee);
|
|
113
|
+
}));
|
|
114
|
+
return function (_x) {
|
|
115
|
+
return _ref4.apply(this, arguments);
|
|
116
|
+
};
|
|
117
|
+
}(), {
|
|
118
|
+
manual: true
|
|
119
|
+
});
|
|
75
120
|
};
|
|
76
121
|
|
|
77
|
-
export { useCurrentForm,
|
|
122
|
+
export { useCurrentForm, useHDialogForm, useModifyProps, useSub };
|
|
78
123
|
// powered by hdj
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import type { HFormProps } from "@/components/Form/modal";
|
|
2
2
|
import type { ModalProps } from "antd";
|
|
3
3
|
import type { HFormInstance, HItemProps } from "@/components/Form/modal";
|
|
4
|
+
import type { PromiseFnResult } from "@/components/modal";
|
|
4
5
|
type RootProps = HFormProps & ModalProps;
|
|
5
6
|
export interface ModifyPropsModal {
|
|
6
7
|
configData: HItemProps[];
|
|
7
8
|
visible?: boolean;
|
|
8
9
|
initialValues?: Record<string, any>;
|
|
9
|
-
|
|
10
|
+
dialogForm: HDialogFormInstance;
|
|
11
|
+
afterClose?: VoidFunction;
|
|
10
12
|
}
|
|
11
13
|
export interface ShowParamsModal {
|
|
12
14
|
configData?: HItemProps[];
|
|
13
15
|
visible?: boolean;
|
|
14
16
|
initialValues?: Record<string, any>;
|
|
15
17
|
}
|
|
16
|
-
export interface
|
|
18
|
+
export interface HDialogFormInstance extends HFormInstance {
|
|
17
19
|
show: (data: ShowParamsModal) => void;
|
|
18
20
|
hide: VoidFunction;
|
|
19
21
|
}
|
|
20
|
-
export interface
|
|
21
|
-
|
|
22
|
+
export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
|
|
23
|
+
dialogForm?: HDialogFormInstance;
|
|
24
|
+
onFinish?: PromiseFnResult;
|
|
22
25
|
}
|
|
23
26
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { HFormItemProps } from "@/components/Form/modal";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { ConnectConfigModal } from "@/components/Form/modal";
|
|
4
|
-
|
|
5
|
-
declare const _default: (Component: React.FunctionComponent | React.ComponentClass, config?: ConnectConfigModal) => (props: HFormItemProps) => React.ReactElement<ConnectResultProps, string | React.JSXElementConstructor<any>>;
|
|
4
|
+
declare const _default: (component: React.FunctionComponent | React.ComponentClass | React.ForwardRefRenderFunction<any, any>, config?: ConnectConfigModal) => React.ForwardRefExoticComponent<HFormItemProps & React.RefAttributes<any>>;
|
|
6
5
|
export default _default;
|
package/es/Form/HFormConnect.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import
|
|
3
|
-
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
4
|
-
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
5
|
-
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
6
|
-
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
|
-
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
|
-
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
11
3
|
import { useFormContext } from './Context/index.js';
|
|
12
4
|
import React, { useEffect } from 'react';
|
|
13
5
|
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
6
|
var formatMaker = function formatMaker(itemProps, formats) {
|
|
17
7
|
if (!formats) {
|
|
18
8
|
return formats;
|
|
@@ -28,11 +18,11 @@ var formatMaker = function formatMaker(itemProps, formats) {
|
|
|
28
18
|
}
|
|
29
19
|
};
|
|
30
20
|
};
|
|
31
|
-
var HFormConnect = (function (
|
|
21
|
+
var HFormConnect = (function (component) {
|
|
32
22
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
23
|
var _config$format = config.format,
|
|
34
24
|
format = _config$format === void 0 ? {} : _config$format;
|
|
35
|
-
|
|
25
|
+
var Index = function Index(props, ref) {
|
|
36
26
|
var _props$name = props.name,
|
|
37
27
|
name = _props$name === void 0 ? "" : _props$name;
|
|
38
28
|
var _useFormContext = useFormContext(),
|
|
@@ -51,11 +41,14 @@ var HFormConnect = (function (Component) {
|
|
|
51
41
|
name: name
|
|
52
42
|
}, fn);
|
|
53
43
|
};
|
|
54
|
-
|
|
44
|
+
var Component = component;
|
|
45
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
55
46
|
addFormat: addFormat,
|
|
56
|
-
addDispatchListener: addDispatchListener
|
|
47
|
+
addDispatchListener: addDispatchListener,
|
|
48
|
+
ref: ref
|
|
57
49
|
}));
|
|
58
50
|
};
|
|
51
|
+
return /*#__PURE__*/React.forwardRef(Index);
|
|
59
52
|
});
|
|
60
53
|
|
|
61
54
|
export { HFormConnect as default };
|
package/es/Form/config.d.ts
CHANGED
|
@@ -6,21 +6,21 @@ export declare const placeholderConfig: {
|
|
|
6
6
|
declare const _default: {
|
|
7
7
|
select: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("../Select/modal").HSelectProps) => JSX.Element;
|
|
8
8
|
inputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
9
|
-
selectInput:
|
|
9
|
+
selectInput: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
|
|
11
|
-
checkboxGroup:
|
|
11
|
+
checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
12
12
|
checkBox: import("react").FC<import("../CheckboxGroup/modal").HCheckboxProps>;
|
|
13
13
|
radioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("../RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
14
14
|
switch: import("react").FC<import("../Switch").HSwitchProps>;
|
|
15
15
|
datePicker: ({ value, onChange, showTime, format, ...props }: import("../TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
16
|
rangePicker: {
|
|
17
|
-
Component:
|
|
17
|
+
Component: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
18
18
|
placeholder: ({ label }: import("./modal").HItemProps) => string[];
|
|
19
19
|
requiredErrMsg: ({ label }: import("./modal").HItemProps) => string;
|
|
20
20
|
};
|
|
21
21
|
timePicker: ({ value, format, onChange, ...props }: import("../TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
22
22
|
input: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
23
|
-
upload: import("react").ForwardRefExoticComponent<import("
|
|
23
|
+
upload: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
24
24
|
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
25
|
submit: ({ text, type, form, loading, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
26
|
formConfigProvider: import("react").FC<import("./modal").IFormConfigContextProps>;
|
package/es/Form/config.js
CHANGED
|
@@ -12,9 +12,9 @@ import HDatePicker from '../TDPicker/index.js';
|
|
|
12
12
|
import HRangePicker from '../TDPicker/RangePicker.js';
|
|
13
13
|
import HTimePicker from '../TDPicker/TimePicker.js';
|
|
14
14
|
import HUpload from '../Upload/index.js';
|
|
15
|
-
import
|
|
15
|
+
import Index$3 from '../Upload/UrlUpload/index.js';
|
|
16
16
|
import HSubmit from '../Submit/index.js';
|
|
17
|
-
import Index$
|
|
17
|
+
import Index$4 from './Context/FormConfigProvider.js';
|
|
18
18
|
import TextArea from '../TextArea/index.js';
|
|
19
19
|
|
|
20
20
|
var placeholderConfig = {
|
|
@@ -35,9 +35,9 @@ var FormConfig = {
|
|
|
35
35
|
timePicker: HTimePicker,
|
|
36
36
|
input: HInput,
|
|
37
37
|
upload: HUpload,
|
|
38
|
-
urlUpload:
|
|
38
|
+
urlUpload: Index$3,
|
|
39
39
|
submit: HSubmit,
|
|
40
|
-
formConfigProvider: Index$
|
|
40
|
+
formConfigProvider: Index$4,
|
|
41
41
|
textArea: TextArea
|
|
42
42
|
};
|
|
43
43
|
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { IUpLoadProps } from "@/components/Upload/modal";
|
|
|
12
12
|
import type { SelectProps } from "antd";
|
|
13
13
|
import type { RangePickerProps } from "antd/es/date-picker";
|
|
14
14
|
import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRangePickerValueMapModal } from "../modal";
|
|
15
|
+
import type { ForwardedRef } from "react";
|
|
15
16
|
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => void;
|
|
16
17
|
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps;
|
|
17
18
|
export interface HoverModal {
|
|
@@ -42,6 +43,8 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
|
|
|
42
43
|
}
|
|
43
44
|
export interface HFormItemProps extends HItemProps {
|
|
44
45
|
required?: boolean;
|
|
46
|
+
value?: any;
|
|
47
|
+
onChange?: (val: any, item: any) => void;
|
|
45
48
|
}
|
|
46
49
|
export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
|
|
47
50
|
render: (form: HFormInstance) => React.ReactNode;
|
|
@@ -91,8 +94,11 @@ export interface addFormatItemModal {
|
|
|
91
94
|
inputValue: addValueFormat;
|
|
92
95
|
outputValue: addValueFormat;
|
|
93
96
|
}
|
|
94
|
-
export interface ConnectResultProps {
|
|
97
|
+
export interface ConnectResultProps extends HFormItemProps {
|
|
95
98
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
96
99
|
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
100
|
+
ref?: ForwardedRef<any>;
|
|
101
|
+
value?: any;
|
|
102
|
+
onChange?: (value: any, item?: any) => void;
|
|
97
103
|
}
|
|
98
104
|
export {};
|
|
@@ -5,5 +5,5 @@ export declare enum SelectInputType {
|
|
|
5
5
|
select = 1
|
|
6
6
|
}
|
|
7
7
|
export declare const Index: ({ selectProps, value, onChange, valueName, addFormat, addDispatchListener, ...props }: HSelectInputProps) => JSX.Element;
|
|
8
|
-
declare const _default:
|
|
8
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("@/components/Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
9
9
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { HItemProps } from "../Form/modal";
|
|
3
3
|
declare const _default: {
|
|
4
|
-
Component:
|
|
4
|
+
Component: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
5
5
|
placeholder: ({ label }: HItemProps) => string[];
|
|
6
6
|
requiredErrMsg: ({ label }: HItemProps) => string;
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IUrlUploadProps } from "../modal";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const Index: ({ placeholder, value, onChange, mediaType, ...props }: IUrlUploadProps) => JSX.Element;
|
|
4
|
+
export default Index;
|
|
@@ -13,7 +13,7 @@ import HUpload from '../index.js';
|
|
|
13
13
|
import TypeEle from '../MediaTypeEle/TypeEle.js';
|
|
14
14
|
|
|
15
15
|
var _excluded = ["placeholder", "value", "onChange", "mediaType"];
|
|
16
|
-
var
|
|
16
|
+
var Index = function Index(_ref) {
|
|
17
17
|
var _ref$placeholder = _ref.placeholder,
|
|
18
18
|
placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
|
|
19
19
|
_ref$value = _ref.value,
|
|
@@ -113,7 +113,7 @@ var HUrlUpload = (function (_ref) {
|
|
|
113
113
|
onReady: onReady,
|
|
114
114
|
onError: onError
|
|
115
115
|
})));
|
|
116
|
-
}
|
|
116
|
+
};
|
|
117
117
|
|
|
118
|
-
export {
|
|
118
|
+
export { Index as default };
|
|
119
119
|
// powered by hdj
|