@hai-dev/ui-kit 1.0.1 → 1.0.3
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/{Button-0AB7oP6Y.js → Button-DDlVTM6i.js} +3 -2
- package/dist/ButtonBase-CXGZ-DBC.js +1346 -0
- package/dist/{CircularProgress-BD6BPlN2.js → CircularProgress-CscJm1An.js} +9 -8
- package/dist/{DialogTitle-iOQ7wKEt.js → DialogTitle-KN1sayHD.js} +453 -555
- package/dist/assets/photo-list.css +1 -0
- package/dist/assets/upload-dialog.css +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/photo-crop-uploader/components/error-upload-dialog/error-upload-dialog.js +87 -23
- package/dist/components/photo-crop-uploader/components/photo-list/constants.d.ts +1 -0
- package/dist/components/photo-crop-uploader/components/photo-list/constants.js +4 -0
- package/dist/components/photo-crop-uploader/components/photo-list/index.d.ts +1 -0
- package/dist/components/photo-crop-uploader/components/photo-list/index.js +4 -0
- package/dist/components/photo-crop-uploader/components/photo-list/photo-list.d.ts +3 -0
- package/dist/components/photo-crop-uploader/components/photo-list/photo-list.js +88 -0
- package/dist/components/photo-crop-uploader/components/photo-list/types.d.ts +8 -0
- package/dist/components/photo-crop-uploader/components/photo-list/types.js +1 -0
- package/dist/components/photo-crop-uploader/components/upload-button/types.d.ts +3 -1
- package/dist/components/photo-crop-uploader/components/upload-button/upload-button.js +72 -62
- package/dist/components/photo-crop-uploader/components/upload-dialog/constants.d.ts +1 -0
- package/dist/components/photo-crop-uploader/components/upload-dialog/constants.js +4 -0
- package/dist/components/photo-crop-uploader/components/upload-dialog/types.d.ts +5 -2
- package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog.js +172 -135
- package/dist/components/photo-crop-uploader/constants.d.ts +3 -0
- package/dist/components/photo-crop-uploader/constants.js +36 -33
- package/dist/components/photo-crop-uploader/locale.js +8 -2
- package/dist/components/photo-crop-uploader/photo-crop-uploader.js +163 -112
- package/dist/components/photo-crop-uploader/types.d.ts +3 -1
- package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.d.ts +3 -0
- package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.js +32 -0
- 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 +12 -12
- package/dist/components/photo-crop-uploader/utils/index.d.ts +1 -0
- package/dist/components/photo-crop-uploader/utils/index.js +4 -2
- package/dist/components/photo-crop-uploader/utils/read-photo.js +33 -30
- package/dist/createTheme-DSHGFfg6.js +4124 -0
- package/dist/extendSxProp-CzeED7BH.js +49 -0
- package/package.json +1 -1
- package/dist/ButtonBase-Bw_3RZmN.js +0 -5453
|
@@ -1,154 +1,205 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as io, Fragment as ho, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as s, useRef as M } from "react";
|
|
3
3
|
import "../../index-BiffjjQq.js";
|
|
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 { validatePhotoFile as
|
|
12
|
-
import { readPhoto as
|
|
13
|
-
import { getPhotoCrop as
|
|
14
|
-
import { getCropedPhoto as
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
import { c as mo } from "../../index-B2JRaoNz.js";
|
|
5
|
+
import { localizedText as fo } from "./locale.js";
|
|
6
|
+
import { EN_LOCALE as Co } from "../../constants.js";
|
|
7
|
+
import { DEFAULT_MIN_DIMENSION as uo, DEFAULT_ASPECT_RATIO as go, DEFAULT_TIMEOUT as Po, DEFAULT_FILE_MAX_SIZE as Eo } from "./constants.js";
|
|
8
|
+
import { UploadDialog as Do } from "./components/upload-dialog/upload-dialog.js";
|
|
9
|
+
import { UploadButton as So } from "./components/upload-button/upload-button.js";
|
|
10
|
+
import { ErrorUploadDialog as Lo } from "./components/error-upload-dialog/error-upload-dialog.js";
|
|
11
|
+
import { validatePhotoFile as N } from "./utils/validate-photo-file.js";
|
|
12
|
+
import { readPhoto as R } from "./utils/read-photo.js";
|
|
13
|
+
import { getPhotoCrop as wo } from "./utils/get-photo-crop.js";
|
|
14
|
+
import { getCropedPhoto as Uo } from "./utils/get-croped-photo.js";
|
|
15
|
+
import { getDefaultCroppedPhoto as _o } from "./utils/get-default-cropped-photo.js";
|
|
16
|
+
import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr_1", yo = {
|
|
17
|
+
photoCropCanvas: xo
|
|
18
|
+
}, Xo = (k) => {
|
|
18
19
|
const {
|
|
19
|
-
buttonClassname:
|
|
20
|
-
onStartUpload:
|
|
20
|
+
buttonClassname: z = "",
|
|
21
|
+
onStartUpload: H = () => {
|
|
21
22
|
},
|
|
22
|
-
onEndUpload:
|
|
23
|
+
onEndUpload: j = () => {
|
|
23
24
|
},
|
|
24
|
-
onError:
|
|
25
|
+
onError: B = () => {
|
|
25
26
|
},
|
|
26
|
-
onStartCrop:
|
|
27
|
+
onStartCrop: X = () => {
|
|
27
28
|
},
|
|
28
|
-
onEndCrop:
|
|
29
|
+
onEndCrop: Z = () => {
|
|
29
30
|
},
|
|
30
|
-
onDragOver:
|
|
31
|
+
onDragOver: q = () => {
|
|
31
32
|
},
|
|
32
|
-
onDragLeave:
|
|
33
|
+
onDragLeave: G = () => {
|
|
33
34
|
},
|
|
34
|
-
onDragDrop:
|
|
35
|
+
onDragDrop: J = () => {
|
|
35
36
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
onClose: P = () => {
|
|
38
|
+
},
|
|
39
|
+
showErrorPopup: K = !1,
|
|
40
|
+
minDimension: a = uo,
|
|
41
|
+
aspectRatio: h = go,
|
|
42
|
+
locale: e = Co,
|
|
43
|
+
timeout: E = Po,
|
|
44
|
+
fileMaxSize: D = Eo,
|
|
45
|
+
allowedExtensions: m,
|
|
46
|
+
allowedMimeTypes: S,
|
|
47
|
+
circular: Q,
|
|
48
|
+
width: V,
|
|
49
|
+
keepSelection: W,
|
|
50
|
+
photoCropUploaderSlots: Y,
|
|
51
|
+
multiple: L,
|
|
52
|
+
fromSources: $,
|
|
53
|
+
...oo
|
|
54
|
+
} = k, [to, c] = s(!1), [d, w] = s([]), [f, C] = s([]), [l, U] = s(0), _ = M(null), x = M(null), [y, A] = s(!1), [T, v] = s(""), [ro, I] = s(!1), F = (o = []) => {
|
|
55
|
+
P(o), c(!1);
|
|
56
|
+
}, eo = () => {
|
|
57
|
+
P([]), c(!1);
|
|
58
|
+
}, no = () => {
|
|
59
|
+
I(!1);
|
|
60
|
+
}, u = (o) => {
|
|
61
|
+
j(o), w(o), C(Array(o.length)), U(0), c(!0), v("");
|
|
62
|
+
}, g = (o) => {
|
|
63
|
+
o instanceof Error && (console.warn(o.message), B(o), v(o.message), I(!0), w([]), c(!1));
|
|
64
|
+
}, ao = async (o) => {
|
|
65
|
+
const { files: r } = o.target;
|
|
66
|
+
if (r?.length)
|
|
60
67
|
try {
|
|
61
|
-
|
|
62
|
-
r
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
if (A(!0), H(), L) {
|
|
69
|
+
const t = Array.from(r);
|
|
70
|
+
t.forEach((p) => {
|
|
71
|
+
N(
|
|
72
|
+
p,
|
|
73
|
+
{ maxSize: D, allowedExtensions: m, allowedMimeTypes: S },
|
|
74
|
+
e
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
const n = await Promise.all(
|
|
78
|
+
t.map(
|
|
79
|
+
(p) => R(p, a, e, E)
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
u(n);
|
|
83
|
+
} else {
|
|
84
|
+
const t = r[0];
|
|
85
|
+
N(
|
|
86
|
+
t,
|
|
87
|
+
{ maxSize: D, allowedExtensions: m, allowedMimeTypes: S },
|
|
88
|
+
e
|
|
89
|
+
);
|
|
90
|
+
const n = await R(t, a, e, E);
|
|
91
|
+
u([n]);
|
|
92
|
+
}
|
|
68
93
|
} catch (t) {
|
|
69
|
-
|
|
94
|
+
g(t);
|
|
70
95
|
} finally {
|
|
71
|
-
o.target.value = "",
|
|
96
|
+
o.target.value = "", A(!1);
|
|
72
97
|
}
|
|
73
|
-
},
|
|
74
|
-
const { width: r, height: t } = o.currentTarget,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
}, so = (o) => {
|
|
99
|
+
const { width: r, height: t } = o.currentTarget, n = wo(r, t, a, h);
|
|
100
|
+
C((p) => {
|
|
101
|
+
const b = [...p];
|
|
102
|
+
return b[l] = n, b;
|
|
103
|
+
});
|
|
104
|
+
}, lo = (o, r) => {
|
|
105
|
+
C((t) => {
|
|
106
|
+
const n = [...t];
|
|
107
|
+
return n[l] = r, n;
|
|
108
|
+
});
|
|
109
|
+
}, O = () => {
|
|
110
|
+
const o = x.current, r = _.current;
|
|
111
|
+
if (o && r && f)
|
|
81
112
|
try {
|
|
82
|
-
|
|
83
|
-
const t =
|
|
113
|
+
X();
|
|
114
|
+
const t = Uo(
|
|
84
115
|
r,
|
|
85
116
|
o,
|
|
86
|
-
l,
|
|
117
|
+
f[l],
|
|
87
118
|
e
|
|
88
119
|
);
|
|
89
|
-
|
|
120
|
+
Z(t), l >= d.length - 1 && F();
|
|
90
121
|
} catch (t) {
|
|
91
|
-
t instanceof Error && (console.warn(t),
|
|
122
|
+
t instanceof Error && (console.warn(t), g(t));
|
|
92
123
|
}
|
|
124
|
+
}, po = () => {
|
|
125
|
+
O(), U((o) => o + 1);
|
|
126
|
+
}, co = async () => {
|
|
127
|
+
const o = d.slice(l);
|
|
128
|
+
try {
|
|
129
|
+
const r = await Promise.all(
|
|
130
|
+
o.map(
|
|
131
|
+
(t) => _o(t, a, h, e)
|
|
132
|
+
)
|
|
133
|
+
);
|
|
134
|
+
F(r);
|
|
135
|
+
} catch (r) {
|
|
136
|
+
g(r);
|
|
137
|
+
}
|
|
93
138
|
};
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
|
|
139
|
+
return /* @__PURE__ */ io(ho, { children: [
|
|
140
|
+
/* @__PURE__ */ i(
|
|
141
|
+
So,
|
|
97
142
|
{
|
|
98
|
-
onChange:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
143
|
+
onChange: ao,
|
|
144
|
+
onPhotoDataLoaded: u,
|
|
145
|
+
buttonClassname: z,
|
|
146
|
+
disabled: y,
|
|
147
|
+
buttonDisabled: y,
|
|
102
148
|
locale: e,
|
|
103
|
-
width:
|
|
104
|
-
allowedExtensions:
|
|
105
|
-
onDragDrop:
|
|
106
|
-
onDragLeave:
|
|
107
|
-
onDragOver:
|
|
108
|
-
button:
|
|
109
|
-
|
|
110
|
-
|
|
149
|
+
width: V,
|
|
150
|
+
allowedExtensions: m,
|
|
151
|
+
onDragDrop: J,
|
|
152
|
+
onDragLeave: G,
|
|
153
|
+
onDragOver: q,
|
|
154
|
+
button: Y?.button,
|
|
155
|
+
multiple: L,
|
|
156
|
+
fromSources: $,
|
|
157
|
+
...oo,
|
|
158
|
+
children: fo[e].upload
|
|
111
159
|
}
|
|
112
160
|
),
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
|
|
161
|
+
/* @__PURE__ */ i(
|
|
162
|
+
Do,
|
|
115
163
|
{
|
|
116
|
-
open:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
164
|
+
open: to,
|
|
165
|
+
photoCrops: f,
|
|
166
|
+
photoSources: d,
|
|
167
|
+
onNextPhoto: po,
|
|
168
|
+
onSkipCrop: co,
|
|
169
|
+
photoError: T,
|
|
170
|
+
onCloseDialogHandler: eo,
|
|
171
|
+
onCropChange: lo,
|
|
172
|
+
onPhotoCrop: O,
|
|
173
|
+
onPhotoLoad: so,
|
|
174
|
+
imageRef: _,
|
|
175
|
+
minDimension: a,
|
|
176
|
+
aspectRatio: h,
|
|
127
177
|
locale: e,
|
|
128
|
-
circular:
|
|
129
|
-
keepSelection:
|
|
178
|
+
circular: Q,
|
|
179
|
+
keepSelection: W,
|
|
180
|
+
photoIndex: l
|
|
130
181
|
}
|
|
131
182
|
),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
|
|
183
|
+
/* @__PURE__ */ i(
|
|
184
|
+
Lo,
|
|
134
185
|
{
|
|
135
|
-
open:
|
|
136
|
-
photoError:
|
|
137
|
-
onCloseErrorDialog:
|
|
186
|
+
open: K && ro,
|
|
187
|
+
photoError: T,
|
|
188
|
+
onCloseErrorDialog: no,
|
|
138
189
|
locale: e
|
|
139
190
|
}
|
|
140
191
|
),
|
|
141
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ i(
|
|
142
193
|
"canvas",
|
|
143
194
|
{
|
|
144
|
-
className:
|
|
145
|
-
width:
|
|
146
|
-
height:
|
|
147
|
-
ref:
|
|
195
|
+
className: mo(yo.photoCropCanvas),
|
|
196
|
+
width: a,
|
|
197
|
+
height: a,
|
|
198
|
+
ref: x
|
|
148
199
|
}
|
|
149
200
|
)
|
|
150
201
|
] });
|
|
151
202
|
};
|
|
152
203
|
export {
|
|
153
|
-
|
|
204
|
+
Xo as PhotoCropUploader
|
|
154
205
|
};
|
|
@@ -16,10 +16,11 @@ export type PhotoCropUploaderSlots = {
|
|
|
16
16
|
export type PhotoCropUploaderCustomProps = {
|
|
17
17
|
buttonClassname?: string;
|
|
18
18
|
onStartUpload?: () => unknown;
|
|
19
|
-
onEndUpload?: (photoData: PhotoDataUrl) => unknown;
|
|
19
|
+
onEndUpload?: (photoData: PhotoDataUrl[]) => unknown;
|
|
20
20
|
onError?: (error: Error) => unknown;
|
|
21
21
|
onStartCrop?: () => unknown;
|
|
22
22
|
onEndCrop?: (photoData: PhotoDataUrl) => unknown;
|
|
23
|
+
onClose?: (skipPhotosData: PhotoDataUrl[]) => unknown;
|
|
23
24
|
onDragOver?: (event: DragEvent<HTMLDivElement>) => unknown;
|
|
24
25
|
onDragLeave?: (event: DragEvent<HTMLDivElement>) => unknown;
|
|
25
26
|
onDragDrop?: (event: DragEvent<HTMLDivElement>) => unknown;
|
|
@@ -35,6 +36,7 @@ export type PhotoCropUploaderCustomProps = {
|
|
|
35
36
|
keepSelection?: boolean;
|
|
36
37
|
width?: number;
|
|
37
38
|
photoCropUploaderSlots?: PhotoCropUploaderSlots;
|
|
39
|
+
fromSources?: PhotoDataUrl[];
|
|
38
40
|
};
|
|
39
41
|
export type PhotoCropUploaderProps = PhotoCropUploaderCustomProps & InputHTMLAttributes<HTMLInputElement>;
|
|
40
42
|
export type PhotoCropUploaderLocaleText = Record<Locale, Record<string, string>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getPhotoCrop as m } from "./get-photo-crop.js";
|
|
2
|
+
import { getCropedPhoto as g } from "./get-croped-photo.js";
|
|
3
|
+
import { localizedText as P } from "../locale.js";
|
|
4
|
+
const w = async (a, c, s, e) => new Promise((p, n) => {
|
|
5
|
+
const o = new Image(), d = document.createElement("canvas");
|
|
6
|
+
o.src = a, o.addEventListener("load", () => {
|
|
7
|
+
const { width: t, height: h } = o, i = m(
|
|
8
|
+
t,
|
|
9
|
+
h,
|
|
10
|
+
c,
|
|
11
|
+
s,
|
|
12
|
+
!0
|
|
13
|
+
);
|
|
14
|
+
try {
|
|
15
|
+
const r = g(
|
|
16
|
+
o,
|
|
17
|
+
d,
|
|
18
|
+
i,
|
|
19
|
+
e
|
|
20
|
+
);
|
|
21
|
+
p(r);
|
|
22
|
+
} catch (r) {
|
|
23
|
+
n(r);
|
|
24
|
+
}
|
|
25
|
+
}), o.addEventListener("error", () => {
|
|
26
|
+
const t = new Error(P[e]["paint-error"]);
|
|
27
|
+
n(t);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
w as getDefaultCroppedPhoto
|
|
32
|
+
};
|
|
@@ -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) => Crop;
|
|
2
|
+
export declare const getPhotoCrop: (width: number, height: number, minDimension?: number, aspectRatio?: number, maxSize?: boolean) => Crop;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { DEFAULT_MIN_DIMENSION as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
import { B as _, L as C } from "../../../index-BiffjjQq.js";
|
|
2
|
+
import { DEFAULT_MIN_DIMENSION as P, DEFAULT_ASPECT_RATIO as T, FULL_CROP_SIZE as o, PRECENT_UNIT as s } from "../constants.js";
|
|
3
|
+
const U = (r, t, c = P, n = T, e = !1) => {
|
|
4
|
+
const p = c / r * o, I = c / t * o, E = _(
|
|
5
5
|
{
|
|
6
|
-
unit:
|
|
7
|
-
width: e,
|
|
8
|
-
height:
|
|
6
|
+
unit: s,
|
|
7
|
+
width: e ? o : p,
|
|
8
|
+
height: e ? o : I
|
|
9
9
|
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
n,
|
|
11
|
+
r,
|
|
12
|
+
t
|
|
13
13
|
);
|
|
14
|
-
return E
|
|
14
|
+
return C(E, r, t);
|
|
15
15
|
};
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
U as getPhotoCrop
|
|
18
18
|
};
|
|
@@ -2,3 +2,4 @@ export { readPhoto } from './read-photo';
|
|
|
2
2
|
export { getPhotoCrop } from './get-photo-crop';
|
|
3
3
|
export { getCropedPhoto } from './get-croped-photo';
|
|
4
4
|
export { validatePhotoFile } from './validate-photo-file';
|
|
5
|
+
export { getDefaultCroppedPhoto } from './get-default-cropped-photo';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { readPhoto as
|
|
1
|
+
import { readPhoto as e } from "./read-photo.js";
|
|
2
2
|
import { getPhotoCrop as p } from "./get-photo-crop.js";
|
|
3
3
|
import { getCropedPhoto as h } from "./get-croped-photo.js";
|
|
4
4
|
import { validatePhotoFile as x } from "./validate-photo-file.js";
|
|
5
|
+
import { getDefaultCroppedPhoto as a } from "./get-default-cropped-photo.js";
|
|
5
6
|
export {
|
|
6
7
|
h as getCropedPhoto,
|
|
8
|
+
a as getDefaultCroppedPhoto,
|
|
7
9
|
p as getPhotoCrop,
|
|
8
|
-
|
|
10
|
+
e as readPhoto,
|
|
9
11
|
x as validatePhotoFile
|
|
10
12
|
};
|
|
@@ -1,51 +1,54 @@
|
|
|
1
|
-
import { localizedText as
|
|
2
|
-
import { EN_LOCALE as
|
|
3
|
-
import { DEFAULT_MIN_DIMENSION as
|
|
1
|
+
import { localizedText as s } from "../locale.js";
|
|
2
|
+
import { EN_LOCALE as c } from "../../../constants.js";
|
|
3
|
+
import { DEFAULT_MIN_DIMENSION as p, DEFAULT_TIMEOUT as A, MS_UNIT as _, MAX_ASPECT_RATIO as w, MIN_ASPECT_RATIO as l } from "../constants.js";
|
|
4
4
|
import { PhotoSizeError as v } from "../errors/photo-size.error.js";
|
|
5
|
-
const
|
|
6
|
-
(m,
|
|
7
|
-
const
|
|
5
|
+
const S = async (L, d = p, o = c, T = A) => new Promise(
|
|
6
|
+
(m, e) => {
|
|
7
|
+
const t = new FileReader();
|
|
8
8
|
let r = !1;
|
|
9
9
|
const E = setTimeout(() => {
|
|
10
|
-
r || (r = !0,
|
|
10
|
+
r || (r = !0, t.abort(), e(
|
|
11
11
|
new Error(
|
|
12
|
-
`${
|
|
12
|
+
`${s[o]["timeout-error"]}: ${T}${_}`
|
|
13
13
|
)
|
|
14
14
|
));
|
|
15
|
-
},
|
|
16
|
-
|
|
15
|
+
}, T);
|
|
16
|
+
t.addEventListener("load", () => {
|
|
17
17
|
if (r) return;
|
|
18
18
|
r = !0, clearTimeout(E);
|
|
19
|
-
const a =
|
|
19
|
+
const a = t.result?.toString() || "";
|
|
20
20
|
if (!a) {
|
|
21
21
|
m("");
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const { naturalWidth:
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
24
|
+
const i = new Image();
|
|
25
|
+
i.src = a, i.addEventListener("load", () => {
|
|
26
|
+
const { naturalWidth: n, naturalHeight: f } = i, I = f / n;
|
|
27
|
+
if (n < d || f < d) {
|
|
28
|
+
const u = v.get(d, o);
|
|
29
|
+
e(u);
|
|
30
|
+
} else if (I > w || I < l) {
|
|
31
|
+
const u = new Error(s[o].aspect);
|
|
32
|
+
e(u);
|
|
30
33
|
} else
|
|
31
34
|
m(a);
|
|
32
|
-
}),
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
}),
|
|
36
|
-
const
|
|
37
|
-
|
|
35
|
+
}), i.addEventListener("error", () => {
|
|
36
|
+
const n = new Error(s[o]["paint-error"]);
|
|
37
|
+
e(n);
|
|
38
|
+
}), i.addEventListener("abort", () => {
|
|
39
|
+
const n = new Error(s[o]["read-abort"]);
|
|
40
|
+
e(n);
|
|
38
41
|
});
|
|
39
|
-
}),
|
|
40
|
-
r || (r = !0, clearTimeout(E), t
|
|
41
|
-
}),
|
|
42
|
+
}), t.addEventListener("error", () => {
|
|
43
|
+
r || (r = !0, clearTimeout(E), e(t.error));
|
|
44
|
+
}), t.addEventListener("abort", () => {
|
|
42
45
|
if (r) return;
|
|
43
46
|
r = !0, clearTimeout(E);
|
|
44
|
-
const a = new Error(
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
+
const a = new Error(s[o]["paint-abort"]);
|
|
48
|
+
e(a);
|
|
49
|
+
}), t.readAsDataURL(L);
|
|
47
50
|
}
|
|
48
51
|
);
|
|
49
52
|
export {
|
|
50
|
-
|
|
53
|
+
S as readPhoto
|
|
51
54
|
};
|