@hai-dev/ui-kit 1.1.7 → 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";
@@ -40,7 +40,7 @@ export declare const DEFAULT_FILE_MAX_SIZE: number;
40
40
  export declare const DEFAULT_VIDEO_FILE_MAX_SIZE: number;
41
41
  export declare const PHOTO_CANVAS_CONTEXT = "2d";
42
42
  export declare const PHOTO_SMOOTHING_QUALITY = "high";
43
- export declare const PRECENT_UNIT = "%";
43
+ export declare const PERCENT_UNIT = "%";
44
44
  export declare const PIXEL_UNIT = "px";
45
45
  export declare const MS_UNIT = "ms";
46
46
  export declare const MB_UNIT = "mb";
@@ -57,13 +57,13 @@ export {
57
57
  U as MP4_VIDEO_EXT,
58
58
  F as MP4_VIDEO_TYPE,
59
59
  d as MS_UNIT,
60
+ v as PERCENT_UNIT,
60
61
  b as PHOTO_CANVAS_CONTEXT,
61
62
  Z as PHOTO_LOADING_DELAY,
62
63
  J as PHOTO_SMOOTHING_QUALITY,
63
64
  W as PIXEL_UNIT,
64
65
  A as PNG_IMAGE_EXT,
65
66
  G as PNG_IMAGE_TYPE,
66
- v as PRECENT_UNIT,
67
67
  h as RESET_DATA_DELAY,
68
68
  e as SUPPORTED_IMAGE_EXTENSIONS,
69
69
  C as SUPPORTED_IMAGE_MIME_TYPES,
@@ -4,38 +4,38 @@ import { v as Vo, D as bo } from "../../index-CcueJ2sD.js";
4
4
  import { c as ko } from "../../index-B2JRaoNz.js";
5
5
  import { localizedText as zo } from "./locale.js";
6
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 Q, PHOTO_LOADING_DELAY as qo, RESET_DATA_DELAY as d } 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
8
  import { UploadDialog as Jo } from "./components/upload-dialog/upload-dialog.js";
9
9
  import { UploadButton as Ko } from "./components/upload-button/upload-button.js";
10
10
  import { ErrorUploadDialog as Qo } 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";
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
15
  import { getPhotoCrop as $o } from "./utils/get-photo-crop.js";
16
16
  import { getCroppedSource as oe } from "./utils/get-cropped-source.js";
17
- import { getDefaultCroppedPhoto as ro } from "./utils/get-default-cropped-photo.js";
17
+ import { getDefaultCroppedPhoto as no } from "./utils/get-default-cropped-photo.js";
18
18
  import '../../assets/photo-crop-uploader.css';const ee = "_photoCropCanvas_1i4lr_1", te = {
19
19
  photoCropCanvas: ee
20
20
  };
