@hai-dev/ui-kit 1.1.0 → 1.1.2
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,4 +1,4 @@
|
|
|
1
1
|
export { PhotoCropUploader, drawCroppedImage } from './photo-crop-uploader';
|
|
2
2
|
export { Button } from './button';
|
|
3
3
|
export { CircularProgressLoader } from './circular-progress-loader';
|
|
4
|
-
export { CodeInput } from './code-input';
|
|
4
|
+
export { CodeInput, type CodeInputProps } from './code-input';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as a, useRef as
|
|
1
|
+
import { jsxs as To, Fragment as wo, jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import { useState as a, useRef as j } from "react";
|
|
3
3
|
import { D as Ao } from "../../index-BiffjjQq.js";
|
|
4
4
|
import { c as Uo } from "../../index-B2JRaoNz.js";
|
|
5
5
|
import { localizedText as xo } from "./locale.js";
|
|
6
6
|
import { EN_LOCALE as yo } from "../../constants.js";
|
|
7
|
-
import { DEFAULT_MIN_DIMENSION as Oo, DEFAULT_ASPECT_RATIO as Io, DEFAULT_TIMEOUT as vo, DEFAULT_FILE_MAX_SIZE as Fo, FULL_PROGRESS_VALUE as
|
|
7
|
+
import { DEFAULT_MIN_DIMENSION as Oo, DEFAULT_ASPECT_RATIO as Io, DEFAULT_TIMEOUT as vo, DEFAULT_FILE_MAX_SIZE as Fo, FULL_PROGRESS_VALUE as B, PHOTO_LOADING_DELAY as Mo, RESET_DATA_DELAY as D } from "./constants.js";
|
|
8
8
|
import { UploadDialog as No } from "./components/upload-dialog/upload-dialog.js";
|
|
9
9
|
import { UploadButton as Ro } from "./components/upload-button/upload-button.js";
|
|
10
10
|
import { ErrorUploadDialog as Ho } from "./components/error-upload-dialog/error-upload-dialog.js";
|
|
11
|
-
import { validatePhotoFile as
|
|
11
|
+
import { validatePhotoFile as G } from "./utils/validate-photo-file.js";
|
|
12
12
|
import { readPhoto as Y } from "./utils/read-photo.js";
|
|
13
13
|
import { getPhotoCrop as bo } from "./utils/get-photo-crop.js";
|
|
14
14
|
import { getCroppedSource as ko } from "./utils/get-cropped-source.js";
|
|
@@ -34,8 +34,8 @@ function nr(n) {
|
|
|
34
34
|
onDragDrop: ro = () => {
|
|
35
35
|
},
|
|
36
36
|
showErrorPopup: to = !1,
|
|
37
|
-
minDimension:
|
|
38
|
-
aspectRatio:
|
|
37
|
+
minDimension: l = Oo,
|
|
38
|
+
aspectRatio: h = Io,
|
|
39
39
|
locale: s = yo,
|
|
40
40
|
timeout: O = vo,
|
|
41
41
|
fileMaxSize: I = Fo,
|
|
@@ -47,20 +47,20 @@ function nr(n) {
|
|
|
47
47
|
uploadButton: ao,
|
|
48
48
|
multiple: m = !1,
|
|
49
49
|
fromSources: F,
|
|
50
|
-
returnCropParams:
|
|
51
|
-
...
|
|
50
|
+
returnCropParams: lo = !1,
|
|
51
|
+
...io
|
|
52
52
|
} = n, {
|
|
53
|
-
onEndCrop:
|
|
54
|
-
onClose:
|
|
53
|
+
onEndCrop: Wo,
|
|
54
|
+
onClose: jo,
|
|
55
55
|
...co
|
|
56
|
-
} =
|
|
56
|
+
} = io, [po, d] = a(!1), [f, C] = a([]), [L, _] = a([]), [p, M] = a(0), N = j(null), R = j(null), [i, T] = a(!1), [fo, H] = a(0), [b, k] = a(""), [uo, g] = a([]), [ho, z] = a(!1), mo = po || i && m, Co = () => {
|
|
57
57
|
g([]);
|
|
58
|
-
},
|
|
59
|
-
|
|
58
|
+
}, w = (o = []) => {
|
|
59
|
+
i || (n.returnCropParams === !0 && n.onClose?.(o, f), d(!1), setTimeout(() => g([]), D), setTimeout(() => C([]), D));
|
|
60
60
|
}, A = (o = []) => {
|
|
61
|
-
|
|
61
|
+
i || (n.returnCropParams !== !0 && n.onClose?.(o, f), d(!1), setTimeout(() => g([]), D), setTimeout(() => C([]), D));
|
|
62
62
|
}, go = () => {
|
|
63
|
-
|
|
63
|
+
i || (n.returnCropParams === !0 ? w([]) : A([]));
|
|
64
64
|
}, Eo = () => {
|
|
65
65
|
z(!1);
|
|
66
66
|
}, U = (o) => {
|
|
@@ -69,13 +69,13 @@ function nr(n) {
|
|
|
69
69
|
o instanceof Error && (console.warn(o.message), K(o), k(o.message), z(!0), C([]), d(!1));
|
|
70
70
|
}, Po = async (o) => {
|
|
71
71
|
const { files: t } = o.target;
|
|
72
|
-
if (t?.length && !
|
|
72
|
+
if (t?.length && !i)
|
|
73
73
|
try {
|
|
74
|
-
if (
|
|
75
|
-
const r = Array.from(t), e =
|
|
74
|
+
if (T(!0), q(), m) {
|
|
75
|
+
const r = Array.from(t), e = B / r.length, E = [], u = [];
|
|
76
76
|
for (const y of r) {
|
|
77
77
|
try {
|
|
78
|
-
|
|
78
|
+
G(
|
|
79
79
|
y,
|
|
80
80
|
{
|
|
81
81
|
maxSize: I,
|
|
@@ -84,46 +84,46 @@ function nr(n) {
|
|
|
84
84
|
},
|
|
85
85
|
s
|
|
86
86
|
);
|
|
87
|
-
const c = await Y(y,
|
|
87
|
+
const c = await Y(y, l, s, O);
|
|
88
88
|
E.push(c);
|
|
89
89
|
} catch (c) {
|
|
90
|
-
let
|
|
91
|
-
c instanceof Error && (
|
|
90
|
+
let W = "";
|
|
91
|
+
c instanceof Error && (W = c.message), u.push({
|
|
92
92
|
photoName: y.name,
|
|
93
|
-
errorMessage:
|
|
93
|
+
errorMessage: W
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
H(
|
|
97
|
-
(c) => Math.min(
|
|
97
|
+
(c) => Math.min(B, c + e)
|
|
98
98
|
), await new Promise((c) => setTimeout(c, 0));
|
|
99
99
|
}
|
|
100
100
|
if (F?.length)
|
|
101
|
-
throw new Error(
|
|
102
|
-
g(
|
|
101
|
+
throw new Error(u[0]?.errorMessage);
|
|
102
|
+
g(u), U(E);
|
|
103
103
|
} else {
|
|
104
104
|
const r = t[0];
|
|
105
|
-
|
|
105
|
+
G(
|
|
106
106
|
r,
|
|
107
107
|
{ maxSize: I, allowedExtensions: S, allowedMimeTypes: v },
|
|
108
108
|
s
|
|
109
109
|
);
|
|
110
|
-
const e = await Y(r,
|
|
110
|
+
const e = await Y(r, l, s, O);
|
|
111
111
|
U([e]);
|
|
112
112
|
}
|
|
113
113
|
} catch (r) {
|
|
114
114
|
x(r);
|
|
115
115
|
} finally {
|
|
116
116
|
m ? setTimeout(() => {
|
|
117
|
-
o.target.value = "", H(0),
|
|
118
|
-
}, Mo) : (o.target.value = "",
|
|
117
|
+
o.target.value = "", H(0), T(!1);
|
|
118
|
+
}, Mo) : (o.target.value = "", T(!1));
|
|
119
119
|
}
|
|
120
120
|
}, Do = (o) => {
|
|
121
121
|
const { width: t, height: r } = o.currentTarget;
|
|
122
122
|
console.log(o);
|
|
123
|
-
const e = bo(t, r,
|
|
123
|
+
const e = bo(t, r, l, h);
|
|
124
124
|
_((E) => {
|
|
125
|
-
const
|
|
126
|
-
return
|
|
125
|
+
const u = [...E];
|
|
126
|
+
return u[p] = e, u;
|
|
127
127
|
});
|
|
128
128
|
}, So = (o, t) => {
|
|
129
129
|
_((r) => {
|
|
@@ -137,8 +137,8 @@ function nr(n) {
|
|
|
137
137
|
const r = L[p];
|
|
138
138
|
if (!r) return !1;
|
|
139
139
|
if (Q(), n.returnCropParams === !0) {
|
|
140
|
-
const e = Ao(r, t.
|
|
141
|
-
n.onEndCrop?.(e), p >= f.length - 1 &&
|
|
140
|
+
const e = Ao(r, t.naturalWidth, t.naturalHeight);
|
|
141
|
+
n.onEndCrop?.(e), p >= f.length - 1 && w();
|
|
142
142
|
} else {
|
|
143
143
|
const e = ko(
|
|
144
144
|
t,
|
|
@@ -159,26 +159,26 @@ function nr(n) {
|
|
|
159
159
|
}, _o = async () => {
|
|
160
160
|
const o = f.slice(p);
|
|
161
161
|
try {
|
|
162
|
-
if (
|
|
162
|
+
if (lo) {
|
|
163
163
|
const t = await Promise.all(
|
|
164
164
|
o.map(
|
|
165
165
|
(r) => X(
|
|
166
166
|
r,
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
l,
|
|
168
|
+
h,
|
|
169
169
|
s,
|
|
170
170
|
!0
|
|
171
171
|
)
|
|
172
172
|
)
|
|
173
173
|
);
|
|
174
|
-
|
|
174
|
+
w(t);
|
|
175
175
|
} else {
|
|
176
176
|
const t = await Promise.all(
|
|
177
177
|
o.map(
|
|
178
178
|
(r) => X(
|
|
179
179
|
r,
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
l,
|
|
181
|
+
h,
|
|
182
182
|
s,
|
|
183
183
|
!1
|
|
184
184
|
)
|
|
@@ -190,15 +190,15 @@ function nr(n) {
|
|
|
190
190
|
x(t);
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
|
-
return /* @__PURE__ */ wo
|
|
193
|
+
return /* @__PURE__ */ To(wo, { children: [
|
|
194
194
|
/* @__PURE__ */ P(
|
|
195
195
|
Ro,
|
|
196
196
|
{
|
|
197
197
|
onChange: Po,
|
|
198
198
|
onPhotoDataLoaded: U,
|
|
199
199
|
buttonClassname: Z,
|
|
200
|
-
disabled:
|
|
201
|
-
buttonDisabled:
|
|
200
|
+
disabled: i,
|
|
201
|
+
buttonDisabled: i,
|
|
202
202
|
locale: s,
|
|
203
203
|
width: so,
|
|
204
204
|
allowedExtensions: S,
|
|
@@ -216,9 +216,9 @@ function nr(n) {
|
|
|
216
216
|
No,
|
|
217
217
|
{
|
|
218
218
|
open: mo,
|
|
219
|
-
photoSourceLoading:
|
|
219
|
+
photoSourceLoading: i,
|
|
220
220
|
loadingValue: fo,
|
|
221
|
-
errors:
|
|
221
|
+
errors: uo,
|
|
222
222
|
photoCrops: L,
|
|
223
223
|
photoSources: f,
|
|
224
224
|
onNextPhoto: Lo,
|
|
@@ -230,8 +230,8 @@ function nr(n) {
|
|
|
230
230
|
onPhotoCrop: V,
|
|
231
231
|
onPhotoLoad: Do,
|
|
232
232
|
imageRef: N,
|
|
233
|
-
minDimension:
|
|
234
|
-
aspectRatio:
|
|
233
|
+
minDimension: l,
|
|
234
|
+
aspectRatio: h,
|
|
235
235
|
locale: s,
|
|
236
236
|
circular: eo,
|
|
237
237
|
keepSelection: no,
|
|
@@ -241,7 +241,7 @@ function nr(n) {
|
|
|
241
241
|
/* @__PURE__ */ P(
|
|
242
242
|
Ho,
|
|
243
243
|
{
|
|
244
|
-
open: to &&
|
|
244
|
+
open: to && ho,
|
|
245
245
|
photoError: b,
|
|
246
246
|
onCloseErrorDialog: Eo,
|
|
247
247
|
locale: s
|
|
@@ -251,8 +251,8 @@ function nr(n) {
|
|
|
251
251
|
"canvas",
|
|
252
252
|
{
|
|
253
253
|
className: Uo(Vo.photoCropCanvas),
|
|
254
|
-
width:
|
|
255
|
-
height:
|
|
254
|
+
width: l,
|
|
255
|
+
height: l,
|
|
256
256
|
ref: R
|
|
257
257
|
}
|
|
258
258
|
)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { PhotoCropUploader, Button, CircularProgressLoader, } from './components';
|
|
1
|
+
export { PhotoCropUploader, Button, CircularProgressLoader, CodeInput } from './components';
|
|
2
2
|
export { drawCroppedImage } from './components';
|
|
3
3
|
export type { Crop, PercentCrop, PixelCrop } from 'react-image-crop';
|
|
4
|
+
export type { CodeInputProps } from './components';
|
|
4
5
|
export type { Locale } from './types';
|
|
5
6
|
export type { PhotoDataUrl, PhotoFileSize, PhotoExtension, PhotoMimeType, PhotoFileOptions, PhotoCropUploaderProps, } from './components/photo-crop-uploader/types';
|
|
6
7
|
export { EN_LOCALE, RU_LOCALE, BYTE_TO_KILOBYTE } from './constants';
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { BYTE_TO_KILOBYTE as G, EN_LOCALE as I, RU_LOCALE as
|
|
2
|
-
import { BMP_IMAGE_EXT as
|
|
1
|
+
import { BYTE_TO_KILOBYTE as G, EN_LOCALE as I, RU_LOCALE as o } from "./constants.js";
|
|
2
|
+
import { BMP_IMAGE_EXT as P, BMP_IMAGE_TYPE as T, GIF_IMAGE_EXT as M, GIF_IMAGE_TYPE as A, ICO_IMAGE_EXT as e, ICO_IMAGE_TYPE as p, JPEG_IMAGE_EXT as t, JPEG_IMAGE_TYPE as Y, JPG_IMAGE_EXT as C, JPG_IMAGE_TYPE as O, MICROSOFT_ICO_IMAGE_TYPE as m, PNG_IMAGE_EXT as X, PNG_IMAGE_TYPE as f, SVG_IMAGE_EXT as x, SVG_IMAGE_TYPE as B, WEBP_IMAGE_EXT as L, WEBP_IMAGE_TYPE as a } from "./components/photo-crop-uploader/constants.js";
|
|
3
3
|
import { PhotoCropUploader as J } from "./components/photo-crop-uploader/photo-crop-uploader.js";
|
|
4
|
-
import { Button as
|
|
5
|
-
import { CircularProgressLoader as
|
|
4
|
+
import { Button as F } from "./components/button/button.js";
|
|
5
|
+
import { CircularProgressLoader as S } from "./components/circular-progress-loader/circular-progress-loader.js";
|
|
6
|
+
import { CodeInput as l } from "./components/code-input/code-input.js";
|
|
6
7
|
import { drawCroppedImage as s } from "./components/photo-crop-uploader/utils/draw-cropped-image.js";
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
P as BMP_IMAGE_EXT,
|
|
10
|
+
T as BMP_IMAGE_TYPE,
|
|
10
11
|
G as BYTE_TO_KILOBYTE,
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
F as Button,
|
|
13
|
+
S as CircularProgressLoader,
|
|
14
|
+
l as CodeInput,
|
|
13
15
|
I as EN_LOCALE,
|
|
14
16
|
M as GIF_IMAGE_EXT,
|
|
15
17
|
A as GIF_IMAGE_TYPE,
|
|
16
18
|
e as ICO_IMAGE_EXT,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
p as ICO_IMAGE_TYPE,
|
|
20
|
+
t as JPEG_IMAGE_EXT,
|
|
21
|
+
Y as JPEG_IMAGE_TYPE,
|
|
20
22
|
C as JPG_IMAGE_EXT,
|
|
21
23
|
O as JPG_IMAGE_TYPE,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
m as MICROSOFT_ICO_IMAGE_TYPE,
|
|
25
|
+
X as PNG_IMAGE_EXT,
|
|
26
|
+
f as PNG_IMAGE_TYPE,
|
|
25
27
|
J as PhotoCropUploader,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
o as RU_LOCALE,
|
|
29
|
+
x as SVG_IMAGE_EXT,
|
|
30
|
+
B as SVG_IMAGE_TYPE,
|
|
29
31
|
L as WEBP_IMAGE_EXT,
|
|
30
32
|
a as WEBP_IMAGE_TYPE,
|
|
31
33
|
s as drawCroppedImage
|