@hw-component/form 1.0.9 → 1.1.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/es/Upload/MediaTypeEle/TypeEle.js +19 -6
- package/es/Upload/enums.d.ts +2 -1
- package/es/Upload/enums.js +1 -0
- package/es/Upload/index.js +1 -0
- package/lib/Upload/MediaTypeEle/TypeEle.js +18 -5
- package/lib/Upload/enums.d.ts +2 -1
- package/lib/Upload/enums.js +1 -0
- package/lib/Upload/index.js +1 -0
- package/package.json +2 -1
- package/src/components/Upload/MediaTypeEle/TypeEle.tsx +11 -1
- package/src/components/Upload/enums.ts +1 -0
- package/src/components/Upload/index.tsx +1 -0
- package/src/pages/Upload/index.tsx +12 -4
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { MediaTypeEnum } from '../enums.js';
|
|
4
|
+
import { useEffect } from 'react';
|
|
4
5
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
onReady
|
|
9
|
-
|
|
6
|
+
var File = function File(_ref) {
|
|
7
|
+
var onReady = _ref.onReady;
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
onReady === null || onReady === void 0 || onReady();
|
|
10
|
+
}, []);
|
|
11
|
+
return jsx(Fragment, {});
|
|
12
|
+
};
|
|
13
|
+
var TypeEle = (function (_ref2) {
|
|
14
|
+
var mediaType = _ref2.mediaType,
|
|
15
|
+
url = _ref2.url,
|
|
16
|
+
onReady = _ref2.onReady,
|
|
17
|
+
onError = _ref2.onError;
|
|
10
18
|
if (mediaType === MediaTypeEnum.video) {
|
|
11
19
|
return jsx("video", {
|
|
12
20
|
autoPlay: true,
|
|
@@ -30,6 +38,11 @@ var TypeEle = (function (_ref) {
|
|
|
30
38
|
})
|
|
31
39
|
});
|
|
32
40
|
}
|
|
41
|
+
if (mediaType === MediaTypeEnum.file) {
|
|
42
|
+
return jsx(File, {
|
|
43
|
+
onReady: onReady
|
|
44
|
+
});
|
|
45
|
+
}
|
|
33
46
|
return jsx("img", {
|
|
34
47
|
src: url,
|
|
35
48
|
width: "100%",
|
package/es/Upload/enums.d.ts
CHANGED
package/es/Upload/enums.js
CHANGED
|
@@ -4,6 +4,7 @@ var MediaTypeEnum;
|
|
|
4
4
|
MediaTypeEnum[MediaTypeEnum["video"] = 0] = "video";
|
|
5
5
|
MediaTypeEnum[MediaTypeEnum["audio"] = 1] = "audio";
|
|
6
6
|
MediaTypeEnum[MediaTypeEnum["img"] = 2] = "img";
|
|
7
|
+
MediaTypeEnum[MediaTypeEnum["file"] = 3] = "file";
|
|
7
8
|
})(MediaTypeEnum || (MediaTypeEnum = {}));
|
|
8
9
|
|
|
9
10
|
export { MediaTypeEnum };
|
package/es/Upload/index.js
CHANGED
|
@@ -4,12 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var enums = require('../enums.js');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
onReady
|
|
12
|
-
|
|
9
|
+
var File = function File(_ref) {
|
|
10
|
+
var onReady = _ref.onReady;
|
|
11
|
+
React.useEffect(function () {
|
|
12
|
+
onReady === null || onReady === void 0 || onReady();
|
|
13
|
+
}, []);
|
|
14
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
15
|
+
};
|
|
16
|
+
var TypeEle = (function (_ref2) {
|
|
17
|
+
var mediaType = _ref2.mediaType,
|
|
18
|
+
url = _ref2.url,
|
|
19
|
+
onReady = _ref2.onReady,
|
|
20
|
+
onError = _ref2.onError;
|
|
13
21
|
if (mediaType === enums.MediaTypeEnum.video) {
|
|
14
22
|
return jsxRuntime.jsx("video", {
|
|
15
23
|
autoPlay: true,
|
|
@@ -33,6 +41,11 @@ var TypeEle = (function (_ref) {
|
|
|
33
41
|
})
|
|
34
42
|
});
|
|
35
43
|
}
|
|
44
|
+
if (mediaType === enums.MediaTypeEnum.file) {
|
|
45
|
+
return jsxRuntime.jsx(File, {
|
|
46
|
+
onReady: onReady
|
|
47
|
+
});
|
|
48
|
+
}
|
|
36
49
|
return jsxRuntime.jsx("img", {
|
|
37
50
|
src: url,
|
|
38
51
|
width: "100%",
|
package/lib/Upload/enums.d.ts
CHANGED
package/lib/Upload/enums.js
CHANGED
|
@@ -5,5 +5,6 @@ exports.MediaTypeEnum = void 0;
|
|
|
5
5
|
MediaTypeEnum[MediaTypeEnum["video"] = 0] = "video";
|
|
6
6
|
MediaTypeEnum[MediaTypeEnum["audio"] = 1] = "audio";
|
|
7
7
|
MediaTypeEnum[MediaTypeEnum["img"] = 2] = "img";
|
|
8
|
+
MediaTypeEnum[MediaTypeEnum["file"] = 3] = "file";
|
|
8
9
|
})(exports.MediaTypeEnum || (exports.MediaTypeEnum = {}));
|
|
9
10
|
// powered by h
|
package/lib/Upload/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/form",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "基于antd二次开发",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"author": "hdj",
|
|
11
11
|
"main": "lib/index.js",
|
|
12
12
|
"module": "es/index.js",
|
|
13
|
+
"types": "es/index.d.ts",
|
|
13
14
|
"scripts": {
|
|
14
15
|
"build": "rollup --config ./scripts/rollup.config.js",
|
|
15
16
|
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {MediaTypeEnum} from "../enums";
|
|
2
|
+
import {useEffect} from "react";
|
|
2
3
|
|
|
3
4
|
interface TypeEleProps {
|
|
4
5
|
mediaType?: MediaTypeEnum;
|
|
@@ -6,6 +7,12 @@ interface TypeEleProps {
|
|
|
6
7
|
onReady?: VoidFunction;
|
|
7
8
|
onError?: VoidFunction;
|
|
8
9
|
}
|
|
10
|
+
const File=({onReady}:TypeEleProps)=>{
|
|
11
|
+
useEffect(()=>{
|
|
12
|
+
onReady?.();
|
|
13
|
+
},[])
|
|
14
|
+
return <></>
|
|
15
|
+
}
|
|
9
16
|
export default ({ mediaType, url, onReady, onError }: TypeEleProps) => {
|
|
10
17
|
if (mediaType === MediaTypeEnum.video) {
|
|
11
18
|
return (
|
|
@@ -22,5 +29,8 @@ export default ({ mediaType, url, onReady, onError }: TypeEleProps) => {
|
|
|
22
29
|
</audio>
|
|
23
30
|
);
|
|
24
31
|
}
|
|
32
|
+
if (mediaType===MediaTypeEnum.file){
|
|
33
|
+
return <File onReady={onReady}/>
|
|
34
|
+
}
|
|
25
35
|
return <img src={url} width="100%" onLoad={onReady} onError={onError} />;
|
|
26
36
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HUrlUpload
|
|
3
|
-
import React, {
|
|
1
|
+
import {Space} from "antd";
|
|
2
|
+
import {HUpload, HUrlUpload} from "../../components";
|
|
3
|
+
import React, {useState} from "react";
|
|
4
|
+
import {MediaTypeEnum} from "../../components/Upload/enums";
|
|
4
5
|
|
|
5
6
|
export default () => {
|
|
6
7
|
const [files, setFiles] = useState([]);
|
|
@@ -8,7 +9,14 @@ export default () => {
|
|
|
8
9
|
return (
|
|
9
10
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
10
11
|
<HUpload value={files} onChange={setFiles} multiple={true} maxCount={3} />
|
|
11
|
-
<HUrlUpload value={files1}
|
|
12
|
+
<HUrlUpload value={files1}
|
|
13
|
+
mediaType={MediaTypeEnum.file}
|
|
14
|
+
showUploadList={{
|
|
15
|
+
showPreviewIcon:false
|
|
16
|
+
}}
|
|
17
|
+
exFiles={["TXT",'EXE']}
|
|
18
|
+
onChange={setFiles1}
|
|
19
|
+
/>
|
|
12
20
|
</Space>
|
|
13
21
|
);
|
|
14
22
|
};
|