@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.
@@ -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 TypeEle = (function (_ref) {
6
- var mediaType = _ref.mediaType,
7
- url = _ref.url,
8
- onReady = _ref.onReady,
9
- onError = _ref.onError;
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%",
@@ -1,5 +1,6 @@
1
1
  export declare enum MediaTypeEnum {
2
2
  video = 0,
3
3
  audio = 1,
4
- img = 2
4
+ img = 2,
5
+ file = 3
5
6
  }
@@ -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 };
@@ -113,6 +113,7 @@ var Index = function Index(_ref, ref) {
113
113
  }
114
114
  }
115
115
  });
116
+ console.log(onPreview, "onPreview");
116
117
  return jsxs("div", {
117
118
  style: contentStyle,
118
119
  children: [jsx(Upload, _objectSpread(_objectSpread({
@@ -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 TypeEle = (function (_ref) {
9
- var mediaType = _ref.mediaType,
10
- url = _ref.url,
11
- onReady = _ref.onReady,
12
- onError = _ref.onError;
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%",
@@ -1,5 +1,6 @@
1
1
  export declare enum MediaTypeEnum {
2
2
  video = 0,
3
3
  audio = 1,
4
- img = 2
4
+ img = 2,
5
+ file = 3
5
6
  }
@@ -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
@@ -116,6 +116,7 @@ var Index = function Index(_ref, ref) {
116
116
  }
117
117
  }
118
118
  });
119
+ console.log(onPreview, "onPreview");
119
120
  return jsxRuntime.jsxs("div", {
120
121
  style: contentStyle,
121
122
  children: [jsxRuntime.jsx(antd.Upload, _objectSpread(_objectSpread({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.0.9",
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 { MediaTypeEnum } from "../enums";
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
  };
@@ -2,4 +2,5 @@ export enum MediaTypeEnum {
2
2
  video,
3
3
  audio,
4
4
  img,
5
+ file
5
6
  }
@@ -90,6 +90,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
90
90
  },
91
91
  },
92
92
  });
93
+ console.log(onPreview,"onPreview")
93
94
  return (
94
95
  <div style={contentStyle}>
95
96
  <Upload
@@ -1,6 +1,7 @@
1
- import { Space } from "antd";
2
- import { HUrlUpload, HUpload } from "../../components";
3
- import React, { useState } from "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} onChange={setFiles1} />
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
  };