assui 2.0.2 → 2.0.6
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/button-drawer/index.d.ts +10 -0
- package/es/button-drawer/index.js +116 -0
- package/es/button-drawer/style/index.d.ts +1 -0
- package/es/button-drawer/style/index.js +1 -0
- package/es/button-modal/index.d.ts +14 -0
- package/es/button-modal/index.js +131 -0
- package/es/button-modal/style/index.d.ts +1 -0
- package/es/button-modal/style/index.js +1 -0
- package/es/condition-input/index.d.ts +15 -0
- package/es/condition-input/index.js +108 -0
- package/es/condition-input/parse2RegexOption.d.ts +13 -0
- package/es/condition-input/parse2RegexOption.js +57 -0
- package/es/condition-input/style/index.d.ts +1 -0
- package/es/condition-input/style/index.js +1 -0
- package/es/copy-to-clipboard/index.d.ts +22 -0
- package/es/copy-to-clipboard/index.js +95 -0
- package/es/copy-to-clipboard/style/index.css +249 -0
- package/es/copy-to-clipboard/style/index.d.ts +1 -0
- package/es/copy-to-clipboard/style/index.js +1 -0
- package/es/copy-to-clipboard/style/index.less +1 -0
- package/es/highlight-textarea/HighlighedContents.d.ts +7 -0
- package/es/highlight-textarea/HighlighedContents.js +15 -0
- package/es/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
- package/es/highlight-textarea/extractSpansOfClasses.js +159 -0
- package/es/highlight-textarea/getRanges.d.ts +2 -0
- package/es/highlight-textarea/getRanges.js +142 -0
- package/es/highlight-textarea/getType.d.ts +2 -0
- package/es/highlight-textarea/getType.js +29 -0
- package/es/highlight-textarea/index.d.ts +12 -0
- package/es/highlight-textarea/index.js +132 -0
- package/es/highlight-textarea/style/index.css +38 -0
- package/es/highlight-textarea/style/index.d.ts +2 -0
- package/es/highlight-textarea/style/index.js +2 -0
- package/es/highlight-textarea/style/index.less +42 -0
- package/es/highlight-textarea/types.d.ts +16 -0
- package/es/highlight-textarea/types.js +0 -0
- package/es/highlight-words/index.d.ts +3 -0
- package/es/highlight-words/index.js +2 -0
- package/es/highlight-words/style/index.d.ts +1 -0
- package/es/highlight-words/style/index.js +0 -0
- package/es/icon/demo/svg/check-circle-filled.svg +6 -0
- package/es/icon/demo/svg/coin-circle.svg +9 -0
- package/es/icon/index.d.ts +27 -0
- package/es/icon/index.js +95 -0
- package/es/icon/style/index.d.ts +1 -0
- package/es/icon/style/index.js +0 -0
- package/es/icon/utils.d.ts +6 -0
- package/es/icon/utils.js +22 -0
- package/es/img-crop/EasyCrop.d.ts +6 -0
- package/es/img-crop/EasyCrop.js +113 -0
- package/es/img-crop/getCroppedImg.d.ts +6 -0
- package/es/img-crop/getCroppedImg.js +199 -0
- package/es/img-crop/index.d.ts +53 -0
- package/es/img-crop/index.js +531 -0
- package/es/img-crop/style/index.css +52 -0
- package/es/img-crop/style/index.d.ts +3 -0
- package/es/img-crop/style/index.js +3 -0
- package/es/img-crop/style/index.less +54 -0
- package/es/index.d.ts +34 -2
- package/es/index.js +18 -2
- package/es/keep-tab/demo/index.modules.less +66 -0
- package/es/keep-tab/index.d.ts +29 -0
- package/es/keep-tab/index.js +129 -0
- package/es/keep-tab/style/index.css +1129 -0
- package/es/keep-tab/style/index.d.ts +2 -0
- package/es/keep-tab/style/index.js +2 -0
- package/es/keep-tab/style/index.less +2 -0
- package/es/number-input/index.d.ts +22 -7
- package/es/number-input/index.js +22 -11
- package/es/number-input/style/index.d.ts +1 -1
- package/es/number-input/style/index.js +1 -1
- package/es/number-input/utils.d.ts +10 -11
- package/es/number-input/utils.js +7 -7
- package/es/rc-echart/core.d.ts +32 -0
- package/es/rc-echart/core.js +136 -0
- package/es/rc-echart/index.d.ts +21 -0
- package/es/rc-echart/index.js +27 -0
- package/es/rc-echart/style/index.d.ts +1 -0
- package/es/rc-echart/style/index.js +0 -0
- package/es/rc-motion/demo/CSSMotion.less +91 -0
- package/es/rc-motion/index.d.ts +2 -0
- package/es/rc-motion/index.js +2 -0
- package/es/rc-motion/style/index.d.ts +1 -0
- package/es/rc-motion/style/index.js +0 -0
- package/es/rc-qrcode/index.d.ts +20 -0
- package/es/rc-qrcode/index.js +57 -0
- package/es/rc-qrcode/style/index.d.ts +1 -0
- package/es/rc-qrcode/style/index.js +0 -0
- package/es/rc-qrcode/useQrcode.d.ts +4 -0
- package/es/rc-qrcode/useQrcode.js +50 -0
- package/es/rc-transition-group/index.d.ts +2 -0
- package/es/rc-transition-group/index.js +2 -0
- package/es/rc-transition-group/style/index.d.ts +1 -0
- package/es/rc-transition-group/style/index.js +0 -0
- package/es/single-img-upload/index.d.ts +19 -0
- package/es/single-img-upload/index.js +199 -0
- package/es/single-img-upload/style/index.css +74 -0
- package/es/single-img-upload/style/index.d.ts +3 -0
- package/es/single-img-upload/style/index.js +3 -0
- package/es/single-img-upload/style/index.less +85 -0
- package/es/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
- package/es/sortable-hoc/demo/index.modules.less +248 -0
- package/es/sortable-hoc/index.d.ts +2 -0
- package/es/sortable-hoc/index.js +2 -0
- package/es/sortable-hoc/style/index.d.ts +1 -0
- package/es/sortable-hoc/style/index.js +0 -0
- package/es/split-pane/index.d.ts +59 -0
- package/es/split-pane/index.js +21 -0
- package/es/split-pane/style/index.css +41 -0
- package/es/split-pane/style/index.d.ts +1 -0
- package/es/split-pane/style/index.js +1 -0
- package/es/split-pane/style/index.less +49 -0
- package/es/text-area/index.d.ts +12 -0
- package/es/text-area/index.js +96 -0
- package/es/text-area/style/index.d.ts +1 -0
- package/es/text-area/style/index.js +1 -0
- package/es/text-input/index.d.ts +5 -0
- package/es/text-input/index.js +85 -0
- package/es/{number-input → text-input}/style/index.css +0 -3
- package/es/text-input/style/index.d.ts +1 -0
- package/es/text-input/style/index.js +1 -0
- package/es/{number-input → text-input}/style/index.less +0 -4
- package/lib/button-drawer/index.d.ts +10 -0
- package/lib/button-drawer/index.js +164 -0
- package/lib/button-drawer/style/index.d.ts +1 -0
- package/lib/button-drawer/style/index.js +7 -0
- package/lib/button-modal/index.d.ts +14 -0
- package/lib/button-modal/index.js +178 -0
- package/lib/button-modal/style/index.d.ts +1 -0
- package/lib/button-modal/style/index.js +7 -0
- package/lib/condition-input/index.d.ts +15 -0
- package/lib/condition-input/index.js +158 -0
- package/lib/condition-input/parse2RegexOption.d.ts +13 -0
- package/lib/condition-input/parse2RegexOption.js +72 -0
- package/lib/condition-input/style/index.d.ts +1 -0
- package/lib/condition-input/style/index.js +7 -0
- package/lib/copy-to-clipboard/index.d.ts +22 -0
- package/lib/copy-to-clipboard/index.js +143 -0
- package/lib/copy-to-clipboard/style/index.css +249 -0
- package/lib/copy-to-clipboard/style/index.d.ts +1 -0
- package/lib/copy-to-clipboard/style/index.js +7 -0
- package/lib/copy-to-clipboard/style/index.less +1 -0
- package/lib/highlight-textarea/HighlighedContents.d.ts +7 -0
- package/lib/highlight-textarea/HighlighedContents.js +29 -0
- package/lib/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
- package/lib/highlight-textarea/extractSpansOfClasses.js +173 -0
- package/lib/highlight-textarea/getRanges.d.ts +2 -0
- package/lib/highlight-textarea/getRanges.js +156 -0
- package/lib/highlight-textarea/getType.d.ts +2 -0
- package/lib/highlight-textarea/getType.js +37 -0
- package/lib/highlight-textarea/index.d.ts +12 -0
- package/lib/highlight-textarea/index.js +183 -0
- package/lib/highlight-textarea/style/index.css +38 -0
- package/lib/highlight-textarea/style/index.d.ts +2 -0
- package/lib/highlight-textarea/style/index.js +9 -0
- package/lib/highlight-textarea/style/index.less +42 -0
- package/lib/highlight-textarea/types.d.ts +16 -0
- package/lib/highlight-textarea/types.js +5 -0
- package/lib/highlight-words/index.d.ts +3 -0
- package/lib/highlight-words/index.js +15 -0
- package/lib/highlight-words/style/index.d.ts +1 -0
- package/lib/highlight-words/style/index.js +0 -0
- package/lib/icon/demo/svg/check-circle-filled.svg +6 -0
- package/lib/icon/demo/svg/coin-circle.svg +9 -0
- package/lib/icon/index.d.ts +27 -0
- package/lib/icon/index.js +143 -0
- package/lib/icon/style/index.d.ts +1 -0
- package/lib/icon/style/index.js +0 -0
- package/lib/icon/utils.d.ts +6 -0
- package/lib/icon/utils.js +32 -0
- package/lib/img-crop/EasyCrop.d.ts +6 -0
- package/lib/img-crop/EasyCrop.js +160 -0
- package/lib/img-crop/getCroppedImg.d.ts +6 -0
- package/lib/img-crop/getCroppedImg.js +205 -0
- package/lib/img-crop/index.d.ts +53 -0
- package/lib/img-crop/index.js +582 -0
- package/lib/img-crop/style/index.css +52 -0
- package/lib/img-crop/style/index.d.ts +3 -0
- package/lib/img-crop/style/index.js +11 -0
- package/lib/img-crop/style/index.less +54 -0
- package/lib/index.d.ts +34 -2
- package/lib/index.js +160 -9
- package/lib/keep-tab/demo/index.modules.less +66 -0
- package/lib/keep-tab/index.d.ts +29 -0
- package/lib/keep-tab/index.js +181 -0
- package/lib/keep-tab/style/index.css +1129 -0
- package/lib/keep-tab/style/index.d.ts +2 -0
- package/lib/keep-tab/style/index.js +9 -0
- package/lib/keep-tab/style/index.less +2 -0
- package/lib/number-input/index.d.ts +22 -7
- package/lib/number-input/index.js +22 -11
- package/lib/number-input/style/index.d.ts +1 -1
- package/lib/number-input/style/index.js +1 -1
- package/lib/number-input/utils.d.ts +10 -11
- package/lib/number-input/utils.js +8 -8
- package/lib/rc-echart/core.d.ts +32 -0
- package/lib/rc-echart/core.js +185 -0
- package/lib/rc-echart/index.d.ts +21 -0
- package/lib/rc-echart/index.js +75 -0
- package/lib/rc-echart/style/index.d.ts +1 -0
- package/lib/rc-echart/style/index.js +0 -0
- package/lib/rc-motion/demo/CSSMotion.less +91 -0
- package/lib/rc-motion/index.d.ts +2 -0
- package/lib/rc-motion/index.js +43 -0
- package/lib/rc-motion/style/index.d.ts +1 -0
- package/lib/rc-motion/style/index.js +0 -0
- package/lib/rc-qrcode/index.d.ts +20 -0
- package/lib/rc-qrcode/index.js +108 -0
- package/lib/rc-qrcode/style/index.d.ts +1 -0
- package/lib/rc-qrcode/style/index.js +0 -0
- package/lib/rc-qrcode/useQrcode.d.ts +4 -0
- package/lib/rc-qrcode/useQrcode.js +66 -0
- package/lib/rc-transition-group/index.d.ts +2 -0
- package/lib/rc-transition-group/index.js +43 -0
- package/lib/rc-transition-group/style/index.d.ts +1 -0
- package/lib/rc-transition-group/style/index.js +0 -0
- package/lib/single-img-upload/index.d.ts +19 -0
- package/lib/single-img-upload/index.js +250 -0
- package/lib/single-img-upload/style/index.css +74 -0
- package/lib/single-img-upload/style/index.d.ts +3 -0
- package/lib/single-img-upload/style/index.js +11 -0
- package/lib/single-img-upload/style/index.less +85 -0
- package/lib/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
- package/lib/sortable-hoc/demo/index.modules.less +248 -0
- package/lib/sortable-hoc/index.d.ts +2 -0
- package/lib/sortable-hoc/index.js +43 -0
- package/lib/sortable-hoc/style/index.d.ts +1 -0
- package/lib/sortable-hoc/style/index.js +0 -0
- package/lib/split-pane/index.d.ts +59 -0
- package/lib/split-pane/index.js +69 -0
- package/lib/split-pane/style/index.css +41 -0
- package/lib/split-pane/style/index.d.ts +1 -0
- package/lib/split-pane/style/index.js +7 -0
- package/lib/split-pane/style/index.less +49 -0
- package/lib/text-area/index.d.ts +12 -0
- package/lib/text-area/index.js +144 -0
- package/lib/text-area/style/index.d.ts +1 -0
- package/lib/text-area/style/index.js +7 -0
- package/lib/text-input/index.d.ts +5 -0
- package/lib/text-input/index.js +99 -0
- package/lib/{number-input → text-input}/style/index.css +0 -3
- package/lib/text-input/style/index.d.ts +1 -0
- package/lib/text-input/style/index.js +7 -0
- package/lib/{number-input → text-input}/style/index.less +0 -4
- package/package.json +20 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import QRCode, { QRCodeRenderersOptions, QRCodeSegment } from 'qrcode';
|
|
2
|
+
import useQrcode from './useQrcode';
|
|
3
|
+
export interface RcQRcodeProps {
|
|
4
|
+
/** 生成二维码的值 */
|
|
5
|
+
value: QRCodeSegment[];
|
|
6
|
+
/** qrcode的QRCodeRenderersOptions */
|
|
7
|
+
options: QRCodeRenderersOptions;
|
|
8
|
+
/** 获取HTMLCanvasElement */
|
|
9
|
+
getCanvasInstance: (result: HTMLCanvasElement) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const RcQRcode: {
|
|
12
|
+
(props: RcQRcodeProps): JSX.Element;
|
|
13
|
+
defaultProps: {
|
|
14
|
+
value: string;
|
|
15
|
+
options: {};
|
|
16
|
+
};
|
|
17
|
+
useQrcode: (value: string | QRCode.QRCodeSegment[], options: QRCode.QRCodeToDataURLOptions) => string;
|
|
18
|
+
};
|
|
19
|
+
export default RcQRcode;
|
|
20
|
+
export { useQrcode };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
|
|
6
|
+
for (var p in s) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
import * as React from 'react';
|
|
18
|
+
import QRCode from 'qrcode';
|
|
19
|
+
import useMount from 'ahooks/lib/useMount';
|
|
20
|
+
import useQrcode from './useQrcode';
|
|
21
|
+
|
|
22
|
+
var RcQRcode = function RcQRcode(props) {
|
|
23
|
+
var value = props.value,
|
|
24
|
+
options = props.options;
|
|
25
|
+
var domElRef = React.useRef(null);
|
|
26
|
+
var defaultOptions = {
|
|
27
|
+
errorCorrectionLevel: 'H',
|
|
28
|
+
margin: 0,
|
|
29
|
+
width: 134
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var finallyOptions = __assign(__assign({}, defaultOptions), options);
|
|
33
|
+
|
|
34
|
+
useMount(function () {
|
|
35
|
+
QRCode.toCanvas(value, finallyOptions, function (err, result) {
|
|
36
|
+
var _a;
|
|
37
|
+
|
|
38
|
+
if (err) {
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
props === null || props === void 0 ? void 0 : props.getCanvasInstance(result);
|
|
43
|
+
(_a = domElRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(result);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
ref: domElRef
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
RcQRcode.defaultProps = {
|
|
52
|
+
value: '',
|
|
53
|
+
options: {}
|
|
54
|
+
};
|
|
55
|
+
RcQRcode.useQrcode = useQrcode;
|
|
56
|
+
export default RcQRcode;
|
|
57
|
+
export { useQrcode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __read = this && this.__read || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o),
|
|
5
|
+
r,
|
|
6
|
+
ar = [],
|
|
7
|
+
e;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
11
|
+
ar.push(r.value);
|
|
12
|
+
}
|
|
13
|
+
} catch (error) {
|
|
14
|
+
e = {
|
|
15
|
+
error: error
|
|
16
|
+
};
|
|
17
|
+
} finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
} finally {
|
|
21
|
+
if (e) throw e.error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
import QRCode from 'qrcode';
|
|
29
|
+
import { useEffect, useState } from 'react';
|
|
30
|
+
export var useQRCode = function useQRCode(value, options) {
|
|
31
|
+
var _a = __read(useState(''), 2),
|
|
32
|
+
dataURL = _a[0],
|
|
33
|
+
setDataURL = _a[1];
|
|
34
|
+
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (!value) {
|
|
37
|
+
return setDataURL('');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
QRCode.toDataURL(value, options, function (err, url) {
|
|
41
|
+
if (err) {
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setDataURL(url);
|
|
46
|
+
});
|
|
47
|
+
}, [value, options]);
|
|
48
|
+
return dataURL;
|
|
49
|
+
};
|
|
50
|
+
export default useQRCode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UploadProps } from 'rc-upload';
|
|
2
|
+
export interface RcFile extends File {
|
|
3
|
+
uid: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UploadProgressEvent extends ProgressEvent {
|
|
6
|
+
percent: number;
|
|
7
|
+
}
|
|
8
|
+
export interface SingleImgUploadProps extends UploadProps {
|
|
9
|
+
value?: string;
|
|
10
|
+
wrapperClassName?: string;
|
|
11
|
+
onDeleteUpload?: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare const SingleImgUpload: {
|
|
14
|
+
(props: SingleImgUploadProps): JSX.Element;
|
|
15
|
+
defaultProps: {
|
|
16
|
+
beforeUpload(): boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default SingleImgUpload;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
|
|
6
|
+
for (var p in s) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
|
|
20
|
+
for (var p in s) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var __read = this && this.__read || function (o, n) {
|
|
31
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
32
|
+
if (!m) return o;
|
|
33
|
+
var i = m.call(o),
|
|
34
|
+
r,
|
|
35
|
+
ar = [],
|
|
36
|
+
e;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
40
|
+
ar.push(r.value);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
e = {
|
|
44
|
+
error: error
|
|
45
|
+
};
|
|
46
|
+
} finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
} finally {
|
|
50
|
+
if (e) throw e.error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return ar;
|
|
55
|
+
};
|
|
56
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
import * as React from 'react';
|
|
60
|
+
import Upload from 'rc-upload';
|
|
61
|
+
import Progress from 'antd/lib/progress';
|
|
62
|
+
import Image from 'antd/lib/image';
|
|
63
|
+
import classNames from 'classnames';
|
|
64
|
+
import useUpdateEffect from 'ahooks/lib/useUpdateEffect';
|
|
65
|
+
import CloseOutlined from 'a-icons/lib/CloseOutlined';
|
|
66
|
+
|
|
67
|
+
var getLocalImgURL = function getLocalImgURL(file) {
|
|
68
|
+
var URL = window.URL || window.webkitURL;
|
|
69
|
+
var imgURL = URL.createObjectURL(file);
|
|
70
|
+
return imgURL;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
var SingleImgUpload = function SingleImgUpload(props) {
|
|
74
|
+
var className = props.className,
|
|
75
|
+
wrapperClassName = props.wrapperClassName,
|
|
76
|
+
children = props.children,
|
|
77
|
+
value = props.value,
|
|
78
|
+
onStart = props.onStart,
|
|
79
|
+
onDeleteUpload = props.onDeleteUpload,
|
|
80
|
+
onSuccess = props.onSuccess,
|
|
81
|
+
onError = props.onError,
|
|
82
|
+
restProps = __rest(props, ["className", "wrapperClassName", "children", "value", "onStart", "onDeleteUpload", "onSuccess", "onError"]);
|
|
83
|
+
|
|
84
|
+
var uploadInstanceRef = React.useRef();
|
|
85
|
+
var fileRef = React.useRef();
|
|
86
|
+
|
|
87
|
+
var _a = __read(React.useState(value ? 'done' : 'init'), 2),
|
|
88
|
+
uploadStatus = _a[0],
|
|
89
|
+
setUploadStatus = _a[1];
|
|
90
|
+
|
|
91
|
+
var _b = __read(React.useState(value), 2),
|
|
92
|
+
fileUrl = _b[0],
|
|
93
|
+
setFileUrl = _b[1];
|
|
94
|
+
|
|
95
|
+
var _c = __read(React.useState(0), 2),
|
|
96
|
+
uploadPercent = _c[0],
|
|
97
|
+
setUploadPercent = _c[1];
|
|
98
|
+
|
|
99
|
+
useUpdateEffect(function () {
|
|
100
|
+
setFileUrl(value);
|
|
101
|
+
|
|
102
|
+
if (value) {
|
|
103
|
+
setUploadStatus('done');
|
|
104
|
+
} else {
|
|
105
|
+
setUploadStatus('init');
|
|
106
|
+
}
|
|
107
|
+
}, [value]);
|
|
108
|
+
|
|
109
|
+
var handleStart = function handleStart(file) {
|
|
110
|
+
fileRef.current = file;
|
|
111
|
+
setUploadPercent(0);
|
|
112
|
+
setFileUrl(getLocalImgURL(file));
|
|
113
|
+
setUploadStatus('uploading');
|
|
114
|
+
onStart && onStart(file);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var handleProgress = function handleProgress(e) {
|
|
118
|
+
var percent = e.percent;
|
|
119
|
+
setUploadPercent(parseInt("" + percent, 10));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
var handleError = function handleError(error, ret, file) {
|
|
123
|
+
setUploadStatus('init');
|
|
124
|
+
onError && onError(error, ret, file);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var handleSuccess = function handleSuccess(res, file, xhr) {
|
|
128
|
+
onSuccess && onSuccess(res, file, xhr);
|
|
129
|
+
setUploadStatus('done');
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
var uploadCls = classNames(className, {
|
|
133
|
+
'not-upload-init': uploadStatus !== 'init'
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
var handleDeleteUpload = function handleDeleteUpload() {
|
|
137
|
+
setUploadStatus('init');
|
|
138
|
+
onDeleteUpload && onDeleteUpload();
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var cancelUpload = function cancelUpload() {
|
|
142
|
+
var _a;
|
|
143
|
+
|
|
144
|
+
if (fileRef.current) {
|
|
145
|
+
(_a = uploadInstanceRef.current) === null || _a === void 0 ? void 0 : _a.abort(fileRef.current);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setUploadStatus('init');
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
var cls = classNames('as-img-upload', wrapperClassName);
|
|
152
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
153
|
+
className: cls
|
|
154
|
+
}, uploadStatus === 'uploading' && /*#__PURE__*/React.createElement("div", {
|
|
155
|
+
className: "as-img-upload-content"
|
|
156
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
157
|
+
className: "preview-img",
|
|
158
|
+
src: fileUrl,
|
|
159
|
+
alt: ""
|
|
160
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: "dark"
|
|
162
|
+
}), /*#__PURE__*/React.createElement(Progress, {
|
|
163
|
+
className: "as-img-upload-upload-progress",
|
|
164
|
+
percent: uploadPercent,
|
|
165
|
+
size: "small",
|
|
166
|
+
status: "active"
|
|
167
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
168
|
+
className: "as-img-upload-close-button",
|
|
169
|
+
onClick: cancelUpload
|
|
170
|
+
}, /*#__PURE__*/React.createElement(CloseOutlined, null))), uploadStatus === 'done' && /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
className: "as-img-upload-content"
|
|
172
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
173
|
+
wrapperClassName: "as-img-upload-preview",
|
|
174
|
+
src: fileUrl,
|
|
175
|
+
preview: true
|
|
176
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
177
|
+
className: "as-img-upload-close-button",
|
|
178
|
+
onClick: handleDeleteUpload
|
|
179
|
+
}, /*#__PURE__*/React.createElement(CloseOutlined, null))), /*#__PURE__*/React.createElement(Upload, __assign({
|
|
180
|
+
ref: function ref(uploader) {
|
|
181
|
+
uploadInstanceRef.current = uploader;
|
|
182
|
+
},
|
|
183
|
+
name: "file",
|
|
184
|
+
className: uploadCls,
|
|
185
|
+
onStart: handleStart,
|
|
186
|
+
onProgress: handleProgress,
|
|
187
|
+
onError: handleError,
|
|
188
|
+
onSuccess: handleSuccess
|
|
189
|
+
}, restProps), uploadStatus === 'init' && /*#__PURE__*/React.createElement("div", {
|
|
190
|
+
className: "as-img-upload-button"
|
|
191
|
+
}, children)));
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
SingleImgUpload.defaultProps = {
|
|
195
|
+
beforeUpload: function beforeUpload() {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
export default SingleImgUpload;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
|
|
2
|
+
/* stylelint-disable no-duplicate-selectors */
|
|
3
|
+
/* stylelint-disable */
|
|
4
|
+
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
|
|
5
|
+
.as-img-upload {
|
|
6
|
+
width: 335px;
|
|
7
|
+
height: 140px;
|
|
8
|
+
border: 1px solid #cacaca;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
}
|
|
11
|
+
.as-img-upload:hover {
|
|
12
|
+
border: 1px solid #1890ff;
|
|
13
|
+
}
|
|
14
|
+
.as-img-upload .rc-upload,
|
|
15
|
+
.as-img-upload:focus {
|
|
16
|
+
outline: none;
|
|
17
|
+
}
|
|
18
|
+
.as-img-upload-button {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
.as-img-upload-button:focus {
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
.as-img-upload-content {
|
|
32
|
+
position: relative;
|
|
33
|
+
z-index: 1010;
|
|
34
|
+
width: 100%;
|
|
35
|
+
height: 100%;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
background-color: #fff;
|
|
38
|
+
}
|
|
39
|
+
.as-img-upload-close-button {
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 0;
|
|
42
|
+
right: 0;
|
|
43
|
+
z-index: 10;
|
|
44
|
+
width: 20px;
|
|
45
|
+
height: 20px;
|
|
46
|
+
text-align: center;
|
|
47
|
+
background-color: #000;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
opacity: 0.6;
|
|
50
|
+
}
|
|
51
|
+
.as-img-upload-close-button .spotecicon {
|
|
52
|
+
width: 15px;
|
|
53
|
+
height: 15px;
|
|
54
|
+
color: #fff;
|
|
55
|
+
}
|
|
56
|
+
.as-img-upload-preview {
|
|
57
|
+
height: 100%;
|
|
58
|
+
}
|
|
59
|
+
.as-img-upload-upload-progress {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 50%;
|
|
62
|
+
left: 0;
|
|
63
|
+
z-index: 2;
|
|
64
|
+
transform: translateY(-34%);
|
|
65
|
+
}
|
|
66
|
+
.as-img-upload-upload-progress .ant-progress-outer {
|
|
67
|
+
padding: 0 20px;
|
|
68
|
+
}
|
|
69
|
+
.as-img-upload-upload-progress .ant-progress-text {
|
|
70
|
+
display: block;
|
|
71
|
+
width: 100%;
|
|
72
|
+
color: #fff;
|
|
73
|
+
text-align: center;
|
|
74
|
+
}
|