assui 2.3.9 → 3.0.1
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/a-select/index.js +7 -22
- package/es/a-select/style/index.css +195 -743
- package/es/area-text/index.js +1 -3
- package/es/button-drawer/index.js +12 -30
- package/es/button-modal/index.js +12 -33
- package/es/color-select/index.js +10 -23
- package/es/color-select/style/index.css +195 -743
- package/es/condition-input/index.js +8 -26
- package/es/condition-input/parse2RegexOption.js +0 -11
- package/es/config-provider/index.js +1 -3
- package/es/copy-to-clipboard/index.js +11 -27
- package/es/copy-to-clipboard/style/index.css +0 -1
- package/es/highlight-textarea/HighlighedContents.js +1 -3
- package/es/highlight-textarea/extractSpansOfClasses.d.ts +1 -0
- package/es/highlight-textarea/extractSpansOfClasses.js +7 -29
- package/es/highlight-textarea/getRanges.js +3 -35
- package/es/highlight-textarea/getType.js +0 -6
- package/es/highlight-textarea/index.js +11 -30
- package/es/highlight-textarea/style/index.css +7 -21
- package/es/img-crop/EasyCrop.js +18 -34
- package/es/img-crop/getCroppedImg.js +15 -50
- package/es/img-crop/index.js +56 -145
- package/es/img-crop/style/index.css +195 -743
- package/es/json-editor/index.js +6 -20
- package/es/keep-tab/index.d.ts +7 -4
- package/es/keep-tab/index.js +34 -59
- package/es/keep-tab/style/index.css +39 -99
- package/es/label-auto-complete/index.js +14 -32
- package/es/label-auto-complete/style/index.css +195 -743
- package/es/label-condition-input/index.js +13 -29
- package/es/label-customize-range-picker/defaultRadioList.js +0 -3
- package/es/label-customize-range-picker/index.js +36 -78
- package/es/label-customize-range-picker/style/index.css +195 -743
- package/es/label-customize-range-picker/utils/index.js +5 -14
- package/es/label-date-picker/index.js +11 -28
- package/es/label-date-picker/style/index.css +195 -743
- package/es/label-input/index.js +23 -37
- package/es/label-number-input/index.js +13 -28
- package/es/label-range-picker/index.js +11 -28
- package/es/label-range-picker/style/index.css +195 -743
- package/es/label-select/index.js +11 -27
- package/es/label-select/style/index.css +195 -743
- package/es/label-text-area/index.js +13 -35
- package/es/label-tree-select/index.js +15 -32
- package/es/label-tree-select/style/index.css +195 -743
- package/es/number-format-input/index.js +1 -11
- package/es/number-input/index.js +18 -37
- package/es/number-input/utils.js +7 -15
- package/es/rc-echart/core.js +15 -27
- package/es/rc-echart/index.js +0 -6
- package/es/rc-qrcode/index.js +2 -12
- package/es/rc-qrcode/useQrcode.js +5 -12
- package/es/rich-text-editor/index.js +5 -16
- package/es/rich-text-editor/plugins/code/index.js +0 -8
- package/es/rich-text-editor/style/index.css +195 -743
- package/es/single-img-upload/index.js +36 -110
- package/es/single-img-upload/style/index.css +195 -743
- package/es/split-pane/index.js +0 -4
- package/es/step-number-input/index.js +14 -39
- package/es/step-number-input/style/index.css +195 -743
- package/es/table-col/index.js +2 -4
- package/es/text-area/index.js +8 -27
- package/es/text-input/index.js +4 -18
- package/es/text-input/style/index.css +7 -21
- package/lib/a-select/index.js +7 -27
- package/lib/a-select/style/index.css +195 -743
- package/lib/a-select/style/index.js +0 -2
- package/lib/area-text/index.js +1 -6
- package/lib/area-text/style/index.js +0 -1
- package/lib/beautiful-dnd/index.js +0 -9
- package/lib/button-drawer/index.js +12 -42
- package/lib/button-drawer/style/index.js +0 -1
- package/lib/button-modal/index.js +12 -44
- package/lib/button-modal/style/index.js +0 -1
- package/lib/color-select/index.js +10 -39
- package/lib/color-select/style/index.css +195 -743
- package/lib/color-select/style/index.js +0 -2
- package/lib/condition-input/index.js +8 -41
- package/lib/condition-input/parse2RegexOption.js +0 -16
- package/lib/condition-input/style/index.js +0 -1
- package/lib/config-provider/context.js +0 -4
- package/lib/config-provider/index.js +1 -28
- package/lib/copy-to-clipboard/index.js +11 -38
- package/lib/copy-to-clipboard/style/index.css +0 -1
- package/lib/copy-to-clipboard/style/index.js +0 -1
- package/lib/highlight-textarea/HighlighedContents.js +1 -7
- package/lib/highlight-textarea/extractSpansOfClasses.d.ts +1 -0
- package/lib/highlight-textarea/extractSpansOfClasses.js +7 -31
- package/lib/highlight-textarea/getRanges.js +3 -38
- package/lib/highlight-textarea/getType.js +0 -8
- package/lib/highlight-textarea/index.js +11 -44
- package/lib/highlight-textarea/style/index.css +7 -21
- package/lib/highlight-textarea/style/index.js +0 -1
- package/lib/highlight-words/index.js +0 -3
- package/lib/img-crop/EasyCrop.js +18 -44
- package/lib/img-crop/getCroppedImg.js +15 -51
- package/lib/img-crop/index.js +56 -159
- package/lib/img-crop/style/index.css +195 -743
- package/lib/img-crop/style/index.js +0 -3
- package/lib/index.js +0 -77
- package/lib/json-editor/index.js +6 -35
- package/lib/json-editor/style/index.js +0 -2
- package/lib/keep-tab/index.d.ts +7 -4
- package/lib/keep-tab/index.js +34 -76
- package/lib/keep-tab/style/index.css +39 -99
- package/lib/keep-tab/style/index.js +0 -2
- package/lib/label-auto-complete/index.js +14 -39
- package/lib/label-auto-complete/style/index.css +195 -743
- package/lib/label-auto-complete/style/index.js +0 -2
- package/lib/label-condition-input/index.js +13 -36
- package/lib/label-condition-input/style/index.js +0 -1
- package/lib/label-customize-range-picker/defaultRadioList.js +0 -7
- package/lib/label-customize-range-picker/index.js +36 -99
- package/lib/label-customize-range-picker/style/index.css +195 -743
- package/lib/label-customize-range-picker/style/index.js +0 -5
- package/lib/label-customize-range-picker/utils/index.js +5 -19
- package/lib/label-date-picker/index.js +11 -34
- package/lib/label-date-picker/style/index.css +195 -743
- package/lib/label-date-picker/style/index.js +0 -2
- package/lib/label-input/index.js +23 -46
- package/lib/label-input/style/index.js +0 -1
- package/lib/label-number-input/index.js +13 -36
- package/lib/label-number-input/style/index.js +0 -1
- package/lib/label-range-picker/index.js +11 -36
- package/lib/label-range-picker/style/index.css +195 -743
- package/lib/label-range-picker/style/index.js +0 -2
- package/lib/label-select/index.js +11 -36
- package/lib/label-select/style/index.css +195 -743
- package/lib/label-select/style/index.js +0 -2
- package/lib/label-text-area/index.js +13 -40
- package/lib/label-text-area/style/index.js +0 -1
- package/lib/label-tree-select/index.js +15 -38
- package/lib/label-tree-select/style/index.css +195 -743
- package/lib/label-tree-select/style/index.js +0 -2
- package/lib/messages/index.js +0 -2
- package/lib/number-format-input/index.js +1 -15
- package/lib/number-format-input/style/index.js +0 -1
- package/lib/number-input/index.js +18 -55
- package/lib/number-input/style/index.js +0 -1
- package/lib/number-input/utils.js +8 -20
- package/lib/rc-echart/core.js +15 -40
- package/lib/rc-echart/index.js +0 -17
- package/lib/rc-motion/index.js +0 -3
- package/lib/rc-qrcode/index.js +2 -25
- package/lib/rc-qrcode/useQrcode.js +5 -17
- package/lib/rc-transition-group/index.js +0 -9
- package/lib/resizable/index.js +0 -2
- package/lib/resizable/style/index.js +0 -1
- package/lib/rich-text-editor/index.js +5 -53
- package/lib/rich-text-editor/plugins/code/index.js +2 -12
- package/lib/rich-text-editor/style/index.css +195 -743
- package/lib/rich-text-editor/style/index.js +0 -1
- package/lib/single-img-upload/index.js +36 -125
- package/lib/single-img-upload/style/index.css +195 -743
- package/lib/single-img-upload/style/index.js +0 -3
- package/lib/sortable-hoc/index.js +0 -9
- package/lib/split-pane/index.js +0 -15
- package/lib/split-pane/style/index.js +0 -1
- package/lib/step-number-input/index.js +14 -55
- package/lib/step-number-input/style/index.css +195 -743
- package/lib/step-number-input/style/index.js +0 -2
- package/lib/table-col/index.js +2 -6
- package/lib/text-area/index.js +8 -38
- package/lib/text-area/style/index.js +0 -1
- package/lib/text-input/index.js +4 -23
- package/lib/text-input/style/index.css +7 -21
- package/lib/text-input/style/index.js +0 -1
- package/package.json +6 -6
package/es/img-crop/index.js
CHANGED
|
@@ -2,25 +2,20 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
5
|
for (var p in s) {
|
|
7
6
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return __assign.apply(this, arguments);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
18
14
|
function adopt(value) {
|
|
19
15
|
return value instanceof P ? value : new P(function (resolve) {
|
|
20
16
|
resolve(value);
|
|
21
17
|
});
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
20
|
function fulfilled(value) {
|
|
26
21
|
try {
|
|
@@ -29,7 +24,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
29
24
|
reject(e);
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
function rejected(value) {
|
|
34
28
|
try {
|
|
35
29
|
step(generator["throw"](value));
|
|
@@ -37,29 +31,26 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
37
31
|
reject(e);
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
function step(result) {
|
|
42
35
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
38
|
});
|
|
47
39
|
};
|
|
48
|
-
|
|
49
40
|
var __generator = this && this.__generator || function (thisArg, body) {
|
|
50
41
|
var _ = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
label: 0,
|
|
43
|
+
sent: function sent() {
|
|
44
|
+
if (t[0] & 1) throw t[1];
|
|
45
|
+
return t[1];
|
|
46
|
+
},
|
|
47
|
+
trys: [],
|
|
48
|
+
ops: []
|
|
55
49
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
y,
|
|
61
|
-
t,
|
|
62
|
-
g;
|
|
50
|
+
f,
|
|
51
|
+
y,
|
|
52
|
+
t,
|
|
53
|
+
g;
|
|
63
54
|
return g = {
|
|
64
55
|
next: verb(0),
|
|
65
56
|
"throw": verb(1),
|
|
@@ -67,79 +58,60 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
67
58
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
68
59
|
return this;
|
|
69
60
|
}), g;
|
|
70
|
-
|
|
71
61
|
function verb(n) {
|
|
72
62
|
return function (v) {
|
|
73
63
|
return step([n, v]);
|
|
74
64
|
};
|
|
75
65
|
}
|
|
76
|
-
|
|
77
66
|
function step(op) {
|
|
78
67
|
if (f) throw new TypeError("Generator is already executing.");
|
|
79
|
-
|
|
80
68
|
while (_) {
|
|
81
69
|
try {
|
|
82
70
|
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
71
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
84
|
-
|
|
85
72
|
switch (op[0]) {
|
|
86
73
|
case 0:
|
|
87
74
|
case 1:
|
|
88
75
|
t = op;
|
|
89
76
|
break;
|
|
90
|
-
|
|
91
77
|
case 4:
|
|
92
78
|
_.label++;
|
|
93
79
|
return {
|
|
94
80
|
value: op[1],
|
|
95
81
|
done: false
|
|
96
82
|
};
|
|
97
|
-
|
|
98
83
|
case 5:
|
|
99
84
|
_.label++;
|
|
100
85
|
y = op[1];
|
|
101
86
|
op = [0];
|
|
102
87
|
continue;
|
|
103
|
-
|
|
104
88
|
case 7:
|
|
105
89
|
op = _.ops.pop();
|
|
106
|
-
|
|
107
90
|
_.trys.pop();
|
|
108
|
-
|
|
109
91
|
continue;
|
|
110
|
-
|
|
111
92
|
default:
|
|
112
93
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
113
94
|
_ = 0;
|
|
114
95
|
continue;
|
|
115
96
|
}
|
|
116
|
-
|
|
117
97
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
118
98
|
_.label = op[1];
|
|
119
99
|
break;
|
|
120
100
|
}
|
|
121
|
-
|
|
122
101
|
if (op[0] === 6 && _.label < t[1]) {
|
|
123
102
|
_.label = t[1];
|
|
124
103
|
t = op;
|
|
125
104
|
break;
|
|
126
105
|
}
|
|
127
|
-
|
|
128
106
|
if (t && _.label < t[2]) {
|
|
129
107
|
_.label = t[2];
|
|
130
|
-
|
|
131
108
|
_.ops.push(op);
|
|
132
|
-
|
|
133
109
|
break;
|
|
134
110
|
}
|
|
135
|
-
|
|
136
111
|
if (t[2]) _.ops.pop();
|
|
137
|
-
|
|
138
112
|
_.trys.pop();
|
|
139
|
-
|
|
140
113
|
continue;
|
|
141
114
|
}
|
|
142
|
-
|
|
143
115
|
op = body.call(thisArg, _);
|
|
144
116
|
} catch (e) {
|
|
145
117
|
op = [6, e];
|
|
@@ -148,7 +120,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
148
120
|
f = t = 0;
|
|
149
121
|
}
|
|
150
122
|
}
|
|
151
|
-
|
|
152
123
|
if (op[0] & 5) throw op[1];
|
|
153
124
|
return {
|
|
154
125
|
value: op[0] ? op[1] : void 0,
|
|
@@ -156,28 +127,23 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
156
127
|
};
|
|
157
128
|
}
|
|
158
129
|
};
|
|
159
|
-
|
|
160
130
|
var __rest = this && this.__rest || function (s, e) {
|
|
161
131
|
var t = {};
|
|
162
|
-
|
|
163
132
|
for (var p in s) {
|
|
164
133
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
165
134
|
}
|
|
166
|
-
|
|
167
135
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
168
136
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
169
137
|
}
|
|
170
138
|
return t;
|
|
171
139
|
};
|
|
172
|
-
|
|
173
140
|
var __read = this && this.__read || function (o, n) {
|
|
174
141
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
175
142
|
if (!m) return o;
|
|
176
143
|
var i = m.call(o),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
144
|
+
r,
|
|
145
|
+
ar = [],
|
|
146
|
+
e;
|
|
181
147
|
try {
|
|
182
148
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
183
149
|
ar.push(r.value);
|
|
@@ -193,60 +159,51 @@ var __read = this && this.__read || function (o, n) {
|
|
|
193
159
|
if (e) throw e.error;
|
|
194
160
|
}
|
|
195
161
|
}
|
|
196
|
-
|
|
197
162
|
return ar;
|
|
198
163
|
};
|
|
199
|
-
|
|
200
164
|
import * as React from 'react';
|
|
201
165
|
import Modal from "antd/es/modal";
|
|
202
166
|
import Slider from "antd/es/slider";
|
|
203
167
|
import getCroppedImg from './getCroppedImg';
|
|
204
168
|
import EasyCrop from './EasyCrop';
|
|
205
169
|
import './style/index.less';
|
|
206
|
-
|
|
207
170
|
var noop = function noop() {};
|
|
208
|
-
|
|
209
171
|
var ZOOM_STEP = 0.1;
|
|
210
172
|
var MIN_ROTATE = 0;
|
|
211
173
|
var MAX_ROTATE = 360;
|
|
212
174
|
var ROTATE_STEP = 1;
|
|
213
|
-
|
|
214
175
|
var ImgCrop = function ImgCrop(props) {
|
|
215
176
|
var aspect = props.aspect,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
177
|
+
shape = props.shape,
|
|
178
|
+
grid = props.grid,
|
|
179
|
+
quality = props.quality,
|
|
180
|
+
zoom = props.zoom,
|
|
181
|
+
rotate = props.rotate,
|
|
182
|
+
minZoom = props.minZoom,
|
|
183
|
+
maxZoom = props.maxZoom,
|
|
184
|
+
fillColor = props.fillColor,
|
|
185
|
+
prefix = props.prefix,
|
|
186
|
+
modalTitle = props.modalTitle,
|
|
187
|
+
modalWidth = props.modalWidth,
|
|
188
|
+
modalOk = props.modalOk,
|
|
189
|
+
modalCancel = props.modalCancel,
|
|
190
|
+
beforeCrop = props.beforeCrop,
|
|
191
|
+
zipImg = props.zipImg,
|
|
192
|
+
children = props.children,
|
|
193
|
+
cropperProps = props.cropperProps;
|
|
233
194
|
var pkg = "".concat(prefix, "-img-crop");
|
|
234
195
|
var MEDIA_CLASS = "".concat(pkg, "-media");
|
|
235
196
|
var hasZoom = zoom === true;
|
|
236
197
|
var hasRotate = rotate === true;
|
|
237
|
-
|
|
238
198
|
var _a = __read(React.useState(''), 2),
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
199
|
+
src = _a[0],
|
|
200
|
+
setSrc = _a[1];
|
|
242
201
|
var _b = __read(React.useState(1), 2),
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
202
|
+
zoomVal = _b[0],
|
|
203
|
+
setZoomVal = _b[1];
|
|
246
204
|
var _c = __read(React.useState(0), 2),
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
205
|
+
rotateVal = _c[0],
|
|
206
|
+
setRotateVal = _c[1];
|
|
250
207
|
var beforeUploadRef = React.useRef();
|
|
251
208
|
var fileRef = React.useRef();
|
|
252
209
|
var resolveRef = React.useRef(noop);
|
|
@@ -255,15 +212,12 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
255
212
|
/**
|
|
256
213
|
* Upload
|
|
257
214
|
*/
|
|
258
|
-
|
|
259
215
|
var renderUpload = React.useCallback(function () {
|
|
260
216
|
var upload = Array.isArray(children) ? children[0] : children;
|
|
261
|
-
|
|
262
217
|
var _a = upload.props,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
218
|
+
beforeUpload = _a.beforeUpload,
|
|
219
|
+
accept = _a.accept,
|
|
220
|
+
restUploadProps = __rest(_a, ["beforeUpload", "accept"]);
|
|
267
221
|
beforeUploadRef.current = beforeUpload;
|
|
268
222
|
return __assign(__assign({}, upload), {
|
|
269
223
|
props: __assign(__assign({}, restUploadProps), {
|
|
@@ -274,7 +228,6 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
274
228
|
reject();
|
|
275
229
|
return;
|
|
276
230
|
}
|
|
277
|
-
|
|
278
231
|
fileRef.current = file;
|
|
279
232
|
resolveRef.current = resolve;
|
|
280
233
|
rejectRef.current = reject;
|
|
@@ -291,14 +244,12 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
291
244
|
/**
|
|
292
245
|
* EasyCrop
|
|
293
246
|
*/
|
|
294
|
-
|
|
295
247
|
var onComplete = React.useCallback(function (croppedAreaPixels) {
|
|
296
248
|
cropPixelsRef.current = croppedAreaPixels;
|
|
297
249
|
}, []);
|
|
298
250
|
/**
|
|
299
251
|
* Controls
|
|
300
252
|
*/
|
|
301
|
-
|
|
302
253
|
var isMinZoom = zoomVal - ZOOM_STEP < minZoom;
|
|
303
254
|
var isMaxZoom = zoomVal + ZOOM_STEP > maxZoom;
|
|
304
255
|
var isMinRotate = rotateVal === MIN_ROTATE;
|
|
@@ -318,7 +269,6 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
318
269
|
/**
|
|
319
270
|
* Modal
|
|
320
271
|
*/
|
|
321
|
-
|
|
322
272
|
var modalProps = React.useMemo(function () {
|
|
323
273
|
var obj = {
|
|
324
274
|
width: modalWidth,
|
|
@@ -335,7 +285,6 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
335
285
|
var onOk = React.useCallback(function () {
|
|
336
286
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
337
287
|
var naturalImg, naturalWidth, naturalHeight, canvas, ctx, maxLen, halfMax, left, top, maxImgData, _a, width, height, x, y, _b, type, name, uid;
|
|
338
|
-
|
|
339
288
|
return __generator(this, function (_c) {
|
|
340
289
|
onClose();
|
|
341
290
|
naturalImg = document.querySelector(".".concat(MEDIA_CLASS));
|
|
@@ -344,15 +293,14 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
344
293
|
ctx = canvas.getContext('2d');
|
|
345
294
|
maxLen = Math.sqrt(Math.pow(naturalWidth, 2) + Math.pow(naturalHeight, 2));
|
|
346
295
|
canvas.width = maxLen;
|
|
347
|
-
canvas.height = maxLen;
|
|
348
|
-
|
|
296
|
+
canvas.height = maxLen;
|
|
297
|
+
// rotate the image
|
|
349
298
|
if (hasRotate && rotateVal > 0 && rotateVal < 360) {
|
|
350
299
|
halfMax = maxLen / 2;
|
|
351
300
|
ctx === null || ctx === void 0 ? void 0 : ctx.translate(halfMax, halfMax);
|
|
352
301
|
ctx === null || ctx === void 0 ? void 0 : ctx.rotate(rotateVal * Math.PI / 180);
|
|
353
302
|
ctx === null || ctx === void 0 ? void 0 : ctx.translate(-halfMax, -halfMax);
|
|
354
303
|
}
|
|
355
|
-
|
|
356
304
|
ctx.fillStyle = fillColor;
|
|
357
305
|
ctx === null || ctx === void 0 ? void 0 : ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
358
306
|
left = (maxLen - naturalWidth) / 2;
|
|
@@ -373,87 +321,52 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
373
321
|
newFile = new File([blob], name, {
|
|
374
322
|
type: type
|
|
375
323
|
});
|
|
376
|
-
if (!zipImg) return [3
|
|
377
|
-
/*break*/
|
|
378
|
-
, 2];
|
|
324
|
+
if (!zipImg) return [3 /*break*/, 2];
|
|
379
325
|
url = window.URL || window.webkitURL;
|
|
380
326
|
imgUrl = url.createObjectURL(newFile);
|
|
381
|
-
return [4
|
|
382
|
-
/*yield*/
|
|
383
|
-
, getCroppedImg(imgUrl, zipImg, name, type)];
|
|
384
|
-
|
|
327
|
+
return [4 /*yield*/, getCroppedImg(imgUrl, zipImg, name, type)];
|
|
385
328
|
case 1:
|
|
386
329
|
fileObj = _a.sent().fileObj;
|
|
387
330
|
newFile = fileObj;
|
|
388
331
|
_a.label = 2;
|
|
389
|
-
|
|
390
332
|
case 2:
|
|
391
333
|
newFile.uid = uid;
|
|
392
|
-
if (typeof beforeUploadRef.current !== 'function') return [2
|
|
393
|
-
/*return*/
|
|
394
|
-
, resolveRef.current(newFile)];
|
|
334
|
+
if (typeof beforeUploadRef.current !== 'function') return [2 /*return*/, resolveRef.current(newFile)];
|
|
395
335
|
res = beforeUploadRef.current(newFile, [newFile]);
|
|
396
|
-
if (!(typeof res !== 'boolean' && !res)) return [3
|
|
397
|
-
/*break*/
|
|
398
|
-
, 3];
|
|
336
|
+
if (!(typeof res !== 'boolean' && !res)) return [3 /*break*/, 3];
|
|
399
337
|
console.error('beforeUpload must return a boolean or Promise');
|
|
400
|
-
return [3
|
|
401
|
-
/*break*/
|
|
402
|
-
, 7];
|
|
403
|
-
|
|
338
|
+
return [3 /*break*/, 7];
|
|
404
339
|
case 3:
|
|
405
|
-
if (res === true) return [2
|
|
406
|
-
/*return
|
|
407
|
-
|
|
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];
|
|
340
|
+
if (res === true) return [2 /*return*/, resolveRef.current(newFile)];
|
|
341
|
+
if (res === false) return [2 /*return*/, rejectRef.current('not upload')];
|
|
342
|
+
if (!(res && typeof res.then === 'function')) return [3 /*break*/, 7];
|
|
414
343
|
_a.label = 4;
|
|
415
|
-
|
|
416
344
|
case 4:
|
|
417
345
|
_a.trys.push([4, 6,, 7]);
|
|
418
|
-
|
|
419
|
-
return [4
|
|
420
|
-
/*yield*/
|
|
421
|
-
, res];
|
|
422
|
-
|
|
346
|
+
return [4 /*yield*/, res];
|
|
423
347
|
case 5:
|
|
424
348
|
passedFile = _a.sent();
|
|
425
349
|
fileType = Object.prototype.toString.call(passedFile);
|
|
426
350
|
if (fileType === '[object File]' || fileType === '[object Blob]') newFile = passedFile;
|
|
427
351
|
resolveRef.current(newFile);
|
|
428
|
-
return [3
|
|
429
|
-
/*break*/
|
|
430
|
-
, 7];
|
|
431
|
-
|
|
352
|
+
return [3 /*break*/, 7];
|
|
432
353
|
case 6:
|
|
433
354
|
err_1 = _a.sent();
|
|
434
355
|
rejectRef.current(err_1);
|
|
435
|
-
return [3
|
|
436
|
-
/*break*/
|
|
437
|
-
, 7];
|
|
438
|
-
|
|
356
|
+
return [3 /*break*/, 7];
|
|
439
357
|
case 7:
|
|
440
|
-
return [2
|
|
441
|
-
/*return*/
|
|
442
|
-
, null];
|
|
358
|
+
return [2 /*return*/, null];
|
|
443
359
|
}
|
|
444
360
|
});
|
|
445
361
|
});
|
|
446
362
|
}, type, quality);
|
|
447
|
-
return [2
|
|
448
|
-
/*return*/
|
|
449
|
-
];
|
|
363
|
+
return [2 /*return*/];
|
|
450
364
|
});
|
|
451
365
|
});
|
|
452
366
|
}, [hasRotate, onClose, quality, rotateVal]);
|
|
453
|
-
|
|
454
367
|
var renderComponent = function renderComponent(titleOfModal) {
|
|
455
368
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderUpload(), src && /*#__PURE__*/React.createElement(Modal, __assign({
|
|
456
|
-
|
|
369
|
+
open: true,
|
|
457
370
|
wrapClassName: "".concat(pkg, "-modal"),
|
|
458
371
|
title: titleOfModal,
|
|
459
372
|
onOk: onOk,
|
|
@@ -511,10 +424,8 @@ var ImgCrop = function ImgCrop(props) {
|
|
|
511
424
|
disabled: isMaxRotate
|
|
512
425
|
}, "\u21BB"))));
|
|
513
426
|
};
|
|
514
|
-
|
|
515
427
|
return renderComponent(modalTitle);
|
|
516
428
|
};
|
|
517
|
-
|
|
518
429
|
ImgCrop.defaultProps = {
|
|
519
430
|
prefix: 'ant',
|
|
520
431
|
aspect: 1,
|