@hai-dev/ui-kit 1.0.10 → 1.0.11
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as To, Fragment as
|
|
1
|
+
import { jsxs as To, Fragment as _o, jsx as C } from "react/jsx-runtime";
|
|
2
2
|
import { useState as n, useRef as G } from "react";
|
|
3
|
-
import { D as
|
|
3
|
+
import { D as wo } from "../../index-BiffjjQq.js";
|
|
4
4
|
import { c as Ao } from "../../index-B2JRaoNz.js";
|
|
5
5
|
import { localizedText as Uo } from "./locale.js";
|
|
6
6
|
import { EN_LOCALE as xo } from "../../constants.js";
|
|
@@ -8,21 +8,21 @@ import { DEFAULT_MIN_DIMENSION as yo, DEFAULT_ASPECT_RATIO as Oo, DEFAULT_TIMEOU
|
|
|
8
8
|
import { UploadDialog as Mo } from "./components/upload-dialog/upload-dialog.js";
|
|
9
9
|
import { UploadButton as No } from "./components/upload-button/upload-button.js";
|
|
10
10
|
import { ErrorUploadDialog as Ro } from "./components/error-upload-dialog/error-upload-dialog.js";
|
|
11
|
-
import { validatePhotoFile as
|
|
12
|
-
import { readPhoto as
|
|
13
|
-
import { getPhotoCrop as
|
|
14
|
-
import { getCroppedSource as
|
|
11
|
+
import { validatePhotoFile as W } from "./utils/validate-photo-file.js";
|
|
12
|
+
import { readPhoto as X } from "./utils/read-photo.js";
|
|
13
|
+
import { getPhotoCrop as Ho } from "./utils/get-photo-crop.js";
|
|
14
|
+
import { getCroppedSource as bo } from "./utils/get-cropped-source.js";
|
|
15
15
|
import { getDefaultCroppedPhoto as zo } from "./utils/get-default-cropped-photo.js";
|
|
16
16
|
import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr_1", Vo = {
|
|
17
17
|
photoCropCanvas: ko
|
|
18
|
-
}, et = (
|
|
18
|
+
}, et = (Z) => {
|
|
19
19
|
const {
|
|
20
|
-
buttonClassname:
|
|
21
|
-
onStartUpload:
|
|
20
|
+
buttonClassname: q = "",
|
|
21
|
+
onStartUpload: J = () => {
|
|
22
22
|
},
|
|
23
|
-
onEndUpload:
|
|
23
|
+
onEndUpload: K = () => {
|
|
24
24
|
},
|
|
25
|
-
onError:
|
|
25
|
+
onError: Q = () => {
|
|
26
26
|
},
|
|
27
27
|
onStartCrop: $ = () => {
|
|
28
28
|
},
|
|
@@ -37,7 +37,7 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
37
37
|
onClose: P = () => {
|
|
38
38
|
},
|
|
39
39
|
showErrorPopup: eo = !1,
|
|
40
|
-
minDimension:
|
|
40
|
+
minDimension: l = yo,
|
|
41
41
|
aspectRatio: D = Oo,
|
|
42
42
|
locale: s = xo,
|
|
43
43
|
timeout: O = vo,
|
|
@@ -47,35 +47,35 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
47
47
|
circular: so,
|
|
48
48
|
width: no,
|
|
49
49
|
keepSelection: ao,
|
|
50
|
-
uploadButton:
|
|
50
|
+
uploadButton: lo,
|
|
51
51
|
multiple: m = !1,
|
|
52
52
|
fromSources: F,
|
|
53
53
|
returnCropParams: S = !1,
|
|
54
|
-
...
|
|
55
|
-
} =
|
|
54
|
+
...io
|
|
55
|
+
} = Z, [po, f] = n(!1), [p, u] = n([]), [T, _] = n([]), [c, M] = n(0), N = G(null), R = G(null), [i, w] = n(!1), [co, H] = n(0), [b, z] = n(""), [ho, d] = n([]), [mo, k] = n(!1), fo = po || i && m, uo = () => {
|
|
56
56
|
d([]);
|
|
57
57
|
}, V = (o = []) => {
|
|
58
|
-
|
|
58
|
+
i || (P?.(
|
|
59
59
|
o,
|
|
60
60
|
p
|
|
61
61
|
), f(!1), setTimeout(() => d([]), E), setTimeout(() => u([]), E));
|
|
62
62
|
}, go = () => {
|
|
63
|
-
|
|
63
|
+
i || (P([], p), f(!1), setTimeout(() => d([]), E), setTimeout(() => u([]), E));
|
|
64
64
|
}, Co = () => {
|
|
65
65
|
k(!1);
|
|
66
66
|
}, A = (o) => {
|
|
67
|
-
|
|
67
|
+
K(o), u(o), _(Array(o.length)), M(0), f(!0), z("");
|
|
68
68
|
}, U = (o) => {
|
|
69
|
-
o instanceof Error && (console.warn(o.message),
|
|
69
|
+
o instanceof Error && (console.warn(o.message), Q(o), z(o.message), k(!0), u([]), f(!1));
|
|
70
70
|
}, Eo = async (o) => {
|
|
71
71
|
const { files: r } = o.target;
|
|
72
|
-
if (r?.length && !
|
|
72
|
+
if (r?.length && !i)
|
|
73
73
|
try {
|
|
74
|
-
if (
|
|
74
|
+
if (w(!0), J(), m) {
|
|
75
75
|
const t = Array.from(r), e = Y / t.length, g = [], h = [];
|
|
76
76
|
for (const x of t) {
|
|
77
77
|
try {
|
|
78
|
-
|
|
78
|
+
W(
|
|
79
79
|
x,
|
|
80
80
|
{
|
|
81
81
|
maxSize: v,
|
|
@@ -84,7 +84,7 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
84
84
|
},
|
|
85
85
|
s
|
|
86
86
|
);
|
|
87
|
-
const a = await
|
|
87
|
+
const a = await X(x, l, s, O);
|
|
88
88
|
g.push(a);
|
|
89
89
|
} catch (a) {
|
|
90
90
|
let B = "";
|
|
@@ -93,7 +93,7 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
93
93
|
errorMessage: B
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
H(
|
|
97
97
|
(a) => Math.min(Y, a + e)
|
|
98
98
|
), await new Promise((a) => setTimeout(a, 0));
|
|
99
99
|
}
|
|
@@ -102,29 +102,29 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
102
102
|
d(h), A(g);
|
|
103
103
|
} else {
|
|
104
104
|
const t = r[0];
|
|
105
|
-
|
|
105
|
+
W(
|
|
106
106
|
t,
|
|
107
107
|
{ maxSize: v, allowedExtensions: L, allowedMimeTypes: I },
|
|
108
108
|
s
|
|
109
109
|
);
|
|
110
|
-
const e = await
|
|
110
|
+
const e = await X(t, l, s, O);
|
|
111
111
|
A([e]);
|
|
112
112
|
}
|
|
113
113
|
} catch (t) {
|
|
114
114
|
U(t);
|
|
115
115
|
} finally {
|
|
116
116
|
m ? setTimeout(() => {
|
|
117
|
-
o.target.value = "",
|
|
118
|
-
}, Fo) : (o.target.value = "",
|
|
117
|
+
o.target.value = "", H(0), w(!1);
|
|
118
|
+
}, Fo) : (o.target.value = "", w(!1));
|
|
119
119
|
}
|
|
120
120
|
}, Po = (o) => {
|
|
121
|
-
const { width: r, height: t } = o.currentTarget, e =
|
|
122
|
-
|
|
121
|
+
const { width: r, height: t } = o.currentTarget, e = Ho(r, t, l, D);
|
|
122
|
+
_((g) => {
|
|
123
123
|
const h = [...g];
|
|
124
124
|
return h[c] = e, h;
|
|
125
125
|
});
|
|
126
126
|
}, Do = (o, r) => {
|
|
127
|
-
|
|
127
|
+
_((t) => {
|
|
128
128
|
const e = [...t];
|
|
129
129
|
return e[c] = r, e;
|
|
130
130
|
});
|
|
@@ -135,10 +135,14 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
135
135
|
$();
|
|
136
136
|
const t = T[c];
|
|
137
137
|
if (S) {
|
|
138
|
-
const e =
|
|
138
|
+
const e = wo(
|
|
139
|
+
t,
|
|
140
|
+
r.naturalWidth,
|
|
141
|
+
r.naturalHeight
|
|
142
|
+
);
|
|
139
143
|
y?.(e);
|
|
140
144
|
} else {
|
|
141
|
-
const e =
|
|
145
|
+
const e = bo(
|
|
142
146
|
r,
|
|
143
147
|
o,
|
|
144
148
|
t,
|
|
@@ -159,7 +163,7 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
159
163
|
o.map(
|
|
160
164
|
(t) => zo(
|
|
161
165
|
t,
|
|
162
|
-
|
|
166
|
+
l,
|
|
163
167
|
D,
|
|
164
168
|
s,
|
|
165
169
|
S
|
|
@@ -171,25 +175,25 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
171
175
|
U(r);
|
|
172
176
|
}
|
|
173
177
|
};
|
|
174
|
-
return /* @__PURE__ */ To(
|
|
178
|
+
return /* @__PURE__ */ To(_o, { children: [
|
|
175
179
|
/* @__PURE__ */ C(
|
|
176
180
|
No,
|
|
177
181
|
{
|
|
178
182
|
onChange: Eo,
|
|
179
183
|
onPhotoDataLoaded: A,
|
|
180
|
-
buttonClassname:
|
|
181
|
-
disabled:
|
|
182
|
-
buttonDisabled:
|
|
184
|
+
buttonClassname: q,
|
|
185
|
+
disabled: i,
|
|
186
|
+
buttonDisabled: i,
|
|
183
187
|
locale: s,
|
|
184
188
|
width: no,
|
|
185
189
|
allowedExtensions: L,
|
|
186
190
|
onDragDrop: ro,
|
|
187
191
|
onDragLeave: to,
|
|
188
192
|
onDragOver: oo,
|
|
189
|
-
button:
|
|
193
|
+
button: lo,
|
|
190
194
|
multiple: m,
|
|
191
195
|
fromSources: F,
|
|
192
|
-
...
|
|
196
|
+
...io,
|
|
193
197
|
children: Uo[s].upload
|
|
194
198
|
}
|
|
195
199
|
),
|
|
@@ -197,7 +201,7 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
197
201
|
Mo,
|
|
198
202
|
{
|
|
199
203
|
open: fo,
|
|
200
|
-
photoSourceLoading:
|
|
204
|
+
photoSourceLoading: i,
|
|
201
205
|
loadingValue: co,
|
|
202
206
|
errors: ho,
|
|
203
207
|
photoCrops: T,
|
|
@@ -205,13 +209,13 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
205
209
|
onNextPhoto: Lo,
|
|
206
210
|
onSkipCrop: So,
|
|
207
211
|
onClearErrors: uo,
|
|
208
|
-
photoError:
|
|
212
|
+
photoError: b,
|
|
209
213
|
onCloseDialogHandler: go,
|
|
210
214
|
onCropChange: Do,
|
|
211
215
|
onPhotoCrop: j,
|
|
212
216
|
onPhotoLoad: Po,
|
|
213
217
|
imageRef: N,
|
|
214
|
-
minDimension:
|
|
218
|
+
minDimension: l,
|
|
215
219
|
aspectRatio: D,
|
|
216
220
|
locale: s,
|
|
217
221
|
circular: so,
|
|
@@ -223,7 +227,7 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
223
227
|
Ro,
|
|
224
228
|
{
|
|
225
229
|
open: eo && mo,
|
|
226
|
-
photoError:
|
|
230
|
+
photoError: b,
|
|
227
231
|
onCloseErrorDialog: Co,
|
|
228
232
|
locale: s
|
|
229
233
|
}
|
|
@@ -232,8 +236,8 @@ import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr
|
|
|
232
236
|
"canvas",
|
|
233
237
|
{
|
|
234
238
|
className: Ao(Vo.photoCropCanvas),
|
|
235
|
-
width:
|
|
236
|
-
height:
|
|
239
|
+
width: l,
|
|
240
|
+
height: l,
|
|
237
241
|
ref: R
|
|
238
242
|
}
|
|
239
243
|
)
|