@hw-component/form 0.0.2-bate → 0.0.2-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 (112) hide show
  1. package/es/CheckboxGroup/index.d.ts +1 -1
  2. package/es/CheckboxGroup/index.js +4 -2
  3. package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
  4. package/es/DialogForm/DrawerForm/Footer.js +23 -0
  5. package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
  6. package/es/DialogForm/DrawerForm/Title.js +18 -0
  7. package/es/DialogForm/DrawerForm/index.d.ts +4 -0
  8. package/es/DialogForm/DrawerForm/index.js +111 -0
  9. package/es/DialogForm/ModalForm.d.ts +4 -0
  10. package/es/DialogForm/ModalForm.js +89 -0
  11. package/es/DialogForm/hooks.d.ts +14 -0
  12. package/es/DialogForm/hooks.js +124 -0
  13. package/es/DialogForm/modal.d.ts +25 -0
  14. package/es/Form/HFormConnect.d.ts +1 -2
  15. package/es/Form/HFormConnect.js +17 -16
  16. package/es/Form/InitSet.d.ts +1 -4
  17. package/es/Form/InitSet.js +2 -3
  18. package/es/Form/config.d.ts +5 -4
  19. package/es/Form/config.js +6 -4
  20. package/es/Form/hooks/index.d.ts +0 -6
  21. package/es/Form/hooks/index.js +1 -33
  22. package/es/Form/hooks/useHForm.js +72 -15
  23. package/es/Form/index.js +46 -15
  24. package/es/Form/modal.d.ts +20 -8
  25. package/es/Input/SelectInput.d.ts +2 -2
  26. package/es/Input/SelectInput.js +8 -5
  27. package/es/Input/modal.d.ts +2 -0
  28. package/es/Select/hooks/norHooks.d.ts +1 -1
  29. package/es/TDPicker/RangePicker.d.ts +1 -1
  30. package/es/TDPicker/RangePicker.js +4 -2
  31. package/es/TextArea/index.js +21 -0
  32. package/es/Upload/UrlUpload/index.d.ts +2 -2
  33. package/es/Upload/UrlUpload/index.js +3 -3
  34. package/es/Upload/hooks/customRequest.js +99 -36
  35. package/es/Upload/index.d.ts +1 -2
  36. package/es/Upload/index.js +40 -5
  37. package/es/Upload/modal.d.ts +2 -0
  38. package/es/config.js +4 -4
  39. package/es/index.css +1 -1
  40. package/es/index.d.ts +8 -4
  41. package/es/index.js +7 -1
  42. package/lib/CheckboxGroup/index.d.ts +1 -1
  43. package/lib/CheckboxGroup/index.js +4 -2
  44. package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
  45. package/lib/DialogForm/DrawerForm/Footer.js +26 -0
  46. package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
  47. package/lib/DialogForm/DrawerForm/Title.js +21 -0
  48. package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
  49. package/lib/DialogForm/DrawerForm/index.js +114 -0
  50. package/lib/DialogForm/ModalForm.d.ts +4 -0
  51. package/lib/DialogForm/ModalForm.js +92 -0
  52. package/lib/DialogForm/hooks.d.ts +14 -0
  53. package/lib/DialogForm/hooks.js +128 -0
  54. package/lib/DialogForm/modal.d.ts +25 -0
  55. package/lib/Form/HFormConnect.d.ts +1 -2
  56. package/lib/Form/HFormConnect.js +17 -16
  57. package/lib/Form/InitSet.d.ts +1 -4
  58. package/lib/Form/InitSet.js +2 -3
  59. package/lib/Form/config.d.ts +5 -4
  60. package/lib/Form/config.js +3 -1
  61. package/lib/Form/hooks/index.d.ts +0 -6
  62. package/lib/Form/hooks/index.js +0 -33
  63. package/lib/Form/hooks/useHForm.js +72 -15
  64. package/lib/Form/index.js +53 -22
  65. package/lib/Form/modal.d.ts +20 -8
  66. package/lib/Input/SelectInput.d.ts +2 -2
  67. package/lib/Input/SelectInput.js +8 -5
  68. package/lib/Input/modal.d.ts +2 -0
  69. package/lib/Select/hooks/norHooks.d.ts +1 -1
  70. package/lib/TDPicker/RangePicker.d.ts +1 -1
  71. package/lib/TDPicker/RangePicker.js +4 -2
  72. package/lib/TextArea/index.js +24 -0
  73. package/lib/Upload/UrlUpload/index.d.ts +2 -2
  74. package/lib/Upload/UrlUpload/index.js +3 -3
  75. package/lib/Upload/hooks/customRequest.js +99 -36
  76. package/lib/Upload/index.d.ts +1 -2
  77. package/lib/Upload/index.js +40 -5
  78. package/lib/Upload/modal.d.ts +2 -0
  79. package/lib/config.js +4 -4
  80. package/lib/index.css +1 -1
  81. package/lib/index.d.ts +8 -4
  82. package/lib/index.js +10 -0
  83. package/package.json +1 -1
  84. package/src/components/CheckboxGroup/index.tsx +2 -2
  85. package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
  86. package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
  87. package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
  88. package/src/components/DialogForm/ModalForm.tsx +60 -0
  89. package/src/components/DialogForm/hooks.ts +87 -0
  90. package/src/components/DialogForm/modal.ts +27 -0
  91. package/src/components/Form/FormItem/Helper.tsx +3 -4
  92. package/src/components/Form/HFormConnect.tsx +26 -8
  93. package/src/components/Form/InitSet.tsx +3 -5
  94. package/src/components/Form/config.ts +2 -1
  95. package/src/components/Form/hooks/index.ts +0 -20
  96. package/src/components/Form/hooks/useHForm.ts +67 -14
  97. package/src/components/Form/index.less +1 -1
  98. package/src/components/Form/index.tsx +25 -7
  99. package/src/components/Form/modal.ts +22 -10
  100. package/src/components/Input/SelectInput.tsx +4 -2
  101. package/src/components/Input/modal.ts +2 -0
  102. package/src/components/TDPicker/RangePicker.tsx +5 -6
  103. package/src/components/Upload/UrlUpload/index.tsx +2 -2
  104. package/src/components/Upload/hooks/customRequest.ts +57 -14
  105. package/src/components/Upload/index.tsx +40 -7
  106. package/src/components/Upload/modal.ts +2 -0
  107. package/src/components/config.ts +4 -4
  108. package/src/components/index.tsx +6 -0
  109. package/src/pages/DrawerForm/index.tsx +127 -0
  110. package/src/pages/Form/index.tsx +3 -0
  111. package/src/pages/ModalForm/index.tsx +127 -0
  112. package/src/routes.tsx +12 -0
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
- declare const _default: (props: import("../Form/modal").HFormItemProps) => React.ReactElement<import("../Form/modal").ConnectResultProps, string | React.JSXElementConstructor<any>>;
2
+ declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
3
3
  export default _default;
