@hw-component/form 1.9.71 → 1.9.73

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.
@@ -71,15 +71,17 @@ var Index = function Index(_ref) {
71
71
  wrap: wrap,
72
72
  children: checkOptions === null || checkOptions === void 0 ? void 0 : checkOptions.map(function (item) {
73
73
  var label = item.label,
74
- itemVal = item.value;
74
+ itemVal = item.value,
75
+ itemDisabled = item.disabled;
75
76
  var checked = val[itemVal];
77
+ var nDis = typeof itemDisabled === "undefined" ? disabled : itemDisabled;
76
78
  return jsx(Index$1, {
77
79
  value: checked,
78
80
  onChange: function onChange(changeVal) {
79
81
  change(itemVal, changeVal);
80
82
  },
81
83
  valueMap: valueMap,
82
- disabled: disabled,
84
+ disabled: nDis,
83
85
  children: label
84
86
  }, itemVal);
85
87
  })
@@ -1,6 +1,6 @@
1
1
  // welcome to hoo hoo hoo
2
- import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
3
2
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
3
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
4
4
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
5
5
  import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
6
6
  import { jsx } from 'react/jsx-runtime';
@@ -72,48 +72,56 @@ var Index = function Index(_ref) {
72
72
  }),
73
73
  loading = _useSub.loading,
74
74
  run = _useSub.run;
75
+ var finish = /*#__PURE__*/function () {
76
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
77
+ var result, close;
78
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
79
+ while (1) switch (_context.prev = _context.next) {
80
+ case 0:
81
+ _context.next = 2;
82
+ return run(values, subParams);
83
+ case 2:
84
+ result = _context.sent;
85
+ close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
86
+ if (!(close === false)) {
87
+ _context.next = 6;
88
+ break;
89
+ }
90
+ return _context.abrupt("return");
91
+ case 6:
92
+ cancel();
93
+ case 7:
94
+ case "end":
95
+ return _context.stop();
96
+ }
97
+ }, _callee);
98
+ }));
99
+ return function finish(_x, _x2) {
100
+ return _ref2.apply(this, arguments);
101
+ };
102
+ }();
103
+ var footerOnOk = function footerOnOk() {
104
+ if (modalFormData) {
105
+ dialogForm === null || dialogForm === void 0 || dialogForm.submit();
106
+ return;
107
+ }
108
+ finish({}, formParams);
109
+ };
75
110
  var defaultFooter = useFooterRender({
76
111
  dialogForm: dialogForm,
77
112
  footer: footer,
78
113
  confirmLoading: loading,
79
- params: formParams
114
+ params: formParams,
115
+ onOk: footerOnOk
80
116
  });
81
- var node = jsx(HForm, _objectSpread(_objectSpread({
117
+ var node = modalFormData && jsx(HForm, _objectSpread(_objectSpread({
82
118
  configData: modalFormData,
83
119
  initialValues: initValue,
84
120
  onValuesChange: onValuesChange
85
121
  }, props), {}, {
86
122
  form: currentForm,
87
123
  params: formParams,
88
- onFinish: function () {
89
- var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
90
- var result, close;
91
- return _regeneratorRuntime.wrap(function _callee$(_context) {
92
- while (1) switch (_context.prev = _context.next) {
93
- case 0:
94
- _context.next = 2;
95
- return run(values, subParams);
96
- case 2:
97
- result = _context.sent;
98
- close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
99
- if (!(close === false)) {
100
- _context.next = 6;
101
- break;
102
- }
103
- return _context.abrupt("return");
104
- case 6:
105
- cancel();
106
- case 7:
107
- case "end":
108
- return _context.stop();
109
- }
110
- }, _callee);
111
- }));
112
- function onFinish(_x, _x2) {
113
- return _onFinish.apply(this, arguments);
114
- }
115
- return onFinish;
116
- }(),
124
+ onFinish: finish,
117
125
  infoRequest: infoRequest,
118
126
  labelWidth: labelWidth
119
127
  }));
@@ -1,6 +1,6 @@
1
1
  // welcome to hoo hoo hoo
2
- import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
3
2
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
3
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
4
4
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
5
5
  import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
6
6
  import { jsx } from 'react/jsx-runtime';
@@ -62,39 +62,46 @@ var Index = function Index(_ref) {
62
62
  }),
63
63
  loading = _useSub.loading,
64
64
  run = _useSub.run;
