@hw-component/form 0.0.3-beta-v1 → 0.0.3-beta-v2

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.
Files changed (44) hide show
  1. package/es/DialogForm/DrawerForm/Footer.d.ts +6 -2
  2. package/es/DialogForm/DrawerForm/index.d.ts +1 -1
  3. package/es/DialogForm/DrawerForm/index.js +26 -13
  4. package/es/DialogForm/ModalForm.d.ts +1 -1
  5. package/es/DialogForm/ModalForm.js +24 -10
  6. package/es/DialogForm/hooks.d.ts +5 -4
  7. package/es/DialogForm/hooks.js +23 -10
  8. package/es/DialogForm/modal.d.ts +12 -6
  9. package/es/Form/hooks/index.d.ts +5 -3
  10. package/es/Form/hooks/index.js +65 -8
  11. package/es/Form/hooks/useHForm.js +4 -1
  12. package/es/Form/index.d.ts +1 -1
  13. package/es/Form/index.js +17 -42
  14. package/es/Form/modal.d.ts +6 -3
  15. package/lib/DialogForm/DrawerForm/Footer.d.ts +6 -2
  16. package/lib/DialogForm/DrawerForm/index.d.ts +1 -1
  17. package/lib/DialogForm/DrawerForm/index.js +26 -13
  18. package/lib/DialogForm/ModalForm.d.ts +1 -1
  19. package/lib/DialogForm/ModalForm.js +24 -10
  20. package/lib/DialogForm/hooks.d.ts +5 -4
  21. package/lib/DialogForm/hooks.js +23 -10
  22. package/lib/DialogForm/modal.d.ts +12 -6
  23. package/lib/Form/hooks/index.d.ts +5 -3
  24. package/lib/Form/hooks/index.js +65 -8
  25. package/lib/Form/hooks/useHForm.js +4 -1
  26. package/lib/Form/index.d.ts +1 -1
  27. package/lib/Form/index.js +16 -41
  28. package/lib/Form/modal.d.ts +6 -3
  29. package/package.json +1 -1
  30. package/src/components/DialogForm/DrawerForm/Footer.tsx +7 -2
  31. package/src/components/DialogForm/DrawerForm/index.tsx +13 -5
  32. package/src/components/DialogForm/ModalForm.tsx +14 -6
  33. package/src/components/DialogForm/hooks.ts +19 -6
  34. package/src/components/DialogForm/modal.ts +13 -6
  35. package/src/components/Form/FormItem/UpFormItem.tsx +1 -1
  36. package/src/components/Form/hooks/index.ts +46 -7
  37. package/src/components/Form/hooks/useHForm.ts +6 -3
  38. package/src/components/Form/index.tsx +10 -14
  39. package/src/components/Form/modal.ts +6 -3
  40. package/src/components/Input/ButtonInput.tsx +7 -1
  41. package/src/components/Input/modal.ts +1 -1
  42. package/src/components/Upload/index.tsx +3 -2
  43. package/src/pages/Form/index.tsx +2 -1
  44. package/src/pages/ModalForm/index.tsx +20 -8
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
- import type { DialogFormProps } from "../modal";
3
- declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<DialogFormProps, "configData">) => JSX.Element;
2
+ interface IProps {
3
+ onOk?: VoidFunction;
4
+ onCancel?: VoidFunction;
5
+ confirmLoading?: boolean;
6
+ }
7
+ declare const _default: ({ onCancel, onOk, confirmLoading, }: IProps) => JSX.Element;
4
8
  export default _default;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
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;
3
+ declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, ...props }: DialogFormProps) => JSX.Element;
4
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", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer"];
13
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params"];
14
14
  var DrawerForm = (function (_ref) {
15
15
  var visible = _ref.visible,
16
16
  title = _ref.title,
@@ -24,29 +24,32 @@ var DrawerForm = (function (_ref) {
24
24
  closable = _ref$closable === void 0 ? true : _ref$closable,
25
25
  _ref$initialValues = _ref.initialValues,
26
26
  initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
27
- labelWidth = _ref.labelWidth;
28
- _ref.onOk;
29
- var onFinish = _ref.onFinish;
27
+ labelWidth = _ref.labelWidth,
28
+ onOk = _ref.onOk,
29
+ onFinish = _ref.onFinish;
30
30
  _ref.size;
31
31
  _ref.form;
32
32
  var footer = _ref.footer,
33
+ params = _ref.params,
33
34
  props = _objectWithoutProperties(_ref, _excluded);
34
35
  var currentForm = useCurrentForm(dialogForm);
35
36
  var _useModifyProps = useModifyProps({
36
37
  configData: configData,
37
38
  visible: visible,
38
39
  initialValues: initialValues,
39
- dialogForm: currentForm
40
+ dialogForm: currentForm,
41
+ params: params
40
42
  }),
41
43
  modalVisible = _useModifyProps.modalVisible,
42
44
  modalFormData = _useModifyProps.modalFormData,
43
45
  setModalVisible = _useModifyProps.setModalVisible,
44
46
  initValue = _useModifyProps.initValue,
45
- onAfterClose = _useModifyProps.onAfterClose;
46
- var cancel = function cancel(e) {
47
+ onAfterClose = _useModifyProps.onAfterClose,
48
+ formParams = _useModifyProps.formParams;
49
+ var cancel = function cancel() {
47
50
  onAfterClose();
48
51
  if (onCancel) {
49
- return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
52
+ return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
50
53
  }
51
54
  setModalVisible(false);
52
55
  };
@@ -83,22 +86,32 @@ var DrawerForm = (function (_ref) {
83
86
  initialValues: initValue
84
87
  }, props, {
85
88
  form: currentForm,
89
+ params: formParams,
86
90
  onFinish: /*#__PURE__*/function () {
87
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
91
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
92
+ var result, close;
88
93
  return _regeneratorRuntime.wrap(function _callee$(_context) {
89
94
  while (1) switch (_context.prev = _context.next) {
90
95
  case 0:
91
96
  _context.next = 2;
92
- return run(values);
97
+ return run(values, subParams);
93
98
  case 2:
94
- setModalVisible(false);
95
- case 3:
99
+ result = _context.sent;
100
+ close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
101
+ if (!(close === false)) {
102
+ _context.next = 6;
103
+ break;
104
+ }
105
+ return _context.abrupt("return");
106
+ case 6:
107
+ cancel();
108
+ case 7:
96
109
  case "end":
97
110
  return _context.stop();
98
111
  }
99
112
  }, _callee);
100
113
  }));
101
- return function (_x) {
114
+ return function (_x, _x2) {
102
115
  return _ref2.apply(this, arguments);
103
116
  };
104
117
  }(),
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import type { DialogFormProps } from "./modal";
3
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: DialogFormProps) => JSX.Element;
3
+ declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, ...props }: DialogFormProps) => JSX.Element;
4
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", "dialogForm", "initialValues", "onFinish"];
11
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk"];
12
12
  var ModalForm = (function (_ref) {
13
13
  var visible = _ref.visible,
14
14
  title = _ref.title,
@@ -21,21 +21,25 @@ var ModalForm = (function (_ref) {
21
21
  _ref$initialValues = _ref.initialValues,
22
22
  initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
23
23
  onFinish = _ref.onFinish,
24
+ params = _ref.params,
25
+ onOk = _ref.onOk,
24
26
  props = _objectWithoutProperties(_ref, _excluded);
25
27
  var currentForm = useCurrentForm(dialogForm);
26
28
  var _useModifyProps = useModifyProps({
27
29
  configData: configData,
28
30
  visible: visible,
29
31
  initialValues: initialValues,
30
- dialogForm: currentForm
32
+ dialogForm: currentForm,
33
+ params: params
31
34
  }),
32
35
  modalVisible = _useModifyProps.modalVisible,
33
36
  modalFormData = _useModifyProps.modalFormData,
34
37
  setModalVisible = _useModifyProps.setModalVisible,
35
- initValue = _useModifyProps.initValue;
36
- var cancel = function cancel(e) {
38
+ initValue = _useModifyProps.initValue,
39
+ formParams = _useModifyProps.formParams;
40
+ var cancel = function cancel() {
37
41
  if (onCancel) {
38
- return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
42
+ return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
39
43
  }
40
44
  setModalVisible(false);
41
45
  };
@@ -61,25 +65,35 @@ var ModalForm = (function (_ref) {
61
65
  configData: modalFormData,
62
66
  initialValues: initValue,
63
67
  onFinish: /*#__PURE__*/function () {
64
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
68
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, params) {
69
+ var result, close;
65
70
  return _regeneratorRuntime.wrap(function _callee$(_context) {
66
71
  while (1) switch (_context.prev = _context.next) {
67
72
  case 0:
68
73
  _context.next = 2;
69
- return run(values);
74
+ return run(values, params);
70
75
  case 2:
71
- setModalVisible(false);
72
- case 3:
76
+ result = _context.sent;
77
+ close = onOk === null || onOk === void 0 ? void 0 : onOk(result, params);
78
+ if (!(close === false)) {
79
+ _context.next = 6;
80
+ break;
81
+ }
82
+ return _context.abrupt("return");
83
+ case 6:
84
+ cancel();
85
+ case 7:
73
86
  case "end":
74
87
  return _context.stop();
75
88
  }
76
89
  }, _callee);
77
90
  }));
78
- return function (_x) {
91
+ return function (_x, _x2) {
79
92
  return _ref2.apply(this, arguments);
80
93
  };
81
94
  }()
82
95
  }, props, {
96
+ params: formParams,
83
97
  form: currentForm,
84
98
  infoRequest: infoRequest
85
99
  })));
@@ -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, }: ModifyPropsModal) => {
3
+ export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params }: ModifyPropsModal) => {
4
4
  modalFormData: import("../Form/modal").HItemProps[];
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
@@ -8,7 +8,8 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
8
8
  initValue: Record<string, any> | undefined;
9
9
  setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
10
10
  onAfterClose: () => void;
11
+ formParams: any;
11
12
  };
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]>;
13
+ export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
14
+ export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
15
+ export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any, params: any]>;
@@ -23,7 +23,8 @@ var useModifyProps = function useModifyProps(_ref) {
23
23
  configData = _ref.configData,
24
24
  initialValues = _ref.initialValues,
25
25
  dialogForm = _ref.dialogForm,
26
- afterClose = _ref.afterClose;
26
+ afterClose = _ref.afterClose,
27
+ params = _ref.params;
27
28
  var _useState = useState(visible),
28
29
  _useState2 = _slicedToArray(_useState, 2),
29
30
  modalVisible = _useState2[0],
@@ -36,11 +37,15 @@ var useModifyProps = function useModifyProps(_ref) {
36
37
  _useState6 = _slicedToArray(_useState5, 2),
37
38
  initValue = _useState6[0],
38
39
  setInitValue = _useState6[1];
40
+ var _useState7 = useState(params),
41
+ _useState8 = _slicedToArray(_useState7, 2),
42
+ formParams = _useState8[0],
43
+ setFormParams = _useState8[1];
39
44
  var onAfterClose = function onAfterClose() {
40
45
  _setTimeout(function () {
41
46
  dialogForm.resetFields();
42
47
  afterClose === null || afterClose === void 0 ? void 0 : afterClose();
43
- }, 0);
48
+ }, 100);
44
49
  };
