@hw-component/form 1.2.3 → 1.2.5
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/FormItem/BasicItem.js +0 -1
- package/es/Form/FormItem/hooks.d.ts +2 -2
- package/es/Form/config.d.ts +1 -1
- package/es/Form/config.js +1 -1
- package/es/Form/modal.d.ts +2 -1
- package/es/Input/VerificationCodeInput/hooks.d.ts +1 -1
- package/es/Input/VerificationCodeInput/index.d.ts +2 -2
- package/es/Upload/UrlUpload/hooks.d.ts +2 -0
- package/es/Upload/UrlUpload/hooks.js +20 -0
- package/es/Upload/UrlUpload/index.d.ts +1 -1
- package/es/Upload/UrlUpload/index.js +21 -5
- package/es/Upload/hooks/change.d.ts +1 -1
- package/es/Upload/hooks/change.js +16 -9
- package/es/Upload/index.js +4 -3
- package/es/Upload/modal.d.ts +3 -0
- package/es/index.css +1 -1
- package/es/index.d.ts +1 -1
- package/lib/Form/FormItem/BasicItem.js +0 -1
- package/lib/Form/FormItem/hooks.d.ts +2 -2
- package/lib/Form/config.d.ts +1 -1
- package/lib/Form/config.js +1 -1
- package/lib/Form/modal.d.ts +2 -1
- package/lib/Input/VerificationCodeInput/hooks.d.ts +1 -1
- package/lib/Input/VerificationCodeInput/index.d.ts +2 -2
- package/lib/Upload/UrlUpload/hooks.d.ts +2 -0
- package/lib/Upload/UrlUpload/hooks.js +21 -0
- package/lib/Upload/UrlUpload/index.d.ts +1 -1
- package/lib/Upload/UrlUpload/index.js +20 -4
- package/lib/Upload/hooks/change.d.ts +1 -1
- package/lib/Upload/hooks/change.js +16 -9
- package/lib/Upload/index.js +4 -3
- package/lib/Upload/modal.d.ts +3 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Form/FormItem/BasicItem.tsx +0 -1
- package/src/components/Form/FormItem/hooks.tsx +4 -3
- package/src/components/Form/config.ts +1 -0
- package/src/components/Form/index.less +1 -1
- package/src/components/Form/modal.ts +4 -2
- package/src/components/Input/VerificationCodeInput/hooks.ts +2 -2
- package/src/components/Input/VerificationCodeInput/index.tsx +5 -5
- package/src/components/Upload/UrlUpload/hooks.ts +16 -0
- package/src/components/Upload/UrlUpload/index.tsx +13 -5
- package/src/components/Upload/hooks/change.ts +8 -1
- package/src/components/Upload/index.tsx +2 -1
- package/src/components/Upload/modal.ts +3 -0
- package/src/components/Upload/util.ts +1 -0
- package/src/pages/Form/index.tsx +16 -0
|
@@ -2,21 +2,21 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import ButtonInput from "../ButtonInput";
|
|
3
3
|
import { useRequest } from "ahooks";
|
|
4
4
|
import type { HFormInstance } from "../../Form/modal";
|
|
5
|
-
import {HButtonInputProps} from "../modal";
|
|
5
|
+
import type {HButtonInputProps} from "../modal";
|
|
6
6
|
import HFormConnect from "../../Form/HFormConnect";
|
|
7
|
-
import {argsFn} from "../../Form/modal";
|
|
7
|
+
import type {argsFn} from "../../Form/modal";
|
|
8
8
|
import {useDis} from "./hooks";
|
|
9
9
|
|
|
10
|
-
type disabledFn=(data:any)=>boolean;
|
|
10
|
+
type disabledFn=(data: any) => boolean;
|
|
11
11
|
export interface ButtonProps extends Omit<HButtonInputProps["buttonProps"],"disabled">{
|
|
12
|
-
disabled?:boolean|disabledFn;
|
|
12
|
+
disabled?: boolean|disabledFn;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface HVerificationCodeInputProps extends Omit<HButtonInputProps, "form"|"buttonProps"> {
|
|
16
16
|
request?: (value: any) => Promise<any>;
|
|
17
17
|
form?: HFormInstance;
|
|
18
18
|
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
19
|
-
buttonProps?:ButtonProps;
|
|
19
|
+
buttonProps?: ButtonProps;
|
|
20
20
|
}
|
|
21
21
|
const Index= ({
|
|
22
22
|
value,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {IUrlUploadProps} from "../modal";
|
|
2
|
+
import {MediaTypeEnum} from '../enums';
|
|
3
|
+
|
|
4
|
+
const defaultExFiles={
|
|
5
|
+
[MediaTypeEnum.video]:["MP4"],
|
|
6
|
+
[MediaTypeEnum.audio]:["MP3"],
|
|
7
|
+
}
|
|
8
|
+
export const useDefaultExFiles=({mediaType=MediaTypeEnum.img,exFiles}: IUrlUploadProps)=>{
|
|
9
|
+
console.log(exFiles,"exFiles")
|
|
10
|
+
if (exFiles){
|
|
11
|
+
return exFiles;
|
|
12
|
+
};
|
|
13
|
+
console.log(defaultExFiles,mediaType===MediaTypeEnum.video,"mediaType")
|
|
14
|
+
|
|
15
|
+
return defaultExFiles[mediaType]
|
|
16
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { message, Space } from "antd";
|
|
1
|
+
import { message, Space ,Typography} from "antd";
|
|
2
2
|
import Input from "antd/es/input/Input";
|
|
3
3
|
import Upload from "../index";
|
|
4
4
|
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
|
-
|
|
8
|
+
import {useDefaultExFiles} from "./hooks";
|
|
9
|
+
const {Text}=Typography;
|
|
9
10
|
const mkSubFileList = (fileList: UploadFile[], maxCount = 1) => {
|
|
10
11
|
const len = fileList.length;
|
|
11
12
|
if (len > maxCount) {
|
|
@@ -19,12 +20,17 @@ const Index = ({
|
|
|
19
20
|
value = [],
|
|
20
21
|
onChange,
|
|
21
22
|
mediaType,
|
|
23
|
+
inputHelper,
|
|
24
|
+
style={},
|
|
25
|
+
exFiles,
|
|
22
26
|
...props
|
|
23
27
|
}: IUrlUploadProps) => {
|
|
24
|
-
const { maxCount
|
|
28
|
+
const { maxCount} = props;
|
|
29
|
+
const defaultExFiles: string[]=useDefaultExFiles({mediaType,exFiles});
|
|
25
30
|
const [url, setUrl] = useState("");
|
|
26
31
|
const [load, setLoad] = useState<boolean>(false);
|
|
27
32
|
const ref = useRef<IUploadRefModal | null>(null);
|
|
33
|
+
|
|
28
34
|
const onReady = () => {
|
|
29
35
|
const newFileList = [...value];
|
|
30
36
|
newFileList.push({
|
|
@@ -76,8 +82,9 @@ const Index = ({
|
|
|
76
82
|
setUrl("");
|
|
77
83
|
setLoad(false);
|
|
78
84
|
};
|
|
85
|
+
const upProps={exFiles:defaultExFiles,...props};
|
|
79
86
|
return (
|
|
80
|
-
<Space direction={"vertical"} style={{
|
|
87
|
+
<Space direction={"vertical"} style={{width:"100%",...style}} size={"middle"}>
|
|
81
88
|
<Input
|
|
82
89
|
placeholder={placeholder}
|
|
83
90
|
onBlur={onBlur}
|
|
@@ -87,7 +94,8 @@ const Index = ({
|
|
|
87
94
|
setUrl(e.target.value);
|
|
88
95
|
}}
|
|
89
96
|
/>
|
|
90
|
-
|
|
97
|
+
{inputHelper&&<Text type={"secondary"}>{inputHelper}</Text>}
|
|
98
|
+
<Upload {...upProps} ref={ref} value={value} onChange={onChange} />
|
|
91
99
|
{load && (
|
|
92
100
|
<div style={{ display: "none" }}>
|
|
93
101
|
<TypeEle
|
|
@@ -50,6 +50,7 @@ export const useChange = ({
|
|
|
50
50
|
request,
|
|
51
51
|
exFiles,
|
|
52
52
|
maxSize,
|
|
53
|
+
thumbUrl
|
|
53
54
|
}: IUpLoadProps) => {
|
|
54
55
|
const customRequest = useCustomRequest({ request, onChange, value });
|
|
55
56
|
|
|
@@ -67,7 +68,13 @@ export const useChange = ({
|
|
|
67
68
|
if (errList.length) {
|
|
68
69
|
message.error(errList[0].message);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
const changeFile=newFileList?.map((item)=>{
|
|
72
|
+
return {
|
|
73
|
+
thumbUrl,
|
|
74
|
+
...item
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
onChange?.(changeFile);
|
|
71
78
|
customRequest(addFile);
|
|
72
79
|
},
|
|
73
80
|
{ manual: true, debounceInterval: 100 }
|
|
@@ -20,6 +20,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
20
20
|
request,
|
|
21
21
|
maxSize,
|
|
22
22
|
addFormat,
|
|
23
|
+
thumbUrl,
|
|
23
24
|
...props
|
|
24
25
|
},
|
|
25
26
|
ref
|
|
@@ -31,6 +32,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
31
32
|
value,
|
|
32
33
|
maxCount,
|
|
33
34
|
onChange,
|
|
35
|
+
thumbUrl
|
|
34
36
|
});
|
|
35
37
|
useImperativeHandle(ref, () => {
|
|
36
38
|
return {
|
|
@@ -90,7 +92,6 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
90
92
|
},
|
|
91
93
|
},
|
|
92
94
|
});
|
|
93
|
-
console.log(onPreview, "onPreview");
|
|
94
95
|
return (
|
|
95
96
|
<div style={contentStyle}>
|
|
96
97
|
<Upload
|
|
@@ -4,6 +4,7 @@ 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
6
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
|
+
import type React from "react";
|
|
7
8
|
|
|
8
9
|
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
9
10
|
exFiles?: string[];
|
|
@@ -16,6 +17,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
16
17
|
maxRowNum?: number;
|
|
17
18
|
maxSize?: number;
|
|
18
19
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
|
+
thumbUrl?: string;
|
|
19
21
|
}
|
|
20
22
|
export interface IMediaTypeEleProps {
|
|
21
23
|
file?: UploadFile;
|
|
@@ -30,4 +32,5 @@ export interface IUploadRefModal {
|
|
|
30
32
|
export interface IUrlUploadProps extends IUpLoadProps {
|
|
31
33
|
placeholder?: string;
|
|
32
34
|
mediaType?: MediaTypeEnum;
|
|
35
|
+
inputHelper?: React.ReactNode
|
|
33
36
|
}
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { HForm, HFormConfigProvider, useHForm } from "../../components";
|
|
|
2
2
|
import { Button, Form, Input } from "antd";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import {useRequest} from "ahooks";
|
|
5
|
+
import {MediaTypeEnum} from "../../components/Upload/enums";
|
|
5
6
|
|
|
6
7
|
const formData = () => {
|
|
7
8
|
return [
|
|
@@ -109,6 +110,21 @@ const formData = () => {
|
|
|
109
110
|
manual:false
|
|
110
111
|
},
|
|
111
112
|
},
|
|
113
|
+
{
|
|
114
|
+
type: "urlUpload",
|
|
115
|
+
name:"urlUpload",
|
|
116
|
+
label:"测试",
|
|
117
|
+
helper:"123123",
|
|
118
|
+
itemProps: {
|
|
119
|
+
inputHelper:"fff",
|
|
120
|
+
style:{
|
|
121
|
+
width:368
|
|
122
|
+
},
|
|
123
|
+
mediaType:MediaTypeEnum.video,
|
|
124
|
+
maxSize:1024*1024*10,
|
|
125
|
+
thumbUrl:"https://inews.gtimg.com/om_bt/OHyQqgC_5oi4Vm0tlH49XvJzqNBHo2Zryxx5F_be5N2cIAA/1000"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
112
128
|
];
|
|
113
129
|
};
|
|
114
130
|
function Ttta({ form }) {
|