@hw-component/form 0.0.1-beta-v2 → 0.0.1-beta-v3
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.
- package/es/ModalForm/hooks.d.ts +1 -1
- package/es/ModalForm/hooks.js +16 -1
- package/es/ModalForm/index.js +9 -22
- package/es/ModalForm/modal.d.ts +4 -1
- package/lib/ModalForm/hooks.d.ts +1 -1
- package/lib/ModalForm/hooks.js +16 -1
- package/lib/ModalForm/index.js +7 -20
- package/lib/ModalForm/modal.d.ts +4 -1
- package/package.json +1 -1
- package/src/components/ModalForm/hooks.ts +17 -1
- package/src/components/ModalForm/index.tsx +3 -20
- package/src/components/ModalForm/modal.ts +4 -1
package/es/ModalForm/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HModalFormInstance, ModifyPropsModal } from "@/components/ModalForm/modal";
|
|
3
|
-
export declare const useModifyProps: ({ visible, configData, initialValues, }: ModifyPropsModal) => {
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, modalForm }: ModifyPropsModal) => {
|
|
4
4
|
modalFormData: import("../Form/modal").HItemProps[];
|
|
5
5
|
modalVisible: boolean | undefined;
|
|
6
6
|
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
package/es/ModalForm/hooks.js
CHANGED
|
@@ -17,7 +17,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
17
17
|
var useModifyProps = function useModifyProps(_ref) {
|
|
18
18
|
var visible = _ref.visible,
|
|
19
19
|
configData = _ref.configData,
|
|
20
|
-
initialValues = _ref.initialValues
|
|
20
|
+
initialValues = _ref.initialValues,
|
|
21
|
+
modalForm = _ref.modalForm;
|
|
21
22
|
var _useState = useState(visible),
|
|
22
23
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
24
|
modalVisible = _useState2[0],
|
|
@@ -36,6 +37,20 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
36
37
|
useEffect(function () {
|
|
37
38
|
setModalFormData(configData);
|
|
38
39
|
}, [configData]);
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
modalForm.show = function (_ref2) {
|
|
42
|
+
var changeConfigData = _ref2.configData,
|
|
43
|
+
changeInitialValues = _ref2.initialValues;
|
|
44
|
+
if (!!changeConfigData) {
|
|
45
|
+
setModalFormData(changeConfigData);
|
|
46
|
+
}
|
|
47
|
+
setInitValue(changeInitialValues);
|
|
48
|
+
setModalVisible(true);
|
|
49
|
+
};
|
|
50
|
+
modalForm.hide = function () {
|
|
51
|
+
setModalVisible(false);
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
39
54
|
return {
|
|
40
55
|
modalFormData: modalFormData,
|
|
41
56
|
modalVisible: modalVisible,
|
package/es/ModalForm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
5
|
import { Modal } from 'antd';
|
|
6
6
|
import HForm from '../Form/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import { useCurrentForm, useModifyProps } from './hooks.js';
|
|
8
8
|
|
|
9
9
|
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "modalForm", "initialValues"];
|
|
10
10
|
var ModalForm = (function (_ref) {
|
|
@@ -19,32 +19,17 @@ var ModalForm = (function (_ref) {
|
|
|
19
19
|
_ref$initialValues = _ref.initialValues,
|
|
20
20
|
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
21
21
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var currentForm = useCurrentForm(modalForm);
|
|
22
23
|
var _useModifyProps = useModifyProps({
|
|
23
24
|
configData: configData,
|
|
24
25
|
visible: visible,
|
|
25
|
-
initialValues: initialValues
|
|
26
|
+
initialValues: initialValues,
|
|
27
|
+
modalForm: currentForm
|
|
26
28
|
}),
|
|
27
29
|
modalVisible = _useModifyProps.modalVisible,
|
|
28
30
|
modalFormData = _useModifyProps.modalFormData,
|
|
29
31
|
setModalVisible = _useModifyProps.setModalVisible,
|
|
30
|
-
|
|
31
|
-
initValue = _useModifyProps.initValue,
|
|
32
|
-
setInitValue = _useModifyProps.setInitValue;
|
|
33
|
-
var currentForm = useCurrentForm(modalForm);
|
|
34
|
-
useEffect(function () {
|
|
35
|
-
currentForm.show = function (_ref2) {
|
|
36
|
-
var changeConfigData = _ref2.configData,
|
|
37
|
-
changeInitialValues = _ref2.initialValues;
|
|
38
|
-
if (!!changeConfigData) {
|
|
39
|
-
setModalFormData(changeConfigData);
|
|
40
|
-
}
|
|
41
|
-
setInitValue(changeInitialValues);
|
|
42
|
-
setModalVisible(true);
|
|
43
|
-
};
|
|
44
|
-
currentForm.hide = function () {
|
|
45
|
-
setModalVisible(false);
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
32
|
+
initValue = _useModifyProps.initValue;
|
|
48
33
|
var cancel = function cancel(e) {
|
|
49
34
|
if (onCancel) {
|
|
50
35
|
return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
|
|
@@ -59,7 +44,9 @@ var ModalForm = (function (_ref) {
|
|
|
59
44
|
currentForm.resetFields();
|
|
60
45
|
_afterClose === null || _afterClose === void 0 ? void 0 : _afterClose();
|
|
61
46
|
}
|
|
62
|
-
}, props
|
|
47
|
+
}, props, {
|
|
48
|
+
destroyOnClose: true
|
|
49
|
+
}), /*#__PURE__*/React.createElement(HForm, _extends({
|
|
63
50
|
configData: modalFormData,
|
|
64
51
|
initialValues: initValue
|
|
65
52
|
}, props, {
|
package/es/ModalForm/modal.d.ts
CHANGED
|
@@ -6,8 +6,11 @@ export interface ModifyPropsModal {
|
|
|
6
6
|
configData: HItemProps[];
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
initialValues?: Record<string, any>;
|
|
9
|
+
modalForm: HModalFormInstance;
|
|
9
10
|
}
|
|
10
|
-
export interface ShowParamsModal
|
|
11
|
+
export interface ShowParamsModal {
|
|
12
|
+
configData?: HItemProps[];
|
|
13
|
+
visible?: boolean;
|
|
11
14
|
initialValues?: Record<string, any>;
|
|
12
15
|
}
|
|
13
16
|
export interface HModalFormInstance extends HFormInstance {
|
package/lib/ModalForm/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HModalFormInstance, ModifyPropsModal } from "@/components/ModalForm/modal";
|
|
3
|
-
export declare const useModifyProps: ({ visible, configData, initialValues, }: ModifyPropsModal) => {
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, modalForm }: ModifyPropsModal) => {
|
|
4
4
|
modalFormData: import("../Form/modal").HItemProps[];
|
|
5
5
|
modalVisible: boolean | undefined;
|
|
6
6
|
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
package/lib/ModalForm/hooks.js
CHANGED
|
@@ -18,7 +18,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
18
|
var useModifyProps = function useModifyProps(_ref) {
|
|
19
19
|
var visible = _ref.visible,
|
|
20
20
|
configData = _ref.configData,
|
|
21
|
-
initialValues = _ref.initialValues
|
|
21
|
+
initialValues = _ref.initialValues,
|
|
22
|
+
modalForm = _ref.modalForm;
|
|
22
23
|
var _useState = React.useState(visible),
|
|
23
24
|
_useState2 = _slicedToArray(_useState, 2),
|
|
24
25
|
modalVisible = _useState2[0],
|
|
@@ -37,6 +38,20 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
37
38
|
React.useEffect(function () {
|
|
38
39
|
setModalFormData(configData);
|
|
39
40
|
}, [configData]);
|
|
41
|
+
React.useEffect(function () {
|
|
42
|
+
modalForm.show = function (_ref2) {
|
|
43
|
+
var changeConfigData = _ref2.configData,
|
|
44
|
+
changeInitialValues = _ref2.initialValues;
|
|
45
|
+
if (!!changeConfigData) {
|
|
46
|
+
setModalFormData(changeConfigData);
|
|
47
|
+
}
|
|
48
|
+
setInitValue(changeInitialValues);
|
|
49
|
+
setModalVisible(true);
|
|
50
|
+
};
|
|
51
|
+
modalForm.hide = function () {
|
|
52
|
+
setModalVisible(false);
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
40
55
|
return {
|
|
41
56
|
modalFormData: modalFormData,
|
|
42
57
|
modalVisible: modalVisible,
|
package/lib/ModalForm/index.js
CHANGED
|
@@ -22,32 +22,17 @@ var ModalForm = (function (_ref) {
|
|
|
22
22
|
_ref$initialValues = _ref.initialValues,
|
|
23
23
|
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
24
24
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
var currentForm = hooks.useCurrentForm(modalForm);
|
|
25
26
|
var _useModifyProps = hooks.useModifyProps({
|
|
26
27
|
configData: configData,
|
|
27
28
|
visible: visible,
|
|
28
|
-
initialValues: initialValues
|
|
29
|
+
initialValues: initialValues,
|
|
30
|
+
modalForm: currentForm
|
|
29
31
|
}),
|
|
30
32
|
modalVisible = _useModifyProps.modalVisible,
|
|
31
33
|
modalFormData = _useModifyProps.modalFormData,
|
|
32
34
|
setModalVisible = _useModifyProps.setModalVisible,
|
|
33
|
-
|
|
34
|
-
initValue = _useModifyProps.initValue,
|
|
35
|
-
setInitValue = _useModifyProps.setInitValue;
|
|
36
|
-
var currentForm = hooks.useCurrentForm(modalForm);
|
|
37
|
-
React.useEffect(function () {
|
|
38
|
-
currentForm.show = function (_ref2) {
|
|
39
|
-
var changeConfigData = _ref2.configData,
|
|
40
|
-
changeInitialValues = _ref2.initialValues;
|
|
41
|
-
if (!!changeConfigData) {
|
|
42
|
-
setModalFormData(changeConfigData);
|
|
43
|
-
}
|
|
44
|
-
setInitValue(changeInitialValues);
|
|
45
|
-
setModalVisible(true);
|
|
46
|
-
};
|
|
47
|
-
currentForm.hide = function () {
|
|
48
|
-
setModalVisible(false);
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
35
|
+
initValue = _useModifyProps.initValue;
|
|
51
36
|
var cancel = function cancel(e) {
|
|
52
37
|
if (onCancel) {
|
|
53
38
|
return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
|
|
@@ -62,7 +47,9 @@ var ModalForm = (function (_ref) {
|
|
|
62
47
|
currentForm.resetFields();
|
|
63
48
|
_afterClose === null || _afterClose === void 0 ? void 0 : _afterClose();
|
|
64
49
|
}
|
|
65
|
-
}, props
|
|
50
|
+
}, props, {
|
|
51
|
+
destroyOnClose: true
|
|
52
|
+
}), /*#__PURE__*/React.createElement(index.default, _extends({
|
|
66
53
|
configData: modalFormData,
|
|
67
54
|
initialValues: initValue
|
|
68
55
|
}, props, {
|
package/lib/ModalForm/modal.d.ts
CHANGED
|
@@ -6,8 +6,11 @@ export interface ModifyPropsModal {
|
|
|
6
6
|
configData: HItemProps[];
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
initialValues?: Record<string, any>;
|
|
9
|
+
modalForm: HModalFormInstance;
|
|
9
10
|
}
|
|
10
|
-
export interface ShowParamsModal
|
|
11
|
+
export interface ShowParamsModal {
|
|
12
|
+
configData?: HItemProps[];
|
|
13
|
+
visible?: boolean;
|
|
11
14
|
initialValues?: Record<string, any>;
|
|
12
15
|
}
|
|
13
16
|
export interface HModalFormInstance extends HFormInstance {
|
package/package.json
CHANGED
|
@@ -2,13 +2,14 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import useHForm from "../Form/hooks/useHForm";
|
|
3
3
|
import type {
|
|
4
4
|
HModalFormInstance,
|
|
5
|
-
ModifyPropsModal
|
|
5
|
+
ModifyPropsModal
|
|
6
6
|
} from "@/components/ModalForm/modal";
|
|
7
7
|
|
|
8
8
|
export const useModifyProps = ({
|
|
9
9
|
visible,
|
|
10
10
|
configData,
|
|
11
11
|
initialValues,
|
|
12
|
+
modalForm
|
|
12
13
|
}: ModifyPropsModal) => {
|
|
13
14
|
const [modalVisible, setModalVisible] = useState(visible);
|
|
14
15
|
const [modalFormData, setModalFormData] = useState(configData);
|
|
@@ -19,6 +20,21 @@ export const useModifyProps = ({
|
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
setModalFormData(configData);
|
|
21
22
|
}, [configData]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
modalForm.show = ({
|
|
25
|
+
configData: changeConfigData,
|
|
26
|
+
initialValues: changeInitialValues,
|
|
27
|
+
}) => {
|
|
28
|
+
if (!!changeConfigData) {
|
|
29
|
+
setModalFormData(changeConfigData);
|
|
30
|
+
}
|
|
31
|
+
setInitValue(changeInitialValues);
|
|
32
|
+
setModalVisible(true);
|
|
33
|
+
};
|
|
34
|
+
modalForm.hide = () => {
|
|
35
|
+
setModalVisible(false);
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
22
38
|
return {
|
|
23
39
|
modalFormData,
|
|
24
40
|
modalVisible,
|
|
@@ -15,31 +15,13 @@ export default ({
|
|
|
15
15
|
initialValues = {},
|
|
16
16
|
...props
|
|
17
17
|
}: ModalFormProps) => {
|
|
18
|
+
const currentForm = useCurrentForm(modalForm);
|
|
18
19
|
const {
|
|
19
20
|
modalVisible,
|
|
20
21
|
modalFormData,
|
|
21
22
|
setModalVisible,
|
|
22
|
-
setModalFormData,
|
|
23
23
|
initValue,
|
|
24
|
-
|
|
25
|
-
} = useModifyProps({ configData, visible, initialValues });
|
|
26
|
-
|
|
27
|
-
const currentForm = useCurrentForm(modalForm);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
currentForm.show = ({
|
|
30
|
-
configData: changeConfigData,
|
|
31
|
-
initialValues: changeInitialValues,
|
|
32
|
-
}) => {
|
|
33
|
-
if (!!changeConfigData) {
|
|
34
|
-
setModalFormData(changeConfigData);
|
|
35
|
-
}
|
|
36
|
-
setInitValue(changeInitialValues);
|
|
37
|
-
setModalVisible(true);
|
|
38
|
-
};
|
|
39
|
-
currentForm.hide = () => {
|
|
40
|
-
setModalVisible(false);
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
24
|
+
} = useModifyProps({ configData, visible, initialValues ,modalForm:currentForm});
|
|
43
25
|
const cancel = (e) => {
|
|
44
26
|
if (onCancel) {
|
|
45
27
|
return onCancel?.(e);
|
|
@@ -56,6 +38,7 @@ export default ({
|
|
|
56
38
|
afterClose?.();
|
|
57
39
|
}}
|
|
58
40
|
{...props}
|
|
41
|
+
destroyOnClose={true}
|
|
59
42
|
>
|
|
60
43
|
<HForm
|
|
61
44
|
configData={modalFormData}
|
|
@@ -8,8 +8,11 @@ export interface ModifyPropsModal {
|
|
|
8
8
|
configData: HItemProps[];
|
|
9
9
|
visible?: boolean;
|
|
10
10
|
initialValues?: Record<string, any>;
|
|
11
|
+
modalForm:HModalFormInstance
|
|
11
12
|
}
|
|
12
|
-
export interface ShowParamsModal
|
|
13
|
+
export interface ShowParamsModal{
|
|
14
|
+
configData?: HItemProps[];
|
|
15
|
+
visible?: boolean;
|
|
13
16
|
initialValues?: Record<string, any>;
|
|
14
17
|
}
|
|
15
18
|
|