@hai-dev/ui-kit 1.0.12 → 1.1.0

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.
Files changed (70) hide show
  1. package/dist/{Box-D8oKffw9.js → Box-CykjCaXY.js} +21 -22
  2. package/dist/{Button-BBF8hp7e.js → Button-CcvrOEKV.js} +6 -5
  3. package/dist/{ButtonBase-T2KH9jsD.js → ButtonBase-DPLf5-lz.js} +226 -279
  4. package/dist/{CircularProgress-BQQkuSse.js → CircularProgress-CrHaMZDC.js} +4 -3
  5. package/dist/{Dialog-B97c7WYP.js → Dialog-DqFOpJyx.js} +118 -125
  6. package/dist/{DialogTitle-Du4tqTs0.js → DialogTitle-CeM_Z851.js} +4 -4
  7. package/dist/{Typography-r_TXEM1e.js → Typography-DDVoglvI.js} +38 -40
  8. package/dist/assets/centered-decorator.css +1 -0
  9. package/dist/assets/code-input.css +1 -0
  10. package/dist/assets/dark-decorator.css +1 -0
  11. package/dist/assets/upload-dialog-errors.css +1 -1
  12. package/dist/chainPropTypes-C04Ex8aP.js +413 -0
  13. package/dist/components/button/button.js +1 -1
  14. package/dist/components/circular-progress-loader/circular-progress-loader.js +3 -3
  15. package/dist/components/code-input/code-input.d.ts +3 -0
  16. package/dist/components/code-input/code-input.js +934 -0
  17. package/dist/components/code-input/code-input.stories.d.ts +7 -0
  18. package/dist/components/code-input/constants.d.ts +8 -0
  19. package/dist/components/code-input/constants.js +11 -0
  20. package/dist/components/code-input/index.d.ts +1 -0
  21. package/dist/components/code-input/index.js +4 -0
  22. package/dist/components/code-input/types.d.ts +11 -0
  23. package/dist/components/code-input/utils/get-code-input-label.d.ts +2 -0
  24. package/dist/components/code-input/utils/get-code-input-label.js +5 -0
  25. package/dist/components/code-input/utils/index.d.ts +2 -0
  26. package/dist/components/code-input/utils/index.js +6 -0
  27. package/dist/components/code-input/utils/slide-down-animate.d.ts +1 -0
  28. package/dist/components/code-input/utils/slide-down-animate.js +10 -0
  29. package/dist/components/index.d.ts +1 -0
  30. package/dist/components/index.js +4 -2
  31. package/dist/components/photo-crop-uploader/components/error-upload-dialog/error-upload-dialog.js +6 -6
  32. package/dist/components/photo-crop-uploader/components/photo-list/photo-list.js +1 -1
  33. package/dist/components/photo-crop-uploader/components/upload-button/upload-button.js +1 -1
  34. package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog-errors.js +2 -2
  35. package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog.js +12 -10
  36. package/dist/components/photo-crop-uploader/photo-crop-uploader.d.ts +2 -2
  37. package/dist/components/photo-crop-uploader/photo-crop-uploader.js +183 -168
  38. package/dist/components/photo-crop-uploader/types.d.ts +8 -7
  39. package/dist/components/photo-crop-uploader/utils/draw-cropped-image.js +28 -29
  40. package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.d.ts +4 -2
  41. package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.js +34 -32
  42. package/dist/createSimplePaletteValueFilter-B7--0ryQ.js +17 -0
  43. package/dist/{createTheme-RvzX1VSA.js → createTheme-RRQUOQoF.js} +182 -178
  44. package/dist/decorators/centered-decorator/centered-decorator.js +7 -0
  45. package/dist/decorators/centered-decorator/index.d.ts +2 -0
  46. package/dist/decorators/centered-decorator/index.js +4 -0
  47. package/dist/decorators/centered-decorator/types.js +1 -0
  48. package/dist/decorators/dark-decorator/dark-decorator.d.ts +3 -0
  49. package/dist/decorators/dark-decorator/dark-decorator.js +7 -0
  50. package/dist/decorators/dark-decorator/index.d.ts +2 -0
  51. package/dist/decorators/dark-decorator/index.js +4 -0
  52. package/dist/decorators/dark-decorator/types.d.ts +4 -0
  53. package/dist/decorators/dark-decorator/types.js +1 -0
  54. package/dist/decorators/index.d.ts +2 -1
  55. package/dist/decorators/index.js +4 -2
  56. package/dist/extendSxProp-VC2-7DJw.js +49 -0
  57. package/dist/index-BMkXyDFs.js +91 -0
  58. package/dist/isHostComponent-Dm_U9uOy.js +14 -0
  59. package/dist/memoTheme-5A7c_y33.js +15 -0
  60. package/dist/refType-CCKoQjVR.js +61 -0
  61. package/dist/{upload-dialog-errors-ku54UrUb.js → upload-dialog-errors-Bxun25O-.js} +41 -41
  62. package/package.json +1 -1
  63. package/dist/chainPropTypes-KIxDwPzf.js +0 -387
  64. package/dist/createSimplePaletteValueFilter-nb0wSOzC.js +0 -30
  65. package/dist/decorators/centered-decorator.js +0 -16
  66. package/dist/extendSxProp-BW9e6LtL.js +0 -36
  67. package/dist/useTheme-CsjkCBFJ.js +0 -16
  68. /package/dist/{decorators → components/code-input}/types.js +0 -0
  69. /package/dist/decorators/{centered-decorator.d.ts → centered-decorator/centered-decorator.d.ts} +0 -0
  70. /package/dist/decorators/{types.d.ts → centered-decorator/types.d.ts} +0 -0
