@bikdotai/bik-component-library 0.0.359-beta.23 → 0.0.359-beta.25

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.
@@ -2,6 +2,7 @@
2
2
  import { HEADER_TYPES } from "../../template-preview/models/TemplateMeta";
3
3
  export interface EditMediaV2Props {
4
4
  imageName: string[];
5
+ selectedVariable?: string;
5
6
  errorSecondaryText?: string;
6
7
  error?: string;
7
8
  isLoading?: boolean;
@@ -5,4 +5,4 @@
5
5
  height: 24px;
6
6
  border-left: 1px solid ${c.COLORS.stroke.primary};
7
7
  cursor: pointer;
8
- `;exports.default=n=>{const{imageName:h,error:j,isLoading:p,mediaType:x,handleImageChange:O,setOpenEditMedia:y}=n,m=null==h?void 0:h[0].split("/"),f=null==m?void 0:m[m.length-1];return e.jsxs(u.Container,{children:[e.jsx(u.ImageContainer,Object.assign({error:!!j,onClick:j?O:void 0},{children:j?e.jsx(s.default,{color:c.COLORS.content.brand,width:32,height:32}):p?e.jsx(o.Spinner,{size:"small"}):x===l.HEADER_TYPES.IMAGE?e.jsx("img",{alt:"",src:null==h?void 0:h[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):x===l.HEADER_TYPES.VIDEO?e.jsx(r.default,{width:18,height:22,color:c.COLORS.content.placeholder}):e.jsx(t.default,{width:18,height:22,color:c.COLORS.content.placeholder})})),e.jsxs(u.RightComponent,{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:h&&j?e.jsx(e.Fragment,{}):p?e.jsx(d.BodyCaption,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):e.jsx(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.primary,marginLeft:8}},{children:a.default.toCapitilize(null==x?void 0:x.toLowerCase())||f}))})),!!j&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.negative}},{children:["Error loading this ",null==x?void 0:x.toLowerCase(),". Retry"]})),e.jsx(d.Caption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:j}))]})),!j&&!p&&e.jsx(g,Object.assign({onClick:()=>null==y?void 0:y(!0),onKeyDown:()=>null==y?void 0:y(!0),role:"presentation"},{children:e.jsx(i.default,{width:24,height:24,color:c.COLORS.content.placeholder})}))]})]})};
8
+ `;exports.default=n=>{const{imageName:h,error:j,isLoading:p,mediaType:x,handleImageChange:O,selectedVariable:y,setOpenEditMedia:m}=n,f=null==h?void 0:h[0].split("/"),v=null==f?void 0:f[f.length-1];return e.jsxs(u.Container,{children:[e.jsx(u.ImageContainer,Object.assign({error:!!j,onClick:j?O:void 0},{children:j?e.jsx(s.default,{color:c.COLORS.content.brand,width:32,height:32}):p?e.jsx(o.Spinner,{size:"small"}):x===l.HEADER_TYPES.IMAGE?e.jsx("img",{alt:"",src:null==h?void 0:h[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):x===l.HEADER_TYPES.VIDEO?e.jsx(r.default,{width:18,height:22,color:c.COLORS.content.placeholder}):e.jsx(t.default,{width:18,height:22,color:c.COLORS.content.placeholder})})),e.jsxs(u.RightComponent,{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:h&&j?e.jsx(e.Fragment,{}):p?e.jsx(d.BodyCaption,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):e.jsx(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.primary,marginLeft:8}},{children:y||a.default.toCapitilize(null==x?void 0:x.toLowerCase())||v}))})),!!j&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.negative}},{children:["Error loading this ",null==x?void 0:x.toLowerCase(),". Retry"]})),e.jsx(d.Caption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:j}))]})),!j&&!p&&e.jsx(g,Object.assign({onClick:()=>null==m?void 0:m(!0),onKeyDown:()=>null==m?void 0:m(!0),role:"presentation"},{children:e.jsx(i.default,{width:24,height:24,color:c.COLORS.content.placeholder})}))]})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),a=require("react"),i=require("../../helpers/FileUploaderHelper.js"),r=require("../../image-cropper/BikImageCropper.js");require("../../image-compress/ImageCompress.js"),require("../../states/StateComponent.js"),require("../../../constants/zindex.js");var n=require("../../modals/styledModal.js");require("../../spinner/Spinner.js");var l=require("../../input-with-vars/InputWithVariables.js"),o=require("../../template-preview/models/TemplateMeta.js"),s=require("../context/templateModalContext.js"),d=require("./EditMediaV2.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(a);exports.default=c=>{let{mediaComponent:p,template:m,updateTemplateImageUrl:f,whatsappSpecificPickerMeta:v,variableList:g}=c;var h,j;const[E,b]=a.useState(void 0),[x,y]=a.useState(),[_,C]=a.useState(!1),S=u.default.createRef(),[A,M]=a.useState(!1),[w,T]=a.useState(""),{template:q,setTemplate:I}=s.useTemplateModalContext();let R;function O(t){return e.__awaiter(this,void 0,void 0,(function*(){if(M(!0),T(""),t){const e=t.startsWith("https")?t:"https://shorturl.at/fgyP0";try{const a=yield fetch(e),i=yield a.blob();if(yield D(i),/^{{.*}}$/.test(t)){const e=Object.assign({},q);e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]}),null==I||I(Object.assign({},e)))}}catch(e){T("An unknown technical error occured")}}else P()}))}function P(){var e;(null===(e=null==S?void 0:S.current)||void 0===e?void 0:e.click)&&S.current.click()}function D(t){var a;return e.__awaiter(this,void 0,void 0,(function*(){const e=new i.FileUploaderHelper;if(t instanceof Blob){const i=e.validate(t);if(i)T(i),C(!1),M(!1);else{const e=p.format===o.HEADER_TYPES.IMAGE,i=yield v.uploadMediaFiles({file:t,fileName:E,isImage:e});if(i.success){const[e]=t.type.split("/");f(null!==(a=i.url)&&void 0!==a?a:"","application"===e?o.HEADER_TYPES.DOCUMENT:o.HEADER_TYPES[e.toUpperCase()])}else T("An unknown technical error occured");M(!1),C(!1)}}else T("An unknown technical error occured"),C(!1),M(!1)}))}return console.log("currentTemplate",q),R=p.format===o.HEADER_TYPES.IMAGE?"image/png, image/jpeg":p.format===o.HEADER_TYPES.VIDEO?"video/mp4":"application/pdf",t.jsxs(t.Fragment,{children:[t.jsx(n.StyledModal,Object.assign({open:_,zIndex:2e3,onClose:()=>C(!1),width:"480px"},{children:t.jsxs("div",Object.assign({style:{padding:16}},{children:[t.jsx(l.InputWithVariables,{addVarBoxRight:"16px",allowMix:!1,onChange:e=>{console.log(e)},prevVariable:{actualValue:"",variableType:"string"},variablesList:g,showSideVariablePanel:!0,placeHolder:"Enter url or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&(console.log(t),O(t.actualValue))},showAddButton:p.format===o.HEADER_TYPES.IMAGE}),t.jsx("button",Object.assign({onClick:()=>O()},{children:"upload media"}))]}))})),!!x&&t.jsx(r.BikImageCropper,{aspectRatio:15/8,src:x,onCropComplete:function(t){return e.__awaiter(this,void 0,void 0,(function*(){M(!1),T("");const e=yield fetch(t);D(yield e.blob()).then((()=>{y(void 0)}))}))},onCancel:()=>{M(!1),y("")}}),t.jsx("input",{ref:S,style:{display:"none"},type:"file",onChange:function(e){var t;T(""),M(!0);const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(p.format===o.HEADER_TYPES.IMAGE){const e=new FileReader;y(""),b(""),e.onload=()=>{y(e.result),b(null==a?void 0:a.name)},a&&e.readAsDataURL(a)}else D(a)},accept:R}),t.jsx(d.default,{imageName:null!==(j=null===(h=null==p?void 0:p.example)||void 0===h?void 0:h.header_handle)&&void 0!==j?j:[],handleImageChange:P,mediaType:null==p?void 0:p.format,error:w,isLoading:A,setOpenEditMedia:C})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),a=require("react"),i=require("../../helpers/FileUploaderHelper.js"),n=require("../../image-cropper/BikImageCropper.js");require("../../image-compress/ImageCompress.js"),require("../../states/StateComponent.js"),require("../../../constants/zindex.js");var r=require("../../modals/styledModal.js");require("../../spinner/Spinner.js");var o=require("../../input-with-vars/InputWithVariables.js"),l=require("../../template-preview/models/TemplateMeta.js"),s=require("../context/templateModalContext.js"),d=require("./EditMediaV2.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(a);exports.default=c=>{let{mediaComponent:p,template:m,updateTemplateImageUrl:f,whatsappSpecificPickerMeta:v,variableList:g}=c;var h,j;const[E,b]=a.useState(void 0),[x,y]=a.useState(),[_,S]=a.useState(),[A,C]=a.useState(!1),w=u.default.createRef(),[I,M]=a.useState(!1),[T,q]=a.useState(""),{template:O,setTemplate:R}=s.useTemplateModalContext();let D;function H(t){var a;return e.__awaiter(this,void 0,void 0,(function*(){if(M(!0),q(""),t)if(t.startsWith("https"))try{const e=yield fetch(t),a=yield e.blob();yield k(a)}catch(e){q("An unknown technical error occurred")}else if(/^{{.*}}$/.test(t)){S(t);const e=Object.assign({},O);if(e.components){const t=null===(a=null==e?void 0:e.components)||void 0===a?void 0:a.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==t&&t>-1&&(null==e?void 0:e.components[t])){const a=Object.assign(Object.assign({},e.components[t]),{format:p.format,example:{header_handle:["https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"]}}),i=[...e.components];i[t]=a,e.components=i}}e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]})),null==R||R(Object.assign({},e)),C(!1),M(!1)}else M(!1),q("Invalid URL or variable");else V()}))}function V(){var e;(null===(e=null==w?void 0:w.current)||void 0===e?void 0:e.click)&&w.current.click()}function k(t){var a;return e.__awaiter(this,void 0,void 0,(function*(){const e=new i.FileUploaderHelper;if(t instanceof Blob){const i=e.validate(t);if(i)q(i),C(!1),M(!1);else{const e=p.format===l.HEADER_TYPES.IMAGE,i=yield v.uploadMediaFiles({file:t,fileName:E,isImage:e});if(i.success){const[e]=t.type.split("/");f(null!==(a=i.url)&&void 0!==a?a:"","application"===e?l.HEADER_TYPES.DOCUMENT:l.HEADER_TYPES[e.toUpperCase()])}else q("An unknown technical error occured");M(!1),C(!1)}}else q("An unknown technical error occured"),C(!1),M(!1)}))}return D=p.format===l.HEADER_TYPES.IMAGE?"image/png, image/jpeg":p.format===l.HEADER_TYPES.VIDEO?"video/mp4":"application/pdf",t.jsxs(t.Fragment,{children:[t.jsx(r.StyledModal,Object.assign({open:A,zIndex:2e3,onClose:()=>C(!1),width:"480px"},{children:t.jsxs("div",Object.assign({style:{padding:16}},{children:[t.jsx(o.InputWithVariables,{addVarBoxRight:"16px",allowMix:!1,onChange:e=>{console.log(e)},prevVariable:{actualValue:"",variableType:"string"},variablesList:g,showSideVariablePanel:!0,placeHolder:"Enter url or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&H(t.actualValue)},showAddButton:p.format===l.HEADER_TYPES.IMAGE}),t.jsx("button",Object.assign({onClick:()=>H()},{children:"upload media"}))]}))})),!!x&&t.jsx(n.BikImageCropper,{aspectRatio:15/8,src:x,onCropComplete:function(t){return e.__awaiter(this,void 0,void 0,(function*(){M(!1),q("");const e=yield fetch(t);k(yield e.blob()).then((()=>{y(void 0)}))}))},onCancel:()=>{M(!1),y("")}}),t.jsx("input",{ref:w,style:{display:"none"},type:"file",onChange:function(e){var t;q(""),M(!0);const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(p.format===l.HEADER_TYPES.IMAGE){const e=new FileReader;y(""),b(""),e.onload=()=>{y(e.result),b(null==a?void 0:a.name)},a&&e.readAsDataURL(a)}else k(a)},accept:D}),t.jsx(d.default,{imageName:null!==(j=null===(h=null==p?void 0:p.example)||void 0===h?void 0:h.header_handle)&&void 0!==j?j:[],handleImageChange:V,mediaType:null==p?void 0:p.format,error:T,isLoading:I,setOpenEditMedia:C,selectedVariable:_})]})};
@@ -2,6 +2,7 @@
2
2
  import { HEADER_TYPES } from "../../template-preview/models/TemplateMeta";
3
3
  export interface EditMediaV2Props {
4
4
  imageName: string[];
5
+ selectedVariable?: string;
5
6
  errorSecondaryText?: string;
6
7
  error?: string;
7
8
  isLoading?: boolean;
@@ -5,4 +5,4 @@ import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import o from"..
5
5
  height: 24px;
6
6
  border-left: 1px solid ${g.stroke.primary};
7
7
  cursor: pointer;
8
- `,u=l=>{const{imageName:u,error:b,isLoading:x,mediaType:w,handleImageChange:O,setOpenEditMedia:C}=l,L=null==u?void 0:u[0].split("/"),E=null==L?void 0:L[L.length-1];return e(f,{children:[t(j,Object.assign({error:!!b,onClick:b?O:void 0},{children:b?t(s,{color:g.content.brand,width:32,height:32}):x?t(d,{size:"small"}):w===c.IMAGE?t("img",{alt:"",src:null==u?void 0:u[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):w===c.VIDEO?t(n,{width:18,height:22,color:g.content.placeholder}):t(o,{width:18,height:22,color:g.content.placeholder})})),e(v,{children:[t("div",Object.assign({style:{flex:1}},{children:u&&b?t(i,{}):x?t(a,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):t(m,Object.assign({style:{color:g.content.primary,marginLeft:8}},{children:h.toCapitilize(null==w?void 0:w.toLowerCase())||E}))})),!!b&&e("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e(m,Object.assign({style:{color:g.content.negative}},{children:["Error loading this ",null==w?void 0:w.toLowerCase(),". Retry"]})),t(p,Object.assign({style:{color:g.content.secondary}},{children:b}))]})),!b&&!x&&t(y,Object.assign({onClick:()=>null==C?void 0:C(!0),onKeyDown:()=>null==C?void 0:C(!0),role:"presentation"},{children:t(r,{width:24,height:24,color:g.content.placeholder})}))]})]})};export{u as default};
8
+ `,u=l=>{const{imageName:u,error:b,isLoading:x,mediaType:w,handleImageChange:O,selectedVariable:C,setOpenEditMedia:L}=l,E=null==u?void 0:u[0].split("/"),M=null==E?void 0:E[E.length-1];return e(f,{children:[t(j,Object.assign({error:!!b,onClick:b?O:void 0},{children:b?t(s,{color:g.content.brand,width:32,height:32}):x?t(d,{size:"small"}):w===c.IMAGE?t("img",{alt:"",src:null==u?void 0:u[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):w===c.VIDEO?t(n,{width:18,height:22,color:g.content.placeholder}):t(o,{width:18,height:22,color:g.content.placeholder})})),e(v,{children:[t("div",Object.assign({style:{flex:1}},{children:u&&b?t(i,{}):x?t(a,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):t(m,Object.assign({style:{color:g.content.primary,marginLeft:8}},{children:C||h.toCapitilize(null==w?void 0:w.toLowerCase())||M}))})),!!b&&e("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e(m,Object.assign({style:{color:g.content.negative}},{children:["Error loading this ",null==w?void 0:w.toLowerCase(),". Retry"]})),t(p,Object.assign({style:{color:g.content.secondary}},{children:b}))]})),!b&&!x&&t(y,Object.assign({onClick:()=>null==L?void 0:L(!0),onKeyDown:()=>null==L?void 0:L(!0),role:"presentation"},{children:t(r,{width:24,height:24,color:g.content.placeholder})}))]})]})};export{u as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,Fragment as i,jsx as o}from"react/jsx-runtime";import a,{useState as n}from"react";import{FileUploaderHelper as l}from"../../helpers/FileUploaderHelper.js";import{BikImageCropper as r}from"../../image-cropper/BikImageCropper.js";import"../../image-compress/ImageCompress.js";import"../../states/StateComponent.js";import"../../../constants/zindex.js";import{StyledModal as s}from"../../modals/styledModal.js";import"../../spinner/Spinner.js";import{InputWithVariables as c}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as p}from"../../template-preview/models/TemplateMeta.js";import{useTemplateModalContext as d}from"../context/templateModalContext.js";import m from"./EditMediaV2.js";const u=u=>{let{mediaComponent:f,template:v,updateTemplateImageUrl:g,whatsappSpecificPickerMeta:h,variableList:b}=u;var j,y;const[C,M]=n(void 0),[w,I]=n(),[x,O]=n(!1),A=a.createRef(),[E,V]=n(!1),[k,T]=n(""),{template:B,setTemplate:R}=d();let U;function G(t){return e(this,void 0,void 0,(function*(){if(V(!0),T(""),t){const e=t.startsWith("https")?t:"https://shorturl.at/fgyP0";try{const i=yield fetch(e),o=yield i.blob();if(yield S(o),/^{{.*}}$/.test(t)){const e=Object.assign({},B);e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]}),null==R||R(Object.assign({},e)))}}catch(e){T("An unknown technical error occured")}}else L()}))}function L(){var e;(null===(e=null==A?void 0:A.current)||void 0===e?void 0:e.click)&&A.current.click()}function S(t){var i;return e(this,void 0,void 0,(function*(){const e=new l;if(t instanceof Blob){const o=e.validate(t);if(o)T(o),O(!1),V(!1);else{const e=f.format===p.IMAGE,o=yield h.uploadMediaFiles({file:t,fileName:C,isImage:e});if(o.success){const[e]=t.type.split("/");g(null!==(i=o.url)&&void 0!==i?i:"","application"===e?p.DOCUMENT:p[e.toUpperCase()])}else T("An unknown technical error occured");V(!1),O(!1)}}else T("An unknown technical error occured"),O(!1),V(!1)}))}return console.log("currentTemplate",B),U=f.format===p.IMAGE?"image/png, image/jpeg":f.format===p.VIDEO?"video/mp4":"application/pdf",t(i,{children:[o(s,Object.assign({open:x,zIndex:2e3,onClose:()=>O(!1),width:"480px"},{children:t("div",Object.assign({style:{padding:16}},{children:[o(c,{addVarBoxRight:"16px",allowMix:!1,onChange:e=>{console.log(e)},prevVariable:{actualValue:"",variableType:"string"},variablesList:b,showSideVariablePanel:!0,placeHolder:"Enter url or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&(console.log(t),G(t.actualValue))},showAddButton:f.format===p.IMAGE}),o("button",Object.assign({onClick:()=>G()},{children:"upload media"}))]}))})),!!w&&o(r,{aspectRatio:15/8,src:w,onCropComplete:function(t){return e(this,void 0,void 0,(function*(){V(!1),T("");const e=yield fetch(t);S(yield e.blob()).then((()=>{I(void 0)}))}))},onCancel:()=>{V(!1),I("")}}),o("input",{ref:A,style:{display:"none"},type:"file",onChange:function(e){var t;T(""),V(!0);const i=null===(t=e.target.files)||void 0===t?void 0:t[0];if(f.format===p.IMAGE){const e=new FileReader;I(""),M(""),e.onload=()=>{I(e.result),M(null==i?void 0:i.name)},i&&e.readAsDataURL(i)}else S(i)},accept:U}),o(m,{imageName:null!==(y=null===(j=null==f?void 0:f.example)||void 0===j?void 0:j.header_handle)&&void 0!==y?y:[],handleImageChange:L,mediaType:null==f?void 0:f.format,error:k,isLoading:E,setOpenEditMedia:O})]})};export{u as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,Fragment as o,jsx as i}from"react/jsx-runtime";import n,{useState as a}from"react";import{FileUploaderHelper as l}from"../../helpers/FileUploaderHelper.js";import{BikImageCropper as r}from"../../image-cropper/BikImageCropper.js";import"../../image-compress/ImageCompress.js";import"../../states/StateComponent.js";import"../../../constants/zindex.js";import{StyledModal as s}from"../../modals/styledModal.js";import"../../spinner/Spinner.js";import{InputWithVariables as p}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as c}from"../../template-preview/models/TemplateMeta.js";import{useTemplateModalContext as d}from"../context/templateModalContext.js";import m from"./EditMediaV2.js";const u=u=>{let{mediaComponent:f,template:v,updateTemplateImageUrl:g,whatsappSpecificPickerMeta:h,variableList:b}=u;var j,y;const[C,I]=a(void 0),[w,x]=a(),[E,M]=a(),[O,A]=a(!1),V=n.createRef(),[k,T]=a(!1),[R,U]=a(""),{template:B,setTemplate:L}=d();let N;function D(t){var o;return e(this,void 0,void 0,(function*(){if(T(!0),U(""),t)if(t.startsWith("https"))try{const e=yield fetch(t),o=yield e.blob();yield S(o)}catch(e){U("An unknown technical error occurred")}else if(/^{{.*}}$/.test(t)){M(t);const e=Object.assign({},B);if(e.components){const t=null===(o=null==e?void 0:e.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==t&&t>-1&&(null==e?void 0:e.components[t])){const o=Object.assign(Object.assign({},e.components[t]),{format:f.format,example:{header_handle:["https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"]}}),i=[...e.components];i[t]=o,e.components=i}}e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]})),null==L||L(Object.assign({},e)),A(!1),T(!1)}else T(!1),U("Invalid URL or variable");else G()}))}function G(){var e;(null===(e=null==V?void 0:V.current)||void 0===e?void 0:e.click)&&V.current.click()}function S(t){var o;return e(this,void 0,void 0,(function*(){const e=new l;if(t instanceof Blob){const i=e.validate(t);if(i)U(i),A(!1),T(!1);else{const e=f.format===c.IMAGE,i=yield h.uploadMediaFiles({file:t,fileName:C,isImage:e});if(i.success){const[e]=t.type.split("/");g(null!==(o=i.url)&&void 0!==o?o:"","application"===e?c.DOCUMENT:c[e.toUpperCase()])}else U("An unknown technical error occured");T(!1),A(!1)}}else U("An unknown technical error occured"),A(!1),T(!1)}))}return N=f.format===c.IMAGE?"image/png, image/jpeg":f.format===c.VIDEO?"video/mp4":"application/pdf",t(o,{children:[i(s,Object.assign({open:O,zIndex:2e3,onClose:()=>A(!1),width:"480px"},{children:t("div",Object.assign({style:{padding:16}},{children:[i(p,{addVarBoxRight:"16px",allowMix:!1,onChange:e=>{console.log(e)},prevVariable:{actualValue:"",variableType:"string"},variablesList:b,showSideVariablePanel:!0,placeHolder:"Enter url or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&D(t.actualValue)},showAddButton:f.format===c.IMAGE}),i("button",Object.assign({onClick:()=>D()},{children:"upload media"}))]}))})),!!w&&i(r,{aspectRatio:15/8,src:w,onCropComplete:function(t){return e(this,void 0,void 0,(function*(){T(!1),U("");const e=yield fetch(t);S(yield e.blob()).then((()=>{x(void 0)}))}))},onCancel:()=>{T(!1),x("")}}),i("input",{ref:V,style:{display:"none"},type:"file",onChange:function(e){var t;U(""),T(!0);const o=null===(t=e.target.files)||void 0===t?void 0:t[0];if(f.format===c.IMAGE){const e=new FileReader;x(""),I(""),e.onload=()=>{x(e.result),I(null==o?void 0:o.name)},o&&e.readAsDataURL(o)}else S(o)},accept:N}),i(m,{imageName:null!==(y=null===(j=null==f?void 0:f.example)||void 0===j?void 0:j.header_handle)&&void 0!==y?y:[],handleImageChange:G,mediaType:null==f?void 0:f.format,error:R,isLoading:k,setOpenEditMedia:A,selectedVariable:E})]})};export{u as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.359-beta.23",
3
+ "version": "0.0.359-beta.25",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",