@hw-component/form 0.0.1-beta-v2 → 0.0.1-beta-v4

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.
@@ -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>>;
@@ -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,
@@ -1,10 +1,10 @@
1
1
  // welcome to hoo hoo hoo
2
- import React, { useEffect } from '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 { useModifyProps, useCurrentForm } from './hooks.js';
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
- setModalFormData = _useModifyProps.setModalFormData,
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), /*#__PURE__*/React.createElement(HForm, _extends({
47
+ }, props, {
48
+ destroyOnClose: true
49
+ }), /*#__PURE__*/React.createElement(HForm, _extends({
63
50
  configData: modalFormData,
64
51
  initialValues: initValue
65
52
  }, props, {
@@ -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 extends Partial<ModifyPropsModal> {
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/es/config.js CHANGED
@@ -10,12 +10,12 @@ var baseConfig = {
10
10
  value: "value"
11
11
  },
12
12
  valueCheckMap: {
13
- checked: true,
14
- noChecked: false
13
+ checked: 1,
14
+ noChecked: 0
15
15
  },
16
16
  valueSwitchMap: {
17
- open: true,
18
- close: false
17
+ open: 1,
18
+ close: 0
19
19
  },
20
20
  valueRangePickerValueMap: {
21
21
  start: function start(name) {
@@ -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>>;
@@ -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,
@@ -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
- setModalFormData = _useModifyProps.setModalFormData,
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), /*#__PURE__*/React.createElement(index.default, _extends({
50
+ }, props, {
51
+ destroyOnClose: true
52
+ }), /*#__PURE__*/React.createElement(index.default, _extends({
66
53
  configData: modalFormData,
67
54
  initialValues: initValue
68
55
  }, props, {
@@ -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 extends Partial<ModifyPropsModal> {
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/config.js CHANGED
@@ -11,12 +11,12 @@ var baseConfig = {
11
11
  value: "value"
12
12
  },
13
13
  valueCheckMap: {
14
- checked: true,
15
- noChecked: false
14
+ checked: 1,
15
+ noChecked: 0
16
16
  },
17
17
  valueSwitchMap: {
18
- open: true,
19
- close: false
18
+ open: 1,
19
+ close: 0
20
20
  },
21
21
  valueRangePickerValueMap: {
22
22
  start: function start(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.1-beta-v2",
3
+ "version": "0.0.1-beta-v4",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@ 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,
@@ -2,7 +2,6 @@ import { Modal } from "antd";
2
2
  import type { ModalFormProps } from "@/components/ModalForm/modal";
3
3
  import HForm from "../Form";
4
4
  import { useCurrentForm, useModifyProps } from "./hooks";
5
- import { useEffect } from "react";
6
5
  export default ({
7
6
  visible,
8
7
  title,
@@ -15,31 +14,14 @@ export default ({
15
14
  initialValues = {},
16
15
  ...props
17
16
  }: ModalFormProps) => {
18
- const {
19
- modalVisible,
20
- modalFormData,
21
- setModalVisible,
22
- setModalFormData,
23
- initValue,
24
- setInitValue,
25
- } = useModifyProps({ configData, visible, initialValues });
26
-
27
17
  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
- }, []);
18
+ const { modalVisible, modalFormData, setModalVisible, initValue } =
19
+ useModifyProps({
20
+ configData,
21
+ visible,
22
+ initialValues,
23
+ modalForm: currentForm,
24
+ });
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 extends Partial<ModifyPropsModal> {
13
+ export interface ShowParamsModal {
14
+ configData?: HItemProps[];
15
+ visible?: boolean;
13
16
  initialValues?: Record<string, any>;
14
17
  }
15
18
 
@@ -7,12 +7,12 @@ export const baseConfig: IFormConfigContextProps = {
7
7
  value: "value",
8
8
  },
9
9
  valueCheckMap: {
10
- checked: true,
11
- noChecked: false,
10
+ checked: 1,
11
+ noChecked:0,
12
12
  },
13
13
  valueSwitchMap: {
14
- open: true,
15
- close: false,
14
+ open: 1,
15
+ close: 0,
16
16
  },
17
17
  valueRangePickerValueMap: {
18
18
  start: (name) => {