@hai-dev/ui-kit 1.1.6 → 1.1.8

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
1
  import { jsxs as _, jsx as e } from "react/jsx-runtime";
2
2
  import { c as m } from "../../index-B2JRaoNz.js";
3
- import { PRECENT_SYMBOL as T } from "../../constants.js";
3
+ import { PERCENT_SYMBOL as T } from "../../constants.js";
4
4
  import { CIRCULAR_PROGRESS_DEFAULT_VALUE as R, PROGRESS_VARIANT_DETERMINATE as a, CIRCULAR_PROGRESS_DEFAULT_SIZE as C } from "./constants.js";
5
5
  import { B as l } from "../../Box-CykjCaXY.js";
6
6
  import { C as E } from "../../CircularProgress-CrHaMZDC.js";
@@ -1,6 +1,6 @@
1
1
  import { jsxs as L, jsx as a, Fragment as _ } from "react/jsx-runtime";
2
2
  import * as k from "react";
3
- import { S as $ } from "../../../../index-BiffjjQq.js";
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";
@@ -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";
@@ -39,7 +40,7 @@ export declare const DEFAULT_FILE_MAX_SIZE: number;
39
40
  export declare const DEFAULT_VIDEO_FILE_MAX_SIZE: number;
40
41
  export declare const PHOTO_CANVAS_CONTEXT = "2d";
41
42
  export declare const PHOTO_SMOOTHING_QUALITY = "high";
42
- export declare const PRECENT_UNIT = "%";
43
+ export declare const PERCENT_UNIT = "%";
43
44
  export declare const PIXEL_UNIT = "px";
44
45
  export declare const MS_UNIT = "ms";
45
46
  export declare const MB_UNIT = "mb";
@@ -1,75 +1,76 @@
1
1
  import { BYTE_TO_KILOBYTE as E } from "../../constants.js";
