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.
Files changed (245) hide show
  1. package/es/button-drawer/index.d.ts +10 -0
  2. package/es/button-drawer/index.js +116 -0
  3. package/es/button-drawer/style/index.d.ts +1 -0
  4. package/es/button-drawer/style/index.js +1 -0
  5. package/es/button-modal/index.d.ts +14 -0
  6. package/es/button-modal/index.js +131 -0
  7. package/es/button-modal/style/index.d.ts +1 -0
  8. package/es/button-modal/style/index.js +1 -0
  9. package/es/condition-input/index.d.ts +15 -0
  10. package/es/condition-input/index.js +108 -0
  11. package/es/condition-input/parse2RegexOption.d.ts +13 -0
  12. package/es/condition-input/parse2RegexOption.js +57 -0
  13. package/es/condition-input/style/index.d.ts +1 -0
  14. package/es/condition-input/style/index.js +1 -0
  15. package/es/copy-to-clipboard/index.d.ts +22 -0
  16. package/es/copy-to-clipboard/index.js +95 -0
  17. package/es/copy-to-clipboard/style/index.css +249 -0
  18. package/es/copy-to-clipboard/style/index.d.ts +1 -0
  19. package/es/copy-to-clipboard/style/index.js +1 -0
  20. package/es/copy-to-clipboard/style/index.less +1 -0
  21. package/es/highlight-textarea/HighlighedContents.d.ts +7 -0
  22. package/es/highlight-textarea/HighlighedContents.js +15 -0
  23. package/es/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
  24. package/es/highlight-textarea/extractSpansOfClasses.js +159 -0
  25. package/es/highlight-textarea/getRanges.d.ts +2 -0
  26. package/es/highlight-textarea/getRanges.js +142 -0
  27. package/es/highlight-textarea/getType.d.ts +2 -0
  28. package/es/highlight-textarea/getType.js +29 -0
  29. package/es/highlight-textarea/index.d.ts +12 -0
  30. package/es/highlight-textarea/index.js +132 -0
  31. package/es/highlight-textarea/style/index.css +38 -0
  32. package/es/highlight-textarea/style/index.d.ts +2 -0
  33. package/es/highlight-textarea/style/index.js +2 -0
  34. package/es/highlight-textarea/style/index.less +42 -0
  35. package/es/highlight-textarea/types.d.ts +16 -0
  36. package/es/highlight-textarea/types.js +0 -0
  37. package/es/highlight-words/index.d.ts +3 -0
  38. package/es/highlight-words/index.js +2 -0
  39. package/es/highlight-words/style/index.d.ts +1 -0
  40. package/es/highlight-words/style/index.js +0 -0
  41. package/es/icon/demo/svg/check-circle-filled.svg +6 -0
  42. package/es/icon/demo/svg/coin-circle.svg +9 -0
  43. package/es/icon/index.d.ts +27 -0
  44. package/es/icon/index.js +95 -0
  45. package/es/icon/style/index.d.ts +1 -0
  46. package/es/icon/style/index.js +0 -0
  47. package/es/icon/utils.d.ts +6 -0
  48. package/es/icon/utils.js +22 -0
  49. package/es/img-crop/EasyCrop.d.ts +6 -0
  50. package/es/img-crop/EasyCrop.js +113 -0
  51. package/es/img-crop/getCroppedImg.d.ts +6 -0
  52. package/es/img-crop/getCroppedImg.js +199 -0
  53. package/es/img-crop/index.d.ts +53 -0
  54. package/es/img-crop/index.js +531 -0
  55. package/es/img-crop/style/index.css +52 -0
  56. package/es/img-crop/style/index.d.ts +3 -0
  57. package/es/img-crop/style/index.js +3 -0
  58. package/es/img-crop/style/index.less +54 -0
  59. package/es/index.d.ts +34 -2
  60. package/es/index.js +18 -2
  61. package/es/keep-tab/demo/index.modules.less +66 -0
  62. package/es/keep-tab/index.d.ts +29 -0
  63. package/es/keep-tab/index.js +129 -0
  64. package/es/keep-tab/style/index.css +1129 -0
  65. package/es/keep-tab/style/index.d.ts +2 -0
  66. package/es/keep-tab/style/index.js +2 -0
  67. package/es/keep-tab/style/index.less +2 -0
  68. package/es/number-input/index.d.ts +22 -7
  69. package/es/number-input/index.js +22 -11
  70. package/es/number-input/style/index.d.ts +1 -1
  71. package/es/number-input/style/index.js +1 -1
  72. package/es/number-input/utils.d.ts +10 -11
  73. package/es/number-input/utils.js +7 -7
  74. package/es/rc-echart/core.d.ts +32 -0
  75. package/es/rc-echart/core.js +136 -0
  76. package/es/rc-echart/index.d.ts +21 -0
  77. package/es/rc-echart/index.js +27 -0
  78. package/es/rc-echart/style/index.d.ts +1 -0
  79. package/es/rc-echart/style/index.js +0 -0
  80. package/es/rc-motion/demo/CSSMotion.less +91 -0
  81. package/es/rc-motion/index.d.ts +2 -0
  82. package/es/rc-motion/index.js +2 -0
  83. package/es/rc-motion/style/index.d.ts +1 -0
  84. package/es/rc-motion/style/index.js +0 -0
  85. package/es/rc-qrcode/index.d.ts +20 -0
  86. package/es/rc-qrcode/index.js +57 -0
  87. package/es/rc-qrcode/style/index.d.ts +1 -0
  88. package/es/rc-qrcode/style/index.js +0 -0
  89. package/es/rc-qrcode/useQrcode.d.ts +4 -0
  90. package/es/rc-qrcode/useQrcode.js +50 -0
  91. package/es/rc-transition-group/index.d.ts +2 -0
  92. package/es/rc-transition-group/index.js +2 -0
  93. package/es/rc-transition-group/style/index.d.ts +1 -0
  94. package/es/rc-transition-group/style/index.js +0 -0
  95. package/es/single-img-upload/index.d.ts +19 -0
  96. package/es/single-img-upload/index.js +199 -0
  97. package/es/single-img-upload/style/index.css +74 -0
  98. package/es/single-img-upload/style/index.d.ts +3 -0
  99. package/es/single-img-upload/style/index.js +3 -0
  100. package/es/single-img-upload/style/index.less +85 -0
  101. package/es/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
  102. package/es/sortable-hoc/demo/index.modules.less +248 -0
  103. package/es/sortable-hoc/index.d.ts +2 -0
  104. package/es/sortable-hoc/index.js +2 -0
  105. package/es/sortable-hoc/style/index.d.ts +1 -0
  106. package/es/sortable-hoc/style/index.js +0 -0
  107. package/es/split-pane/index.d.ts +59 -0
  108. package/es/split-pane/index.js +21 -0
  109. package/es/split-pane/style/index.css +41 -0
  110. package/es/split-pane/style/index.d.ts +1 -0
  111. package/es/split-pane/style/index.js +1 -0
  112. package/es/split-pane/style/index.less +49 -0
  113. package/es/text-area/index.d.ts +12 -0
  114. package/es/text-area/index.js +96 -0
  115. package/es/text-area/style/index.d.ts +1 -0
  116. package/es/text-area/style/index.js +1 -0
  117. package/es/text-input/index.d.ts +5 -0
  118. package/es/text-input/index.js +85 -0
  119. package/es/{number-input → text-input}/style/index.css +0 -3
  120. package/es/text-input/style/index.d.ts +1 -0
  121. package/es/text-input/style/index.js +1 -0
  122. package/es/{number-input → text-input}/style/index.less +0 -4
  123. package/lib/button-drawer/index.d.ts +10 -0
  124. package/lib/button-drawer/index.js +164 -0
  125. package/lib/button-drawer/style/index.d.ts +1 -0
  126. package/lib/button-drawer/style/index.js +7 -0
  127. package/lib/button-modal/index.d.ts +14 -0
  128. package/lib/button-modal/index.js +178 -0
  129. package/lib/button-modal/style/index.d.ts +1 -0
  130. package/lib/button-modal/style/index.js +7 -0
  131. package/lib/condition-input/index.d.ts +15 -0
  132. package/lib/condition-input/index.js +158 -0
  133. package/lib/condition-input/parse2RegexOption.d.ts +13 -0
  134. package/lib/condition-input/parse2RegexOption.js +72 -0
  135. package/lib/condition-input/style/index.d.ts +1 -0
  136. package/lib/condition-input/style/index.js +7 -0
  137. package/lib/copy-to-clipboard/index.d.ts +22 -0
  138. package/lib/copy-to-clipboard/index.js +143 -0
  139. package/lib/copy-to-clipboard/style/index.css +249 -0
  140. package/lib/copy-to-clipboard/style/index.d.ts +1 -0
  141. package/lib/copy-to-clipboard/style/index.js +7 -0
  142. package/lib/copy-to-clipboard/style/index.less +1 -0
  143. package/lib/highlight-textarea/HighlighedContents.d.ts +7 -0
  144. package/lib/highlight-textarea/HighlighedContents.js +29 -0
  145. package/lib/highlight-textarea/extractSpansOfClasses.d.ts +15 -0
  146. package/lib/highlight-textarea/extractSpansOfClasses.js +173 -0
  147. package/lib/highlight-textarea/getRanges.d.ts +2 -0
  148. package/lib/highlight-textarea/getRanges.js +156 -0
  149. package/lib/highlight-textarea/getType.d.ts +2 -0
  150. package/lib/highlight-textarea/getType.js +37 -0
  151. package/lib/highlight-textarea/index.d.ts +12 -0
  152. package/lib/highlight-textarea/index.js +183 -0
  153. package/lib/highlight-textarea/style/index.css +38 -0
  154. package/lib/highlight-textarea/style/index.d.ts +2 -0
  155. package/lib/highlight-textarea/style/index.js +9 -0
  156. package/lib/highlight-textarea/style/index.less +42 -0
  157. package/lib/highlight-textarea/types.d.ts +16 -0
  158. package/lib/highlight-textarea/types.js +5 -0
  159. package/lib/highlight-words/index.d.ts +3 -0
  160. package/lib/highlight-words/index.js +15 -0
  161. package/lib/highlight-words/style/index.d.ts +1 -0
  162. package/lib/highlight-words/style/index.js +0 -0
  163. package/lib/icon/demo/svg/check-circle-filled.svg +6 -0
  164. package/lib/icon/demo/svg/coin-circle.svg +9 -0
  165. package/lib/icon/index.d.ts +27 -0
  166. package/lib/icon/index.js +143 -0
  167. package/lib/icon/style/index.d.ts +1 -0
  168. package/lib/icon/style/index.js +0 -0
  169. package/lib/icon/utils.d.ts +6 -0
  170. package/lib/icon/utils.js +32 -0
  171. package/lib/img-crop/EasyCrop.d.ts +6 -0
  172. package/lib/img-crop/EasyCrop.js +160 -0
  173. package/lib/img-crop/getCroppedImg.d.ts +6 -0
  174. package/lib/img-crop/getCroppedImg.js +205 -0
  175. package/lib/img-crop/index.d.ts +53 -0
  176. package/lib/img-crop/index.js +582 -0
  177. package/lib/img-crop/style/index.css +52 -0
  178. package/lib/img-crop/style/index.d.ts +3 -0
  179. package/lib/img-crop/style/index.js +11 -0
  180. package/lib/img-crop/style/index.less +54 -0
  181. package/lib/index.d.ts +34 -2
  182. package/lib/index.js +160 -9
  183. package/lib/keep-tab/demo/index.modules.less +66 -0
  184. package/lib/keep-tab/index.d.ts +29 -0
  185. package/lib/keep-tab/index.js +181 -0
  186. package/lib/keep-tab/style/index.css +1129 -0
  187. package/lib/keep-tab/style/index.d.ts +2 -0
  188. package/lib/keep-tab/style/index.js +9 -0
  189. package/lib/keep-tab/style/index.less +2 -0
  190. package/lib/number-input/index.d.ts +22 -7
  191. package/lib/number-input/index.js +22 -11
  192. package/lib/number-input/style/index.d.ts +1 -1
  193. package/lib/number-input/style/index.js +1 -1
  194. package/lib/number-input/utils.d.ts +10 -11
  195. package/lib/number-input/utils.js +8 -8
  196. package/lib/rc-echart/core.d.ts +32 -0
  197. package/lib/rc-echart/core.js +185 -0
  198. package/lib/rc-echart/index.d.ts +21 -0
  199. package/lib/rc-echart/index.js +75 -0
  200. package/lib/rc-echart/style/index.d.ts +1 -0
  201. package/lib/rc-echart/style/index.js +0 -0
  202. package/lib/rc-motion/demo/CSSMotion.less +91 -0
  203. package/lib/rc-motion/index.d.ts +2 -0
  204. package/lib/rc-motion/index.js +43 -0
  205. package/lib/rc-motion/style/index.d.ts +1 -0
  206. package/lib/rc-motion/style/index.js +0 -0
  207. package/lib/rc-qrcode/index.d.ts +20 -0
  208. package/lib/rc-qrcode/index.js +108 -0
  209. package/lib/rc-qrcode/style/index.d.ts +1 -0
  210. package/lib/rc-qrcode/style/index.js +0 -0
  211. package/lib/rc-qrcode/useQrcode.d.ts +4 -0
  212. package/lib/rc-qrcode/useQrcode.js +66 -0
  213. package/lib/rc-transition-group/index.d.ts +2 -0
  214. package/lib/rc-transition-group/index.js +43 -0
  215. package/lib/rc-transition-group/style/index.d.ts +1 -0
  216. package/lib/rc-transition-group/style/index.js +0 -0
  217. package/lib/single-img-upload/index.d.ts +19 -0
  218. package/lib/single-img-upload/index.js +250 -0
  219. package/lib/single-img-upload/style/index.css +74 -0
  220. package/lib/single-img-upload/style/index.d.ts +3 -0
  221. package/lib/single-img-upload/style/index.js +11 -0
  222. package/lib/single-img-upload/style/index.less +85 -0
  223. package/lib/sortable-hoc/demo/VerticalListBase/index.modules.less +63 -0
  224. package/lib/sortable-hoc/demo/index.modules.less +248 -0
  225. package/lib/sortable-hoc/index.d.ts +2 -0
  226. package/lib/sortable-hoc/index.js +43 -0
  227. package/lib/sortable-hoc/style/index.d.ts +1 -0
  228. package/lib/sortable-hoc/style/index.js +0 -0
  229. package/lib/split-pane/index.d.ts +59 -0
  230. package/lib/split-pane/index.js +69 -0
  231. package/lib/split-pane/style/index.css +41 -0
  232. package/lib/split-pane/style/index.d.ts +1 -0
  233. package/lib/split-pane/style/index.js +7 -0
  234. package/lib/split-pane/style/index.less +49 -0
  235. package/lib/text-area/index.d.ts +12 -0
  236. package/lib/text-area/index.js +144 -0
  237. package/lib/text-area/style/index.d.ts +1 -0
  238. package/lib/text-area/style/index.js +7 -0
  239. package/lib/text-input/index.d.ts +5 -0
  240. package/lib/text-input/index.js +99 -0
  241. package/lib/{number-input → text-input}/style/index.css +0 -3
  242. package/lib/text-input/style/index.d.ts +1 -0
  243. package/lib/text-input/style/index.js +7 -0
  244. package/lib/{number-input → text-input}/style/index.less +0 -4
  245. package/package.json +20 -3
@@ -0,0 +1,2 @@
1
+ import * as RcMotion from 'rc-motion';
2
+ export default RcMotion;
@@ -0,0 +1,2 @@
1
+ import * as RcMotion from 'rc-motion';
2
+ export default RcMotion;
@@ -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,4 @@
1
+ import { QRCodeToDataURLOptions, QRCodeSegment } from 'qrcode';
2
+ declare type ValueTypes = string | QRCodeSegment[];
3
+ export declare const useQRCode: (value: ValueTypes, options: QRCodeToDataURLOptions) => string;
4
+ export default useQRCode;
@@ -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,2 @@
1
+ import * as RcTransitionGroup from 'react-transition-group';
2
+ export default RcTransitionGroup;
@@ -0,0 +1,2 @@
1
+ import * as RcTransitionGroup from 'react-transition-group';
2
+ export default RcTransitionGroup;
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
+ }