@hw-component/form 0.0.2-bate → 0.0.2-beta-v1
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/CheckboxGroup/index.d.ts +1 -1
- package/es/CheckboxGroup/index.js +4 -2
- package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Footer.js +23 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Title.js +18 -0
- package/es/DialogForm/DrawerForm/index.d.ts +4 -0
- package/es/DialogForm/DrawerForm/index.js +111 -0
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/DialogForm/ModalForm.js +89 -0
- package/es/DialogForm/hooks.d.ts +14 -0
- package/es/DialogForm/hooks.js +124 -0
- package/es/DialogForm/modal.d.ts +25 -0
- package/es/Form/HFormConnect.d.ts +1 -2
- package/es/Form/HFormConnect.js +17 -16
- package/es/Form/InitSet.d.ts +1 -4
- package/es/Form/InitSet.js +2 -3
- package/es/Form/config.d.ts +5 -4
- package/es/Form/config.js +6 -4
- package/es/Form/hooks/index.d.ts +0 -6
- package/es/Form/hooks/index.js +1 -33
- package/es/Form/hooks/useHForm.js +72 -15
- package/es/Form/index.js +46 -15
- package/es/Form/modal.d.ts +20 -8
- package/es/Input/SelectInput.d.ts +2 -2
- package/es/Input/SelectInput.js +8 -5
- package/es/Input/modal.d.ts +2 -0
- package/es/Select/hooks/norHooks.d.ts +1 -1
- package/es/TDPicker/RangePicker.d.ts +1 -1
- package/es/TDPicker/RangePicker.js +4 -2
- package/es/TextArea/index.js +21 -0
- package/es/Upload/UrlUpload/index.d.ts +2 -2
- package/es/Upload/UrlUpload/index.js +3 -3
- package/es/Upload/hooks/customRequest.js +99 -36
- package/es/Upload/index.d.ts +1 -2
- package/es/Upload/index.js +39 -5
- package/es/Upload/modal.d.ts +2 -0
- package/es/config.js +4 -4
- package/es/index.css +1 -1
- package/es/index.d.ts +8 -4
- package/es/index.js +7 -1
- package/lib/CheckboxGroup/index.d.ts +1 -1
- package/lib/CheckboxGroup/index.js +4 -2
- package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Footer.js +26 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Title.js +21 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/index.js +114 -0
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/DialogForm/ModalForm.js +92 -0
- package/lib/DialogForm/hooks.d.ts +14 -0
- package/lib/DialogForm/hooks.js +128 -0
- package/lib/DialogForm/modal.d.ts +25 -0
- package/lib/Form/HFormConnect.d.ts +1 -2
- package/lib/Form/HFormConnect.js +17 -16
- package/lib/Form/InitSet.d.ts +1 -4
- package/lib/Form/InitSet.js +2 -3
- package/lib/Form/config.d.ts +5 -4
- package/lib/Form/config.js +3 -1
- package/lib/Form/hooks/index.d.ts +0 -6
- package/lib/Form/hooks/index.js +0 -33
- package/lib/Form/hooks/useHForm.js +72 -15
- package/lib/Form/index.js +53 -22
- package/lib/Form/modal.d.ts +20 -8
- package/lib/Input/SelectInput.d.ts +2 -2
- package/lib/Input/SelectInput.js +8 -5
- package/lib/Input/modal.d.ts +2 -0
- package/lib/Select/hooks/norHooks.d.ts +1 -1
- package/lib/TDPicker/RangePicker.d.ts +1 -1
- package/lib/TDPicker/RangePicker.js +4 -2
- package/lib/TextArea/index.js +24 -0
- package/lib/Upload/UrlUpload/index.d.ts +2 -2
- package/lib/Upload/UrlUpload/index.js +3 -3
- package/lib/Upload/hooks/customRequest.js +99 -36
- package/lib/Upload/index.d.ts +1 -2
- package/lib/Upload/index.js +39 -5
- package/lib/Upload/modal.d.ts +2 -0
- package/lib/config.js +4 -4
- package/lib/index.css +1 -1
- package/lib/index.d.ts +8 -4
- package/lib/index.js +10 -0
- package/package.json +1 -1
- package/src/components/CheckboxGroup/index.tsx +2 -2
- package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
- package/src/components/DialogForm/ModalForm.tsx +60 -0
- package/src/components/DialogForm/hooks.ts +87 -0
- package/src/components/DialogForm/modal.ts +27 -0
- package/src/components/Form/FormItem/Helper.tsx +3 -4
- package/src/components/Form/HFormConnect.tsx +26 -8
- package/src/components/Form/InitSet.tsx +3 -5
- package/src/components/Form/config.ts +2 -1
- package/src/components/Form/hooks/index.ts +0 -20
- package/src/components/Form/hooks/useHForm.ts +67 -14
- package/src/components/Form/index.less +1 -1
- package/src/components/Form/index.tsx +25 -7
- package/src/components/Form/modal.ts +22 -10
- package/src/components/Input/SelectInput.tsx +4 -2
- package/src/components/Input/modal.ts +2 -0
- package/src/components/TDPicker/RangePicker.tsx +5 -6
- package/src/components/Upload/UrlUpload/index.tsx +2 -2
- package/src/components/Upload/hooks/customRequest.ts +57 -14
- package/src/components/Upload/index.tsx +39 -7
- package/src/components/Upload/modal.ts +2 -0
- package/src/components/config.ts +4 -4
- package/src/components/index.tsx +6 -0
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +3 -0
- package/src/pages/ModalForm/index.tsx +127 -0
- package/src/routes.tsx +12 -0
|
@@ -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
|
-
|
|
24
|
-
|
|
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
|
|
8
|
-
import
|
|
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,40 @@ 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 fileList = initFileList.map((url, index) => {
|
|
65
|
+
return {
|
|
66
|
+
name: url,
|
|
67
|
+
response: {
|
|
68
|
+
url,
|
|
69
|
+
},
|
|
70
|
+
status: "done",
|
|
71
|
+
uid: `init-${index}`,
|
|
72
|
+
thumbUrl: url,
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
[name]: fileList,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
outputValue: (item, outputValue) => {
|
|
80
|
+
const { name: valueName = "" } = item;
|
|
81
|
+
const { [valueName]: itemVal = [] } = outputValue;
|
|
82
|
+
const urls = itemVal.map((fileItem) => {
|
|
83
|
+
return fileItem.response.url;
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
[valueName]: urls,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
59
91
|
return (
|
|
60
92
|
<div style={contentStyle}>
|
|
61
93
|
<Upload
|
|
@@ -82,4 +114,4 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
82
114
|
);
|
|
83
115
|
};
|
|
84
116
|
|
|
85
|
-
export default React.forwardRef(Index);
|
|
117
|
+
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;
|
package/src/components/config.ts
CHANGED
|
@@ -7,12 +7,12 @@ export const baseConfig: IFormConfigContextProps = {
|
|
|
7
7
|
value: "value",
|
|
8
8
|
},
|
|
9
9
|
valueCheckMap: {
|
|
10
|
-
checked:
|
|
11
|
-
noChecked:
|
|
10
|
+
checked: 1,
|
|
11
|
+
noChecked: 0,
|
|
12
12
|
},
|
|
13
13
|
valueSwitchMap: {
|
|
14
|
-
open:
|
|
15
|
-
close:
|
|
14
|
+
open: 1,
|
|
15
|
+
close: 0,
|
|
16
16
|
},
|
|
17
17
|
valueRangePickerValueMap: {
|
|
18
18
|
start: (name) => {
|
package/src/components/index.tsx
CHANGED
|
@@ -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
|
+
};
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -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;
|