@@ -50,7 +50,8 @@ var Index = function Index(_ref) {
50
50
  addFormat === null || addFormat === void 0 ? void 0 : addFormat({
51
51
  "float": {
52
52
  inputValue: function inputValue(item, initValue) {
53
- var name = item.name;
53
+ var _item$name = item.name,
54
+ name = _item$name === void 0 ? "" : _item$name;
54
55
  var keys = checkOptions === null || checkOptions === void 0 ? void 0 : _mapInstanceProperty(checkOptions).call(checkOptions, function (optItem) {
55
56
  return optItem.value;
56
57
  });
@@ -61,7 +62,8 @@ var Index = function Index(_ref) {
61
62
  return _defineProperty({}, name, resultObj);
62
63
  },
63
64
  outputValue: function outputValue(item, _outputValue) {
64
- var name = item.name;
65
+ var _item$name2 = item.name,
66
+ name = _item$name2 === void 0 ? "" : _item$name2;
65
67
  var _outputValue$name = _outputValue[name],
66
68
  itemVal = _outputValue$name === void 0 ? {} : _outputValue$name;
67
69
  return _objectSpread({}, itemVal);
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { DialogFormProps } from "../modal";
3
+ declare const _default: ({ onCancel, onOk, confirmLoading, }: Omit<DialogFormProps, "configData">) => JSX.Element;
4
+ export default _default;
@@ -0,0 +1,23 @@
1
+ // welcome to hoo hoo hoo
2
+ import React from 'react';
3
+ import { Row, Space, Button } from 'antd';
4
+
5
+ var Footer = (function (_ref) {
6
+ var onCancel = _ref.onCancel,
7
+ onOk = _ref.onOk,
8
+ confirmLoading = _ref.confirmLoading;
9
+ return /*#__PURE__*/React.createElement(Row, {
10
+ justify: "end"
11
+ }, /*#__PURE__*/React.createElement(Space, {
12
+ size: "middle"
13
+ }, /*#__PURE__*/React.createElement(Button, {
14
+ onClick: onCancel
15
+ }, "\u5173\u95ED"), /*#__PURE__*/React.createElement(Button, {
16
+ type: "primary",
17
+ onClick: onOk,
18
+ loading: confirmLoading
19
+ }, "\u786E\u5B9A")));
20
+ });
21
+
22
+ export { Footer as default };
23
+ // powered by hdj
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { ModalProps } from "antd";
3
+ declare const _default: ({ title, closable, onCancel }: ModalProps) => JSX.Element;
4
+ export default _default;
@@ -0,0 +1,18 @@
1
+ // welcome to hoo hoo hoo
2
+ import React from 'react';
3
+ import { Row } from 'antd';
4
+ import { CloseOutlined } from '@ant-design/icons';
5
+
6
+ var Title = (function (_ref) {
7
+ var title = _ref.title,
8
+ closable = _ref.closable,
9
+ onCancel = _ref.onCancel;
10
+ return /*#__PURE__*/React.createElement(Row, {
11
+ justify: "space-between"
12
+ }, /*#__PURE__*/React.createElement("div", null, title), closable && /*#__PURE__*/React.createElement(CloseOutlined, {
13
+ onClick: onCancel
14
+ }));
15
+ });
16
+
17
+ export { Title as default };
18
+ // powered by hdj
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { DialogFormProps } from "../modal";
3
+ declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: DialogFormProps) => JSX.Element;
4
+ export default _default;
@@ -0,0 +1,111 @@
1
+ // welcome to hoo hoo hoo
2
+ import React from 'react';
3
+ import _extends from '@babel/runtime-corejs3/helpers/extends';
4
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
5
+ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
6
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
7
+ import { Drawer } from 'antd';
8
+ import { useCurrentForm, useModifyProps, useSub } from '../hooks.js';
9
+ import HForm from '../../Form/index.js';
10
+ import Title from './Title.js';
11
+ import Footer from './Footer.js';
12
+
13
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer"];
14
+ var DrawerForm = (function (_ref) {
15
+ var visible = _ref.visible,
16
+ title = _ref.title,
17
+ onCancel = _ref.onCancel,
18
+ configData = _ref.configData,
19
+ infoRequest = _ref.infoRequest,
20
+ request = _ref.request;
21
+ _ref.afterClose;
22
+ var dialogForm = _ref.dialogForm,
23
+ _ref$closable = _ref.closable,
24
+ closable = _ref$closable === void 0 ? true : _ref$closable,
25
+ _ref$initialValues = _ref.initialValues,
26
+ initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
27
+ labelWidth = _ref.labelWidth;
28
+ _ref.onOk;
29
+ var onFinish = _ref.onFinish;
30
+ _ref.size;
31
+ _ref.form;
32
+ var footer = _ref.footer,
33
+ props = _objectWithoutProperties(_ref, _excluded);
34
+ var currentForm = useCurrentForm(dialogForm);
35
+ var _useModifyProps = useModifyProps({
36
+ configData: configData,
37
+ visible: visible,
38
+ initialValues: initialValues,
39
+ dialogForm: currentForm
40
+ }),
41
+ modalVisible = _useModifyProps.modalVisible,
42
+ modalFormData = _useModifyProps.modalFormData,
43
+ setModalVisible = _useModifyProps.setModalVisible,
44
+ initValue = _useModifyProps.initValue,
45
+ onAfterClose = _useModifyProps.onAfterClose;
46
+ var cancel = function cancel(e) {
47
+ onAfterClose();
48
+ if (onCancel) {
49
+ return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
50
+ }
51
+ setModalVisible(false);
52
+ };
53
+ var _useSub = useSub({
54
+ request: request,
55
+ onFinish: onFinish
56
+ }),
57
+ loading = _useSub.loading,
58
+ run = _useSub.run;
59
+ var footerComponent = function footerComponent() {
60
+ if (footer === null) {
61
+ return null;
62
+ }
63
+ return footer || /*#__PURE__*/React.createElement(Footer, {
64
+ onCancel: cancel,
65
+ onOk: currentForm.submit,
66
+ confirmLoading: loading
67
+ });
68
+ };
69
+ return /*#__PURE__*/React.createElement(Drawer, _extends({
70
+ visible: modalVisible,
71
+ title: /*#__PURE__*/React.createElement(Title, {
72
+ title: title,
73
+ closable: closable,
74
+ onCancel: cancel
75
+ })
76
+ }, props, {
77
+ onClose: cancel,
78
+ closable: false,
79
+ destroyOnClose: true,
80
+ footer: footerComponent()
81
+ }), /*#__PURE__*/React.createElement(HForm, _extends({
82
+ configData: modalFormData,
83
+ initialValues: initValue
84
+ }, props, {
85
+ form: currentForm,
86
+ onFinish: /*#__PURE__*/function () {
87
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
88
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
89
+ while (1) switch (_context.prev = _context.next) {
90
+ case 0:
91
+ _context.next = 2;
92
+ return run(values);
93
+ case 2:
94
+ setModalVisible(false);
95
+ case 3:
96
+ case "end":
97
+ return _context.stop();
98
+ }
99
+ }, _callee);
100
+ }));
101
+ return function (_x) {
102
+ return _ref2.apply(this, arguments);
103
+ };
104
+ }(),
105
+ infoRequest: infoRequest,
106
+ labelWidth: labelWidth
107
+ })));
108
+ });
109
+
110
+ export { DrawerForm as default };
111
+ // powered by hdj
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { DialogFormProps } from "./modal";
3
+ declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: DialogFormProps) => JSX.Element;
4
+ export default _default;
@@ -0,0 +1,89 @@
1
+ // welcome to hoo hoo hoo
2
+ import React from 'react';
3
+ import _extends from '@babel/runtime-corejs3/helpers/extends';
4
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
5
+ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
6
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
7
+ import { Modal } from 'antd';
8
+ import HForm from '../Form/index.js';
9
+ import { useCurrentForm, useModifyProps, useSub } from './hooks.js';
10
+
11
+ var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish"];
12
+ var ModalForm = (function (_ref) {
13
+ var visible = _ref.visible,
14
+ title = _ref.title,
15
+ onCancel = _ref.onCancel,
16
+ configData = _ref.configData,
17
+ infoRequest = _ref.infoRequest,
18
+ request = _ref.request,
19
+ _afterClose = _ref.afterClose,
20
+ dialogForm = _ref.dialogForm,
21
+ _ref$initialValues = _ref.initialValues,
22
+ initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
23
+ onFinish = _ref.onFinish,
24
+ props = _objectWithoutProperties(_ref, _excluded);
25
+ var currentForm = useCurrentForm(dialogForm);
26
+ var _useModifyProps = useModifyProps({
27
+ configData: configData,
28
+ visible: visible,
29
+ initialValues: initialValues,
30
+ dialogForm: currentForm
31
+ }),
32
+ modalVisible = _useModifyProps.modalVisible,
33
+ modalFormData = _useModifyProps.modalFormData,
34
+ setModalVisible = _useModifyProps.setModalVisible,
35
+ initValue = _useModifyProps.initValue;
36
+ var cancel = function cancel(e) {
37
+ if (onCancel) {
38
+ return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
39
+ }
40
+ setModalVisible(false);
41
+ };
42
+ var _useSub = useSub({
43
+ request: request,
44
+ onFinish: onFinish
45
+ }),
46
+ loading = _useSub.loading,
47
+ run = _useSub.run;
48
+ return /*#__PURE__*/React.createElement(Modal, _extends({
49
+ title: title,
50
+ visible: modalVisible,
51
+ onCancel: cancel,
52
+ confirmLoading: loading,
53
+ afterClose: function afterClose() {
54
+ currentForm.resetFields();
55
+ _afterClose === null || _afterClose === void 0 ? void 0 : _afterClose();
56
+ }
57
+ }, props, {
58
+ onOk: currentForm.submit,
59
+ destroyOnClose: true
60
+ }), /*#__PURE__*/React.createElement(HForm, _extends({
61
+ configData: modalFormData,
62
+ initialValues: initValue,
63
+ onFinish: /*#__PURE__*/function () {
64
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
65
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
66
+ while (1) switch (_context.prev = _context.next) {
67
+ case 0:
68
+ _context.next = 2;
69
+ return run(values);
70
+ case 2:
71
+ setModalVisible(false);
72
+ case 3:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }, _callee);
77
+ }));
78
+ return function (_x) {
79
+ return _ref2.apply(this, arguments);
80
+ };
81
+ }()
82
+ }, props, {
83
+ form: currentForm,
84
+ infoRequest: infoRequest
85
+ })));
86
+ });
87
+
88
+ export { ModalForm as default };
89
+ // powered by hdj
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
+ export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, }: ModifyPropsModal) => {
4
+ modalFormData: import("../Form/modal").HItemProps[];
5
+ modalVisible: boolean | undefined;
6
+ setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
7
+ setModalFormData: import("react").Dispatch<import("react").SetStateAction<import("../Form/modal").HItemProps[]>>;
8
+ initValue: Record<string, any> | undefined;
9
+ setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
10
+ onAfterClose: () => void;
11
+ };
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]>;
@@ -0,0 +1,124 @@
1
+ // welcome to hoo hoo hoo
2
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
3
+ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
4
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
5
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
6
+ import _setTimeout from '@babel/runtime-corejs3/core-js/set-timeout';
7
+ import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
8
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
9
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
10
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
11
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
12
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
13
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
14
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
15
+ import { useMemo, useState, useEffect } from 'react';
16
+ import useHForm from '../Form/hooks/useHForm.js';
17
+ import { useRequest } from 'ahooks';
18
+
19
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+ var useModifyProps = function useModifyProps(_ref) {
22
+ var visible = _ref.visible,
23
+ configData = _ref.configData,
24
+ initialValues = _ref.initialValues,
25
+ dialogForm = _ref.dialogForm,
26
+ afterClose = _ref.afterClose;
27
+ var _useState = useState(visible),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ modalVisible = _useState2[0],
30
+ setModalVisible = _useState2[1];
31
+ var _useState3 = useState(configData),
32
+ _useState4 = _slicedToArray(_useState3, 2),
33
+ modalFormData = _useState4[0],
34
+ setModalFormData = _useState4[1];
35
+ var _useState5 = useState(initialValues),
36
+ _useState6 = _slicedToArray(_useState5, 2),
37
+ initValue = _useState6[0],
38
+ setInitValue = _useState6[1];
39
+ var onAfterClose = function onAfterClose() {
40
+ _setTimeout(function () {
41
+ dialogForm.resetFields();
42
+ afterClose === null || afterClose === void 0 ? void 0 : afterClose();
43
+ }, 0);
44
+ };
45
+ useEffect(function () {
46
+ setModalVisible(visible);
47
+ }, [visible]);
48
+ useEffect(function () {
49
+ setModalFormData(configData);
50
+ }, [configData]);
51
+ useEffect(function () {
52
+ dialogForm.show = function () {
53
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
+ var changeConfigData = params.configData,
55
+ changeInitialValues = params.initialValues;
56
+ if (!!changeConfigData) {
57
+ setModalFormData(changeConfigData);
58
+ }
59
+ setInitValue(changeInitialValues);
60
+ setModalVisible(true);
61
+ };
62
+ dialogForm.hide = function () {
63
+ setModalVisible(false);
64
+ onAfterClose();
65
+ };
66
+ }, [afterClose]);
67
+ return {
68
+ modalFormData: modalFormData,
69
+ modalVisible: modalVisible,
70
+ setModalVisible: setModalVisible,
71
+ setModalFormData: setModalFormData,
72
+ initValue: initValue,
73
+ setInitValue: setInitValue,
74
+ onAfterClose: onAfterClose
75
+ };
76
+ };
77
+ var useHDialogForm = function useHDialogForm() {
78
+ var hForm = useHForm();
79
+ return useMemo(function () {
80
+ return _objectSpread(_objectSpread({}, hForm), {}, {
81
+ show: function show(params) {},
82
+ hide: function hide() {}
83
+ });
84
+ }, []);
85
+ };
86
+ var useCurrentForm = function useCurrentForm(hDialogForm) {
87
+ var defaultHModalForm = useHDialogForm();
88
+ return hDialogForm || defaultHModalForm;
89
+ };
90
+ var useSub = function useSub(_ref2) {
91
+ var request = _ref2.request,
92
+ onFinish = _ref2.onFinish;
93
+ return useRequest( /*#__PURE__*/function () {
94
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
95
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
96
+ while (1) switch (_context.prev = _context.next) {
97
+ case 0:
98
+ if (!onFinish) {
99
+ _context.next = 2;
100
+ break;
101
+ }
102
+ return _context.abrupt("return", onFinish(values));
103
+ case 2:
104
+ if (!request) {
105
+ _context.next = 4;
106
+ break;
107
+ }
108
+ return _context.abrupt("return", request(values));
109
+ case 4:
110
+ case "end":
111
+ return _context.stop();
112
+ }
113
+ }, _callee);
114
+ }));
115
+ return function (_x) {
116
+ return _ref3.apply(this, arguments);
117
+ };
118
+ }(), {
119
+ manual: true
120
+ });
121
+ };
122
+
123
+ export { useCurrentForm, useHDialogForm, useModifyProps, useSub };
124
+ // powered by hdj
@@ -0,0 +1,25 @@
1
+ import type { ModalProps } from "antd";
2
+ import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
3
+ import type { PromiseFnResult } from "../modal";
4
+ type RootProps = HFormProps & ModalProps;
5
+ export interface ModifyPropsModal {
6
+ configData: HItemProps[];
7
+ visible?: boolean;
8
+ initialValues?: Record<string, any>;
9
+ dialogForm: HDialogFormInstance;
10
+ afterClose?: VoidFunction;
11
+ }
12
+ export interface ShowParamsModal {
13
+ configData?: HItemProps[];
14
+ visible?: boolean;
15
+ initialValues?: Record<string, any>;
16
+ }
17
+ export interface HDialogFormInstance extends HFormInstance {
18
+ show: (data?: ShowParamsModal) => void;
19
+ hide: VoidFunction;
20
+ }
21
+ export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
22
+ dialogForm?: HDialogFormInstance;
23
+ onFinish?: PromiseFnResult;
24
+ }
25
+ export {};
@@ -1,6 +1,5 @@
1
1
  import type { HFormItemProps } from "@/components/Form/modal";
