@hai-dev/ui-kit 1.1.1 → 1.1.4
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-button/types.d.ts +1 -0
- package/dist/components/photo-crop-uploader/components/upload-button/upload-button.js +69 -68
- package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog.js +25 -25
- package/dist/components/photo-crop-uploader/constants.d.ts +4 -0
- package/dist/components/photo-crop-uploader/constants.js +47 -43
- package/dist/components/photo-crop-uploader/photo-crop-uploader.js +227 -198
- package/dist/components/photo-crop-uploader/types.d.ts +3 -2
- package/dist/components/photo-crop-uploader/utils/index.d.ts +1 -0
- package/dist/components/photo-crop-uploader/utils/index.js +6 -4
- package/dist/components/photo-crop-uploader/utils/is-video.d.ts +1 -0
- package/dist/components/photo-crop-uploader/utils/is-video.js +8 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ type UploadButtonCustonProps = {
|
|
|
13
13
|
onDragLeave?: (event: DragEvent<HTMLDivElement>) => unknown;
|
|
14
14
|
onDragDrop?: (event: DragEvent<HTMLDivElement>) => unknown;
|
|
15
15
|
button?: ReactNode;
|
|
16
|
+
withVideoUploaded?: boolean;
|
|
16
17
|
};
|
|
17
18
|
export type UploadButtonProps = InputHTMLAttributes<HTMLInputElement> & UploadButtonCustonProps;
|
|
18
19
|
export {};
|
|
@@ -1,113 +1,114 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { c as
|
|
4
|
-
import { localizedText as
|
|
5
|
-
import { EN_LOCALE as
|
|
6
|
-
import { SUPPORTED_IMAGE_EXTENSIONS as
|
|
7
|
-
import { UPLOAD_BUTTON_WIDTH_DEFAULT as
|
|
8
|
-
import { B as
|
|
9
|
-
import '../../../../assets/upload-button.css';const
|
|
10
|
-
dragDropWrapper:
|
|
11
|
-
input:
|
|
12
|
-
},
|
|
1
|
+
import { jsx as r, jsxs as E, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { useState as R, useRef as W } from "react";
|
|
3
|
+
import { c as n } from "../../../../index-B2JRaoNz.js";
|
|
4
|
+
import { localizedText as T } from "../../locale.js";
|
|
5
|
+
import { EN_LOCALE as y } from "../../../../constants.js";
|
|
6
|
+
import { SUPPORTED_IMAGE_EXTENSIONS as M, MP4_VIDEO_EXT as j, WEBM_VIDEO_EXT as H } from "../../constants.js";
|
|
7
|
+
import { UPLOAD_BUTTON_WIDTH_DEFAULT as X, UPLOAD_BUTTON_TAB_INDEX as F, UPLOAD_BUTTON_IMAGE_SIZE as x } from "./constants.js";
|
|
8
|
+
import { B as z } from "../../../../Button-CcvrOEKV.js";
|
|
9
|
+
import '../../../../assets/upload-button.css';const Y = "data:image/svg+xml,%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Transformed%20by:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%201024%201024'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23000000'%3e%3cg%20id='SVGRepo_bgCarrier'%20stroke-width='0'/%3e%3cg%20id='SVGRepo_tracerCarrier'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cg%20id='SVGRepo_iconCarrier'%3e%3cpath%20fill='%23ffffff'%20d='M544%20864V672h128L512%20480%20352%20672h128v192H320v-1.6c-5.376.32-10.496%201.6-16%201.6A240%20240%200%200%201%2064%20624c0-123.136%2093.12-223.488%20212.608-237.248A239.808%20239.808%200%200%201%20512%20192a239.872%20239.872%200%200%201%20235.456%20194.752c119.488%2013.76%20212.48%20114.112%20212.48%20237.248a240%20240%200%200%201-240%20240c-5.376%200-10.56-1.28-16-1.6v1.6H544z'/%3e%3c/g%3e%3c/svg%3e", Z = "_dragDropWrapper_cgx9x_1", q = "_input_cgx9x_4", a = {
|
|
10
|
+
dragDropWrapper: Z,
|
|
11
|
+
input: q
|
|
12
|
+
}, ne = (w) => {
|
|
13
13
|
const {
|
|
14
|
-
buttonClassname:
|
|
15
|
-
buttonDisabled:
|
|
16
|
-
children:
|
|
14
|
+
buttonClassname: O,
|
|
15
|
+
buttonDisabled: o = !1,
|
|
16
|
+
children: C,
|
|
17
17
|
className: p,
|
|
18
|
-
onChange:
|
|
19
|
-
locale:
|
|
20
|
-
width:
|
|
21
|
-
allowedExtensions:
|
|
18
|
+
onChange: c,
|
|
19
|
+
locale: d = y,
|
|
20
|
+
width: I = X,
|
|
21
|
+
allowedExtensions: g = M,
|
|
22
22
|
onDragOver: N = () => {
|
|
23
23
|
},
|
|
24
|
-
onDragLeave:
|
|
24
|
+
onDragLeave: P = () => {
|
|
25
25
|
},
|
|
26
|
-
onDragDrop:
|
|
26
|
+
onDragDrop: S = () => {
|
|
27
27
|
},
|
|
28
|
-
button:
|
|
28
|
+
button: i,
|
|
29
29
|
multiple: f,
|
|
30
30
|
onPhotoDataLoaded: L = () => {
|
|
31
31
|
},
|
|
32
32
|
fromSources: t,
|
|
33
|
+
withVideoUploaded: U = !1,
|
|
33
34
|
...u
|
|
34
|
-
} = w, [
|
|
35
|
-
|
|
35
|
+
} = w, [B, s] = R(!1), l = W(null), h = U ? [...g, j, H] : g, D = (e) => {
|
|
36
|
+
o || e && e.length > 0 && c && c({
|
|
36
37
|
target: {
|
|
37
38
|
files: e,
|
|
38
39
|
value: ""
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
|
-
},
|
|
42
|
-
t?.length || (e.preventDefault(), e.stopPropagation(), N(e),
|
|
42
|
+
}, V = (e) => {
|
|
43
|
+
t?.length || (e.preventDefault(), e.stopPropagation(), N(e), o || s(!0));
|
|
43
44
|
}, A = (e) => {
|
|
44
|
-
t?.length || (e.preventDefault(), e.stopPropagation(),
|
|
45
|
-
},
|
|
46
|
-
if (t?.length || (e.preventDefault(), e.stopPropagation(),
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
t?.length ? L(t) :
|
|
51
|
-
}, D = (e) => {
|
|
52
|
-
t?.length && e.preventDefault();
|
|
45
|
+
t?.length || (e.preventDefault(), e.stopPropagation(), P(e), s(!1));
|
|
46
|
+
}, G = (e) => {
|
|
47
|
+
if (t?.length || (e.preventDefault(), e.stopPropagation(), S(e), s(!1), o)) return;
|
|
48
|
+
const v = e.dataTransfer?.files;
|
|
49
|
+
D(v);
|
|
50
|
+
}, b = () => {
|
|
51
|
+
t?.length ? L(t) : i && l.current?.click();
|
|
53
52
|
}, m = (e) => {
|
|
54
|
-
|
|
53
|
+
t?.length && e.preventDefault();
|
|
54
|
+
}, _ = (e) => {
|
|
55
|
+
D(e.target.files), e.target.value = "";
|
|
55
56
|
};
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ r(
|
|
57
58
|
"div",
|
|
58
59
|
{
|
|
59
|
-
className: a
|
|
60
|
-
onDragOver:
|
|
60
|
+
className: n(a.dragDropWrapper),
|
|
61
|
+
onDragOver: V,
|
|
61
62
|
onDragLeave: A,
|
|
62
|
-
onDrop:
|
|
63
|
-
onClick:
|
|
64
|
-
children:
|
|
65
|
-
|
|
66
|
-
/* @__PURE__ */
|
|
63
|
+
onDrop: G,
|
|
64
|
+
onClick: b,
|
|
65
|
+
children: i ? /* @__PURE__ */ E(k, { children: [
|
|
66
|
+
i,
|
|
67
|
+
/* @__PURE__ */ r(
|
|
67
68
|
"input",
|
|
68
69
|
{
|
|
69
|
-
onClick:
|
|
70
|
-
ref:
|
|
71
|
-
className: a
|
|
70
|
+
onClick: m,
|
|
71
|
+
ref: l,
|
|
72
|
+
className: n(a.input, p),
|
|
72
73
|
type: "file",
|
|
73
|
-
accept:
|
|
74
|
-
onChange:
|
|
74
|
+
accept: h.join(", "),
|
|
75
|
+
onChange: _,
|
|
75
76
|
multiple: f,
|
|
76
77
|
...u
|
|
77
78
|
}
|
|
78
79
|
)
|
|
79
|
-
] }) : /* @__PURE__ */
|
|
80
|
-
|
|
80
|
+
] }) : /* @__PURE__ */ E(
|
|
81
|
+
z,
|
|
81
82
|
{
|
|
82
83
|
component: "label",
|
|
83
84
|
sx: {
|
|
84
|
-
width:
|
|
85
|
+
width: I
|
|
85
86
|
},
|
|
86
87
|
role: "none",
|
|
87
88
|
variant: "contained",
|
|
88
|
-
disabled:
|
|
89
|
-
tabIndex:
|
|
90
|
-
className: a
|
|
91
|
-
startIcon: /* @__PURE__ */
|
|
89
|
+
disabled: o,
|
|
90
|
+
tabIndex: F,
|
|
91
|
+
className: n(a.uploadButton, O),
|
|
92
|
+
startIcon: /* @__PURE__ */ r(
|
|
92
93
|
"img",
|
|
93
94
|
{
|
|
94
|
-
width:
|
|
95
|
-
height:
|
|
96
|
-
src:
|
|
97
|
-
alt:
|
|
95
|
+
width: x,
|
|
96
|
+
height: x,
|
|
97
|
+
src: Y,
|
|
98
|
+
alt: T[d].upload
|
|
98
99
|
}
|
|
99
100
|
),
|
|
100
101
|
children: [
|
|
101
|
-
|
|
102
|
-
/* @__PURE__ */
|
|
102
|
+
B ? T[d].drop : C,
|
|
103
|
+
/* @__PURE__ */ r(
|
|
103
104
|
"input",
|
|
104
105
|
{
|
|
105
|
-
onClick:
|
|
106
|
-
ref:
|
|
107
|
-
className: a
|
|
106
|
+
onClick: m,
|
|
107
|
+
ref: l,
|
|
108
|
+
className: n(a.input, p),
|
|
108
109
|
type: "file",
|
|
109
|
-
accept:
|
|
110
|
-
onChange:
|
|
110
|
+
accept: h.join(", "),
|
|
111
|
+
onChange: _,
|
|
111
112
|
multiple: f,
|
|
112
113
|
...u
|
|
113
114
|
}
|
|
@@ -119,5 +120,5 @@ import '../../../../assets/upload-button.css';const M = "data:image/svg+xml,%3c!
|
|
|
119
120
|
);
|
|
120
121
|
};
|
|
121
122
|
export {
|
|
122
|
-
|
|
123
|
+
ne as UploadButton
|
|
123
124
|
};
|
|
@@ -22,7 +22,7 @@ import { Button as E } from "../../../button/button.js";
|
|
|
22
22
|
import '../../../../assets/upload-dialog.css';function io(o) {
|
|
23
23
|
return Q("MuiIconButton", o);
|
|
24
24
|
}
|
|
25
|
-
const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary", "colorSecondary", "colorError", "colorInfo", "colorSuccess", "colorWarning", "edgeStart", "edgeEnd", "sizeSmall", "sizeMedium", "sizeLarge", "loading", "loadingIndicator", "loadingWrapper"]),
|
|
25
|
+
const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary", "colorSecondary", "colorError", "colorInfo", "colorSuccess", "colorWarning", "edgeStart", "edgeEnd", "sizeSmall", "sizeMedium", "sizeLarge", "loading", "loadingIndicator", "loadingWrapper"]), lo = (o) => {
|
|
26
26
|
const {
|
|
27
27
|
classes: e,
|
|
28
28
|
disabled: r,
|
|
@@ -36,7 +36,7 @@ const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary"
|
|
|
36
36
|
loadingWrapper: ["loadingWrapper"]
|
|
37
37
|
};
|
|
38
38
|
return eo(u, io, e);
|
|
39
|
-
},
|
|
39
|
+
}, so = W(ro, {
|
|
40
40
|
name: "MuiIconButton",
|
|
41
41
|
slot: "Root",
|
|
42
42
|
overridesResolver: (o, e) => {
|
|
@@ -182,9 +182,9 @@ const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary"
|
|
|
182
182
|
disableFocusRipple: I = !1,
|
|
183
183
|
size: z = "medium",
|
|
184
184
|
id: v,
|
|
185
|
-
loading:
|
|
185
|
+
loading: s = null,
|
|
186
186
|
loadingIndicator: R,
|
|
187
|
-
...
|
|
187
|
+
...l
|
|
188
188
|
} = c, N = ao(v), B = R ?? /* @__PURE__ */ a(no, {
|
|
189
189
|
"aria-labelledby": N,
|
|
190
190
|
color: "inherit",
|
|
@@ -195,20 +195,20 @@ const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary"
|
|
|
195
195
|
color: u,
|
|
196
196
|
disabled: y,
|
|
197
197
|
disableFocusRipple: I,
|
|
198
|
-
loading:
|
|
198
|
+
loading: s,
|
|
199
199
|
loadingIndicator: B,
|
|
200
200
|
size: z
|
|
201
|
-
}, d =
|
|
202
|
-
return /* @__PURE__ */ L(
|
|
203
|
-
id:
|
|
201
|
+
}, d = lo(h);
|
|
202
|
+
return /* @__PURE__ */ L(so, {
|
|
203
|
+
id: s ? N : v,
|
|
204
204
|
className: X(d.root, b),
|
|
205
205
|
centerRipple: !0,
|
|
206
206
|
focusRipple: !I,
|
|
207
|
-
disabled: y ||
|
|
207
|
+
disabled: y || s,
|
|
208
208
|
ref: r,
|
|
209
|
-
...
|
|
209
|
+
...l,
|
|
210
210
|
ownerState: h,
|
|
211
|
-
children: [typeof
|
|
211
|
+
children: [typeof s == "boolean" && // use plain HTML span to minimize the runtime overhead
|
|
212
212
|
/* @__PURE__ */ a("span", {
|
|
213
213
|
className: d.loadingWrapper,
|
|
214
214
|
style: {
|
|
@@ -217,7 +217,7 @@ const U = K("MuiIconButton", ["root", "disabled", "colorInherit", "colorPrimary"
|
|
|
217
217
|
children: /* @__PURE__ */ a(co, {
|
|
218
218
|
className: d.loadingIndicator,
|
|
219
219
|
ownerState: h,
|
|
220
|
-
children:
|
|
220
|
+
children: s && B
|
|
221
221
|
})
|
|
222
222
|
}), f]
|
|
223
223
|
});
|
|
@@ -315,9 +315,9 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
315
315
|
onNextPhoto: I,
|
|
316
316
|
onSkipCrop: z,
|
|
317
317
|
onClearErrors: v,
|
|
318
|
-
minDimension:
|
|
318
|
+
minDimension: s = Y,
|
|
319
319
|
aspectRatio: R = q,
|
|
320
|
-
locale:
|
|
320
|
+
locale: l = Z,
|
|
321
321
|
circular: N,
|
|
322
322
|
keepSelection: B = !0,
|
|
323
323
|
photoSourceLoading: h,
|
|
@@ -327,7 +327,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
327
327
|
errors: k,
|
|
328
328
|
...x
|
|
329
329
|
} = o, S = r.slice(C).length > 1;
|
|
330
|
-
return h ? /* @__PURE__ */ a(
|
|
330
|
+
return h || !r.length ? /* @__PURE__ */ a(
|
|
331
331
|
T,
|
|
332
332
|
{
|
|
333
333
|
className: i(n.dialog, d),
|
|
@@ -344,7 +344,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
344
344
|
children: /* @__PURE__ */ a(
|
|
345
345
|
V,
|
|
346
346
|
{
|
|
347
|
-
locale:
|
|
347
|
+
locale: l,
|
|
348
348
|
photoSources: r,
|
|
349
349
|
errors: k,
|
|
350
350
|
onCloseDialogHandler: e,
|
|
@@ -364,7 +364,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
364
364
|
{
|
|
365
365
|
onClick: e,
|
|
366
366
|
className: i(n.close),
|
|
367
|
-
"aria-label": p[
|
|
367
|
+
"aria-label": p[l].back,
|
|
368
368
|
children: /* @__PURE__ */ a(
|
|
369
369
|
"img",
|
|
370
370
|
{
|
|
@@ -372,12 +372,12 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
372
372
|
width: w,
|
|
373
373
|
height: w,
|
|
374
374
|
src: po,
|
|
375
|
-
alt: p[
|
|
375
|
+
alt: p[l].back
|
|
376
376
|
}
|
|
377
377
|
)
|
|
378
378
|
}
|
|
379
379
|
) }),
|
|
380
|
-
/* @__PURE__ */ a(G, { className: i(n.title), children: p[
|
|
380
|
+
/* @__PURE__ */ a(G, { className: i(n.title), children: p[l]["photo-crop"] }),
|
|
381
381
|
/* @__PURE__ */ L(D, { className: i(n.content, S && n.many), children: [
|
|
382
382
|
S && /* @__PURE__ */ a("span", {}),
|
|
383
383
|
!!r.length && /* @__PURE__ */ a(
|
|
@@ -388,8 +388,8 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
388
388
|
circularCrop: N,
|
|
389
389
|
keepSelection: B,
|
|
390
390
|
aspect: R,
|
|
391
|
-
minWidth:
|
|
392
|
-
minHeight:
|
|
391
|
+
minWidth: s,
|
|
392
|
+
minHeight: s,
|
|
393
393
|
onChange: g,
|
|
394
394
|
children: /* @__PURE__ */ a(
|
|
395
395
|
"img",
|
|
@@ -397,7 +397,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
397
397
|
onLoad: f,
|
|
398
398
|
src: r[C],
|
|
399
399
|
ref: b,
|
|
400
|
-
alt: p[
|
|
400
|
+
alt: p[l]["photo-crop"],
|
|
401
401
|
draggable: !1
|
|
402
402
|
},
|
|
403
403
|
C
|
|
@@ -417,7 +417,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
417
417
|
buttonWeight: 500,
|
|
418
418
|
className: i(n.button),
|
|
419
419
|
onClick: z,
|
|
420
|
-
children: p[
|
|
420
|
+
children: p[l].skip
|
|
421
421
|
}
|
|
422
422
|
),
|
|
423
423
|
/* @__PURE__ */ a(
|
|
@@ -429,7 +429,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
429
429
|
buttonWeight: 500,
|
|
430
430
|
className: i(n.button),
|
|
431
431
|
onClick: I,
|
|
432
|
-
children: p[
|
|
432
|
+
children: p[l].continue
|
|
433
433
|
}
|
|
434
434
|
)
|
|
435
435
|
] }) : /* @__PURE__ */ a(
|
|
@@ -442,7 +442,7 @@ const po = "data:image/svg+xml,%3csvg%20width='46'%20height='46'%20viewBox='0%20
|
|
|
442
442
|
buttonWeight: 500,
|
|
443
443
|
className: i(n.button),
|
|
444
444
|
onClick: y,
|
|
445
|
-
children: p[
|
|
445
|
+
children: p[l].crop
|
|
446
446
|
}
|
|
447
447
|
) })
|
|
448
448
|
]
|
|
@@ -18,6 +18,10 @@ export declare const GIF_IMAGE_TYPE = "image/gif";
|
|
|
18
18
|
export declare const WEBP_IMAGE_TYPE = "image/webp";
|
|
19
19
|
export declare const ICO_IMAGE_TYPE = "image/x-icon";
|
|
20
20
|
export declare const MICROSOFT_ICO_IMAGE_TYPE = "image/vnd.microsoft.icon";
|
|
21
|
+
export declare const MP4_VIDEO_EXT = ".mp4";
|
|
22
|
+
export declare const WEBM_VIDEO_EXT = ".webm";
|
|
23
|
+
export declare const MP4_VIDEO_TYPE = "video/mp4";
|
|
24
|
+
export declare const WEBM_VIDEO_TYPE = "video/webm";
|
|
21
25
|
export declare const SUPPORTED_IMAGE_MIME_TYPES: string[];
|
|
22
26
|
export declare const MIME_TO_EXT: {
|
|
23
27
|
JPEG_IMAGE_TYPE: string[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BYTE_TO_KILOBYTE as I } from "../../constants.js";
|
|
2
|
-
const
|
|
3
|
-
_,
|
|
2
|
+
const N = 1, e = 670, E = ".jpg", _ = ".jpeg", P = ".png", o = ".svg", M = ".bmp", A = ".gif", T = ".ico", G = ".webp", D = [
|
|
4
3
|
E,
|
|
5
|
-
|
|
4
|
+
_,
|
|
6
5
|
P,
|
|
7
|
-
G,
|
|
8
|
-
M,
|
|
9
6
|
o,
|
|
7
|
+
M,
|
|
8
|
+
A,
|
|
9
|
+
G,
|
|
10
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",
|
|
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 = [
|
|
12
12
|
n,
|
|
13
13
|
c,
|
|
14
14
|
s,
|
|
@@ -16,55 +16,59 @@ const m = 1, L = 670, _ = ".jpg", E = ".jpeg", A = ".png", P = ".svg", G = ".bmp
|
|
|
16
16
|
O,
|
|
17
17
|
Y,
|
|
18
18
|
S,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
JPEG_IMAGE_TYPE: [
|
|
23
|
-
JPG_IMAGE_TYPE: [
|
|
24
|
-
PNG_IMAGE_TYPE: [
|
|
25
|
-
GIF_IMAGE_TYPE: [
|
|
26
|
-
SVG_IMAGE_TYPE: [
|
|
27
|
-
BMP_IMAGE_TYPE: [
|
|
28
|
-
WEBP_IMAGE_TYPE: [
|
|
19
|
+
m,
|
|
20
|
+
g
|
|
21
|
+
], F = {
|
|
22
|
+
JPEG_IMAGE_TYPE: [E, _],
|
|
23
|
+
JPG_IMAGE_TYPE: [E, _],
|
|
24
|
+
PNG_IMAGE_TYPE: [P],
|
|
25
|
+
GIF_IMAGE_TYPE: [A],
|
|
26
|
+
SVG_IMAGE_TYPE: [o],
|
|
27
|
+
BMP_IMAGE_TYPE: [M],
|
|
28
|
+
WEBP_IMAGE_TYPE: [G],
|
|
29
29
|
ICO_IMAGE_TYPE: [T],
|
|
30
30
|
MICROSOFT_ICO_IMAGE_TYPE: [T]
|
|
31
|
-
},
|
|
31
|
+
}, R = 500, B = 5 * I * I, a = "2d", V = "high", b = "%", J = "px", v = "ms", W = "mb", d = 1, f = 100, j = 2, r = 0.5, w = 100, x = 100, H = 500;
|
|
32
32
|
export {
|
|
33
|
-
|
|
33
|
+
M as BMP_IMAGE_EXT,
|
|
34
34
|
O as BMP_IMAGE_TYPE,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
N as DEFAULT_ASPECT_RATIO,
|
|
36
|
+
B as DEFAULT_FILE_MAX_SIZE,
|
|
37
|
+
e as DEFAULT_MIN_DIMENSION,
|
|
38
|
+
R as DEFAULT_TIMEOUT,
|
|
39
|
+
f as FULL_CROP_SIZE,
|
|
40
|
+
w as FULL_PROGRESS_VALUE,
|
|
41
|
+
A as GIF_IMAGE_EXT,
|
|
42
42
|
Y as GIF_IMAGE_TYPE,
|
|
43
43
|
T as ICO_IMAGE_EXT,
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
m as ICO_IMAGE_TYPE,
|
|
45
|
+
_ as JPEG_IMAGE_EXT,
|
|
46
46
|
c as JPEG_IMAGE_TYPE,
|
|
47
|
-
|
|
47
|
+
E as JPG_IMAGE_EXT,
|
|
48
48
|
n as JPG_IMAGE_TYPE,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
j as MAX_ASPECT_RATIO,
|
|
50
|
+
d as MB_FRACTION_DIGITS,
|
|
51
|
+
W as MB_UNIT,
|
|
52
|
+
g as MICROSOFT_ICO_IMAGE_TYPE,
|
|
53
|
+
F as MIME_TO_EXT,
|
|
54
|
+
r as MIN_ASPECT_RATIO,
|
|
55
|
+
L as MP4_VIDEO_EXT,
|
|
56
|
+
p as MP4_VIDEO_TYPE,
|
|
57
|
+
v as MS_UNIT,
|
|
58
|
+
a as PHOTO_CANVAS_CONTEXT,
|
|
57
59
|
x as PHOTO_LOADING_DELAY,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
V as PHOTO_SMOOTHING_QUALITY,
|
|
61
|
+
J as PIXEL_UNIT,
|
|
62
|
+
P as PNG_IMAGE_EXT,
|
|
61
63
|
s as PNG_IMAGE_TYPE,
|
|
62
|
-
|
|
64
|
+
b as PRECENT_UNIT,
|
|
63
65
|
H as RESET_DATA_DELAY,
|
|
64
|
-
|
|
66
|
+
D as SUPPORTED_IMAGE_EXTENSIONS,
|
|
65
67
|
U as SUPPORTED_IMAGE_MIME_TYPES,
|
|
66
|
-
|
|
68
|
+
o as SVG_IMAGE_EXT,
|
|
67
69
|
t as SVG_IMAGE_TYPE,
|
|
68
|
-
|
|
70
|
+
X as WEBM_VIDEO_EXT,
|
|
71
|
+
C as WEBM_VIDEO_TYPE,
|
|
72
|
+
G as WEBP_IMAGE_EXT,
|
|
69
73
|
S as WEBP_IMAGE_TYPE
|
|
70
74
|
};
|
|
@@ -1,263 +1,292 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState 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 {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
|
|
1
|
+
import { jsxs as Ro, Fragment as yo, jsx as _ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as i, useRef as w } from "react";
|
|
3
|
+
import { D as Io } from "../../index-BiffjjQq.js";
|
|
4
|
+
import { c as Fo } from "../../index-B2JRaoNz.js";
|
|
5
|
+
import { localizedText as Mo } from "./locale.js";
|
|
6
|
+
import { EN_LOCALE as No } from "../../constants.js";
|
|
7
|
+
import { DEFAULT_MIN_DIMENSION as bo, DEFAULT_ASPECT_RATIO as Ho, DEFAULT_TIMEOUT as Vo, DEFAULT_FILE_MAX_SIZE as ko, FULL_PROGRESS_VALUE as J, PHOTO_LOADING_DELAY as jo, RESET_DATA_DELAY as m } from "./constants.js";
|
|
8
|
+
import { UploadDialog as zo } from "./components/upload-dialog/upload-dialog.js";
|
|
9
|
+
import { UploadButton as Wo } from "./components/upload-button/upload-button.js";
|
|
10
|
+
import { ErrorUploadDialog as Bo } from "./components/error-upload-dialog/error-upload-dialog.js";
|
|
11
|
+
import { isVideo as K } from "./utils/is-video.js";
|
|
12
|
+
import { validatePhotoFile as Q } from "./utils/validate-photo-file.js";
|
|
13
|
+
import { readPhoto as $ } from "./utils/read-photo.js";
|
|
14
|
+
import { getPhotoCrop as Go } from "./utils/get-photo-crop.js";
|
|
15
|
+
import { getCroppedSource as Yo } from "./utils/get-cropped-source.js";
|
|
16
|
+
import { getDefaultCroppedPhoto as oo } from "./utils/get-default-cropped-photo.js";
|
|
17
|
+
import '../../assets/photo-crop-uploader.css';const Xo = "_photoCropCanvas_1i4lr_1", Zo = {
|
|
18
|
+
photoCropCanvas: Xo
|
|
18
19
|
};
|
|
19
|
-
function
|
|
20
|
+
function he(a) {
|
|
20
21
|
const {
|
|
21
|
-
buttonClassname:
|
|
22
|
-
onStartUpload:
|
|
22
|
+
buttonClassname: eo = "",
|
|
23
|
+
onStartUpload: ro = () => {
|
|
23
24
|
},
|
|
24
|
-
onEndUpload:
|
|
25
|
+
onEndUpload: to = () => {
|
|
25
26
|
},
|
|
26
|
-
onError:
|
|
27
|
+
onError: no = () => {
|
|
27
28
|
},
|
|
28
|
-
onStartCrop:
|
|
29
|
+
onStartCrop: so = () => {
|
|
29
30
|
},
|
|
30
|
-
onDragOver:
|
|
31
|
+
onDragOver: ao = () => {
|
|
31
32
|
},
|
|
32
|
-
onDragLeave:
|
|
33
|
+
onDragLeave: io = () => {
|
|
33
34
|
},
|
|
34
|
-
onDragDrop:
|
|
35
|
+
onDragDrop: co = () => {
|
|
35
36
|
},
|
|
36
|
-
showErrorPopup:
|
|
37
|
-
minDimension:
|
|
38
|
-
aspectRatio:
|
|
39
|
-
locale:
|
|
40
|
-
timeout:
|
|
41
|
-
fileMaxSize:
|
|
42
|
-
allowedExtensions:
|
|
43
|
-
allowedMimeTypes:
|
|
44
|
-
circular:
|
|
45
|
-
width:
|
|
46
|
-
keepSelection:
|
|
47
|
-
uploadButton:
|
|
48
|
-
multiple:
|
|
49
|
-
fromSources:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
37
|
+
showErrorPopup: lo = !1,
|
|
38
|
+
minDimension: c = bo,
|
|
39
|
+
aspectRatio: C = Ho,
|
|
40
|
+
locale: n = No,
|
|
41
|
+
timeout: M = Vo,
|
|
42
|
+
fileMaxSize: N = ko,
|
|
43
|
+
allowedExtensions: U,
|
|
44
|
+
allowedMimeTypes: b,
|
|
45
|
+
circular: po,
|
|
46
|
+
width: uo,
|
|
47
|
+
keepSelection: fo,
|
|
48
|
+
uploadButton: ho,
|
|
49
|
+
multiple: g = !1,
|
|
50
|
+
fromSources: H,
|
|
51
|
+
withVideoUploaded: A = !1,
|
|
52
|
+
returnCropParams: mo = !1,
|
|
53
|
+
...Co
|
|
54
|
+
} = a, {
|
|
55
|
+
onEndCrop: qo,
|
|
56
|
+
onClose: Jo,
|
|
57
|
+
...go
|
|
58
|
+
} = Co, [Eo, E] = i(!1), [P, D] = i([]), [x, v] = i([]), f = w([]), h = w([]), [p, V] = i(0), k = w(null), j = w(null), [l, O] = i(!1), [Po, z] = i(0), [W, B] = i(""), [Do, S] = i([]), [So, G] = i(!1), Lo = Eo || l && g, To = () => {
|
|
59
|
+
S([]);
|
|
60
|
+
}, R = (o = []) => {
|
|
61
|
+
l || (a.returnCropParams === !0 && a.onClose?.(
|
|
62
|
+
o,
|
|
63
|
+
f.current,
|
|
64
|
+
h.current
|
|
65
|
+
), E(!1), setTimeout(() => S([]), m), setTimeout(() => D([]), m), setTimeout(() => {
|
|
66
|
+
f.current = [], h.current = [];
|
|
67
|
+
}, m));
|
|
68
|
+
}, y = (o = []) => {
|
|
69
|
+
l || (a.returnCropParams || a.onClose?.(
|
|
70
|
+
o,
|
|
71
|
+
f.current,
|
|
72
|
+
h.current
|
|
73
|
+
), E(!1), setTimeout(() => S([]), m), setTimeout(() => D([]), m), setTimeout(() => {
|
|
74
|
+
f.current = [], h.current = [];
|
|
75
|
+
}, m));
|
|
76
|
+
}, Y = () => {
|
|
77
|
+
l || (a.returnCropParams === !0 ? R([]) : y([]));
|
|
78
|
+
}, _o = () => {
|
|
79
|
+
G(!1);
|
|
80
|
+
}, L = (o, r = o, e = []) => {
|
|
81
|
+
to(o), B(""), D(o), v(Array(o.length)), V(0), E(!0), f.current = r, h.current = e, o.length || Y();
|
|
82
|
+
}, I = (o) => {
|
|
83
|
+
o instanceof Error && (console.warn(o.message), no(o), B(o.message), G(!0), D([]), E(!1), f.current = [], h.current = []);
|
|
84
|
+
}, wo = async (o) => {
|
|
85
|
+
const { files: r } = o.target;
|
|
86
|
+
if (r?.length && !l)
|
|
73
87
|
try {
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
76
|
-
for (const
|
|
88
|
+
if (O(!0), ro(), g) {
|
|
89
|
+
const e = Array.from(r), t = J / e.length, T = [], u = [], Z = [], F = [];
|
|
90
|
+
for (const d of e) {
|
|
91
|
+
const Oo = K(d);
|
|
77
92
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
if (A && Oo) {
|
|
94
|
+
const s = URL.createObjectURL(d);
|
|
95
|
+
Z.push(u.length), u.push(s);
|
|
96
|
+
} else {
|
|
97
|
+
Q(
|
|
98
|
+
d,
|
|
99
|
+
{
|
|
100
|
+
maxSize: N,
|
|
101
|
+
allowedExtensions: U,
|
|
102
|
+
allowedMimeTypes: b
|
|
103
|
+
},
|
|
104
|
+
n
|
|
105
|
+
);
|
|
106
|
+
const s = await $(
|
|
107
|
+
d,
|
|
108
|
+
c,
|
|
109
|
+
n,
|
|
110
|
+
M
|
|
111
|
+
);
|
|
112
|
+
T.push(s), u.push(s);
|
|
113
|
+
}
|
|
114
|
+
} catch (s) {
|
|
115
|
+
let q = "";
|
|
116
|
+
s instanceof Error && (q = s.message), F.push({
|
|
117
|
+
photoName: d.name,
|
|
118
|
+
errorMessage: q
|
|
94
119
|
});
|
|
95
120
|
}
|
|
96
|
-
|
|
97
|
-
(
|
|
98
|
-
), await new Promise((
|
|
121
|
+
z(
|
|
122
|
+
(s) => Math.min(J, s + t)
|
|
123
|
+
), await new Promise((s) => setTimeout(s, 0));
|
|
99
124
|
}
|
|
100
|
-
if (
|
|
101
|
-
throw new Error(
|
|
102
|
-
|
|
125
|
+
if (H?.length)
|
|
126
|
+
throw new Error(F[0]?.errorMessage);
|
|
127
|
+
S(F), L(T, u, Z);
|
|
103
128
|
} else {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
129
|
+
const e = r[0];
|
|
130
|
+
if (A && K(e)) {
|
|
131
|
+
const t = URL.createObjectURL(e);
|
|
132
|
+
L([], [t], [0]);
|
|
133
|
+
} else {
|
|
134
|
+
Q(
|
|
135
|
+
e,
|
|
136
|
+
{ maxSize: N, allowedExtensions: U, allowedMimeTypes: b },
|
|
137
|
+
n
|
|
138
|
+
);
|
|
139
|
+
const t = await $(e, c, n, M);
|
|
140
|
+
L([t]);
|
|
141
|
+
}
|
|
112
142
|
}
|
|
113
|
-
} catch (
|
|
114
|
-
|
|
143
|
+
} catch (e) {
|
|
144
|
+
I(e);
|
|
115
145
|
} finally {
|
|
116
|
-
|
|
117
|
-
o.target.value = "",
|
|
118
|
-
},
|
|
146
|
+
g ? setTimeout(() => {
|
|
147
|
+
o.target.value = "", z(0), O(!1);
|
|
148
|
+
}, jo) : (o.target.value = "", O(!1));
|
|
119
149
|
}
|
|
120
|
-
},
|
|
121
|
-
const { width:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const h = [...E];
|
|
126
|
-
return h[p] = e, h;
|
|
150
|
+
}, Uo = (o) => {
|
|
151
|
+
const { width: r, height: e } = o.currentTarget, t = Go(r, e, c, C);
|
|
152
|
+
v((T) => {
|
|
153
|
+
const u = [...T];
|
|
154
|
+
return u[p] = t, u;
|
|
127
155
|
});
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
return
|
|
156
|
+
}, Ao = (o, r) => {
|
|
157
|
+
v((e) => {
|
|
158
|
+
const t = [...e];
|
|
159
|
+
return t[p] = r, t;
|
|
132
160
|
});
|
|
133
|
-
},
|
|
134
|
-
const o =
|
|
135
|
-
if (o &&
|
|
161
|
+
}, X = () => {
|
|
162
|
+
const o = j.current, r = k.current;
|
|
163
|
+
if (o && r && x)
|
|
136
164
|
try {
|
|
137
|
-
const
|
|
138
|
-
if (!
|
|
139
|
-
if (
|
|
140
|
-
const
|
|
141
|
-
|
|
165
|
+
const e = x[p];
|
|
166
|
+
if (!e) return !1;
|
|
167
|
+
if (so(), a.returnCropParams === !0) {
|
|
168
|
+
const t = Io(e, r.naturalWidth, r.naturalHeight);
|
|
169
|
+
a.onEndCrop?.(t), p >= P.length - 1 && R();
|
|
142
170
|
} else {
|
|
143
|
-
const
|
|
144
|
-
t,
|
|
145
|
-
o,
|
|
171
|
+
const t = Yo(
|
|
146
172
|
r,
|
|
147
|
-
|
|
173
|
+
o,
|
|
174
|
+
e,
|
|
175
|
+
n
|
|
148
176
|
);
|
|
149
|
-
|
|
177
|
+
a.onEndCrop?.(t), p >= P.length - 1 && y();
|
|
150
178
|
}
|
|
151
179
|
return !0;
|
|
152
|
-
} catch (
|
|
153
|
-
return
|
|
180
|
+
} catch (e) {
|
|
181
|
+
return e instanceof Error && (console.warn(e), I(e)), !1;
|
|
154
182
|
}
|
|
155
183
|
else
|
|
156
184
|
return !1;
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
const o =
|
|
185
|
+
}, xo = () => {
|
|
186
|
+
X() && V((r) => r + 1);
|
|
187
|
+
}, vo = async () => {
|
|
188
|
+
const o = P.slice(p);
|
|
161
189
|
try {
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
190
|
+
if (mo) {
|
|
191
|
+
const r = await Promise.all(
|
|
164
192
|
o.map(
|
|
165
|
-
(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
193
|
+
(e) => oo(
|
|
194
|
+
e,
|
|
195
|
+
c,
|
|
196
|
+
C,
|
|
197
|
+
n,
|
|
170
198
|
!0
|
|
171
199
|
)
|
|
172
200
|
)
|
|
173
201
|
);
|
|
174
|
-
|
|
202
|
+
R(r);
|
|
175
203
|
} else {
|
|
176
|
-
const
|
|
204
|
+
const r = await Promise.all(
|
|
177
205
|
o.map(
|
|
178
|
-
(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
206
|
+
(e) => oo(
|
|
207
|
+
e,
|
|
208
|
+
c,
|
|
209
|
+
C,
|
|
210
|
+
n,
|
|
183
211
|
!1
|
|
184
212
|
)
|
|
185
213
|
)
|
|
186
214
|
);
|
|
187
|
-
|
|
215
|
+
y(r);
|
|
188
216
|
}
|
|
189
|
-
} catch (
|
|
190
|
-
|
|
217
|
+
} catch (r) {
|
|
218
|
+
I(r);
|
|
191
219
|
}
|
|
192
220
|
};
|
|
193
|
-
return /* @__PURE__ */
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
|
|
221
|
+
return /* @__PURE__ */ Ro(yo, { children: [
|
|
222
|
+
/* @__PURE__ */ _(
|
|
223
|
+
Wo,
|
|
196
224
|
{
|
|
197
|
-
onChange:
|
|
198
|
-
onPhotoDataLoaded:
|
|
199
|
-
buttonClassname:
|
|
225
|
+
onChange: wo,
|
|
226
|
+
onPhotoDataLoaded: L,
|
|
227
|
+
buttonClassname: eo,
|
|
200
228
|
disabled: l,
|
|
201
229
|
buttonDisabled: l,
|
|
202
|
-
locale:
|
|
203
|
-
width:
|
|
204
|
-
allowedExtensions:
|
|
205
|
-
onDragDrop:
|
|
206
|
-
onDragLeave:
|
|
207
|
-
onDragOver:
|
|
208
|
-
button:
|
|
209
|
-
multiple:
|
|
210
|
-
fromSources:
|
|
211
|
-
|
|
212
|
-
|
|
230
|
+
locale: n,
|
|
231
|
+
width: uo,
|
|
232
|
+
allowedExtensions: U,
|
|
233
|
+
onDragDrop: co,
|
|
234
|
+
onDragLeave: io,
|
|
235
|
+
onDragOver: ao,
|
|
236
|
+
button: ho,
|
|
237
|
+
multiple: g,
|
|
238
|
+
fromSources: H,
|
|
239
|
+
withVideoUploaded: A,
|
|
240
|
+
...go,
|
|
241
|
+
children: Mo[n].upload
|
|
213
242
|
}
|
|
214
243
|
),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
|
|
244
|
+
/* @__PURE__ */ _(
|
|
245
|
+
zo,
|
|
217
246
|
{
|
|
218
|
-
open:
|
|
247
|
+
open: Lo,
|
|
219
248
|
photoSourceLoading: l,
|
|
220
|
-
loadingValue:
|
|
221
|
-
errors:
|
|
222
|
-
photoCrops:
|
|
223
|
-
photoSources:
|
|
224
|
-
onNextPhoto:
|
|
225
|
-
onSkipCrop:
|
|
226
|
-
onClearErrors:
|
|
227
|
-
photoError:
|
|
228
|
-
onCloseDialogHandler:
|
|
229
|
-
onCropChange:
|
|
230
|
-
onPhotoCrop:
|
|
231
|
-
onPhotoLoad:
|
|
232
|
-
imageRef:
|
|
233
|
-
minDimension:
|
|
234
|
-
aspectRatio:
|
|
235
|
-
locale:
|
|
236
|
-
circular:
|
|
237
|
-
keepSelection:
|
|
249
|
+
loadingValue: Po,
|
|
250
|
+
errors: Do,
|
|
251
|
+
photoCrops: x,
|
|
252
|
+
photoSources: P,
|
|
253
|
+
onNextPhoto: xo,
|
|
254
|
+
onSkipCrop: vo,
|
|
255
|
+
onClearErrors: To,
|
|
256
|
+
photoError: W,
|
|
257
|
+
onCloseDialogHandler: Y,
|
|
258
|
+
onCropChange: Ao,
|
|
259
|
+
onPhotoCrop: X,
|
|
260
|
+
onPhotoLoad: Uo,
|
|
261
|
+
imageRef: k,
|
|
262
|
+
minDimension: c,
|
|
263
|
+
aspectRatio: C,
|
|
264
|
+
locale: n,
|
|
265
|
+
circular: po,
|
|
266
|
+
keepSelection: fo,
|
|
238
267
|
photoIndex: p
|
|
239
268
|
}
|
|
240
269
|
),
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
|
|
270
|
+
/* @__PURE__ */ _(
|
|
271
|
+
Bo,
|
|
243
272
|
{
|
|
244
|
-
open:
|
|
245
|
-
photoError:
|
|
246
|
-
onCloseErrorDialog:
|
|
247
|
-
locale:
|
|
273
|
+
open: lo && So,
|
|
274
|
+
photoError: W,
|
|
275
|
+
onCloseErrorDialog: _o,
|
|
276
|
+
locale: n
|
|
248
277
|
}
|
|
249
278
|
),
|
|
250
|
-
/* @__PURE__ */
|
|
279
|
+
/* @__PURE__ */ _(
|
|
251
280
|
"canvas",
|
|
252
281
|
{
|
|
253
|
-
className:
|
|
254
|
-
width:
|
|
255
|
-
height:
|
|
256
|
-
ref:
|
|
282
|
+
className: Fo(Zo.photoCropCanvas),
|
|
283
|
+
width: c,
|
|
284
|
+
height: c,
|
|
285
|
+
ref: j
|
|
257
286
|
}
|
|
258
287
|
)
|
|
259
288
|
] });
|
|
260
289
|
}
|
|
261
290
|
export {
|
|
262
|
-
|
|
291
|
+
he as PhotoCropUploader
|
|
263
292
|
};
|
|
@@ -18,12 +18,12 @@ export type PhotoFileOptions = {
|
|
|
18
18
|
type CropPropsWithParams = {
|
|
19
19
|
returnCropParams: true;
|
|
20
20
|
onEndCrop?: (photoData: PixelCrop) => unknown;
|
|
21
|
-
onClose?: (skipPhotosData: PixelCrop[], sourcesData: PhotoDataUrl[]) => unknown;
|
|
21
|
+
onClose?: (skipPhotosData: PixelCrop[], sourcesData: PhotoDataUrl[], videoSourceIndexes: number[]) => unknown;
|
|
22
22
|
};
|
|
23
23
|
type CropPropsWithDataUrl = {
|
|
24
24
|
returnCropParams?: false;
|
|
25
25
|
onEndCrop?: (photoData: PhotoDataUrl) => unknown;
|
|
26
|
-
onClose?: (skipPhotosData: PhotoDataUrl[], sourcesData: PhotoDataUrl[]) => unknown;
|
|
26
|
+
onClose?: (skipPhotosData: PhotoDataUrl[], sourcesData: PhotoDataUrl[], videoSourceIndexes: number[]) => unknown;
|
|
27
27
|
};
|
|
28
28
|
type CropProps = CropPropsWithParams | CropPropsWithDataUrl;
|
|
29
29
|
export type PhotoCropUploaderCustomProps = {
|
|
@@ -48,6 +48,7 @@ export type PhotoCropUploaderCustomProps = {
|
|
|
48
48
|
width?: number;
|
|
49
49
|
uploadButton?: ReactNode;
|
|
50
50
|
fromSources?: PhotoDataUrl[];
|
|
51
|
+
withVideoUploaded?: boolean;
|
|
51
52
|
};
|
|
52
53
|
export type PhotoCropUploaderProps = PhotoCropUploaderCustomProps & CropProps & InputHTMLAttributes<HTMLInputElement>;
|
|
53
54
|
export type PhotoCropUploaderLocaleText = Record<Locale, Record<string, string>>;
|
|
@@ -4,3 +4,4 @@ export { getCroppedSource } from './get-cropped-source';
|
|
|
4
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
|
+
export { isVideo } from './is-video';
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { readPhoto as e } from "./read-photo.js";
|
|
2
2
|
import { getPhotoCrop as p } from "./get-photo-crop.js";
|
|
3
3
|
import { getCroppedSource as m } from "./get-cropped-source.js";
|
|
4
|
-
import { validatePhotoFile as
|
|
4
|
+
import { validatePhotoFile as x } from "./validate-photo-file.js";
|
|
5
5
|
import { getDefaultCroppedPhoto as g } from "./get-default-cropped-photo.js";
|
|
6
|
-
import { drawCroppedImage as
|
|
6
|
+
import { drawCroppedImage as i } from "./draw-cropped-image.js";
|
|
7
|
+
import { isVideo as P } from "./is-video.js";
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
+
i as drawCroppedImage,
|
|
9
10
|
m as getCroppedSource,
|
|
10
11
|
g as getDefaultCroppedPhoto,
|
|
11
12
|
p as getPhotoCrop,
|
|
13
|
+
P as isVideo,
|
|
12
14
|
e as readPhoto,
|
|
13
|
-
|
|
15
|
+
x as validatePhotoFile
|
|
14
16
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isVideo: (file: File) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MP4_VIDEO_EXT as o, WEBM_VIDEO_EXT as s, MP4_VIDEO_TYPE as _, WEBM_VIDEO_TYPE as I } from "../constants.js";
|
|
2
|
+
const c = [o, s], O = [_, I], T = (E) => {
|
|
3
|
+
const t = E.name.lastIndexOf("."), e = t > 0 ? E.name.slice(t).toLowerCase() : "", n = E.type;
|
|
4
|
+
return c.includes(e) && O.includes(n);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
T as isVideo
|
|
8
|
+
};
|