@bikdotai/bik-component-library 0.0.612-beta-vsp.8 → 0.0.612-beta-vsp.11

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,S,E,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,[ie,se]=l.useState(J);l.useEffect((()=>{se(J)}),[J]),console.log(ie,"tempState"),l.useEffect((()=>{me(D)}),[D]);const re=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),ne=null==P?void 0:P.isProductCarouselType,[de,ue]=l.useState(y===s.CHANNEL_TYPE.EMAIL||y==s.CHANNEL_TYPE.WEBPUSH||re?"desktop":"mobile"),[ce,pe]=l.useState(!1),[ve,me]=l.useState(D),[Ce,he]=l.useState(!1),[be,Se]=l.useState([]),[Ee,fe]=l.useState({}),[xe,Pe]=l.useState(P),[ge,Te]=l.useState([]),[ye,De]=l.useState(null),[Ie,Le]=l.useState(!1),[Ne,je]=l.useState(null!=I?I:[]),[we,ke]=l.useState(!1),[Ve,Ae]=l.useState(re?(null===(b=null===(h=null==xe?void 0:xe.mapping)||void 0===h?void 0:h.body)||void 0===b?void 0:b.length)?-1:0:-1),[He,Me]=l.useState([]),[Oe,qe]=l.useState(void 0),Be=l.useRef(null),[Fe,_e]=l.useState(!1),[We,Ye]=l.useState(!1),[Re,Ue]=l.useState(!1),[ze,$e]=l.useState({});l.useEffect((()=>{U?Me(U):ne&&Me([])}),[U]),l.useEffect((()=>{var e;if(!Ie&&ne&&(!U||0===Me.length)){const t=null===(e=null==xe?void 0:xe.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:"")}))})),Te(l),Le(!0)}}),[Ie]);const Ge=l.useMemo((()=>c.convertPlaceholdersToBikDropdown(N)),[N]);return l.useEffect((()=>{qe(t.cloneDeep(A))}),[A]),e.jsx(n.TemplateModalContext.Provider,Object.assign({value:{hideFooterButton:Re,setHideFooterButton:Ue,hideCrossButton:We,setHideCrossButton:Ye,variableList:Oe,setVariableList:qe,variableCallback:ye,setVariableCallback:De,showVariablePicker:ce,setShowVariablePicker:pe,template:xe,setTemplate:Pe,device:de,setDevice:ue,display_content:ve,setDisplayContent:me,originalVariableList:Ne,setOriginalVariableList:je,isError:Ce,setIsError:he,channel:y,globalNormalizedPlaceholders:Ge,templateSelectionTriggered:we,setTemplateSelectionTriggered:ke,enabledCustomText:q,disableEditVariable:_,pod:W,extras:Y,isWhatsappCarousel:re,selectedCarouselIndex:Ve,setSelectedCarouselIndex:Ae,isProductCarouselType:ne,templateErrorIndexes:Ee,cardCount:re?null===(E=null===(S=P.components)||void 0===S?void 0:S[1].cards)||void 0===E?void 0:E.length:void 0,errorIndexes:be,setErrorIndexes:Se,pickerConf:R,carouselProducts:He,setCarouselProducts:Me,disableEditExpiry:z,cardWidth:$,cardImages:ge,onDeleteSelectedProducts:G,hideDeviceContainerInPreview:Q,sliderRef:Be,isCarouselHovered:Fe,setIsCarouselHovered:_e,maxCharLimit:X,ctaOptionsErrors:ze,setCtaOptionsErrors:$e,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:We,zIndex:k,centralContainerStyles:{width:re?900:y===s.CHANNEL_TYPE.EMAIL&&T?1e3:800},open:!0,onClose:()=>{null==g||g()},headingTitle:null==xe?void 0:xe.label,headingSubtitle:y===s.CHANNEL_TYPE.WHATSAPP?`${o.default.capitaliseFirstLetterOfString(null!==(f=null==xe?void 0:xe.category)&&void 0!==f?f:"")} • ${null!==(x=null==xe?void 0:xe.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:Oe,fileName:J,setFileName:e=>{null==K||K(e)},skipDefaultVariableContent:ee}),L?e.jsx(d.default,{isWhatsappCarousel:null!=re&&re,onSelect:function(){var e,t,l;if((null==He?void 0:He.length)<1&&ne)return void he(!0);if(Object.keys(ze).length>0&&W!==r.POD.CHATBOT)return void he(!0);if(console.log(W,"pod"),W===r.POD.CHATBOT){console.log(xe,"template");const l=null!==(t=null===(e=null==xe?void 0:xe.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 he(!0)}const o=null==L?void 0:L(xe,Ne,null!=ve?ve:"",He);fe(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)&&Se(o.errorIndexes),(null==o?void 0:o.error)&&he(!!(null==o?void 0:o.error))):ke(!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 u}from"../modals/styledModal.js";import{CHANNEL_TYPE as c}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;i((()=>{be(L)}),[L]);const ue=k===c.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),ce=null==D?void 0:D.isProductCarouselType,[pe,me]=r(k===c.EMAIL||k==c.WEBPUSH||ue?"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(ue?(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):ce&&Ne([])}),[Q]),i((()=>{var e;if(!ke&&ce&&(!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:ue,selectedCarouselIndex:He,setSelectedCarouselIndex:Oe,isProductCarouselType:ce,templateErrorIndexes:Pe,cardCount:ue?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:c.EMAIL,hideHeader:!0}):o(u,Object.assign({hideCrossButton:_e,zIndex:O,centralContainerStyles:{width:ue?900:k===c.EMAIL&&V?1e3:800},open:!0,onClose:()=>{null==w||w()},headingTitle:null==Se?void 0:Se.label,headingSubtitle:k===c.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!=ue&&ue,onSelect:function(){var e,o,l;if((null==Fe?void 0:Fe.length)<1&&ce)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};
1
+ import{jsx as e,jsxs as o,Fragment as l}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useState as i,useEffect 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,S,y,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,[ce,ue]=i(ee);r((()=>{ue(ee)}),[ee]),console.log(ce,"tempState"),r((()=>{ge(L)}),[L]);const pe=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),me=null==D?void 0:D.isProductCarouselType,[ve,he]=i(k===u.EMAIL||k==u.WEBPUSH||pe?"desktop":"mobile"),[Ce,be]=i(!1),[fe,ge]=i(L),[xe,Ee]=i(!1),[Pe,Se]=i([]),[ye,Te]=i({}),[Ie,De]=i(D),[we,Ve]=i([]),[ke,Le]=i(null),[je,Me]=i(!1),[Ae,Be]=i(null!=j?j:[]),[He,Oe]=i(!1),[Fe,Ne]=i(pe?(null===(P=null===(E=null==Ie?void 0:Ie.mapping)||void 0===E?void 0:E.body)||void 0===P?void 0:P.length)?-1:0:-1),[We,Ue]=i([]),[ze,Re]=i(void 0),$e=a(null),[_e,qe]=i(!1),[Ge,Je]=i(!1),[Ke,Qe]=i(!1),[Xe,Ye]=i({});r((()=>{Q?Ue(Q):me&&Ue([])}),[Q]),r((()=>{var e;if(!je&&me&&(!Q||0===Ue.length)){const o=null===(e=null==Ie?void 0:Ie.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:"")}))})),Ve(l),Me(!0)}}),[je]);const Ze=s((()=>C(A)),[A]);return r((()=>{Re(t(N))}),[N]),e(m.Provider,Object.assign({value:{hideFooterButton:Ke,setHideFooterButton:Qe,hideCrossButton:Ge,setHideCrossButton:Je,variableList:ze,setVariableList:Re,variableCallback:ke,setVariableCallback:Le,showVariablePicker:Ce,setShowVariablePicker:be,template:Ie,setTemplate:De,device:ve,setDevice:he,display_content:fe,setDisplayContent:ge,originalVariableList:Ae,setOriginalVariableList:Be,isError:xe,setIsError:Ee,channel:k,globalNormalizedPlaceholders:Ze,templateSelectionTriggered:He,setTemplateSelectionTriggered:Oe,enabledCustomText:R,disableEditVariable:q,pod:G,extras:J,isWhatsappCarousel:pe,selectedCarouselIndex:Fe,setSelectedCarouselIndex:Ne,isProductCarouselType:me,templateErrorIndexes:ye,cardCount:pe?null===(y=null===(S=D.components)||void 0===S?void 0:S[1].cards)||void 0===y?void 0:y.length:void 0,errorIndexes:Pe,setErrorIndexes:Se,pickerConf:K,carouselProducts:We,setCarouselProducts:Ue,disableEditExpiry:X,cardWidth:Y,cardImages:we,onDeleteSelectedProducts:Z,hideDeviceContainerInPreview:le,sliderRef:$e,isCarouselHovered:_e,setIsCarouselHovered:qe,maxCharLimit:te,ctaOptionsErrors:Xe,setCtaOptionsErrors:Ye,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:Ge,zIndex:O,centralContainerStyles:{width:pe?900:k===u.EMAIL&&V?1e3:800},open:!0,onClose:()=>{null==w||w()},headingTitle:null==Ie?void 0:Ie.label,headingSubtitle:k===u.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(T=null==Ie?void 0:Ie.category)&&void 0!==T?T:"")} • ${null!==(I=null==Ie?void 0:Ie.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?$:ze,fileName:ee,setFileName:e=>{null==oe||oe(e)},skipDefaultVariableContent:re}),M?e(v,{isWhatsappCarousel:null!=pe&&pe,onSelect:function(){var e,o,l;if((null==We?void 0:We.length)<1&&me)return void Ee(!0);if(Object.keys(Xe).length>0&&G!==p.CHATBOT)return void Ee(!0);if(console.log(G,"pod"),G===p.CHATBOT){console.log(Ie,"template");const l=null!==(o=null===(e=null==Ie?void 0:Ie.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 Ee(!0)}const t=null==M?void 0:M(Ie,Ae,null!=fe?fe:"",We);Te(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)&&Se(t.errorIndexes),(null==t?void 0:t.error)&&Ee(!!(null==t?void 0:t.error))):Oe(!0)}}):e(l,{})]}))}))};export{f as TemplateContextMapper};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.612-beta-vsp.8",
3
+ "version": "0.0.612-beta-vsp.11",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",