@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
@@ -25,6 +25,7 @@ import type {
25
25
  ValueSwitchMapModal,
26
26
  DateRangePickerValueMapModal,
27
27
  } from "../modal";
28
+ import type { ForwardedRef } from "react";
28
29
  type RenderFun = (
29
30
  props: HItemProps,
30
31
  node: React.ReactNode,
@@ -53,18 +54,20 @@ type HelperModal = (form: HFormInstance) => React.ReactNode | string;
53
54
 
54
55
  export type HideModal = (form: HFormInstance) => boolean;
55
56
 
57
+ export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
58
+
56
59
  export interface HItemProps extends Omit<FormItemProps, "name"> {
57
60
  type?: string;
58
61
  itemProps?: ItemPropsType;
59
62
  render?: RenderFun;
60
- helper?: HelperModal;
63
+ helper?: HelperModal | string;
61
64
  hover?: string | HoverModal;
62
65
  // formItems?: HItemProps[]; 保留感觉没必要
63
66
  labelWidth?: number;
64
67
  hide?: boolean | HideModal;
65
68
  placeholder?: string | string[];
66
- formatKeys?: string[];
67
- name: string;
69
+ // formatKeys?: string[];
70
+ name?: string;
68
71
  }
69
72
 
70
73
  export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
@@ -78,11 +81,13 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
78
81
 
79
82
  export interface HFormItemProps extends HItemProps {
80
83
  required?: boolean;
84
+ value?: any;
85
+ onChange?: (val: any, item: any) => void;
81
86
  }
82
87
  export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
83
88
  render: (form: HFormInstance) => React.ReactNode;
84
89
  }
