@bikdotai/bik-component-library 0.0.488-beta-4 → 0.0.488-beta-6
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.
- package/dist/cjs/components/image-cropper/BikImagePipeline/BikImagePipeline.d.ts +4 -1
- package/dist/cjs/components/image-cropper/BikImagePipeline/BikImagePipeline.js +1 -1
- package/dist/esm/components/image-cropper/BikImagePipeline/BikImagePipeline.d.ts +4 -1
- package/dist/esm/components/image-cropper/BikImagePipeline/BikImagePipeline.js +1 -1
- package/package.json +1 -1
|
@@ -26,5 +26,8 @@ export interface BikImagePipelineProps {
|
|
|
26
26
|
error?: string;
|
|
27
27
|
success?: boolean;
|
|
28
28
|
};
|
|
29
|
+
loadingStateOptions?: {
|
|
30
|
+
headerImage?: string;
|
|
31
|
+
};
|
|
29
32
|
}
|
|
30
|
-
export declare const BikImagePipeline: ({ cropOptions, fileTitle, compressionOptions, currentImage, options, onFinish, onCancel, fileUploadOptions, }: BikImagePipelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const BikImagePipeline: ({ cropOptions, fileTitle, compressionOptions, currentImage, options, onFinish, onCancel, fileUploadOptions, loadingStateOptions, }: BikImagePipelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react"),r=require("../../image-compress/ImageCompress.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react"),r=require("../../image-compress/ImageCompress.js"),t=require("../../states/StateComponent.js");require("../../../_virtual/_tslib.js");var s=require("../../states-modal/StateModalComponent.js");require("../../modals/styledModal.js");var a=require("../BikImageCropper.js");exports.BikImagePipeline=i=>{let{cropOptions:l,fileTitle:n,compressionOptions:p,currentImage:c,options:u,onFinish:d,onCancel:m,fileUploadOptions:g,loadingStateOptions:h}=i;const j=o.useRef(null),[C,I]=o.useState(),[f,v]=o.useState(c),[x,S]=o.useState(!1);o.useEffect((()=>{u.upload?(I("upload"),setTimeout((()=>{y()}),500)):u.crop?I("crop"):u.compress?I("compress"):u.uploadToFirestorage?I("cloud-upload"):S(!0)}),[u.upload,u.crop,u.compress,u.uploadToFirestorage]);const F=o.useCallback(((e,o)=>{if(!u.uploadToFirestorage)return d(e,o),void S(!0);I("cloud-upload"),g&&g.uploadFile(o,g.path).then((r=>{d(e,o,r),S(!0)})).catch((e=>{console.log("starting err process with ")}))}),[]),b=e=>{e||m();const o=r.ImageService.base64ToImage(e);u.compress?(I("compress"),r.ImageService.compressImage(o,p).then((e=>{if(!e)return S(!0),void m();F(e.base64,e.compressedFile)}))):F(e,o)},y=()=>{j.current.click()};return x?e.jsx(e.Fragment,{}):"cloud-upload"===C?!g||g.success?e.jsx(e.Fragment,{}):g.error?e.jsx("div",{children:e.jsx(s.StateModalComponent,{states:t.StateInterface.ERROR,heading:"Error while uploading",subline:"Please check your image and try again",isButtonEnabled:!1,width:300,onClose:()=>{S(!0),m()}})}):e.jsx("div",{children:e.jsx(s.StateModalComponent,{headerImage:null==h?void 0:h.headerImage,states:t.StateInterface.LOADING,heading:`Uploading your ${n||"photo"}`,subline:`Please wait while we upload your ${n||"photo"}`,isButtonEnabled:!1,width:300})}):e.jsxs(e.Fragment,{children:[u.upload&&e.jsx("input",{ref:j,type:"file",accept:"image/*",style:{display:"none"},onChange:e=>{const o=e.target.files[0],r=new FileReader;r.onload=()=>{var e;v({src:r.result}),e=r.result,u.crop?I("crop"):b(e)},o&&r.readAsDataURL(o)}}),"crop"===C&&e.jsx(a.BikImageCropper,{src:f.src,onCropComplete:e=>{v({src:e}),b(e)},aspectRatio:l.aspectRatio,onCancel:m})]})};
|
|
@@ -26,5 +26,8 @@ export interface BikImagePipelineProps {
|
|
|
26
26
|
error?: string;
|
|
27
27
|
success?: boolean;
|
|
28
28
|
};
|
|
29
|
+
loadingStateOptions?: {
|
|
30
|
+
headerImage?: string;
|
|
31
|
+
};
|
|
29
32
|
}
|
|
30
|
-
export declare const BikImagePipeline: ({ cropOptions, fileTitle, compressionOptions, currentImage, options, onFinish, onCancel, fileUploadOptions, }: BikImagePipelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const BikImagePipeline: ({ cropOptions, fileTitle, compressionOptions, currentImage, options, onFinish, onCancel, fileUploadOptions, loadingStateOptions, }: BikImagePipelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as t,useState as s,useEffect as a,useCallback as i}from"react";import{ImageService as
|
|
1
|
+
import{jsx as o,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as t,useState as s,useEffect as a,useCallback as i}from"react";import{ImageService as l}from"../../image-compress/ImageCompress.js";import{StateInterface as p}from"../../states/StateComponent.js";import"../../../_virtual/_tslib.js";import{StateModalComponent as n}from"../../states-modal/StateModalComponent.js";import"../../modals/styledModal.js";import{BikImageCropper as c}from"../BikImageCropper.js";const d=d=>{let{cropOptions:m,fileTitle:u,compressionOptions:g,currentImage:h,options:f,onFinish:C,onCancel:w,fileUploadOptions:y,loadingStateOptions:I}=d;const b=t(null),[j,v]=s(),[F,R]=s(h),[O,T]=s(!1);a((()=>{f.upload?(v("upload"),setTimeout((()=>{B()}),500)):f.crop?v("crop"):f.compress?v("compress"):f.uploadToFirestorage?v("cloud-upload"):T(!0)}),[f.upload,f.crop,f.compress,f.uploadToFirestorage]);const E=i(((o,e)=>{if(!f.uploadToFirestorage)return C(o,e),void T(!0);v("cloud-upload"),y&&y.uploadFile(e,y.path).then((r=>{C(o,e,r),T(!0)})).catch((o=>{console.log("starting err process with ")}))}),[]),k=o=>{o||w();const e=l.base64ToImage(o);f.compress?(v("compress"),l.compressImage(e,g).then((o=>{if(!o)return T(!0),void w();E(o.base64,o.compressedFile)}))):E(o,e)},B=()=>{b.current.click()};return O?o(e,{}):"cloud-upload"===j?!y||y.success?o(e,{}):y.error?o("div",{children:o(n,{states:p.ERROR,heading:"Error while uploading",subline:"Please check your image and try again",isButtonEnabled:!1,width:300,onClose:()=>{T(!0),w()}})}):o("div",{children:o(n,{headerImage:null==I?void 0:I.headerImage,states:p.LOADING,heading:`Uploading your ${u||"photo"}`,subline:`Please wait while we upload your ${u||"photo"}`,isButtonEnabled:!1,width:300})}):r(e,{children:[f.upload&&o("input",{ref:b,type:"file",accept:"image/*",style:{display:"none"},onChange:o=>{const e=o.target.files[0],r=new FileReader;r.onload=()=>{var o;R({src:r.result}),o=r.result,f.crop?v("crop"):k(o)},e&&r.readAsDataURL(e)}}),"crop"===j&&o(c,{src:F.src,onCropComplete:o=>{R({src:o}),k(o)},aspectRatio:m.aspectRatio,onCancel:w})]})};export{d as BikImagePipeline};
|