@hw-component/form 1.4.9 → 1.5.2
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/.eslintcache +1 -1
- package/es/Form/index.js +6 -1
- package/es/Input/InputNumberGroup.d.ts +2 -2
- package/es/Input/InputNumberGroup.js +4 -4
- package/es/Upload/hooks/customRequest.js +11 -6
- package/lib/Form/index.js +6 -1
- package/lib/Input/InputNumberGroup.d.ts +2 -2
- package/lib/Input/InputNumberGroup.js +4 -4
- package/lib/Upload/hooks/customRequest.js +11 -6
- package/package.json +1 -1
- package/src/components/Form/HFormConnect.tsx +6 -7
- package/src/components/Form/config.ts +2 -3
- package/src/components/Form/hooks/useDefaultRender.tsx +1 -1
- package/src/components/Form/hooks/useHForm.ts +10 -7
- package/src/components/Form/index.tsx +5 -1
- package/src/components/Input/InputNumberGroup.tsx +141 -129
- package/src/components/Input/index.less +5 -5
- package/src/components/Select/components/AllSelect.tsx +13 -13
- package/src/components/Select/components/CheckBoxOption.tsx +3 -3
- package/src/components/Select/defaultConfig.tsx +4 -2
- package/src/components/Select/hooks/changeHooks.tsx +2 -2
- package/src/components/Switch/index.tsx +1 -1
- package/src/components/Upload/hooks/customRequest.ts +7 -3
- package/src/components/Upload/index.tsx +1 -1
- package/src/pages/Form/index.tsx +64 -42
- package/src/pages/ModalForm/index.tsx +11 -10
- package/src/pages/Select/index.tsx +1 -1
- package/src/pages/Upload/index.tsx +13 -1
|
@@ -142,11 +142,11 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
142
142
|
onChange(newChangeVal, subItemOps);
|
|
143
143
|
};
|
|
144
144
|
useEffect(() => {
|
|
145
|
-
if (mode === "tags"
|
|
145
|
+
if (mode === "tags") {
|
|
146
146
|
setVal(value);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
if (value===null||value===undefined){
|
|
149
|
+
if (value === null || value === undefined) {
|
|
150
150
|
setVal(undefined);
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
@@ -43,7 +43,7 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
43
43
|
float: {
|
|
44
44
|
inputValue: (item, initValue) => {
|
|
45
45
|
const { close } = valueSwitchMap;
|
|
46
|
-
const { name: valueName="" } = item;
|
|
46
|
+
const { name: valueName = "" } = item;
|
|
47
47
|
let val = initValue[valueName];
|
|
48
48
|
if (typeof val === "undefined" || val === null) {
|
|
49
49
|
val = close;
|
|
@@ -9,13 +9,14 @@ import { message } from "antd";
|
|
|
9
9
|
interface SubReqParamsModal {
|
|
10
10
|
request?: (
|
|
11
11
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
12
|
-
) => Promise<{ url: string }>;
|
|
12
|
+
) => Promise<{ url: string ,thumbUrl?:string}>;
|
|
13
13
|
file: RcFile;
|
|
14
14
|
}
|
|
15
15
|
interface ResultModal {
|
|
16
16
|
url: string;
|
|
17
17
|
status: UploadFileStatus;
|
|
18
18
|
uid?: string;
|
|
19
|
+
thumbUrl?:string;
|
|
19
20
|
}
|
|
20
21
|
const subReq = async ({
|
|
21
22
|
request,
|
|
@@ -28,9 +29,10 @@ const subReq = async ({
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
try {
|
|
31
|
-
const { url } = await request(file);
|
|
32
|
+
const { url ,thumbUrl} = await request(file);
|
|
32
33
|
return {
|
|
33
34
|
url,
|
|
35
|
+
thumbUrl,
|
|
34
36
|
status: "done",
|
|
35
37
|
};
|
|
36
38
|
} catch (err: any) {
|
|
@@ -42,17 +44,19 @@ const subReq = async ({
|
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
46
|
const fileListProvider = (changeFile: ResultModal, files?: UploadFile[]) => {
|
|
45
|
-
const { status, url, uid } = changeFile;
|
|
47
|
+
const { status, url, uid,thumbUrl } = changeFile;
|
|
46
48
|
if (status === "error") {
|
|
47
49
|
return files?.filter((item) => {
|
|
48
50
|
return item.uid !== uid;
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
return files?.map((item) => {
|
|
54
|
+
const fileDefaultThumbUrl=item.thumbUrl||thumbUrl;
|
|
52
55
|
const resultUrl = url || item.thumbUrl;
|
|
53
56
|
if (item.uid === uid) {
|
|
54
57
|
item.status = status;
|
|
55
58
|
item.response = { url: resultUrl };
|
|
59
|
+
item.thumbUrl=fileDefaultThumbUrl;
|
|
56
60
|
return item;
|
|
57
61
|
}
|
|
58
62
|
return item;
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
HForm,
|
|
3
|
+
HFormConfigProvider,
|
|
4
|
+
HSwitch,
|
|
5
|
+
useHForm,
|
|
6
|
+
} from "../../components";
|
|
2
7
|
import { useState } from "react";
|
|
3
|
-
import {Button, DatePicker, Form, Input, Row} from "antd";
|
|
4
|
-
const Test2=()=>{
|
|
5
|
-
return <Row style={{background:"red"}}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
import { Button, DatePicker, Form, Input, Row } from "antd";
|
|
9
|
+
const Test2 = () => {
|
|
10
|
+
return <Row style={{ background: "red" }} />;
|
|
11
|
+
};
|
|
12
|
+
const Test3 = ({ value, onChange }) => {
|
|
13
|
+
return (
|
|
14
|
+
<Input
|
|
15
|
+
value={value.input}
|
|
16
|
+
style={{ width: 100 }}
|
|
17
|
+
onChange={(e) => {
|
|
18
|
+
onChange({
|
|
19
|
+
...value,
|
|
20
|
+
input: e.target.value,
|
|
21
|
+
});
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
19
26
|
const formData = (options) => {
|
|
20
27
|
const op = [
|
|
21
28
|
{
|
|
@@ -28,21 +35,36 @@ const formData = (options) => {
|
|
|
28
35
|
},
|
|
29
36
|
];
|
|
30
37
|
return [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
38
|
+
{
|
|
39
|
+
label: "12321",
|
|
40
|
+
className: "3",
|
|
41
|
+
name: "inputNumberGroup",
|
|
42
|
+
type: "inputNumberGroup",
|
|
43
|
+
itemProps: {
|
|
44
|
+
addonAfter: <Test3 />,
|
|
39
45
|
},
|
|
46
|
+
},
|
|
40
47
|
{
|
|
41
48
|
label: "测试12312",
|
|
42
49
|
className: "hdjd",
|
|
43
|
-
|
|
44
|
-
name:"
|
|
50
|
+
type: "select",
|
|
51
|
+
name: "test321",
|
|
52
|
+
itemProps: {
|
|
53
|
+
options:[{
|
|
54
|
+
value:"选项1",
|
|
55
|
+
key:1
|
|
56
|
+
},{
|
|
57
|
+
value:"选项2",
|
|
58
|
+
key:2
|
|
59
|
+
}],
|
|
60
|
+
showSearch:true
|
|
61
|
+
}
|
|
45
62
|
},
|
|
63
|
+
{
|
|
64
|
+
label: "测试12312",
|
|
65
|
+
className: "hdjd",
|
|
66
|
+
name: "test123",
|
|
67
|
+
},
|
|
46
68
|
];
|
|
47
69
|
};
|
|
48
70
|
function Ttta({ form }) {
|
|
@@ -93,18 +115,18 @@ export default () => {
|
|
|
93
115
|
form={form}
|
|
94
116
|
labelAlign={"right"}
|
|
95
117
|
onFinish={(value) => {
|
|
96
|
-
console.log(value,"
|
|
118
|
+
console.log(value, "onFinish");
|
|
97
119
|
}}
|
|
98
120
|
onValuesChange={(val) => {
|
|
99
121
|
console.log(val, "onValuesChange");
|
|
100
122
|
}}
|
|
101
123
|
initialValues={{
|
|
102
124
|
file: "https://img0.baidu.com/it/u=530540642,263790536&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=667",
|
|
103
|
-
min:1,
|
|
104
|
-
max:2,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
min: 1,
|
|
126
|
+
max: 2,
|
|
127
|
+
inputNumberGroup: {
|
|
128
|
+
input: "xxxxxxx",
|
|
129
|
+
},
|
|
108
130
|
}}
|
|
109
131
|
request={(params) => {
|
|
110
132
|
return new Promise<any>((resolve) => {
|
|
@@ -117,19 +139,19 @@ export default () => {
|
|
|
117
139
|
</HFormConfigProvider>
|
|
118
140
|
<div
|
|
119
141
|
onClick={async () => {
|
|
120
|
-
|
|
121
|
-
|
|
142
|
+
const result = await form.validateFields();
|
|
143
|
+
console.log(result);
|
|
122
144
|
}}
|
|
123
145
|
>
|
|
124
146
|
点我
|
|
125
147
|
</div>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
148
|
+
<div
|
|
149
|
+
onClick={() => {
|
|
150
|
+
form.submit();
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
提交
|
|
154
|
+
</div>
|
|
133
155
|
<div
|
|
134
156
|
onClick={() => {
|
|
135
157
|
form.resetFields();
|
|
@@ -2,14 +2,15 @@ import { Button } from "antd";
|
|
|
2
2
|
import {
|
|
3
3
|
HModalForm,
|
|
4
4
|
useHDialogForm,
|
|
5
|
-
HFormConfigProvider,
|
|
5
|
+
HFormConfigProvider,
|
|
6
|
+
HUrlUpload,
|
|
6
7
|
} from "../../components";
|
|
7
8
|
import { useState } from "react";
|
|
8
9
|
import { ShowParamsModal } from "@/components/DialogForm/modal";
|
|
9
10
|
|
|
10
|
-
const Test=(props)=>{
|
|
11
|
-
return <HUrlUpload {...props}
|
|
12
|
-
}
|
|
11
|
+
const Test = (props) => {
|
|
12
|
+
return <HUrlUpload {...props} />;
|
|
13
|
+
};
|
|
13
14
|
const data = [
|
|
14
15
|
{
|
|
15
16
|
label: "输入框",
|
|
@@ -109,9 +110,9 @@ const data = [
|
|
|
109
110
|
{
|
|
110
111
|
label: "地址文件",
|
|
111
112
|
name: "urlUpload",
|
|
112
|
-
render:()=>{
|
|
113
|
-
return <Test
|
|
114
|
-
}
|
|
113
|
+
render: () => {
|
|
114
|
+
return <Test />;
|
|
115
|
+
},
|
|
115
116
|
},
|
|
116
117
|
{
|
|
117
118
|
label: "下拉框",
|
|
@@ -154,9 +155,9 @@ export default () => {
|
|
|
154
155
|
params: {
|
|
155
156
|
name: num,
|
|
156
157
|
},
|
|
157
|
-
initialValues:{
|
|
158
|
-
urlUpload:"ffff"
|
|
159
|
-
}
|
|
158
|
+
initialValues: {
|
|
159
|
+
urlUpload: "ffff",
|
|
160
|
+
},
|
|
160
161
|
});
|
|
161
162
|
}}
|
|
162
163
|
>
|
|
@@ -14,7 +14,7 @@ export default () => {
|
|
|
14
14
|
<HSelect
|
|
15
15
|
fieldNames={{ label: "name", value: "value" }}
|
|
16
16
|
options={[
|
|
17
|
-
{ name: "测试1", value: 10, userId: 112321,disabled:true },
|
|
17
|
+
{ name: "测试1", value: 10, userId: 112321, disabled: true },
|
|
18
18
|
{ name: "测试2", value: 20, userId: 112321 },
|
|
19
19
|
]}
|
|
20
20
|
placeholder="多选"
|
|
@@ -6,9 +6,21 @@ import { MediaTypeEnum } from "../../components/Upload/enums";
|
|
|
6
6
|
export default () => {
|
|
7
7
|
const [files, setFiles] = useState([]);
|
|
8
8
|
const [files1, setFiles1] = useState([]);
|
|
9
|
+
console.log(files)
|
|
9
10
|
return (
|
|
10
11
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
11
|
-
<HUpload
|
|
12
|
+
<HUpload exFiles={null}
|
|
13
|
+
value={files}
|
|
14
|
+
request={()=>{
|
|
15
|
+
return {
|
|
16
|
+
url:"https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641",
|
|
17
|
+
thumbUrl:"https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641"
|
|
18
|
+
}
|
|
19
|
+
}}
|
|
20
|
+
onChange={setFiles}
|
|
21
|
+
multiple={true}
|
|
22
|
+
maxCount={3}
|
|
23
|
+
maxSize={Number.MAX_SAFE_INTEGER}/>
|
|
12
24
|
<HUrlUpload
|
|
13
25
|
value={files1}
|
|
14
26
|
mediaType={MediaTypeEnum.file}
|