2
- const N = 1, e = 670, _ = ".jpg", I = ".jpeg", o = ".png", A = ".svg", M = ".bmp", P = ".gif", T = ".ico", n = ".webp", D = [
2
+ const D = 1, i = 670, L = 90, _ = ".jpg", I = ".jpeg", A = ".png", o = ".svg", M = ".bmp", P = ".gif", T = ".ico", n = ".webp", e = [
3
3
  _,
4
4
  I,
5
- o,
6
5
  A,
6
+ o,
7
7
  M,
8
8
  P,
9
9
  n,
10
10
  T
11
- ], G = "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", U = "video/mp4", p = "video/webm", C = [
12
- G,
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
- g
21
- ], F = {
20
+ N
21
+ ], B = {
22
22
  JPEG_IMAGE_TYPE: [_, I],
23
23
  JPG_IMAGE_TYPE: [_, I],
24
- PNG_IMAGE_TYPE: [o],
24
+ PNG_IMAGE_TYPE: [A],
25
25
  GIF_IMAGE_TYPE: [P],
26
- SVG_IMAGE_TYPE: [A],
26
+ SVG_IMAGE_TYPE: [o],
27
27
  BMP_IMAGE_TYPE: [M],
28
28
  WEBP_IMAGE_TYPE: [n],
29
29
  ICO_IMAGE_TYPE: [T],
30
30
  MICROSOFT_ICO_IMAGE_TYPE: [T]
31
- }, R = 500, B = 10 * E * E, V = 50 * E * E, a = "2d", b = "high", J = "%", v = "px", W = "ms", d = "mb", f = 1, j = 100, r = 2, w = 0.5, x = 100, H = 100, Z = 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
- N as DEFAULT_ASPECT_RATIO,
36
- B as DEFAULT_FILE_MAX_SIZE,
37
- e as DEFAULT_MIN_DIMENSION,
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
- V as DEFAULT_VIDEO_FILE_MAX_SIZE,
40
- j as FULL_CROP_SIZE,
41
- x as FULL_PROGRESS_VALUE,
40
+ a as DEFAULT_VIDEO_FILE_MAX_SIZE,
41
+ r as FULL_CROP_SIZE,
42
+ H as FULL_PROGRESS_VALUE,
42
43
  P as GIF_IMAGE_EXT,
43
- Y as GIF_IMAGE_TYPE,
44
+ S as GIF_IMAGE_TYPE,
44
45
  T as ICO_IMAGE_EXT,
45
46
  m as ICO_IMAGE_TYPE,
46
47
  I as JPEG_IMAGE_EXT,
47
- c as JPEG_IMAGE_TYPE,
48
+ s as JPEG_IMAGE_TYPE,
48
49
  _ as JPG_IMAGE_EXT,
49
- G as JPG_IMAGE_TYPE,
50
- r as MAX_ASPECT_RATIO,
51
- f as MB_FRACTION_DIGITS,
52
- d as MB_UNIT,
53
- g as MICROSOFT_ICO_IMAGE_TYPE,
54
- F as MIME_TO_EXT,
55
- w as MIN_ASPECT_RATIO,
56
- L as MP4_VIDEO_EXT,
57
- U as MP4_VIDEO_TYPE,
58
- W as MS_UNIT,
59
- a as PHOTO_CANVAS_CONTEXT,
60
- H as PHOTO_LOADING_DELAY,
61
- b as PHOTO_SMOOTHING_QUALITY,
62
- v as PIXEL_UNIT,
63
- o as PNG_IMAGE_EXT,
64
- s as PNG_IMAGE_TYPE,
65
- J as PRECENT_UNIT,
66
- Z as RESET_DATA_DELAY,
67
- D as SUPPORTED_IMAGE_EXTENSIONS,
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
+ v as PERCENT_UNIT,
61
+ b as PHOTO_CANVAS_CONTEXT,
62
+ Z as PHOTO_LOADING_DELAY,
63
+ J as PHOTO_SMOOTHING_QUALITY,
64
+ W as PIXEL_UNIT,
65
+ A as PNG_IMAGE_EXT,
66
+ G as PNG_IMAGE_TYPE,
67
+ h as RESET_DATA_DELAY,
68
+ e as SUPPORTED_IMAGE_EXTENSIONS,
68
69
  C as SUPPORTED_IMAGE_MIME_TYPES,
69
- A as SVG_IMAGE_EXT,
70
+ o as SVG_IMAGE_EXT,
70
71
  t as SVG_IMAGE_TYPE,
71
72
  X as WEBM_VIDEO_EXT,
72
73
  p as WEBM_VIDEO_TYPE,
73
74
  n as WEBP_IMAGE_EXT,
74
- S as WEBP_IMAGE_TYPE
75
+ Y as WEBP_IMAGE_TYPE
75
76
  };
@@ -1,222 +1,242 @@
1
- import { jsxs as yo, Fragment as Mo, jsx as U } from "react/jsx-runtime";
2
- import { useState as i, useRef as w } from "react";
3
- import { D as No } from "../../index-BiffjjQq.js";
4
- import { c as Vo } from "../../index-B2JRaoNz.js";
5
- import { localizedText as bo } from "./locale.js";
6
- import { EN_LOCALE as Ho } from "../../constants.js";
7
- import { DEFAULT_MIN_DIMENSION as ko, DEFAULT_ASPECT_RATIO as zo, DEFAULT_TIMEOUT as jo, DEFAULT_FILE_MAX_SIZE as Wo, DEFAULT_VIDEO_FILE_MAX_SIZE as Bo, FULL_PROGRESS_VALUE as Q, PHOTO_LOADING_DELAY as Go, RESET_DATA_DELAY as d } from "./constants.js";
8
- import { UploadDialog as Xo } from "./components/upload-dialog/upload-dialog.js";
9
- import { UploadButton as Yo } from "./components/upload-button/upload-button.js";
10
- import { ErrorUploadDialog as Zo } 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 qo } from "./utils/get-photo-crop.js";
16
- import { getCroppedSource as Jo } 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 Ko = "_photoCropCanvas_1i4lr_1", Qo = {
19
- photoCropCanvas: Ko
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 $, 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 oo } from "./utils/is-video.js";
12
+ import { validateVideoFile as eo } from "./utils/validate-video-file.js";
13
+ import { validatePhotoFile as to } from "./utils/validate-photo-file.js";
14
+ import { readPhoto as ro } 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 no } from "./utils/get-default-cropped-photo.js";
18
+ import '../../assets/photo-crop-uploader.css';const ee = "_photoCropCanvas_1i4lr_1", te = {
19
+ photoCropCanvas: ee
20
20
  };