65
- var node = jsx(HForm, _objectSpread(_objectSpread({
65
+ var finish = /*#__PURE__*/function () {
66
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
67
+ var result, close;
68
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
69
+ while (1) switch (_context.prev = _context.next) {
70
+ case 0:
71
+ _context.next = 2;
72
+ return run(values, outParams);
73
+ case 2:
74
+ result = _context.sent;
75
+ close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
76
+ if (!(close === false)) {
77
+ _context.next = 6;
78
+ break;
79
+ }
80
+ return _context.abrupt("return");
81
+ case 6:
82
+ cancel();
83
+ case 7:
84
+ case "end":
85
+ return _context.stop();
86
+ }
87
+ }, _callee);
88
+ }));
89
+ return function finish(_x, _x2) {
90
+ return _ref2.apply(this, arguments);
91
+ };
92
+ }();
93
+ var footerOnOk = function footerOnOk() {
94
+ if (modalFormData) {
95
+ dialogForm === null || dialogForm === void 0 || dialogForm.submit();
96
+ return;
97
+ }
98
+ finish({}, formParams);
99
+ };
100
+ var node = modalFormData && jsx(HForm, _objectSpread(_objectSpread({
66
101
  configData: modalFormData,
67
102
  initialValues: initValue,
68
103
  onValuesChange: onValuesChange,
69
- onFinish: function () {
70
- var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
71
- var result, close;
72
- return _regeneratorRuntime.wrap(function _callee$(_context) {
73
- while (1) switch (_context.prev = _context.next) {
74
- case 0:
75
- _context.next = 2;
76
- return run(values, outParams);
77
- case 2:
78
- result = _context.sent;
79
- close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
80
- if (!(close === false)) {
81
- _context.next = 6;
82
- break;
83
- }
84
- return _context.abrupt("return");
85
- case 6:
86
- cancel();
87
- case 7:
88
- case "end":
89
- return _context.stop();
90
- }
91
- }, _callee);
92
- }));
93
- function onFinish(_x, _x2) {
94
- return _onFinish.apply(this, arguments);
95
- }
96
- return onFinish;
97
- }()
104
+ onFinish: finish
98
105
  }, props), {}, {
99
106
  params: formParams,
100
107
  form: currentForm,
@@ -104,7 +111,8 @@ var Index = function Index(_ref) {
104
111
  dialogForm: dialogForm,
105
112
  footer: footer,
106
113
  confirmLoading: loading,
107
- params: formParams
114
+ params: formParams,
115
+ onOk: footerOnOk
108
116
  });
109
117
  return jsx(Modal, _objectSpread(_objectSpread({
110
118
  title: modalTitle,
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
3
  export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, autoClear, }: ModifyPropsModal) => {
4
- modalFormData: import("../Form/modal").HItemProps[];
4
+ modalFormData: import("../Form/modal").HItemProps[] | undefined;
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>;
7
- setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[]>>;
7
+ setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[] | undefined>>;
8
8
  initValue: Record<string, any> | undefined;
9
9
  setInitValue: React.Dispatch<React.SetStateAction<Record<string, any> | undefined>>;
10
10
  formParams: any;
@@ -14,4 +14,8 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
14
14
  export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
15
15
  export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
16
16
  export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any, params: any]>;
17
- export declare const useFooterRender: ({ footer, confirmLoading, dialogForm, params, }: Omit<DialogFormProps, "configData">) => any;
17
+ interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData"> {
18
+ onOk: VoidFunction;
19
+ }
20
+ export declare const useFooterRender: ({ footer, confirmLoading, dialogForm, params, onOk }: FooterRenderParamsModal) => any;
21
+ export {};
@@ -154,7 +154,8 @@ var useFooterRender = function useFooterRender(_ref4) {
154
154
  var footer = _ref4.footer,
155
155
  confirmLoading = _ref4.confirmLoading,
156
156
  dialogForm = _ref4.dialogForm,
157
- params = _ref4.params;
157
+ params = _ref4.params,
158
+ onOk = _ref4.onOk;
158
159
  if (footer === null) {
159
160
  return null;
160
161
  }
@@ -165,9 +166,7 @@ var useFooterRender = function useFooterRender(_ref4) {
165
166
  onCancel: function onCancel() {
166
167
  dialogForm === null || dialogForm === void 0 || dialogForm.hide();
167
168
  },
168
- onOk: function onOk() {
169
- dialogForm === null || dialogForm === void 0 || dialogForm.submit();
170
- },
169
+ onOk: onOk,
171
170
  confirmLoading: confirmLoading
172
171
  });
173
172
  };
