@hai-dev/ui-kit 1.1.6 → 1.1.7
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/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog.js +1 -1
- package/dist/components/photo-crop-uploader/constants.d.ts +1 -0
- package/dist/components/photo-crop-uploader/constants.js +40 -39
- package/dist/components/photo-crop-uploader/photo-crop-uploader.js +158 -139
- package/dist/components/photo-crop-uploader/types.d.ts +5 -3
- package/dist/components/photo-crop-uploader/utils/draw-cropped-image.js +1 -1
- package/dist/components/photo-crop-uploader/utils/get-cropped-source.js +1 -1
- package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.js +1 -1
- package/dist/components/photo-crop-uploader/utils/get-photo-crop.d.ts +1 -1
- package/dist/components/photo-crop-uploader/utils/get-photo-crop.js +29 -12
- package/dist/{index-BiffjjQq.js → index-CcueJ2sD.js} +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as L, jsx as a, Fragment as _ } from "react/jsx-runtime";
|
|
2
2
|
import * as k from "react";
|
|
3
|
-
import { S as $ } from "../../../../index-
|
|
3
|
+
import { S as $ } from "../../../../index-CcueJ2sD.js";
|
|
4
4
|
import { c as i } from "../../../../index-B2JRaoNz.js";
|
|
5
5
|
import { s as n, U as V } from "../../../../upload-dialog-errors-Bxun25O-.js";
|
|
6
6
|
import { PhotoList as H } from "../photo-list/photo-list.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_ASPECT_RATIO = 1;
|
|
2
2
|
export declare const DEFAULT_MIN_DIMENSION = 670;
|
|
3
|
+
export declare const DEFAULT_BASE_DIMENSION = 90;
|
|
3
4
|
export declare const JPG_IMAGE_EXT = ".jpg";
|
|
4
5
|
export declare const JPEG_IMAGE_EXT = ".jpeg";
|
|
5
6
|
export declare const PNG_IMAGE_EXT = ".png";
|
|
@@ -1,75 +1,76 @@
|
|
|
1
1
|
import { BYTE_TO_KILOBYTE as E } from "../../constants.js";
|
|
2
|
-
const
|
|
2
|
+
const D = 1, i = 670, L = 90, _ = ".jpg", I = ".jpeg", A = ".png", o = ".svg", M = ".bmp", P = ".gif", T = ".ico", n = ".webp", e = [
|
|
3
3
|
_,
|
|
4
4
|
I,
|
|
5
|
-
o,
|
|
6
5
|
A,
|
|
6
|
+
o,
|
|
7
7
|
M,
|
|
8
8
|
P,
|
|
9
9
|
n,
|
|
10
10
|
T
|
|
11
|
-
],
|
|
12
|
-
G,
|
|
11
|
+
], c = "image/jpg", s = "image/jpeg", G = "image/png", t = "image/svg+xml", O = "image/bmp", S = "image/gif", Y = "image/webp", m = "image/x-icon", N = "image/vnd.microsoft.icon", U = ".mp4", X = ".webm", F = "video/mp4", p = "video/webm", C = [
|
|
13
12
|
c,
|
|
14
13
|
s,
|
|
14
|
+
G,
|
|
15
15
|
t,
|
|
16
16
|
O,
|
|
17
|
-
Y,
|
|
18
17
|
S,
|
|
18
|
+
Y,
|
|
19
19
|
m,
|
|
20
|
-
|
|
21
|
-
],
|
|
20
|
+
N
|
|
21
|
+
], B = {
|
|
22
22
|
JPEG_IMAGE_TYPE: [_, I],
|
|
23
23
|
JPG_IMAGE_TYPE: [_, I],
|
|
24
|
-
PNG_IMAGE_TYPE: [
|
|
24
|
+
PNG_IMAGE_TYPE: [A],
|
|
25
25
|
GIF_IMAGE_TYPE: [P],
|
|
26
|
-
SVG_IMAGE_TYPE: [
|
|
26
|
+
SVG_IMAGE_TYPE: [o],
|
|
27
27
|
BMP_IMAGE_TYPE: [M],
|
|
28
28
|
WEBP_IMAGE_TYPE: [n],
|
|
29
29
|
ICO_IMAGE_TYPE: [T],
|
|
30
30
|
MICROSOFT_ICO_IMAGE_TYPE: [T]
|
|
31
|
-
}, R = 500,
|
|
31
|
+
}, R = 500, V = 10 * E * E, a = 50 * E * E, b = "2d", J = "high", v = "%", W = "px", d = "ms", f = "mb", j = 1, r = 100, w = 2, x = 0.5, H = 100, Z = 100, h = 500;
|
|
32
32
|
export {
|
|
33
33
|
M as BMP_IMAGE_EXT,
|
|
34
34
|
O as BMP_IMAGE_TYPE,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
D as DEFAULT_ASPECT_RATIO,
|
|
36
|
+
L as DEFAULT_BASE_DIMENSION,
|
|
37
|
+
V as DEFAULT_FILE_MAX_SIZE,
|
|
38
|
+
i as DEFAULT_MIN_DIMENSION,
|
|
38
39
|
R as DEFAULT_TIMEOUT,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
a as DEFAULT_VIDEO_FILE_MAX_SIZE,
|
|
41
|
+
r as FULL_CROP_SIZE,
|
|
42
|
+
H as FULL_PROGRESS_VALUE,
|
|
42
43
|
P as GIF_IMAGE_EXT,
|
|
43
|
-
|
|
44
|
+
S as GIF_IMAGE_TYPE,
|
|
44
45
|
T as ICO_IMAGE_EXT,
|
|
45
46
|
m as ICO_IMAGE_TYPE,
|
|
46
47
|
I as JPEG_IMAGE_EXT,
|
|
47
|
-
|
|
48
|
+
s as JPEG_IMAGE_TYPE,
|
|
48
49
|
_ as JPG_IMAGE_EXT,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
c as JPG_IMAGE_TYPE,
|
|
51
|
+
w as MAX_ASPECT_RATIO,
|
|
52
|
+
j as MB_FRACTION_DIGITS,
|
|
53
|
+
f as MB_UNIT,
|
|
54
|
+
N as MICROSOFT_ICO_IMAGE_TYPE,
|
|
55
|
+
B as MIME_TO_EXT,
|
|
56
|
+
x as MIN_ASPECT_RATIO,
|
|
57
|
+
U as MP4_VIDEO_EXT,
|
|
58
|
+
F as MP4_VIDEO_TYPE,
|
|
59
|
+
d as MS_UNIT,
|
|
60
|
+
b as PHOTO_CANVAS_CONTEXT,
|
|
61
|
+
Z as PHOTO_LOADING_DELAY,
|
|
62
|
+
J as PHOTO_SMOOTHING_QUALITY,
|
|
63
|
+
W as PIXEL_UNIT,
|
|
64
|
+
A as PNG_IMAGE_EXT,
|
|
65
|
+
G as PNG_IMAGE_TYPE,
|
|
66
|
+
v as PRECENT_UNIT,
|
|
67
|
+
h as RESET_DATA_DELAY,
|
|
68
|
+
e as SUPPORTED_IMAGE_EXTENSIONS,
|
|
68
69
|
C as SUPPORTED_IMAGE_MIME_TYPES,
|
|
69
|
-
|
|
70
|
+
o as SVG_IMAGE_EXT,
|
|
70
71
|
t as SVG_IMAGE_TYPE,
|
|
71
72
|
X as WEBM_VIDEO_EXT,
|
|
72
73
|
p as WEBM_VIDEO_TYPE,
|
|
73
74
|
n as WEBP_IMAGE_EXT,
|
|
74
|
-
|
|
75
|
+
Y as WEBP_IMAGE_TYPE
|
|
75
76
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as i, useRef as
|
|
3
|
-
import { D as
|
|
4
|
-
import { c as
|
|
5
|
-
import { localizedText as
|
|
6
|
-
import { EN_LOCALE as
|
|
7
|
-
import { DEFAULT_MIN_DIMENSION as
|
|
8
|
-
import { UploadDialog as
|
|
9
|
-
import { UploadButton as
|
|
10
|
-
import { ErrorUploadDialog as
|
|
1
|
+
import { jsxs as No, Fragment as Ho, jsx as U } from "react/jsx-runtime";
|
|
2
|
+
import { useState as i, useRef as A } from "react";
|
|
3
|
+
import { v as Vo, D as bo } from "../../index-CcueJ2sD.js";
|
|
4
|
+
import { c as ko } from "../../index-B2JRaoNz.js";
|
|
5
|
+
import { localizedText as zo } from "./locale.js";
|
|
6
|
+
import { EN_LOCALE as jo } from "../../constants.js";
|
|
7
|
+
import { DEFAULT_MIN_DIMENSION as Wo, DEFAULT_ASPECT_RATIO as Bo, DEFAULT_TIMEOUT as Go, DEFAULT_FILE_MAX_SIZE as Xo, DEFAULT_VIDEO_FILE_MAX_SIZE as Yo, DEFAULT_BASE_DIMENSION as Zo, FULL_PROGRESS_VALUE as Q, PHOTO_LOADING_DELAY as qo, RESET_DATA_DELAY as d } from "./constants.js";
|
|
8
|
+
import { UploadDialog as Jo } from "./components/upload-dialog/upload-dialog.js";
|
|
9
|
+
import { UploadButton as Ko } from "./components/upload-button/upload-button.js";
|
|
10
|
+
import { ErrorUploadDialog as Qo } from "./components/error-upload-dialog/error-upload-dialog.js";
|
|
11
11
|
import { isVideo as $ } from "./utils/is-video.js";
|
|
12
12
|
import { validateVideoFile as oo } from "./utils/validate-video-file.js";
|
|
13
13
|
import { validatePhotoFile as eo } from "./utils/validate-photo-file.js";
|
|
14
14
|
import { readPhoto as to } from "./utils/read-photo.js";
|
|
15
|
-
import { getPhotoCrop as
|
|
16
|
-
import { getCroppedSource as
|
|
15
|
+
import { getPhotoCrop as $o } from "./utils/get-photo-crop.js";
|
|
16
|
+
import { getCroppedSource as oe } from "./utils/get-cropped-source.js";
|
|
17
17
|
import { getDefaultCroppedPhoto as ro } from "./utils/get-default-cropped-photo.js";
|
|
18
|
-
import '../../assets/photo-crop-uploader.css';const
|
|
19
|
-
photoCropCanvas:
|
|
18
|
+
import '../../assets/photo-crop-uploader.css';const ee = "_photoCropCanvas_1i4lr_1", te = {
|
|
19
|
+
photoCropCanvas: ee
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function Le(a) {
|
|
22
22
|
const {
|
|
23
|
-
buttonClassname:
|
|
24
|
-
onStartUpload:
|
|
23
|
+
buttonClassname: no = "",
|
|
24
|
+
onStartUpload: so = () => {
|
|
25
25
|
},
|
|
26
26
|
onEndUpload: ao = () => {
|
|
27
27
|
},
|
|
@@ -36,41 +36,43 @@ function Ee(a) {
|
|
|
36
36
|
onDragDrop: uo = () => {
|
|
37
37
|
},
|
|
38
38
|
showErrorPopup: fo = !1,
|
|
39
|
-
minDimension: l =
|
|
40
|
-
aspectRatio: C =
|
|
41
|
-
locale:
|
|
42
|
-
timeout: M =
|
|
43
|
-
fileMaxSize: N =
|
|
44
|
-
videoFileMaxSize:
|
|
45
|
-
allowedExtensions:
|
|
46
|
-
allowedMimeTypes:
|
|
39
|
+
minDimension: l = Wo,
|
|
40
|
+
aspectRatio: C = Bo,
|
|
41
|
+
locale: n = jo,
|
|
42
|
+
timeout: M = Go,
|
|
43
|
+
fileMaxSize: N = Xo,
|
|
44
|
+
videoFileMaxSize: H = Yo,
|
|
45
|
+
allowedExtensions: w,
|
|
46
|
+
allowedMimeTypes: V,
|
|
47
47
|
circular: ho,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
usePercentCrop: mo = !0,
|
|
49
|
+
width: Co,
|
|
50
|
+
keepSelection: go,
|
|
51
|
+
uploadButton: Eo,
|
|
51
52
|
multiple: g = !1,
|
|
52
|
-
fromSources:
|
|
53
|
+
fromSources: b,
|
|
53
54
|
withVideoUploaded: v = !1,
|
|
54
|
-
returnCropParams:
|
|
55
|
+
returnCropParams: Po = !1,
|
|
55
56
|
dialogClassname: k,
|
|
56
|
-
|
|
57
|
+
defaultDimension: Do = Zo,
|
|
58
|
+
...So
|
|
57
59
|
} = a, {
|
|
58
|
-
onEndCrop:
|
|
59
|
-
onClose:
|
|
60
|
-
...
|
|
61
|
-
} =
|
|
60
|
+
onEndCrop: re,
|
|
61
|
+
onClose: ne,
|
|
62
|
+
...Lo
|
|
63
|
+
} = So, [_o, E] = i(!1), [P, D] = i([]), [I, x] = i([]), f = A([]), h = A([]), [p, z] = i(0), j = A(null), W = A(null), [c, O] = i(!1), [To, B] = i(0), [G, X] = i(""), [Uo, S] = i([]), [Ao, Y] = i(!1), wo = _o || c && g, vo = () => {
|
|
62
64
|
S([]);
|
|
63
|
-
}, F = (
|
|
65
|
+
}, F = (e = []) => {
|
|
64
66
|
c || (a.returnCropParams === !0 && a.onClose?.(
|
|
65
|
-
|
|
67
|
+
e,
|
|
66
68
|
f.current,
|
|
67
69
|
h.current
|
|
68
70
|
), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
|
|
69
71
|
f.current = [], h.current = [];
|
|
70
72
|
}, d));
|
|
71
|
-
}, R = (
|
|
73
|
+
}, R = (e = []) => {
|
|
72
74
|
c || (a.returnCropParams || a.onClose?.(
|
|
73
|
-
|
|
75
|
+
e,
|
|
74
76
|
f.current,
|
|
75
77
|
h.current
|
|
76
78
|
), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
|
|
@@ -78,132 +80,149 @@ function Ee(a) {
|
|
|
78
80
|
}, d));
|
|
79
81
|
}, Z = () => {
|
|
80
82
|
c || (a.returnCropParams === !0 ? F([]) : R([]));
|
|
81
|
-
},
|
|
83
|
+
}, Io = () => {
|
|
82
84
|
Y(!1);
|
|
83
|
-
}, L = (
|
|
84
|
-
ao(
|
|
85
|
-
}, y = (
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
const { files: t } =
|
|
85
|
+
}, L = (e, t = e, o = [], r = !1) => {
|
|
86
|
+
ao(e), X(""), D(e), x(Array(e.length)), z(0), E(!0), f.current = t, h.current = o, !e.length && !r && Z();
|
|
87
|
+
}, y = (e) => {
|
|
88
|
+
e instanceof Error && (console.warn(e.message), io(e), X(e.message), Y(!0), D([]), E(!1), f.current = [], h.current = []);
|
|
89
|
+
}, xo = async (e) => {
|
|
90
|
+
const { files: t } = e.target;
|
|
89
91
|
if (t?.length && !c)
|
|
90
92
|
try {
|
|
91
|
-
if (O(!0),
|
|
92
|
-
const
|
|
93
|
-
for (const m of
|
|
94
|
-
const
|
|
93
|
+
if (O(!0), so(), g) {
|
|
94
|
+
const o = Array.from(t), r = Q / o.length, _ = [], u = [], J = [], T = [];
|
|
95
|
+
for (const m of o) {
|
|
96
|
+
const Mo = $(m);
|
|
95
97
|
try {
|
|
96
|
-
if (v &&
|
|
97
|
-
oo(m,
|
|
98
|
-
const
|
|
99
|
-
J.push(u.length), u.push(
|
|
98
|
+
if (v && Mo) {
|
|
99
|
+
oo(m, H, n);
|
|
100
|
+
const s = URL.createObjectURL(m);
|
|
101
|
+
J.push(u.length), u.push(s);
|
|
100
102
|
} else {
|
|
101
103
|
eo(
|
|
102
104
|
m,
|
|
103
105
|
{
|
|
104
106
|
maxSize: N,
|
|
105
|
-
allowedExtensions:
|
|
106
|
-
allowedMimeTypes:
|
|
107
|
+
allowedExtensions: w,
|
|
108
|
+
allowedMimeTypes: V
|
|
107
109
|
},
|
|
108
|
-
|
|
110
|
+
n
|
|
109
111
|
);
|
|
110
|
-
const
|
|
112
|
+
const s = await to(
|
|
111
113
|
m,
|
|
112
114
|
l,
|
|
113
|
-
|
|
115
|
+
n,
|
|
114
116
|
M
|
|
115
117
|
);
|
|
116
|
-
_.push(
|
|
118
|
+
_.push(s), u.push(s);
|
|
117
119
|
}
|
|
118
|
-
} catch (
|
|
120
|
+
} catch (s) {
|
|
119
121
|
let K = "";
|
|
120
|
-
|
|
122
|
+
s instanceof Error && (K = s.message), T.push({
|
|
121
123
|
photoName: m.name,
|
|
122
124
|
errorMessage: K
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
127
|
B(
|
|
126
|
-
(
|
|
127
|
-
), await new Promise((
|
|
128
|
+
(s) => Math.min(Q, s + r)
|
|
129
|
+
), await new Promise((s) => setTimeout(s, 0));
|
|
128
130
|
}
|
|
129
|
-
if (
|
|
131
|
+
if (b?.length)
|
|
130
132
|
throw new Error(T[0]?.errorMessage);
|
|
131
133
|
S(T), L(_, u, J, T.length > 0);
|
|
132
134
|
} else {
|
|
133
|
-
const
|
|
134
|
-
if (v && $(
|
|
135
|
-
oo(
|
|
136
|
-
const r = URL.createObjectURL(
|
|
135
|
+
const o = t[0];
|
|
136
|
+
if (v && $(o)) {
|
|
137
|
+
oo(o, H, n);
|
|
138
|
+
const r = URL.createObjectURL(o);
|
|
137
139
|
L([], [r], [0]);
|
|
138
140
|
} else {
|
|
139
141
|
eo(
|
|
140
|
-
|
|
141
|
-
{ maxSize: N, allowedExtensions:
|
|
142
|
-
|
|
142
|
+
o,
|
|
143
|
+
{ maxSize: N, allowedExtensions: w, allowedMimeTypes: V },
|
|
144
|
+
n
|
|
143
145
|
);
|
|
144
|
-
const r = await to(
|
|
146
|
+
const r = await to(o, l, n, M);
|
|
145
147
|
L([r]);
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
|
-
} catch (
|
|
149
|
-
y(
|
|
150
|
+
} catch (o) {
|
|
151
|
+
y(o);
|
|
150
152
|
} finally {
|
|
151
153
|
g ? setTimeout(() => {
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
+
e.target.value = "", B(0), O(!1);
|
|
155
|
+
}, qo) : (e.target.value = "", O(!1));
|
|
154
156
|
}
|
|
155
|
-
},
|
|
156
|
-
const { width: t, height:
|
|
157
|
-
|
|
157
|
+
}, Oo = (e) => {
|
|
158
|
+
const { width: t, height: o } = e.currentTarget, r = $o(
|
|
159
|
+
t,
|
|
160
|
+
o,
|
|
161
|
+
l,
|
|
162
|
+
C,
|
|
163
|
+
!1,
|
|
164
|
+
Do
|
|
165
|
+
);
|
|
166
|
+
x((_) => {
|
|
158
167
|
const u = [..._];
|
|
159
168
|
return u[p] = r, u;
|
|
160
169
|
});
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
const r = [...
|
|
170
|
+
}, Fo = (e, t) => {
|
|
171
|
+
x((o) => {
|
|
172
|
+
const r = [...o];
|
|
164
173
|
return r[p] = t, r;
|
|
165
174
|
});
|
|
166
175
|
}, q = () => {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
176
|
+
const e = W.current, t = j.current;
|
|
177
|
+
if (e && t && I)
|
|
169
178
|
try {
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
179
|
+
const o = I[p];
|
|
180
|
+
if (!o) return !1;
|
|
172
181
|
if (lo(), a.returnCropParams === !0) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
182
|
+
if (mo) {
|
|
183
|
+
const r = Vo(
|
|
184
|
+
o,
|
|
185
|
+
t.naturalWidth,
|
|
186
|
+
t.naturalHeight
|
|
187
|
+
);
|
|
188
|
+
a.onEndCrop?.(r);
|
|
189
|
+
} else {
|
|
190
|
+
const r = bo(
|
|
191
|
+
o,
|
|
192
|
+
t.naturalWidth,
|
|
193
|
+
t.naturalHeight
|
|
194
|
+
);
|
|
195
|
+
a.onEndCrop?.(r);
|
|
196
|
+
}
|
|
197
|
+
p >= P.length - 1 && F();
|
|
179
198
|
} else {
|
|
180
|
-
const r =
|
|
199
|
+
const r = oe(
|
|
181
200
|
t,
|
|
182
|
-
o,
|
|
183
201
|
e,
|
|
184
|
-
|
|
202
|
+
o,
|
|
203
|
+
n
|
|
185
204
|
);
|
|
186
205
|
a.onEndCrop?.(r), p >= P.length - 1 && R();
|
|
187
206
|
}
|
|
188
207
|
return !0;
|
|
189
|
-
} catch (
|
|
190
|
-
return
|
|
208
|
+
} catch (o) {
|
|
209
|
+
return o instanceof Error && (console.warn(o), y(o)), !1;
|
|
191
210
|
}
|
|
192
211
|
else
|
|
193
212
|
return !1;
|
|
194
|
-
},
|
|
213
|
+
}, Ro = () => {
|
|
195
214
|
q() && z((t) => t + 1);
|
|
196
|
-
},
|
|
197
|
-
const
|
|
215
|
+
}, yo = async () => {
|
|
216
|
+
const e = P.slice(p);
|
|
198
217
|
try {
|
|
199
|
-
if (
|
|
218
|
+
if (Po) {
|
|
200
219
|
const t = await Promise.all(
|
|
201
|
-
|
|
202
|
-
(
|
|
203
|
-
|
|
220
|
+
e.map(
|
|
221
|
+
(o) => ro(
|
|
222
|
+
o,
|
|
204
223
|
l,
|
|
205
224
|
C,
|
|
206
|
-
|
|
225
|
+
n,
|
|
207
226
|
!0
|
|
208
227
|
)
|
|
209
228
|
)
|
|
@@ -211,12 +230,12 @@ function Ee(a) {
|
|
|
211
230
|
F(t);
|
|
212
231
|
} else {
|
|
213
232
|
const t = await Promise.all(
|
|
214
|
-
|
|
215
|
-
(
|
|
216
|
-
|
|
233
|
+
e.map(
|
|
234
|
+
(o) => ro(
|
|
235
|
+
o,
|
|
217
236
|
l,
|
|
218
237
|
C,
|
|
219
|
-
|
|
238
|
+
n,
|
|
220
239
|
!1
|
|
221
240
|
)
|
|
222
241
|
)
|
|
@@ -227,70 +246,70 @@ function Ee(a) {
|
|
|
227
246
|
y(t);
|
|
228
247
|
}
|
|
229
248
|
};
|
|
230
|
-
return /* @__PURE__ */
|
|
249
|
+
return /* @__PURE__ */ No(Ho, { children: [
|
|
231
250
|
/* @__PURE__ */ U(
|
|
232
|
-
|
|
251
|
+
Ko,
|
|
233
252
|
{
|
|
234
|
-
onChange:
|
|
253
|
+
onChange: xo,
|
|
235
254
|
onPhotoDataLoaded: L,
|
|
236
|
-
buttonClassname:
|
|
255
|
+
buttonClassname: no,
|
|
237
256
|
disabled: c,
|
|
238
257
|
buttonDisabled: c,
|
|
239
|
-
locale:
|
|
240
|
-
width:
|
|
241
|
-
allowedExtensions:
|
|
258
|
+
locale: n,
|
|
259
|
+
width: Co,
|
|
260
|
+
allowedExtensions: w,
|
|
242
261
|
onDragDrop: uo,
|
|
243
262
|
onDragLeave: po,
|
|
244
263
|
onDragOver: co,
|
|
245
|
-
button:
|
|
264
|
+
button: Eo,
|
|
246
265
|
multiple: g,
|
|
247
|
-
fromSources:
|
|
266
|
+
fromSources: b,
|
|
248
267
|
withVideoUploaded: v,
|
|
249
|
-
...
|
|
250
|
-
children:
|
|
268
|
+
...Lo,
|
|
269
|
+
children: zo[n].upload
|
|
251
270
|
}
|
|
252
271
|
),
|
|
253
272
|
/* @__PURE__ */ U(
|
|
254
|
-
|
|
273
|
+
Jo,
|
|
255
274
|
{
|
|
256
|
-
open:
|
|
275
|
+
open: wo,
|
|
257
276
|
className: k,
|
|
258
277
|
photoSourceLoading: c,
|
|
259
|
-
loadingValue:
|
|
260
|
-
errors:
|
|
261
|
-
photoCrops:
|
|
278
|
+
loadingValue: To,
|
|
279
|
+
errors: Uo,
|
|
280
|
+
photoCrops: I,
|
|
262
281
|
photoSources: P,
|
|
263
|
-
onNextPhoto:
|
|
264
|
-
onSkipCrop:
|
|
265
|
-
onClearErrors:
|
|
282
|
+
onNextPhoto: Ro,
|
|
283
|
+
onSkipCrop: yo,
|
|
284
|
+
onClearErrors: vo,
|
|
266
285
|
photoError: G,
|
|
267
286
|
onCloseDialogHandler: Z,
|
|
268
|
-
onCropChange:
|
|
287
|
+
onCropChange: Fo,
|
|
269
288
|
onPhotoCrop: q,
|
|
270
|
-
onPhotoLoad:
|
|
289
|
+
onPhotoLoad: Oo,
|
|
271
290
|
imageRef: j,
|
|
272
291
|
minDimension: l,
|
|
273
292
|
aspectRatio: C,
|
|
274
|
-
locale:
|
|
293
|
+
locale: n,
|
|
275
294
|
circular: ho,
|
|
276
|
-
keepSelection:
|
|
295
|
+
keepSelection: go,
|
|
277
296
|
photoIndex: p
|
|
278
297
|
}
|
|
279
298
|
),
|
|
280
299
|
/* @__PURE__ */ U(
|
|
281
|
-
|
|
300
|
+
Qo,
|
|
282
301
|
{
|
|
283
302
|
className: k,
|
|
284
|
-
open: fo &&
|
|
303
|
+
open: fo && Ao,
|
|
285
304
|
photoError: G,
|
|
286
|
-
onCloseErrorDialog:
|
|
287
|
-
locale:
|
|
305
|
+
onCloseErrorDialog: Io,
|
|
306
|
+
locale: n
|
|
288
307
|
}
|
|
289
308
|
),
|
|
290
309
|
/* @__PURE__ */ U(
|
|
291
310
|
"canvas",
|
|
292
311
|
{
|
|
293
|
-
className:
|
|
312
|
+
className: ko(te.photoCropCanvas),
|
|
294
313
|
width: l,
|
|
295
314
|
height: l,
|
|
296
315
|
ref: W
|
|
@@ -299,5 +318,5 @@ function Ee(a) {
|
|
|
299
318
|
] });
|
|
300
319
|
}
|
|
301
320
|
export {
|
|
302
|
-
|
|
321
|
+
Le as PhotoCropUploader
|
|
303
322
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DragEvent, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Crop } from 'react-image-crop';
|
|
3
3
|
import { Locale } from '../../types';
|
|
4
4
|
import { BMP_IMAGE_TYPE, GIF_IMAGE_TYPE, ICO_IMAGE_TYPE, JPEG_IMAGE_TYPE, JPG_IMAGE_TYPE, MICROSOFT_ICO_IMAGE_TYPE, PNG_IMAGE_TYPE, SVG_IMAGE_TYPE, WEBP_IMAGE_TYPE, ICO_IMAGE_EXT, BMP_IMAGE_EXT, GIF_IMAGE_EXT, JPEG_IMAGE_EXT, JPG_IMAGE_EXT, PNG_IMAGE_EXT, SVG_IMAGE_EXT, WEBP_IMAGE_EXT } from './constants';
|
|
5
5
|
export type PhotoDataUrl = string;
|
|
@@ -17,8 +17,8 @@ export type PhotoFileOptions = {
|
|
|
17
17
|
};
|
|
18
18
|
type CropPropsWithParams = {
|
|
19
19
|
returnCropParams: true;
|
|
20
|
-
onEndCrop?: (photoData:
|
|
21
|
-
onClose?: (skipPhotosData:
|
|
20
|
+
onEndCrop?: (photoData: Crop) => unknown;
|
|
21
|
+
onClose?: (skipPhotosData: Crop[], sourcesData: PhotoDataUrl[], videoSourceIndexes: number[]) => unknown;
|
|
22
22
|
};
|
|
23
23
|
type CropPropsWithDataUrl = {
|
|
24
24
|
returnCropParams?: false;
|
|
@@ -37,8 +37,10 @@ export type PhotoCropUploaderCustomProps = {
|
|
|
37
37
|
onDragDrop?: (event: DragEvent<HTMLDivElement>) => unknown;
|
|
38
38
|
showErrorPopup?: boolean;
|
|
39
39
|
minDimension?: number;
|
|
40
|
+
defaultDimension?: number;
|
|
40
41
|
aspectRatio?: number;
|
|
41
42
|
locale?: 'ru' | 'en';
|
|
43
|
+
usePercentCrop?: boolean;
|
|
42
44
|
timeout?: number;
|
|
43
45
|
fileMaxSize?: number;
|
|
44
46
|
videoFileMaxSize?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as w } from "../../../index-
|
|
1
|
+
import { D as w } from "../../../index-CcueJ2sD.js";
|
|
2
2
|
import { localizedText as m } from "../locale.js";
|
|
3
3
|
import { EN_LOCALE as E } from "../../../constants.js";
|
|
4
4
|
import { PHOTO_CANVAS_CONTEXT as x } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as w } from "../../../index-
|
|
1
|
+
import { D as w } from "../../../index-CcueJ2sD.js";
|
|
2
2
|
import { localizedText as x } from "../locale.js";
|
|
3
3
|
import { EN_LOCALE as O } from "../../../constants.js";
|
|
4
4
|
import { PHOTO_CANVAS_CONTEXT as f, PHOTO_SMOOTHING_QUALITY as T } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as u } from "../../../index-
|
|
1
|
+
import { D as u } from "../../../index-CcueJ2sD.js";
|
|
2
2
|
import { getPhotoCrop as g } from "./get-photo-crop.js";
|
|
3
3
|
import { getCroppedSource as C } from "./get-cropped-source.js";
|
|
4
4
|
import { localizedText as l } from "../locale.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Crop } from 'react-image-crop';
|
|
2
|
-
export declare const getPhotoCrop: (width: number, height: number, minDimension?: number, aspectRatio?: number, maxSize?: boolean) => Crop;
|
|
2
|
+
export declare const getPhotoCrop: (width: number, height: number, minDimension?: number, aspectRatio?: number, maxSize?: boolean, defaultDimension?: number) => Crop;
|
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { DEFAULT_MIN_DIMENSION as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
import { B as E, L as N } from "../../../index-CcueJ2sD.js";
|
|
2
|
+
import { DEFAULT_MIN_DIMENSION as n, DEFAULT_ASPECT_RATIO as A, FULL_CROP_SIZE as t, PRECENT_UNIT as _ } from "../constants.js";
|
|
3
|
+
const M = (r, c, C = n, I = A, P = !1, o) => {
|
|
4
|
+
const L = r / c / I, T = C / r * t, e = C / c * t;
|
|
5
|
+
let p;
|
|
6
|
+
return o && o >= T && o >= e ? L <= 1 ? p = E(
|
|
5
7
|
{
|
|
6
|
-
unit:
|
|
7
|
-
width:
|
|
8
|
-
height: e ? o : I
|
|
8
|
+
unit: _,
|
|
9
|
+
width: o
|
|
9
10
|
},
|
|
10
|
-
|
|
11
|
+
I,
|
|
11
12
|
r,
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
|
|
13
|
+
c
|
|
14
|
+
) : p = E(
|
|
15
|
+
{
|
|
16
|
+
unit: _,
|
|
17
|
+
height: o
|
|
18
|
+
},
|
|
19
|
+
I,
|
|
20
|
+
r,
|
|
21
|
+
c
|
|
22
|
+
) : p = E(
|
|
23
|
+
{
|
|
24
|
+
unit: _,
|
|
25
|
+
width: P ? t : T,
|
|
26
|
+
height: P ? t : e
|
|
27
|
+
},
|
|
28
|
+
I,
|
|
29
|
+
r,
|
|
30
|
+
c
|
|
31
|
+
), N(p, r, c);
|
|
15
32
|
};
|
|
16
33
|
export {
|
|
17
|
-
|
|
34
|
+
M as getPhotoCrop
|
|
18
35
|
};
|