@hw-component/form 0.0.1-beta-v6 → 0.0.1-beta-v7
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/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/{ModalForm/index.js → DiaLogForm/ModalForm.js} +36 -6
- package/es/{ModalForm → DiaLogForm}/hooks.d.ts +5 -2
- package/es/{ModalForm → DiaLogForm}/hooks.js +52 -7
- package/es/{ModalForm → DiaLogForm}/modal.d.ts +4 -1
- package/es/Form/HFormConnect.d.ts +1 -2
- package/es/Form/HFormConnect.js +8 -15
- package/es/Form/config.d.ts +4 -4
- package/es/Form/config.js +4 -4
- package/es/Form/modal.d.ts +7 -1
- package/es/Input/SelectInput.d.ts +1 -1
- package/es/TDPicker/RangePicker.d.ts +1 -1
- package/es/Upload/UrlUpload/index.d.ts +2 -2
- package/es/Upload/UrlUpload/index.js +3 -3
- 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/index.d.ts +7 -6
- package/es/index.js +5 -3
- package/lib/CheckboxGroup/index.d.ts +1 -1
- 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/{ModalForm/index.js → DiaLogForm/ModalForm.js} +35 -5
- package/lib/{ModalForm → DiaLogForm}/hooks.d.ts +5 -2
- package/lib/{ModalForm → DiaLogForm}/hooks.js +52 -6
- package/lib/{ModalForm → DiaLogForm}/modal.d.ts +4 -1
- package/lib/Form/HFormConnect.d.ts +1 -2
- package/lib/Form/HFormConnect.js +8 -15
- package/lib/Form/config.d.ts +4 -4
- package/lib/Form/modal.d.ts +7 -1
- package/lib/Input/SelectInput.d.ts +1 -1
- package/lib/TDPicker/RangePicker.d.ts +1 -1
- package/lib/Upload/UrlUpload/index.d.ts +2 -2
- package/lib/Upload/UrlUpload/index.js +3 -3
- 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/index.d.ts +7 -6
- package/lib/index.js +6 -3
- package/package.json +1 -1
- 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/{ModalForm/index.tsx → DiaLogForm/ModalForm.tsx} +10 -2
- package/src/components/{ModalForm → DiaLogForm}/hooks.ts +27 -2
- package/src/components/{ModalForm → DiaLogForm}/modal.ts +4 -1
- package/src/components/Form/HFormConnect.tsx +21 -7
- package/src/components/Form/config.ts +2 -2
- package/src/components/Form/modal.ts +7 -1
- package/src/components/Input/SelectInput.tsx +1 -0
- package/src/components/TDPicker/modal.ts +0 -1
- package/src/components/Upload/UrlUpload/index.tsx +2 -2
- package/src/components/Upload/index.tsx +39 -7
- package/src/components/Upload/modal.ts +2 -0
- package/src/components/index.tsx +5 -4
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +3 -0
- package/src/routes.tsx +7 -0
- package/es/ModalForm/index.d.ts +0 -4
- package/lib/ModalForm/index.d.ts +0 -4
|
@@ -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;
|
|
@@ -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/index.tsx
CHANGED
|
@@ -3,9 +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 { useHModalForm } from "./
|
|
7
|
-
import ModalForm from "./ModalForm";
|
|
8
|
-
|
|
6
|
+
export { useHModalForm } from "./DiaLogForm/hooks";
|
|
7
|
+
import ModalForm from "./DiaLogForm/ModalForm";
|
|
8
|
+
import DrawerForm from "./DiaLogForm/DrawerForm";
|
|
9
9
|
export const HSelect = FormConfig.select;
|
|
10
10
|
export const HInput = FormConfig.input;
|
|
11
11
|
export const HSelectInput = FormConfig.selectInput;
|
|
@@ -22,5 +22,6 @@ export const HTimePicker = FormConfig.timePicker;
|
|
|
22
22
|
export const HInputNumber = FormConfig.inputNumber;
|
|
23
23
|
export const HPageHandler = PageHandler;
|
|
24
24
|
export const HFormConfigProvider = FormConfig.formConfigProvider;
|
|
25
|
-
export const
|
|
25
|
+
export const HTextArea = FormConfig.textArea;
|
|
26
26
|
export const HModalForm = ModalForm;
|
|
27
|
+
export const HDrawerForm = DrawerForm;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Button } from "antd";
|
|
2
|
+
import { HDrawerForm, useHModalForm } 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 = useHModalForm();
|
|
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
package/src/routes.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import DatePicker from "./pages/DatePicker";
|
|
|
9
9
|
import Upload from "./pages/Upload";
|
|
10
10
|
import Form from "./pages/Form";
|
|
11
11
|
import ModalForm from "./pages/ModalForm";
|
|
12
|
+
import DrawerForm from "./pages/DrawerForm";
|
|
13
|
+
|
|
12
14
|
export interface RouteModal {
|
|
13
15
|
path?: string;
|
|
14
16
|
name?: string;
|
|
@@ -68,6 +70,11 @@ const routes: RouteModal[] = [
|
|
|
68
70
|
name: "弹窗表单",
|
|
69
71
|
element: <ModalForm />,
|
|
70
72
|
},
|
|
73
|
+
{
|
|
74
|
+
path: "/drawerForm",
|
|
75
|
+
name: "抽屉表单",
|
|
76
|
+
element: <DrawerForm />,
|
|
77
|
+
},
|
|
71
78
|
];
|
|
72
79
|
|
|
73
80
|
export default routes;
|
package/es/ModalForm/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ModalFormProps } from "@/components/ModalForm/modal";
|
|
3
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, ...props }: ModalFormProps) => JSX.Element;
|
|
4
|
-
export default _default;
|
package/lib/ModalForm/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { ModalFormProps } from "@/components/ModalForm/modal";
|
|
3
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, ...props }: ModalFormProps) => JSX.Element;
|
|
4
|
-
export default _default;
|