@hw-component/form 0.0.6-beta-v8 → 0.0.7-beta-v1
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.js +2 -1
- package/es/DialogForm/ModalForm.js +2 -1
- package/es/DialogForm/hooks.d.ts +1 -1
- package/es/DialogForm/hooks.js +3 -1
- package/es/DialogForm/modal.d.ts +1 -0
- package/es/Form/config.d.ts +8 -1
- package/es/Form/config.js +3 -1
- package/es/Form/hooks/index.d.ts +1 -1
- package/es/Form/hooks/index.js +11 -15
- package/es/Form/modal.d.ts +2 -2
- package/lib/DialogForm/DrawerForm/index.js +2 -1
- package/lib/DialogForm/ModalForm.js +2 -1
- package/lib/DialogForm/hooks.d.ts +1 -1
- package/lib/DialogForm/hooks.js +3 -1
- package/lib/DialogForm/modal.d.ts +1 -0
- package/lib/Form/config.d.ts +8 -1
- package/lib/Form/config.js +3 -1
- package/lib/Form/hooks/index.d.ts +1 -1
- package/lib/Form/hooks/index.js +11 -15
- package/lib/Form/modal.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +23 -20
- package/src/components/DialogForm/ModalForm.tsx +20 -17
- package/src/components/DialogForm/hooks.ts +2 -0
- package/src/components/DialogForm/modal.ts +1 -0
- package/src/components/Form/config.ts +2 -1
- package/src/components/Form/hooks/index.ts +5 -7
- package/src/components/Form/modal.ts +4 -3
- package/src/pages/ModalForm/index.tsx +22 -18
|
@@ -50,7 +50,8 @@ var DrawerForm = (function (_ref) {
|
|
|
50
50
|
initialValues: initialValues,
|
|
51
51
|
dialogForm: currentForm,
|
|
52
52
|
params: params,
|
|
53
|
-
title: title
|
|
53
|
+
title: title,
|
|
54
|
+
onCancel: onCancel
|
|
54
55
|
}),
|
|
55
56
|
modalVisible = _useModifyProps.modalVisible,
|
|
56
57
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -42,7 +42,8 @@ var ModalForm = (function (_ref) {
|
|
|
42
42
|
initialValues: initialValues,
|
|
43
43
|
dialogForm: currentForm,
|
|
44
44
|
params: params,
|
|
45
|
-
title: title
|
|
45
|
+
title: title,
|
|
46
|
+
onCancel: onCancel
|
|
46
47
|
}),
|
|
47
48
|
modalVisible = _useModifyProps.modalVisible,
|
|
48
49
|
modalFormData = _useModifyProps.modalFormData,
|
package/es/DialogForm/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
|
|
3
|
-
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, }: ModifyPropsModal) => {
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, }: ModifyPropsModal) => {
|
|
4
4
|
modalFormData: import("../Form/modal").HItemProps[];
|
|
5
5
|
modalVisible: boolean | undefined;
|
|
6
6
|
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
package/es/DialogForm/hooks.js
CHANGED
|
@@ -23,7 +23,8 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
23
23
|
dialogForm = _ref.dialogForm,
|
|
24
24
|
afterClose = _ref.afterClose,
|
|
25
25
|
params = _ref.params,
|
|
26
|
-
title = _ref.title
|
|
26
|
+
title = _ref.title,
|
|
27
|
+
onCancel = _ref.onCancel;
|
|
27
28
|
var _useState = useState(visible),
|
|
28
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
30
|
modalVisible = _useState2[0],
|
|
@@ -45,6 +46,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
45
46
|
modalTitle = _useState10[0],
|
|
46
47
|
setModalTitle = _useState10[1];
|
|
47
48
|
var onAfterClose = function onAfterClose() {
|
|
49
|
+
onCancel === null || onCancel === void 0 || onCancel();
|
|
48
50
|
setTimeout(function () {
|
|
49
51
|
dialogForm.clear();
|
|
50
52
|
afterClose === null || afterClose === void 0 || afterClose();
|
package/es/DialogForm/modal.d.ts
CHANGED
package/es/Form/config.d.ts
CHANGED
|
@@ -24,6 +24,13 @@ declare const componentConfig: {
|
|
|
24
24
|
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
25
|
submit: ({ text, type, form, loading, position, reset, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
26
|
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
27
|
-
colorInput: ({ value, onChange, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
27
|
+
colorInput: ({ value, onChange, defaultColor, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
28
|
+
cascader: (<OptionType extends import("rc-cascader").DefaultOptionType | import("rc-cascader").BaseOptionType = import("rc-cascader").DefaultOptionType>(props: import("react").PropsWithChildren<import("antd").CascaderProps<OptionType>> & {
|
|
29
|
+
ref?: import("react").Ref<import("antd/lib/cascader").CascaderRef> | undefined;
|
|
30
|
+
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) & {
|
|
31
|
+
displayName: string;
|
|
32
|
+
SHOW_PARENT: "SHOW_PARENT";
|
|
33
|
+
SHOW_CHILD: "SHOW_CHILD";
|
|
34
|
+
};
|
|
28
35
|
};
|
|
29
36
|
export default componentConfig;
|
package/es/Form/config.js
CHANGED
|
@@ -16,6 +16,7 @@ import Index$4 from '../Upload/UrlUpload/index.js';
|
|
|
16
16
|
import HSubmit from '../Submit/index.js';
|
|
17
17
|
import TextArea from '../TextArea/index.js';
|
|
18
18
|
import ColorInput from '../Input/ColorInput/index.js';
|
|
19
|
+
import { Cascader } from 'antd';
|
|
19
20
|
|
|
20
21
|
var placeholderConfig = {
|
|
21
22
|
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
@@ -38,7 +39,8 @@ var componentConfig = {
|
|
|
38
39
|
urlUpload: Index$4,
|
|
39
40
|
submit: HSubmit,
|
|
40
41
|
textArea: TextArea,
|
|
41
|
-
colorInput: ColorInput
|
|
42
|
+
colorInput: ColorInput,
|
|
43
|
+
cascader: Cascader
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
export { componentConfig as default, placeholderConfig };
|
package/es/Form/hooks/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
|
9
9
|
type ParamsModal = Omit<HFormProps, "configData">;
|
|
10
10
|
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
|
|
11
11
|
subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
12
|
-
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<
|
|
12
|
+
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<any, [reqParams?: any]>;
|
|
13
13
|
};
|
|
14
14
|
export declare const useDefaultComponents: () => any;
|
|
15
15
|
export declare const useValuesChange: ({ onValuesChange, dispatch, form, }: UseValuesChangeModal) => (changedValues: any, values: any) => void;
|
package/es/Form/hooks/index.js
CHANGED
|
@@ -63,33 +63,29 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
63
63
|
});
|
|
64
64
|
var infoControl = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
65
65
|
var reqParams,
|
|
66
|
+
result,
|
|
66
67
|
setValue,
|
|
67
68
|
_args2 = arguments;
|
|
68
69
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
69
70
|
while (1) switch (_context2.prev = _context2.next) {
|
|
70
71
|
case 0:
|
|
71
72
|
reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
|
|
72
|
-
setValue = initialValues;
|
|
73
73
|
reqData.params = reqParams;
|
|
74
|
-
if (!(!initialValues && !infoRequest)) {
|
|
75
|
-
_context2.next = 6;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
form === null || form === void 0 || form.setFieldsValue({});
|
|
79
|
-
return _context2.abrupt("return", {});
|
|
80
|
-
case 6:
|
|
81
74
|
if (!infoRequest) {
|
|
82
|
-
_context2.next =
|
|
75
|
+
_context2.next = 8;
|
|
83
76
|
break;
|
|
84
77
|
}
|
|
85
|
-
_context2.next =
|
|
78
|
+
_context2.next = 5;
|
|
86
79
|
return infoRequest(reqParams);
|
|
87
|
-
case
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
case 5:
|
|
81
|
+
result = _context2.sent;
|
|
82
|
+
form === null || form === void 0 || form.setFieldsValue(result);
|
|
83
|
+
return _context2.abrupt("return", result || {});
|
|
84
|
+
case 8:
|
|
85
|
+
setValue = initialValues || {};
|
|
90
86
|
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
91
|
-
return _context2.abrupt("return", setValue
|
|
92
|
-
case
|
|
87
|
+
return _context2.abrupt("return", setValue);
|
|
88
|
+
case 11:
|
|
93
89
|
case "end":
|
|
94
90
|
return _context2.stop();
|
|
95
91
|
}
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormInstance, FormItemProps, FormProps } from "antd";
|
|
1
|
+
import type { CascaderProps, FormInstance, FormItemProps, FormProps } from "antd";
|
|
2
2
|
import type { HCheckboxProps } from "../CheckboxGroup/modal";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import type { HButtonProps, HInputProps, HSelectInputProps } from "../Input/modal";
|
|
@@ -15,7 +15,7 @@ import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRang
|
|
|
15
15
|
import type { ForwardedRef } from "react";
|
|
16
16
|
import type { DataFnProvider } from "../modal";
|
|
17
17
|
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => React.ReactNode;
|
|
18
|
-
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps
|
|
18
|
+
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps | CascaderProps<any>;
|
|
19
19
|
export interface HoverModal {
|
|
20
20
|
text?: string;
|
|
21
21
|
icon?: React.ReactNode;
|
|
@@ -53,7 +53,8 @@ var DrawerForm = (function (_ref) {
|
|
|
53
53
|
initialValues: initialValues,
|
|
54
54
|
dialogForm: currentForm,
|
|
55
55
|
params: params,
|
|
56
|
-
title: title
|
|
56
|
+
title: title,
|
|
57
|
+
onCancel: onCancel
|
|
57
58
|
}),
|
|
58
59
|
modalVisible = _useModifyProps.modalVisible,
|
|
59
60
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -45,7 +45,8 @@ var ModalForm = (function (_ref) {
|
|
|
45
45
|
initialValues: initialValues,
|
|
46
46
|
dialogForm: currentForm,
|
|
47
47
|
params: params,
|
|
48
|
-
title: title
|
|
48
|
+
title: title,
|
|
49
|
+
onCancel: onCancel
|
|
49
50
|
}),
|
|
50
51
|
modalVisible = _useModifyProps.modalVisible,
|
|
51
52
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
|
|
3
|
-
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, }: ModifyPropsModal) => {
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, }: ModifyPropsModal) => {
|
|
4
4
|
modalFormData: import("../Form/modal").HItemProps[];
|
|
5
5
|
modalVisible: boolean | undefined;
|
|
6
6
|
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
package/lib/DialogForm/hooks.js
CHANGED
|
@@ -24,7 +24,8 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
24
24
|
dialogForm = _ref.dialogForm,
|
|
25
25
|
afterClose = _ref.afterClose,
|
|
26
26
|
params = _ref.params,
|
|
27
|
-
title = _ref.title
|
|
27
|
+
title = _ref.title,
|
|
28
|
+
onCancel = _ref.onCancel;
|
|
28
29
|
var _useState = React.useState(visible),
|
|
29
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
31
|
modalVisible = _useState2[0],
|
|
@@ -46,6 +47,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
46
47
|
modalTitle = _useState10[0],
|
|
47
48
|
setModalTitle = _useState10[1];
|
|
48
49
|
var onAfterClose = function onAfterClose() {
|
|
50
|
+
onCancel === null || onCancel === void 0 || onCancel();
|
|
49
51
|
setTimeout(function () {
|
|
50
52
|
dialogForm.clear();
|
|
51
53
|
afterClose === null || afterClose === void 0 || afterClose();
|
package/lib/Form/config.d.ts
CHANGED
|
@@ -24,6 +24,13 @@ declare const componentConfig: {
|
|
|
24
24
|
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
25
|
submit: ({ text, type, form, loading, position, reset, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
26
|
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
27
|
-
colorInput: ({ value, onChange, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
27
|
+
colorInput: ({ value, onChange, defaultColor, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
28
|
+
cascader: (<OptionType extends import("rc-cascader").DefaultOptionType | import("rc-cascader").BaseOptionType = import("rc-cascader").DefaultOptionType>(props: import("react").PropsWithChildren<import("antd").CascaderProps<OptionType>> & {
|
|
29
|
+
ref?: import("react").Ref<import("antd/lib/cascader").CascaderRef> | undefined;
|
|
30
|
+
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) & {
|
|
31
|
+
displayName: string;
|
|
32
|
+
SHOW_PARENT: "SHOW_PARENT";
|
|
33
|
+
SHOW_CHILD: "SHOW_CHILD";
|
|
34
|
+
};
|
|
28
35
|
};
|
|
29
36
|
export default componentConfig;
|
package/lib/Form/config.js
CHANGED
|
@@ -19,6 +19,7 @@ var index$8 = require('../Upload/UrlUpload/index.js');
|
|
|
19
19
|
var index$9 = require('../Submit/index.js');
|
|
20
20
|
var index$a = require('../TextArea/index.js');
|
|
21
21
|
var index$b = require('../Input/ColorInput/index.js');
|
|
22
|
+
var antd = require('antd');
|
|
22
23
|
|
|
23
24
|
var placeholderConfig = {
|
|
24
25
|
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
@@ -41,7 +42,8 @@ var componentConfig = {
|
|
|
41
42
|
urlUpload: index$8.default,
|
|
42
43
|
submit: index$9.default,
|
|
43
44
|
textArea: index$a.default,
|
|
44
|
-
colorInput: index$b.default
|
|
45
|
+
colorInput: index$b.default,
|
|
46
|
+
cascader: antd.Cascader
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
exports.default = componentConfig;
|
|
@@ -9,7 +9,7 @@ export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
|
9
9
|
type ParamsModal = Omit<HFormProps, "configData">;
|
|
10
10
|
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
|
|
11
11
|
subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
12
|
-
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<
|
|
12
|
+
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<any, [reqParams?: any]>;
|
|
13
13
|
};
|
|
14
14
|
export declare const useDefaultComponents: () => any;
|
|
15
15
|
export declare const useValuesChange: ({ onValuesChange, dispatch, form, }: UseValuesChangeModal) => (changedValues: any, values: any) => void;
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -64,33 +64,29 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
64
64
|
});
|
|
65
65
|
var infoControl = ahooks.useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
66
66
|
var reqParams,
|
|
67
|
+
result,
|
|
67
68
|
setValue,
|
|
68
69
|
_args2 = arguments;
|
|
69
70
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
70
71
|
while (1) switch (_context2.prev = _context2.next) {
|
|
71
72
|
case 0:
|
|
72
73
|
reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
|
|
73
|
-
setValue = initialValues;
|
|
74
74
|
reqData.params = reqParams;
|
|
75
|
-
if (!(!initialValues && !infoRequest)) {
|
|
76
|
-
_context2.next = 6;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
form === null || form === void 0 || form.setFieldsValue({});
|
|
80
|
-
return _context2.abrupt("return", {});
|
|
81
|
-
case 6:
|
|
82
75
|
if (!infoRequest) {
|
|
83
|
-
_context2.next =
|
|
76
|
+
_context2.next = 8;
|
|
84
77
|
break;
|
|
85
78
|
}
|
|
86
|
-
_context2.next =
|
|
79
|
+
_context2.next = 5;
|
|
87
80
|
return infoRequest(reqParams);
|
|
88
|
-
case
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
case 5:
|
|
82
|
+
result = _context2.sent;
|
|
83
|
+
form === null || form === void 0 || form.setFieldsValue(result);
|
|
84
|
+
return _context2.abrupt("return", result || {});
|
|
85
|
+
case 8:
|
|
86
|
+
setValue = initialValues || {};
|
|
91
87
|
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
92
|
-
return _context2.abrupt("return", setValue
|
|
93
|
-
case
|
|
88
|
+
return _context2.abrupt("return", setValue);
|
|
89
|
+
case 11:
|
|
94
90
|
case "end":
|
|
95
91
|
return _context2.stop();
|
|
96
92
|
}
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormInstance, FormItemProps, FormProps } from "antd";
|
|
1
|
+
import type { CascaderProps, FormInstance, FormItemProps, FormProps } from "antd";
|
|
2
2
|
import type { HCheckboxProps } from "../CheckboxGroup/modal";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import type { HButtonProps, HInputProps, HSelectInputProps } from "../Input/modal";
|
|
@@ -15,7 +15,7 @@ import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRang
|
|
|
15
15
|
import type { ForwardedRef } from "react";
|
|
16
16
|
import type { DataFnProvider } from "../modal";
|
|
17
17
|
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => React.ReactNode;
|
|
18
|
-
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps
|
|
18
|
+
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps | CascaderProps<any>;
|
|
19
19
|
export interface HoverModal {
|
|
20
20
|
text?: string;
|
|
21
21
|
icon?: React.ReactNode;
|
package/package.json
CHANGED
|
@@ -4,7 +4,9 @@ import { useCurrentForm, useModifyProps, useSub } from "../hooks";
|
|
|
4
4
|
import HForm from "../../Form";
|
|
5
5
|
import Title from "./Title";
|
|
6
6
|
import Footer from "./Footer";
|
|
7
|
-
import FormConfigProvider,{
|
|
7
|
+
import FormConfigProvider, {
|
|
8
|
+
useFormConfigContext,
|
|
9
|
+
} from "../../Form/Context/FormConfigProvider";
|
|
8
10
|
export default ({
|
|
9
11
|
visible,
|
|
10
12
|
title,
|
|
@@ -27,7 +29,7 @@ export default ({
|
|
|
27
29
|
...props
|
|
28
30
|
}: DialogFormProps) => {
|
|
29
31
|
const currentForm = useCurrentForm(dialogForm);
|
|
30
|
-
const providerConfig=useFormConfigContext();
|
|
32
|
+
const providerConfig = useFormConfigContext();
|
|
31
33
|
const {
|
|
32
34
|
modalVisible,
|
|
33
35
|
modalFormData,
|
|
@@ -35,14 +37,15 @@ export default ({
|
|
|
35
37
|
initValue,
|
|
36
38
|
onAfterClose,
|
|
37
39
|
formParams,
|
|
38
|
-
title:modalTitle
|
|
40
|
+
title: modalTitle,
|
|
39
41
|
} = useModifyProps({
|
|
40
42
|
configData,
|
|
41
43
|
visible,
|
|
42
44
|
initialValues,
|
|
43
45
|
dialogForm: currentForm,
|
|
44
46
|
params,
|
|
45
|
-
title
|
|
47
|
+
title,
|
|
48
|
+
onCancel,
|
|
46
49
|
});
|
|
47
50
|
const cancel = () => {
|
|
48
51
|
onAfterClose();
|
|
@@ -78,22 +81,22 @@ export default ({
|
|
|
78
81
|
>
|
|
79
82
|
<FormConfigProvider {...providerConfig}>
|
|
80
83
|
<HForm
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
configData={modalFormData}
|
|
85
|
+
initialValues={initValue}
|
|
86
|
+
onValuesChange={onValuesChange}
|
|
87
|
+
{...props}
|
|
88
|
+
form={currentForm}
|
|
89
|
+
params={formParams}
|
|
90
|
+
onFinish={async (values, subParams) => {
|
|
91
|
+
const result = await run(values, subParams);
|
|
92
|
+
const close = onOk?.(result, subParams);
|
|
93
|
+
if (close === false) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
cancel();
|
|
97
|
+
}}
|
|
98
|
+
infoRequest={infoRequest}
|
|
99
|
+
labelWidth={labelWidth}
|
|
97
100
|
/>
|
|
98
101
|
</FormConfigProvider>
|
|
99
102
|
</Drawer>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Modal } from "antd";
|
|
2
2
|
import type { DialogFormProps } from "./modal";
|
|
3
3
|
import HForm from "../Form";
|
|
4
|
-
import FormConfigProvider, {
|
|
4
|
+
import FormConfigProvider, {
|
|
5
|
+
useFormConfigContext,
|
|
6
|
+
} from "../Form/Context/FormConfigProvider";
|
|
5
7
|
import { useCurrentForm, useModifyProps, useSub } from "./hooks";
|
|
6
8
|
export default ({
|
|
7
9
|
visible,
|
|
@@ -20,7 +22,7 @@ export default ({
|
|
|
20
22
|
...props
|
|
21
23
|
}: DialogFormProps) => {
|
|
22
24
|
const currentForm = useCurrentForm(dialogForm);
|
|
23
|
-
const providerConfig=useFormConfigContext();
|
|
25
|
+
const providerConfig = useFormConfigContext();
|
|
24
26
|
const {
|
|
25
27
|
modalVisible,
|
|
26
28
|
modalFormData,
|
|
@@ -35,6 +37,7 @@ export default ({
|
|
|
35
37
|
dialogForm: currentForm,
|
|
36
38
|
params,
|
|
37
39
|
title,
|
|
40
|
+
onCancel,
|
|
38
41
|
});
|
|
39
42
|
const cancel = () => {
|
|
40
43
|
if (onCancel) {
|
|
@@ -59,21 +62,21 @@ export default ({
|
|
|
59
62
|
>
|
|
60
63
|
<FormConfigProvider {...providerConfig}>
|
|
61
64
|
<HForm
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
configData={modalFormData}
|
|
66
|
+
initialValues={initValue}
|
|
67
|
+
onValuesChange={onValuesChange}
|
|
68
|
+
onFinish={async (values, outParams) => {
|
|
69
|
+
const result = await run(values, outParams);
|
|
70
|
+
const close = onOk?.(result, outParams);
|
|
71
|
+
if (close === false) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
cancel();
|
|
75
|
+
}}
|
|
76
|
+
{...props}
|
|
77
|
+
params={formParams}
|
|
78
|
+
form={currentForm}
|
|
79
|
+
infoRequest={infoRequest}
|
|
77
80
|
/>
|
|
78
81
|
</FormConfigProvider>
|
|
79
82
|
</Modal>
|
|
@@ -15,6 +15,7 @@ export const useModifyProps = ({
|
|
|
15
15
|
afterClose,
|
|
16
16
|
params,
|
|
17
17
|
title,
|
|
18
|
+
onCancel,
|
|
18
19
|
}: ModifyPropsModal) => {
|
|
19
20
|
const [modalVisible, setModalVisible] = useState(visible);
|
|
20
21
|
const [modalFormData, setModalFormData] = useState(configData);
|
|
@@ -22,6 +23,7 @@ export const useModifyProps = ({
|
|
|
22
23
|
const [formParams, setFormParams] = useState(params);
|
|
23
24
|
const [modalTitle, setModalTitle] = useState(title);
|
|
24
25
|
const onAfterClose = () => {
|
|
26
|
+
onCancel?.();
|
|
25
27
|
setTimeout(() => {
|
|
26
28
|
dialogForm.clear();
|
|
27
29
|
afterClose?.();
|
|
@@ -15,7 +15,7 @@ import HUrlUpload from "../Upload/UrlUpload";
|
|
|
15
15
|
import HSubmit from "../Submit";
|
|
16
16
|
import TextArea from "../TextArea";
|
|
17
17
|
import ColorInput from "../Input/ColorInput";
|
|
18
|
-
|
|
18
|
+
import {Cascader} from 'antd';
|
|
19
19
|
export const placeholderConfig = {
|
|
20
20
|
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
21
21
|
selectType: ["select", "datePicker", "timePicker", "colorInput"],
|
|
@@ -38,6 +38,7 @@ const componentConfig = {
|
|
|
38
38
|
submit: HSubmit,
|
|
39
39
|
textArea: TextArea,
|
|
40
40
|
colorInput: ColorInput,
|
|
41
|
+
cascader:Cascader
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
export default componentConfig;
|
|
@@ -44,17 +44,15 @@ export const useInfoReq = ({
|
|
|
44
44
|
{ manual: true }
|
|
45
45
|
);
|
|
46
46
|
const infoControl = useRequest(async (reqParams = reqData.params) => {
|
|
47
|
-
let setValue = initialValues;
|
|
48
47
|
reqData.params = reqParams;
|
|
49
|
-
if (!initialValues && !infoRequest) {
|
|
50
|
-
form?.setFieldsValue({});
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
48
|
if (infoRequest) {
|
|
54
|
-
|
|
49
|
+
const result = await infoRequest(reqParams);
|
|
50
|
+
form?.setFieldsValue(result);
|
|
51
|
+
return result || {};
|
|
55
52
|
}
|
|
53
|
+
const setValue = initialValues || {};
|
|
56
54
|
form?.setFieldsValue(setValue);
|
|
57
|
-
return setValue
|
|
55
|
+
return setValue;
|
|
58
56
|
});
|
|
59
57
|
const { run, mutate } = infoControl;
|
|
60
58
|
useEffect(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormInstance, FormItemProps, FormProps
|
|
1
|
+
import type {CascaderProps, FormInstance, FormItemProps, FormProps} from "antd";
|
|
2
2
|
import type { HCheckboxProps } from "../CheckboxGroup/modal";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import type {
|
|
@@ -46,7 +46,8 @@ type ItemPropsType =
|
|
|
46
46
|
| HRangePickerProps
|
|
47
47
|
| HTimePickerProps
|
|
48
48
|
| TextAreaProps
|
|
49
|
-
| IUpLoadProps
|
|
49
|
+
| IUpLoadProps
|
|
50
|
+
|CascaderProps<any>;
|
|
50
51
|
|
|
51
52
|
export interface HoverModal {
|
|
52
53
|
text?: string;
|
|
@@ -147,7 +148,7 @@ export interface HFormInstance extends FormInstance {
|
|
|
147
148
|
addDispatchListener: AddDispatchListenerFn;
|
|
148
149
|
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
149
150
|
reload: PromiseFnResult;
|
|
150
|
-
clear:VoidFunction;
|
|
151
|
+
clear: VoidFunction;
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
export interface ConnectConfigModal {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
HModalForm,
|
|
4
|
+
useHDialogForm,
|
|
5
|
+
HFormConfigProvider,
|
|
6
|
+
} from "../../components";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { ShowParamsModal } from "@/components/DialogForm/modal";
|
|
5
9
|
const data = [
|
|
6
10
|
{
|
|
7
11
|
label: "输入框",
|
|
@@ -120,8 +124,6 @@ const data = [
|
|
|
120
124
|
let num = 0;
|
|
121
125
|
export default () => {
|
|
122
126
|
const modalForm = useHDialogForm();
|
|
123
|
-
const [testModal,setTestModal]=useState<ShowParamsModal>({});
|
|
124
|
-
const {visible,params}=testModal;
|
|
125
127
|
return (
|
|
126
128
|
<>
|
|
127
129
|
<Button
|
|
@@ -151,21 +153,23 @@ export default () => {
|
|
|
151
153
|
宣誓
|
|
152
154
|
</Button>
|
|
153
155
|
<HFormConfigProvider
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
uploadProps={{
|
|
157
|
+
request: () => {
|
|
158
|
+
console.log("request,request,request,request");
|
|
159
|
+
return Promise.resolve({
|
|
160
|
+
url: "https://gw.alicdn.com/imgextra/i2/O1CN01MYuwJQ1GXVBWryCFJ_!!6000000000632-2-tps-1125-570.png_468x468q75.jpg_.webp",
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
}}
|
|
160
164
|
>
|
|
161
165
|
<HModalForm
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
configData={data}
|
|
167
|
+
labelWidth={88}
|
|
168
|
+
request={(val, params) => {
|
|
169
|
+
console.log(val, params);
|
|
170
|
+
}}
|
|
171
|
+
dialogForm={modalForm}
|
|
172
|
+
title="测试"
|
|
169
173
|
/>
|
|
170
174
|
</HFormConfigProvider>
|
|
171
175
|
</>
|