21
21
  function Le(a) {
22
22
  const {
23
- buttonClassname: no = "",
24
- onStartUpload: so = () => {
23
+ buttonClassname: so = "",
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,
38
+ showErrorPopup: ho = !1,
39
39
  minDimension: l = Wo,
40
40
  aspectRatio: C = Bo,
41
41
  locale: n = jo,
@@ -44,23 +44,23 @@ function Le(a) {
44
44
  videoFileMaxSize: H = Yo,
45
45
  allowedExtensions: w,
46
46
  allowedMimeTypes: V,
47
- circular: ho,
48
- usePercentCrop: mo = !0,
47
+ circular: mo,
48
+ usePercentCrop: b = !0,
49
49
  width: Co,
50
50
  keepSelection: go,
51
51
  uploadButton: Eo,
52
52
  multiple: g = !1,
53
- fromSources: b,
53
+ fromSources: k,
54
54
  withVideoUploaded: v = !1,
55
55
  returnCropParams: Po = !1,
56
- dialogClassname: k,
56
+ dialogClassname: z,
57
57
  defaultDimension: Do = Zo,
58
58
  ...So
59
59
  } = a, {
60
60
  onEndCrop: re,
61
61
  onClose: ne,
62
62
  ...Lo
63
- } = So, [_o, E] = i(!1), [P, D] = i([]), [I, x] = i([]), f = A([]), h = A([]), [p, z] = i(0), j = A(null), W = A(null), [c, O] = i(!1), [To, B] = i(0), [G, X] = i(""), [Uo, S] = i([]), [Ao, Y] = i(!1), wo = _o || c && g, vo = () => {
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 = () => {
64
64
  S([]);
65
65
  }, F = (e = []) => {
66
66
  c || (a.returnCropParams === !0 && a.onClose?.(
@@ -78,29 +78,29 @@ function Le(a) {
78
78
  ), E(!1), setTimeout(() => S([]), d), setTimeout(() => D([]), d), setTimeout(() => {
79
79
  f.current = [], h.current = [];
80
80
  }, d));
81
- }, Z = () => {
81
+ }, q = () => {
82
82
  c || (a.returnCropParams === !0 ? F([]) : R([]));
83
83
  }, Io = () => {
84
- Y(!1);
84
+ Z(!1);
85
85
  }, L = (e, t = e, o = [], r = !1) => {
86
- ao(e), X(""), D(e), x(Array(e.length)), z(0), E(!0), f.current = t, h.current = o, !e.length && !r && Z();
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
87
  }, y = (e) => {
88
- e instanceof Error && (console.warn(e.message), io(e), X(e.message), Y(!0), D([]), E(!1), f.current = [], h.current = []);
88
+ e instanceof Error && (console.warn(e.message), lo(e), Y(e.message), Z(!0), D([]), E(!1), f.current = [], h.current = []);
89
89
  }, xo = async (e) => {
90
90
  const { files: t } = e.target;
91
91
  if (t?.length && !c)
92
92
  try {
93
- if (O(!0), so(), g) {
94
- const o = Array.from(t), r = Q / o.length, _ = [], u = [], J = [], T = [];
93
+ if (O(!0), ao(), g) {
94
+ const o = Array.from(t), r = $ / o.length, _ = [], u = [], K = [], T = [];
95
95
  for (const m of o) {
96
- const Mo = $(m);
96
+ const Mo = oo(m);
97
97
  try {
98
98
  if (v && Mo) {
99
- oo(m, H, n);
99
+ eo(m, H, n);
100
100
  const s = URL.createObjectURL(m);
101
- J.push(u.length), u.push(s);
101
+ K.push(u.length), u.push(s);
102
102
  } else {
103
- eo(
103
+ to(
104
104
  m,
105
105
  {
106
106
  maxSize: N,
@@ -109,7 +109,7 @@ function Le(a) {
109
109
  },
110
110
  n
111
111
  );
112
- const s = await to(
112
+ const s = await ro(
113
113
  m,
114
114
  l,
115
115
  n,
@@ -118,32 +118,32 @@ function Le(a) {
118
118
  _.push(s), u.push(s);
119
119
  }
120
120
  } catch (s) {
121
- let K = "";
122
- s instanceof Error && (K = s.message), T.push({
121
+ let Q = "";
122
+ s instanceof Error && (Q = s.message), T.push({
123
123
  photoName: m.name,
124
- errorMessage: K
124
+ errorMessage: Q
125
125
  });
126
126
  }
127
- B(
128
- (s) => Math.min(Q, s + r)
127
+ G(
128
+ (s) => Math.min($, s + r)
129
129
  ), await new Promise((s) => setTimeout(s, 0));
130
130
  }
131
- if (b?.length)
131
+ if (k?.length)
132
132
  throw new Error(T[0]?.errorMessage);
133
- S(T), L(_, u, J, T.length > 0);
133
+ S(T), L(_, u, K, T.length > 0);
134
134
  } else {
135
135
  const o = t[0];
136
- if (v && $(o)) {
137
- oo(o, H, n);
136
+ if (v && oo(o)) {
137
+ eo(o, H, n);
138
138
  const r = URL.createObjectURL(o);
139
139
  L([], [r], [0]);
140
140
  } else {
141
- eo(
141
+ to(
142
142
  o,
143
143
  { maxSize: N, allowedExtensions: w, allowedMimeTypes: V },
144
144
  n
145
145
  );
146
- const r = await to(o, l, n, M);
146
+ const r = await ro(o, l, n, M);
147
147
  L([r]);
148
148
  }
149
149
  }
@@ -151,7 +151,7 @@ function Le(a) {
151
151
  y(o);
152
152
  } finally {
153
153
  g ? setTimeout(() => {
154
- e.target.value = "", B(0), O(!1);
154
+ e.target.value = "", G(0), O(!1);
155
155
  }, qo) : (e.target.value = "", O(!1));
156
156
  }
157
157
  }, Oo = (e) => {
@@ -172,14 +172,14 @@ function Le(a) {
172
172
  const r = [...o];
173
173
  return r[p] = t, r;
174
174
  });
175
- }, q = () => {
176
- const e = W.current, t = j.current;
175
+ }, J = () => {
176
+ const e = B.current, t = W.current;
177
177
  if (e && t && I)
178
178
  try {
179
179
  const o = I[p];
180
180
  if (!o) return !1;
181
- if (lo(), a.returnCropParams === !0) {
182
- if (mo) {
181
+ if (co(), a.returnCropParams === !0) {
182
+ if (b) {
183
183
  const r = Vo(
184
184
  o,
185
185
  t.naturalWidth,
@@ -211,19 +211,20 @@ function Le(a) {
211
211
  else
212
212
  return !1;
213
213
  }, Ro = () => {
214
- q() && z((t) => t + 1);
214
+ J() && j((t) => t + 1);
215
215
  }, yo = async () => {
216
216
  const e = P.slice(p);
217
217
  try {
218
218
  if (Po) {
219
219
  const t = await Promise.all(
220
220
  e.map(
221
- (o) => ro(
221
+ (o) => no(
222
222
  o,
223
223
  l,
224
224
  C,
225
225
  n,
226
- !0
226
+ !0,
227
+ b
227
228
  )
228
229
  )
229
230
  );
@@ -231,7 +232,7 @@ function Le(a) {
231
232
  } else {
232
233
  const t = await Promise.all(
233
234
  e.map(
234
- (o) => ro(
235
+ (o) => no(
235
236
  o,
236
237
  l,
237
238
  C,
@@ -252,18 +253,18 @@ function Le(a) {
252
253
  {
253
254
  onChange: xo,
254
255
  onPhotoDataLoaded: L,
255
- buttonClassname: no,
256
+ buttonClassname: so,
256
257
  disabled: c,
257
258
  buttonDisabled: c,
258
259
  locale: n,
259
260
  width: Co,
260
261
  allowedExtensions: w,
261
- onDragDrop: uo,
262
- onDragLeave: po,
263
- onDragOver: co,
262
+ onDragDrop: fo,
263
+ onDragLeave: uo,
264
+ onDragOver: po,
264
265
  button: Eo,
265
266
  multiple: g,
266
- fromSources: b,
267
+ fromSources: k,
267
268
  withVideoUploaded: v,
268
269
  ...Lo,
269
270
  children: zo[n].upload
@@ -273,7 +274,7 @@ function Le(a) {
273
274
  Jo,
274
275
  {
275
276
  open: wo,
276
- className: k,
277
+ className: z,
277
278
  photoSourceLoading: c,
278
279
  loadingValue: To,
279
280
  errors: Uo,
@@ -282,16 +283,16 @@ function Le(a) {
282
283
  onNextPhoto: Ro,
283
284
  onSkipCrop: yo,
284
285
  onClearErrors: vo,
285
- photoError: G,
286
- onCloseDialogHandler: Z,
286
+ photoError: X,
287
+ onCloseDialogHandler: q,
287
288
  onCropChange: Fo,
288
- onPhotoCrop: q,
289
+ onPhotoCrop: J,
289
290
  onPhotoLoad: Oo,
290
- imageRef: j,
291
+ imageRef: W,
291
292
  minDimension: l,
292
293
  aspectRatio: C,
293
294
  locale: n,
294
- circular: ho,
295
+ circular: mo,
295
296
  keepSelection: go,
296
297
  photoIndex: p
297
298
  }
@@ -299,9 +300,9 @@ function Le(a) {
299
300
  /* @__PURE__ */ U(
300
301
  Qo,
301
302
  {
302
- className: k,
303
- open: fo && Ao,
304
- photoError: G,
303
+ className: z,
304
+ open: ho && Ao,
305
+ photoError: X,
305
306
  onCloseErrorDialog: Io,
306
307
  locale: n
307
308
  }
@@ -312,7 +313,7 @@ function Le(a) {
312
313
  className: ko(te.photoCropCanvas),
313
314
  width: l,
314
315
  height: l,
315
- ref: W
316
+ ref: B
316
317
  }
317
318
  )
318
319
  ] });
@@ -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-CcueJ2sD.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,29 +1,29 @@
1
- import { B as E, L as N } from "../../../index-CcueJ2sD.js";
2
- import { DEFAULT_MIN_DIMENSION as n, DEFAULT_ASPECT_RATIO as A, FULL_CROP_SIZE as t, PRECENT_UNIT as _ } from "../constants.js";
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
3
  const M = (r, c, C = n, I = A, P = !1, o) => {
4
- const L = r / c / I, T = C / r * t, e = C / c * t;
4
+ const L = r / c / I, T = C / r * E, e = C / c * E;
5
5
  let p;
6
- return o && o >= T && o >= e ? L <= 1 ? p = E(
6
+ return o && o >= T && o >= e ? L <= 1 ? p = _(
7
7
  {
8
- unit: _,
8
+ unit: t,
9
9
  width: o
10
10
  },
11
11
  I,
12
12
  r,
13
13
  c
14
- ) : p = E(
14
+ ) : p = _(
15
15
  {
16
- unit: _,
16
+ unit: t,
17
17
  height: o
18
18
  },
19
19
  I,
20
20
  r,
21
21
  c
22
- ) : p = E(
22
+ ) : p = _(
23
23
  {
24
- unit: _,
25
- width: P ? t : T,
26
- height: P ? t : e
24
+ unit: t,
25
+ width: P ? E : T,
26
+ height: P ? E : e
27
27
  },
28
28
  I,
29
29
  r,
@@ -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
  };
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.7",
4
+ "version": "1.1.8",
5
5
  "license": "UNLICENSED",
6
6
  "author": {
7
7
  "name": "Vladislav Knitrunov",