@@ -4,7 +4,7 @@ import type { PromiseFnResult } from "../modal";
4
4
  import type React from "react";
5
5
  type RootProps = HFormProps & ModalProps;
6
6
  export interface ModifyPropsModal<P = any> {
7
- configData: HItemProps[];
7
+ configData?: HItemProps[];
8
8
  visible?: boolean;
9
9
  initialValues?: Record<string, any>;
10
10
  dialogForm: HDialogFormInstance;
@@ -28,8 +28,9 @@ export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
28
28
  getParams: () => Record<string, any>;
29
29
  }
30
30
  export type FooterRender = (dialogForm?: HDialogFormInstance, loading?: boolean, params?: Record<string, any>) => React.ReactNode;
31
- export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer"> {
31
+ export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer" | "configData"> {
32
32
  dialogForm?: HDialogFormInstance;
33
+ configData?: HFormProps["configData"];
33
34
  onFinish?: (values: T, params: P) => Promise<any>;
34
35
  onCancel?: VoidFunction;
35
36
  onOk?: (data: T, params: P) => boolean | void;
@@ -74,15 +74,17 @@ var Index = function Index(_ref) {
74
74
  wrap: wrap,
75
75
  children: checkOptions === null || checkOptions === void 0 ? void 0 : checkOptions.map(function (item) {
76
76
  var label = item.label,
77
- itemVal = item.value;
77
+ itemVal = item.value,
78
+ itemDisabled = item.disabled;
78
79
  var checked = val[itemVal];
80
+ var nDis = typeof itemDisabled === "undefined" ? disabled : itemDisabled;
79
81
  return jsxRuntime.jsx(index$1.default, {
80
82
  value: checked,
81
83
  onChange: function onChange(changeVal) {
82
84
  change(itemVal, changeVal);
83
85
  },
84
86
  valueMap: valueMap,
85
- disabled: disabled,
87
+ disabled: nDis,
86
88
  children: label
87
89
  }, itemVal);
88
90
  })
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
6
5
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
6
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
7
7
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
8
8
  var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
9
9
  var jsxRuntime = require('react/jsx-runtime');
@@ -75,48 +75,56 @@ var Index = function Index(_ref) {
75
75
  }),
76
76
  loading = _useSub.loading,
77
77
  run = _useSub.run;
78
+ var finish = /*#__PURE__*/function () {
79
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
80
+ var result, close;
81
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
82
+ while (1) switch (_context.prev = _context.next) {
83
+ case 0:
84
+ _context.next = 2;
85
+ return run(values, subParams);
86
+ case 2:
87
+ result = _context.sent;
88
+ close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
89
+ if (!(close === false)) {
90
+ _context.next = 6;
91
+ break;
92
+ }
93
+ return _context.abrupt("return");
94
+ case 6:
95
+ cancel();
96
+ case 7:
97
+ case "end":
98
+ return _context.stop();
99
+ }
100
+ }, _callee);
101
+ }));
102
+ return function finish(_x, _x2) {
103
+ return _ref2.apply(this, arguments);
104
+ };
105
+ }();
106
+ var footerOnOk = function footerOnOk() {
107
+ if (modalFormData) {
108
+ dialogForm === null || dialogForm === void 0 || dialogForm.submit();
109
+ return;
110
+ }
111
+ finish({}, formParams);
112
+ };
78
113
  var defaultFooter = hooks.useFooterRender({
79
114
  dialogForm: dialogForm,
80
115
  footer: footer,
81
116
  confirmLoading: loading,
82
- params: formParams
117
+ params: formParams,
118
+ onOk: footerOnOk
83
119
  });
84
- var node = jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
120
+ var node = modalFormData && jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
85
121
  configData: modalFormData,
86
122
  initialValues: initValue,
87
123
  onValuesChange: onValuesChange
88
124
  }, props), {}, {
89
125
  form: currentForm,
90
126
  params: formParams,
91
- onFinish: function () {
92
- var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
93
- var result, close;
94
- return _regeneratorRuntime.wrap(function _callee$(_context) {
95
- while (1) switch (_context.prev = _context.next) {
96
- case 0:
97
- _context.next = 2;
98
- return run(values, subParams);
99
- case 2:
100
- result = _context.sent;
101
- close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
102
- if (!(close === false)) {
103
- _context.next = 6;
104
- break;
105
- }
106
- return _context.abrupt("return");
107
- case 6:
108
- cancel();
109
- case 7:
110
- case "end":
111
- return _context.stop();
112
- }
113
- }, _callee);
114
- }));
115
- function onFinish(_x, _x2) {
116
- return _onFinish.apply(this, arguments);
117
- }
118
- return onFinish;
119
- }(),
127
+ onFinish: finish,
120
128
  infoRequest: infoRequest,
