@hw-component/form 1.6.7 → 1.6.9

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.
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { HDialogFormInstance } from "@/components/DialogForm/modal";
3
+ interface IProps<P = any> {
4
+ contentRender?: (dom: React.ReactNode, form: HDialogFormInstance, params: P) => React.ReactNode;
5
+ dialogForm: HDialogFormInstance;
6
+ params: P;
7
+ formNode: React.ReactNode;
8
+ }
9
+ declare const Index: React.FC<IProps>;
10
+ export default Index;
@@ -0,0 +1,22 @@
1
+ // welcome to hoo hoo hoo
2
+ import { jsx, Fragment } from 'react/jsx-runtime';
3
+ import React from 'react';
4
+
5
+ var Index = function Index(_ref) {
6
+ var contentRender = _ref.contentRender,
7
+ formNode = _ref.formNode,
8
+ params = _ref.params,
9
+ dialogForm = _ref.dialogForm,
10
+ children = _ref.children;
11
+ var cuNode = children ? /*#__PURE__*/React.cloneElement(children, {
12
+ dialogForm: dialogForm,
13
+ params: params,
14
+ formNode: formNode
15
+ }) : formNode;
16
+ return jsx(Fragment, {
17
+ children: contentRender ? contentRender(cuNode, dialogForm, params) : cuNode
18
+ });
19
+ };
20
+
21
+ export { Index as default };
22
+ // powered by hdj
@@ -1,3 +1,4 @@
1
1
  import type { DialogFormProps } from "../modal";
2
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, contentRender, ...props }: DialogFormProps) => JSX.Element;
3
- export default _default;
2
+ import React from "react";
3
+ declare const Index: React.FC<DialogFormProps>;
4
+ export default Index;
@@ -16,12 +16,13 @@ import { useCurrentForm, useModifyProps, useSub } from '../hooks.js';
16
16
  import HForm from '../../Form/index.js';
17
17
  import Title from './Title.js';
18
18
  import Footer from './Footer.js';
19
- import Index, { useFormConfigContext } from '../../Form/Context/FormConfigProvider.js';
19
+ import Index$1, { useFormConfigContext } from '../../Form/Context/FormConfigProvider.js';
20
+ import Index$2 from '../ChildComponent.js';
20
21
 
