@bikdotai/bik-component-library 0.0.394-beta.11 → 0.0.394-beta.2
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/bik-layout/BikSidebar.js +1 -1
- package/dist/cjs/components/bik-layout/SidebarStyles.js +1 -1
- package/dist/cjs/components/plans/NewSubscriptionPlan.js +1 -1
- package/dist/cjs/components/plans/SubscriptionPlansCollected.js +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/BackTrackComponent.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/DiscountCodeComponent.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/MobilePreview.js +3 -3
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorsPanel.js +3 -4
- package/dist/cjs/components/template-preview/WhatsApp/ChatBtn.js +1 -1
- package/dist/cjs/components/template-preview/WhatsApp/ChatUI.style.js +5 -5
- package/dist/cjs/components/template-preview/WhatsApp/ChatUiV2.js +2 -2
- package/dist/cjs/components/template-preview/WhatsAppTemplatePreview.js +1 -1
- package/dist/cjs/components/template-preview/helpers/TemplateCreatorHelper.js +1 -1
- package/dist/cjs/components/template-preview/models/WhatsAppTemplate.d.ts +24 -6
- package/dist/esm/components/bik-layout/BikSidebar.js +1 -1
- package/dist/esm/components/bik-layout/SidebarStyles.js +1 -1
- package/dist/esm/components/plans/NewSubscriptionPlan.js +1 -1
- package/dist/esm/components/plans/SubscriptionPlansCollected.js +2 -2
- package/dist/esm/components/template-context-mapper/modalElements/BackTrackComponent.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/DiscountCodeComponent.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/MobilePreview.js +4 -4
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorsPanel.js +3 -4
- package/dist/esm/components/template-preview/WhatsApp/ChatBtn.js +1 -1
- package/dist/esm/components/template-preview/WhatsApp/ChatUI.style.js +1 -1
- package/dist/esm/components/template-preview/WhatsApp/ChatUiV2.js +4 -4
- package/dist/esm/components/template-preview/WhatsAppTemplatePreview.js +1 -1
- package/dist/esm/components/template-preview/helpers/TemplateCreatorHelper.js +1 -1
- package/dist/esm/components/template-preview/models/WhatsAppTemplate.d.ts +24 -6
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../../assets/icons/halfRectangle.svg.js";import i from"../../../assets/icons/phone.svg.js";import s from"../../../assets/icons/RedirectToNew.svg.js";import a from"styled-components";import{Tooltip as n}from"../../tooltips/Tooltip.js";import{Caption as p,BodySecondary as l}from"../../TypographyStyle.js";import{COLORS as m}from"../../../constants/Theme.js";import{VariableEditorHelper as d}from"../helpers/VariableEditorHelper.js";import{HEADER_TYPES as h,ACTIONS_TYPES as c}from"../models/TemplateMeta.js";import{ChatBtn as f}from"./ChatBtn.js";import{Container as x,FooterWrapper as y,TimeStamp as g}from"./ChatUI.style.js";import{MediaCard as T}from"./MediaCard.js";const
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../../assets/icons/halfRectangle.svg.js";import i from"../../../assets/icons/phone.svg.js";import s from"../../../assets/icons/RedirectToNew.svg.js";import a from"styled-components";import{Tooltip as n}from"../../tooltips/Tooltip.js";import{Caption as p,BodySecondary as l}from"../../TypographyStyle.js";import{COLORS as m}from"../../../constants/Theme.js";import{VariableEditorHelper as d}from"../helpers/VariableEditorHelper.js";import{HEADER_TYPES as h,ACTIONS_TYPES as c}from"../models/TemplateMeta.js";import{ChatBtn as f}from"./ChatBtn.js";import{Container as x,FooterWrapper as y,TimeStamp as g}from"./ChatUI.style.js";import{MediaCard as T}from"./MediaCard.js";const b=a.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: 8px;
|
|
4
4
|
height: 8px;
|
|
5
5
|
left: -8px;
|
|
6
6
|
top: -9px;
|
|
7
|
-
`,
|
|
7
|
+
`,j=a.div`
|
|
8
8
|
font-family: 'Inter';
|
|
9
9
|
font-style: normal;
|
|
10
10
|
font-weight: 400;
|
|
@@ -13,7 +13,7 @@ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"..
|
|
|
13
13
|
padding: 8px 12px 0px;
|
|
14
14
|
color: ${m.content.primary};
|
|
15
15
|
word-wrap: break-word;
|
|
16
|
-
`,w=a(
|
|
16
|
+
`,w=a(j)`
|
|
17
17
|
font-weight: 600;
|
|
18
18
|
margin-bottom: 8px;
|
|
19
|
-
`,v=new d,u=a=>{const{bodyText:m,footerText:d,headerMediaType:u,headerText:I,headerAssetLink:L,headerAssetName:N,quickReplybtn:
|
|
19
|
+
`,v=new d,u=a=>{const{bodyText:m,footerText:d,headerMediaType:u,headerText:I,headerAssetLink:L,headerAssetName:N,quickReplybtn:_,ctaBtn:A,actionTypes:C,extras:M,showHeader:E,imagePreviewStyles:S,size:k,bodyVariableList:H,headerVariableList:R}=a,z=v.format(m,H),B=v.format(I,R),O={phoneNumber:i,website:s,copy_code:i};return e(x,{children:[t(b,{children:t(r,{color:"white",height:8,width:8})}),u===h.TEXT?t(w,{dangerouslySetInnerHTML:{__html:B}}):u!==h.NONE?t(T,{headerAssetLink:L,headerAssetName:N,mediaType:u,imagePreviewStyles:u===h.IMAGE?S:{}}):t(o,{}),!!m&&t(o,{children:t(j,{dangerouslySetInnerHTML:{__html:z}})}),e(y,{children:[t(n,Object.assign({body:null!=d?d:"",placement:"top"},{children:t(g,Object.assign({style:{flex:1}},{children:d}))})),t(g,{children:"16:48"})]}),C===c.QUICK_REPLY?t("div",{children:null==_?void 0:_.map(((e,o)=>t(f,{text:e.text},o)))}):C===c.CTA_BTN?t("div",{children:null==A?void 0:A.map(((e,o)=>t(f,{textTypography:E?p:l,extraContent:M?e.extra:void 0,placeholder:e.placeholder,text:e.text,Icon:O[e.type],size:k},o)))}):t(o,{})]})};export{u as ChatUIV2};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as l}from"react/jsx-runtime";import{useState as t,useEffect as
|
|
1
|
+
import{jsx as e,Fragment as l}from"react/jsx-runtime";import{useState as t,useEffect as o}from"react";import{TemplateCreatorHelper as i}from"./helpers/TemplateCreatorHelper.js";import{HEADER_TYPES as a}from"./models/TemplateMeta.js";import{TemplateHelperUtils as n}from"./utils/TemplateHelperUtils.js";import{WhatsappLikePreview as d}from"./WhatsApp/WhatsAppLikePreview.js";import{WhatsappLikePreviewV2 as r}from"./WhatsApp/WhatsAppLikePreviewV2.js";const p=p=>{let{template:v,extras:u,containerStyle:s,usePlaceHolderName:h,showHeader:c,zeroStateComponent:m,size:x,showSampleValues:b}=p;var y,T,B,w,k,N,V,C,f,A,L,S,j,P,g,F,H,O,q,z,R,U,W,I,M,D,E,_;const[G,J]=t(),K=new i,Q=new n,X=[];return(null===(T=null===(y=null==G?void 0:G.ctaBtn)||void 0===y?void 0:y.phoneNumber)||void 0===T?void 0:T.isChecked)&&X.push({type:"phoneNumber",text:null!==(B=G.ctaBtn.phoneNumber.btnText)&&void 0!==B?B:"",extra:null!==(w=G.ctaBtn.phoneNumber.phoneNumber)&&void 0!==w?w:""}),(null===(N=null===(k=null==G?void 0:G.ctaBtn)||void 0===k?void 0:k.websiteLinkBtn)||void 0===N?void 0:N.isChecked)&&X.push({type:"website",text:null!==(V=G.ctaBtn.websiteLinkBtn.btnText)&&void 0!==V?V:"",extra:null!==(f=null===(C=G.ctaBtn.websiteLinkBtn)||void 0===C?void 0:C.linkOpens)&&void 0!==f?f:"",placeholder:null!==(A=G.ctaBtn.websiteLinkBtn.placeholder)&&void 0!==A?A:""}),(null===(S=null===(L=null==G?void 0:G.ctaBtn)||void 0===L?void 0:L.copyCodeBtn)||void 0===S?void 0:S.isChecked)&&X.push({type:"copy_code",text:null!==(j=G.ctaBtn.copyCodeBtn.btnText)&&void 0!==j?j:"Copy Code",extra:null!==(g=null===(P=G.ctaBtn.copyCodeBtn)||void 0===P?void 0:P.code)&&void 0!==g?g:"",placeholder:null!==(F=G.ctaBtn.copyCodeBtn.placeholder)&&void 0!==F?F:""}),o((()=>{v&&K.parseUITemplateFromDBFormat({dbFormattedTemplate:v,isDuplicate:!1,showSampleValues:b,isV2:!v.htmlContentUrl}).then((e=>{J(Object.assign({},e))}))}),[v,b]),v?v.htmlContentUrl?e(d,{showHeader:c,containerPadding:"large"===x?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:s,textType:"html",bodyText:Q.whatsappOnlyFillVariablesValueInBodyText(null!==(W=null==G?void 0:G.bodyText)&&void 0!==W?W:"",null!==(I=null==G?void 0:G.bodyVariables)&&void 0!==I?I:[],h),footerText:null==G?void 0:G.footerText,headerMediaType:(null==G?void 0:G.headerType)||a.NONE,headerText:Q.fillVariablesValInBodyText(null!==(M=null==G?void 0:G.headerText)&&void 0!==M?M:"",null!==(D=null==G?void 0:G.headerVariables)&&void 0!==D?D:[],h),headerAssetLink:null!==(E=null==G?void 0:G.headerAssetLink)&&void 0!==E?E:"",headerAssetName:null!==(_=null==G?void 0:G.headerAssetName)&&void 0!==_?_:"",quickReplybtn:null==G?void 0:G.quickReply,ctaBtn:X,actionTypes:null==G?void 0:G.actionsType,extras:u,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=m?m:e(l,{children:" "})}):e(r,{showHeader:c,containerPadding:"large"===x?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:s,textType:"html",bodyText:null==G?void 0:G.bodyText,footerText:null==G?void 0:G.footerText,headerMediaType:(null==G?void 0:G.headerType)||a.NONE,headerText:null==G?void 0:G.headerText,headerAssetLink:null!==(H=null==G?void 0:G.headerAssetLink)&&void 0!==H?H:"",headerAssetName:null!==(O=null==G?void 0:G.headerAssetName)&&void 0!==O?O:"",quickReplybtn:null==G?void 0:G.quickReply,ctaBtn:X,actionTypes:null==G?void 0:G.actionsType,extras:u,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=m?m:e(l,{children:" "}),bodyVariableList:null!==(z=null===(q=null==G?void 0:G.bodyVariables)||void 0===q?void 0:q.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==z?z:[],headerVariableList:null!==(U=null===(R=null==G?void 0:G.headerVariables)||void 0===R?void 0:R.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==U?U:[]}):e(l,{children:m})};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{COLORS as t}from"../../../constants/Theme.js";import{specialCharPattern as n,placeHolderNamePattern as i,editableVarPattern as o}from"../constants/regexPatterns.js";import{REQUIRED_FIELD as l,NAME_LEN_LIMIT as a,NAME_LEN_ERROR as d,NO_SPECIAL_CHAR as r,HEADER_TEXT_LEN_LIMIT as v,HEADER_LEN_ERROR as s,ONE_VAR_ALLOWED as u,HEADER_ASSET_LINK_ERROR as p,BODY_TEXT_LEN_LIMIT as c,BODY_LEN_ERROR as m,QUICK_REPLY_BTN_TEXT_LIMIT as h,QUICK_REPLY_LEN_ERROR as b,BUTTON_EMOJI_ERROR as T,VALID_PHONE_NUMBER as y,QUICK_REPLY_NAME_LEN_LIMIT as B,CREATE_TEMPLATE_DOM_IDS as x,QUICK_REPLY_NAME_ERROR as f}from"../constants/TemplateConstants.js";import{HEADER_TYPES as k,ACTIONS_TYPES as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{COLORS as t}from"../../../constants/Theme.js";import{specialCharPattern as n,placeHolderNamePattern as i,editableVarPattern as o}from"../constants/regexPatterns.js";import{REQUIRED_FIELD as l,NAME_LEN_LIMIT as a,NAME_LEN_ERROR as d,NO_SPECIAL_CHAR as r,HEADER_TEXT_LEN_LIMIT as v,HEADER_LEN_ERROR as s,ONE_VAR_ALLOWED as u,HEADER_ASSET_LINK_ERROR as p,BODY_TEXT_LEN_LIMIT as c,BODY_LEN_ERROR as m,QUICK_REPLY_BTN_TEXT_LIMIT as h,QUICK_REPLY_LEN_ERROR as b,BUTTON_EMOJI_ERROR as T,VALID_PHONE_NUMBER as y,QUICK_REPLY_NAME_LEN_LIMIT as B,CREATE_TEMPLATE_DOM_IDS as x,QUICK_REPLY_NAME_ERROR as f}from"../constants/TemplateConstants.js";import{HEADER_TYPES as k,ACTIONS_TYPES as C}from"../models/TemplateMeta.js";import{TemplateHelperUtils as N}from"../utils/TemplateHelperUtils.js";class g{parseDataFromHeaderComponent(e,t){var n,i,o,l,a,d,r,v,s,u;const p={headerType:k.NONE,headerVariables:[]},c=null===(n=e.components)||void 0===n?void 0:n.find((e=>"HEADER"===e.type));if(c){p.headerType=c.format,p.headerText=c.text,p.headerAssetLink=null===(o=null===(i=c.example)||void 0===i?void 0:i.header_handle)||void 0===o?void 0:o[0];const n=null===(a=null===(l=c.example)||void 0===l?void 0:l.header_text)||void 0===a?void 0:a[0],m=null===(r=null===(d=e.mapping)||void 0===d?void 0:d.header)||void 0===r?void 0:r[0],h=m;if(n&&m){const e=null==m?void 0:m.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),i=/\(\(/.test(m),o={idx:0,variableVal:t?n:h,editable:i,editableDefaultValues:i?void 0:n,variableName:e};p.headerVariables=[o],(null===(s=null===(v=c.example)||void 0===v?void 0:v.header_text)||void 0===s?void 0:s.length)&&(p.headerText=null===(u=p.headerText)||void 0===u?void 0:u.replace("{{1}}",`{{${e}}}`))}}return p}validateState(e){var t,i,o,g,L,E,R,w,_,V,A,D,I,U,O,q,F,j,P,$,Y;const K=/\p{Extended_Pictographic}/u;let M="valid";const Q={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},S=new N;let H=!1;const G=e=>{var t;null===(t=document.getElementById(e))||void 0===t||t.scrollIntoView({behavior:"smooth",block:"nearest"})};if((null===(t=e.meta)||void 0===t?void 0:t.name)?e.meta.name.trim().length>a?(Q.meta.name=d,M="invalid"):n.test(e.meta.name.trim())&&(Q.meta.name=r,M="invalid"):(Q.meta.name=l,M="invalid"),Q.meta.name&&!H&&(G(x.name),H=!0),e.headerType===k.TEXT){const t=null!==(o=null===(i=e.headerText)||void 0===i?void 0:i.trim())&&void 0!==o?o:"";if(t)if(t.length>v)Q.header=s,M="invalid";else{const e=S.getTemplateVariablesFromState(t);e&&e.length>1&&(Q.header=u,M="invalid")}else Q.header=l,M="invalid"}else e.headerType===k.DOCUMENT||e.headerType===k.IMAGE||(e.headerType,k.VIDEO);if(e.headerType!==k.DOCUMENT&&e.headerType!==k.IMAGE&&e.headerType!==k.VIDEO||e.headerAssetLink||(Q.header=p,M="invalid"),Q.header&&!H&&(G(x.header),H=!0),e.bodyText?e.bodyTextRaw&&(null===(g=e.bodyTextRaw)||void 0===g?void 0:g.trim().length)>c&&(Q.body=m,M="invalid"):(Q.body=l,M="invalid"),Q.body&&!H&&(G(x.body),H=!0),e.footerText&&e.footerText.length>v&&(Q.footer=s,M="invalid"),(null==Q?void 0:Q.footer)&&!H&&(G(x.footer),H=!0),e.actionsType===C.CTA_BTN){if(null===(E=null===(L=e.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===E?void 0:E.isChecked){const t=null===(R=e.ctaBtn.phoneNumber.btnText)||void 0===R?void 0:R.trim(),n=e.ctaBtn.phoneNumber.phoneNumber;Q.ctaBtn&&!t?(Q.ctaBtn.phoneNumber.btnText=l,M="invalid"):Q.ctaBtn&&t&&t.length>h?(Q.ctaBtn.phoneNumber.btnText=b,M="invalid"):Q.ctaBtn&&t&&K.test(t)&&(Q.ctaBtn.phoneNumber.btnText=T,M="invalid"),Q.ctaBtn&&!n?(Q.ctaBtn.phoneNumber.link=l,M="invalid"):Q.ctaBtn&&n&&n.length<10&&(Q.ctaBtn.phoneNumber.link=y,M="invalid")}if(null===(_=null===(w=e.ctaBtn)||void 0===w?void 0:w.websiteLinkBtn)||void 0===_?void 0:_.isChecked){const t=null===(V=e.ctaBtn.websiteLinkBtn.btnText)||void 0===V?void 0:V.trim(),n=null===(A=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===A?void 0:A.trim(),i=null===(D=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===D?void 0:D.trim();Q.ctaBtn&&!t?(Q.ctaBtn.websiteLink.btnText=l,M="invalid"):Q.ctaBtn&&t&&t.length>h?(Q.ctaBtn.websiteLink.btnText=b,M="invalid"):Q.ctaBtn&&t&&K.test(t)&&(Q.ctaBtn.websiteLink.btnText=T,M="invalid"),!Q.ctaBtn||n||i||(Q.ctaBtn.websiteLink.link=l,M="invalid")}}else if(e.actionsType===C.QUICK_REPLY){const t=["","",""];e.quickReply.forEach(((n,i)=>{const o=n.text.trim();if(o)if(o.length>B)t[i]=b,M="invalid";else if(K.test(o))t[i]=T,M="invalid";else{const n=[...e.quickReply];n.splice(i,1);n.find((e=>e.text===o))&&(t[i]=f,M="invalid")}else t[i]=l,M="invalid"})),Q.quickReply=t}if(e.actionsType===C.CTA_BTN||e.actionsType===C.QUICK_REPLY){const e=null===(I=Q.quickReply)||void 0===I?void 0:I.reduce(((e,t)=>e||!!t),!1);((null===(O=null===(U=null==Q?void 0:Q.ctaBtn)||void 0===U?void 0:U.websiteLink)||void 0===O?void 0:O.link)||(null===(F=null===(q=Q.ctaBtn)||void 0===q?void 0:q.websiteLink)||void 0===F?void 0:F.btnText)||(null===(P=null===(j=Q.ctaBtn)||void 0===j?void 0:j.phoneNumber)||void 0===P?void 0:P.link)||(null===(Y=null===($=Q.ctaBtn)||void 0===$?void 0:$.phoneNumber)||void 0===Y?void 0:Y.btnText)||e)&&!H&&(G(x.actionButtons),H=!0)}return{status:M,errors:Q}}parseBodyComponent(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2?arguments[2]:void 0;var l,a,d,r,v;const s=[];let u="";const p=null===(l=e.components)||void 0===l?void 0:l.find((e=>"BODY"===e.type));return p&&(null===(d=null===(a=p.example)||void 0===a?void 0:a.body_text)||void 0===d||d[0].forEach(((t,n)=>{var l,a;let d=null===(a=null===(l=e.mapping)||void 0===l?void 0:l.body)||void 0===a?void 0:a[n];const r=d,v=d&&/\(\(/.test(d),u=null==d?void 0:d.match(i);(null==u?void 0:u[2])&&(d=null==u?void 0:u[2]),s.push({idx:n,variableVal:o?t:r,editable:!!v,editableDefaultValues:v?void 0:t,variableName:null!=d?d:""})})),u=e.htmlContentUrl?e.htmlContentUrl:(null===(r=p.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).length)?null===(v=p.text)||void 0===v?void 0:v.split(/\{\{[0-9]+\}\}/).map(((e,i)=>{if(null==s?void 0:s[i]){const o=s[i].variableName;return n?`${e}{{${o}}}`:`${e} <span> </span><span style="color: ${t.content.brand}; text-decoration: underline;">{{${o}}}</span><span> </span>`}return e})).join(""):""),{bodyVariable:s,bodyText:u}}parseFooterComponent(e){var t;const n=null===(t=e.components)||void 0===t?void 0:t.find((e=>"FOOTER"===e.type));return null==n?void 0:n.text}parseButtonComponent(e){var t,n,i,l,a,d;const r={actionsType:C.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0,copyCodeBtn:void 0}},v=null===(t=e.components)||void 0===t?void 0:t.find((e=>"BUTTONS"===e.type));if(v&&(null===(n=null==v?void 0:v.buttons)||void 0===n?void 0:n.length)){const t="QUICK_REPLY"===(null===(i=null==v?void 0:v.buttons)||void 0===i?void 0:i[0].type)?C.QUICK_REPLY:C.CTA_BTN;if(r.actionsType=t,t===C.QUICK_REPLY){const e=null!==(a=null===(l=null==v?void 0:v.buttons)||void 0===l?void 0:l.map((e=>e)))&&void 0!==a?a:[];return r.quickReply=e,r}t===C.CTA_BTN&&(null===(d=null==v?void 0:v.buttons)||void 0===d||d.forEach((t=>{var n,i,l,a;if(t.phone_number&&(r.ctaBtn.phoneNumber={isChecked:!0,btnText:t.text,phoneNumber:t.phone_number}),t.url){const d=null!==(l=null===(i=null===(n=null==e?void 0:e.mapping)||void 0===n?void 0:n.buttons)||void 0===i?void 0:i[0])&&void 0!==l?l:void 0;let v=!1;d&&o.test(d)&&(v=!0),r.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:t.text,linkOpens:v?null===(a=t.example)||void 0===a?void 0:a[0]:t.url,placeholder:v?void 0:d}}})))}return r}parseUITemplateFromDBFormat(t){var n;return e(this,void 0,void 0,(function*(){const{dbFormattedTemplate:e,isDuplicate:i,isV2:o=!1,showSampleValues:l}=t,{headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s}=yield this.parseDataFromHeaderComponent(e),{bodyText:u,bodyVariable:p}=yield this.parseBodyComponent(e,o,l),{actionsType:c,quickReply:m,ctaBtn:h}=yield this.parseButtonComponent(e),b={quickReply:m,ctaBtn:h,meta:{name:i?`${e.label} Copy`:e.label,category:null===(n=e.category)||void 0===n?void 0:n.toUpperCase(),subCategory:e.templateCategory,language:e.language,templateId:e.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:c,footerText:this.parseFooterComponent(e),bodyVariables:p,bodyText:u,headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s,alreadyAsADraft:e.isDraft,mode:"edit",initialLoading:!1},{errors:T}=this.validateState(b);return b.error=T,b}))}}export{g as TemplateCreatorHelper};
|
|
@@ -71,6 +71,12 @@ export type CreateTemplateType = {
|
|
|
71
71
|
linkOpens?: string;
|
|
72
72
|
placeholder?: string;
|
|
73
73
|
};
|
|
74
|
+
copyCodeBtn?: {
|
|
75
|
+
isChecked?: boolean;
|
|
76
|
+
btnText?: string;
|
|
77
|
+
code?: string;
|
|
78
|
+
placeholder?: string;
|
|
79
|
+
};
|
|
74
80
|
};
|
|
75
81
|
meta: {
|
|
76
82
|
name: string;
|
|
@@ -153,12 +159,7 @@ export type WhatsappLikePreviewTypes = {
|
|
|
153
159
|
headerAssetLink?: string;
|
|
154
160
|
headerAssetName?: string;
|
|
155
161
|
quickReplybtn?: QUICK_REPLY_BUTTON[];
|
|
156
|
-
ctaBtn?:
|
|
157
|
-
type: 'phoneNumber' | 'website';
|
|
158
|
-
text: string;
|
|
159
|
-
extra?: string;
|
|
160
|
-
placeholder?: string;
|
|
161
|
-
}[];
|
|
162
|
+
ctaBtn?: CTABtnPreview[];
|
|
162
163
|
actionTypes?: ACTIONS_TYPES;
|
|
163
164
|
textType: 'html' | 'markdown';
|
|
164
165
|
hidePreviewText?: boolean;
|
|
@@ -173,6 +174,13 @@ export type WhatsappLikePreviewTypes = {
|
|
|
173
174
|
bodyVariableList?: variableType[];
|
|
174
175
|
headerVariableList?: variableType[];
|
|
175
176
|
};
|
|
177
|
+
export type CTABtnPreview = {
|
|
178
|
+
type: 'phoneNumber' | 'website' | 'copy_code';
|
|
179
|
+
text: string;
|
|
180
|
+
extra?: string;
|
|
181
|
+
placeholder?: string;
|
|
182
|
+
};
|
|
183
|
+
export type CtaBtnPreviewType = CTABtnPreview['type'];
|
|
176
184
|
export type WhatsappMeta = {
|
|
177
185
|
containerStyle?: React.CSSProperties | undefined;
|
|
178
186
|
templateContainerStyles?: React.CSSProperties | undefined;
|
|
@@ -226,3 +234,13 @@ export declare enum BUTTON_TYPE {
|
|
|
226
234
|
URL = "URL",
|
|
227
235
|
PHONE_NUMBER = "PHONE_NUMBER"
|
|
228
236
|
}
|
|
237
|
+
export type Extras = {
|
|
238
|
+
discountCodeExtra?: [
|
|
239
|
+
discountCode: string,
|
|
240
|
+
setDiscountCode: (discountCode: string) => void
|
|
241
|
+
];
|
|
242
|
+
backTrackExtra?: [
|
|
243
|
+
backTrackMessage: string,
|
|
244
|
+
setBackTrackMessage: (backTrackMessage: string) => void
|
|
245
|
+
];
|
|
246
|
+
};
|