@hai-dev/ui-kit 1.0.8 → 1.0.10

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,3 +1,3 @@
1
- export { PhotoCropUploader } from './photo-crop-uploader';
1
+ export { PhotoCropUploader, drawCroppedImage } from './photo-crop-uploader';
2
2
  export { Button } from './button';
3
3
  export { CircularProgressLoader } from './circular-progress-loader';
@@ -1,8 +1,10 @@
1
1
  import { PhotoCropUploader as e } from "./photo-crop-uploader/photo-crop-uploader.js";
2
- import { Button as p } from "./button/button.js";
2
+ import { drawCroppedImage as t } from "./photo-crop-uploader/utils/draw-cropped-image.js";
3
+ import { Button as m } from "./button/button.js";
3
4
  import { CircularProgressLoader as f } from "./circular-progress-loader/circular-progress-loader.js";
4
5
  export {
5
- p as Button,
6
+ m as Button,
6
7
  f as CircularProgressLoader,
7
- e as PhotoCropUploader
8
+ e as PhotoCropUploader,
9
+ t as drawCroppedImage
8
10
  };
@@ -1 +1,2 @@
1
1
  export { PhotoCropUploader } from './photo-crop-uploader';
2
+ export { drawCroppedImage } from './utils';
@@ -1,4 +1,6 @@
1
1
  import { PhotoCropUploader as p } from "./photo-crop-uploader.js";
2
+ import { drawCroppedImage as a } from "./utils/draw-cropped-image.js";
2
3
  export {
3
- p as PhotoCropUploader
4
+ p as PhotoCropUploader,
5
+ a as drawCroppedImage
4
6
  };
@@ -11,7 +11,7 @@ import { ErrorUploadDialog as Ro } from "./components/error-upload-dialog/error-
11
11
  import { validatePhotoFile as X } from "./utils/validate-photo-file.js";
12
12
  import { readPhoto as Z } from "./utils/read-photo.js";
13
13
  import { getPhotoCrop as bo } from "./utils/get-photo-crop.js";
14
- import { getCropedPhoto as Ho } from "./utils/get-croped-photo.js";
14
+ import { getCroppedSource as Ho } from "./utils/get-cropped-source.js";
15
15
  import { getDefaultCroppedPhoto as zo } from "./utils/get-default-cropped-photo.js";
16
16
  import '../../assets/photo-crop-uploader.css';const ko = "_photoCropCanvas_1i4lr_1", Vo = {
17
17
  photoCropCanvas: ko
@@ -0,0 +1,3 @@
1
+ import { Crop } from 'react-image-crop';
2
+ import { Locale } from '../../../types';
3
+ export declare const drawCroppedImage: (canvas: HTMLCanvasElement, source: string, crop: Crop, locale?: Locale) => Promise<void>;
@@ -0,0 +1,33 @@
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";
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
+ });
29
+ });
30
+ };
31
+ export {
32
+ O as drawCroppedImage
33
+ };
@@ -0,0 +1,4 @@
1
+ import { Crop } from 'react-image-crop';
2
+ import { Locale } from '../../../types';
3
+ import { PhotoDataUrl } from '../types';
4
+ export declare const getCroppedSource: (photo: HTMLImageElement, canvas: HTMLCanvasElement, crop: Crop, locale?: Locale) => PhotoDataUrl;
@@ -22,5 +22,5 @@ const H = (c, o, d, m = O) => {
22
22
  ), t.restore(), o.toDataURL();
23
23
  };
24
24
  export {
25
- H as getCropedPhoto
25
+ H as getCroppedSource
26
26
  };
@@ -1,13 +1,13 @@
1
1
  import { D as g } from "../../../index-BiffjjQq.js";
2
- import { getPhotoCrop as C } from "./get-photo-crop.js";
3
- import { getCropedPhoto as P } from "./get-croped-photo.js";
2
+ import { getPhotoCrop as u } from "./get-photo-crop.js";
3
+ import { getCroppedSource as C } from "./get-cropped-source.js";
4
4
  import { localizedText as l } from "../locale.js";