@@ -1,248 +1,263 @@
1
- import { jsxs as To, Fragment as _o, jsx as C } from "react/jsx-runtime";
2
- import { useState as n, useRef as G } from "react";
3
- import { D as wo } from "../../index-BiffjjQq.js";
4
- import { c as Ao } from "../../index-B2JRaoNz.js";
5
- import { localizedText as Uo } from "./locale.js";
6
- import { EN_LOCALE as xo } from "../../constants.js";
7
- import { DEFAULT_MIN_DIMENSION as yo, DEFAULT_ASPECT_RATIO as Oo, DEFAULT_TIMEOUT as vo, DEFAULT_FILE_MAX_SIZE as Io, FULL_PROGRESS_VALUE as Y, PHOTO_LOADING_DELAY as Fo, RESET_DATA_DELAY as E } from "./constants.js";
8
- import { UploadDialog as Mo } from "./components/upload-dialog/upload-dialog.js";
9
- import { UploadButton as No } from "./components/upload-button/upload-button.js";
10
- import { ErrorUploadDialog as Ro } from "./components/error-upload-dialog/error-upload-dialog.js";
1
+ import { jsxs as wo, Fragment as To, jsx as P } from "react/jsx-runtime";
2
+ import { useState as a, useRef as B } from "react";
3
+ import { D as Ao } from "../../index-BiffjjQq.js";
4
+ import { c as Uo } from "../../index-B2JRaoNz.js";
5
+ import { localizedText as xo } from "./locale.js";
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 G, PHOTO_LOADING_DELAY as Mo, RESET_DATA_DELAY as D } from "./constants.js";
8
+ import { UploadDialog as No } from "./components/upload-dialog/upload-dialog.js";
9
+ import { UploadButton as Ro } from "./components/upload-button/upload-button.js";
10
+ import { ErrorUploadDialog as Ho } from "./components/error-upload-dialog/error-upload-dialog.js";
11
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
- import { getDefaultCroppedPhoto as zo } from "./utils/get-default-cropped-photo.js";
16
- import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr_1", Vo = {
17
- photoCropCanvas: ko
18
- }, et = (Z) => {
12
+ import { readPhoto as Y } from "./utils/read-photo.js";
13
+ import { getPhotoCrop as bo } from "./utils/get-photo-crop.js";
14
+ import { getCroppedSource as ko } from "./utils/get-cropped-source.js";
15
+ import { getDefaultCroppedPhoto as X } from "./utils/get-default-cropped-photo.js";
16
+ import '../../assets/photo-crop-uploader.css';const zo = "_photoCropCanvas_1i4lr_1", Vo = {
17
+ photoCropCanvas: zo
18
+ };
19
+ function nr(n) {
19
20
  const {
20
- buttonClassname: q = "",
21
- onStartUpload: J = () => {
22
- },
23
- onEndUpload: K = () => {
21
+ buttonClassname: Z = "",
22
+ onStartUpload: q = () => {
24
23
  },
25
- onError: Q = () => {
24
+ onEndUpload: J = () => {
26
25
  },
27
- onStartCrop: $ = () => {
26
+ onError: K = () => {
28
27
  },
29
- onEndCrop: y = () => {
28
+ onStartCrop: Q = () => {
30
29
  },
31
- onDragOver: oo = () => {
30
+ onDragOver: $ = () => {
32
31
  },
33
- onDragLeave: to = () => {
32
+ onDragLeave: oo = () => {
34
33
  },
35
34
  onDragDrop: ro = () => {
36
35
  },
37
- onClose: P = () => {
38
- },
39
- showErrorPopup: eo = !1,
40
- minDimension: l = yo,
41
- aspectRatio: D = Oo,
42
- locale: s = xo,
36
+ showErrorPopup: to = !1,
37
+ minDimension: i = Oo,
38
+ aspectRatio: u = Io,
39
+ locale: s = yo,
43
40
  timeout: O = vo,
44
- fileMaxSize: v = Io,
45
- allowedExtensions: L,
46
- allowedMimeTypes: I,
47
- circular: so,
48
- width: no,
49
- keepSelection: ao,
50
- uploadButton: lo,
41
+ fileMaxSize: I = Fo,
42
+ allowedExtensions: S,
43
+ allowedMimeTypes: v,
44
+ circular: eo,
45
+ width: so,
46
+ keepSelection: no,
47
+ uploadButton: ao,
51
48
  multiple: m = !1,
52
49
  fromSources: F,
53
- returnCropParams: S = !1,
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
- d([]);
57
- }, V = (o = []) => {
58
- i || (P?.(
59
- o,
60
- p
61
- ), f(!1), setTimeout(() => d([]), E), setTimeout(() => u([]), E));
50
+ returnCropParams: io = !1,
51
+ ...lo
52
+ } = n, {
53
+ onEndCrop: jo,
54
+ onClose: Bo,
55
+ ...co
56
+ } = lo, [po, d] = a(!1), [f, C] = a([]), [L, _] = a([]), [p, M] = a(0), N = B(null), R = B(null), [l, w] = a(!1), [fo, H] = a(0), [b, k] = a(""), [ho, g] = a([]), [uo, z] = a(!1), mo = po || l && m, Co = () => {
57
+ g([]);
58
+ }, T = (o = []) => {
59
+ l || (n.returnCropParams === !0 && n.onClose?.(o, f), d(!1), setTimeout(() => g([]), D), setTimeout(() => C([]), D));
60
+ }, A = (o = []) => {
61
+ l || (n.returnCropParams !== !0 && n.onClose?.(o, f), d(!1), setTimeout(() => g([]), D), setTimeout(() => C([]), D));
62
62
  }, go = () => {
63
- i || (P([], p), f(!1), setTimeout(() => d([]), E), setTimeout(() => u([]), E));
64
- }, Co = () => {
65
- k(!1);
66
- }, A = (o) => {
67
- K(o), u(o), _(Array(o.length)), M(0), f(!0), z("");
63
+ l || (n.returnCropParams === !0 ? T([]) : A([]));
64
+ }, Eo = () => {
65
+ z(!1);
68
66
  }, U = (o) => {
69
- o instanceof Error && (console.warn(o.message), Q(o), z(o.message), k(!0), u([]), f(!1));
70
- }, Eo = async (o) => {
71
- const { files: r } = o.target;
72
- if (r?.length && !i)
67
+ J(o), C(o), _(Array(o.length)), M(0), d(!0), k("");
68
+ }, x = (o) => {
69
+ o instanceof Error && (console.warn(o.message), K(o), k(o.message), z(!0), C([]), d(!1));
70
+ }, Po = async (o) => {
71
+ const { files: t } = o.target;
72
+ if (t?.length && !l)
73
73
  try {
74
- if (w(!0), J(), m) {
75
- const t = Array.from(r), e = Y / t.length, g = [], h = [];
76
- for (const x of t) {
74
+ if (w(!0), q(), m) {
75
+ const r = Array.from(t), e = G / r.length, E = [], h = [];
76
+ for (const y of r) {
77
77
  try {
78
78
  W(
79
- x,
79
+ y,
80
80
  {
81
- maxSize: v,
82
- allowedExtensions: L,
83
- allowedMimeTypes: I
81
+ maxSize: I,
82
+ allowedExtensions: S,
83
+ allowedMimeTypes: v
84
84
  },
85
85
  s
86
86
  );
87
- const a = await X(x, l, s, O);
88
- g.push(a);
89
- } catch (a) {
90
- let B = "";
91
- a instanceof Error && (B = a.message), h.push({
92
- photoName: x.name,
93
- errorMessage: B
87
+ const c = await Y(y, i, s, O);
88
+ E.push(c);
89
+ } catch (c) {
90
+ let j = "";
91
+ c instanceof Error && (j = c.message), h.push({
92
+ photoName: y.name,
93
+ errorMessage: j
94
94
  });
95
95
  }
96
96
  H(
97
- (a) => Math.min(Y, a + e)
98
- ), await new Promise((a) => setTimeout(a, 0));
97
+ (c) => Math.min(G, c + e)
98
+ ), await new Promise((c) => setTimeout(c, 0));
99
99
  }
100
100
  if (F?.length)
101
101
  throw new Error(h[0]?.errorMessage);
102
- d(h), A(g);
102
+ g(h), U(E);
103
103
  } else {
104
- const t = r[0];
104
+ const r = t[0];
105
105
  W(
106
- t,
107
- { maxSize: v, allowedExtensions: L, allowedMimeTypes: I },
106
+ r,
107
+ { maxSize: I, allowedExtensions: S, allowedMimeTypes: v },
108
108
  s
109
109
  );
110
- const e = await X(t, l, s, O);
111
- A([e]);
110
+ const e = await Y(r, i, s, O);
111
+ U([e]);
112
112
  }
113
- } catch (t) {
114
- U(t);
113
+ } catch (r) {
114
+ x(r);
115
115
  } finally {
116
116
  m ? setTimeout(() => {
117
117
  o.target.value = "", H(0), w(!1);
118
- }, Fo) : (o.target.value = "", w(!1));
118
+ }, Mo) : (o.target.value = "", w(!1));
119
119
  }
120
- }, Po = (o) => {
121
- const { width: r, height: t } = o.currentTarget, e = Ho(r, t, l, D);
122
- _((g) => {
123
- const h = [...g];
124
- return h[c] = e, h;
120
+ }, Do = (o) => {
121
+ const { width: t, height: r } = o.currentTarget;
122
+ console.log(o);
123
+ const e = bo(t, r, i, u);
124
+ _((E) => {
125
+ const h = [...E];
126
+ return h[p] = e, h;
125
127
  });
126
- }, Do = (o, r) => {
127
- _((t) => {
128
- const e = [...t];
129
- return e[c] = r, e;
128
+ }, So = (o, t) => {
129
+ _((r) => {
130
+ const e = [...r];
131
+ return e[p] = t, e;
130
132
  });
131
- }, j = () => {
132
- const o = R.current, r = N.current;
133
- if (o && r && T)
133
+ }, V = () => {
134
+ const o = R.current, t = N.current;
135
+ if (o && t && L)
134
136
  try {
135
- $();
136
- const t = T[c];
137
- if (S) {
138
- const e = wo(
139
- t,
140
- r.naturalWidth,
141
- r.naturalHeight
142
- );
143
- y?.(e);
137
+ const r = L[p];
138
+ if (!r) return !1;
139
+ if (Q(), n.returnCropParams === !0) {
140
+ const e = Ao(r, t.width, t.height);
141
+ n.onEndCrop?.(e), p >= f.length - 1 && T();
144
142
  } else {
145
- const e = bo(
146
- r,
147
- o,
143
+ const e = ko(
148
144
  t,
145
+ o,
146
+ r,
149
147
  s
150
148
  );
151
- y?.(e);
149
+ n.onEndCrop?.(e), p >= f.length - 1 && A();
152
150
  }
153
- c >= p.length - 1 && V();
154
- } catch (t) {
155
- t instanceof Error && (console.warn(t), U(t));
151
+ return !0;
152
+ } catch (r) {
153
+ return r instanceof Error && (console.warn(r), x(r)), !1;
156
154
  }
155
+ else
156
+ return !1;
157
157
  }, Lo = () => {
158
- j(), M((o) => o + 1);
159
- }, So = async () => {
160
- const o = p.slice(c);
158
+ V() && M((t) => t + 1);
159
+ }, _o = async () => {
160
+ const o = f.slice(p);
161
161
  try {
162
- const r = await Promise.all(
163
- o.map(
164
- (t) => zo(
165
- t,
166
- l,
167
- D,
168
- s,
169
- S
162
+ if (io) {
163
+ const t = await Promise.all(
164
+ o.map(
165
+ (r) => X(
166
+ r,
167
+ i,
168
+ u,
169
+ s,
170
+ !0
171
+ )
172
+ )
173
+ );
174
+ T(t);
175
+ } else {
176
+ const t = await Promise.all(
177
+ o.map(
178
+ (r) => X(
179
+ r,
180
+ i,
181
+ u,
182
+ s,
183
+ !1
184
+ )
170
185
  )
171
- )
172
- );
173
- V(r);
174
- } catch (r) {
175
- U(r);
186
+ );
187
+ A(t);
188
+ }
189
+ } catch (t) {
190
+ x(t);
176
191
  }
177
192
  };
178
- return /* @__PURE__ */ To(_o, { children: [
179
- /* @__PURE__ */ C(
180
- No,
193
+ return /* @__PURE__ */ wo(To, { children: [
194
+ /* @__PURE__ */ P(
195
+ Ro,
181
196
  {
182
- onChange: Eo,
183
- onPhotoDataLoaded: A,
184
- buttonClassname: q,
185
- disabled: i,
186
- buttonDisabled: i,
197
+ onChange: Po,
198
+ onPhotoDataLoaded: U,
199
+ buttonClassname: Z,
200
+ disabled: l,
201
+ buttonDisabled: l,
187
202
  locale: s,
188
- width: no,
189
- allowedExtensions: L,
203
+ width: so,
204
+ allowedExtensions: S,
190
205
  onDragDrop: ro,
191
- onDragLeave: to,
192
- onDragOver: oo,
193
- button: lo,
206
+ onDragLeave: oo,
207
+ onDragOver: $,
208
+ button: ao,
194
209
  multiple: m,
195
210
  fromSources: F,
196
- ...io,
197
- children: Uo[s].upload
211
+ ...co,
212
+ children: xo[s].upload
198
213
  }
199
214
  ),
200
- /* @__PURE__ */ C(
201
- Mo,
215
+ /* @__PURE__ */ P(
216
+ No,
202
217
  {
203
- open: fo,
204
- photoSourceLoading: i,
205
- loadingValue: co,
218
+ open: mo,
219
+ photoSourceLoading: l,
220
+ loadingValue: fo,
206
221
  errors: ho,
207
- photoCrops: T,
208
- photoSources: p,
222
+ photoCrops: L,
223
+ photoSources: f,
209
224
  onNextPhoto: Lo,
210
- onSkipCrop: So,
211
- onClearErrors: uo,
225
+ onSkipCrop: _o,
226
+ onClearErrors: Co,
212
227
  photoError: b,
213
228
  onCloseDialogHandler: go,
214
- onCropChange: Do,
215
- onPhotoCrop: j,
216
- onPhotoLoad: Po,
229
+ onCropChange: So,
230
+ onPhotoCrop: V,
231
+ onPhotoLoad: Do,
217
232
  imageRef: N,
218
- minDimension: l,
219
- aspectRatio: D,
233
+ minDimension: i,
234
+ aspectRatio: u,
220
235
  locale: s,
221
- circular: so,
222
- keepSelection: ao,
223
- photoIndex: c
236
+ circular: eo,
237
+ keepSelection: no,
238
+ photoIndex: p
224
239
  }
225
240
  ),
226
- /* @__PURE__ */ C(
227
- Ro,
241
+ /* @__PURE__ */ P(
242
+ Ho,
228
243
  {
229
- open: eo && mo,
244
+ open: to && uo,
230
245
  photoError: b,
231
- onCloseErrorDialog: Co,
246
+ onCloseErrorDialog: Eo,
232
247
  locale: s
233
248
  }
234
249
  ),
235
- /* @__PURE__ */ C(
250
+ /* @__PURE__ */ P(
236
251
  "canvas",
237
252
  {
238
- className: Ao(Vo.photoCropCanvas),
239
- width: l,
240
- height: l,
253
+ className: Uo(Vo.photoCropCanvas),
254
+ width: i,
255
+ height: i,
241
256
  ref: R
242
257
  }
243
258
  )
244
259
  ] });
245
- };
260
+ }
246
261
  export {
247
- et as PhotoCropUploader
262
+ nr as PhotoCropUploader
248
263
  };
@@ -15,16 +15,17 @@ export type PhotoFileOptions = {
15
15
  allowedExtensions?: PhotoExtension[];
16
16
  allowedMimeTypes?: PhotoMimeType[];
17
17
  };
18
- type WithNoReturnCropParamsProps = {
19
- returnCropParams?: false;
20
- onEndCrop?: (photoData: PhotoDataUrl) => unknown;
21
- onClose?: (skipPhotosData: PhotoDataUrl[], sourcesData: PhotoDataUrl[]) => unknown;
22
- };
23
- type WithReturnCropParamsProps = {
18
+ type CropPropsWithParams = {
24
19
  returnCropParams: true;
25
20
  onEndCrop?: (photoData: PixelCrop) => unknown;
26
21
  onClose?: (skipPhotosData: PixelCrop[], sourcesData: PhotoDataUrl[]) => unknown;
27
22
  };
23
+ type CropPropsWithDataUrl = {
24
+ returnCropParams?: false;
25
+ onEndCrop?: (photoData: PhotoDataUrl) => unknown;
26
+ onClose?: (skipPhotosData: PhotoDataUrl[], sourcesData: PhotoDataUrl[]) => unknown;
27
+ };
28
+ type CropProps = CropPropsWithParams | CropPropsWithDataUrl;
28
29
  export type PhotoCropUploaderCustomProps = {
29
30
  buttonClassname?: string;
30
31
  onStartUpload?: () => unknown;
@@ -48,6 +49,6 @@ export type PhotoCropUploaderCustomProps = {
48
49
  uploadButton?: ReactNode;
49
50
  fromSources?: PhotoDataUrl[];
50
51
  };
51
- export type PhotoCropUploaderProps = PhotoCropUploaderCustomProps & (WithNoReturnCropParamsProps | WithReturnCropParamsProps) & InputHTMLAttributes<HTMLInputElement>;
52
+ export type PhotoCropUploaderProps = PhotoCropUploaderCustomProps & CropProps & InputHTMLAttributes<HTMLInputElement>;
52
53
  export type PhotoCropUploaderLocaleText = Record<Locale, Record<string, string>>;
53
54
  export {};
@@ -1,33 +1,32 @@
1
- import { D as h } from "../../../index-BiffjjQq.js";
2
- import { localizedText as w } from "../locale.js";
3
- import { EN_LOCALE as l } from "../../../constants.js";
1
+ import { D as w } from "../../../index-BiffjjQq.js";
2
+ import { localizedText as m } from "../locale.js";
3
+ import { EN_LOCALE as E } from "../../../constants.js";
4
4
  import { PHOTO_CANVAS_CONTEXT as x } from "../constants.js";
5
- const O = async (o, n, a, m = l) => {
6
- new Promise((d, s) => {
7
- const r = new Image();
8
- r.src = n, r.addEventListener("load", () => {
9
- const { width: e, height: c } = o, { naturalWidth: p, naturalHeight: g } = r, i = o.getContext(x);
10
- if (i) {
11
- const t = h(a, p, g);
12
- i.drawImage(
13
- r,
14
- t.x,
15
- t.y,
16
- t.width,
17
- t.height,
18
- 0,
19
- 0,
20
- e,
21
- c
22
- );
23
- }
24
- d("");
25
- }), r.addEventListener("error", () => {
26
- const e = new Error(w[m]["paint-error"]);
27
- s(e);
28
- });
5
+ const L = (o, d, s, n = E) => new Promise((p, i) => {
6
+ const r = new Image();
7
+ r.src = d, r.addEventListener("load", () => {
8
+ const { width: e, height: c } = o, { naturalWidth: g, naturalHeight: h } = r, a = o.getContext(x);
9
+ if (!a) {
10
+ i(new Error(m[n]["canvas-error"]));
11
+ return;
12
+ }
13
+ const t = w(s, g, h);
14
+ a.drawImage(
15
+ r,
16
+ t.x,
17
+ t.y,
18
+ t.width,
19
+ t.height,
20
+ 0,
21
+ 0,
22
+ e,
23
+ c
24
+ ), p();
25
+ }), r.addEventListener("error", () => {
26
+ const e = new Error(m[n]["paint-error"]);
27
+ i(e);
29
28
  });
30
- };
29
+ });
31
30
  export {
32
- O as drawCroppedImage
31
+ L as drawCroppedImage
33
32
  };
@@ -1,4 +1,6 @@
1
- import { Crop } from 'react-image-crop';
1
+ import { PixelCrop } from 'react-image-crop';
2
2
  import { Locale } from '../../../types';
3
3
  import { PhotoDataUrl } from '../types';
4
- export declare const getDefaultCroppedPhoto: (photoSourse: PhotoDataUrl, minDimension: number, aspectRatio: number, locale: Locale, returnCropParams: boolean) => Promise<PhotoDataUrl | Crop>;
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>;
@@ -1,39 +1,41 @@
1
- import { D as g } from "../../../index-BiffjjQq.js";
2
- import { getPhotoCrop as u } from "./get-photo-crop.js";
1
+ import { D as u } from "../../../index-BiffjjQq.js";
2
+ import { getPhotoCrop as g } from "./get-photo-crop.js";
3
3
  import { getCroppedSource as C } from "./get-cropped-source.js";
4
4
  import { localizedText as l } from "../locale.js";
5
- const x = async (a, s, i, e, m) => new Promise((n, c) => {
6
- const o = new Image(), d = document.createElement("canvas");
7
- o.src = a, o.addEventListener("load", () => {
8
- const { width: r, height: p } = o;
9
- try {
10
- const t = u(
11
- r,
12
- p,
13
- s,
14
- i,
15
- !0
16
- );
17
- if (m) {
18
- const f = g(t, r, p);
19
- n(f);
20
- return;
5
+ function x(a, i, m, e, s) {
6
+ return new Promise((n, p) => {
7
+ const o = new Image(), d = document.createElement("canvas");
8
+ o.src = a, o.addEventListener("load", () => {
9
+ const { width: r, height: c } = o;
10
+ try {
11
+ const t = g(
12
+ r,
13
+ c,
14
+ i,
15
+ m,
16
+ !0
17
+ );
18
+ if (s) {
19
+ const f = u(t, r, c);
20
+ n(f);
21
+ return;
22
+ }
23
+ const h = C(
24
+ o,
25
+ d,
26
+ t,
27
+ e
28
+ );
29
+ n(h);
30
+ } catch (t) {
31
+ p(t);
21
32
  }
22
- const h = C(
23
- o,
24
- d,
25
- t,
26
- e
27
- );
28
- n(h);
29
- } catch (t) {
30
- c(t);
31
- }
32
- }), o.addEventListener("error", () => {
33
- const r = new Error(l[e]["paint-error"]);
34
- c(r);
33
+ }), o.addEventListener("error", () => {
34
+ const r = new Error(l[e]["paint-error"]);
35
+ p(r);
36
+ });
35
37
  });
36
- });
38
+ }
37
39
  export {
38
40
  x as getDefaultCroppedPhoto
39
41
  };
@@ -0,0 +1,17 @@
1
+ function n(e) {
2
+ return typeof e.main == "string";
3
+ }
4
+ function a(e, r = []) {
5
+ if (!n(e))
6
+ return !1;
7
+ for (const t of r)
8
+ if (!e.hasOwnProperty(t) || typeof e[t] != "string")
9
+ return !1;
10
+ return !0;
11
+ }
12
+ function i(e = []) {
13
+ return ([, r]) => r && a(r, e);
14
+ }
15
+ export {
16
+ i as c
17
+ };