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,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CropperProps } from 'react-easy-crop';
|
|
3
|
+
import getCroppedImg from './getCroppedImg';
|
|
4
|
+
import './style/index.less';
|
|
5
|
+
export interface RcFile extends File {
|
|
6
|
+
uid: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ImgCropProps {
|
|
9
|
+
prefix: string;
|
|
10
|
+
aspect: number;
|
|
11
|
+
shape: 'rect' | 'round';
|
|
12
|
+
grid?: boolean;
|
|
13
|
+
quality?: number;
|
|
14
|
+
zoom?: boolean;
|
|
15
|
+
rotate?: boolean;
|
|
16
|
+
minZoom: number;
|
|
17
|
+
maxZoom: number;
|
|
18
|
+
fillColor: string;
|
|
19
|
+
modalTitle: string;
|
|
20
|
+
modalWidth?: string | number;
|
|
21
|
+
modalCancel?: string;
|
|
22
|
+
modalOk?: string;
|
|
23
|
+
zipImg?: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
beforeCrop?: (file: RcFile, fileList: RcFile[]) => boolean;
|
|
28
|
+
cropperProps?: CropperProps;
|
|
29
|
+
children?: React.ReactElement;
|
|
30
|
+
}
|
|
31
|
+
export declare type Area = {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
declare const ImgCrop: {
|
|
38
|
+
(props: ImgCropProps): JSX.Element;
|
|
39
|
+
defaultProps: {
|
|
40
|
+
prefix: string;
|
|
41
|
+
aspect: number;
|
|
42
|
+
shape: string;
|
|
43
|
+
grid: boolean;
|
|
44
|
+
quality: number;
|
|
45
|
+
zoom: boolean;
|
|
46
|
+
rotate: boolean;
|
|
47
|
+
minZoom: number;
|
|
48
|
+
maxZoom: number;
|
|
49
|
+
fillColor: string;
|
|
50
|
+
};
|
|
51
|
+
getCroppedImg: typeof getCroppedImg;
|
|
52
|
+
};
|
|
53
|
+
export default ImgCrop;
|
|
@@ -0,0 +1,531 @@
|
|
|
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 __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) {
|
|
19
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
20
|
+
resolve(value);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
+
function fulfilled(value) {
|
|
26
|
+
try {
|
|
27
|
+
step(generator.next(value));
|
|
28
|
+
} catch (e) {
|
|
29
|
+
reject(e);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function rejected(value) {
|
|
34
|
+
try {
|
|
35
|
+
step(generator["throw"](value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function step(result) {
|
|
42
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
50
|
+
var _ = {
|
|
51
|
+
label: 0,
|
|
52
|
+
sent: function sent() {
|
|
53
|
+
if (t[0] & 1) throw t[1];
|
|
54
|
+
return t[1];
|
|
55
|
+
},
|
|
56
|
+
trys: [],
|
|
57
|
+
ops: []
|
|
58
|
+
},
|
|
59
|
+
f,
|
|
60
|
+
y,
|
|
61
|
+
t,
|
|
62
|
+
g;
|
|
63
|
+
return g = {
|
|
64
|
+
next: verb(0),
|
|
65
|
+
"throw": verb(1),
|
|
66
|
+
"return": verb(2)
|
|
67
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
68
|
+
return this;
|
|
69
|
+
}), g;
|
|
70
|
+
|
|
71
|
+
function verb(n) {
|
|
72
|
+
return function (v) {
|
|
73
|
+
return step([n, v]);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function step(op) {
|
|
78
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
79
|
+
|
|
80
|
+
while (_) {
|
|
81
|
+
try {
|
|
82
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
83
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
84
|
+
|
|
85
|
+
switch (op[0]) {
|
|
86
|
+
case 0:
|
|
87
|
+
case 1:
|
|
88
|
+
t = op;
|
|
89
|
+
break;
|
|
90
|
+
|
|
91
|
+
case 4:
|
|
92
|
+
_.label++;
|
|
93
|
+
return {
|
|
94
|
+
value: op[1],
|
|
95
|
+
done: false
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
case 5:
|
|
99
|
+
_.label++;
|
|
100
|
+
y = op[1];
|
|
101
|
+
op = [0];
|
|
102
|
+
continue;
|
|
103
|
+
|
|
104
|
+
case 7:
|
|
105
|
+
op = _.ops.pop();
|
|
106
|
+
|
|
107
|
+
_.trys.pop();
|
|
108
|
+
|
|
109
|
+
continue;
|
|
110
|
+
|
|
111
|
+
default:
|
|
112
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
113
|
+
_ = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
118
|
+
_.label = op[1];
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
123
|
+
_.label = t[1];
|
|
124
|
+
t = op;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (t && _.label < t[2]) {
|
|
129
|
+
_.label = t[2];
|
|
130
|
+
|
|
131
|
+
_.ops.push(op);
|
|
132
|
+
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (t[2]) _.ops.pop();
|
|
137
|
+
|
|
138
|
+
_.trys.pop();
|
|
139
|
+
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
op = body.call(thisArg, _);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
op = [6, e];
|
|
146
|
+
y = 0;
|
|
147
|
+
} finally {
|
|
148
|
+
f = t = 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (op[0] & 5) throw op[1];
|
|
153
|
+
return {
|
|
154
|
+
value: op[0] ? op[1] : void 0,
|
|
155
|
+
done: true
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
161
|
+
var t = {};
|
|
162
|
+
|
|
163
|
+
for (var p in s) {
|
|
164
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
168
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
169
|
+
}
|
|
170
|
+
return t;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
var __read = this && this.__read || function (o, n) {
|
|
174
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
175
|
+
if (!m) return o;
|
|
176
|
+
var i = m.call(o),
|
|
177
|
+
r,
|
|
178
|
+
ar = [],
|
|
179
|
+
e;
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
183
|
+
ar.push(r.value);
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
e = {
|
|
187
|
+
error: error
|
|
188
|
+
};
|
|
189
|
+
} finally {
|
|
190
|
+
try {
|
|
191
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
192
|
+
} finally {
|
|
193
|
+
if (e) throw e.error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return ar;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
import * as React from 'react';
|
|
201
|
+
import Modal from 'antd/lib/modal';
|
|
202
|
+
import Slider from 'antd/lib/slider';
|
|
203
|
+
import getCroppedImg from './getCroppedImg';
|
|
204
|
+
import EasyCrop from './EasyCrop';
|
|
205
|
+
import './style/index.less';
|
|
206
|
+
|
|
207
|
+
var noop = function noop() {};
|
|
208
|
+
|
|
209
|
+
var ZOOM_STEP = 0.1;
|
|
210
|
+
var MIN_ROTATE = 0;
|
|
211
|
+
var MAX_ROTATE = 360;
|
|
212
|
+
var ROTATE_STEP = 1;
|
|
213
|
+
|
|
214
|
+
var ImgCrop = function ImgCrop(props) {
|
|
215
|
+
var aspect = props.aspect,
|
|
216
|
+
shape = props.shape,
|
|
217
|
+
grid = props.grid,
|
|
218
|
+
quality = props.quality,
|
|
219
|
+
zoom = props.zoom,
|
|
220
|
+
rotate = props.rotate,
|
|
221
|
+
minZoom = props.minZoom,
|
|
222
|
+
maxZoom = props.maxZoom,
|
|
223
|
+
fillColor = props.fillColor,
|
|
224
|
+
prefix = props.prefix,
|
|
225
|
+
modalTitle = props.modalTitle,
|
|
226
|
+
modalWidth = props.modalWidth,
|
|
227
|
+
modalOk = props.modalOk,
|
|
228
|
+
modalCancel = props.modalCancel,
|
|
229
|
+
beforeCrop = props.beforeCrop,
|
|
230
|
+
zipImg = props.zipImg,
|
|
231
|
+
children = props.children,
|
|
232
|
+
cropperProps = props.cropperProps;
|
|
233
|
+
var pkg = prefix + "-img-crop";
|
|
234
|
+
var MEDIA_CLASS = pkg + "-media";
|
|
235
|
+
var hasZoom = zoom === true;
|
|
236
|
+
var hasRotate = rotate === true;
|
|
237
|
+
|
|
238
|
+
var _a = __read(React.useState(''), 2),
|
|
239
|
+
src = _a[0],
|
|
240
|
+
setSrc = _a[1];
|
|
241
|
+
|
|
242
|
+
var _b = __read(React.useState(1), 2),
|
|
243
|
+
zoomVal = _b[0],
|
|
244
|
+
setZoomVal = _b[1];
|
|
245
|
+
|
|
246
|
+
var _c = __read(React.useState(0), 2),
|
|
247
|
+
rotateVal = _c[0],
|
|
248
|
+
setRotateVal = _c[1];
|
|
249
|
+
|
|
250
|
+
var beforeUploadRef = React.useRef();
|
|
251
|
+
var fileRef = React.useRef();
|
|
252
|
+
var resolveRef = React.useRef(noop);
|
|
253
|
+
var rejectRef = React.useRef(noop);
|
|
254
|
+
var cropPixelsRef = React.useRef();
|
|
255
|
+
/**
|
|
256
|
+
* Upload
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
var renderUpload = React.useCallback(function () {
|
|
260
|
+
var upload = Array.isArray(children) ? children[0] : children;
|
|
261
|
+
|
|
262
|
+
var _a = upload.props,
|
|
263
|
+
beforeUpload = _a.beforeUpload,
|
|
264
|
+
accept = _a.accept,
|
|
265
|
+
restUploadProps = __rest(_a, ["beforeUpload", "accept"]);
|
|
266
|
+
|
|
267
|
+
beforeUploadRef.current = beforeUpload;
|
|
268
|
+
return __assign(__assign({}, upload), {
|
|
269
|
+
props: __assign(__assign({}, restUploadProps), {
|
|
270
|
+
accept: accept || 'image/*',
|
|
271
|
+
beforeUpload: function beforeUpload(file, fileList) {
|
|
272
|
+
return new Promise(function (resolve, reject) {
|
|
273
|
+
if (beforeCrop && !beforeCrop(file, fileList)) {
|
|
274
|
+
reject();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
fileRef.current = file;
|
|
279
|
+
resolveRef.current = resolve;
|
|
280
|
+
rejectRef.current = reject;
|
|
281
|
+
var reader = new FileReader();
|
|
282
|
+
reader.addEventListener('load', function () {
|
|
283
|
+
setSrc(reader.result);
|
|
284
|
+
});
|
|
285
|
+
reader.readAsDataURL(file);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
}, [beforeCrop, children]);
|
|
291
|
+
/**
|
|
292
|
+
* EasyCrop
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
var onComplete = React.useCallback(function (croppedAreaPixels) {
|
|
296
|
+
cropPixelsRef.current = croppedAreaPixels;
|
|
297
|
+
}, []);
|
|
298
|
+
/**
|
|
299
|
+
* Controls
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
var isMinZoom = zoomVal - ZOOM_STEP < minZoom;
|
|
303
|
+
var isMaxZoom = zoomVal + ZOOM_STEP > maxZoom;
|
|
304
|
+
var isMinRotate = rotateVal === MIN_ROTATE;
|
|
305
|
+
var isMaxRotate = rotateVal === MAX_ROTATE;
|
|
306
|
+
var subZoomVal = React.useCallback(function () {
|
|
307
|
+
if (!isMinZoom) setZoomVal(zoomVal - ZOOM_STEP);
|
|
308
|
+
}, [isMinZoom, zoomVal]);
|
|
309
|
+
var addZoomVal = React.useCallback(function () {
|
|
310
|
+
if (!isMaxZoom) setZoomVal(zoomVal + ZOOM_STEP);
|
|
311
|
+
}, [isMaxZoom, zoomVal]);
|
|
312
|
+
var subRotateVal = React.useCallback(function () {
|
|
313
|
+
if (!isMinRotate) setRotateVal(rotateVal - ROTATE_STEP);
|
|
314
|
+
}, [isMinRotate, rotateVal]);
|
|
315
|
+
var addRotateVal = React.useCallback(function () {
|
|
316
|
+
if (!isMaxRotate) setRotateVal(rotateVal + ROTATE_STEP);
|
|
317
|
+
}, [isMaxRotate, rotateVal]);
|
|
318
|
+
/**
|
|
319
|
+
* Modal
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
var modalProps = React.useMemo(function () {
|
|
323
|
+
var obj = {
|
|
324
|
+
width: modalWidth,
|
|
325
|
+
okText: modalOk,
|
|
326
|
+
cancelText: modalCancel
|
|
327
|
+
};
|
|
328
|
+
return obj;
|
|
329
|
+
}, [modalCancel, modalOk, modalWidth]);
|
|
330
|
+
var onClose = React.useCallback(function () {
|
|
331
|
+
setSrc('');
|
|
332
|
+
setZoomVal(1);
|
|
333
|
+
setRotateVal(0);
|
|
334
|
+
}, []);
|
|
335
|
+
var onOk = React.useCallback(function () {
|
|
336
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
337
|
+
var naturalImg, naturalWidth, naturalHeight, canvas, ctx, maxLen, halfMax, left, top, maxImgData, _a, width, height, x, y, _b, type, name, uid;
|
|
338
|
+
|
|
339
|
+
return __generator(this, function (_c) {
|
|
340
|
+
onClose();
|
|
341
|
+
naturalImg = document.querySelector("." + MEDIA_CLASS);
|
|
342
|
+
naturalWidth = naturalImg.naturalWidth, naturalHeight = naturalImg.naturalHeight;
|
|
343
|
+
canvas = document.createElement('canvas');
|
|
344
|
+
ctx = canvas.getContext('2d');
|
|
345
|
+
maxLen = Math.sqrt(Math.pow(naturalWidth, 2) + Math.pow(naturalHeight, 2));
|
|
346
|
+
canvas.width = maxLen;
|
|
347
|
+
canvas.height = maxLen; // rotate the image
|
|
348
|
+
|
|
349
|
+
if (hasRotate && rotateVal > 0 && rotateVal < 360) {
|
|
350
|
+
halfMax = maxLen / 2;
|
|
351
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.translate(halfMax, halfMax);
|
|
352
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.rotate(rotateVal * Math.PI / 180);
|
|
353
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.translate(-halfMax, -halfMax);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
ctx.fillStyle = fillColor;
|
|
357
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
358
|
+
left = (maxLen - naturalWidth) / 2;
|
|
359
|
+
top = (maxLen - naturalHeight) / 2;
|
|
360
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(naturalImg, left, top);
|
|
361
|
+
maxImgData = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(0, 0, maxLen, maxLen);
|
|
362
|
+
_a = cropPixelsRef.current, width = _a.width, height = _a.height, x = _a.x, y = _a.y;
|
|
363
|
+
canvas.width = width;
|
|
364
|
+
canvas.height = height;
|
|
365
|
+
ctx.putImageData(maxImgData, Math.round(-left - x), Math.round(-top - y));
|
|
366
|
+
_b = fileRef.current, type = _b.type, name = _b.name, uid = _b.uid;
|
|
367
|
+
canvas.toBlob(function (blob) {
|
|
368
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
369
|
+
var newFile, url, imgUrl, fileObj, res, passedFile, fileType, err_1;
|
|
370
|
+
return __generator(this, function (_a) {
|
|
371
|
+
switch (_a.label) {
|
|
372
|
+
case 0:
|
|
373
|
+
newFile = new File([blob], name, {
|
|
374
|
+
type: type
|
|
375
|
+
});
|
|
376
|
+
if (!zipImg) return [3
|
|
377
|
+
/*break*/
|
|
378
|
+
, 2];
|
|
379
|
+
url = window.URL || window.webkitURL;
|
|
380
|
+
imgUrl = url.createObjectURL(newFile);
|
|
381
|
+
return [4
|
|
382
|
+
/*yield*/
|
|
383
|
+
, getCroppedImg(imgUrl, zipImg, name, type)];
|
|
384
|
+
|
|
385
|
+
case 1:
|
|
386
|
+
fileObj = _a.sent().fileObj;
|
|
387
|
+
newFile = fileObj;
|
|
388
|
+
_a.label = 2;
|
|
389
|
+
|
|
390
|
+
case 2:
|
|
391
|
+
newFile.uid = uid;
|
|
392
|
+
if (typeof beforeUploadRef.current !== 'function') return [2
|
|
393
|
+
/*return*/
|
|
394
|
+
, resolveRef.current(newFile)];
|
|
395
|
+
res = beforeUploadRef.current(newFile, [newFile]);
|
|
396
|
+
if (!(typeof res !== 'boolean' && !res)) return [3
|
|
397
|
+
/*break*/
|
|
398
|
+
, 3];
|
|
399
|
+
console.error('beforeUpload must return a boolean or Promise');
|
|
400
|
+
return [3
|
|
401
|
+
/*break*/
|
|
402
|
+
, 7];
|
|
403
|
+
|
|
404
|
+
case 3:
|
|
405
|
+
if (res === true) return [2
|
|
406
|
+
/*return*/
|
|
407
|
+
, resolveRef.current(newFile)];
|
|
408
|
+
if (res === false) return [2
|
|
409
|
+
/*return*/
|
|
410
|
+
, rejectRef.current('not upload')];
|
|
411
|
+
if (!(res && typeof res.then === 'function')) return [3
|
|
412
|
+
/*break*/
|
|
413
|
+
, 7];
|
|
414
|
+
_a.label = 4;
|
|
415
|
+
|
|
416
|
+
case 4:
|
|
417
|
+
_a.trys.push([4, 6,, 7]);
|
|
418
|
+
|
|
419
|
+
return [4
|
|
420
|
+
/*yield*/
|
|
421
|
+
, res];
|
|
422
|
+
|
|
423
|
+
case 5:
|
|
424
|
+
passedFile = _a.sent();
|
|
425
|
+
fileType = Object.prototype.toString.call(passedFile);
|
|
426
|
+
if (fileType === '[object File]' || fileType === '[object Blob]') newFile = passedFile;
|
|
427
|
+
resolveRef.current(newFile);
|
|
428
|
+
return [3
|
|
429
|
+
/*break*/
|
|
430
|
+
, 7];
|
|
431
|
+
|
|
432
|
+
case 6:
|
|
433
|
+
err_1 = _a.sent();
|
|
434
|
+
rejectRef.current(err_1);
|
|
435
|
+
return [3
|
|
436
|
+
/*break*/
|
|
437
|
+
, 7];
|
|
438
|
+
|
|
439
|
+
case 7:
|
|
440
|
+
return [2
|
|
441
|
+
/*return*/
|
|
442
|
+
, null];
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
}, type, quality);
|
|
447
|
+
return [2
|
|
448
|
+
/*return*/
|
|
449
|
+
];
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
}, [hasRotate, onClose, quality, rotateVal]);
|
|
453
|
+
|
|
454
|
+
var renderComponent = function renderComponent(titleOfModal) {
|
|
455
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, renderUpload(), src && /*#__PURE__*/React.createElement(Modal, __assign({
|
|
456
|
+
visible: true,
|
|
457
|
+
wrapClassName: pkg + "-modal",
|
|
458
|
+
title: titleOfModal,
|
|
459
|
+
onOk: onOk,
|
|
460
|
+
onCancel: onClose,
|
|
461
|
+
maskClosable: false,
|
|
462
|
+
destroyOnClose: true
|
|
463
|
+
}, modalProps), /*#__PURE__*/React.createElement(EasyCrop, __assign({
|
|
464
|
+
image: src,
|
|
465
|
+
aspect: aspect,
|
|
466
|
+
cropShape: shape,
|
|
467
|
+
showGrid: grid,
|
|
468
|
+
zoomWithScroll: hasZoom,
|
|
469
|
+
zoom: zoomVal,
|
|
470
|
+
rotation: rotateVal,
|
|
471
|
+
onZoomChange: setZoomVal,
|
|
472
|
+
onRotationChange: setRotateVal,
|
|
473
|
+
minZoom: minZoom,
|
|
474
|
+
maxZoom: maxZoom,
|
|
475
|
+
onComplete: onComplete,
|
|
476
|
+
classes: {
|
|
477
|
+
containerClassName: pkg + "-container",
|
|
478
|
+
mediaClassName: MEDIA_CLASS
|
|
479
|
+
}
|
|
480
|
+
}, cropperProps)), hasZoom && /*#__PURE__*/React.createElement("div", {
|
|
481
|
+
className: pkg + "-control zoom"
|
|
482
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
483
|
+
type: "button",
|
|
484
|
+
onClick: subZoomVal,
|
|
485
|
+
disabled: isMinZoom
|
|
486
|
+
}, "\uFF0D"), /*#__PURE__*/React.createElement(Slider, {
|
|
487
|
+
min: minZoom,
|
|
488
|
+
max: maxZoom,
|
|
489
|
+
step: ZOOM_STEP,
|
|
490
|
+
value: zoomVal,
|
|
491
|
+
onChange: setZoomVal
|
|
492
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
493
|
+
type: "button",
|
|
494
|
+
onClick: addZoomVal,
|
|
495
|
+
disabled: isMaxZoom
|
|
496
|
+
}, "\uFF0B")), hasRotate && /*#__PURE__*/React.createElement("div", {
|
|
497
|
+
className: pkg + "-control rotate"
|
|
498
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
499
|
+
type: "button",
|
|
500
|
+
onClick: subRotateVal,
|
|
501
|
+
disabled: isMinRotate
|
|
502
|
+
}, "\u21BA"), /*#__PURE__*/React.createElement(Slider, {
|
|
503
|
+
min: MIN_ROTATE,
|
|
504
|
+
max: MAX_ROTATE,
|
|
505
|
+
step: ROTATE_STEP,
|
|
506
|
+
value: rotateVal,
|
|
507
|
+
onChange: setRotateVal
|
|
508
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
509
|
+
type: "button",
|
|
510
|
+
onClick: addRotateVal,
|
|
511
|
+
disabled: isMaxRotate
|
|
512
|
+
}, "\u21BB"))));
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
return renderComponent(modalTitle);
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
ImgCrop.defaultProps = {
|
|
519
|
+
prefix: 'ant',
|
|
520
|
+
aspect: 1,
|
|
521
|
+
shape: 'rect',
|
|
522
|
+
grid: false,
|
|
523
|
+
quality: 0.4,
|
|
524
|
+
zoom: true,
|
|
525
|
+
rotate: false,
|
|
526
|
+
minZoom: 1,
|
|
527
|
+
maxZoom: 3,
|
|
528
|
+
fillColor: 'rgba(0,0,0,0)'
|
|
529
|
+
};
|
|
530
|
+
ImgCrop.getCroppedImg = getCroppedImg;
|
|
531
|
+
export default ImgCrop;
|