@hw-component/form 0.0.1-beta-v7 → 0.0.1-beta-v9
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 → DialogForm}/DrawerForm/Footer.d.ts +2 -2
- package/es/DialogForm/DrawerForm/index.d.ts +4 -0
- package/es/{DiaLogForm → DialogForm}/DrawerForm/index.js +4 -4
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/{DiaLogForm → DialogForm}/ModalForm.js +4 -4
- package/es/{DiaLogForm → DialogForm}/hooks.d.ts +5 -6
- package/es/{DiaLogForm → DialogForm}/hooks.js +17 -16
- package/es/{DiaLogForm → DialogForm}/modal.d.ts +7 -8
- package/es/Form/config.d.ts +4 -4
- package/es/index.d.ts +7 -7
- package/es/index.js +3 -3
- package/lib/{DiaLogForm → DialogForm}/DrawerForm/Footer.d.ts +2 -2
- package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
- package/lib/{DiaLogForm → DialogForm}/DrawerForm/index.js +4 -4
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/{DiaLogForm → DialogForm}/ModalForm.js +4 -4
- package/lib/{DiaLogForm → DialogForm}/hooks.d.ts +5 -6
- package/lib/{DiaLogForm → DialogForm}/hooks.js +17 -16
- package/lib/{DiaLogForm → DialogForm}/modal.d.ts +7 -8
- package/lib/Form/config.d.ts +4 -4
- package/lib/index.d.ts +7 -7
- package/lib/index.js +4 -4
- package/package.json +1 -1
- package/src/components/{DiaLogForm → DialogForm}/DrawerForm/Footer.tsx +2 -2
- package/src/components/{DiaLogForm → DialogForm}/DrawerForm/index.tsx +5 -5
- package/src/components/{DiaLogForm → DialogForm}/ModalForm.tsx +5 -5
- package/src/components/{DiaLogForm → DialogForm}/hooks.ts +15 -18
- package/src/components/DialogForm/modal.ts +27 -0
- package/src/components/index.tsx +3 -3
- package/src/pages/DrawerForm/index.tsx +2 -2
- package/src/pages/ModalForm/index.tsx +2 -2
- package/es/DiaLogForm/DrawerForm/index.d.ts +0 -4
- package/es/DiaLogForm/ModalForm.d.ts +0 -4
- package/lib/DiaLogForm/DrawerForm/index.d.ts +0 -4
- package/lib/DiaLogForm/ModalForm.d.ts +0 -4
- package/src/components/DiaLogForm/modal.ts +0 -28
- /package/es/{DiaLogForm → DialogForm}/DrawerForm/Footer.js +0 -0
- /package/es/{DiaLogForm → DialogForm}/DrawerForm/Title.d.ts +0 -0
- /package/es/{DiaLogForm → DialogForm}/DrawerForm/Title.js +0 -0
- /package/lib/{DiaLogForm → DialogForm}/DrawerForm/Footer.js +0 -0
- /package/lib/{DiaLogForm → DialogForm}/DrawerForm/Title.d.ts +0 -0
- /package/lib/{DiaLogForm → DialogForm}/DrawerForm/Title.js +0 -0
- /package/src/components/{DiaLogForm → DialogForm}/DrawerForm/Title.tsx +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<
|
|
2
|
+
import type { DialogFormProps } from "../modal";
|
|
3
|
+
declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<DialogFormProps, "configData">) => JSX.Element;
|
|
4
4
|
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps } from "../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;
|
|
@@ -10,7 +10,7 @@ import HForm from '../../Form/index.js';
|
|
|
10
10
|
import Title from './Title.js';
|
|
11
11
|
import Footer from './Footer.js';
|
|
12
12
|
|
|
13
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "
|
|
13
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer"];
|
|
14
14
|
var DrawerForm = (function (_ref) {
|
|
15
15
|
var visible = _ref.visible,
|
|
16
16
|
title = _ref.title,
|
|
@@ -19,7 +19,7 @@ var DrawerForm = (function (_ref) {
|
|
|
19
19
|
infoRequest = _ref.infoRequest,
|
|
20
20
|
request = _ref.request;
|
|
21
21
|
_ref.afterClose;
|
|
22
|
-
var
|
|
22
|
+
var dialogForm = _ref.dialogForm,
|
|
23
23
|
_ref$closable = _ref.closable,
|
|
24
24
|
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
25
25
|
_ref$initialValues = _ref.initialValues,
|
|
@@ -31,12 +31,12 @@ var DrawerForm = (function (_ref) {
|
|
|
31
31
|
_ref.form;
|
|
32
32
|
var footer = _ref.footer,
|
|
33
33
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
-
var currentForm = useCurrentForm(
|
|
34
|
+
var currentForm = useCurrentForm(dialogForm);
|
|
35
35
|
var _useModifyProps = useModifyProps({
|
|
36
36
|
configData: configData,
|
|
37
37
|
visible: visible,
|
|
38
38
|
initialValues: initialValues,
|
|
39
|
-
|
|
39
|
+
dialogForm: currentForm
|
|
40
40
|
}),
|
|
41
41
|
modalVisible = _useModifyProps.modalVisible,
|
|
42
42
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps } from "./modal";
|
|
3
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: DialogFormProps) => JSX.Element;
|
|
4
|
+
export default _default;
|
|
@@ -8,7 +8,7 @@ import { Modal } from 'antd';
|
|
|
8
8
|
import HForm from '../Form/index.js';
|
|
9
9
|
import { useCurrentForm, useModifyProps, useSub } from './hooks.js';
|
|
10
10
|
|
|
11
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "
|
|
11
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish"];
|
|
12
12
|
var ModalForm = (function (_ref) {
|
|
13
13
|
var visible = _ref.visible,
|
|
14
14
|
title = _ref.title,
|
|
@@ -17,17 +17,17 @@ var ModalForm = (function (_ref) {
|
|
|
17
17
|
infoRequest = _ref.infoRequest,
|
|
18
18
|
request = _ref.request,
|
|
19
19
|
_afterClose = _ref.afterClose,
|
|
20
|
-
|
|
20
|
+
dialogForm = _ref.dialogForm,
|
|
21
21
|
_ref$initialValues = _ref.initialValues,
|
|
22
22
|
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
23
23
|
onFinish = _ref.onFinish,
|
|
24
24
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
-
var currentForm = useCurrentForm(
|
|
25
|
+
var currentForm = useCurrentForm(dialogForm);
|
|
26
26
|
var _useModifyProps = useModifyProps({
|
|
27
27
|
configData: configData,
|
|
28
28
|
visible: visible,
|
|
29
29
|
initialValues: initialValues,
|
|
30
|
-
|
|
30
|
+
dialogForm: currentForm
|
|
31
31
|
}),
|
|
32
32
|
modalVisible = _useModifyProps.modalVisible,
|
|
33
33
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export declare const useModifyProps: ({ visible, configData, initialValues, modalForm, afterClose, }: ModifyPropsModal) => {
|
|
2
|
+
import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, }: ModifyPropsModal) => {
|
|
5
4
|
modalFormData: import("../Form/modal").HItemProps[];
|
|
6
5
|
modalVisible: boolean | undefined;
|
|
7
6
|
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
|
@@ -10,6 +9,6 @@ export declare const useModifyProps: ({ visible, configData, initialValues, moda
|
|
|
10
9
|
setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
|
|
11
10
|
onAfterClose: () => void;
|
|
12
11
|
};
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const useCurrentForm: (
|
|
15
|
-
export declare const useSub: ({ request, onFinish }: Partial<
|
|
12
|
+
export declare const useHDialogForm: () => HDialogFormInstance;
|
|
13
|
+
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance;
|
|
14
|
+
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any]>;
|
|
@@ -22,7 +22,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
22
22
|
var visible = _ref.visible,
|
|
23
23
|
configData = _ref.configData,
|
|
24
24
|
initialValues = _ref.initialValues,
|
|
25
|
-
|
|
25
|
+
dialogForm = _ref.dialogForm,
|
|
26
26
|
afterClose = _ref.afterClose;
|
|
27
27
|
var _useState = useState(visible),
|
|
28
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -38,7 +38,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
38
38
|
setInitValue = _useState6[1];
|
|
39
39
|
var onAfterClose = function onAfterClose() {
|
|
40
40
|
_setTimeout(function () {
|
|
41
|
-
|
|
41
|
+
dialogForm.resetFields();
|
|
42
42
|
afterClose === null || afterClose === void 0 ? void 0 : afterClose();
|
|
43
43
|
}, 0);
|
|
44
44
|
};
|
|
@@ -49,16 +49,17 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
49
49
|
setModalFormData(configData);
|
|
50
50
|
}, [configData]);
|
|
51
51
|
useEffect(function () {
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
|
|
52
|
+
dialogForm.show = function () {
|
|
53
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
54
|
+
var changeConfigData = params.configData,
|
|
55
|
+
changeInitialValues = params.initialValues;
|
|
55
56
|
if (!!changeConfigData) {
|
|
56
57
|
setModalFormData(changeConfigData);
|
|
57
58
|
}
|
|
58
59
|
setInitValue(changeInitialValues);
|
|
59
60
|
setModalVisible(true);
|
|
60
61
|
};
|
|
61
|
-
|
|
62
|
+
dialogForm.hide = function () {
|
|
62
63
|
setModalVisible(false);
|
|
63
64
|
onAfterClose();
|
|
64
65
|
};
|
|
@@ -73,7 +74,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
73
74
|
onAfterClose: onAfterClose
|
|
74
75
|
};
|
|
75
76
|
};
|
|
76
|
-
var
|
|
77
|
+
var useHDialogForm = function useHDialogForm() {
|
|
77
78
|
var hForm = useHForm();
|
|
78
79
|
return useMemo(function () {
|
|
79
80
|
return _objectSpread(_objectSpread({}, hForm), {}, {
|
|
@@ -82,15 +83,15 @@ var useHModalForm = function useHModalForm() {
|
|
|
82
83
|
});
|
|
83
84
|
}, []);
|
|
84
85
|
};
|
|
85
|
-
var useCurrentForm = function useCurrentForm(
|
|
86
|
-
var defaultHModalForm =
|
|
87
|
-
return
|
|
86
|
+
var useCurrentForm = function useCurrentForm(hDialogForm) {
|
|
87
|
+
var defaultHModalForm = useHDialogForm();
|
|
88
|
+
return hDialogForm || defaultHModalForm;
|
|
88
89
|
};
|
|
89
|
-
var useSub = function useSub(
|
|
90
|
-
var request =
|
|
91
|
-
onFinish =
|
|
90
|
+
var useSub = function useSub(_ref2) {
|
|
91
|
+
var request = _ref2.request,
|
|
92
|
+
onFinish = _ref2.onFinish;
|
|
92
93
|
return useRequest( /*#__PURE__*/function () {
|
|
93
|
-
var
|
|
94
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
94
95
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
95
96
|
while (1) switch (_context.prev = _context.next) {
|
|
96
97
|
case 0:
|
|
@@ -112,12 +113,12 @@ var useSub = function useSub(_ref3) {
|
|
|
112
113
|
}, _callee);
|
|
113
114
|
}));
|
|
114
115
|
return function (_x) {
|
|
115
|
-
return
|
|
116
|
+
return _ref3.apply(this, arguments);
|
|
116
117
|
};
|
|
117
118
|
}(), {
|
|
118
119
|
manual: true
|
|
119
120
|
});
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
export { useCurrentForm,
|
|
123
|
+
export { useCurrentForm, useHDialogForm, useModifyProps, useSub };
|
|
123
124
|
// powered by hdj
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { HFormProps } from "@/components/Form/modal";
|
|
2
1
|
import type { ModalProps } from "antd";
|
|
3
|
-
import type { HFormInstance, HItemProps } from "
|
|
4
|
-
import type { PromiseFnResult } from "
|
|
2
|
+
import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
|
|
3
|
+
import type { PromiseFnResult } from "../modal";
|
|
5
4
|
type RootProps = HFormProps & ModalProps;
|
|
6
5
|
export interface ModifyPropsModal {
|
|
7
6
|
configData: HItemProps[];
|
|
8
7
|
visible?: boolean;
|
|
9
8
|
initialValues?: Record<string, any>;
|
|
10
|
-
|
|
9
|
+
dialogForm: HDialogFormInstance;
|
|
11
10
|
afterClose?: VoidFunction;
|
|
12
11
|
}
|
|
13
12
|
export interface ShowParamsModal {
|
|
@@ -15,12 +14,12 @@ export interface ShowParamsModal {
|
|
|
15
14
|
visible?: boolean;
|
|
16
15
|
initialValues?: Record<string, any>;
|
|
17
16
|
}
|
|
18
|
-
export interface
|
|
19
|
-
show: (data
|
|
17
|
+
export interface HDialogFormInstance extends HFormInstance {
|
|
18
|
+
show: (data?: ShowParamsModal) => void;
|
|
20
19
|
hide: VoidFunction;
|
|
21
20
|
}
|
|
22
|
-
export interface
|
|
23
|
-
|
|
21
|
+
export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
|
|
22
|
+
dialogForm?: HDialogFormInstance;
|
|
24
23
|
onFinish?: PromiseFnResult;
|
|
25
24
|
}
|
|
26
25
|
export {};
|
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: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<
|
|
9
|
+
selectInput: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
|
|
11
|
-
checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<
|
|
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: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<
|
|
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("./modal").HFormItemProps & import("react").RefAttributes<
|
|
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/index.d.ts
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
import "./styles/index.less";
|
|
3
3
|
export { default as HForm } from "./Form";
|
|
4
4
|
export { default as useHForm } from "./Form/hooks/useHForm";
|
|
5
|
-
export {
|
|
5
|
+
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
6
|
export declare const HSelect: ({ 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;
|
|
7
7
|
export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
8
|
-
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
9
|
-
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
8
|
+
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
9
|
+
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
11
11
|
export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
|
|
12
12
|
export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
|
|
13
13
|
export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
|
|
14
|
-
export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
14
|
+
export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
15
15
|
export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
|
-
export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
16
|
+
export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
17
17
|
export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
18
18
|
export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
19
19
|
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
20
20
|
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
21
21
|
export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
|
|
22
22
|
export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
23
|
-
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose,
|
|
24
|
-
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose,
|
|
23
|
+
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
|
24
|
+
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
package/es/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import FormConfig from './Form/config.js';
|
|
|
3
3
|
import Index from './PageHandler/index.js';
|
|
4
4
|
export { default as HForm } from './Form/index.js';
|
|
5
5
|
export { default as useHForm } from './Form/hooks/useHForm.js';
|
|
6
|
-
export {
|
|
7
|
-
import ModalForm from './
|
|
8
|
-
import DrawerForm from './
|
|
6
|
+
export { useHDialogForm } from './DialogForm/hooks.js';
|
|
7
|
+
import ModalForm from './DialogForm/ModalForm.js';
|
|
8
|
+
import DrawerForm from './DialogForm/DrawerForm/index.js';
|
|
9
9
|
|
|
10
10
|
var HSelect = FormConfig.select;
|
|
11
11
|
var HInput = FormConfig.input;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<
|
|
2
|
+
import type { DialogFormProps } from "../modal";
|
|
3
|
+
declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<DialogFormProps, "configData">) => JSX.Element;
|
|
4
4
|
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps } from "../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;
|
|
@@ -13,7 +13,7 @@ var index = require('../../Form/index.js');
|
|
|
13
13
|
var Title = require('./Title.js');
|
|
14
14
|
var Footer = require('./Footer.js');
|
|
15
15
|
|
|
16
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "
|
|
16
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer"];
|
|
17
17
|
var DrawerForm = (function (_ref) {
|
|
18
18
|
var visible = _ref.visible,
|
|
19
19
|
title = _ref.title,
|
|
@@ -22,7 +22,7 @@ var DrawerForm = (function (_ref) {
|
|
|
22
22
|
infoRequest = _ref.infoRequest,
|
|
23
23
|
request = _ref.request;
|
|
24
24
|
_ref.afterClose;
|
|
25
|
-
var
|
|
25
|
+
var dialogForm = _ref.dialogForm,
|
|
26
26
|
_ref$closable = _ref.closable,
|
|
27
27
|
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
28
28
|
_ref$initialValues = _ref.initialValues,
|
|
@@ -34,12 +34,12 @@ var DrawerForm = (function (_ref) {
|
|
|
34
34
|
_ref.form;
|
|
35
35
|
var footer = _ref.footer,
|
|
36
36
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
-
var currentForm = hooks.useCurrentForm(
|
|
37
|
+
var currentForm = hooks.useCurrentForm(dialogForm);
|
|
38
38
|
var _useModifyProps = hooks.useModifyProps({
|
|
39
39
|
configData: configData,
|
|
40
40
|
visible: visible,
|
|
41
41
|
initialValues: initialValues,
|
|
42
|
-
|
|
42
|
+
dialogForm: currentForm
|
|
43
43
|
}),
|
|
44
44
|
modalVisible = _useModifyProps.modalVisible,
|
|
45
45
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps } from "./modal";
|
|
3
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: DialogFormProps) => JSX.Element;
|
|
4
|
+
export default _default;
|
|
@@ -11,7 +11,7 @@ var antd = require('antd');
|
|
|
11
11
|
var index = require('../Form/index.js');
|
|
12
12
|
var hooks = require('./hooks.js');
|
|
13
13
|
|
|
14
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "
|
|
14
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish"];
|
|
15
15
|
var ModalForm = (function (_ref) {
|
|
16
16
|
var visible = _ref.visible,
|
|
17
17
|
title = _ref.title,
|
|
@@ -20,17 +20,17 @@ var ModalForm = (function (_ref) {
|
|
|
20
20
|
infoRequest = _ref.infoRequest,
|
|
21
21
|
request = _ref.request,
|
|
22
22
|
_afterClose = _ref.afterClose,
|
|
23
|
-
|
|
23
|
+
dialogForm = _ref.dialogForm,
|
|
24
24
|
_ref$initialValues = _ref.initialValues,
|
|
25
25
|
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
26
26
|
onFinish = _ref.onFinish,
|
|
27
27
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
-
var currentForm = hooks.useCurrentForm(
|
|
28
|
+
var currentForm = hooks.useCurrentForm(dialogForm);
|
|
29
29
|
var _useModifyProps = hooks.useModifyProps({
|
|
30
30
|
configData: configData,
|
|
31
31
|
visible: visible,
|
|
32
32
|
initialValues: initialValues,
|
|
33
|
-
|
|
33
|
+
dialogForm: currentForm
|
|
34
34
|
}),
|
|
35
35
|
modalVisible = _useModifyProps.modalVisible,
|
|
36
36
|
modalFormData = _useModifyProps.modalFormData,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export declare const useModifyProps: ({ visible, configData, initialValues, modalForm, afterClose, }: ModifyPropsModal) => {
|
|
2
|
+
import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, }: ModifyPropsModal) => {
|
|
5
4
|
modalFormData: import("../Form/modal").HItemProps[];
|
|
6
5
|
modalVisible: boolean | undefined;
|
|
7
6
|
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
|
@@ -10,6 +9,6 @@ export declare const useModifyProps: ({ visible, configData, initialValues, moda
|
|
|
10
9
|
setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
|
|
11
10
|
onAfterClose: () => void;
|
|
12
11
|
};
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const useCurrentForm: (
|
|
15
|
-
export declare const useSub: ({ request, onFinish }: Partial<
|
|
12
|
+
export declare const useHDialogForm: () => HDialogFormInstance;
|
|
13
|
+
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance;
|
|
14
|
+
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any]>;
|
|
@@ -23,7 +23,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
23
23
|
var visible = _ref.visible,
|
|
24
24
|
configData = _ref.configData,
|
|
25
25
|
initialValues = _ref.initialValues,
|
|
26
|
-
|
|
26
|
+
dialogForm = _ref.dialogForm,
|
|
27
27
|
afterClose = _ref.afterClose;
|
|
28
28
|
var _useState = React.useState(visible),
|
|
29
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -39,7 +39,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
39
39
|
setInitValue = _useState6[1];
|
|
40
40
|
var onAfterClose = function onAfterClose() {
|
|
41
41
|
_setTimeout(function () {
|
|
42
|
-
|
|
42
|
+
dialogForm.resetFields();
|
|
43
43
|
afterClose === null || afterClose === void 0 ? void 0 : afterClose();
|
|
44
44
|
}, 0);
|
|
45
45
|
};
|
|
@@ -50,16 +50,17 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
50
50
|
setModalFormData(configData);
|
|
51
51
|
}, [configData]);
|
|
52
52
|
React.useEffect(function () {
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
53
|
+
dialogForm.show = function () {
|
|
54
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
55
|
+
var changeConfigData = params.configData,
|
|
56
|
+
changeInitialValues = params.initialValues;
|
|
56
57
|
if (!!changeConfigData) {
|
|
57
58
|
setModalFormData(changeConfigData);
|
|
58
59
|
}
|
|
59
60
|
setInitValue(changeInitialValues);
|
|
60
61
|
setModalVisible(true);
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
+
dialogForm.hide = function () {
|
|
63
64
|
setModalVisible(false);
|
|
64
65
|
onAfterClose();
|
|
65
66
|
};
|
|
@@ -74,7 +75,7 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
74
75
|
onAfterClose: onAfterClose
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
|
-
var
|
|
78
|
+
var useHDialogForm = function useHDialogForm() {
|
|
78
79
|
var hForm = useHForm.default();
|
|
79
80
|
return React.useMemo(function () {
|
|
80
81
|
return _objectSpread(_objectSpread({}, hForm), {}, {
|
|
@@ -83,15 +84,15 @@ var useHModalForm = function useHModalForm() {
|
|
|
83
84
|
});
|
|
84
85
|
}, []);
|
|
85
86
|
};
|
|
86
|
-
var useCurrentForm = function useCurrentForm(
|
|
87
|
-
var defaultHModalForm =
|
|
88
|
-
return
|
|
87
|
+
var useCurrentForm = function useCurrentForm(hDialogForm) {
|
|
88
|
+
var defaultHModalForm = useHDialogForm();
|
|
89
|
+
return hDialogForm || defaultHModalForm;
|
|
89
90
|
};
|
|
90
|
-
var useSub = function useSub(
|
|
91
|
-
var request =
|
|
92
|
-
onFinish =
|
|
91
|
+
var useSub = function useSub(_ref2) {
|
|
92
|
+
var request = _ref2.request,
|
|
93
|
+
onFinish = _ref2.onFinish;
|
|
93
94
|
return ahooks.useRequest( /*#__PURE__*/function () {
|
|
94
|
-
var
|
|
95
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
95
96
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
96
97
|
while (1) switch (_context.prev = _context.next) {
|
|
97
98
|
case 0:
|
|
@@ -113,7 +114,7 @@ var useSub = function useSub(_ref3) {
|
|
|
113
114
|
}, _callee);
|
|
114
115
|
}));
|
|
115
116
|
return function (_x) {
|
|
116
|
-
return
|
|
117
|
+
return _ref3.apply(this, arguments);
|
|
117
118
|
};
|
|
118
119
|
}(), {
|
|
119
120
|
manual: true
|
|
@@ -121,7 +122,7 @@ var useSub = function useSub(_ref3) {
|
|
|
121
122
|
};
|
|
122
123
|
|
|
123
124
|
exports.useCurrentForm = useCurrentForm;
|
|
124
|
-
exports.
|
|
125
|
+
exports.useHDialogForm = useHDialogForm;
|
|
125
126
|
exports.useModifyProps = useModifyProps;
|
|
126
127
|
exports.useSub = useSub;
|
|
127
128
|
// powered by h
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { HFormProps } from "@/components/Form/modal";
|
|
2
1
|
import type { ModalProps } from "antd";
|
|
3
|
-
import type { HFormInstance, HItemProps } from "
|
|
4
|
-
import type { PromiseFnResult } from "
|
|
2
|
+
import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
|
|
3
|
+
import type { PromiseFnResult } from "../modal";
|
|
5
4
|
type RootProps = HFormProps & ModalProps;
|
|
6
5
|
export interface ModifyPropsModal {
|
|
7
6
|
configData: HItemProps[];
|
|
8
7
|
visible?: boolean;
|
|
9
8
|
initialValues?: Record<string, any>;
|
|
10
|
-
|
|
9
|
+
dialogForm: HDialogFormInstance;
|
|
11
10
|
afterClose?: VoidFunction;
|
|
12
11
|
}
|
|
13
12
|
export interface ShowParamsModal {
|
|
@@ -15,12 +14,12 @@ export interface ShowParamsModal {
|
|
|
15
14
|
visible?: boolean;
|
|
16
15
|
initialValues?: Record<string, any>;
|
|
17
16
|
}
|
|
18
|
-
export interface
|
|
19
|
-
show: (data
|
|
17
|
+
export interface HDialogFormInstance extends HFormInstance {
|
|
18
|
+
show: (data?: ShowParamsModal) => void;
|
|
20
19
|
hide: VoidFunction;
|
|
21
20
|
}
|
|
22
|
-
export interface
|
|
23
|
-
|
|
21
|
+
export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
|
|
22
|
+
dialogForm?: HDialogFormInstance;
|
|
24
23
|
onFinish?: PromiseFnResult;
|
|
25
24
|
}
|
|
26
25
|
export {};
|
package/lib/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: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<
|
|
9
|
+
selectInput: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
|
|
11
|
-
checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<
|
|
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: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<
|
|
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("./modal").HFormItemProps & import("react").RefAttributes<
|
|
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/lib/index.d.ts
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
import "./styles/index.less";
|
|
3
3
|
export { default as HForm } from "./Form";
|
|
4
4
|
export { default as useHForm } from "./Form/hooks/useHForm";
|
|
5
|
-
export {
|
|
5
|
+
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
6
|
export declare const HSelect: ({ 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;
|
|
7
7
|
export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
8
|
-
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
9
|
-
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
8
|
+
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
9
|
+
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
11
11
|
export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
|
|
12
12
|
export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
|
|
13
13
|
export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
|
|
14
|
-
export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
14
|
+
export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
15
15
|
export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
|
-
export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<
|
|
16
|
+
export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
17
17
|
export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
18
18
|
export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
19
19
|
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
20
20
|
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
21
21
|
export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
|
|
22
22
|
export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
23
|
-
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose,
|
|
24
|
-
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose,
|
|
23
|
+
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
|
24
|
+
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -4,9 +4,9 @@ var config = require('./Form/config.js');
|
|
|
4
4
|
var index$1 = require('./PageHandler/index.js');
|
|
5
5
|
var index = require('./Form/index.js');
|
|
6
6
|
var useHForm = require('./Form/hooks/useHForm.js');
|
|
7
|
-
var hooks = require('./
|
|
8
|
-
var ModalForm = require('./
|
|
9
|
-
var index$2 = require('./
|
|
7
|
+
var hooks = require('./DialogForm/hooks.js');
|
|
8
|
+
var ModalForm = require('./DialogForm/ModalForm.js');
|
|
9
|
+
var index$2 = require('./DialogForm/DrawerForm/index.js');
|
|
10
10
|
|
|
11
11
|
var HSelect = config.default.select;
|
|
12
12
|
var HInput = config.default.input;
|
|
@@ -30,7 +30,7 @@ var HDrawerForm = index$2.default;
|
|
|
30
30
|
|
|
31
31
|
exports.HForm = index.default;
|
|
32
32
|
exports.useHForm = useHForm.default;
|
|
33
|
-
exports.
|
|
33
|
+
exports.useHDialogForm = hooks.useHDialogForm;
|
|
34
34
|
exports.HButtonInput = HButtonInput;
|
|
35
35
|
exports.HCheckBox = HCheckBox;
|
|
36
36
|
exports.HCheckboxGroup = HCheckboxGroup;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Row, Space, Button } from "antd";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DialogFormProps } from "../modal";
|
|
3
3
|
|
|
4
4
|
export default ({
|
|
5
5
|
onCancel,
|
|
6
6
|
onOk,
|
|
7
7
|
confirmLoading,
|
|
8
|
-
}: Omit<
|
|
8
|
+
}: Omit<DialogFormProps, "configData">) => {
|
|
9
9
|
return (
|
|
10
10
|
<Row justify={"end"}>
|
|
11
11
|
<Space size={"middle"}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Drawer } from "antd";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DialogFormProps } from "../modal";
|
|
3
3
|
import { useCurrentForm, useModifyProps, useSub } from "../hooks";
|
|
4
4
|
import HForm from "../../Form";
|
|
5
5
|
import Title from "./Title";
|
|
@@ -12,7 +12,7 @@ export default ({
|
|
|
12
12
|
infoRequest,
|
|
13
13
|
request,
|
|
14
14
|
afterClose,
|
|
15
|
-
|
|
15
|
+
dialogForm,
|
|
16
16
|
closable = true,
|
|
17
17
|
initialValues = {},
|
|
18
18
|
labelWidth,
|
|
@@ -22,8 +22,8 @@ export default ({
|
|
|
22
22
|
form,
|
|
23
23
|
footer,
|
|
24
24
|
...props
|
|
25
|
-
}:
|
|
26
|
-
const currentForm = useCurrentForm(
|
|
25
|
+
}: DialogFormProps) => {
|
|
26
|
+
const currentForm = useCurrentForm(dialogForm);
|
|
27
27
|
const {
|
|
28
28
|
modalVisible,
|
|
29
29
|
modalFormData,
|
|
@@ -34,7 +34,7 @@ export default ({
|
|
|
34
34
|
configData,
|
|
35
35
|
visible,
|
|
36
36
|
initialValues,
|
|
37
|
-
|
|
37
|
+
dialogForm: currentForm,
|
|
38
38
|
});
|
|
39
39
|
const cancel = (e) => {
|
|
40
40
|
onAfterClose();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Modal } from "antd";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DialogFormProps } from "./modal";
|
|
3
3
|
import HForm from "../Form";
|
|
4
4
|
import { useCurrentForm, useModifyProps, useSub } from "./hooks";
|
|
5
5
|
export default ({
|
|
@@ -10,18 +10,18 @@ export default ({
|
|
|
10
10
|
infoRequest,
|
|
11
11
|
request,
|
|
12
12
|
afterClose,
|
|
13
|
-
|
|
13
|
+
dialogForm,
|
|
14
14
|
initialValues = {},
|
|
15
15
|
onFinish,
|
|
16
16
|
...props
|
|
17
|
-
}:
|
|
18
|
-
const currentForm = useCurrentForm(
|
|
17
|
+
}: DialogFormProps) => {
|
|
18
|
+
const currentForm = useCurrentForm(dialogForm);
|
|
19
19
|
const { modalVisible, modalFormData, setModalVisible, initValue } =
|
|
20
20
|
useModifyProps({
|
|
21
21
|
configData,
|
|
22
22
|
visible,
|
|
23
23
|
initialValues,
|
|
24
|
-
|
|
24
|
+
dialogForm: currentForm,
|
|
25
25
|
});
|
|
26
26
|
const cancel = (e) => {
|
|
27
27
|
if (onCancel) {
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from "react";
|
|
2
2
|
import useHForm from "../Form/hooks/useHForm";
|
|
3
|
-
import type {
|
|
4
|
-
HModalFormInstance,
|
|
5
|
-
ModifyPropsModal,
|
|
6
|
-
} from "@/components/DiaLogForm/modal";
|
|
7
|
-
import type { ModalFormProps } from "@/components/DiaLogForm/modal";
|
|
3
|
+
import type { DialogFormProps,HDialogFormInstance,ModifyPropsModal} from "./modal";
|
|
8
4
|
import { useRequest } from "ahooks";
|
|
9
5
|
|
|
10
6
|
export const useModifyProps = ({
|
|
11
7
|
visible,
|
|
12
8
|
configData,
|
|
13
9
|
initialValues,
|
|
14
|
-
|
|
10
|
+
dialogForm,
|
|
15
11
|
afterClose,
|
|
16
12
|
}: ModifyPropsModal) => {
|
|
17
13
|
const [modalVisible, setModalVisible] = useState(visible);
|
|
@@ -19,7 +15,7 @@ export const useModifyProps = ({
|
|
|
19
15
|
const [initValue, setInitValue] = useState(initialValues);
|
|
20
16
|
const onAfterClose = () => {
|
|
21
17
|
setTimeout(() => {
|
|
22
|
-
|
|
18
|
+
dialogForm.resetFields();
|
|
23
19
|
afterClose?.();
|
|
24
20
|
}, 0);
|
|
25
21
|
};
|
|
@@ -30,17 +26,18 @@ export const useModifyProps = ({
|
|
|
30
26
|
setModalFormData(configData);
|
|
31
27
|
}, [configData]);
|
|
32
28
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
dialogForm.show = (params={}) => {
|
|
30
|
+
const {
|
|
31
|
+
configData: changeConfigData,
|
|
32
|
+
initialValues: changeInitialValues,
|
|
33
|
+
}=params;
|
|
37
34
|
if (!!changeConfigData) {
|
|
38
35
|
setModalFormData(changeConfigData);
|
|
39
36
|
}
|
|
40
37
|
setInitValue(changeInitialValues);
|
|
41
38
|
setModalVisible(true);
|
|
42
39
|
};
|
|
43
|
-
|
|
40
|
+
dialogForm.hide = () => {
|
|
44
41
|
setModalVisible(false);
|
|
45
42
|
onAfterClose();
|
|
46
43
|
};
|
|
@@ -55,9 +52,9 @@ export const useModifyProps = ({
|
|
|
55
52
|
onAfterClose,
|
|
56
53
|
};
|
|
57
54
|
};
|
|
58
|
-
export const
|
|
55
|
+
export const useHDialogForm = () => {
|
|
59
56
|
const hForm = useHForm();
|
|
60
|
-
return useMemo<
|
|
57
|
+
return useMemo<HDialogFormInstance>(() => {
|
|
61
58
|
return {
|
|
62
59
|
...hForm,
|
|
63
60
|
show: (params) => {},
|
|
@@ -66,12 +63,12 @@ export const useHModalForm = () => {
|
|
|
66
63
|
}, []);
|
|
67
64
|
};
|
|
68
65
|
|
|
69
|
-
export const useCurrentForm = (
|
|
70
|
-
const defaultHModalForm =
|
|
71
|
-
return
|
|
66
|
+
export const useCurrentForm = (hDialogForm?: HDialogFormInstance) => {
|
|
67
|
+
const defaultHModalForm = useHDialogForm();
|
|
68
|
+
return hDialogForm || defaultHModalForm;
|
|
72
69
|
};
|
|
73
70
|
|
|
74
|
-
export const useSub = ({ request, onFinish }: Partial<
|
|
71
|
+
export const useSub = ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
75
72
|
return useRequest(
|
|
76
73
|
async (values) => {
|
|
77
74
|
if (onFinish) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ModalProps } from "antd";
|
|
2
|
+
import type { HFormInstance, HItemProps ,HFormProps} from "../Form/modal";
|
|
3
|
+
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
|
|
5
|
+
type RootProps = HFormProps & ModalProps;
|
|
6
|
+
|
|
7
|
+
export interface ModifyPropsModal {
|
|
8
|
+
configData: HItemProps[];
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
initialValues?: Record<string, any>;
|
|
11
|
+
dialogForm: HDialogFormInstance;
|
|
12
|
+
afterClose?: VoidFunction;
|
|
13
|
+
}
|
|
14
|
+
export interface ShowParamsModal {
|
|
15
|
+
configData?: HItemProps[];
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
initialValues?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HDialogFormInstance extends HFormInstance {
|
|
21
|
+
show: (data?: ShowParamsModal) => void;
|
|
22
|
+
hide: VoidFunction;
|
|
23
|
+
}
|
|
24
|
+
export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
|
|
25
|
+
dialogForm?: HDialogFormInstance;
|
|
26
|
+
onFinish?: PromiseFnResult;
|
|
27
|
+
}
|
package/src/components/index.tsx
CHANGED
|
@@ -3,9 +3,9 @@ import FormConfig from "./Form/config";
|
|
|
3
3
|
import PageHandler from "./PageHandler";
|
|
4
4
|
export { default as HForm } from "./Form";
|
|
5
5
|
export { default as useHForm } from "./Form/hooks/useHForm";
|
|
6
|
-
export {
|
|
7
|
-
import ModalForm from "./
|
|
8
|
-
import DrawerForm from "./
|
|
6
|
+
export { useHDialogForm } from "./DialogForm/hooks";
|
|
7
|
+
import ModalForm from "./DialogForm/ModalForm";
|
|
8
|
+
import DrawerForm from "./DialogForm/DrawerForm";
|
|
9
9
|
export const HSelect = FormConfig.select;
|
|
10
10
|
export const HInput = FormConfig.input;
|
|
11
11
|
export const HSelectInput = FormConfig.selectInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import { HDrawerForm,
|
|
2
|
+
import { HDrawerForm, useHDiaLogForm } from "../../components";
|
|
3
3
|
const data = [
|
|
4
4
|
{
|
|
5
5
|
label: "输入框",
|
|
@@ -98,7 +98,7 @@ const data = [
|
|
|
98
98
|
},
|
|
99
99
|
];
|
|
100
100
|
export default () => {
|
|
101
|
-
const modalForm =
|
|
101
|
+
const modalForm = useHDiaLogForm();
|
|
102
102
|
return (
|
|
103
103
|
<>
|
|
104
104
|
<Button
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import { HModalForm,
|
|
2
|
+
import { HModalForm, useHDiaLogForm } from "../../components";
|
|
3
3
|
const data = [
|
|
4
4
|
{
|
|
5
5
|
label: "输入框",
|
|
@@ -98,7 +98,7 @@ const data = [
|
|
|
98
98
|
},
|
|
99
99
|
];
|
|
100
100
|
export default () => {
|
|
101
|
-
const modalForm =
|
|
101
|
+
const modalForm = useHDiaLogForm();
|
|
102
102
|
return (
|
|
103
103
|
<>
|
|
104
104
|
<Button
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ModalFormProps } from "@/components/DiaLogForm/modal";
|
|
3
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: ModalFormProps) => JSX.Element;
|
|
4
|
-
export default _default;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ModalFormProps } from "@/components/DiaLogForm/modal";
|
|
3
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, onFinish, ...props }: ModalFormProps) => JSX.Element;
|
|
4
|
-
export default _default;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ModalFormProps } from "@/components/DiaLogForm/modal";
|
|
3
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: ModalFormProps) => JSX.Element;
|
|
4
|
-
export default _default;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ModalFormProps } from "@/components/DiaLogForm/modal";
|
|
3
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, onFinish, ...props }: ModalFormProps) => JSX.Element;
|
|
4
|
-
export default _default;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { HFormProps } from "@/components/Form/modal";
|
|
2
|
-
import type { ModalProps } from "antd";
|
|
3
|
-
import type { HFormInstance, HItemProps } from "@/components/Form/modal";
|
|
4
|
-
import type { PromiseFnResult } from "@/components/modal";
|
|
5
|
-
|
|
6
|
-
type RootProps = HFormProps & ModalProps;
|
|
7
|
-
|
|
8
|
-
export interface ModifyPropsModal {
|
|
9
|
-
configData: HItemProps[];
|
|
10
|
-
visible?: boolean;
|
|
11
|
-
initialValues?: Record<string, any>;
|
|
12
|
-
modalForm: HModalFormInstance;
|
|
13
|
-
afterClose?: VoidFunction;
|
|
14
|
-
}
|
|
15
|
-
export interface ShowParamsModal {
|
|
16
|
-
configData?: HItemProps[];
|
|
17
|
-
visible?: boolean;
|
|
18
|
-
initialValues?: Record<string, any>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface HModalFormInstance extends HFormInstance {
|
|
22
|
-
show: (data: ShowParamsModal) => void;
|
|
23
|
-
hide: VoidFunction;
|
|
24
|
-
}
|
|
25
|
-
export interface ModalFormProps extends Omit<RootProps, "onFinish"> {
|
|
26
|
-
modalForm?: HModalFormInstance;
|
|
27
|
-
onFinish?: PromiseFnResult;
|
|
28
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|