@hai-dev/ui-kit 1.0.6 → 1.0.7

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 (33) hide show
  1. package/dist/{Box-CiYPzbPd.js → Box-D8oKffw9.js} +18 -17
  2. package/dist/{Button-chJUX25I.js → Button-BBF8hp7e.js} +16 -15
  3. package/dist/{ButtonBase-DZwhOh56.js → ButtonBase-T2KH9jsD.js} +2 -2
  4. package/dist/{CircularProgress-BCrSQadM.js → CircularProgress-BQQkuSse.js} +110 -136
  5. package/dist/{DialogTitle-BUcXvkzd.js → Dialog-B97c7WYP.js} +765 -1010
  6. package/dist/DialogTitle-Du4tqTs0.js +254 -0
  7. package/dist/{Typography-BmYEfS8y.js → Typography-r_TXEM1e.js} +4 -4
  8. package/dist/assets/upload-dialog-errors.css +1 -0
  9. package/dist/assets/upload-dialog.css +1 -1
  10. package/dist/{chainPropTypes-HYSaT0L0.js → chainPropTypes-KIxDwPzf.js} +15 -15
  11. package/dist/components/button/button.js +1 -1
  12. package/dist/components/circular-progress-loader/circular-progress-loader.js +3 -3
  13. package/dist/components/photo-crop-uploader/components/error-upload-dialog/error-upload-dialog.js +26 -25
  14. package/dist/components/photo-crop-uploader/components/photo-list/photo-list.js +1 -1
  15. package/dist/components/photo-crop-uploader/components/upload-button/upload-button.js +17 -17
  16. package/dist/components/photo-crop-uploader/components/upload-dialog/types.d.ts +12 -1
  17. package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog-errors.d.ts +3 -0
  18. package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog-errors.js +10 -0
  19. package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog.js +152 -129
  20. package/dist/components/photo-crop-uploader/constants.d.ts +3 -0
  21. package/dist/components/photo-crop-uploader/constants.js +35 -32
  22. package/dist/components/photo-crop-uploader/locale.js +8 -2
  23. package/dist/components/photo-crop-uploader/photo-crop-uploader.js +169 -145
  24. package/dist/components/photo-crop-uploader/types.d.ts +4 -0
  25. package/dist/constants.d.ts +1 -0
  26. package/dist/constants.js +2 -1
  27. package/dist/createSimplePaletteValueFilter-nb0wSOzC.js +30 -0
  28. package/dist/{createTheme-BfVKUMHQ.js → createTheme-RvzX1VSA.js} +9 -9
  29. package/dist/extendSxProp-BW9e6LtL.js +36 -0
  30. package/dist/upload-dialog-errors-ku54UrUb.js +365 -0
  31. package/dist/useTheme-CsjkCBFJ.js +16 -0
  32. package/package.json +1 -1
  33. package/dist/extendSxProp-bpz0eCso.js +0 -49
@@ -1,205 +1,229 @@
1
- import { jsxs as io, Fragment as ho, jsx as h } from "react/jsx-runtime";
2
- import { useState as s, useRef as N } from "react";
1
+ import { jsxs as So, Fragment as To, jsx as E } from "react/jsx-runtime";
2
+ import { useState as s, useRef as j } from "react";
3
3
  import "../../index-BiffjjQq.js";