45
50
  useEffect(function () {
46
51
  setModalVisible(visible);
@@ -48,14 +53,21 @@ var useModifyProps = function useModifyProps(_ref) {
48
53
  useEffect(function () {
49
54
  setModalFormData(configData);
50
55
  }, [configData]);
56
+ useEffect(function () {
57
+ setFormParams(params);
58
+ }, [params]);
51
59
  useEffect(function () {
52
60
  dialogForm.show = function () {
53
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
- var changeConfigData = params.configData,
55
- changeInitialValues = params.initialValues;
61
+ var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
+ var changeConfigData = showParams.configData,
63
+ changeInitialValues = showParams.initialValues,
64
+ params = showParams.params;
56
65
  if (!!changeConfigData) {
57
66
  setModalFormData(changeConfigData);
58
67
  }
68
+ if (!!params) {
69
+ setFormParams(params);
70
+ }
59
71
  setInitValue(changeInitialValues);
60
72
  setModalVisible(true);
61
73
  };
@@ -71,7 +83,8 @@ var useModifyProps = function useModifyProps(_ref) {
71
83
  setModalFormData: setModalFormData,
72
84
  initValue: initValue,
73
85
  setInitValue: setInitValue,
74
- onAfterClose: onAfterClose
86
+ onAfterClose: onAfterClose,
87
+ formParams: formParams
75
88
  };
76
89
  };
77
90
  var useHDialogForm = function useHDialogForm() {
@@ -91,7 +104,7 @@ var useSub = function useSub(_ref2) {
91
104
  var request = _ref2.request,
92
105
  onFinish = _ref2.onFinish;
93
106
  return useRequest( /*#__PURE__*/function () {
94
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
107
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, params) {
95
108
  return _regeneratorRuntime.wrap(function _callee$(_context) {
96
109
  while (1) switch (_context.prev = _context.next) {
97
110
  case 0:
@@ -99,20 +112,20 @@ var useSub = function useSub(_ref2) {
99
112
  _context.next = 2;
100
113
  break;
101
114
  }
102
- return _context.abrupt("return", onFinish(values));
115
+ return _context.abrupt("return", onFinish(values, params));
103
116
  case 2:
104
117
  if (!request) {
105
118
  _context.next = 4;
106
119
  break;
107
120
  }
108
- return _context.abrupt("return", request(values));
121
+ return _context.abrupt("return", request(values, params));
109
122
  case 4:
110
123
  case "end":
111
124
  return _context.stop();
112
125
  }
113
126
  }, _callee);
114
127
  }));
115
- return function (_x) {
128
+ return function (_x, _x2) {
116
129
  return _ref3.apply(this, arguments);
117
130
  };
118
131
  }(), {
@@ -2,24 +2,30 @@ import type { ModalProps } from "antd";
2
2
  import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
3
3
  import type { PromiseFnResult } from "../modal";
4
4
  type RootProps = HFormProps & ModalProps;
5
- export interface ModifyPropsModal {
5
+ export interface ModifyPropsModal<P = any> {
6
6
  configData: HItemProps[];
7
7
  visible?: boolean;
8
8
  initialValues?: Record<string, any>;
9
9
  dialogForm: HDialogFormInstance;
10
10
  afterClose?: VoidFunction;
11
+ params?: P;
11
12
  }
12
- export interface ShowParamsModal {
13
+ export interface ShowParamsModal<P = any, T = any> {
13
14
  configData?: HItemProps[];
14
15
  visible?: boolean;
15
16
  initialValues?: Record<string, any>;
17
+ infoRequest?: PromiseFnResult<P, T>;
18
+ params?: P;
16
19
  }
17
- export interface HDialogFormInstance extends HFormInstance {
18
- show: (data?: ShowParamsModal) => void;
20
+ export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
21
+ show: (data?: ShowParamsModal<P, T>) => void;
19
22
  hide: VoidFunction;
20
23
  }
21
- export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
24
+ export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest"> {
22
25
  dialogForm?: HDialogFormInstance;
23
- onFinish?: PromiseFnResult;
26
+ onFinish?: (values: T, params: P) => Promise<any>;
27
+ onCancel?: VoidFunction;
28
+ onOk?: (data: T, params: P) => boolean | undefined;
29
+ infoRequest?: (params: P) => Promise<T>;
24
30
  }
25
31
  export {};
@@ -1,6 +1,8 @@
1
- import type { HFormProps } from "@/components/Form/modal";
2
- import type { HFormInstance } from "@/components/Form/modal";
1
+ import type { HFormProps, HFormInstance } from "../modal";
3
2
  export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
4
3
  type ParamsModal = Omit<HFormProps, "configData">;
5
- export declare const useSub: ({ request, onFinish, form }: ParamsModal) => import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
4
+ export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
5
+ subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
6
+ infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<import("rc-field-form/lib/interface").Store, [reqParams?: any]>;
7
+ };
6
8
  export {};
@@ -3,16 +3,26 @@ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
3
3
  import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
4
4
  import { useRequest } from 'ahooks';
5
5
  import useHForm from './useHForm.js';
6
+ import { useMemo, useEffect } from 'react';
6
7
 
7
8
  var useCurrentForm = function useCurrentForm(form) {
8
9
  var selfForm = useHForm();
9
10
  return form || selfForm;
10
11
  };
11
- var useSub = function useSub(_ref) {
12
- var request = _ref.request,
13
- onFinish = _ref.onFinish,
14
- form = _ref.form;
15
- return useRequest( /*#__PURE__*/function () {
12
+ var useInfoReq = function useInfoReq(_ref) {
13
+ var initialValues = _ref.initialValues,
14
+ infoRequest = _ref.infoRequest,
15
+ form = _ref.form,
16
+ params = _ref.params,
17
+ request = _ref.request,
18
+ onFinish = _ref.onFinish;
19
+ var reqData = useMemo(function () {
20
+ var saveParams = params || {};
21
+ return {
22
+ params: saveParams
23
+ };
24
+ }, [params]);
25
+ var subControl = useRequest( /*#__PURE__*/function () {
16
26
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
17
27
  var subVal;
18
28
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -24,9 +34,9 @@ var useSub = function useSub(_ref) {
24
34
  break;
25
35
  }
26
36
  _context.next = 4;
27
- return request(subVal);
37
+ return request(subVal, reqData.params);
28
38
  case 4:
29
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(subVal);
39
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(subVal, reqData.params);
30
40
  case 5:
31
41
  case "end":
32
42
  return _context.stop();
@@ -39,7 +49,54 @@ var useSub = function useSub(_ref) {
39
49
  }(), {
40
50
  manual: true
41
51
  });
52
+ var infoControl = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
53
+ var reqParams,
54
+ setValue,
55
+ _args2 = arguments;
56
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
57
+ while (1) switch (_context2.prev = _context2.next) {
58
+ case 0:
59
+ reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
60
+ setValue = initialValues;
61
+ reqData.params = reqParams;
62
+ if (!(!initialValues && !infoRequest)) {
63
+ _context2.next = 5;
64
+ break;
65
+ }
66
+ return _context2.abrupt("return", {});
67
+ case 5:
68
+ if (!infoRequest) {
69
+ _context2.next = 9;
70
+ break;
71
+ }
72
+ _context2.next = 8;
73
+ return infoRequest(reqParams);
74
+ case 8:
75
+ setValue = _context2.sent;
76
+ case 9:
77
+ form === null || form === void 0 ? void 0 : form.setFieldsValue(setValue);
78
+ return _context2.abrupt("return", setValue || {});
79
+ case 11:
80
+ case "end":
81
+ return _context2.stop();
82
+ }
83
+ }, _callee2);
84
+ })));
85
+ var run = infoControl.run,
86
+ mutate = infoControl.mutate;
87
+ useEffect(function () {
88
+ if (form) {
89
+ form.reload = function (params) {
90
+ mutate(undefined);
91
+ return run(params);
92
+ };
93
+ }
94
+ }, []);
95
+ return {
96
+ subControl: subControl,
97
+ infoControl: infoControl
98
+ };
42
99
  };
43
100
 
44
- export { useCurrentForm, useSub };
101
+ export { useCurrentForm, useInfoReq };
45
102
  // powered by hdj
@@ -8,12 +8,12 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define
8
8
  import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
10
10
  import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
11
+ import _Promise from '@babel/runtime-corejs3/core-js/promise';
11
12
  import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
12
13
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
13
14
  import _Reflect$deleteProperty from '@babel/runtime-corejs3/core-js/reflect/delete-property';
14
15
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
15
16
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
16
- import _Promise from '@babel/runtime-corejs3/core-js/promise';
17
17
  import { useMemo } from 'react';
18
18
  import { Form } from 'antd';
19
19
 
@@ -41,6 +41,9 @@ var useHForm = (function () {
41
41
  };
42
42
  };
43
43
  return _objectSpread(_objectSpread({
44
+ reload: function reload(params) {
45
+ return _Promise.resolve(params);
46
+ },
44
47
  initValues: function initValues() {
45
48
  if (cacheValues) {
46
49
  var newValue = this.formatValues(cacheValues);
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import type { HFormProps } from "./modal";
3
- declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, ...props }: HFormProps) => JSX.Element;
3
+ declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, ...props }: HFormProps) => JSX.Element;
4
4
  export default _default;
package/es/Form/index.js CHANGED
@@ -1,20 +1,17 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import React, { useEffect } from 'react';
3
3
  import _extends from '@babel/runtime-corejs3/helpers/extends';
4
- import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
5
4
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
6
5
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
7
- import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
8
6
  import { Form } from 'antd';
9
7
  import Item from './FormItem/index.js';
10
- import { useCurrentForm, useSub } from './hooks/index.js';
8
+ import { useCurrentForm, useInfoReq } from './hooks/index.js';
11
9
  import { FormContext } from './Context/index.js';
12
10
  import Index from '../PageHandler/index.js';
13
11
  import useInitConfigData from './hooks/useInitConfigData.js';
14
- import { useRequest } from 'ahooks';
15
12
  import InitSet from './InitSet.js';
16
13
 
17
- var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues"];
14
+ var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params"];
18
15
  var HForm = (function (_ref) {
19
16
  var configData = _ref.configData,
20
17
  labelWidth = _ref.labelWidth,
@@ -25,53 +22,31 @@ var HForm = (function (_ref) {
25
22
  _ref$valueType = _ref.valueType,
26
23
  valueType = _ref$valueType === void 0 ? "float" : _ref$valueType,
27
24
  initialValues = _ref.initialValues,
25
+ _ref$params = _ref.params,
26
+ params = _ref$params === void 0 ? {} : _ref$params,
28
27
  props = _objectWithoutProperties(_ref, _excluded);
29
28
  var hForm = useCurrentForm(form);
30
29
  var newConfigData = useInitConfigData({
31
30
  configData: configData,
32
31
  form: hForm
33
32
  });
34
- var _useSub = useSub({
33
+ var _useInfoReq = useInfoReq({
34
+ initialValues: initialValues,
35
35
  request: request,
36
36
  onFinish: onFinish,
37
37
  valueType: valueType,
38
- form: hForm
38
+ form: hForm,
39
+ infoRequest: infoRequest,
40
+ params: params
39
41
  }),
40
- run = _useSub.run,
41
- loading = _useSub.loading;
42
- var _useRequest = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
43
- var setValue;
44
- return _regeneratorRuntime.wrap(function _callee$(_context) {
45
- while (1) switch (_context.prev = _context.next) {
46
- case 0:
47
- setValue = initialValues;
48
- if (!(!initialValues && !infoRequest)) {
49
- _context.next = 3;
50
- break;
51
- }
52
- return _context.abrupt("return", {});
53
- case 3:
54
- if (!infoRequest) {
55
- _context.next = 7;
56
- break;
57
- }
58
- _context.next = 6;
59
- return infoRequest();
60
- case 6:
61
- setValue = _context.sent;
62
- case 7:
63
- hForm.setFieldsValue(setValue);
64
- return _context.abrupt("return", setValue || {});
65
- case 9:
66
- case "end":
67
- return _context.stop();
68
- }
69
- }, _callee);
70
- }))),
71
- infoRun = _useRequest.run,
72
- infoLoading = _useRequest.loading,
73
- infoErr = _useRequest.error,
74
- infoData = _useRequest.data;
42
+ subControl = _useInfoReq.subControl,
43
+ infoControl = _useInfoReq.infoControl;
44
+ var run = subControl.run,
45
+ loading = subControl.loading;
46
+ var infoRun = infoControl.run,
47
+ infoLoading = infoControl.loading,
48
+ infoErr = infoControl.error,
49
+ infoData = infoControl.data;
75
50
  useEffect(function () {
76
51
  return function () {
77
52
  hForm.removeDispatchListener();
@@ -33,13 +33,15 @@ export interface HItemProps extends Omit<FormItemProps, "name"> {
33
33
  placeholder?: string | string[];
34
34
  name?: string;
35
35
  }
36
- export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
36
+ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "onFinish"> {
37
37
  configData: HItemProps[];
38
38
  labelWidth?: number;
39
- request?: PromiseFnResult<T, R>;
40
- infoRequest?: () => Promise<T>;
39
+ request?: (values: T, params?: any) => Promise<R>;
40
+ infoRequest?: PromiseFnResult;
41
41
  valueType?: string;
42
42
  form?: HFormInstance;
43
+ params?: any;
44
+ onFinish?: (values: T, params?: any) => void;
43
45
  }
44
46
  export interface HFormItemProps extends HItemProps {
45
47
  required?: boolean;
@@ -80,6 +82,7 @@ export interface HFormInstance extends FormInstance {
80
82
  outputValues: (values?: Record<string, any>) => Record<string, any>;
81
83
  addDispatchListener: AddDispatchListenerFn;
82
84
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
85
+ reload: PromiseFnResult;
83
86
  }
84
87
  export interface ConnectConfigModal {
85
88
  format?: Record<string, addFormatItemModal>;
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
- import type { DialogFormProps } from "../modal";
3
- declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<DialogFormProps, "configData">) => JSX.Element;
2
+ interface IProps {
3
+ onOk?: VoidFunction;
4
+ onCancel?: VoidFunction;
5
+ confirmLoading?: boolean;
6
+ }
7
+ declare const _default: ({ onCancel, onOk, confirmLoading, }: IProps) => JSX.Element;
4
8
  export default _default;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
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;
3
+ declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, ...props }: DialogFormProps) => JSX.Element;
4
4
  export default _default;