121
129
  labelWidth: labelWidth
122
130
  }));
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
6
5
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
6
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
7
7
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
8
8
  var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
9
9
  var jsxRuntime = require('react/jsx-runtime');
@@ -65,39 +65,46 @@ var Index = function Index(_ref) {
65
65
  }),
66
66
  loading = _useSub.loading,
67
67
  run = _useSub.run;
68
- var node = jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
68
+ var finish = /*#__PURE__*/function () {
69
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
70
+ var result, close;
71
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
72
+ while (1) switch (_context.prev = _context.next) {
73
+ case 0:
74
+ _context.next = 2;
75
+ return run(values, outParams);
76
+ case 2:
77
+ result = _context.sent;
78
+ close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
79
+ if (!(close === false)) {
80
+ _context.next = 6;
81
+ break;
82
+ }
83
+ return _context.abrupt("return");
84
+ case 6:
85
+ cancel();
86
+ case 7:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee);
91
+ }));
92
+ return function finish(_x, _x2) {
93
+ return _ref2.apply(this, arguments);
94
+ };
95
+ }();
96
+ var footerOnOk = function footerOnOk() {
97
+ if (modalFormData) {
98
+ dialogForm === null || dialogForm === void 0 || dialogForm.submit();
99
+ return;
100
+ }
101
+ finish({}, formParams);
102
+ };
103
+ var node = modalFormData && jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
69
104
  configData: modalFormData,
70
105
  initialValues: initValue,
71
106
  onValuesChange: onValuesChange,
72
- onFinish: function () {
73
- var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
74
- var result, close;
75
- return _regeneratorRuntime.wrap(function _callee$(_context) {
76
- while (1) switch (_context.prev = _context.next) {
77
- case 0:
78
- _context.next = 2;
79
- return run(values, outParams);
80
- case 2:
81
- result = _context.sent;
82
- close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
83
- if (!(close === false)) {
84
- _context.next = 6;
85
- break;
86
- }
87
- return _context.abrupt("return");
88
- case 6:
89
- cancel();
90
- case 7:
91
- case "end":
92
- return _context.stop();
93
- }
94
- }, _callee);
95
- }));
96
- function onFinish(_x, _x2) {
97
- return _onFinish.apply(this, arguments);
98
- }
99
- return onFinish;
100
- }()
107
+ onFinish: finish
101
108
  }, props), {}, {
102
109
  params: formParams,
103
110
  form: currentForm,
@@ -107,7 +114,8 @@ var Index = function Index(_ref) {
107
114
  dialogForm: dialogForm,
108
115
  footer: footer,
109
116
  confirmLoading: loading,
110
- params: formParams
117
+ params: formParams,
118
+ onOk: footerOnOk
111
119
  });
112
120
  return jsxRuntime.jsx(antd.Modal, _objectSpread(_objectSpread({
113
121
  title: modalTitle,
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
3
  export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, autoClear, }: ModifyPropsModal) => {
4
- modalFormData: import("../Form/modal").HItemProps[];
4
+ modalFormData: import("../Form/modal").HItemProps[] | undefined;
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>;
7
- setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[]>>;
7
+ setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[] | undefined>>;
8
8
  initValue: Record<string, any> | undefined;
9
9
  setInitValue: React.Dispatch<React.SetStateAction<Record<string, any> | undefined>>;
10
10
  formParams: any;
@@ -14,4 +14,8 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
14
14
  export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
15
15
  export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
16
16
  export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any, params: any]>;
17
- export declare const useFooterRender: ({ footer, confirmLoading, dialogForm, params, }: Omit<DialogFormProps, "configData">) => any;
17
+ interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData"> {
18
+ onOk: VoidFunction;
19
+ }
20
+ export declare const useFooterRender: ({ footer, confirmLoading, dialogForm, params, onOk }: FooterRenderParamsModal) => any;
21
+ export {};
@@ -155,7 +155,8 @@ var useFooterRender = function useFooterRender(_ref4) {
155
155
  var footer = _ref4.footer,
156
156
  confirmLoading = _ref4.confirmLoading,
157
157
  dialogForm = _ref4.dialogForm,
158
- params = _ref4.params;
158
+ params = _ref4.params,
159
+ onOk = _ref4.onOk;
159
160
  if (footer === null) {
160
161
  return null;
161
162
  }
@@ -166,9 +167,7 @@ var useFooterRender = function useFooterRender(_ref4) {
166
167
  onCancel: function onCancel() {
167
168
  dialogForm === null || dialogForm === void 0 || dialogForm.hide();
168
169
  },
169
- onOk: function onOk() {
170
- dialogForm === null || dialogForm === void 0 || dialogForm.submit();
171
- },
170
+ onOk: onOk,
172
171
  confirmLoading: confirmLoading
173
172
  });
174
173
  };
