@hw-component/form 0.0.4-beta-v3 → 0.0.4-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.
@@ -41,13 +41,15 @@ var ModalForm = (function (_ref) {
41
41
  visible: visible,
42
42
  initialValues: initialValues,
43
43
  dialogForm: currentForm,
44
- params: params
44
+ params: params,
45
+ title: title
45
46
  }),
46
47
  modalVisible = _useModifyProps.modalVisible,
47
48
  modalFormData = _useModifyProps.modalFormData,
48
49
  setModalVisible = _useModifyProps.setModalVisible,
49
50
  initValue = _useModifyProps.initValue,
50
- formParams = _useModifyProps.formParams;
51
+ formParams = _useModifyProps.formParams,
52
+ modalTitle = _useModifyProps.title;
51
53
  var cancel = function cancel() {
52
54
  if (onCancel) {
53
55
  return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
@@ -61,7 +63,7 @@ var ModalForm = (function (_ref) {
61
63
  loading = _useSub.loading,
62
64
  run = _useSub.run;
63
65
  return jsx(Modal, _objectSpread(_objectSpread({
64
- title: title,
66
+ title: modalTitle,
65
67
  visible: modalVisible,
66
68
  onCancel: cancel,
67
69
  confirmLoading: loading,
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
- export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, }: ModifyPropsModal) => {
3
+ export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title }: ModifyPropsModal) => {
4
4
  modalFormData: import("../Form/modal").HItemProps[];
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
@@ -9,6 +9,7 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
9
9
  setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
10
10
  onAfterClose: () => void;
11
11
  formParams: any;
12
+ title: string | (string & import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | (string & import("react").ReactNodeArray) | (string & import("react").ReactPortal) | undefined;
12
13
  };
13
14
  export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
14
15
  export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
@@ -24,7 +24,8 @@ var useModifyProps = function useModifyProps(_ref) {
24
24
  initialValues = _ref.initialValues,
25
25
  dialogForm = _ref.dialogForm,
26
26
  afterClose = _ref.afterClose,
27
- params = _ref.params;
27
+ params = _ref.params,
28
+ title = _ref.title;
28
29
  var _useState = useState(visible),
29
30
  _useState2 = _slicedToArray(_useState, 2),
30
31
  modalVisible = _useState2[0],
@@ -41,6 +42,10 @@ var useModifyProps = function useModifyProps(_ref) {
41
42
  _useState8 = _slicedToArray(_useState7, 2),
42
43
  formParams = _useState8[0],
43
44
  setFormParams = _useState8[1];
45
+ var _useState9 = useState(title),
46
+ _useState10 = _slicedToArray(_useState9, 2),
47
+ modalTitle = _useState10[0],
48
+ setModalTitle = _useState10[1];
44
49
  var onAfterClose = function onAfterClose() {
45
50
  _setTimeout(function () {
46
51
  dialogForm.resetFields();
@@ -56,18 +61,25 @@ var useModifyProps = function useModifyProps(_ref) {
56
61
  useEffect(function () {
57
62
  setFormParams(params);
58
63
  }, [params]);
64
+ useEffect(function () {
65
+ setModalTitle(title);
66
+ }, [title]);
59
67
  useEffect(function () {
60
68
  dialogForm.show = function () {
61
69
  var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
70
  var changeConfigData = showParams.configData,
63
71
  changeInitialValues = showParams.initialValues,
64
- changeParams = showParams.params;
72
+ changeParams = showParams.params,
73
+ changeTitle = showParams.title;
65
74
  if (!!changeConfigData) {
66
75
  setModalFormData(changeConfigData);
67
76
  }
68
77
  if (!!changeParams) {
69
78
  setFormParams(changeParams);
70
79
  }
80
+ if (!!changeTitle) {
81
+ setModalTitle(changeTitle);
82
+ }
71
83
  setInitValue(changeInitialValues);
72
84
  setModalVisible(true);
73
85
  };
@@ -84,7 +96,8 @@ var useModifyProps = function useModifyProps(_ref) {
84
96
  initValue: initValue,
85
97
  setInitValue: setInitValue,
86
98
  onAfterClose: onAfterClose,
87
- formParams: formParams
99
+ formParams: formParams,
100
+ title: modalTitle
88
101
  };
89
102
  };
90
103
  var useHDialogForm = function useHDialogForm() {
@@ -9,6 +9,7 @@ export interface ModifyPropsModal<P = any> {
9
9
  dialogForm: HDialogFormInstance;
10
10
  afterClose?: VoidFunction;
11
11
  params?: P;
12
+ title?: DialogFormProps["title"];
12
13
  }
13
14
  export interface ShowParamsModal<P = any, T = any> {
14
15
  configData?: HItemProps[];
@@ -16,6 +17,7 @@ export interface ShowParamsModal<P = any, T = any> {
16
17
  initialValues?: Record<string, any>;
17
18
  infoRequest?: PromiseFnResult<P, T>;
18
19
  params?: P;
20
+ title?: DialogFormProps["title"];
19
21
  }
20
22
  export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
21
23
  show: (data?: ShowParamsModal<P, T>) => void;
@@ -10,7 +10,7 @@ export declare const useOptionReq: ({ manual, request, options, serviceSearch, s
10
10
  data: OptionType[] | undefined;
11
11
  onSearch: ((value: string) => void) | undefined;
12
12
  mathShowSearch: boolean | undefined;
13
- reload: ({ options: changeOpts, params: requestParams }: ParamsModal) => void | Promise<OptionType[] | undefined>;
13
+ reload: ({ options: changeOpts, params: requestParams, }: ParamsModal) => void | Promise<OptionType[] | undefined>;
14
14
  };
15
15
  export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
16
16
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { SelectProps } from "antd";
2
2
  import type React from "react";
3
3
  import type { PromiseFnResult } from "../modal";
4
- import { argsFn } from "@/components/Form/modal";
4
+ import type { argsFn } from "@/components/Form/modal";
5
5
  export type OptionType = Record<string, any>;
6
6
  export type PartialHSelectProps = Partial<HSelectProps>;
7
7
  export type RenderFn = (data: OptionType) => React.ReactNode;
@@ -44,13 +44,15 @@ var ModalForm = (function (_ref) {
44
44
  visible: visible,
45
45
  initialValues: initialValues,
46
46
  dialogForm: currentForm,
47
- params: params
47
+ params: params,
48
+ title: title
48
49
  }),
49
50
  modalVisible = _useModifyProps.modalVisible,
50
51
  modalFormData = _useModifyProps.modalFormData,
51
52
  setModalVisible = _useModifyProps.setModalVisible,
52
53
  initValue = _useModifyProps.initValue,
53
- formParams = _useModifyProps.formParams;
54
+ formParams = _useModifyProps.formParams,
55
+ modalTitle = _useModifyProps.title;
54
56
  var cancel = function cancel() {
55
57
  if (onCancel) {
56
58
  return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
@@ -64,7 +66,7 @@ var ModalForm = (function (_ref) {
64
66
  loading = _useSub.loading,
65
67
  run = _useSub.run;
66
68
  return jsxRuntime.jsx(antd.Modal, _objectSpread(_objectSpread({
67
- title: title,
69
+ title: modalTitle,
68
70
  visible: modalVisible,
69
71
  onCancel: cancel,
70
72
  confirmLoading: loading,
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
- export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, }: ModifyPropsModal) => {
3
+ export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title }: ModifyPropsModal) => {
4
4
  modalFormData: import("../Form/modal").HItemProps[];
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
@@ -9,6 +9,7 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
9
9
  setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
10
10
  onAfterClose: () => void;
11
11
  formParams: any;
12
+ title: string | (string & import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | (string & import("react").ReactNodeArray) | (string & import("react").ReactPortal) | undefined;
12
13
  };
13
14
  export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
14
15
  export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
@@ -25,7 +25,8 @@ var useModifyProps = function useModifyProps(_ref) {
25
25
  initialValues = _ref.initialValues,
26
26
  dialogForm = _ref.dialogForm,
27
27
  afterClose = _ref.afterClose,
28
- params = _ref.params;
28
+ params = _ref.params,
29
+ title = _ref.title;
29
30
  var _useState = React.useState(visible),
30
31
  _useState2 = _slicedToArray(_useState, 2),
31
32
  modalVisible = _useState2[0],
@@ -42,6 +43,10 @@ var useModifyProps = function useModifyProps(_ref) {
42
43
  _useState8 = _slicedToArray(_useState7, 2),
43
44
  formParams = _useState8[0],
44
45
  setFormParams = _useState8[1];
46
+ var _useState9 = React.useState(title),
47
+ _useState10 = _slicedToArray(_useState9, 2),
48
+ modalTitle = _useState10[0],
49
+ setModalTitle = _useState10[1];
45
50
  var onAfterClose = function onAfterClose() {
46
51
  _setTimeout(function () {
47
52
  dialogForm.resetFields();
@@ -57,18 +62,25 @@ var useModifyProps = function useModifyProps(_ref) {
57
62
  React.useEffect(function () {
58
63
  setFormParams(params);
59
64
  }, [params]);
65
+ React.useEffect(function () {
66
+ setModalTitle(title);
67
+ }, [title]);
60
68
  React.useEffect(function () {
61
69
  dialogForm.show = function () {
62
70
  var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63
71
  var changeConfigData = showParams.configData,
64
72
  changeInitialValues = showParams.initialValues,
65
- changeParams = showParams.params;
73
+ changeParams = showParams.params,
74
+ changeTitle = showParams.title;
66
75
  if (!!changeConfigData) {
67
76
  setModalFormData(changeConfigData);
68
77
  }
69
78
  if (!!changeParams) {
70
79
  setFormParams(changeParams);
71
80
  }
81
+ if (!!changeTitle) {
82
+ setModalTitle(changeTitle);
83
+ }
72
84
  setInitValue(changeInitialValues);
73
85
  setModalVisible(true);
74
86
  };
@@ -85,7 +97,8 @@ var useModifyProps = function useModifyProps(_ref) {
85
97
  initValue: initValue,
86
98
  setInitValue: setInitValue,
87
99
  onAfterClose: onAfterClose,
88
- formParams: formParams
100
+ formParams: formParams,
101
+ title: modalTitle
89
102
  };
90
103
  };
91
104
  var useHDialogForm = function useHDialogForm() {
@@ -9,6 +9,7 @@ export interface ModifyPropsModal<P = any> {
9
9
  dialogForm: HDialogFormInstance;
10
10
  afterClose?: VoidFunction;
11
11
  params?: P;
12
+ title?: DialogFormProps["title"];
12
13
  }
13
14
  export interface ShowParamsModal<P = any, T = any> {
14
15
  configData?: HItemProps[];
@@ -16,6 +17,7 @@ export interface ShowParamsModal<P = any, T = any> {
16
17
  initialValues?: Record<string, any>;
17
18
  infoRequest?: PromiseFnResult<P, T>;
18
19
  params?: P;
20
+ title?: DialogFormProps["title"];
19
21
  }
20
22
  export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
21
23
  show: (data?: ShowParamsModal<P, T>) => void;
@@ -10,7 +10,7 @@ export declare const useOptionReq: ({ manual, request, options, serviceSearch, s
10
10
  data: OptionType[] | undefined;
11
11
  onSearch: ((value: string) => void) | undefined;
12
12
  mathShowSearch: boolean | undefined;
13
- reload: ({ options: changeOpts, params: requestParams }: ParamsModal) => void | Promise<OptionType[] | undefined>;
13
+ reload: ({ options: changeOpts, params: requestParams, }: ParamsModal) => void | Promise<OptionType[] | undefined>;
14
14
  };
15
15
  export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
16
16
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { SelectProps } from "antd";
2
2
  import type React from "react";
3
3
  import type { PromiseFnResult } from "../modal";
4
- import { argsFn } from "@/components/Form/modal";
4
+ import type { argsFn } from "@/components/Form/modal";
5
5
  export type OptionType = Record<string, any>;
6
6
  export type PartialHSelectProps = Partial<HSelectProps>;
7
7
  export type RenderFn = (data: OptionType) => React.ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.4-beta-v3",
3
+ "version": "0.0.4-beta-v4",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,12 +25,14 @@ export default ({
25
25
  setModalVisible,
26
26
  initValue,
27
27
  formParams,
28
+ title:modalTitle
28
29
  } = useModifyProps({
29
30
  configData,
30
31
  visible,
31
32
  initialValues,
32
33
  dialogForm: currentForm,
33
34
  params,
35
+ title
34
36
  });
35
37
  const cancel = () => {
36
38
  if (onCancel) {
@@ -41,7 +43,7 @@ export default ({
41
43
  const { loading, run } = useSub({ request, onFinish });
42
44
  return (
43
45
  <Modal
44
- title={title}
46
+ title={modalTitle}
45
47
  visible={modalVisible}
46
48
  onCancel={cancel}
47
49
  confirmLoading={loading}
@@ -14,11 +14,13 @@ export const useModifyProps = ({
14
14
  dialogForm,
15
15
  afterClose,
16
16
  params,
17
+ title
17
18
  }: ModifyPropsModal) => {
18
19
  const [modalVisible, setModalVisible] = useState(visible);
19
20
  const [modalFormData, setModalFormData] = useState(configData);
20
21
  const [initValue, setInitValue] = useState(initialValues);
21
22
  const [formParams, setFormParams] = useState(params);
23
+ const [modalTitle,setModalTitle]=useState(title)
22
24
  const onAfterClose = () => {
23
25
  setTimeout(() => {
24
26
  dialogForm.resetFields();
@@ -36,13 +38,16 @@ export const useModifyProps = ({
36
38
  useEffect(() => {
37
39
  setFormParams(params);
38
40
  }, [params]);
39
-
41
+ useEffect(() => {
42
+ setModalTitle(title);
43
+ }, [title]);
40
44
  useEffect(() => {
41
45
  dialogForm.show = (showParams = {}) => {
42
46
  const {
43
47
  configData: changeConfigData,
44
48
  initialValues: changeInitialValues,
45
49
  params: changeParams,
50
+ title:changeTitle
46
51
  } = showParams;
47
52
  if (!!changeConfigData) {
48
53
  setModalFormData(changeConfigData);
@@ -50,6 +55,9 @@ export const useModifyProps = ({
50
55
  if (!!changeParams) {
51
56
  setFormParams(changeParams);
52
57
  }
58
+ if (!!changeTitle){
59
+ setModalTitle(changeTitle);
60
+ }
53
61
  setInitValue(changeInitialValues);
54
62
  setModalVisible(true);
55
63
  };
@@ -67,6 +75,7 @@ export const useModifyProps = ({
67
75
  setInitValue,
68
76
  onAfterClose,
69
77
  formParams,
78
+ title:modalTitle
70
79
  };
71
80
  };
72
81
  export const useHDialogForm = () => {
@@ -11,6 +11,7 @@ export interface ModifyPropsModal<P = any> {
11
11
  dialogForm: HDialogFormInstance;
12
12
  afterClose?: VoidFunction;
13
13
  params?: P;
14
+ title?:DialogFormProps["title"];
14
15
  }
15
16
  export interface ShowParamsModal<P = any, T = any> {
16
17
  configData?: HItemProps[];
@@ -18,6 +19,7 @@ export interface ShowParamsModal<P = any, T = any> {
18
19
  initialValues?: Record<string, any>;
19
20
  infoRequest?: PromiseFnResult<P, T>;
20
21
  params?: P;
22
+ title?:DialogFormProps["title"];
21
23
  }
22
24
 
23
25
  export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
@@ -5,9 +5,9 @@ import type {
5
5
  } from "@/components/Select/modal";
6
6
  import { useRequest } from "ahooks";
7
7
 
8
- interface ParamsModal{
8
+ interface ParamsModal {
9
9
  options?: OptionType[];
10
- params?:any;
10
+ params?: any;
11
11
  }
12
12
  export const useOptionReq = ({
13
13
  manual,
@@ -36,12 +36,15 @@ export const useOptionReq = ({
36
36
  },
37
37
  }
38
38
  );
39
- const reload=({options:changeOpts,params:requestParams}:ParamsModal)=>{
40
- if (changeOpts){
41
- return setData(changeOpts);
42
- };
43
- return run(requestParams);
44
- }
39
+ const reload = ({
40
+ options: changeOpts,
41
+ params: requestParams,
42
+ }: ParamsModal) => {
43
+ if (changeOpts) {
44
+ return setData(changeOpts);
45
+ }
46
+ return run(requestParams);
47
+ };
45
48
  const onSearch = (inputValue: string) => {
46
49
  if (!serviceSearch) {
47
50
  propsOnSearch?.(inputValue);
@@ -62,7 +65,7 @@ export const useOptionReq = ({
62
65
  data,
63
66
  onSearch: mathShowSearch ? onSearch : propsOnSearch,
64
67
  mathShowSearch: showSearch || serviceSearch,
65
- reload
68
+ reload,
66
69
  };
67
70
  };
68
71
 
@@ -30,7 +30,7 @@ const Index: React.FC<HSelectProps> = ({
30
30
  labelInValue,
31
31
  noMatchItemRender = defaultSelectConfig.noMatchItemRender,
32
32
  allSelect,
33
- addDispatchListener,
33
+ addDispatchListener,
34
34
  ...props
35
35
  }) => {
36
36
  const { icon, render } = modeConfig?.[mode || ""] || {};
@@ -44,7 +44,7 @@ const Index: React.FC<HSelectProps> = ({
44
44
  error,
45
45
  onSearch,
46
46
  mathShowSearch,
47
- reload
47
+ reload,
48
48
  } = useOptionReq({
49
49
  options,
50
50
  manual,
@@ -65,7 +65,7 @@ const Index: React.FC<HSelectProps> = ({
65
65
  noMatchItemRender,
66
66
  fieldNames,
67
67
  });
68
- addDispatchListener?.("reload",reload);
68
+ addDispatchListener?.("reload", reload);
69
69
  return (
70
70
  <Select
71
71
  style={style}
@@ -1,7 +1,7 @@
1
1
  import type { SelectProps } from "antd";
2
2
  import type React from "react";
3
3
  import type { PromiseFnResult } from "../modal";
4
- import {argsFn} from "@/components/Form/modal";
4
+ import type { argsFn } from "@/components/Form/modal";
5
5
  export type OptionType = Record<string, any>;
6
6
  export type PartialHSelectProps = Partial<HSelectProps>;
7
7
  export type RenderFn = (data: OptionType) => React.ReactNode;
@@ -25,8 +25,8 @@ const formData = (options) => {
25
25
  name: "select",
26
26
  type: "select",
27
27
  itemProps: {
28
- request: (params={}) => {
29
- const {label="123",value=1}=params;
28
+ request: (params = {}) => {
29
+ const { label = "123", value = 1 } = params;
30
30
  return Promise.resolve([{ label, value }]);
31
31
  },
32
32
  },
@@ -175,15 +175,18 @@ export default () => {
175
175
  </HFormConfigProvider>
176
176
  <div
177
177
  onClick={() => {
178
- form.dispatch({
179
- name:"select",
180
- key:"reload"
181
- },{
182
- params:{
183
- label:"更新",
184
- value:2
185
- }
186
- })
178
+ form.dispatch(
179
+ {
180
+ name: "select",
181
+ key: "reload",
182
+ },
183
+ {
184
+ params: {
185
+ label: "更新",
186
+ value: 2,
187
+ },
188
+ }
189
+ );
187
190
  }}
188
191
  >
189
192
  点我