@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.
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.d.ts +1 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.d.ts +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -1
- package/package.json +1 -1
|
@@ -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:
|
|
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})}))]})]})};
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js
CHANGED
|
@@ -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"),
|
|
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:_})]})};
|
|
@@ -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:
|
|
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};
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,Fragment as
|
|
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};
|