2
2
  import React from "react";
3
3
  import type { ConnectConfigModal } from "@/components/Form/modal";
4
- import type { ConnectResultProps } from "@/components/Form/modal";
5
- declare const _default: (Component: React.FunctionComponent | React.ComponentClass, config?: ConnectConfigModal) => (props: HFormItemProps) => React.ReactElement<ConnectResultProps, string | React.JSXElementConstructor<any>>;
4
+ declare const _default: (component: React.FunctionComponent | React.ComponentClass | React.ForwardRefRenderFunction<any, any>, config?: ConnectConfigModal) => React.ForwardRefExoticComponent<HFormItemProps & React.RefAttributes<any>>;
6
5
  export default _default;
@@ -1,18 +1,8 @@
1
1
  // welcome to hoo hoo hoo
2
- import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
3
- import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
4
- import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
5
- import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
6
- import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
7
- import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
8
- import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
9
- import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
10
- import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
2
+ import _extends from '@babel/runtime-corejs3/helpers/extends';
11
3
  import { useFormContext } from './Context/index.js';
12
4
  import React, { useEffect } from 'react';
13
5
 
14
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
16
6
  var formatMaker = function formatMaker(itemProps, formats) {
17
7
  if (!formats) {
18
8
  return formats;
@@ -28,12 +18,13 @@ var formatMaker = function formatMaker(itemProps, formats) {
28
18
  }
29
19
  };
30
20
  };