85
-
90
+ export type argsFn = (...args: any[]) => void;
86
91
  export interface FormContextProps {
87
92
  loading?: boolean;
88
93
  form: HFormInstance;
@@ -102,18 +107,21 @@ export interface IFormConfigContextProps {
102
107
  dateRanges?: RangePickerProps["ranges"];
103
108
  uploadProps?: ConfigUploadProps;
104
109
  }
105
-
110
+ interface ActionModal {
111
+ key: string;
112
+ name?: string;
113
+ }
106
114
  export interface HFormInstance extends FormInstance {
107
115
  addFormat: (name: string, formats?: FormatItemModal) => void;
108
- initValues: (values?: Record<string, any>) => void;
116
+ initValues: VoidFunction;
109
117
  formatValues: (
110
118
  values?: Record<string, any>,
111
119
  formatKey?: string
112
120
  ) => Record<string, any>;
113
- dispatch: (key: string) => void;
121
+ dispatch: (action: ActionModal, ...args: any[]) => void;
114
122
  outputValues: (values?: Record<string, any>) => Record<string, any>;
115
- addDispatchListener: (key: string, fn: VoidFunction) => void;
116
- removeDispatchListener: (key?: string) => void;
123
+ addDispatchListener: AddDispatchListenerFn;
124
+ removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
117
125
  }
118
126
 
119
127
  export interface ConnectConfigModal {
@@ -137,6 +145,10 @@ export interface addFormatItemModal {
137
145
  outputValue: addValueFormat;
138
146
  }
139
147
 
140
- export interface ConnectResultProps {
148
+ export interface ConnectResultProps extends HFormItemProps {
141
149
  addFormat?: (format: Record<string, addFormatItemModal>) => void;
150
+ addDispatchListener?: (key: string, fn: argsFn) => void;
151
+ ref?: ForwardedRef<any>;
152
+ value?: any;
153
+ onChange?: (value: any, item?: any) => void;
142
154
  }
@@ -3,6 +3,7 @@ import type { HSelectInputProps } from "./modal";
3
3
  import HSelect from "../Select";
4
4
  import { defaultSelectStyle, defaultValueName } from "./defaultConfig";
5
5
  import HFormConnect from "../Form/HFormConnect";
6
+ import { ConnectResultProps } from "@/components/Form/modal";
6
7
  export enum SelectInputType {
7
8
  input,
8
9
  select,
@@ -13,6 +14,7 @@ export const Index = ({
13
14
  onChange,
14
15
  valueName = defaultValueName,
15
16
  addFormat,
17
+ addDispatchListener,
16
18
  ...props
17
19
  }: HSelectInputProps) => {
18
20
  const { input = "", select = "" } = valueName;
@@ -31,7 +33,7 @@ export const Index = ({
31
33
  addFormat?.({
32
34
  float: {
33
35
  inputValue: (item, initValue) => {
34
- const { name } = item;
36
+ const { name = "" } = item;
35
37
  const resultObj = {};
36
38
  Object.values(valueName).forEach((key) => {
37
39
  resultObj[key] = initValue[key];
@@ -41,7 +43,7 @@ export const Index = ({
41
43
  };
42
44
  },
43
45
  outputValue: (item, outputValue) => {
44
- const { name } = item;
46
+ const { name = "" } = item;
45
47
  const { [name]: itemVal = {} } = outputValue;
46
48
  const newItemVal = { [itemVal[select]]: itemVal[input] };
47
49
  return {
@@ -3,6 +3,7 @@ import type { HSelectProps } from "../Select/modal";
3
3
  import type { SelectInputType } from "./SelectInput";
4
4
  import type { PromiseFnResult } from "../modal";
5
5
  import type { addFormatItemModal } from "../Form/modal";
6
+ import type { AddDispatchListenerFn } from "../Form/modal";
6
7
 
7
8
  export type HInputProps = InputProps;
8
9
 
@@ -18,6 +19,7 @@ export interface HSelectInputProps
18
19
  onChange?: (value: Record<string, any>, type: SelectInputType) => void;
19
20
  valueName?: ValueNameModal;
20
21
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
22
+ addDispatchListener?: AddDispatchListenerFn;
21
23
  }
22
24
  export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
23
25
  onClick: (
@@ -47,24 +47,23 @@ const HRangePicker: React.FC<HRangePickerProps> = ({
47
47
  }
48
48
  return ranges;
49
49
  }, [ranges]); //默认
50
-
51
50
  addFormat?.({
52
51
  float: {
53
52
  inputValue: (item, initValue) => {
54
- const { name: valueName } = item;
53
+ const { name: valueName = "" } = item;
55
54
  const resultObj = {};
56
55
  Object.values(dateMapKeys).forEach((key) => {
57
- if (initValue[key]){
56
+ if (initValue[key]) {
58
57
  resultObj[key] = initValue[key];
59
58
  }
60
59
  });
61
- const hasKeys=Object.keys(resultObj).length!==0;
60
+ const hasKeys = Object.keys(resultObj).length !== 0;
62
61
  return {
63
- [valueName]: hasKeys?resultObj:null,
62
+ [valueName]: hasKeys ? resultObj : null,
64
63
  };
65
64
  },
66
65
  outputValue: (item, outputValue) => {
67
- const { name: valueName } = item;
66
+ const { name: valueName = "" } = item;
68
67
  const { [valueName]: itemVal = {} } = outputValue;
69
68
  return {
70
69
  ...itemVal,
@@ -5,8 +5,7 @@ import type { IUploadRefModal, IUrlUploadProps } from "../modal";
5
5
  import TypeEle from "../MediaTypeEle/TypeEle";
6
6
  import { useRef, useState } from "react";
7
7
  import type { RcFile, UploadFile } from "antd/es/upload/interface";
8
-
9
- export default ({
8
+ const Index = ({
10
9
  placeholder = "请输入文件地址",
11
10
  value = [],
12
11
  onChange,
@@ -89,3 +88,4 @@ export default ({
89
88
  </Space>
90
89
  );
91
90
  };
91
+ export default Index;
@@ -2,7 +2,62 @@ import type { IUpLoadProps } from "../modal";
2
2
  import type { UploadFile } from "antd/es/upload/interface";
3
3
  import type { RcFile } from "antd/lib/upload";
4
4
  import { useEffect, useMemo } from "react";
5
+ import type { UploadFileStatus } from "antd/es/upload/interface";
6
+ import type { BeforeUploadFileType } from "rc-upload/lib/interface";
7
+ import { message } from "antd";
5
8
 
9
+ interface SubReqParamsModal {
10
+ request?: (
11
+ file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
12
+ ) => Promise<{ url: string }>;
13
+ file: RcFile;
14
+ }
15
+ interface ResultModal {
16
+ url: string;
17
+ status: UploadFileStatus;
18
+ uid?: string;
19
+ }
20
+ const subReq = async ({
21
+ request,
22
+ file,
23
+ }: SubReqParamsModal): Promise<ResultModal> => {
24
+ if (!request) {
25
+ return {
26
+ url: "",
27
+ status: "done",
28
+ };
29
+ }
30
+ try {
31
+ const { url } = await request(file);
32
+ return {
33
+ url,
34
+ status: "done",
35
+ };
36
+ } catch (err: any) {
37
+ message.error(err.message);
38
+ return {
39
+ url: "",
40
+ status: "error",
41
+ };
42
+ }
43
+ };
44
+ const fileListProvider = (changeFile: ResultModal, files?: UploadFile[]) => {
45
+ const { status, url, uid } = changeFile;
46
+ if (status === "error") {
47
+ return files?.filter((item) => {
48
+ return item.uid !== uid;
49
+ });
50
+ }
51
+ return files?.map((item) => {
52
+ const resultUrl = url || item.thumbUrl;
53
+ if (item.uid === uid) {
54
+ item.status = status;
55
+ item.response = { url: resultUrl };
56
+ return item;
57
+ }
58
+ return item;
59
+ });
60
+ };
6
61
  export const useCustomRequest = ({
7
62
  value,
8
63
  request,
@@ -20,20 +75,8 @@ export const useCustomRequest = ({
20
75
 
21
76
  const sendFile = async (file: RcFile) => {
22
77
  const { uid } = file;
23
- let url = "";
24
- if (request) {
25
- const result = await request(file);
26
- url = result.url;
27
- }
28
- const fileList = valObj?.value?.map((item) => {
29
- const resultUrl = url || item.thumbUrl;
30
- if (item.uid === uid) {
31
- item.status = "done";
32
- item.response = { url: resultUrl };
33
- return item;
34
- }
35
- return item;
36
- });
78
+ const result = await subReq({ request, file });
79
+ const fileList = fileListProvider({ ...result, uid }, valObj.value);
37
80
  onChange?.(fileList || []);
38
81
  };
39
82
  return (fileList: UploadFile[]) => {
@@ -1,11 +1,12 @@
1
- import { Upload } from "antd";
2
- import Btn from "./Btn";
3
1
  import React, { useImperativeHandle, useMemo, useState } from "react";
2
+ import type { IUpLoadProps, IUploadRefModal } from "./modal";
3
+ import { useProps } from "./hooks/propsMaker";
4
4
  import type { IPreviewProps } from "./Preview";
5
5
  import Preview from "./Preview";
6
6
  import { useChange } from "./hooks/change";
7
- import type { IUpLoadProps, IUploadRefModal } from "./modal";
8
- import { useProps } from "./hooks/propsMaker";
7
+ import { Upload } from "antd";
8
+ import Btn from "./Btn";
9
+ import HFormConnect from "../Form/HFormConnect";
9
10
 
10
11
  const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
11
12
  {
@@ -18,6 +19,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
18
19
  onPreview,
19
20
  request,
20
21
  maxSize,
22
+ addFormat,
21
23
  ...props
22
24
  },
23
25
  ref
@@ -52,10 +54,41 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
52
54
  file,
53
55
  });
54
56
  };
55
-
56
57
  const maxNum = maxCount === 1 ? maxCount : Number.MAX_VALUE;
57
58
  const { visible, file: previewFile } = previewModal;
58
-
59
+ addFormat?.({
60
+ float: {
61
+ inputValue: (item, initValue) => {
62
+ const { name = "" } = item;
63
+ const initFileList = initValue[name] || [];
64
+ const relInitFileList=typeof initFileList==="string"?[initFileList]:initFileList;
65
+ const fileList = relInitFileList.map((url, index) => {
66
+ return {
67
+ name: url,
68
+ response: {
69
+ url,
70
+ },
71
+ status: "done",
72
+ uid: `init-${index}`,
73
+ thumbUrl: url,
74
+ };
75
+ });
76
+ return {
77
+ [name]: fileList,
78
+ };
79
+ },
80
+ outputValue: (item, outputValue) => {
81
+ const { name: valueName = "" } = item;
82
+ const { [valueName]: itemVal = [] } = outputValue;
83
+ const urls = itemVal.map((fileItem) => {
84
+ return fileItem.response.url;
85
+ });
86
+ return {
87
+ [valueName]: maxCount===1?urls[0]:urls,
88
+ };
89
+ },
90
+ },
91
+ });
59
92
  return (
60
93
  <div style={contentStyle}>
61
94
  <Upload
@@ -82,4 +115,4 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
82
115
  );
83
116
  };
84
117
 
85
- export default React.forwardRef(Index);
118
+ export default HFormConnect(React.forwardRef(Index));
@@ -3,6 +3,7 @@ import type { UploadFile } from "antd/es/upload/interface";
3
3
  import type { BeforeUploadFileType, RcFile } from "rc-upload/lib/interface";
4
4
  import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
+ import type { addFormatItemModal } from "@/components/Form/modal";
6
7
 
7
8
  export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
8
9
  exFiles?: string[];
@@ -14,6 +15,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
14
15
  value?: UploadFile[];
15
16
  maxRowNum?: number;
16
17
  maxSize?: number;
18
+ addFormat?: (config: Record<string, addFormatItemModal>) => void;
17
19
  }
18
20
  export interface IMediaTypeEleProps {
19
21
  file?: UploadFile;
@@ -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) => {
@@ -3,6 +3,9 @@ import FormConfig from "./Form/config";
3
3
  import PageHandler from "./PageHandler";
4
4
  export { default as HForm } from "./Form";
5
5
  export { default as useHForm } from "./Form/hooks/useHForm";
6
+ export { useHDialogForm } from "./DialogForm/hooks";
7
+ import ModalForm from "./DialogForm/ModalForm";
8
+ import DrawerForm from "./DialogForm/DrawerForm";
6
9
  export const HSelect = FormConfig.select;
7
10
  export const HInput = FormConfig.input;
8
11
  export const HSelectInput = FormConfig.selectInput;
@@ -19,3 +22,6 @@ export const HTimePicker = FormConfig.timePicker;
19
22
  export const HInputNumber = FormConfig.inputNumber;
20
23
  export const HPageHandler = PageHandler;
21
24
  export const HFormConfigProvider = FormConfig.formConfigProvider;
25
+ export const HTextArea = FormConfig.textArea;
26
+ export const HModalForm = ModalForm;
27
+ export const HDrawerForm = DrawerForm;
@@ -0,0 +1,127 @@
1
+ import { Button } from "antd";
2
+ import { HDrawerForm, useHDiaLogForm } from "../../components";
3
+ const data = [
4
+ {
5
+ label: "输入框",
6
+ name: "name",
7
+ rules: [
8
+ () => {
9
+ return {
10
+ required: true,
11
+ };
12
+ },
13
+ ],
14
+ },
15
+ {
16
+ label: "数字",
17
+ name: "sz",
18
+ type: "inputNumber",
19
+ rules: [{ required: true }],
20
+ },
21
+ {
22
+ label: "下拉输入框",
23
+ name: "selectInput",
24
+ type: "selectInput",
25
+ rules: [{ required: true }],
26
+ itemProps: {
27
+ valueName: {
28
+ select: "op",
29
+ input: "opInput",
30
+ },
31
+ selectProps: {
32
+ options: [{ label: "测试", value: 1 }],
33
+ },
34
+ },
35
+ },
36
+ {
37
+ label: "按钮输入框",
38
+ name: "buttonInput",
39
+ type: "buttonInput",
40
+ children: "点击",
41
+ rules: [{ required: true }],
42
+ },
43
+ {
44
+ label: "选择",
45
+ name: "checkboxGroup",
46
+ type: "checkboxGroup",
47
+ rules: [{ required: true }],
48
+ helper: "帮助我",
49
+ options: [
50
+ { label: "选择1", value: "check1" },
51
+ { label: "选择2", value: "check2" },
52
+ ],
53
+ },
54
+ {
55
+ label: "开关",
56
+ name: "switch",
57
+ type: "switch",
58
+ rules: [{ required: true }],
59
+ },
60
+ {
61
+ label: "时间",
62
+ name: "datePicker",
63
+ type: "datePicker",
64
+ hover: "时间选择",
65
+ helper: "帮助我",
66
+ rules: [{ required: true }],
67
+ },
68
+ {
69
+ label: "时间段",
70
+ name: "rangePicker",
71
+ type: "rangePicker",
72
+ helper: "帮助我",
73
+ rules: [{ required: true }],
74
+ itemProps: {
75
+ valueMap: {
76
+ start: "testStart",
77
+ end: "testEnd",
78
+ },
79
+ },
80
+ },
81
+ {
82
+ label: "时分秒",
83
+ name: "timePicker",
84
+ type: "timePicker",
85
+ rules: [{ required: true }],
86
+ },
87
+ {
88
+ label: "文件",
89
+ name: "upload",
90
+ type: "upload",
91
+ rules: [{ required: true }],
92
+ },
93
+ {
94
+ label: "地址文件",
95
+ name: "urlUpload",
96
+ type: "urlUpload",
97
+ rules: [{ required: true }],
98
+ },
99
+ ];
100
+ export default () => {
101
+ const modalForm = useHDiaLogForm();
102
+ return (
103
+ <>
104
+ <Button
105
+ onClick={() => {
106
+ modalForm.show({
107
+ initialValues: {
108
+ check1: 1,
109
+ testStart: "1694747960",
110
+ testEnd: "1693538359",
111
+ op: 1,
112
+ opInput: "12121",
113
+ },
114
+ });
115
+ }}
116
+ >
117
+ 打开
118
+ </Button>
119
+ <HDrawerForm
120
+ configData={data}
121
+ labelWidth={88}
122
+ modalForm={modalForm}
123
+ title="测试"
124
+ />
125
+ </>
126
+ );
127
+ };
@@ -128,6 +128,9 @@ export default () => {
128
128
  testEnd: "1693538359",
129
129
  op: 1,
130
130
  opInput: "12121",
131
+ upload: [
132
+ "https://img2.baidu.com/it/u=2048195462,703560066&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",
133
+ ],
131
134
  });
132
135
  }, 3000);
133
136
  });
@@ -0,0 +1,127 @@
1
+ import { Button } from "antd";
2
+ import { HModalForm, useHDiaLogForm } from "../../components";
3
+ const data = [
4
+ {
5
+ label: "输入框",
6
+ name: "name",
7
+ rules: [
8
+ () => {
9
+ return {
10
+ required: true,
11
+ };
12
+ },
13
+ ],
14
+ },
15
+ {
16
+ label: "数字",
17
+ name: "sz",
18
+ type: "inputNumber",
19
+ rules: [{ required: true }],
20
+ },
21
+ {
22
+ label: "下拉输入框",
23
+ name: "selectInput",
24
+ type: "selectInput",
25
+ rules: [{ required: true }],
26
+ itemProps: {
27
+ valueName: {
28
+ select: "op",
29
+ input: "opInput",
30
+ },
31
+ selectProps: {
32
+ options: [{ label: "测试", value: 1 }],
33
+ },
34
+ },
35
+ },
36
+ {
37
+ label: "按钮输入框",
38
+ name: "buttonInput",
39
+ type: "buttonInput",
40
+ children: "点击",
41
+ rules: [{ required: true }],
42
+ },
43
+ {
44
+ label: "选择",
45
+ name: "checkboxGroup",
46
+ type: "checkboxGroup",
47
+ rules: [{ required: true }],
48
+ helper: "帮助我",
49
+ options: [
50
+ { label: "选择1", value: "check1" },
51
+ { label: "选择2", value: "check2" },
52
+ ],
53
+ },
54
+ {
55
+ label: "开关",
56
+ name: "switch",
57
+ type: "switch",
58
+ rules: [{ required: true }],
59
+ },
60
+ {
61
+ label: "时间",
62
+ name: "datePicker",
63
+ type: "datePicker",
64
+ hover: "时间选择",
65
+ helper: "帮助我",
66
+ rules: [{ required: true }],
67
+ },
68
+ {
69
+ label: "时间段",
70
+ name: "rangePicker",
71
+ type: "rangePicker",
72
+ helper: "帮助我",
73
+ rules: [{ required: true }],
74
+ itemProps: {
75
+ valueMap: {
76
+ start: "testStart",
77
+ end: "testEnd",
78
+ },
79
+ },
80
+ },
81
+ {
82
+ label: "时分秒",
83
+ name: "timePicker",
84
+ type: "timePicker",
85
+ rules: [{ required: true }],
86
+ },
87
+ {
88
+ label: "文件",
89
+ name: "upload",
90
+ type: "upload",
91
+ rules: [{ required: true }],
92
+ },
93
+ {
94
+ label: "地址文件",
95
+ name: "urlUpload",
96
+ type: "urlUpload",
97
+ rules: [{ required: true }],
98
+ },
99
+ ];
100
+ export default () => {
101
+ const modalForm = useHDiaLogForm();
102
+ return (
103
+ <>
104
+ <Button
105
+ onClick={() => {
106
+ modalForm.show({
107
+ initialValues: {
108
+ check1: 1,
109
+ testStart: "1694747960",
110
+ testEnd: "1693538359",
111
+ op: 1,
112
+ opInput: "12121",
113
+ },
114
+ });
115
+ }}
116
+ >
117
+ 打开
118
+ </Button>
119
+ <HModalForm
120
+ configData={data}
121
+ labelWidth={88}
122
+ modalForm={modalForm}
123
+ title="测试"
124
+ />
125
+ </>
126
+ );
127
+ };
package/src/routes.tsx CHANGED
@@ -8,6 +8,8 @@ import Switch from "./pages/Switch";
8
8
  import DatePicker from "./pages/DatePicker";
9
9
  import Upload from "./pages/Upload";
10
10
  import Form from "./pages/Form";
11
+ import ModalForm from "./pages/ModalForm";
12
+ import DrawerForm from "./pages/DrawerForm";
11
13
 
12
14
  export interface RouteModal {
13
15
  path?: string;
@@ -63,6 +65,16 @@ const routes: RouteModal[] = [
63
65
  name: "表单",
64
66
  element: <Form />,
65
67
  },
68
+ {
69
+ path: "/modalForm",
70
+ name: "弹窗表单",
71
+ element: <ModalForm />,
72
+ },
73
+ {
74
+ path: "/drawerForm",
75
+ name: "抽屉表单",
76
+ element: <DrawerForm />,
77
+ },
66
78
  ];
67
79
 
68
80
  export default routes;