21
- var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender"];
22
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender", "children"];
22
23
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
- var DrawerForm = (function (_ref) {
25
+ var Index = function Index(_ref) {
25
26
  var visible = _ref.visible,
26
27
  title = _ref.title,
27
28
  onCancel = _ref.onCancel,
@@ -44,6 +45,7 @@ var DrawerForm = (function (_ref) {
44
45
  _ref$autoClear = _ref.autoClear,
45
46
  autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
46
47
  contentRender = _ref.contentRender,
48
+ children = _ref.children,
47
49
  props = _objectWithoutProperties(_ref, _excluded);
48
50
  var currentForm = useCurrentForm(dialogForm);
49
51
  var providerConfig = useFormConfigContext();
@@ -82,6 +84,9 @@ var DrawerForm = (function (_ref) {
82
84
  if (footer === null) {
83
85
  return null;
84
86
  }
87
+ if (typeof footer === "function") {
88
+ return footer(dialogForm, loading, formParams);
89
+ }
85
90
  return footer || jsx(Footer, {
86
91
  onCancel: cancel,
87
92
  onOk: currentForm.submit,
@@ -139,11 +144,17 @@ var DrawerForm = (function (_ref) {
139
144
  closable: false,
140
145
  destroyOnClose: true,
141
146
  footer: footerComponent(),
142
- children: jsx(Index, _objectSpread(_objectSpread({}, providerConfig), {}, {
143
- children: contentRender ? contentRender(node, currentForm, params) : node
147
+ children: jsx(Index$1, _objectSpread(_objectSpread({}, providerConfig), {}, {
148
+ children: jsx(Index$2, {
149
+ dialogForm: currentForm,
150
+ contentRender: contentRender,
151
+ params: params,
152
+ formNode: node,
153
+ children: children
154
+ })
144
155
  }))
145
156
  }));
146
- });
157
+ };
147
158
 
148
- export { DrawerForm as default };
159
+ export { Index as default };
149
160
  // powered by hdj
@@ -1,3 +1,4 @@
1
1
  import type { DialogFormProps } from "./modal";
2
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, contentRender, footer, ...props }: DialogFormProps) => JSX.Element;
3
- export default _default;
2
+ import React from "react";
3
+ declare const Index: React.FC<DialogFormProps>;
4
+ export default Index;
@@ -13,13 +13,14 @@ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
13
13
  import { jsx } from 'react/jsx-runtime';
14
14
  import { Modal } from 'antd';
15
15
  import HForm from '../Form/index.js';
16
- import Index, { useFormConfigContext } from '../Form/Context/FormConfigProvider.js';
16
+ import Index$1, { useFormConfigContext } from '../Form/Context/FormConfigProvider.js';
17
17
  import { useCurrentForm, useModifyProps, useSub, useFooterRender } from './hooks.js';
18
+ import Index$2 from './ChildComponent.js';
18
19
 
19
- var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear", "contentRender", "footer"];
20
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear", "contentRender", "footer", "children"];
20
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
22
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
- var ModalForm = (function (_ref) {
23
+ var Index = function Index(_ref) {
23
24
  var visible = _ref.visible,
24
25
  title = _ref.title,
25
26
  onCancel = _ref.onCancel,
@@ -37,6 +38,7 @@ var ModalForm = (function (_ref) {
37
38
  autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
38
39
  contentRender = _ref.contentRender,
39
40
  footer = _ref.footer,
41
+ children = _ref.children,
40
42
  props = _objectWithoutProperties(_ref, _excluded);
41
43
  var currentForm = useCurrentForm(dialogForm);
42
44
  var providerConfig = useFormConfigContext();
@@ -126,11 +128,17 @@ var ModalForm = (function (_ref) {
126
128
  onOk: currentForm.submit,
127
129
  destroyOnClose: true,
128
130
  footer: defaultFooter,
129
- children: jsx(Index, _objectSpread(_objectSpread({}, providerConfig), {}, {
130
- children: contentRender ? contentRender === null || contentRender === void 0 ? void 0 : contentRender(node, currentForm, formParams) : node
131
+ children: jsx(Index$1, _objectSpread(_objectSpread({}, providerConfig), {}, {
132
+ children: jsx(Index$2, {
133
+ dialogForm: currentForm,
134
+ contentRender: contentRender,
135
+ formNode: node,
136
+ params: params,
137
+ children: children
138
+ })
131
139
  }))
132
140
  }));
133
- });
141
+ };
134
142
 
135
- export { ModalForm as default };
143
+ export { Index as default };
136
144
  // powered by hdj
@@ -22,6 +22,7 @@ var Item = (function (props) {
22
22
  _props$labelAlign = props.labelAlign,
23
23
  labelAlign = _props$labelAlign === void 0 ? formLabelAlign : _props$labelAlign;
24
24
  var Component = useFormItemDomControl(props);
25
+ console.log(formLabelWidth, "formLabelWidth");
25
26
  return jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
26
27
  labelAlign: labelAlign,
27
28
  labelWidth: labelWidth
package/es/index.d.ts CHANGED
@@ -22,8 +22,8 @@ export declare const HInputNumber: ({ style, ...props }: import("antd").InputNum
22
22
  export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
23
23
  export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
24
24
  export declare const HColorInput: ({ value, onChange, defaultColor, ...props }: import("./Input/modal").HInputProps<any>) => JSX.Element;
25
- export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, contentRender, footer, ...props }: import("./DialogForm/modal").DialogFormProps<any, any>) => JSX.Element;
26
- export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, contentRender, ...props }: import("./DialogForm/modal").DialogFormProps<any, any>) => JSX.Element;
25
+ export declare const HModalForm: import("react").FC<import("./DialogForm/modal").DialogFormProps<any, any>>;
26
+ export declare const HDrawerForm: import("react").FC<import("./DialogForm/modal").DialogFormProps<any, any>>;
27
27
  export declare const HCascader: ({ request, options, fieldNames: propsFieldNames, ...props }: import("./Cascader").HCascaderProps) => JSX.Element;
28
28
  export declare const HVerificationCodeInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
29
29
  export declare const HTrimInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
package/es/index.js CHANGED
@@ -6,8 +6,8 @@ export { default as useHForm } from './Form/hooks/useHForm.js';
6
6
  export { useHDialogForm } from './DialogForm/hooks.js';
7
7
  export { default as HFormConnect } from './Form/HFormConnect.js';
8
8
  export { default as HFormConfigProvider } from './Form/Context/FormConfigProvider.js';
9
- import ModalForm from './DialogForm/ModalForm.js';
10
- import DrawerForm from './DialogForm/DrawerForm/index.js';
9
+ import Index$1 from './DialogForm/ModalForm.js';
10
+ import Index$2 from './DialogForm/DrawerForm/index.js';
11
11
 
12
12
  var HSelect = componentConfig.select;
13
13
  var HInput = componentConfig.input;
@@ -26,8 +26,8 @@ var HInputNumber = componentConfig.inputNumber;
26
26
  var HPageHandler = Index;
27
27
  var HTextArea = componentConfig.textArea;
28
28
  var HColorInput = componentConfig.colorInput;
29
- var HModalForm = ModalForm;
30
- var HDrawerForm = DrawerForm;
29
+ var HModalForm = Index$1;
30
+ var HDrawerForm = Index$2;
31
31
  var HCascader = componentConfig.cascader;
32
32
  var HVerificationCodeInput = componentConfig.verificationCodeInput;
33
33
  var HTrimInput = componentConfig.trimInput;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { HDialogFormInstance } from "@/components/DialogForm/modal";
3
+ interface IProps<P = any> {
4
+ contentRender?: (dom: React.ReactNode, form: HDialogFormInstance, params: P) => React.ReactNode;
5
+ dialogForm: HDialogFormInstance;
6
+ params: P;
7
+ formNode: React.ReactNode;
8
+ }
9
+ declare const Index: React.FC<IProps>;
10
+ export default Index;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
+
8
+ var Index = function Index(_ref) {
9
+ var contentRender = _ref.contentRender,
10
+ formNode = _ref.formNode,
11
+ params = _ref.params,
12
+ dialogForm = _ref.dialogForm,
13
+ children = _ref.children;
14
+ var cuNode = children ? /*#__PURE__*/React.cloneElement(children, {
15
+ dialogForm: dialogForm,
16
+ params: params,
17
+ formNode: formNode
18
+ }) : formNode;
19
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
20
+ children: contentRender ? contentRender(cuNode, dialogForm, params) : cuNode
21
+ });
22
+ };
23
+
24
+ exports.default = Index;
25
+ // powered by h
@@ -1,3 +1,4 @@
1
1
  import type { DialogFormProps } from "../modal";
2
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, contentRender, ...props }: DialogFormProps) => JSX.Element;
3
- export default _default;
2
+ import React from "react";
3
+ declare const Index: React.FC<DialogFormProps>;
4
+ export default Index;
@@ -20,11 +20,12 @@ var index = require('../../Form/index.js');
20
20
  var Title = require('./Title.js');
21
21
  var Footer = require('./Footer.js');
22
22
  var FormConfigProvider = require('../../Form/Context/FormConfigProvider.js');
23
+ var ChildComponent = require('../ChildComponent.js');
23
24
 
24
- var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender"];
25
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange", "autoClear", "contentRender", "children"];
25
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
27
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
- var DrawerForm = (function (_ref) {
28
+ var Index = function Index(_ref) {
28
29
  var visible = _ref.visible,
29
30
  title = _ref.title,
30
31
  onCancel = _ref.onCancel,
@@ -47,6 +48,7 @@ var DrawerForm = (function (_ref) {
47
48
  _ref$autoClear = _ref.autoClear,
48
49
  autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
49
50
  contentRender = _ref.contentRender,
51
+ children = _ref.children,
50
52
  props = _objectWithoutProperties(_ref, _excluded);
51
53
  var currentForm = hooks.useCurrentForm(dialogForm);
52
54
  var providerConfig = FormConfigProvider.useFormConfigContext();
@@ -85,6 +87,9 @@ var DrawerForm = (function (_ref) {
85
87
  if (footer === null) {
86
88
  return null;
87
89
  }
90
+ if (typeof footer === "function") {
91
+ return footer(dialogForm, loading, formParams);
92
+ }
88
93
  return footer || jsxRuntime.jsx(Footer.default, {
89
94
  onCancel: cancel,
90
95
  onOk: currentForm.submit,
@@ -143,10 +148,16 @@ var DrawerForm = (function (_ref) {
143
148
  destroyOnClose: true,
144
149
  footer: footerComponent(),
145
150
  children: jsxRuntime.jsx(FormConfigProvider.default, _objectSpread(_objectSpread({}, providerConfig), {}, {
146
- children: contentRender ? contentRender(node, currentForm, params) : node
151
+ children: jsxRuntime.jsx(ChildComponent.default, {
152
+ dialogForm: currentForm,
153
+ contentRender: contentRender,
154
+ params: params,
155
+ formNode: node,
156
+ children: children
157
+ })
147
158
  }))
148
159
  }));
149
- });
160
+ };
150
161
 
151
- exports.default = DrawerForm;
162
+ exports.default = Index;
152
163
  // powered by h
@@ -1,3 +1,4 @@
1
1
  import type { DialogFormProps } from "./modal";
2
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, contentRender, footer, ...props }: DialogFormProps) => JSX.Element;
3
- export default _default;
2
+ import React from "react";
3
+ declare const Index: React.FC<DialogFormProps>;
4
+ export default Index;
@@ -18,11 +18,12 @@ var antd = require('antd');
18
18
  var index = require('../Form/index.js');
19
19
  var FormConfigProvider = require('../Form/Context/FormConfigProvider.js');
20
20
  var hooks = require('./hooks.js');
21
+ var ChildComponent = require('./ChildComponent.js');
21
22
 
22
- var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear", "contentRender", "footer"];
23
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange", "autoClear", "contentRender", "footer", "children"];
23
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24
25
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
- var ModalForm = (function (_ref) {
26
+ var Index = function Index(_ref) {
26
27
  var visible = _ref.visible,
27
28
  title = _ref.title,
28
29
  onCancel = _ref.onCancel,
@@ -40,6 +41,7 @@ var ModalForm = (function (_ref) {
40
41
  autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
41
42
  contentRender = _ref.contentRender,
42
43
  footer = _ref.footer,
44
+ children = _ref.children,
43
45
  props = _objectWithoutProperties(_ref, _excluded);
44
46
  var currentForm = hooks.useCurrentForm(dialogForm);
45
47
  var providerConfig = FormConfigProvider.useFormConfigContext();
@@ -130,10 +132,16 @@ var ModalForm = (function (_ref) {
130
132
  destroyOnClose: true,
131
133
  footer: defaultFooter,
132
134
  children: jsxRuntime.jsx(FormConfigProvider.default, _objectSpread(_objectSpread({}, providerConfig), {}, {
133
- children: contentRender ? contentRender === null || contentRender === void 0 ? void 0 : contentRender(node, currentForm, formParams) : node
135
+ children: jsxRuntime.jsx(ChildComponent.default, {
136
+ dialogForm: currentForm,
137
+ contentRender: contentRender,
138
+ formNode: node,
139
+ params: params,
140
+ children: children
141
+ })
134
142
  }))
135
143
  }));
136
- });
144
+ };
137
145
 
138
- exports.default = ModalForm;
146
+ exports.default = Index;
139
147
  // powered by h
@@ -25,6 +25,7 @@ var Item = (function (props) {
25
25
  _props$labelAlign = props.labelAlign,
26
26
  labelAlign = _props$labelAlign === void 0 ? formLabelAlign : _props$labelAlign;
27
27
  var Component = hooks.useFormItemDomControl(props);
28
+ console.log(formLabelWidth, "formLabelWidth");
28
29
  return jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
29
30
  labelAlign: labelAlign,
30
31
  labelWidth: labelWidth
package/lib/index.d.ts CHANGED
@@ -22,8 +22,8 @@ export declare const HInputNumber: ({ style, ...props }: import("antd").InputNum
22
22
  export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
23
23
  export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
24
24
  export declare const HColorInput: ({ value, onChange, defaultColor, ...props }: import("./Input/modal").HInputProps<any>) => JSX.Element;
25
- export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, autoClear, contentRender, footer, ...props }: import("./DialogForm/modal").DialogFormProps<any, any>) => JSX.Element;
26
- export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, autoClear, contentRender, ...props }: import("./DialogForm/modal").DialogFormProps<any, any>) => JSX.Element;
25
+ export declare const HModalForm: import("react").FC<import("./DialogForm/modal").DialogFormProps<any, any>>;
26
+ export declare const HDrawerForm: import("react").FC<import("./DialogForm/modal").DialogFormProps<any, any>>;
27
27
  export declare const HCascader: ({ request, options, fieldNames: propsFieldNames, ...props }: import("./Cascader").HCascaderProps) => JSX.Element;
28
28
  export declare const HVerificationCodeInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
29
29
  export declare const HTrimInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import {HDialogFormInstance} from "@/components/DialogForm/modal";
3
+
4
+ interface IProps<P=any> {
5
+ contentRender?: (
6
+ dom: React.ReactNode,
7
+ form: HDialogFormInstance,
8
+ params: P
9
+ ) => React.ReactNode;
10
+ dialogForm:HDialogFormInstance;
11
+ params:P;
12
+ formNode:React.ReactNode
13
+ }
14
+ const Index:React.FC<IProps>=({contentRender,formNode,params,dialogForm,children})=>{
15
+ const cuNode=children?React.cloneElement((children as any),{dialogForm,params,formNode}):formNode;
16
+ return <>{contentRender?contentRender(cuNode,dialogForm,params):cuNode}</>;
17
+ }
18
+
19
+
20
+ export default Index;
@@ -7,29 +7,32 @@ import Footer from "./Footer";
7
7
  import FormConfigProvider, {
8
8
  useFormConfigContext,
9
9
  } from "../../Form/Context/FormConfigProvider";
10
- export default ({
11
- visible,
12
- title,
13
- onCancel,
14
- configData,
15
- infoRequest,
16
- request,
17
- afterClose,
18
- dialogForm,
19
- closable = true,
20
- initialValues,
21
- labelWidth,
22
- onOk,
23
- onFinish,
24
- size,
25
- form,
26
- footer,
27
- params,
28
- onValuesChange,
29
- autoClear = true,
30
- contentRender,
31
- ...props
32
- }: DialogFormProps) => {
10
+ import React from "react";
11
+ import ChildComponent from '../ChildComponent'
12
+ const Index:React.FC<DialogFormProps>=({
13
+ visible,
14
+ title,
15
+ onCancel,
16
+ configData,
17
+ infoRequest,
18
+ request,
19
+ afterClose,
20
+ dialogForm,
21
+ closable = true,
22
+ initialValues,
23
+ labelWidth,
24
+ onOk,
25
+ onFinish,
26
+ size,
27
+ form,
28
+ footer,
29
+ params,
30
+ onValuesChange,
31
+ autoClear = true,
32
+ contentRender,
33
+ children,
34
+ ...props
35
+ }: DialogFormProps) => {
33
36
  const currentForm = useCurrentForm(dialogForm);
34
37
  const providerConfig = useFormConfigContext();
35
38
  const {
@@ -63,49 +66,60 @@ export default ({
63
66
  if (footer === null) {
64
67
  return null;
65
68
  }
69
+ if (typeof footer==="function"){
70
+ return footer(dialogForm,loading,formParams)
71
+ }
66
72
  return (
67
- footer || (
68
- <Footer
69
- onCancel={cancel}
70
- onOk={currentForm.submit}
71
- confirmLoading={loading}
72
- />
73
- )
73
+ footer || (
74
+ <Footer
75
+ onCancel={cancel}
76
+ onOk={currentForm.submit}
77
+ confirmLoading={loading}
78
+ />
79
+ )
74
80
  );
75
81
  };
76
82
  const node = (
77
- <HForm
78
- configData={modalFormData}
79
- initialValues={initValue}
80
- onValuesChange={onValuesChange}
81
- {...props}
82
- form={currentForm}
83
- 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
- }}
92
- infoRequest={infoRequest}
93
- labelWidth={labelWidth}
94
- />
83
+ <HForm
84
+ configData={modalFormData}
85
+ initialValues={initValue}
86
+ onValuesChange={onValuesChange}
87
+ {...props}
88
+ form={currentForm}
89
+ params={formParams}
90
+ onFinish={async (values, subParams) => {
91
+ const result = await run(values, subParams);
92
+ const close = onOk?.(result, subParams);
93
+ if (close === false) {
94
+ return;
95
+ }
96
+ cancel();
97
+ }}
98
+ infoRequest={infoRequest}
99
+ labelWidth={labelWidth}
100
+ />
95
101
  );
96
102
  return (
97
- <Drawer
98
- visible={modalVisible}
99
- title={<Title title={modalTitle} closable={closable} onCancel={cancel} />}
100
- {...props}
101
- onClose={cancel}
102
- closable={false}
103
- destroyOnClose={true}
104
- footer={footerComponent()}
105
- >
106
- <FormConfigProvider {...providerConfig}>
107
- {contentRender ? contentRender(node, currentForm, params) : node}
108
- </FormConfigProvider>
109
- </Drawer>
103
+ <Drawer
104
+ visible={modalVisible}
105
+ title={<Title title={modalTitle} closable={closable} onCancel={cancel} />}
106
+ {...props}
107
+ onClose={cancel}
108
+ closable={false}
109
+ destroyOnClose={true}
110
+ footer={footerComponent()}
111
+ >
112
+ <FormConfigProvider {...providerConfig}>
113
+ <ChildComponent dialogForm={currentForm}
114
+ contentRender={contentRender}
115
+ params={params}
116
+ formNode={node}
117
+ >
118
+ {children}
119
+ </ChildComponent>
120
+ </FormConfigProvider>
121
+ </Drawer>
110
122
  );
111
123
  };
124
+
125
+ export default Index;
@@ -10,27 +10,31 @@ import {
10
10
  useModifyProps,
11
11
  useSub,
12
12
  } from "./hooks";
13
- export default ({
14
- visible,
15
- title,
16
- onCancel,
17
- configData,
18
- infoRequest,
19
- request,
20
- afterClose,
21
- dialogForm,
22
- initialValues,
23
- onFinish,
24
- params,
25
- onOk,
26
- onValuesChange,
27
- autoClear = true,
28
- contentRender,
29
- footer,
30
- ...props
31
- }: DialogFormProps) => {
13
+ import ChildComponent from './ChildComponent'
14
+ import React from "react";
15
+ const Index:React.FC<DialogFormProps>= ({
16
+ visible,
17
+ title,
18
+ onCancel,
19
+ configData,
20
+ infoRequest,
21
+ request,
22
+ afterClose,
23
+ dialogForm,
24
+ initialValues,
25
+ onFinish,
26
+ params,
27
+ onOk,
28
+ onValuesChange,
29
+ autoClear = true,
30
+ contentRender,
31
+ footer,
32
+ children,
33
+ ...props
34
+ }) => {
32
35
  const currentForm = useCurrentForm(dialogForm);
33
36
  const providerConfig = useFormConfigContext();
37
+
34
38
  const {
35
39
  modalVisible,
36
40
  modalFormData,
@@ -55,23 +59,23 @@ export default ({
55
59
  };
56
60
  const { loading, run } = useSub({ request, onFinish });
57
61
  const node = (
58
- <HForm
59
- configData={modalFormData}
60
- initialValues={initValue}
61
- onValuesChange={onValuesChange}
62
- onFinish={async (values, outParams) => {
63
- const result = await run(values, outParams);
64
- const close = onOk?.(result, outParams);
65
- if (close === false) {
66
- return;
67
- }
68
- cancel();
69
- }}
70
- {...props}
71
- params={formParams}
72
- form={currentForm}
73
- infoRequest={infoRequest}
74
- />
62
+ <HForm
63
+ configData={modalFormData}
64
+ initialValues={initValue}
65
+ 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
+ }}
74
+ {...props}
75
+ params={formParams}
76
+ form={currentForm}
77
+ infoRequest={infoRequest}
78
+ />
75
79
  );
76
80
  const defaultFooter = useFooterRender({
77
81
  dialogForm,
@@ -79,27 +83,33 @@ export default ({
79
83
  confirmLoading: loading,
80
84
  params: formParams,
81
85
  });
82
-
83
86
  return (
84
- <Modal
85
- title={modalTitle}
86
- visible={modalVisible}
87
- onCancel={cancel}
88
- confirmLoading={loading}
89
- afterClose={() => {
90
- if (autoClear) {
91
- currentForm.clear();
92
- }
93
- afterClose?.();
94
- }}
95
- {...props}
96
- onOk={currentForm.submit}
97
- destroyOnClose={true}
98
- footer={defaultFooter}
99
- >
100
- <FormConfigProvider {...providerConfig}>
101
- {contentRender ? contentRender?.(node, currentForm, formParams) : node}
102
- </FormConfigProvider>
103
- </Modal>
87
+ <Modal
88
+ title={modalTitle}
89
+ visible={modalVisible}
90
+ onCancel={cancel}
91
+ confirmLoading={loading}
92
+ afterClose={() => {
93
+ if (autoClear) {
94
+ currentForm.clear();
95
+ }
96
+ afterClose?.();
97
+ }}
98
+ {...props}
99
+ onOk={currentForm.submit}
100
+ destroyOnClose={true}
101
+ footer={defaultFooter}
102
+ >
103
+ <FormConfigProvider {...providerConfig}>
104
+ <ChildComponent dialogForm={currentForm}
105
+ contentRender={contentRender}
106
+ formNode={node}
107
+ params={params}>
108
+ {children}
109
+ </ChildComponent>
110
+ </FormConfigProvider>
111
+ </Modal>
104
112
  );
105
113
  };
114
+
115
+ export default Index;
@@ -7,5 +7,6 @@ export default (props: HItemProps) => {
7
7
  const {labelWidth:formLabelWidth,labelAlign:formLabelAlign}=useFormContext();
8
8
  const {labelWidth=formLabelWidth,labelAlign=formLabelAlign}=props;
9
9
  const Component = useFormItemDomControl(props);
10
+ console.log(formLabelWidth,"formLabelWidth")
10
11
  return <Component {...props} labelAlign={labelAlign} labelWidth={labelWidth}/>;
11
12
  };
@@ -1,61 +1,29 @@
1
1
  import { Button } from "antd";
2
2
  import { HDrawerForm, useHDialogForm } from "../../components";
3
3
  import { MediaTypeEnum } from "../../components/Upload/enums";
4
+ import FormItem from '../../components/Form/FormItem'
5
+ import {useEffect} from "react";
6
+ const Test=()=>{
7
+ return <FormItem name="123" label="你好"/>
8
+ }
4
9
  const data = [
5
10
  {
6
- label: "选择",
7
- name: "checkboxGroup",
8
- type: "radioGroup",
9
- rules: [{ required: true }],
10
- helper: "帮助我",
11
- options: [
12
- { label: "选择1", value: 0 },
13
- { label: "选择2", value: 1 },
14
- ],
15
- },
16
- {
17
- label: "选择",
18
- name: "select",
19
- type: "select",
20
- helper: "select",
21
- itemProps: {
22
- mode: "tags",
23
- options: [
24
- { label: "选择1", value: 0 },
25
- { label: "选择2", value: 1 },
26
- ],
27
- },
28
- },
29
- {
30
- label: "地址文件",
31
- name: "urlUpload",
32
- type: "urlUpload",
33
- rules: [{ required: true }],
34
- hide: (form) => {
35
- const check = form.getFieldValue("checkboxGroup");
36
- return check !== 0;
37
- },
38
- itemProps: {
39
- style: { width: 368 },
40
- placeholder: "粘贴图片地址鼠标移出输入框自动保存",
41
- maxSize: 1024 * 1024 * 10,
42
- thumbUrl:
43
- "http://gips3.baidu.com/it/u=3886271102,3123389489&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960",
44
- mediaType: MediaTypeEnum.video,
45
- },
46
- },
47
- {
48
- label: "验证码",
49
- type: "verificationCodeInput",
50
- name: "verificationCodeInput",
51
- itemProps: {
52
- request: () => {
53
- return Promise.resolve({ code: 200 });
54
- },
55
- },
56
- },
11
+ hideLabel:true,
12
+ render:()=>{
13
+ return <Test/>
14
+ }
15
+ }
57
16
  ];
58
17
  let num = 0;
18
+ const Test1=({formNode,dialogForm,params})=>{
19
+ useEffect(() => {
20
+ console.log("渲染")
21
+ }, []);
22
+ return <div>
23
+ <div>测试一些</div>
24
+ {formNode}
25
+ </div>
26
+ }
59
27
  export default () => {
60
28
  const modalForm = useHDialogForm();
61
29
  return (
@@ -98,14 +66,23 @@ export default () => {
98
66
  labelWidth={88}
99
67
  labelAlign={"left"}
100
68
  dialogForm={modalForm}
69
+ footer={()=>{
70
+ return <div>ff</div>
71
+ }}
72
+ request={(values)=>{
73
+ console.log(values)
74
+ }}
101
75
  afterClose={() => {
102
76
  console.log("afterClose");
103
77
  }}
104
78
  contentRender={(node) => {
79
+ console.log("contentRender");
105
80
  return <div>{node}</div>;
106
81
  }}
107
82
  title="测试"
108
- />
83
+ >
84
+ <Test1/>
85
+ </HDrawerForm>
109
86
  </>
110
87
  );
111
88
  };
@@ -5,7 +5,7 @@ import {
5
5
  HFormConfigProvider,
6
6
  HUrlUpload,
7
7
  } from "../../components";
8
- import { useState } from "react";
8
+ import {useEffect, useState} from "react";
9
9
  import { ShowParamsModal } from "@/components/DialogForm/modal";
10
10
 
11
11
  const Test = (props) => {
@@ -144,6 +144,15 @@ const data = [
144
144
  },
145
145
  ];
146
146
  let num = 0;
147
+ const Test1=({formNode})=>{
148
+ useEffect(() => {
149
+ console.log("渲染")
150
+ }, []);
151
+ return <div>
152
+ <div>测试一些</div>
153
+ {formNode}
154
+ </div>
155
+ }
147
156
  export default () => {
148
157
  const modalForm = useHDialogForm();
149
158
  return (
@@ -190,33 +199,14 @@ export default () => {
190
199
  configData={data}
191
200
  labelWidth={88}
192
201
  labelAlign={"left"}
193
- footer={(dialogForm, loading, params = {}) => {
194
- const { name } = params;
195
- return (
196
- <Button
197
- loading={loading}
198
- onClick={() => {
199
- dialogForm?.submit();
200
- }}
201
- >
202
- {name}
203
- </Button>
204
- );
205
- }}
206
202
  request={(values, params) => {
207
203
  console.log(values, params);
208
204
  }}
209
- contentRender={(node, form) => {
210
- return (
211
- <div>
212
- <div>测试一些</div>
213
- {node}
214
- </div>
215
- );
216
- }}
217
205
  dialogForm={modalForm}
218
206
  title={<div>fff</div>}
219
- />
207
+ >
208
+ <Test1/>
209
+ </HModalForm>
220
210
  </HFormConfigProvider>
221
211
  </>
222
212
  );