31
- var HFormConnect = (function (Component) {
21
+ var HFormConnect = (function (component) {
32
22
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
33
23
  var _config$format = config.format,
34
24
  format = _config$format === void 0 ? {} : _config$format;
35
- return function (props) {
36
- var name = props.name;
25
+ var Index = function Index(props, ref) {
26
+ var _props$name = props.name,
27
+ name = _props$name === void 0 ? "" : _props$name;
37
28
  var _useFormContext = useFormContext(),
38
29
  form = _useFormContext.form,
39
30
  _useFormContext$value = _useFormContext.valueType,
@@ -44,10 +35,20 @@ var HFormConnect = (function (Component) {
44
35
  var addFormat = function addFormat(aFormat) {
45
36
  form === null || form === void 0 ? void 0 : form.addFormat(name, formatMaker(props, aFormat[valueType]));
46
37
  };
47
- return /*#__PURE__*/React.createElement(Component, _objectSpread(_objectSpread({}, props), {}, {
48
- addFormat: addFormat
38
+ var addDispatchListener = function addDispatchListener(key, fn) {
39
+ form === null || form === void 0 ? void 0 : form.addDispatchListener({
40
+ key: key,
41
+ name: name
42
+ }, fn);
43
+ };
44
+ var Component = component;
45
+ return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
46
+ addFormat: addFormat,
47
+ addDispatchListener: addDispatchListener,
48
+ ref: ref
49
49
  }));
50
50
  };
51
+ return /*#__PURE__*/React.forwardRef(Index);
51
52
  });
52
53
 
53
54
  export { HFormConnect as default };
@@ -1,6 +1,3 @@
1
1
  /// <reference types="react" />
2
- interface InitSetProps {
3
- initValues?: Record<string, any>;
4
- }
5
- declare const _default: ({ initValues }: InitSetProps) => JSX.Element;
2
+ declare const _default: () => JSX.Element;
6
3
  export default _default;
@@ -2,12 +2,11 @@
2
2
  import React, { useEffect } from 'react';
3
3
  import { useFormContext } from './Context/index.js';
4
4
 
5
- var InitSet = (function (_ref) {
6
- var initValues = _ref.initValues;
5
+ var InitSet = (function () {
7
6
  var _useFormContext = useFormContext(),
8
7
  form = _useFormContext.form;
9
8
  useEffect(function () {
10
- form.initValues(initValues);
9
+ form.initValues();
11
10
  }, []);
12
11
  return /*#__PURE__*/React.createElement(React.Fragment, null);
13
12
  });
@@ -6,23 +6,24 @@ export declare const placeholderConfig: {
6
6
  declare const _default: {
7
7
  select: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("../Select/modal").HSelectProps) => JSX.Element;
8
8
  inputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
9
- selectInput: ({ selectProps, value, onChange, valueName, ...props }: import("../Input/modal").HSelectInputProps) => JSX.Element;
9
+ selectInput: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
10
10
  buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
11
- checkboxGroup: (props: import("./modal").HFormItemProps) => import("react").ReactElement<import("./modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
11
+ checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
12
12
  checkBox: import("react").FC<import("../CheckboxGroup/modal").HCheckboxProps>;
13
13
  radioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("../RadioGroup").HRadioGroupProps) => JSX.Element;
14
14
  switch: import("react").FC<import("../Switch").HSwitchProps>;
15
15
  datePicker: ({ value, onChange, showTime, format, ...props }: import("../TDPicker/modal").HDatePickerProps) => JSX.Element;
16
16
  rangePicker: {
17
- Component: ({ value, onChange, showTime, format, valueMap, ranges, name, ...props }: import("../TDPicker/modal").HRangePickerProps) => JSX.Element;
17
+ Component: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
18
18
  placeholder: ({ label }: import("./modal").HItemProps) => string[];
19
19
  requiredErrMsg: ({ label }: import("./modal").HItemProps) => string;
20
20
  };
21
21
  timePicker: ({ value, format, onChange, ...props }: import("../TDPicker/modal").HTimePickerProps) => JSX.Element;
22
22
  input: ({ ...props }: import("antd").InputProps) => JSX.Element;
23
- upload: import("react").ForwardRefExoticComponent<import("../Upload/modal").IUpLoadProps & import("react").RefAttributes<import("../Upload/modal").IUploadRefModal>>;
23
+ upload: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
24
24
  urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
25
25
  submit: ({ text, type, form, loading, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
26
26
  formConfigProvider: import("react").FC<import("./modal").IFormConfigContextProps>;
27
+ textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
27
28
  };
28
29
  export default _default;
package/es/Form/config.js CHANGED
@@ -12,9 +12,10 @@ import HDatePicker from '../TDPicker/index.js';
12
12
  import HRangePicker from '../TDPicker/RangePicker.js';
13
13
  import HTimePicker from '../TDPicker/TimePicker.js';
14
14
  import HUpload from '../Upload/index.js';
15
- import HUrlUpload from '../Upload/UrlUpload/index.js';
15
+ import Index$3 from '../Upload/UrlUpload/index.js';
16
16
  import HSubmit from '../Submit/index.js';
17
- import Index$3 from './Context/FormConfigProvider.js';
17
+ import Index$4 from './Context/FormConfigProvider.js';
18
+ import TextArea from '../TextArea/index.js';
18
19
 
19
20
  var placeholderConfig = {
20
21
  inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
@@ -34,9 +35,10 @@ var FormConfig = {
34
35
  timePicker: HTimePicker,
35
36
  input: HInput,
36
37
  upload: HUpload,
37
- urlUpload: HUrlUpload,
38
+ urlUpload: Index$3,
38
39
  submit: HSubmit,
39
- formConfigProvider: Index$3
40
+ formConfigProvider: Index$4,
41
+ textArea: TextArea
40
42
  };
41
43
 
42
44
  export { FormConfig as default, placeholderConfig };
@@ -3,10 +3,4 @@ import type { HFormInstance } from "@/components/Form/modal";
3
3
  export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
4
4
  type ParamsModal = Omit<HFormProps, "configData">;
5
5
  export declare const useSub: ({ request, onFinish, form }: ParamsModal) => import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
6
- export declare const useInit: ({ infoRequest, initialValues }: ParamsModal) => {
7
- infoRun: () => Promise<any>;
8
- infoLoading: boolean;
9
- infoErr: Error | undefined;
10
- infoData: any;
11
- };
12
6
  export {};