@hai-dev/ui-kit 1.1.5 → 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 +24 -24
- package/dist/components/photo-crop-uploader/constants.d.ts +2 -0
- package/dist/components/photo-crop-uploader/constants.js +52 -50
- package/dist/components/photo-crop-uploader/locale.js +10 -8
- package/dist/components/photo-crop-uploader/photo-crop-uploader.js +235 -208
- package/dist/components/photo-crop-uploader/types.d.ts +6 -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/components/photo-crop-uploader/utils/index.d.ts +1 -0
- package/dist/components/photo-crop-uploader/utils/index.js +14 -12
- package/dist/components/photo-crop-uploader/utils/validate-video-file.d.ts +2 -0
- package/dist/components/photo-crop-uploader/utils/validate-video-file.js +16 -0
- 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
|
-
import * as
|
|
3
|
-
import { S as $ } from "../../../../index-
|
|
2
|
+
import * as k from "react";
|
|
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";
|
|
@@ -8,8 +8,8 @@ import { localizedText as p } from "../../locale.js";
|
|
|
8
8
|
import { EN_LOCALE as Z } from "../../../../constants.js";
|
|
9
9
|
import { CLOSE_ICON_SIZE as w } from "./constants.js";
|
|
10
10
|
import { DEFAULT_MIN_DIMENSION as Y, DEFAULT_ASPECT_RATIO as q } from "../../constants.js";
|
|
11
|
-
import { D as
|
|
12
|
-
import { a as D, b as
|
|
11
|
+
import { D as O } from "../../../../Dialog-DqFOpJyx.js";
|
|
12
|
+
import { a as D, b as E, D as G } from "../../../../DialogTitle-CeM_Z851.js";
|
|
13
13
|
import { CircularProgressLoader as J } from "../../../circular-progress-loader/circular-progress-loader.js";
|
|
14
14
|
import { a as K, g as Q, c as X, b as m, P as t } from "../../../../createTheme-RRQUOQoF.js";
|
|
15
15
|
import { m as A } from "../../../../memoTheme-5A7c_y33.js";
|
|
@@ -18,7 +18,7 @@ import { u as oo, s as W, c as eo, b as to } from "../../../../chainPropTypes-C0
|
|
|
18
18
|
import { u as ao } from "../../../../useId-CK6Kn3Tn.js";
|
|
19
19
|
import { B as ro } from "../../../../ButtonBase-DPLf5-lz.js";
|
|
20
20
|
import { C as no } from "../../../../CircularProgress-CrHaMZDC.js";
|
|
21
|
-
import { Button as
|
|
21
|
+
import { Button as P } from "../../../button/button.js";
|
|
22
22
|
import '../../../../assets/upload-dialog.css';function io(o) {
|
|
23
23
|
return Q("MuiIconButton", o);
|
|
24
24
|
}
|
|
@@ -169,7 +169,7 @@ const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary"
|
|
|
169
169
|
display: "flex"
|
|
170
170
|
}
|
|
171
171
|
}]
|
|
172
|
-
})), j = /* @__PURE__ */
|
|
172
|
+
})), j = /* @__PURE__ */ k.forwardRef(function(e, r) {
|
|
173
173
|
const c = oo({
|
|
174
174
|
props: e,
|
|
175
175
|
name: "MuiIconButton"
|
|
@@ -230,7 +230,7 @@ process.env.NODE_ENV !== "production" && (j.propTypes = {
|
|
|
230
230
|
/**
|
|
231
231
|
* The icon to display.
|
|
232
232
|
*/
|
|
233
|
-
children: to(t.node, (o) =>
|
|
233
|
+
children: to(t.node, (o) => k.Children.toArray(o.children).some((r) => /* @__PURE__ */ k.isValidElement(r) && r.props.onClick) ? new Error(["MUI: You are providing an onClick event listener to a child of a button element.", "Prefer applying it to the IconButton directly.", "This guarantees that the whole <button> will be responsive to click events."].join(`
|
|
234
234
|
`)) : null),
|
|
235
235
|
/**
|
|
236
236
|
* Override or extend the styles applied to the component.
|
|
@@ -324,42 +324,42 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
324
324
|
className: d,
|
|
325
325
|
photoIndex: C,
|
|
326
326
|
loadingValue: F,
|
|
327
|
-
errors:
|
|
328
|
-
...
|
|
327
|
+
errors: x,
|
|
328
|
+
...T
|
|
329
329
|
} = o, S = r.slice(C).length > 1;
|
|
330
|
-
return h || !r.length ? /* @__PURE__ */ a(
|
|
331
|
-
|
|
330
|
+
return h || !r.length && !x?.length ? /* @__PURE__ */ a(
|
|
331
|
+
O,
|
|
332
332
|
{
|
|
333
333
|
className: i(n.dialog, d),
|
|
334
334
|
onClose: e,
|
|
335
|
-
...
|
|
335
|
+
...T,
|
|
336
336
|
children: /* @__PURE__ */ a(D, { className: i(n.content), children: /* @__PURE__ */ a(J, { value: F }) })
|
|
337
337
|
}
|
|
338
|
-
) :
|
|
339
|
-
|
|
338
|
+
) : x?.length ? /* @__PURE__ */ a(
|
|
339
|
+
O,
|
|
340
340
|
{
|
|
341
341
|
className: i(n.dialog, d),
|
|
342
342
|
onClose: e,
|
|
343
|
-
...
|
|
343
|
+
...T,
|
|
344
344
|
children: /* @__PURE__ */ a(
|
|
345
345
|
V,
|
|
346
346
|
{
|
|
347
347
|
locale: l,
|
|
348
348
|
photoSources: r,
|
|
349
|
-
errors:
|
|
349
|
+
errors: x,
|
|
350
350
|
onCloseDialogHandler: e,
|
|
351
351
|
onClearErrors: v
|
|
352
352
|
}
|
|
353
353
|
)
|
|
354
354
|
}
|
|
355
355
|
) : /* @__PURE__ */ L(
|
|
356
|
-
|
|
356
|
+
O,
|
|
357
357
|
{
|
|
358
358
|
className: i(n.dialog, d),
|
|
359
359
|
onClose: e,
|
|
360
|
-
...
|
|
360
|
+
...T,
|
|
361
361
|
children: [
|
|
362
|
-
/* @__PURE__ */ a(
|
|
362
|
+
/* @__PURE__ */ a(E, { className: i(n.topActions), children: /* @__PURE__ */ a(
|
|
363
363
|
j,
|
|
364
364
|
{
|
|
365
365
|
onClick: e,
|
|
@@ -406,10 +406,10 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
406
406
|
),
|
|
407
407
|
S && /* @__PURE__ */ a(H, { photoSources: r, photoIndex: C })
|
|
408
408
|
] }),
|
|
409
|
-
u && /* @__PURE__ */ a(
|
|
410
|
-
/* @__PURE__ */ a(
|
|
409
|
+
u && /* @__PURE__ */ a(E, { className: i(n.dialogText), children: u }),
|
|
410
|
+
/* @__PURE__ */ a(E, { className: i(n.botActions), children: S ? /* @__PURE__ */ L(_, { children: [
|
|
411
411
|
/* @__PURE__ */ a(
|
|
412
|
-
|
|
412
|
+
P,
|
|
413
413
|
{
|
|
414
414
|
buttonSize: "small",
|
|
415
415
|
buttonColor: "blue",
|
|
@@ -421,7 +421,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
421
421
|
}
|
|
422
422
|
),
|
|
423
423
|
/* @__PURE__ */ a(
|
|
424
|
-
|
|
424
|
+
P,
|
|
425
425
|
{
|
|
426
426
|
buttonSize: "small",
|
|
427
427
|
buttonColor: "blue",
|
|
@@ -433,7 +433,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
433
433
|
}
|
|
434
434
|
)
|
|
435
435
|
] }) : /* @__PURE__ */ a(
|
|
436
|
-
|
|
436
|
+
P,
|
|
437
437
|
{
|
|
438
438
|
minWidth: "100%",
|
|
439
439
|
buttonSize: "small",
|
|
@@ -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";
|
|
@@ -36,6 +37,7 @@ export declare const MIME_TO_EXT: {
|
|
|
36
37
|
};
|
|
37
38
|
export declare const DEFAULT_TIMEOUT = 500;
|
|
38
39
|
export declare const DEFAULT_FILE_MAX_SIZE: number;
|
|
40
|
+
export declare const DEFAULT_VIDEO_FILE_MAX_SIZE: number;
|
|
39
41
|
export declare const PHOTO_CANVAS_CONTEXT = "2d";
|
|
40
42
|
export declare const PHOTO_SMOOTHING_QUALITY = "high";
|
|
41
43
|
export declare const PRECENT_UNIT = "%";
|
|
@@ -1,74 +1,76 @@
|
|
|
1
|
-
import { BYTE_TO_KILOBYTE as
|
|
2
|
-
const
|
|
3
|
-
E,
|
|
1
|
+
import { BYTE_TO_KILOBYTE as E } from "../../constants.js";
|
|
2
|
+
const D = 1, i = 670, L = 90, _ = ".jpg", I = ".jpeg", A = ".png", o = ".svg", M = ".bmp", P = ".gif", T = ".ico", n = ".webp", e = [
|
|
4
3
|
_,
|
|
5
|
-
|
|
4
|
+
I,
|
|
5
|
+
A,
|
|
6
6
|
o,
|
|
7
7
|
M,
|
|
8
|
-
|
|
9
|
-
G,
|
|
10
|
-
T
|
|
11
|
-
], n = "image/jpg", c = "image/jpeg", s = "image/png", t = "image/svg+xml", O = "image/bmp", Y = "image/gif", S = "image/webp", m = "image/x-icon", g = "image/vnd.microsoft.icon", L = ".mp4", X = ".webm", p = "video/mp4", C = "video/webm", U = [
|
|
8
|
+
P,
|
|
12
9
|
n,
|
|
10
|
+
T
|
|
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
|
-
],
|
|
22
|
-
JPEG_IMAGE_TYPE: [
|
|
23
|
-
JPG_IMAGE_TYPE: [
|
|
24
|
-
PNG_IMAGE_TYPE: [
|
|
25
|
-
GIF_IMAGE_TYPE: [
|
|
20
|
+
N
|
|
21
|
+
], B = {
|
|
22
|
+
JPEG_IMAGE_TYPE: [_, I],
|
|
23
|
+
JPG_IMAGE_TYPE: [_, I],
|
|
24
|
+
PNG_IMAGE_TYPE: [A],
|
|
25
|
+
GIF_IMAGE_TYPE: [P],
|
|
26
26
|
SVG_IMAGE_TYPE: [o],
|
|
27
27
|
BMP_IMAGE_TYPE: [M],
|
|
28
|
-
WEBP_IMAGE_TYPE: [
|
|
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
|
-
|
|
42
|
-
|
|
40
|
+
a as DEFAULT_VIDEO_FILE_MAX_SIZE,
|
|
41
|
+
r as FULL_CROP_SIZE,
|
|
42
|
+
H as FULL_PROGRESS_VALUE,
|
|
43
|
+
P as GIF_IMAGE_EXT,
|
|
44
|
+
S as GIF_IMAGE_TYPE,
|
|
43
45
|
T as ICO_IMAGE_EXT,
|
|
44
46
|
m as ICO_IMAGE_TYPE,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
I as JPEG_IMAGE_EXT,
|
|
48
|
+
s as JPEG_IMAGE_TYPE,
|
|
49
|
+
_ as JPG_IMAGE_EXT,
|
|
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,
|
|
69
|
+
C as SUPPORTED_IMAGE_MIME_TYPES,
|
|
68
70
|
o as SVG_IMAGE_EXT,
|
|
69
71
|
t as SVG_IMAGE_TYPE,
|
|
70
72
|
X as WEBM_VIDEO_EXT,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
p as WEBM_VIDEO_TYPE,
|
|
74
|
+
n as WEBP_IMAGE_EXT,
|
|
75
|
+
Y as WEBP_IMAGE_TYPE
|
|
74
76
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
en: {
|
|
3
|
-
upload: "Upload a
|
|
3
|
+
upload: "Upload a file",
|
|
4
4
|
drop: "Drop the file here",
|
|
5
5
|
"photo-crop": "Select the display area",
|
|
6
6
|
crop: "Save",
|
|
@@ -10,7 +10,8 @@ const e = {
|
|
|
10
10
|
"canvas-error": "Canvas context not found",
|
|
11
11
|
error: "Error",
|
|
12
12
|
"large-file": "The file is too large",
|
|
13
|
-
"maximum-size": "Maximum size",
|
|
13
|
+
"maximum-size": "Maximum size for a photo is",
|
|
14
|
+
"video-maximum-size": "Maximum size for a video is",
|
|
14
15
|
"file-ext-error": "Unsupported file extension",
|
|
15
16
|
"file-type-error": "Unsupported file type",
|
|
16
17
|
"mime-type": "MIME Type",
|
|
@@ -23,11 +24,11 @@ const e = {
|
|
|
23
24
|
skip: "Skip area selection",
|
|
24
25
|
aspect: "The aspect ratio of the cropped image must not be greater than 2",
|
|
25
26
|
close: "Close",
|
|
26
|
-
"not-uploaded": "
|
|
27
|
-
"some-not-uploaded": "Some
|
|
27
|
+
"not-uploaded": "Files were not uploaded",
|
|
28
|
+
"some-not-uploaded": "Some files were not uploaded"
|
|
28
29
|
},
|
|
29
30
|
ru: {
|
|
30
|
-
upload: "Загрузить
|
|
31
|
+
upload: "Загрузить файл",
|
|
31
32
|
drop: "Отпустите файл здесь",
|
|
32
33
|
"photo-crop": "Выберите отображаемую область",
|
|
33
34
|
crop: "Сохранить",
|
|
@@ -37,7 +38,8 @@ const e = {
|
|
|
37
38
|
"canvas-error": "Контекст канваса не найден",
|
|
38
39
|
error: "Ошибка",
|
|
39
40
|
"large-file": "Файл слишком большой",
|
|
40
|
-
"maximum-size": "Максимальный размер",
|
|
41
|
+
"maximum-size": "Максимальный размер для фотографии",
|
|
42
|
+
"video-maximum-size": "Максимальный размер для видео",
|
|
41
43
|
"file-ext-error": "Неподдерживаемое расширение файла",
|
|
42
44
|
"file-type-error": "Неподдерживаемый тип файла",
|
|
43
45
|
"mime-type": "MIME тип",
|
|
@@ -50,8 +52,8 @@ const e = {
|
|
|
50
52
|
skip: "Пропустить выбор области",
|
|
51
53
|
aspect: "Соотношение сторон обрезаемого изображения не должно быть больше 2",
|
|
52
54
|
close: "Закрыть",
|
|
53
|
-
"not-uploaded": "
|
|
54
|
-
"some-not-uploaded": "Некоторые
|
|
55
|
+
"not-uploaded": "Файлы не были загружены",
|
|
56
|
+
"some-not-uploaded": "Некоторые файлы не были загружены"
|
|
55
57
|
}
|
|
56
58
|
};
|
|
57
59
|
export {
|
|
@@ -1,295 +1,322 @@
|
|
|
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
|
|
11
|
-
import { isVideo as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
|
|
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
|
+
import { isVideo as $ } from "./utils/is-video.js";
|
|
12
|
+
import { validateVideoFile as oo } from "./utils/validate-video-file.js";
|
|
13
|
+
import { validatePhotoFile as eo } from "./utils/validate-photo-file.js";
|
|
14
|
+
import { readPhoto as to } from "./utils/read-photo.js";
|
|
15
|
+
import { getPhotoCrop as $o } from "./utils/get-photo-crop.js";
|
|
16
|
+
import { getCroppedSource as oe } from "./utils/get-cropped-source.js";
|
|
17
|
+
import { getDefaultCroppedPhoto as ro } from "./utils/get-default-cropped-photo.js";
|
|
18
|
+
import '../../assets/photo-crop-uploader.css';const ee = "_photoCropCanvas_1i4lr_1", te = {
|
|
19
|
+
photoCropCanvas: ee
|
|
19
20
|
};
|
|
20
|
-
function
|
|
21
|
+
function Le(a) {
|
|
21
22
|
const {
|
|
22
|
-
buttonClassname:
|
|
23
|
-
onStartUpload:
|
|
23
|
+
buttonClassname: no = "",
|
|
24
|
+
onStartUpload: so = () => {
|
|
24
25
|
},
|
|
25
|
-
onEndUpload:
|
|
26
|
+
onEndUpload: ao = () => {
|
|
26
27
|
},
|
|
27
|
-
onError:
|
|
28
|
+
onError: io = () => {
|
|
28
29
|
},
|
|
29
|
-
onStartCrop:
|
|
30
|
+
onStartCrop: lo = () => {
|
|
30
31
|
},
|
|
31
|
-
onDragOver:
|
|
32
|
+
onDragOver: co = () => {
|
|
32
33
|
},
|
|
33
|
-
onDragLeave:
|
|
34
|
+
onDragLeave: po = () => {
|
|
34
35
|
},
|
|
35
|
-
onDragDrop:
|
|
36
|
+
onDragDrop: uo = () => {
|
|
36
37
|
},
|
|
37
|
-
showErrorPopup:
|
|
38
|
-
minDimension:
|
|
39
|
-
aspectRatio: C =
|
|
40
|
-
locale:
|
|
41
|
-
timeout:
|
|
42
|
-
fileMaxSize:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
showErrorPopup: fo = !1,
|
|
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
|
+
circular: ho,
|
|
48
|
+
usePercentCrop: mo = !0,
|
|
49
|
+
width: Co,
|
|
50
|
+
keepSelection: go,
|
|
51
|
+
uploadButton: Eo,
|
|
49
52
|
multiple: g = !1,
|
|
50
|
-
fromSources:
|
|
51
|
-
withVideoUploaded:
|
|
52
|
-
returnCropParams:
|
|
53
|
-
dialogClassname:
|
|
54
|
-
|
|
53
|
+
fromSources: b,
|
|
54
|
+
withVideoUploaded: v = !1,
|
|
55
|
+
returnCropParams: Po = !1,
|
|
56
|
+
dialogClassname: k,
|
|
57
|
+
defaultDimension: Do = Zo,
|
|
58
|
+
...So
|
|
55
59
|
} = a, {
|
|
56
|
-
onEndCrop:
|
|
57
|
-
onClose:
|
|
58
|
-
...
|
|
59
|
-
} =
|
|
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 = () => {
|
|
60
64
|
S([]);
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
}, F = (e = []) => {
|
|
66
|
+
c || (a.returnCropParams === !0 && a.onClose?.(
|
|
67
|
+
e,
|
|
64
68
|
f.current,
|
|
65
69
|
h.current
|
|
66
|
-
), E(!1), setTimeout(() => S([]),
|
|
70
|
+
), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
|
|
67
71
|
f.current = [], h.current = [];
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
}, d));
|
|
73
|
+
}, R = (e = []) => {
|
|
74
|
+
c || (a.returnCropParams || a.onClose?.(
|
|
75
|
+
e,
|
|
72
76
|
f.current,
|
|
73
77
|
h.current
|
|
74
|
-
), E(!1), setTimeout(() => S([]),
|
|
78
|
+
), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
|
|
75
79
|
f.current = [], h.current = [];
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
+
}, d));
|
|
81
|
+
}, Z = () => {
|
|
82
|
+
c || (a.returnCropParams === !0 ? F([]) : R([]));
|
|
83
|
+
}, Io = () => {
|
|
80
84
|
Y(!1);
|
|
81
|
-
}, L = (
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
const { files:
|
|
87
|
-
if (
|
|
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;
|
|
91
|
+
if (t?.length && !c)
|
|
88
92
|
try {
|
|
89
|
-
if (O(!0),
|
|
90
|
-
const
|
|
91
|
-
for (const
|
|
92
|
-
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);
|
|
93
97
|
try {
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
if (v && Mo) {
|
|
99
|
+
oo(m, H, n);
|
|
100
|
+
const s = URL.createObjectURL(m);
|
|
101
|
+
J.push(u.length), u.push(s);
|
|
97
102
|
} else {
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
eo(
|
|
104
|
+
m,
|
|
100
105
|
{
|
|
101
|
-
maxSize:
|
|
102
|
-
allowedExtensions:
|
|
103
|
-
allowedMimeTypes:
|
|
106
|
+
maxSize: N,
|
|
107
|
+
allowedExtensions: w,
|
|
108
|
+
allowedMimeTypes: V
|
|
104
109
|
},
|
|
105
|
-
|
|
110
|
+
n
|
|
106
111
|
);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
const s = await to(
|
|
113
|
+
m,
|
|
114
|
+
l,
|
|
115
|
+
n,
|
|
116
|
+
M
|
|
112
117
|
);
|
|
113
|
-
|
|
118
|
+
_.push(s), u.push(s);
|
|
114
119
|
}
|
|
115
|
-
} catch (
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
photoName:
|
|
119
|
-
errorMessage:
|
|
120
|
+
} catch (s) {
|
|
121
|
+
let K = "";
|
|
122
|
+
s instanceof Error && (K = s.message), T.push({
|
|
123
|
+
photoName: m.name,
|
|
124
|
+
errorMessage: K
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
), await new Promise((
|
|
127
|
+
B(
|
|
128
|
+
(s) => Math.min(Q, s + r)
|
|
129
|
+
), await new Promise((s) => setTimeout(s, 0));
|
|
125
130
|
}
|
|
126
|
-
if (
|
|
127
|
-
throw new Error(
|
|
128
|
-
S(
|
|
131
|
+
if (b?.length)
|
|
132
|
+
throw new Error(T[0]?.errorMessage);
|
|
133
|
+
S(T), L(_, u, J, T.length > 0);
|
|
129
134
|
} else {
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
const o = t[0];
|
|
136
|
+
if (v && $(o)) {
|
|
137
|
+
oo(o, H, n);
|
|
138
|
+
const r = URL.createObjectURL(o);
|
|
139
|
+
L([], [r], [0]);
|
|
134
140
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{ maxSize:
|
|
138
|
-
|
|
141
|
+
eo(
|
|
142
|
+
o,
|
|
143
|
+
{ maxSize: N, allowedExtensions: w, allowedMimeTypes: V },
|
|
144
|
+
n
|
|
139
145
|
);
|
|
140
|
-
const
|
|
141
|
-
L([
|
|
146
|
+
const r = await to(o, l, n, M);
|
|
147
|
+
L([r]);
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
|
-
} catch (
|
|
145
|
-
|
|
150
|
+
} catch (o) {
|
|
151
|
+
y(o);
|
|
146
152
|
} finally {
|
|
147
153
|
g ? setTimeout(() => {
|
|
148
|
-
|
|
149
|
-
},
|
|
154
|
+
e.target.value = "", B(0), O(!1);
|
|
155
|
+
}, qo) : (e.target.value = "", O(!1));
|
|
150
156
|
}
|
|
151
|
-
},
|
|
152
|
-
const { width:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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((_) => {
|
|
167
|
+
const u = [..._];
|
|
168
|
+
return u[p] = r, u;
|
|
156
169
|
});
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
return
|
|
170
|
+
}, Fo = (e, t) => {
|
|
171
|
+
x((o) => {
|
|
172
|
+
const r = [...o];
|
|
173
|
+
return r[p] = t, r;
|
|
161
174
|
});
|
|
162
|
-
},
|
|
163
|
-
const
|
|
164
|
-
if (
|
|
175
|
+
}, q = () => {
|
|
176
|
+
const e = W.current, t = j.current;
|
|
177
|
+
if (e && t && I)
|
|
165
178
|
try {
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
179
|
+
const o = I[p];
|
|
180
|
+
if (!o) return !1;
|
|
181
|
+
if (lo(), a.returnCropParams === !0) {
|
|
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();
|
|
171
198
|
} else {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
o,
|
|
199
|
+
const r = oe(
|
|
200
|
+
t,
|
|
175
201
|
e,
|
|
176
|
-
|
|
202
|
+
o,
|
|
203
|
+
n
|
|
177
204
|
);
|
|
178
|
-
a.onEndCrop?.(
|
|
205
|
+
a.onEndCrop?.(r), p >= P.length - 1 && R();
|
|
179
206
|
}
|
|
180
207
|
return !0;
|
|
181
|
-
} catch (
|
|
182
|
-
return
|
|
208
|
+
} catch (o) {
|
|
209
|
+
return o instanceof Error && (console.warn(o), y(o)), !1;
|
|
183
210
|
}
|
|
184
211
|
else
|
|
185
212
|
return !1;
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
const
|
|
213
|
+
}, Ro = () => {
|
|
214
|
+
q() && z((t) => t + 1);
|
|
215
|
+
}, yo = async () => {
|
|
216
|
+
const e = P.slice(p);
|
|
190
217
|
try {
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
(
|
|
195
|
-
|
|
196
|
-
|
|
218
|
+
if (Po) {
|
|
219
|
+
const t = await Promise.all(
|
|
220
|
+
e.map(
|
|
221
|
+
(o) => ro(
|
|
222
|
+
o,
|
|
223
|
+
l,
|
|
197
224
|
C,
|
|
198
|
-
|
|
225
|
+
n,
|
|
199
226
|
!0
|
|
200
227
|
)
|
|
201
228
|
)
|
|
202
229
|
);
|
|
203
|
-
|
|
230
|
+
F(t);
|
|
204
231
|
} else {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
(
|
|
208
|
-
|
|
209
|
-
|
|
232
|
+
const t = await Promise.all(
|
|
233
|
+
e.map(
|
|
234
|
+
(o) => ro(
|
|
235
|
+
o,
|
|
236
|
+
l,
|
|
210
237
|
C,
|
|
211
|
-
|
|
238
|
+
n,
|
|
212
239
|
!1
|
|
213
240
|
)
|
|
214
241
|
)
|
|
215
242
|
);
|
|
216
|
-
|
|
243
|
+
R(t);
|
|
217
244
|
}
|
|
218
|
-
} catch (
|
|
219
|
-
|
|
245
|
+
} catch (t) {
|
|
246
|
+
y(t);
|
|
220
247
|
}
|
|
221
248
|
};
|
|
222
|
-
return /* @__PURE__ */
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
-
|
|
249
|
+
return /* @__PURE__ */ No(Ho, { children: [
|
|
250
|
+
/* @__PURE__ */ U(
|
|
251
|
+
Ko,
|
|
225
252
|
{
|
|
226
|
-
onChange:
|
|
253
|
+
onChange: xo,
|
|
227
254
|
onPhotoDataLoaded: L,
|
|
228
|
-
buttonClassname:
|
|
229
|
-
disabled:
|
|
230
|
-
buttonDisabled:
|
|
231
|
-
locale:
|
|
232
|
-
width:
|
|
233
|
-
allowedExtensions:
|
|
234
|
-
onDragDrop:
|
|
235
|
-
onDragLeave:
|
|
236
|
-
onDragOver:
|
|
237
|
-
button:
|
|
255
|
+
buttonClassname: no,
|
|
256
|
+
disabled: c,
|
|
257
|
+
buttonDisabled: c,
|
|
258
|
+
locale: n,
|
|
259
|
+
width: Co,
|
|
260
|
+
allowedExtensions: w,
|
|
261
|
+
onDragDrop: uo,
|
|
262
|
+
onDragLeave: po,
|
|
263
|
+
onDragOver: co,
|
|
264
|
+
button: Eo,
|
|
238
265
|
multiple: g,
|
|
239
|
-
fromSources:
|
|
240
|
-
withVideoUploaded:
|
|
241
|
-
...
|
|
242
|
-
children:
|
|
266
|
+
fromSources: b,
|
|
267
|
+
withVideoUploaded: v,
|
|
268
|
+
...Lo,
|
|
269
|
+
children: zo[n].upload
|
|
243
270
|
}
|
|
244
271
|
),
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
|
|
272
|
+
/* @__PURE__ */ U(
|
|
273
|
+
Jo,
|
|
247
274
|
{
|
|
248
|
-
open:
|
|
249
|
-
className:
|
|
250
|
-
photoSourceLoading:
|
|
251
|
-
loadingValue:
|
|
252
|
-
errors:
|
|
253
|
-
photoCrops:
|
|
275
|
+
open: wo,
|
|
276
|
+
className: k,
|
|
277
|
+
photoSourceLoading: c,
|
|
278
|
+
loadingValue: To,
|
|
279
|
+
errors: Uo,
|
|
280
|
+
photoCrops: I,
|
|
254
281
|
photoSources: P,
|
|
255
|
-
onNextPhoto:
|
|
256
|
-
onSkipCrop:
|
|
257
|
-
onClearErrors:
|
|
258
|
-
photoError:
|
|
259
|
-
onCloseDialogHandler:
|
|
260
|
-
onCropChange:
|
|
261
|
-
onPhotoCrop:
|
|
262
|
-
onPhotoLoad:
|
|
282
|
+
onNextPhoto: Ro,
|
|
283
|
+
onSkipCrop: yo,
|
|
284
|
+
onClearErrors: vo,
|
|
285
|
+
photoError: G,
|
|
286
|
+
onCloseDialogHandler: Z,
|
|
287
|
+
onCropChange: Fo,
|
|
288
|
+
onPhotoCrop: q,
|
|
289
|
+
onPhotoLoad: Oo,
|
|
263
290
|
imageRef: j,
|
|
264
|
-
minDimension:
|
|
291
|
+
minDimension: l,
|
|
265
292
|
aspectRatio: C,
|
|
266
|
-
locale:
|
|
267
|
-
circular:
|
|
268
|
-
keepSelection:
|
|
293
|
+
locale: n,
|
|
294
|
+
circular: ho,
|
|
295
|
+
keepSelection: go,
|
|
269
296
|
photoIndex: p
|
|
270
297
|
}
|
|
271
298
|
),
|
|
272
|
-
/* @__PURE__ */
|
|
273
|
-
|
|
299
|
+
/* @__PURE__ */ U(
|
|
300
|
+
Qo,
|
|
274
301
|
{
|
|
275
|
-
className:
|
|
276
|
-
open:
|
|
277
|
-
photoError:
|
|
278
|
-
onCloseErrorDialog:
|
|
279
|
-
locale:
|
|
302
|
+
className: k,
|
|
303
|
+
open: fo && Ao,
|
|
304
|
+
photoError: G,
|
|
305
|
+
onCloseErrorDialog: Io,
|
|
306
|
+
locale: n
|
|
280
307
|
}
|
|
281
308
|
),
|
|
282
|
-
/* @__PURE__ */
|
|
309
|
+
/* @__PURE__ */ U(
|
|
283
310
|
"canvas",
|
|
284
311
|
{
|
|
285
|
-
className:
|
|
286
|
-
width:
|
|
287
|
-
height:
|
|
288
|
-
ref:
|
|
312
|
+
className: ko(te.photoCropCanvas),
|
|
313
|
+
width: l,
|
|
314
|
+
height: l,
|
|
315
|
+
ref: W
|
|
289
316
|
}
|
|
290
317
|
)
|
|
291
318
|
] });
|
|
292
319
|
}
|
|
293
320
|
export {
|
|
294
|
-
|
|
321
|
+
Le as PhotoCropUploader
|
|
295
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,10 +37,13 @@ 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;
|
|
46
|
+
videoFileMaxSize?: number;
|
|
44
47
|
allowedExtensions?: PhotoExtension[];
|
|
45
48
|
allowedMimeTypes?: PhotoMimeType[];
|
|
46
49
|
circular?: boolean;
|
|
@@ -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
|
};
|
|
@@ -5,3 +5,4 @@ export { validatePhotoFile } from './validate-photo-file';
|
|
|
5
5
|
export { getDefaultCroppedPhoto } from './get-default-cropped-photo';
|
|
6
6
|
export { drawCroppedImage } from './draw-cropped-image';
|
|
7
7
|
export { isVideo } from './is-video';
|
|
8
|
+
export { validateVideoFile } from './validate-video-file';
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { readPhoto as
|
|
1
|
+
import { readPhoto as r } from "./read-photo.js";
|
|
2
2
|
import { getPhotoCrop as p } from "./get-photo-crop.js";
|
|
3
|
-
import { getCroppedSource as
|
|
4
|
-
import { validatePhotoFile as
|
|
5
|
-
import { getDefaultCroppedPhoto as
|
|
6
|
-
import { drawCroppedImage as
|
|
7
|
-
import { isVideo as
|
|
3
|
+
import { getCroppedSource as f } from "./get-cropped-source.js";
|
|
4
|
+
import { validatePhotoFile as a } from "./validate-photo-file.js";
|
|
5
|
+
import { getDefaultCroppedPhoto as i } from "./get-default-cropped-photo.js";
|
|
6
|
+
import { drawCroppedImage as g } from "./draw-cropped-image.js";
|
|
7
|
+
import { isVideo as C } from "./is-video.js";
|
|
8
|
+
import { validateVideoFile as u } from "./validate-video-file.js";
|
|
8
9
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
g as drawCroppedImage,
|
|
11
|
+
f as getCroppedSource,
|
|
12
|
+
i as getDefaultCroppedPhoto,
|
|
12
13
|
p as getPhotoCrop,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
C as isVideo,
|
|
15
|
+
r as readPhoto,
|
|
16
|
+
a as validatePhotoFile,
|
|
17
|
+
u as validateVideoFile
|
|
16
18
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { localizedText as t } from "../locale.js";
|
|
2
|
+
import { EN_LOCALE as f, BYTE_TO_KILOBYTE as e } from "../../../constants.js";
|
|
3
|
+
import { MB_UNIT as T, MB_FRACTION_DIGITS as l } from "../constants.js";
|
|
4
|
+
import { PhotoFileError as p } from "../errors/photo-file.error.js";
|
|
5
|
+
const I = (m, o, i = f) => {
|
|
6
|
+
const r = [];
|
|
7
|
+
if (o && m.size > o && r.push(
|
|
8
|
+
`${t[i]["large-file"]}. ${t[i]["video-maximum-size"]}: ${(o / e / e).toFixed(
|
|
9
|
+
l
|
|
10
|
+
)}${T}`
|
|
11
|
+
), r.length)
|
|
12
|
+
throw p.get(r);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
I as validateVideoFile
|
|
16
|
+
};
|