@bikdotai/bik-component-library 0.0.612-beta-vsp.8 → 0.0.612-beta-vsp.9
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),o=require("../../utils/StringUtils.js"),a=require("../../constants/Theme.js"),i=require("../modals/styledModal.js"),s=require("../template-preview/models/Channels.js"),r=require("../template-preview/models/WhatsAppTemplate.js"),n=require("./context/templateModalContext.js"),d=require("./modalElements/Footer.js"),u=require("./modalElements/TemplateSelectModalContent.js"),c=require("./utils/convertPlaceholdersToBikDropdown.js"),p=require("./utils/validateName.js");exports.TemplateContextMapper=v=>{var m,C,h,b,E,S,f,x;const{selectedTemplate:P,closeDialog:g,showVariableMapping:T,channel:y,htmlContent:D,templateVariables:I,onTemplateSelect:L,globalPlaceholders:N,showOnlyContent:j,whatsappSpecificPickerMeta:w,zIndex:k,showVariableModal:V,variableList:A,discountCode:H,setDiscountCode:M,onBackPress:O,enabledCustomText:q,variableListForImage:B,showSampleValues:F,disableEditVariable:_,pod:W,extras:Y,pickerConf:R,selectedCarouselProducts:U,disableEditExpiry:z,cardWidth:$,onDeleteSelectedProducts:G,fileName:J,setFileName:K,hideDeviceContainerInPreview:Q,maxCharLimit:X,onDefaultVariableSelect:Z,skipDefaultVariableContent:ee,disableDatePicker:te,disableCopyCode:le,initialExpiryDateTime:oe,showDiscountCodeExpiryInfo:ae}=v;l.useEffect((()=>{pe(D)}),[D]);const ie=y===s.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(C=null===(m=null==P?void 0:P.components)||void 0===m?void 0:m[1])||void 0===C?void 0:C.type),se=null==P?void 0:P.isProductCarouselType,[re,ne]=l.useState(y===s.CHANNEL_TYPE.EMAIL||y==s.CHANNEL_TYPE.WEBPUSH||ie?"desktop":"mobile"),[de,ue]=l.useState(!1),[ce,pe]=l.useState(D),[ve,me]=l.useState(!1),[Ce,he]=l.useState([]),[be,Ee]=l.useState({}),[Se,fe]=l.useState(P),[xe,Pe]=l.useState([]),[ge,Te]=l.useState(null),[ye,De]=l.useState(!1),[Ie,Le]=l.useState(null!=I?I:[]),[Ne,je]=l.useState(!1),[we,ke]=l.useState(ie?(null===(b=null===(h=null==Se?void 0:Se.mapping)||void 0===h?void 0:h.body)||void 0===b?void 0:b.length)?-1:0:-1),[Ve,Ae]=l.useState([]),[He,Me]=l.useState(void 0),Oe=l.useRef(null),[qe,Be]=l.useState(!1),[Fe,_e]=l.useState(!1),[We,Ye]=l.useState(!1),[Re,Ue]=l.useState({});l.useEffect((()=>{U?Ae(U):se&&Ae([])}),[U]),l.useEffect((()=>{var e;if(!ye&&se&&(!U||0===Ae.length)){const t=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e[1].cards,l=[];null==t||t.forEach((e=>{var t;null===(t=null==e?void 0:e.components)||void 0===t||t.forEach((e=>{var t,o,a;"HEADER"===e.type&&l.push(null!==(a=null===(o=null===(t=e.example)||void 0===t?void 0:t.header_handle)||void 0===o?void 0:o[0])&&void 0!==a?a:"")}))})),Pe(l),De(!0)}}),[ye]);const ze=l.useMemo((()=>c.convertPlaceholdersToBikDropdown(N)),[N]);return l.useEffect((()=>{Me(t.cloneDeep(A))}),[A]),e.jsx(n.TemplateModalContext.Provider,Object.assign({value:{hideFooterButton:We,setHideFooterButton:Ye,hideCrossButton:Fe,setHideCrossButton:_e,variableList:He,setVariableList:Me,variableCallback:ge,setVariableCallback:Te,showVariablePicker:de,setShowVariablePicker:ue,template:Se,setTemplate:fe,device:re,setDevice:ne,display_content:ce,setDisplayContent:pe,originalVariableList:Ie,setOriginalVariableList:Le,isError:ve,setIsError:me,channel:y,globalNormalizedPlaceholders:ze,templateSelectionTriggered:Ne,setTemplateSelectionTriggered:je,enabledCustomText:q,disableEditVariable:_,pod:W,extras:Y,isWhatsappCarousel:ie,selectedCarouselIndex:we,setSelectedCarouselIndex:ke,isProductCarouselType:se,templateErrorIndexes:be,cardCount:ie?null===(S=null===(E=P.components)||void 0===E?void 0:E[1].cards)||void 0===S?void 0:S.length:void 0,errorIndexes:Ce,setErrorIndexes:he,pickerConf:R,carouselProducts:Ve,setCarouselProducts:Ae,disableEditExpiry:z,cardWidth:$,cardImages:xe,onDeleteSelectedProducts:G,hideDeviceContainerInPreview:Q,sliderRef:Oe,isCarouselHovered:qe,setIsCarouselHovered:Be,maxCharLimit:X,ctaOptionsErrors:Re,setCtaOptionsErrors:Ue,onDefaultVariableSelect:Z,disableDatePicker:te,disableCopyCode:le,initialExpiryDateTime:oe,showDiscountCodeExpiryInfo:ae}},{children:j?e.jsx(u.default,{variableListFromProps:A,channel:s.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(i.StyledModal,Object.assign({hideCrossButton:Fe,zIndex:k,centralContainerStyles:{width:ie?900:y===s.CHANNEL_TYPE.EMAIL&&T?1e3:800},open:!0,onClose:()=>{null==g||g()},headingTitle:null==Se?void 0:Se.label,headingSubtitle:y===s.CHANNEL_TYPE.WHATSAPP?`${o.default.capitaliseFirstLetterOfString(null!==(f=null==Se?void 0:Se.category)&&void 0!==f?f:"")} • ${null!==(x=null==Se?void 0:Se.templateCategory)&&void 0!==x?x:""}`:"",onBackPress:()=>{null==O||O()},modalHeaderStyles:{borderBottom:`1px solid ${a.COLORS.stroke.primary}`}},{children:[e.jsx(u.default,{variableListFromProps:A,showSampleValues:F,showVariableMapping:T,channel:y,whatsappSpecificPickerMeta:w,showVariableModal:V,discountCode:H,setDiscountCode:M,variableListForImage:B&&(null==B?void 0:B.length)>0?B:He,fileName:J,setFileName:e=>{null==K||K(e)},skipDefaultVariableContent:ee}),L?e.jsx(d.default,{isWhatsappCarousel:null!=ie&&ie,onSelect:function(){var e,t,l;if((null==Ve?void 0:Ve.length)<1&&se)return void me(!0);if(Object.keys(Re).length>0&&W!==r.POD.CHATBOT)return void me(!0);if(console.log(W,"pod"),W===r.POD.CHATBOT){console.log(Se,"template");const l=null!==(t=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e.some((e=>"DOCUMENT"===e.format)))&&void 0!==t&&t;if(console.log(J,"fileName"),console.log(J,p.validateInputName(null!=J?J:"",W),"validate"),l&&!p.validateInputName(null!=J?J:"",W))return void me(!0)}const o=null==L?void 0:L(Se,Ie,null!=ce?ce:"",Ve);Ee(null!==(l=null==o?void 0:o.templateErrorIndexes)&&void 0!==l?l:{body:[],buttons:[]}),(null==o?void 0:o.errorIndexes)||(null==o?void 0:o.error)?((null==o?void 0:o.errorIndexes)&&he(o.errorIndexes),(null==o?void 0:o.error)&&me(!!(null==o?void 0:o.error))):je(!0)}}):e.jsx(e.Fragment,{})]}))}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),o=require("../../utils/StringUtils.js"),a=require("../../constants/Theme.js"),i=require("../modals/styledModal.js"),s=require("../template-preview/models/Channels.js"),r=require("../template-preview/models/WhatsAppTemplate.js"),n=require("./context/templateModalContext.js"),d=require("./modalElements/Footer.js"),u=require("./modalElements/TemplateSelectModalContent.js"),c=require("./utils/convertPlaceholdersToBikDropdown.js"),p=require("./utils/validateName.js");exports.TemplateContextMapper=v=>{var m,C,h,b,E,S,f,x;const{selectedTemplate:P,closeDialog:g,showVariableMapping:T,channel:y,htmlContent:D,templateVariables:I,onTemplateSelect:L,globalPlaceholders:N,showOnlyContent:j,whatsappSpecificPickerMeta:w,zIndex:k,showVariableModal:V,variableList:A,discountCode:H,setDiscountCode:M,onBackPress:O,enabledCustomText:q,variableListForImage:B,showSampleValues:F,disableEditVariable:_,pod:W,extras:Y,pickerConf:R,selectedCarouselProducts:U,disableEditExpiry:z,cardWidth:$,onDeleteSelectedProducts:G,fileName:J,setFileName:K,hideDeviceContainerInPreview:Q,maxCharLimit:X,onDefaultVariableSelect:Z,skipDefaultVariableContent:ee,disableDatePicker:te,disableCopyCode:le,initialExpiryDateTime:oe,showDiscountCodeExpiryInfo:ae}=v;console.log(J,"fileName"),l.useEffect((()=>{pe(D)}),[D]);const ie=y===s.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(C=null===(m=null==P?void 0:P.components)||void 0===m?void 0:m[1])||void 0===C?void 0:C.type),se=null==P?void 0:P.isProductCarouselType,[re,ne]=l.useState(y===s.CHANNEL_TYPE.EMAIL||y==s.CHANNEL_TYPE.WEBPUSH||ie?"desktop":"mobile"),[de,ue]=l.useState(!1),[ce,pe]=l.useState(D),[ve,me]=l.useState(!1),[Ce,he]=l.useState([]),[be,Ee]=l.useState({}),[Se,fe]=l.useState(P),[xe,Pe]=l.useState([]),[ge,Te]=l.useState(null),[ye,De]=l.useState(!1),[Ie,Le]=l.useState(null!=I?I:[]),[Ne,je]=l.useState(!1),[we,ke]=l.useState(ie?(null===(b=null===(h=null==Se?void 0:Se.mapping)||void 0===h?void 0:h.body)||void 0===b?void 0:b.length)?-1:0:-1),[Ve,Ae]=l.useState([]),[He,Me]=l.useState(void 0),Oe=l.useRef(null),[qe,Be]=l.useState(!1),[Fe,_e]=l.useState(!1),[We,Ye]=l.useState(!1),[Re,Ue]=l.useState({});l.useEffect((()=>{U?Ae(U):se&&Ae([])}),[U]),l.useEffect((()=>{var e;if(!ye&&se&&(!U||0===Ae.length)){const t=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e[1].cards,l=[];null==t||t.forEach((e=>{var t;null===(t=null==e?void 0:e.components)||void 0===t||t.forEach((e=>{var t,o,a;"HEADER"===e.type&&l.push(null!==(a=null===(o=null===(t=e.example)||void 0===t?void 0:t.header_handle)||void 0===o?void 0:o[0])&&void 0!==a?a:"")}))})),Pe(l),De(!0)}}),[ye]);const ze=l.useMemo((()=>c.convertPlaceholdersToBikDropdown(N)),[N]);return l.useEffect((()=>{Me(t.cloneDeep(A))}),[A]),e.jsx(n.TemplateModalContext.Provider,Object.assign({value:{hideFooterButton:We,setHideFooterButton:Ye,hideCrossButton:Fe,setHideCrossButton:_e,variableList:He,setVariableList:Me,variableCallback:ge,setVariableCallback:Te,showVariablePicker:de,setShowVariablePicker:ue,template:Se,setTemplate:fe,device:re,setDevice:ne,display_content:ce,setDisplayContent:pe,originalVariableList:Ie,setOriginalVariableList:Le,isError:ve,setIsError:me,channel:y,globalNormalizedPlaceholders:ze,templateSelectionTriggered:Ne,setTemplateSelectionTriggered:je,enabledCustomText:q,disableEditVariable:_,pod:W,extras:Y,isWhatsappCarousel:ie,selectedCarouselIndex:we,setSelectedCarouselIndex:ke,isProductCarouselType:se,templateErrorIndexes:be,cardCount:ie?null===(S=null===(E=P.components)||void 0===E?void 0:E[1].cards)||void 0===S?void 0:S.length:void 0,errorIndexes:Ce,setErrorIndexes:he,pickerConf:R,carouselProducts:Ve,setCarouselProducts:Ae,disableEditExpiry:z,cardWidth:$,cardImages:xe,onDeleteSelectedProducts:G,hideDeviceContainerInPreview:Q,sliderRef:Oe,isCarouselHovered:qe,setIsCarouselHovered:Be,maxCharLimit:X,ctaOptionsErrors:Re,setCtaOptionsErrors:Ue,onDefaultVariableSelect:Z,disableDatePicker:te,disableCopyCode:le,initialExpiryDateTime:oe,showDiscountCodeExpiryInfo:ae}},{children:j?e.jsx(u.default,{variableListFromProps:A,channel:s.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(i.StyledModal,Object.assign({hideCrossButton:Fe,zIndex:k,centralContainerStyles:{width:ie?900:y===s.CHANNEL_TYPE.EMAIL&&T?1e3:800},open:!0,onClose:()=>{null==g||g()},headingTitle:null==Se?void 0:Se.label,headingSubtitle:y===s.CHANNEL_TYPE.WHATSAPP?`${o.default.capitaliseFirstLetterOfString(null!==(f=null==Se?void 0:Se.category)&&void 0!==f?f:"")} • ${null!==(x=null==Se?void 0:Se.templateCategory)&&void 0!==x?x:""}`:"",onBackPress:()=>{null==O||O()},modalHeaderStyles:{borderBottom:`1px solid ${a.COLORS.stroke.primary}`}},{children:[e.jsx(u.default,{variableListFromProps:A,showSampleValues:F,showVariableMapping:T,channel:y,whatsappSpecificPickerMeta:w,showVariableModal:V,discountCode:H,setDiscountCode:M,variableListForImage:B&&(null==B?void 0:B.length)>0?B:He,fileName:J,setFileName:e=>{null==K||K(e)},skipDefaultVariableContent:ee}),L?e.jsx(d.default,{isWhatsappCarousel:null!=ie&&ie,onSelect:function(){var e,t,l;if((null==Ve?void 0:Ve.length)<1&&se)return void me(!0);if(Object.keys(Re).length>0&&W!==r.POD.CHATBOT)return void me(!0);if(console.log(W,"pod"),W===r.POD.CHATBOT){console.log(Se,"template");const l=null!==(t=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e.some((e=>"DOCUMENT"===e.format)))&&void 0!==t&&t;if(console.log(J,"fileName"),console.log(J,p.validateInputName(null!=J?J:"",W),"validate"),l&&!p.validateInputName(null!=J?J:"",W))return void me(!0)}const o=null==L?void 0:L(Se,Ie,null!=ce?ce:"",Ve);Ee(null!==(l=null==o?void 0:o.templateErrorIndexes)&&void 0!==l?l:{body:[],buttons:[]}),(null==o?void 0:o.errorIndexes)||(null==o?void 0:o.error)?((null==o?void 0:o.errorIndexes)&&he(o.errorIndexes),(null==o?void 0:o.error)&&me(!!(null==o?void 0:o.error))):je(!0)}}):e.jsx(e.Fragment,{})]}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o,Fragment as l}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useEffect as i,useState as r,useRef as a,useMemo as s}from"react";import n from"../../utils/StringUtils.js";import{COLORS as d}from"../../constants/Theme.js";import{StyledModal as
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as l}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useEffect as i,useState as r,useRef as a,useMemo as s}from"react";import n from"../../utils/StringUtils.js";import{COLORS as d}from"../../constants/Theme.js";import{StyledModal as c}from"../modals/styledModal.js";import{CHANNEL_TYPE as u}from"../template-preview/models/Channels.js";import{POD as p}from"../template-preview/models/WhatsAppTemplate.js";import{TemplateModalContext as m}from"./context/templateModalContext.js";import v from"./modalElements/Footer.js";import h from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as C}from"./utils/convertPlaceholdersToBikDropdown.js";import{validateInputName as b}from"./utils/validateName.js";const f=f=>{var g,x,E,P,y,S,T,I;const{selectedTemplate:D,closeDialog:w,showVariableMapping:V,channel:k,htmlContent:L,templateVariables:j,onTemplateSelect:M,globalPlaceholders:A,showOnlyContent:B,whatsappSpecificPickerMeta:H,zIndex:O,showVariableModal:F,variableList:N,discountCode:W,setDiscountCode:U,onBackPress:z,enabledCustomText:R,variableListForImage:$,showSampleValues:_,disableEditVariable:q,pod:G,extras:J,pickerConf:K,selectedCarouselProducts:Q,disableEditExpiry:X,cardWidth:Y,onDeleteSelectedProducts:Z,fileName:ee,setFileName:oe,hideDeviceContainerInPreview:le,maxCharLimit:te,onDefaultVariableSelect:ie,skipDefaultVariableContent:re,disableDatePicker:ae,disableCopyCode:se,initialExpiryDateTime:ne,showDiscountCodeExpiryInfo:de}=f;console.log(ee,"fileName"),i((()=>{be(L)}),[L]);const ce=k===u.WHATSAPP&&"CAROUSEL"===(null===(x=null===(g=null==D?void 0:D.components)||void 0===g?void 0:g[1])||void 0===x?void 0:x.type),ue=null==D?void 0:D.isProductCarouselType,[pe,me]=r(k===u.EMAIL||k==u.WEBPUSH||ce?"desktop":"mobile"),[ve,he]=r(!1),[Ce,be]=r(L),[fe,ge]=r(!1),[xe,Ee]=r([]),[Pe,ye]=r({}),[Se,Te]=r(D),[Ie,De]=r([]),[we,Ve]=r(null),[ke,Le]=r(!1),[je,Me]=r(null!=j?j:[]),[Ae,Be]=r(!1),[He,Oe]=r(ce?(null===(P=null===(E=null==Se?void 0:Se.mapping)||void 0===E?void 0:E.body)||void 0===P?void 0:P.length)?-1:0:-1),[Fe,Ne]=r([]),[We,Ue]=r(void 0),ze=a(null),[Re,$e]=r(!1),[_e,qe]=r(!1),[Ge,Je]=r(!1),[Ke,Qe]=r({});i((()=>{Q?Ne(Q):ue&&Ne([])}),[Q]),i((()=>{var e;if(!ke&&ue&&(!Q||0===Ne.length)){const o=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e[1].cards,l=[];null==o||o.forEach((e=>{var o;null===(o=null==e?void 0:e.components)||void 0===o||o.forEach((e=>{var o,t,i;"HEADER"===e.type&&l.push(null!==(i=null===(t=null===(o=e.example)||void 0===o?void 0:o.header_handle)||void 0===t?void 0:t[0])&&void 0!==i?i:"")}))})),De(l),Le(!0)}}),[ke]);const Xe=s((()=>C(A)),[A]);return i((()=>{Ue(t(N))}),[N]),e(m.Provider,Object.assign({value:{hideFooterButton:Ge,setHideFooterButton:Je,hideCrossButton:_e,setHideCrossButton:qe,variableList:We,setVariableList:Ue,variableCallback:we,setVariableCallback:Ve,showVariablePicker:ve,setShowVariablePicker:he,template:Se,setTemplate:Te,device:pe,setDevice:me,display_content:Ce,setDisplayContent:be,originalVariableList:je,setOriginalVariableList:Me,isError:fe,setIsError:ge,channel:k,globalNormalizedPlaceholders:Xe,templateSelectionTriggered:Ae,setTemplateSelectionTriggered:Be,enabledCustomText:R,disableEditVariable:q,pod:G,extras:J,isWhatsappCarousel:ce,selectedCarouselIndex:He,setSelectedCarouselIndex:Oe,isProductCarouselType:ue,templateErrorIndexes:Pe,cardCount:ce?null===(S=null===(y=D.components)||void 0===y?void 0:y[1].cards)||void 0===S?void 0:S.length:void 0,errorIndexes:xe,setErrorIndexes:Ee,pickerConf:K,carouselProducts:Fe,setCarouselProducts:Ne,disableEditExpiry:X,cardWidth:Y,cardImages:Ie,onDeleteSelectedProducts:Z,hideDeviceContainerInPreview:le,sliderRef:ze,isCarouselHovered:Re,setIsCarouselHovered:$e,maxCharLimit:te,ctaOptionsErrors:Ke,setCtaOptionsErrors:Qe,onDefaultVariableSelect:ie,disableDatePicker:ae,disableCopyCode:se,initialExpiryDateTime:ne,showDiscountCodeExpiryInfo:de}},{children:B?e(h,{variableListFromProps:N,channel:u.EMAIL,hideHeader:!0}):o(c,Object.assign({hideCrossButton:_e,zIndex:O,centralContainerStyles:{width:ce?900:k===u.EMAIL&&V?1e3:800},open:!0,onClose:()=>{null==w||w()},headingTitle:null==Se?void 0:Se.label,headingSubtitle:k===u.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(T=null==Se?void 0:Se.category)&&void 0!==T?T:"")} • ${null!==(I=null==Se?void 0:Se.templateCategory)&&void 0!==I?I:""}`:"",onBackPress:()=>{null==z||z()},modalHeaderStyles:{borderBottom:`1px solid ${d.stroke.primary}`}},{children:[e(h,{variableListFromProps:N,showSampleValues:_,showVariableMapping:V,channel:k,whatsappSpecificPickerMeta:H,showVariableModal:F,discountCode:W,setDiscountCode:U,variableListForImage:$&&(null==$?void 0:$.length)>0?$:We,fileName:ee,setFileName:e=>{null==oe||oe(e)},skipDefaultVariableContent:re}),M?e(v,{isWhatsappCarousel:null!=ce&&ce,onSelect:function(){var e,o,l;if((null==Fe?void 0:Fe.length)<1&&ue)return void ge(!0);if(Object.keys(Ke).length>0&&G!==p.CHATBOT)return void ge(!0);if(console.log(G,"pod"),G===p.CHATBOT){console.log(Se,"template");const l=null!==(o=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e.some((e=>"DOCUMENT"===e.format)))&&void 0!==o&&o;if(console.log(ee,"fileName"),console.log(ee,b(null!=ee?ee:"",G),"validate"),l&&!b(null!=ee?ee:"",G))return void ge(!0)}const t=null==M?void 0:M(Se,je,null!=Ce?Ce:"",Fe);ye(null!==(l=null==t?void 0:t.templateErrorIndexes)&&void 0!==l?l:{body:[],buttons:[]}),(null==t?void 0:t.errorIndexes)||(null==t?void 0:t.error)?((null==t?void 0:t.errorIndexes)&&Ee(t.errorIndexes),(null==t?void 0:t.error)&&ge(!!(null==t?void 0:t.error))):Be(!0)}}):e(l,{})]}))}))};export{f as TemplateContextMapper};
|