5
5
  const x = async (a, s, i, e, m) => new Promise((n, c) => {
6
6
  const o = new Image(), d = document.createElement("canvas");
7
7
  o.src = a, o.addEventListener("load", () => {
8
8
  const { width: r, height: p } = o;
9
9
  try {
10
- const t = C(
10
+ const t = u(
11
11
  r,
12
12
  p,
13
13
  s,
@@ -19,7 +19,7 @@ const x = async (a, s, i, e, m) => new Promise((n, c) => {
19
19
  n(f);
20
20
  return;
21
21
  }
22
- const h = P(
22
+ const h = C(
23
23
  o,
24
24
  d,
25
25
  t,
@@ -1,5 +1,6 @@
1
1
  export { readPhoto } from './read-photo';
2
2
  export { getPhotoCrop } from './get-photo-crop';
3
- export { getCropedPhoto } from './get-croped-photo';
3
+ export { getCroppedSource } from './get-cropped-source';
4
4
  export { validatePhotoFile } from './validate-photo-file';
5
5
  export { getDefaultCroppedPhoto } from './get-default-cropped-photo';
6
+ export { drawCroppedImage } from './draw-cropped-image';
@@ -1,12 +1,14 @@
1
1
  import { readPhoto as e } from "./read-photo.js";
2
2
  import { getPhotoCrop as p } from "./get-photo-crop.js";
3
- import { getCropedPhoto as h } from "./get-croped-photo.js";
4
- import { validatePhotoFile as x } from "./validate-photo-file.js";
5
- import { getDefaultCroppedPhoto as a } from "./get-default-cropped-photo.js";
3
+ import { getCroppedSource as m } from "./get-cropped-source.js";
4
+ import { validatePhotoFile as d } from "./validate-photo-file.js";
5
+ import { getDefaultCroppedPhoto as g } from "./get-default-cropped-photo.js";
6
+ import { drawCroppedImage as C } from "./draw-cropped-image.js";
6
7
  export {
7
- h as getCropedPhoto,
8
- a as getDefaultCroppedPhoto,
8
+ C as drawCroppedImage,
9
+ m as getCroppedSource,
10
+ g as getDefaultCroppedPhoto,
9
11
  p as getPhotoCrop,
10
12
  e as readPhoto,
11
- x as validatePhotoFile
13
+ d as validatePhotoFile
12
14
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { PhotoCropUploader, Button, CircularProgressLoader, } from './components';
2
+ export { drawCroppedImage } from './components';
3
+ export type { Crop, PercentCrop, PixelCrop } from 'react-image-crop';
2
4
  export type { Locale } from './types';
3
5
  export type { PhotoDataUrl, PhotoFileSize, PhotoExtension, PhotoMimeType, PhotoFileOptions, PhotoCropUploaderProps, } from './components/photo-crop-uploader/types';
4
6
  export { EN_LOCALE, RU_LOCALE, BYTE_TO_KILOBYTE } from './constants';
package/dist/index.js CHANGED
@@ -1,30 +1,32 @@
1
- import { BYTE_TO_KILOBYTE as G, EN_LOCALE as I, RU_LOCALE as P } from "./constants.js";
2
- import { BMP_IMAGE_EXT as M, BMP_IMAGE_TYPE as A, GIF_IMAGE_EXT as o, GIF_IMAGE_TYPE as r, ICO_IMAGE_EXT as Y, ICO_IMAGE_TYPE as O, JPEG_IMAGE_EXT as e, JPEG_IMAGE_TYPE as t, JPG_IMAGE_EXT as C, JPG_IMAGE_TYPE as X, MICROSOFT_ICO_IMAGE_TYPE as p, PNG_IMAGE_EXT as B, PNG_IMAGE_TYPE as L, SVG_IMAGE_EXT as f, SVG_IMAGE_TYPE as m, WEBP_IMAGE_EXT as x, WEBP_IMAGE_TYPE as J } from "./components/photo-crop-uploader/constants.js";
3
- import { PhotoCropUploader as F } from "./components/photo-crop-uploader/photo-crop-uploader.js";
4
- import { Button as S } from "./components/button/button.js";
5
- import { CircularProgressLoader as l } from "./components/circular-progress-loader/circular-progress-loader.js";
1
+ import { BYTE_TO_KILOBYTE as G, EN_LOCALE as I, RU_LOCALE as r } from "./constants.js";
2
+ import { BMP_IMAGE_EXT as T, BMP_IMAGE_TYPE as o, GIF_IMAGE_EXT as M, GIF_IMAGE_TYPE as A, ICO_IMAGE_EXT as e, ICO_IMAGE_TYPE as Y, JPEG_IMAGE_EXT as p, JPEG_IMAGE_TYPE as t, JPG_IMAGE_EXT as C, JPG_IMAGE_TYPE as O, MICROSOFT_ICO_IMAGE_TYPE as X, PNG_IMAGE_EXT as m, PNG_IMAGE_TYPE as B, SVG_IMAGE_EXT as f, SVG_IMAGE_TYPE as x, WEBP_IMAGE_EXT as L, WEBP_IMAGE_TYPE as a } from "./components/photo-crop-uploader/constants.js";
3
+ import { PhotoCropUploader as J } from "./components/photo-crop-uploader/photo-crop-uploader.js";
4
+ import { Button as N } from "./components/button/button.js";
5
+ import { CircularProgressLoader as g } from "./components/circular-progress-loader/circular-progress-loader.js";
6
+ import { drawCroppedImage as s } from "./components/photo-crop-uploader/utils/draw-cropped-image.js";
6
7
  export {
7
- M as BMP_IMAGE_EXT,
8
- A as BMP_IMAGE_TYPE,
8
+ T as BMP_IMAGE_EXT,
9
+ o as BMP_IMAGE_TYPE,
9
10
  G as BYTE_TO_KILOBYTE,
10
- S as Button,
11
- l as CircularProgressLoader,
11
+ N as Button,
12
+ g as CircularProgressLoader,
12
13
  I as EN_LOCALE,
13
- o as GIF_IMAGE_EXT,
14
- r as GIF_IMAGE_TYPE,
15
- Y as ICO_IMAGE_EXT,
16
- O as ICO_IMAGE_TYPE,
17
- e as JPEG_IMAGE_EXT,
14
+ M as GIF_IMAGE_EXT,
15
+ A as GIF_IMAGE_TYPE,
16
+ e as ICO_IMAGE_EXT,
17
+ Y as ICO_IMAGE_TYPE,
18
+ p as JPEG_IMAGE_EXT,
18
19
  t as JPEG_IMAGE_TYPE,
19
20
  C as JPG_IMAGE_EXT,
20
- X as JPG_IMAGE_TYPE,
21
- p as MICROSOFT_ICO_IMAGE_TYPE,
22
- B as PNG_IMAGE_EXT,
23
- L as PNG_IMAGE_TYPE,
24
- F as PhotoCropUploader,
25
- P as RU_LOCALE,
21
+ O as JPG_IMAGE_TYPE,
22
+ X as MICROSOFT_ICO_IMAGE_TYPE,
23
+ m as PNG_IMAGE_EXT,
24
+ B as PNG_IMAGE_TYPE,
25
+ J as PhotoCropUploader,
26
+ r as RU_LOCALE,
26
27
  f as SVG_IMAGE_EXT,
27
- m as SVG_IMAGE_TYPE,
28
- x as WEBP_IMAGE_EXT,
29
- J as WEBP_IMAGE_TYPE
28
+ x as SVG_IMAGE_TYPE,
29
+ L as WEBP_IMAGE_EXT,
30
+ a as WEBP_IMAGE_TYPE,
31
+ s as drawCroppedImage
30
32
  };
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.8",
4
+ "version": "1.0.10",
5
5
  "license": "UNLICENSED",
6
6
  "author": {
7
7
  "name": "Vladislav Knitrunov",
@@ -1,4 +0,0 @@
1
- import { Crop } from 'react-image-crop';
2
- import { Locale } from '../../../types';
3
- import { PhotoDataUrl } from '../types';
4
- export declare const getCropedPhoto: (photo: HTMLImageElement, canvas: HTMLCanvasElement, crop: Crop, locale?: Locale) => PhotoDataUrl;