4
- import { c as mo } from "../../index-B2JRaoNz.js";
5
- import { localizedText as fo } from "./locale.js";
6
- import { EN_LOCALE as uo } from "../../constants.js";
7
- import { DEFAULT_MIN_DIMENSION as Co, DEFAULT_ASPECT_RATIO as go, DEFAULT_TIMEOUT as Po, DEFAULT_FILE_MAX_SIZE as Eo } from "./constants.js";
8
- import { UploadDialog as Do } from "./components/upload-dialog/upload-dialog.js";
9
- import { UploadButton as So } from "./components/upload-button/upload-button.js";
10
- import { ErrorUploadDialog as Lo } from "./components/error-upload-dialog/error-upload-dialog.js";
11
- import { validatePhotoFile as b } from "./utils/validate-photo-file.js";
12
- import { readPhoto as R } from "./utils/read-photo.js";
13
- import { getPhotoCrop as wo } from "./utils/get-photo-crop.js";
14
- import { getCropedPhoto as _o } from "./utils/get-croped-photo.js";
15
- import { getDefaultCroppedPhoto as xo } from "./utils/get-default-cropped-photo.js";
16
- import '../../assets/photo-crop-uploader.css';const Uo = "_photoCropCanvas_1i4lr_1", yo = {
17
- photoCropCanvas: Uo
18
- }, Xo = (k) => {
4
+ import { c as _o } from "../../index-B2JRaoNz.js";
5
+ import { localizedText as wo } from "./locale.js";
6
+ import { EN_LOCALE as Ao } from "../../constants.js";
7
+ import { DEFAULT_MIN_DIMENSION as Uo, DEFAULT_ASPECT_RATIO as xo, DEFAULT_TIMEOUT as yo, DEFAULT_FILE_MAX_SIZE as Oo, FULL_PROGRESS_VALUE as B, PHOTO_LOADING_DELAY as Io, RESET_DATA_DELAY as C } from "./constants.js";
8
+ import { UploadDialog as vo } from "./components/upload-dialog/upload-dialog.js";
9
+ import { UploadButton as Fo } from "./components/upload-button/upload-button.js";
10
+ import { ErrorUploadDialog as Mo } from "./components/error-upload-dialog/error-upload-dialog.js";
11
+ import { validatePhotoFile as G } from "./utils/validate-photo-file.js";
12
+ import { readPhoto as Y } from "./utils/read-photo.js";
13
+ import { getPhotoCrop as No } from "./utils/get-photo-crop.js";
14
+ import { getCropedPhoto as Ro } from "./utils/get-croped-photo.js";
15
+ import { getDefaultCroppedPhoto as bo } from "./utils/get-default-cropped-photo.js";
16
+ import '../../assets/photo-crop-uploader.css';const Ho = "_photoCropCanvas_1i4lr_1", ko = {
17
+ photoCropCanvas: Ho
18
+ }, tt = (X) => {
19
19
  const {
20
- buttonClassname: z = "",
21
- onStartUpload: H = () => {
20
+ buttonClassname: Z = "",
21
+ onStartUpload: q = () => {
22
22
  },
23
- onEndUpload: j = () => {
23
+ onEndUpload: J = () => {
24
24
  },
25
- onError: B = () => {
25
+ onError: K = () => {
26
26
  },
27
- onStartCrop: X = () => {
27
+ onStartCrop: Q = () => {
28
28
  },
29
- onEndCrop: Z = () => {
29
+ onEndCrop: W = () => {
30
30
  },
31
- onDragOver: q = () => {
31
+ onDragOver: $ = () => {
32
32
  },
33
- onDragLeave: G = () => {
33
+ onDragLeave: oo = () => {
34
34
  },
35
- onDragDrop: J = () => {
35
+ onDragDrop: to = () => {
36
36
  },
37
- onClose: P = () => {
37
+ onClose: U = () => {
38
38
  },
39
- showErrorPopup: K = !1,
40
- minDimension: a = Co,
41
- aspectRatio: m = go,
42
- locale: e = uo,
43
- timeout: E = Po,
44
- fileMaxSize: D = Eo,
45
- allowedExtensions: d,
46
- allowedMimeTypes: S,
47
- circular: Q,
48
- width: V,
49
- keepSelection: W,
50
- uploadButton: Y,
51
- multiple: L,
52
- fromSources: $,
53
- ...oo
54
- } = k, [to, i] = s(!1), [p, w] = s([]), [f, u] = s([]), [l, _] = s(0), x = N(null), U = N(null), [y, A] = s(!1), [T, v] = s(""), [ro, I] = s(!1), F = (o = []) => {
55
- P(o, p), i(!1);
56
- }, eo = () => {
57
- P([], p), i(!1);
58
- }, no = () => {
59
- I(!1);
60
- }, C = (o) => {
61
- j(o), w(o), u(Array(o.length)), _(0), i(!0), v("");
62
- }, g = (o) => {
63
- o instanceof Error && (console.warn(o.message), B(o), v(o.message), I(!0), w([]), i(!1));
64
- }, ao = async (o) => {
39
+ showErrorPopup: ro = !1,
40
+ minDimension: l = Uo,
41
+ aspectRatio: P = xo,
42
+ locale: e = Ao,
43
+ timeout: x = yo,
44
+ fileMaxSize: y = Oo,
45
+ allowedExtensions: D,
46
+ allowedMimeTypes: O,
47
+ circular: eo,
48
+ width: so,
49
+ keepSelection: no,
50
+ uploadButton: ao,
51
+ multiple: m = !1,
52
+ fromSources: I,
53
+ ...lo
54
+ } = X, [io, f] = s(!1), [h, u] = s([]), [L, S] = s([]), [p, v] = s(0), F = j(null), M = j(null), [i, T] = s(!1), [po, N] = s(0), [R, b] = s(""), [co, d] = s([]), [ho, H] = s(!1), mo = io || i && m, fo = () => {
55
+ d([]);
56
+ }, k = (o = []) => {
57
+ i || (U(o, h), f(!1), setTimeout(() => d([]), C), setTimeout(() => u([]), C));
58
+ }, uo = () => {
59
+ i || (U([], h), f(!1), setTimeout(() => d([]), C), setTimeout(() => u([]), C));
60
+ }, go = () => {
61
+ H(!1);
62
+ }, _ = (o) => {
63
+ J(o), u(o), S(Array(o.length)), v(0), f(!0), b("");
64
+ }, w = (o) => {
65
+ o instanceof Error && (console.warn(o.message), K(o), b(o.message), H(!0), u([]), f(!1));
66
+ }, Eo = async (o) => {
65
67
  const { files: r } = o.target;
66
- if (r?.length)
68
+ if (r?.length && !i)
67
69
  try {
68
- if (A(!0), H(), L) {
69
- const t = Array.from(r);
70
- t.forEach((c) => {
71
- b(
72
- c,
73
- { maxSize: D, allowedExtensions: d, allowedMimeTypes: S },
74
- e
75
- );
76
- });
77
- const n = await Promise.all(
78
- t.map(
79
- (c) => R(c, a, e, E)
80
- )
81
- );
82
- C(n);
70
+ if (T(!0), q(), m) {
71
+ const t = Array.from(r), n = B / t.length, g = [], c = [];
72
+ for (const A of t) {
73
+ try {
74
+ G(
75
+ A,
76
+ {
77
+ maxSize: y,
78
+ allowedExtensions: D,
79
+ allowedMimeTypes: O
80
+ },
81
+ e
82
+ );
83
+ const a = await Y(A, l, e, x);
84
+ g.push(a);
85
+ } catch (a) {
86
+ let V = "";
87
+ a instanceof Error && (V = a.message), c.push({
88
+ photoName: A.name,
89
+ errorMessage: V
90
+ });
91
+ }
92
+ N(
93
+ (a) => Math.min(B, a + n)
94
+ ), await new Promise((a) => setTimeout(a, 0));
95
+ }
96
+ if (I?.length)
97
+ throw new Error(c[0]?.errorMessage);
98
+ d(c), _(g);
83
99
  } else {
84
100
  const t = r[0];
85
- b(
101
+ G(
86
102
  t,
87
- { maxSize: D, allowedExtensions: d, allowedMimeTypes: S },
103
+ { maxSize: y, allowedExtensions: D, allowedMimeTypes: O },
88
104
  e
89
105
  );
90
- const n = await R(t, a, e, E);
91
- C([n]);
106
+ const n = await Y(t, l, e, x);
107
+ _([n]);
92
108
  }
93
109
  } catch (t) {
94
- g(t);
110
+ w(t);
95
111
  } finally {
96
- o.target.value = "", A(!1);
112
+ m ? setTimeout(() => {
113
+ o.target.value = "", N(0), T(!1);
114
+ }, Io) : (o.target.value = "", T(!1));
97
115
  }
98
- }, so = (o) => {
99
- const { width: r, height: t } = o.currentTarget, n = wo(r, t, a, m);
100
- u((c) => {
101
- const M = [...c];
102
- return M[l] = n, M;
116
+ }, Co = (o) => {
117
+ const { width: r, height: t } = o.currentTarget;
118
+ console.log(o);
119
+ const n = No(r, t, l, P);
120
+ S((g) => {
121
+ const c = [...g];
122
+ return c[p] = n, c;
103
123
  });
104
- }, lo = (o, r) => {
105
- u((t) => {
124
+ }, Po = (o, r) => {
125
+ S((t) => {
106
126
  const n = [...t];
107
- return n[l] = r, n;
127
+ return n[p] = r, n;
108
128
  });
109
- }, O = () => {
110
- const o = U.current, r = x.current;
111
- if (o && r && f)
129
+ }, z = () => {
130
+ const o = M.current, r = F.current;
131
+ if (o && r && L)
112
132
  try {
113
- X();
114
- const t = _o(
133
+ Q();
134
+ const t = Ro(
115
135
  r,
116
136
  o,
117
- f[l],
137
+ L[p],
118
138
  e
119
139
  );
120
- Z(t), l >= p.length - 1 && F();
140
+ W(t), p >= h.length - 1 && k();
121
141
  } catch (t) {
122
- t instanceof Error && (console.warn(t), g(t));
142
+ t instanceof Error && (console.warn(t), w(t));
123
143
  }
124
- }, po = () => {
125
- O(), _((o) => o + 1);
126
- }, co = async () => {
127
- const o = p.slice(l);
144
+ }, Do = () => {
145
+ z(), v((o) => o + 1);
146
+ }, Lo = async () => {
147
+ const o = h.slice(p);
128
148
  try {
129
149
  const r = await Promise.all(
130
150
  o.map(
131
- (t) => xo(t, a, m, e)
151
+ (t) => bo(t, l, P, e)
132
152
  )
133
153
  );
134
- F(r);
154
+ k(r);
135
155
  } catch (r) {
136
- g(r);
156
+ w(r);
137
157
  }
138
158
  };
139
- return /* @__PURE__ */ io(ho, { children: [
140
- /* @__PURE__ */ h(
141
- So,
159
+ return /* @__PURE__ */ So(To, { children: [
160
+ /* @__PURE__ */ E(
161
+ Fo,
142
162
  {
143
- onChange: ao,
144
- onPhotoDataLoaded: C,
145
- buttonClassname: z,
146
- disabled: y,
147
- buttonDisabled: y,
163
+ onChange: Eo,
164
+ onPhotoDataLoaded: _,
165
+ buttonClassname: Z,
166
+ disabled: i,
167
+ buttonDisabled: i,
148
168
  locale: e,
149
- width: V,
150
- allowedExtensions: d,
151
- onDragDrop: J,
152
- onDragLeave: G,
153
- onDragOver: q,
154
- button: Y,
155
- multiple: L,
156
- fromSources: $,
157
- ...oo,
158
- children: fo[e].upload
169
+ width: so,
170
+ allowedExtensions: D,
171
+ onDragDrop: to,
172
+ onDragLeave: oo,
173
+ onDragOver: $,
174
+ button: ao,
175
+ multiple: m,
176
+ fromSources: I,
177
+ ...lo,
178
+ children: wo[e].upload
159
179
  }
160
180
  ),
161
- /* @__PURE__ */ h(
162
- Do,
181
+ /* @__PURE__ */ E(
182
+ vo,
163
183
  {
164
- open: to,
165
- photoCrops: f,
166
- photoSources: p,
167
- onNextPhoto: po,
168
- onSkipCrop: co,
169
- photoError: T,
170
- onCloseDialogHandler: eo,
171
- onCropChange: lo,
172
- onPhotoCrop: O,
173
- onPhotoLoad: so,
174
- imageRef: x,
175
- minDimension: a,
176
- aspectRatio: m,
184
+ open: mo,
185
+ photoSourceLoading: i,
186
+ loadingValue: po,
187
+ errors: co,
188
+ photoCrops: L,
189
+ photoSources: h,
190
+ onNextPhoto: Do,
191
+ onSkipCrop: Lo,
192
+ onClearErrors: fo,
193
+ photoError: R,
194
+ onCloseDialogHandler: uo,
195
+ onCropChange: Po,
196
+ onPhotoCrop: z,
197
+ onPhotoLoad: Co,
198
+ imageRef: F,
199
+ minDimension: l,
200
+ aspectRatio: P,
177
201
  locale: e,
178
- circular: Q,
179
- keepSelection: W,
180
- photoIndex: l
202
+ circular: eo,
203
+ keepSelection: no,
204
+ photoIndex: p
181
205
  }
182
206
  ),
183
- /* @__PURE__ */ h(
184
- Lo,
207
+ /* @__PURE__ */ E(
208
+ Mo,
185
209
  {
186
- open: K && ro,
187
- photoError: T,
188
- onCloseErrorDialog: no,
210
+ open: ro && ho,
211
+ photoError: R,
212
+ onCloseErrorDialog: go,
189
213
  locale: e
190
214
  }
191
215
  ),
192
- /* @__PURE__ */ h(
216
+ /* @__PURE__ */ E(
193
217
  "canvas",
194
218
  {
195
- className: mo(yo.photoCropCanvas),
196
- width: a,
197
- height: a,
198
- ref: U
219
+ className: _o(ko.photoCropCanvas),
220
+ width: l,
221
+ height: l,
222
+ ref: M
199
223
  }
200
224
  )
201
225
  ] });
202
226
  };
203
227
  export {
204
- Xo as PhotoCropUploader
228
+ tt as PhotoCropUploader
205
229
  };
@@ -3,6 +3,10 @@ import { Locale } from '../../types';
3
3
  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';
4
4
  export type PhotoDataUrl = string;
5
5
  export type PhotoFileSize = number;
6
+ export type FileErrorItem = {
7
+ photoName: string;
8
+ errorMessage: string;
9
+ };
6
10
  export type PhotoExtension = typeof JPG_IMAGE_EXT | typeof JPEG_IMAGE_EXT | typeof PNG_IMAGE_EXT | typeof SVG_IMAGE_EXT | typeof BMP_IMAGE_EXT | typeof GIF_IMAGE_EXT | typeof WEBP_IMAGE_EXT | typeof ICO_IMAGE_EXT;
7
11
  export type PhotoMimeType = typeof JPG_IMAGE_TYPE | typeof JPEG_IMAGE_TYPE | typeof PNG_IMAGE_TYPE | typeof SVG_IMAGE_TYPE | typeof BMP_IMAGE_TYPE | typeof GIF_IMAGE_TYPE | typeof WEBP_IMAGE_TYPE | typeof ICO_IMAGE_TYPE | typeof MICROSOFT_ICO_IMAGE_TYPE;
8
12
  export type PhotoFileOptions = {
@@ -2,3 +2,4 @@ export declare const EN_LOCALE = "en";
2
2
  export declare const RU_LOCALE = "ru";
3
3
  export declare const BYTE_TO_KILOBYTE = 1024;
4
4
  export declare const PRECENT_SYMBOL = "%";
5
+ export declare const DASH_SYMBOL = "-";
package/dist/constants.js CHANGED
@@ -1,6 +1,7 @@
1
- const E = "en", L = "ru", n = 1024, o = "%";
1
+ const E = "en", L = "ru", n = 1024, o = "%", t = "-";
2
2
  export {
3
3
  n as BYTE_TO_KILOBYTE,
4
+ t as DASH_SYMBOL,
4
5
  E as EN_LOCALE,
5
6
  o as PRECENT_SYMBOL,
6
7
  L as RU_LOCALE
@@ -0,0 +1,30 @@
1
+ import { p as o } from "./chainPropTypes-KIxDwPzf.js";
2
+ const l = {
3
+ theme: void 0
4
+ };
5
+ function u(e) {
6
+ let t, r;
7
+ return function(a) {
8
+ let n = t;
9
+ return (n === void 0 || a.theme !== r) && (l.theme = a.theme, n = o(e(l)), t = n, r = a.theme), n;
10
+ };
11
+ }
12
+ const c = u;
13
+ function i(e) {
14
+ return typeof e.main == "string";
15
+ }
16
+ function m(e, t = []) {
17
+ if (!i(e))
18
+ return !1;
19
+ for (const r of t)
20
+ if (!e.hasOwnProperty(r) || typeof e[r] != "string")
21
+ return !1;
22
+ return !0;
23
+ }
24
+ function h(e = []) {
25
+ return ([, t]) => t && m(t, e);
26
+ }
27
+ export {
28
+ h as c,
29
+ c as m
30
+ };
@@ -4099,18 +4099,18 @@ export {
4099
4099
  Ci as C,
4100
4100
  ha as E,
4101
4101
  je as P,
4102
- pa as T,
4102
+ Qt as T,
4103
4103
  Mr as _,
4104
- Cr as a,
4105
- Ca as b,
4104
+ Sa as a,
4105
+ tn as b,
4106
4106
  va as c,
4107
- sn as d,
4108
- tn as e,
4109
- Qt as f,
4110
- Sa as g,
4111
- vi as h,
4107
+ Sr as d,
4108
+ vi as e,
4109
+ Cr as f,
4110
+ sn as g,
4111
+ pa as h,
4112
4112
  xe as i,
4113
- Sr as j,
4113
+ Ca as j,
4114
4114
  Gr as k,
4115
4115
  Jt as l,
4116
4116
  ma as m,
@@ -0,0 +1,36 @@
1
+ import { i as c, d as l } from "./createTheme-RvzX1VSA.js";
2
+ const a = (t) => {
3
+ const s = {
4
+ systemProps: {},
5
+ otherProps: {}
6
+ }, n = t?.theme?.unstable_sxConfig ?? l;
7
+ return Object.keys(t).forEach((e) => {
8
+ n[e] ? s.systemProps[e] = t[e] : s.otherProps[e] = t[e];
9
+ }), s;
10
+ };
11
+ function x(t) {
12
+ const {
13
+ sx: s,
14
+ ...n
15
+ } = t, {
16
+ systemProps: e,
17
+ otherProps: i
18
+ } = a(n);
19
+ let r;
20
+ return Array.isArray(s) ? r = [e, ...s] : typeof s == "function" ? r = (...f) => {
21
+ const o = s(...f);
22
+ return c(o) ? {
23
+ ...e,
24
+ ...o
25
+ } : e;
26
+ } : r = {
27
+ ...e,
28
+ ...s
29
+ }, {
30
+ ...i,
31
+ sx: r
32
+ };
33
+ }
34
+ export {
35
+ x as e
36
+ };