21
- function Ee(a) {
21
+ function Le(a) {
22
22
  const {
23
23
  buttonClassname: so = "",
24
- onStartUpload: no = () => {
24
+ onStartUpload: ao = () => {
25
25
  },
26
- onEndUpload: ao = () => {
26
+ onEndUpload: io = () => {
27
27
  },
28
- onError: io = () => {
28
+ onError: lo = () => {
29
29
  },
30
- onStartCrop: lo = () => {
30
+ onStartCrop: co = () => {
31
31
  },
32
- onDragOver: co = () => {
32
+ onDragOver: po = () => {
33
33
  },
34
- onDragLeave: po = () => {
34
+ onDragLeave: uo = () => {
35
35
  },
36
- onDragDrop: uo = () => {
36
+ onDragDrop: fo = () => {
37
37
  },
38
- showErrorPopup: fo = !1,
39
- minDimension: l = ko,
40
- aspectRatio: C = zo,
41
- locale: s = Ho,
42
- timeout: M = jo,
43
- fileMaxSize: N = Wo,
44
- videoFileMaxSize: V = Bo,
45
- allowedExtensions: A,
46
- allowedMimeTypes: b,
47
- circular: ho,
48
- width: mo,
49
- keepSelection: Co,
50
- uploadButton: go,
38
+ showErrorPopup: ho = !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: mo,
48
+ usePercentCrop: b = !0,
49
+ width: Co,
50
+ keepSelection: go,
51
+ uploadButton: Eo,
51
52
  multiple: g = !1,
52
- fromSources: H,
53
+ fromSources: k,
53
54
  withVideoUploaded: v = !1,
54
- returnCropParams: Eo = !1,
55
- dialogClassname: k,
56
- ...Po
55
+ returnCropParams: Po = !1,
56
+ dialogClassname: z,
57
+ defaultDimension: Do = Zo,
58
+ ...So
57
59
  } = a, {
58
- onEndCrop: $o,
59
- onClose: oe,
60
- ...Do
61
- } = Po, [So, E] = i(!1), [P, D] = i([]), [x, I] = i([]), f = w([]), h = w([]), [p, z] = i(0), j = w(null), W = w(null), [c, O] = i(!1), [Lo, B] = i(0), [G, X] = i(""), [_o, S] = i([]), [To, Y] = i(!1), Uo = So || c && g, wo = () => {
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, j] = i(0), W = A(null), B = A(null), [c, O] = i(!1), [To, G] = i(0), [X, Y] = i(""), [Uo, S] = i([]), [Ao, Z] = i(!1), wo = _o || c && g, vo = () => {
62
64
  S([]);
63
- }, F = (o = []) => {
65
+ }, F = (e = []) => {
64
66
  c || (a.returnCropParams === !0 && a.onClose?.(
65
- o,
67
+ e,
66
68
  f.current,
67
69
  h.current
68
70
  ), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
69
71
  f.current = [], h.current = [];
70
72
  }, d));
71
- }, R = (o = []) => {
73
+ }, R = (e = []) => {
72
74
  c || (a.returnCropParams || a.onClose?.(
73
- o,
75
+ e,
74
76
  f.current,
75
77
  h.current
76
78
  ), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
77
79
  f.current = [], h.current = [];
78
80
  }, d));
79
- }, Z = () => {
81
+ }, q = () => {
80
82
  c || (a.returnCropParams === !0 ? F([]) : R([]));
81
- }, Ao = () => {
82
- Y(!1);
83
- }, L = (o, t = o, e = [], r = !1) => {
84
- ao(o), X(""), D(o), I(Array(o.length)), z(0), E(!0), f.current = t, h.current = e, !o.length && !r && Z();
85
- }, y = (o) => {
86
- o instanceof Error && (console.warn(o.message), io(o), X(o.message), Y(!0), D([]), E(!1), f.current = [], h.current = []);
87
- }, vo = async (o) => {
88
- const { files: t } = o.target;
83
+ }, Io = () => {
84
+ Z(!1);
85
+ }, L = (e, t = e, o = [], r = !1) => {
86
+ io(e), Y(""), D(e), x(Array(e.length)), j(0), E(!0), f.current = t, h.current = o, !e.length && !r && q();
87
+ }, y = (e) => {
88
+ e instanceof Error && (console.warn(e.message), lo(e), Y(e.message), Z(!0), D([]), E(!1), f.current = [], h.current = []);
89
+ }, xo = async (e) => {
90
+ const { files: t } = e.target;
89
91
  if (t?.length && !c)
90
92
  try {
91
- if (O(!0), no(), g) {
92
- const e = Array.from(t), r = Q / e.length, _ = [], u = [], J = [], T = [];
93
- for (const m of e) {
94
- const Ro = $(m);
93
+ if (O(!0), ao(), g) {
94
+ const o = Array.from(t), r = $ / o.length, _ = [], u = [], K = [], T = [];
95
+ for (const m of o) {
96
+ const Mo = oo(m);
95
97
  try {
96
- if (v && Ro) {
97
- oo(m, V, s);
98
- const n = URL.createObjectURL(m);
99
- J.push(u.length), u.push(n);
98
+ if (v && Mo) {
99
+ eo(m, H, n);
100
+ const s = URL.createObjectURL(m);
101
+ K.push(u.length), u.push(s);
100
102
  } else {
101
- eo(
103
+ to(
102
104
  m,
103
105
  {
104
106
  maxSize: N,
105
- allowedExtensions: A,
106
- allowedMimeTypes: b
107
+ allowedExtensions: w,
108
+ allowedMimeTypes: V
107
109
  },
108
- s
110
+ n
109
111
  );
110
- const n = await to(
112
+ const s = await ro(
111
113
  m,
112
114
  l,
113
- s,
115
+ n,
114
116
  M
115
117
  );
116
- _.push(n), u.push(n);
118
+ _.push(s), u.push(s);
117
119
  }
118
- } catch (n) {
119
- let K = "";
120
- n instanceof Error && (K = n.message), T.push({
120
+ } catch (s) {
121
+ let Q = "";
122
+ s instanceof Error && (Q = s.message), T.push({
121
123
  photoName: m.name,
122
- errorMessage: K
124
+ errorMessage: Q
123
125
  });
124
126
  }
125
- B(
126
- (n) => Math.min(Q, n + r)
127
- ), await new Promise((n) => setTimeout(n, 0));
127
+ G(
128
+ (s) => Math.min($, s + r)
129
+ ), await new Promise((s) => setTimeout(s, 0));
128
130
  }
129
- if (H?.length)
131
+ if (k?.length)
130
132
  throw new Error(T[0]?.errorMessage);
131
- S(T), L(_, u, J, T.length > 0);
133
+ S(T), L(_, u, K, T.length > 0);
132
134
  } else {
133
- const e = t[0];
134
- if (v && $(e)) {
135
- oo(e, V, s);
136
- const r = URL.createObjectURL(e);
135
+ const o = t[0];
136
+ if (v && oo(o)) {
137
+ eo(o, H, n);
138
+ const r = URL.createObjectURL(o);
137
139
  L([], [r], [0]);
138
140
  } else {
139
- eo(
140
- e,
141
- { maxSize: N, allowedExtensions: A, allowedMimeTypes: b },
142
- s
141
+ to(
142
+ o,
143
+ { maxSize: N, allowedExtensions: w, allowedMimeTypes: V },
144
+ n
143
145
  );
144
- const r = await to(e, l, s, M);
146
+ const r = await ro(o, l, n, M);
145
147
  L([r]);
146
148
  }
147
149
  }
148
- } catch (e) {
149
- y(e);
150
+ } catch (o) {
151
+ y(o);
150
152
  } finally {
151
153
  g ? setTimeout(() => {
152
- o.target.value = "", B(0), O(!1);
153
- }, Go) : (o.target.value = "", O(!1));
154
+ e.target.value = "", G(0), O(!1);
155
+ }, qo) : (e.target.value = "", O(!1));
154
156
  }
155
- }, xo = (o) => {
156
- const { width: t, height: e } = o.currentTarget, r = qo(t, e, l, C);
157
- I((_) => {
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((_) => {
158
167
  const u = [..._];
159
168
  return u[p] = r, u;
160
169
  });
161
- }, Io = (o, t) => {
162
- I((e) => {
163
- const r = [...e];
170
+ }, Fo = (e, t) => {
171
+ x((o) => {
172
+ const r = [...o];
164
173
  return r[p] = t, r;
165
174
  });
166
- }, q = () => {
167
- const o = W.current, t = j.current;
168
- if (o && t && x)
175
+ }, J = () => {
176
+ const e = B.current, t = W.current;
177
+ if (e && t && I)
169
178
  try {
170
- const e = x[p];
171
- if (!e) return !1;
172
- if (lo(), a.returnCropParams === !0) {
173
- const r = No(
174
- e,
175
- t.naturalWidth,
176
- t.naturalHeight
177
- );
178
- a.onEndCrop?.(r), p >= P.length - 1 && F();
179
+ const o = I[p];
180
+ if (!o) return !1;
181
+ if (co(), a.returnCropParams === !0) {
182
+ if (b) {
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();
179
198
  } else {
180
- const r = Jo(
199
+ const r = oe(
181
200
  t,
182
- o,
183
201
  e,
184
- s
202
+ o,
203
+ n
185
204
  );
186
205
  a.onEndCrop?.(r), p >= P.length - 1 && R();
187
206
  }
188
207
  return !0;
189
- } catch (e) {
190
- return e instanceof Error && (console.warn(e), y(e)), !1;
208
+ } catch (o) {
209
+ return o instanceof Error && (console.warn(o), y(o)), !1;
191
210
  }
192
211
  else
193
212
  return !1;
194
- }, Oo = () => {
195
- q() && z((t) => t + 1);
196
- }, Fo = async () => {
197
- const o = P.slice(p);
213
+ }, Ro = () => {
214
+ J() && j((t) => t + 1);
215
+ }, yo = async () => {
216
+ const e = P.slice(p);
198
217
  try {
199
- if (Eo) {
218
+ if (Po) {
200
219
  const t = await Promise.all(
201
- o.map(
202
- (e) => ro(
203
- e,
220
+ e.map(
221
+ (o) => no(
222
+ o,
204
223
  l,
205
224
  C,
206
- s,
207
- !0
225
+ n,
226
+ !0,
227
+ b
208
228
  )
209
229
  )
210
230
  );
211
231
  F(t);
212
232
  } else {
213
233
  const t = await Promise.all(
214
- o.map(
215
- (e) => ro(
216
- e,
234
+ e.map(
235
+ (o) => no(
236
+ o,
217
237
  l,
218
238
  C,
219
- s,
239
+ n,
220
240
  !1
221
241
  )
222
242
  )
@@ -227,77 +247,77 @@ function Ee(a) {
227
247
  y(t);
228
248
  }
229
249
  };
230
- return /* @__PURE__ */ yo(Mo, { children: [
250
+ return /* @__PURE__ */ No(Ho, { children: [
231
251
  /* @__PURE__ */ U(
232
- Yo,
252
+ Ko,
233
253
  {
234
- onChange: vo,
254
+ onChange: xo,
235
255
  onPhotoDataLoaded: L,
236
256
  buttonClassname: so,
237
257
  disabled: c,
238
258
  buttonDisabled: c,
239
- locale: s,
240
- width: mo,
241
- allowedExtensions: A,
242
- onDragDrop: uo,
243
- onDragLeave: po,
244
- onDragOver: co,
245
- button: go,
259
+ locale: n,
260
+ width: Co,
261
+ allowedExtensions: w,
262
+ onDragDrop: fo,
263
+ onDragLeave: uo,
264
+ onDragOver: po,
265
+ button: Eo,
246
266
  multiple: g,
247
- fromSources: H,
267
+ fromSources: k,
248
268
  withVideoUploaded: v,
249
- ...Do,
250
- children: bo[s].upload
269
+ ...Lo,
270
+ children: zo[n].upload
251
271
  }
252
272
  ),
253
273
  /* @__PURE__ */ U(
254
- Xo,
274
+ Jo,
255
275
  {
256
- open: Uo,
257
- className: k,
276
+ open: wo,
277
+ className: z,
258
278
  photoSourceLoading: c,
259
- loadingValue: Lo,
260
- errors: _o,
261
- photoCrops: x,
279
+ loadingValue: To,
280
+ errors: Uo,
281
+ photoCrops: I,
262
282
  photoSources: P,
263
- onNextPhoto: Oo,
264
- onSkipCrop: Fo,
265
- onClearErrors: wo,
266
- photoError: G,
267
- onCloseDialogHandler: Z,
268
- onCropChange: Io,
269
- onPhotoCrop: q,
270
- onPhotoLoad: xo,
271
- imageRef: j,
283
+ onNextPhoto: Ro,
284
+ onSkipCrop: yo,
285
+ onClearErrors: vo,
286
+ photoError: X,
287
+ onCloseDialogHandler: q,
288
+ onCropChange: Fo,
289
+ onPhotoCrop: J,
290
+ onPhotoLoad: Oo,
291
+ imageRef: W,
272
292
  minDimension: l,
273
293
  aspectRatio: C,
274
- locale: s,
275
- circular: ho,
276
- keepSelection: Co,
294
+ locale: n,
295
+ circular: mo,
296
+ keepSelection: go,
277
297
  photoIndex: p
278
298
  }
279
299
  ),
280
300
  /* @__PURE__ */ U(
281
- Zo,
301
+ Qo,
282
302
  {
283
- className: k,
284
- open: fo && To,
285
- photoError: G,
286
- onCloseErrorDialog: Ao,
287
- locale: s
303
+ className: z,
304
+ open: ho && Ao,
305
+ photoError: X,
306
+ onCloseErrorDialog: Io,
307
+ locale: n
288
308
  }
289
309
  ),
290
310
  /* @__PURE__ */ U(
291
311
  "canvas",
292
312
  {
293
- className: Vo(Qo.photoCropCanvas),
313
+ className: ko(te.photoCropCanvas),
294
314
  width: l,
295
315
  height: l,
296
- ref: W
316
+ ref: B
297
317
  }
298
318
  )
299
319
  ] });
300
320
  }
301
321
  export {
302
- Ee as PhotoCropUploader
322
+ Le as PhotoCropUploader
303
323
  };
@@ -1,5 +1,5 @@
1
1
  import { DragEvent, InputHTMLAttributes, ReactNode } from 'react';
2
- import { PixelCrop } from 'react-image-crop';
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: PixelCrop) => unknown;
21
- onClose?: (skipPhotosData: PixelCrop[], sourcesData: PhotoDataUrl[], videoSourceIndexes: number[]) => unknown;
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,8 +37,10 @@ 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;
44
46
  videoFileMaxSize?: number;
@@ -1,4 +1,4 @@
1
- import { D as w } from "../../../index-BiffjjQq.js";
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-BiffjjQq.js";
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,6 +1,6 @@
1
- import { PixelCrop } from 'react-image-crop';
1
+ import { Crop } from 'react-image-crop';
2
2
  import { Locale } from '../../../types';
3
3
  import { PhotoDataUrl } from '../types';
4
- export declare function getDefaultCroppedPhoto(photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: true): Promise<PixelCrop>;
5
- export declare function getDefaultCroppedPhoto(photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: false): Promise<PhotoDataUrl>;
6
- export declare function getDefaultCroppedPhoto(photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: boolean): Promise<PhotoDataUrl | PixelCrop>;
4
+ export declare function getDefaultCroppedPhoto(photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: true, isPercent?: boolean): Promise<Crop>;
5
+ export declare function getDefaultCroppedPhoto(photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: false, isPercent?: boolean): Promise<PhotoDataUrl>;
6
+ export declare function getDefaultCroppedPhoto(photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: boolean, isPercent?: boolean): Promise<PhotoDataUrl | Crop>;
@@ -1,41 +1,41 @@
1
- import { D as u } from "../../../index-BiffjjQq.js";
2
- import { getPhotoCrop as g } from "./get-photo-crop.js";
1
+ import { v as g, D as v } from "../../../index-CcueJ2sD.js";
2
+ import { getPhotoCrop as w } from "./get-photo-crop.js";
3
3
  import { getCroppedSource as C } from "./get-cropped-source.js";
4
- import { localizedText as l } from "../locale.js";
5
- function x(a, i, m, e, s) {
6
- return new Promise((n, p) => {
7
- const o = new Image(), d = document.createElement("canvas");
4
+ import { localizedText as E } from "../locale.js";
5
+ function L(a, i, m, n, s, d) {
6
+ return new Promise((c, p) => {
7
+ const o = new Image(), h = document.createElement("canvas");
8
8
  o.src = a, o.addEventListener("load", () => {
9
- const { width: r, height: c } = o;
9
+ const { width: r, height: e } = o;
10
10
  try {
11
- const t = g(
11
+ const t = w(
12
12
  r,
13
- c,
13
+ e,
14
14
  i,
15
15
  m,
16
16
  !0
17
17
  );
18
18
  if (s) {
19
- const f = u(t, r, c);
20
- n(f);
19
+ const u = d ? g(t, r, e) : v(t, r, e);
20
+ c(u);
21
21
  return;
22
22
  }
23
- const h = C(
23
+ const f = C(
24
24
  o,
25
- d,
25
+ h,
26
26
  t,
27
- e
27
+ n
28
28
  );
29
- n(h);
29
+ c(f);
30
30
  } catch (t) {
31
31
  p(t);
32
32
  }
33
33
  }), o.addEventListener("error", () => {
34
- const r = new Error(l[e]["paint-error"]);
34
+ const r = new Error(E[n]["paint-error"]);
35
35
  p(r);
36
36
  });
37
37
  });
38
38
  }
39
39
  export {
40
- x as getDefaultCroppedPhoto
40
+ L as getDefaultCroppedPhoto
41
41
  };
@@ -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 _, 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 = _(
1
+ import { B as _, L as N } from "../../../index-CcueJ2sD.js";
2
+ import { DEFAULT_MIN_DIMENSION as n, DEFAULT_ASPECT_RATIO as A, FULL_CROP_SIZE as E, PERCENT_UNIT as t } from "../constants.js";
3
+ const M = (r, c, C = n, I = A, P = !1, o) => {
4
+ const L = r / c / I, T = C / r * E, e = C / c * E;
5
+ let p;
6
+ return o && o >= T && o >= e ? L <= 1 ? p = _(
5
7
  {
6
- unit: s,
7
- width: e ? o : p,
8
- height: e ? o : I
8
+ unit: t,
9
+ width: o
9
10
  },
10
- n,
11
+ I,
11
12
  r,
12
- t
13
- );
14
- return C(E, r, t);
13
+ c
14
+ ) : p = _(
15
+ {
16
+ unit: t,
17
+ height: o
18
+ },
19
+ I,
20
+ r,
21
+ c
22
+ ) : p = _(
23
+ {
24
+ unit: t,
25
+ width: P ? E : T,
26
+ height: P ? E : e
27
+ },
28
+ I,
29
+ r,
30
+ c
31
+ ), N(p, r, c);
15
32
  };
16
33
  export {
17
- U as getPhotoCrop
34
+ M as getPhotoCrop
18
35
  };
@@ -1,5 +1,5 @@
1
1
  export declare const EN_LOCALE = "en";
2
2
  export declare const RU_LOCALE = "ru";
3
3
  export declare const BYTE_TO_KILOBYTE = 1024;
4
- export declare const PRECENT_SYMBOL = "%";
4
+ export declare const PERCENT_SYMBOL = "%";
5
5
  export declare const DASH_SYMBOL = "-";
package/dist/constants.js CHANGED
@@ -3,6 +3,6 @@ export {
3
3
  n as BYTE_TO_KILOBYTE,
4
4
  t as DASH_SYMBOL,
5
5
  E as EN_LOCALE,
6
- o as PRECENT_SYMBOL,
6
+ o as PERCENT_SYMBOL,
7
7
  L as RU_LOCALE
8
8
  };
@@ -427,5 +427,6 @@ export {
427
427
  N as B,
428
428
  C as D,
429
429
  O as L,
430
- B as S
430
+ B as S,
431
+ f as v
431
432
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hai-dev/ui-kit",
3
3
  "private": false,
4
- "version": "1.1.6",
4
+ "version": "1.1.8",
5
5
  "license": "UNLICENSED",
6
6
  "author": {
7
7
  "name": "Vladislav Knitrunov",