@@ -4,7 +4,7 @@ import type { PromiseFnResult } from "../modal";
4
4
  import type React from "react";
5
5
  type RootProps = HFormProps & ModalProps;
6
6
  export interface ModifyPropsModal<P = any> {
7
- configData: HItemProps[];
7
+ configData?: HItemProps[];
8
8
  visible?: boolean;
9
9
  initialValues?: Record<string, any>;
10
10
  dialogForm: HDialogFormInstance;
@@ -28,8 +28,9 @@ export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
28
28
  getParams: () => Record<string, any>;
29
29
  }
30
30
  export type FooterRender = (dialogForm?: HDialogFormInstance, loading?: boolean, params?: Record<string, any>) => React.ReactNode;
31
- export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer"> {
31
+ export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer" | "configData"> {
32
32
  dialogForm?: HDialogFormInstance;
33
+ configData?: HFormProps["configData"];
33
34
  onFinish?: (values: T, params: P) => Promise<any>;
34
35
  onCancel?: VoidFunction;
35
36
  onOk?: (data: T, params: P) => boolean | void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.71",
3
+ "version": "1.9.73",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@ const Index = ({
20
20
  }: HCheckboxProps) => {
21
21
  const { valueCheckMap: resultValueCheckMap, fieldNames: resultFieldNames } =
22
22
  useMatchConfigProps({ fieldNames, valueCheckMap: valueMap }); //匹配全局
23
- const checkOptions = useChangeOptions({
23
+ const checkOptions:Record<string, any>[]|undefined = useChangeOptions({
24
24
  options,
25
25
  fieldNames: resultFieldNames,
26
26
  });
@@ -63,8 +63,9 @@ const Index = ({
63
63
  return (
64
64
  <Space direction={direction} wrap={wrap}>
65
65
  {checkOptions?.map((item) => {
66
- const { label, value: itemVal } = item;
66
+ const { label, value: itemVal ,disabled:itemDisabled} = item;
67
67
  const checked = val[itemVal];
68
+ const nDis=typeof itemDisabled==="undefined"?disabled:itemDisabled;
68
69
  return (
69
70
  <Checkbox
70
71
  value={checked}
@@ -73,7 +74,7 @@ const Index = ({
73
74
  change(itemVal, changeVal);
74
75
  }}
75
76
  valueMap={valueMap}
76
- disabled={disabled}
77
+ disabled={nDis}
77
78
  >
78
79
  {label}
79
80
  </Checkbox>
@@ -66,14 +66,29 @@ const Index: React.FC<DialogFormProps> = ({
66
66
  setModalVisible(false);
67
67
  };
68
68
  const { loading, run } = useSub({ request, onFinish });
69
-
69
+ const finish=async (values, subParams) => {
70
+ const result = await run(values, subParams);
71
+ const close = onOk?.(result, subParams);
72
+ if (close === false) {
73
+ return;
74
+ }
75
+ cancel();
76
+ }
77
+ const footerOnOk=()=>{
78
+ if (modalFormData){
79
+ dialogForm?.submit();
80
+ return;
81
+ }
82
+ finish({},formParams);
83
+ }
70
84
  const defaultFooter = useFooterRender({
71
85
  dialogForm,
72
86
  footer,
73
87
  confirmLoading: loading,
74
88
  params: formParams,
89
+ onOk :footerOnOk
75
90
  });
76
- const node = (
91
+ const node = modalFormData&&(
77
92
  <HForm
78
93
  configData={modalFormData}
79
94
  initialValues={initValue}
@@ -81,14 +96,7 @@ const Index: React.FC<DialogFormProps> = ({
81
96
  {...props}
82
97
  form={currentForm}
83
98
  params={formParams}
84
- onFinish={async (values, subParams) => {
85
- const result = await run(values, subParams);
86
- const close = onOk?.(result, subParams);
87
- if (close === false) {
88
- return;
89
- }
90
- cancel();
91
- }}
99
+ onFinish={finish}
92
100
  infoRequest={infoRequest}
93
101
  labelWidth={labelWidth}
94
102
  />
@@ -58,19 +58,27 @@ const Index: React.FC<DialogFormProps> = ({
58
58
  setModalVisible(false);
59
59
  };
60
60
  const { loading, run } = useSub({ request, onFinish });
61
- const node = (
61
+ const finish=async (values, outParams)=>{
62
+ const result = await run(values, outParams);
63
+ const close = onOk?.(result, outParams);
64
+ if (close === false) {
65
+ return;
66
+ }
67
+ cancel();
68
+ }
69
+ const footerOnOk=()=>{
70
+ if (modalFormData){
71
+ dialogForm?.submit();
72
+ return;
73
+ }
74
+ finish({},formParams);
75
+ }
76
+ const node = modalFormData&&(
62
77
  <HForm
63
78
  configData={modalFormData}
64
79
  initialValues={initValue}
65
80
  onValuesChange={onValuesChange}
66
- onFinish={async (values, outParams) => {
67
- const result = await run(values, outParams);
68
- const close = onOk?.(result, outParams);
69
- if (close === false) {
70
- return;
71
- }
72
- cancel();
73
- }}
81
+ onFinish={finish}
74
82
  {...props}
75
83
  params={formParams}
76
84
  form={currentForm}
@@ -82,6 +90,7 @@ const Index: React.FC<DialogFormProps> = ({
82
90
  footer,
83
91
  confirmLoading: loading,
84
92
  params: formParams,
93
+ onOk:footerOnOk
85
94
  });
86
95
  return (
87
96
  <Modal
@@ -119,13 +119,17 @@ export const useSub = ({ request, onFinish }: Partial<DialogFormProps>) => {
119
119
  { manual: true }
120
120
  );
121
121
  };
122
+ interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData">{
123
+ onOk:VoidFunction;
124
+ }
122
125
 
123
126
  export const useFooterRender = ({
124
127
  footer,
125
128
  confirmLoading,
126
129
  dialogForm,
127
130
  params,
128
- }: Omit<DialogFormProps, "configData">) => {
131
+ onOk
132
+ }: FooterRenderParamsModal) => {
129
133
  if (footer === null) {
130
134
  return null;
131
135
  }
@@ -138,9 +142,7 @@ export const useFooterRender = ({
138
142
  onCancel={() => {
139
143
  dialogForm?.hide();
140
144
  }}
141
- onOk={() => {
142
- dialogForm?.submit();
143
- }}
145
+ onOk={onOk}
144
146
  confirmLoading={confirmLoading}
145
147
  />
146
148
  )
@@ -6,7 +6,7 @@ import type React from "react";
6
6
  type RootProps = HFormProps & ModalProps;
7
7
 
8
8
  export interface ModifyPropsModal<P = any> {
9
- configData: HItemProps[];
9
+ configData?: HItemProps[];
10
10
  visible?: boolean;
11
11
  initialValues?: Record<string, any>;
12
12
  dialogForm: HDialogFormInstance;
@@ -38,9 +38,10 @@ export type FooterRender = (
38
38
  export interface DialogFormProps<P = any, T = any>
39
39
  extends Omit<
40
40
  RootProps,
41
- "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer"
41
+ "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer"|"configData"
42
42
  > {
43
43
  dialogForm?: HDialogFormInstance;
44
+ configData?:HFormProps["configData"];
44
45
  onFinish?: (values: T, params: P) => Promise<any>;
45
46
  onCancel?: VoidFunction;
46
47
  onOk?: (data: T, params: P) => boolean | void;
@@ -187,9 +187,6 @@ export default () => {
187
187
  text:"你好"
188
188
  }
189
189
  },
190
- subProvider:()=>{
191
- console.log("subProvider")
192
- }
193
190
  },
194
191
  },
195
192
  ]}
@@ -212,6 +212,7 @@ export default () => {
212
212
  }}
213
213
  labelAlign={"left"}
214
214
  request={(values, params) => {
215
+ console.log(values,params)
215
216
  return Promise.resolve();
216
217
  }}
217
218
  dialogForm={modalForm}