@hw-component/form 1.9.79 → 1.9.81

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.
@@ -11,7 +11,7 @@ import Title from './Title.js';
11
11
  import Index$1, { useFormConfigContext } from '../../Form/Context/FormConfigProvider.js';
12
12
  import Index$2 from '../ChildComponent.js';
13
13
 
14
- var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender", "children"];
14
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender", "children", "destroyOnClose"];
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var Index = function Index(_ref) {
@@ -38,6 +38,8 @@ var Index = function Index(_ref) {
38
38
  autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
39
39
  contentRender = _ref.contentRender,
40
40
  children = _ref.children,
41
+ _ref$destroyOnClose = _ref.destroyOnClose,
42
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
41
43
  props = _objectWithoutProperties(_ref, _excluded);
42
44
  var currentForm = useCurrentForm(dialogForm);
43
45
  var providerConfig = useFormConfigContext();
@@ -144,7 +146,7 @@ var Index = function Index(_ref) {
144
146
  afterClose === null || afterClose === void 0 || afterClose();
145
147
  },
146
148
  closable: false,
147
- destroyOnClose: true,
149
+ destroyOnClose: destroyOnClose,
148
150
  footer: defaultFooter,
149
151
  children: jsx(Index$1, _objectSpread(_objectSpread({}, providerConfig), {}, {
150
152
  children: jsx(Index$2, {
@@ -46,7 +46,7 @@ var useModifyProps = function useModifyProps(_ref) {
46
46
  };
47
47
  }, []);
48
48
  var saveOldParams = function saveOldParams() {
49
- saveOldParamsObj.old = dialogForm.outputValues();
49
+ saveOldParamsObj.old = dialogForm.getFieldsValue(true);
50
50
  };
51
51
  useEffect(function () {
52
52
  setModalVisible(visible);
@@ -8,6 +8,10 @@ var InitSet = (function () {
8
8
  form = _useFormContext.form;
9
9
  useEffect(function () {
10
10
  form.initValues();
11
+ form.inited = true;
12
+ return function () {
13
+ form.inited = false;
14
+ };
11
15
  }, []);
12
16
  return jsx(Fragment, {});
13
17
  });
@@ -200,7 +200,8 @@ var useHForm = (function () {
200
200
  clear: function clear() {
201
201
  form.resetFields();
202
202
  isLoading = false;
203
- }
203
+ },
204
+ inited: false
204
205
  });
205
206
  }, []);
206
207
  });
@@ -150,6 +150,7 @@ export interface HFormInstance extends FormInstance {
150
150
  clear: VoidFunction;
151
151
  resetFieldsInitValue: (values?: Record<string, any>) => void;
152
152
  clearFormat: (name: string) => void;
153
+ inited: boolean;
153
154
  }
154
155
  export interface ConnectConfigModal {
155
156
  format?: Record<string, addFormatItemModal>;
@@ -14,7 +14,7 @@ var Title = require('./Title.js');
14
14
  var FormConfigProvider = require('../../Form/Context/FormConfigProvider.js');
15
15
  var ChildComponent = require('../ChildComponent.js');
16
16
 
17
- var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender", "children"];
17
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender", "children", "destroyOnClose"];
18
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
20
  var Index = function Index(_ref) {
@@ -41,6 +41,8 @@ var Index = function Index(_ref) {
41
41
  autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
42
42
  contentRender = _ref.contentRender,
43
43
  children = _ref.children,
44
+ _ref$destroyOnClose = _ref.destroyOnClose,
45
+ destroyOnClose = _ref$destroyOnClose === void 0 ? true : _ref$destroyOnClose,
44
46
  props = _objectWithoutProperties(_ref, _excluded);
45
47
  var currentForm = hooks.useCurrentForm(dialogForm);
46
48
  var providerConfig = FormConfigProvider.useFormConfigContext();
@@ -147,7 +149,7 @@ var Index = function Index(_ref) {
147
149
  afterClose === null || afterClose === void 0 || afterClose();
148
150
  },
149
151
  closable: false,
150
- destroyOnClose: true,
152
+ destroyOnClose: destroyOnClose,
151
153
  footer: defaultFooter,
152
154
  children: jsxRuntime.jsx(FormConfigProvider.default, _objectSpread(_objectSpread({}, providerConfig), {}, {
153
155
  children: jsxRuntime.jsx(ChildComponent.default, {
@@ -47,7 +47,7 @@ var useModifyProps = function useModifyProps(_ref) {
47
47
  };
48
48
  }, []);
49
49
  var saveOldParams = function saveOldParams() {
50
- saveOldParamsObj.old = dialogForm.outputValues();
50
+ saveOldParamsObj.old = dialogForm.getFieldsValue(true);
51
51
  };
52
52
  React.useEffect(function () {
53
53
  setModalVisible(visible);
@@ -11,6 +11,10 @@ var InitSet = (function () {
11
11
  form = _useFormContext.form;
12
12
  React.useEffect(function () {
13
13
  form.initValues();
14
+ form.inited = true;
15
+ return function () {
16
+ form.inited = false;
17
+ };
14
18
  }, []);
15
19
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
16
20
  });
@@ -203,7 +203,8 @@ var useHForm = (function () {
203
203
  clear: function clear() {
204
204
  form.resetFields();
205
205
  isLoading = false;
206
- }
206
+ },
207
+ inited: false
207
208
  });
208
209
  }, []);
209
210
  });
@@ -150,6 +150,7 @@ export interface HFormInstance extends FormInstance {
150
150
  clear: VoidFunction;
151
151
  resetFieldsInitValue: (values?: Record<string, any>) => void;
152
152
  clearFormat: (name: string) => void;
153
+ inited: boolean;
153
154
  }
154
155
  export interface ConnectConfigModal {
155
156
  format?: Record<string, addFormatItemModal>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.79",
3
+ "version": "1.9.81",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,6 +35,7 @@ const Index: React.FC<DialogFormProps> = ({
35
35
  autoClear = true,
36
36
  contentRender,
37
37
  children,
38
+ destroyOnClose=true,
38
39
  ...props
39
40
  }: DialogFormProps) => {
40
41
  const currentForm = useCurrentForm(dialogForm);
@@ -117,7 +118,7 @@ const Index: React.FC<DialogFormProps> = ({
117
118
  afterClose?.();
118
119
  }}
119
120
  closable={false}
120
- destroyOnClose
121
+ destroyOnClose={destroyOnClose}
121
122
  footer={defaultFooter}
122
123
  >
123
124
  <FormConfigProvider {...providerConfig}>
@@ -29,7 +29,7 @@ export const useModifyProps = ({
29
29
  };
30
30
  }, []);
31
31
  const saveOldParams = () => {
32
- saveOldParamsObj.old = dialogForm.outputValues();
32
+ saveOldParamsObj.old = dialogForm.getFieldsValue(true);
33
33
  };
34
34
  useEffect(() => {
35
35
  setModalVisible(visible);
@@ -5,6 +5,10 @@ export default () => {
5
5
  const { form } = useFormContext();
6
6
  useEffect(() => {
7
7
  form.initValues();
8
+ form.inited=true;
9
+ return ()=>{
10
+ form.inited=false;
11
+ }
8
12
  }, []);
9
13
  return <></>;
10
14
  };
@@ -190,6 +190,7 @@ export default () => {
190
190
  form.resetFields();
191
191
  isLoading = false;
192
192
  },
193
+ inited:false
193
194
  };
194
195
  }, []);
195
196
  };
@@ -33,7 +33,6 @@ export default ({
33
33
  }: HFormProps) => {
34
34
  const hForm = useCurrentForm(form);
35
35
  const [dispatchSourceData, setDispatchSourceData] = useState({});
36
-
37
36
  const { subControl, infoControl } = useInfoReq({
38
37
  initialValues,
39
38
  request,
@@ -209,6 +209,7 @@ export interface HFormInstance extends FormInstance {
209
209
  clear: VoidFunction;
210
210
  resetFieldsInitValue: (values?: Record<string, any>) => void;
211
211
  clearFormat: (name: string) => void;
212
+ inited:boolean;
212
213
  }
213
214
 
214
215
  export interface ConnectConfigModal {
@@ -75,6 +75,14 @@ export default () => {
75
75
  <div style={{ width: 1000 }}>
76
76
  <HForm
77
77
  configData={[
78
+ {
79
+ label:"文字",
80
+ name:"wz"
81
+ },
82
+ {
83
+ label:"文字1",
84
+ name:"wz1"
85
+ },
78
86
  {
79
87
  label: "inputSelect",
80
88
  type: "richEditor",
@@ -208,9 +216,6 @@ export default () => {
208
216
  },
209
217
  ]}
210
218
  dismissOnPressEnter={false}
211
- formItemStyle={{
212
- marginBottom: 100,
213
- }}
214
219
  labelWidth={88}
215
220
  form={form}
216
221
  initialValues={{
@@ -243,10 +248,12 @@ export default () => {
243
248
  </div>
244
249
  <div
245
250
  onClick={() => {
246
- form.resetFieldsInitValue();
251
+ form.setFieldsValue({
252
+ wz:"你好"
253
+ })
247
254
  }}
248
255
  >
249
- 重置
256
+ 设置
250
257
  </div>
251
258
  <div
252
259
  onClick={() => {
@@ -22,9 +22,9 @@ const data = [
22
22
  label: "输入框",
23
23
  name: "name",
24
24
  hideLabel: true,
25
- render:()=>{
26
- return <ITest/>
27
- },
25
+ // render:()=>{
26
+ // return <ITest/>
27
+ // },
28
28
  },
29
29
  // {
30
30
  // label: "数字",
@@ -204,15 +204,12 @@ export default () => {
204
204
  formItemStyle={{
205
205
  marginBottom: 100,
206
206
  }}
207
+ destroyOnClose={false}
208
+ autoClear={false}
207
209
  onOk={() => {
208
210
  console.log("fff")
209
211
  return false;
210
212
  }}
211
- infoRequest={() => {
212
- return Promise.resolve({
213
- text: "你好",
214
- });
215
- }}
216
213
  labelAlign={"left"}
217
214
  request={(values, params) => {
218
215
  console.log(values,params)