@hai-dev/ui-kit 1.0.3 → 1.0.5

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,17 +1,17 @@
1
1
  import { jsx as i, jsxs as f } from "react/jsx-runtime";
2
- import { c as n } from "../../../../index-B2JRaoNz.js";
2
+ import { c as m } from "../../../../index-B2JRaoNz.js";
3
3
  import { MAX_ITEMS_COUNT as u } from "./constants.js";
4
4
  import { s as y, f as C, b as B, a as b, C as L, h as P, j, P as e } from "../../../../createTheme-DSHGFfg6.js";
5
5
  import * as v from "react";
6
6
  import { u as E, e as I } from "../../../../extendSxProp-CzeED7BH.js";
7
7
  import '../../../../assets/photo-list.css';function M(l = {}) {
8
8
  const {
9
- themeId: m,
9
+ themeId: n,
10
10
  defaultTheme: p,
11
11
  defaultClassName: a = "MuiBox-root",
12
12
  generateClassName: r
13
- } = l, s = y("div", {
14
- shouldForwardProp: (c) => c !== "theme" && c !== "sx" && c !== "as"
13
+ } = l, t = y("div", {
14
+ shouldForwardProp: (o) => o !== "theme" && o !== "sx" && o !== "as"
15
15
  })(C);
16
16
  return /* @__PURE__ */ v.forwardRef(function(x, N) {
17
17
  const h = E(p), {
@@ -19,11 +19,11 @@ import '../../../../assets/photo-list.css';function M(l = {}) {
19
19
  component: _ = "div",
20
20
  ...T
21
21
  } = I(x);
22
- return /* @__PURE__ */ i(s, {
22
+ return /* @__PURE__ */ i(t, {
23
23
  as: _,
24
24
  ref: N,
25
25
  className: B(g, r ? r(a) : a),
26
- theme: m && h[m] || h,
26
+ theme: n && h[n] || h,
27
27
  ...T
28
28
  });
29
29
  });
@@ -53,34 +53,34 @@ process.env.NODE_ENV !== "production" && (d.propTypes = {
53
53
  */
54
54
  sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object])
55
55
  });
56
- const z = "_photoList_rrp1z_1", R = "_item_rrp1z_6", q = "_image_rrp1z_17", o = {
56
+ const z = "_photoList_rrp1z_1", R = "_item_rrp1z_6", q = "_image_rrp1z_17", s = {
57
57
  photoList: z,
58
58
  item: R,
59
59
  image: q
60
60
  }, G = (l) => {
61
- const { photoSources: m, photoIndex: p, className: a, ...r } = l, s = m.slice(p);
62
- return s.length > u ? /* @__PURE__ */ f(d, { className: n(o.photoList, a), ...r, children: [
63
- s.slice(0, u - 1).map((t) => /* @__PURE__ */ i(
61
+ const { photoSources: n, photoIndex: p, className: a, ...r } = l, t = n.slice(p);
62
+ return t.length > u ? /* @__PURE__ */ f(d, { className: m(s.photoList, a), ...r, children: [
63
+ t.slice(0, u - 1).map((c, o) => /* @__PURE__ */ i(
64
64
  "img",
65
65
  {
66
- className: n(o.item, o.image),
67
- src: t,
66
+ className: m(s.item, s.image),
67
+ src: c,
68
68
  alt: "photo in queue"
69
69
  },
70
- t
70
+ o
71
71
  )),
72
- /* @__PURE__ */ f("div", { className: n(o.item), children: [
72
+ /* @__PURE__ */ f("div", { className: m(s.item), children: [
73
73
  "Еще ",
74
- s.length - u + 1
74
+ t.length - u + 1
75
75
  ] })
76
- ] }) : /* @__PURE__ */ i(d, { className: n(o.photoList, a), ...r, children: s.map((t) => /* @__PURE__ */ i(
76
+ ] }) : /* @__PURE__ */ i(d, { className: m(s.photoList, a), ...r, children: t.map((c, o) => /* @__PURE__ */ i(
77
77
  "img",
78
78
  {
79
- className: n(o.item, o.image),
80
- src: t,
79
+ className: m(s.item, s.image),
80
+ src: c,
81
81
  alt: "photo in queue"
82
82
  },
83
- t
83
+ o
84
84
  )) });
85
85
  };
86
86
  export {
@@ -1,20 +1,20 @@
1
- import { jsxs as io, Fragment as ho, jsx as i } from "react/jsx-runtime";
2
- import { useState as s, useRef as M } from "react";
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";
3
3
  import "../../index-BiffjjQq.js";
4
4
  import { c as mo } from "../../index-B2JRaoNz.js";
5
5
  import { localizedText as fo } from "./locale.js";
6
- import { EN_LOCALE as Co } from "../../constants.js";
7
- import { DEFAULT_MIN_DIMENSION as uo, DEFAULT_ASPECT_RATIO as go, DEFAULT_TIMEOUT as Po, DEFAULT_FILE_MAX_SIZE as Eo } from "./constants.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
8
  import { UploadDialog as Do } from "./components/upload-dialog/upload-dialog.js";
9
9
  import { UploadButton as So } from "./components/upload-button/upload-button.js";
10
10
  import { ErrorUploadDialog as Lo } from "./components/error-upload-dialog/error-upload-dialog.js";
11
- import { validatePhotoFile as N } from "./utils/validate-photo-file.js";
11
+ import { validatePhotoFile as b } from "./utils/validate-photo-file.js";
12
12
  import { readPhoto as R } from "./utils/read-photo.js";
13
13
  import { getPhotoCrop as wo } from "./utils/get-photo-crop.js";
14
- import { getCropedPhoto as Uo } from "./utils/get-croped-photo.js";
15
- import { getDefaultCroppedPhoto as _o } from "./utils/get-default-cropped-photo.js";
16
- import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr_1", yo = {
17
- photoCropCanvas: xo
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
18
  }, Xo = (k) => {
19
19
  const {
20
20
  buttonClassname: z = "",
@@ -37,58 +37,58 @@ import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr
37
37
  onClose: P = () => {
38
38
  },
39
39
  showErrorPopup: K = !1,
40
- minDimension: a = uo,
41
- aspectRatio: h = go,
42
- locale: e = Co,
40
+ minDimension: a = Co,
41
+ aspectRatio: m = go,
42
+ locale: e = uo,
43
43
  timeout: E = Po,
44
44
  fileMaxSize: D = Eo,
45
- allowedExtensions: m,
45
+ allowedExtensions: d,
46
46
  allowedMimeTypes: S,
47
47
  circular: Q,
48
48
  width: V,
49
49
  keepSelection: W,
50
- photoCropUploaderSlots: Y,
50
+ uploadButton: Y,
51
51
  multiple: L,
52
52
  fromSources: $,
53
53
  ...oo
54
- } = k, [to, c] = s(!1), [d, w] = s([]), [f, C] = s([]), [l, U] = s(0), _ = M(null), x = M(null), [y, A] = s(!1), [T, v] = s(""), [ro, I] = s(!1), F = (o = []) => {
55
- P(o), c(!1);
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
56
  }, eo = () => {
57
- P([]), c(!1);
57
+ P([], p), i(!1);
58
58
  }, no = () => {
59
59
  I(!1);
60
- }, u = (o) => {
61
- j(o), w(o), C(Array(o.length)), U(0), c(!0), v("");
60
+ }, C = (o) => {
61
+ j(o), w(o), u(Array(o.length)), _(0), i(!0), v("");
62
62
  }, g = (o) => {
63
- o instanceof Error && (console.warn(o.message), B(o), v(o.message), I(!0), w([]), c(!1));
63
+ o instanceof Error && (console.warn(o.message), B(o), v(o.message), I(!0), w([]), i(!1));
64
64
  }, ao = async (o) => {
65
65
  const { files: r } = o.target;
66
66
  if (r?.length)
67
67
  try {
68
68
  if (A(!0), H(), L) {
69
69
  const t = Array.from(r);
70
- t.forEach((p) => {
71
- N(
72
- p,
73
- { maxSize: D, allowedExtensions: m, allowedMimeTypes: S },
70
+ t.forEach((c) => {
71
+ b(
72
+ c,
73
+ { maxSize: D, allowedExtensions: d, allowedMimeTypes: S },
74
74
  e
75
75
  );
76
76
  });
77
77
  const n = await Promise.all(
78
78
  t.map(
79
- (p) => R(p, a, e, E)
79
+ (c) => R(c, a, e, E)
80
80
  )
81
81
  );
82
- u(n);
82
+ C(n);
83
83
  } else {
84
84
  const t = r[0];
85
- N(
85
+ b(
86
86
  t,
87
- { maxSize: D, allowedExtensions: m, allowedMimeTypes: S },
87
+ { maxSize: D, allowedExtensions: d, allowedMimeTypes: S },
88
88
  e
89
89
  );
90
90
  const n = await R(t, a, e, E);
91
- u([n]);
91
+ C([n]);
92
92
  }
93
93
  } catch (t) {
94
94
  g(t);
@@ -96,39 +96,39 @@ import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr
96
96
  o.target.value = "", A(!1);
97
97
  }
98
98
  }, so = (o) => {
99
- const { width: r, height: t } = o.currentTarget, n = wo(r, t, a, h);
100
- C((p) => {
101
- const b = [...p];
102
- return b[l] = n, b;
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;
103
103
  });
104
104
  }, lo = (o, r) => {
105
- C((t) => {
105
+ u((t) => {
106
106
  const n = [...t];
107
107
  return n[l] = r, n;
108
108
  });
109
109
  }, O = () => {
110
- const o = x.current, r = _.current;
110
+ const o = U.current, r = x.current;
111
111
  if (o && r && f)
112
112
  try {
113
113
  X();
114
- const t = Uo(
114
+ const t = _o(
115
115
  r,
116
116
  o,
117
117
  f[l],
118
118
  e
119
119
  );
120
- Z(t), l >= d.length - 1 && F();
120
+ Z(t), l >= p.length - 1 && F();
121
121
  } catch (t) {
122
122
  t instanceof Error && (console.warn(t), g(t));
123
123
  }
124
124
  }, po = () => {
125
- O(), U((o) => o + 1);
125
+ O(), _((o) => o + 1);
126
126
  }, co = async () => {
127
- const o = d.slice(l);
127
+ const o = p.slice(l);
128
128
  try {
129
129
  const r = await Promise.all(
130
130
  o.map(
131
- (t) => _o(t, a, h, e)
131
+ (t) => xo(t, a, m, e)
132
132
  )
133
133
  );
134
134
  F(r);
@@ -137,33 +137,33 @@ import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr
137
137
  }
138
138
  };
139
139
  return /* @__PURE__ */ io(ho, { children: [
140
- /* @__PURE__ */ i(
140
+ /* @__PURE__ */ h(
141
141
  So,
142
142
  {
143
143
  onChange: ao,
144
- onPhotoDataLoaded: u,
144
+ onPhotoDataLoaded: C,
145
145
  buttonClassname: z,
146
146
  disabled: y,
147
147
  buttonDisabled: y,
148
148
  locale: e,
149
149
  width: V,
150
- allowedExtensions: m,
150
+ allowedExtensions: d,
151
151
  onDragDrop: J,
152
152
  onDragLeave: G,
153
153
  onDragOver: q,
154
- button: Y?.button,
154
+ button: Y,
155
155
  multiple: L,
156
156
  fromSources: $,
157
157
  ...oo,
158
158
  children: fo[e].upload
159
159
  }
160
160
  ),
161
- /* @__PURE__ */ i(
161
+ /* @__PURE__ */ h(
162
162
  Do,
163
163
  {
164
164
  open: to,
165
165
  photoCrops: f,
166
- photoSources: d,
166
+ photoSources: p,
167
167
  onNextPhoto: po,
168
168
  onSkipCrop: co,
169
169
  photoError: T,
@@ -171,16 +171,16 @@ import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr
171
171
  onCropChange: lo,
172
172
  onPhotoCrop: O,
173
173
  onPhotoLoad: so,
174
- imageRef: _,
174
+ imageRef: x,
175
175
  minDimension: a,
176
- aspectRatio: h,
176
+ aspectRatio: m,
177
177
  locale: e,
178
178
  circular: Q,
179
179
  keepSelection: W,
180
180
  photoIndex: l
181
181
  }
182
182
  ),
183
- /* @__PURE__ */ i(
183
+ /* @__PURE__ */ h(
184
184
  Lo,
185
185
  {
186
186
  open: K && ro,
@@ -189,13 +189,13 @@ import '../../assets/photo-crop-uploader.css';const xo = "_photoCropCanvas_1i4lr
189
189
  locale: e
190
190
  }
191
191
  ),
192
- /* @__PURE__ */ i(
192
+ /* @__PURE__ */ h(
193
193
  "canvas",
194
194
  {
195
195
  className: mo(yo.photoCropCanvas),
196
196
  width: a,
197
197
  height: a,
198
- ref: x
198
+ ref: U
199
199
  }
200
200
  )
201
201
  ] });
@@ -10,9 +10,6 @@ export type PhotoFileOptions = {
10
10
  allowedExtensions?: PhotoExtension[];
11
11
  allowedMimeTypes?: PhotoMimeType[];
12
12
  };
13
- export type PhotoCropUploaderSlots = {
14
- button?: ReactNode;
15
- };
16
13
  export type PhotoCropUploaderCustomProps = {
17
14
  buttonClassname?: string;
18
15
  onStartUpload?: () => unknown;
@@ -20,7 +17,7 @@ export type PhotoCropUploaderCustomProps = {
20
17
  onError?: (error: Error) => unknown;
21
18
  onStartCrop?: () => unknown;
22
19
  onEndCrop?: (photoData: PhotoDataUrl) => unknown;
23
- onClose?: (skipPhotosData: PhotoDataUrl[]) => unknown;
20
+ onClose?: (skipPhotosData: PhotoDataUrl[], sourcesData: PhotoDataUrl[]) => unknown;
24
21
  onDragOver?: (event: DragEvent<HTMLDivElement>) => unknown;
25
22
  onDragLeave?: (event: DragEvent<HTMLDivElement>) => unknown;
26
23
  onDragDrop?: (event: DragEvent<HTMLDivElement>) => unknown;
@@ -35,7 +32,7 @@ export type PhotoCropUploaderCustomProps = {
35
32
  circular?: boolean;
36
33
  keepSelection?: boolean;
37
34
  width?: number;
38
- photoCropUploaderSlots?: PhotoCropUploaderSlots;
35
+ uploadButton?: ReactNode;
39
36
  fromSources?: PhotoDataUrl[];
40
37
  };
41
38
  export type PhotoCropUploaderProps = PhotoCropUploaderCustomProps & InputHTMLAttributes<HTMLInputElement>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hai-dev/ui-kit",
3
3
  "private": false,
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "author": {
6
6
  "name": "Vladislav Knitrunov",
7
7
  "email": "kingvlad3008@gmail.com",