@bikdotai/bik-component-library 0.0.433-beta.8 → 0.0.433-beta.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.
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +1 -2
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/cjs/components/template-context-mapper/context/templateModalContext.d.ts +2 -0
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +2 -2
- package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +1 -2
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/esm/components/template-context-mapper/context/templateModalContext.d.ts +2 -0
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +2 -2
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +2 -2
- package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/package.json +1 -1
|
@@ -31,7 +31,6 @@ export interface TemplateContextMapperProps {
|
|
|
31
31
|
disableEditVariable?: boolean;
|
|
32
32
|
pod?: POD;
|
|
33
33
|
extras?: ExtrasWhatsapp;
|
|
34
|
-
isProductCarouselType?: boolean;
|
|
35
34
|
pickerConf?: {
|
|
36
35
|
searchInCollection: any;
|
|
37
36
|
searchProducts: any;
|
|
@@ -40,4 +39,4 @@ export interface TemplateContextMapperProps {
|
|
|
40
39
|
storeId: string;
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
|
-
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras,
|
|
42
|
+
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras, pickerConf, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),o=require("../template-preview/models/Channels.js"),s=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),r=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:u,closeDialog:c,showVariableMapping:p,channel:m,htmlContent:C,templateVariables:h,onTemplateSelect:v,globalPlaceholders:b,showOnlyContent:S,whatsappSpecificPickerMeta:g,zIndex:T,showVariableModal:x,variableList:E,discountCode:P,setDiscountCode:j,onBackPress:M,enabledCustomText:L,variableListForImage:f,showSampleValues:w,disableEditVariable:A,pod:y,extras:N,pickerConf:V}=d;var I,k,q,H,_,D;t.useEffect((()=>{W(C)}),[C]);const O=m===o.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(k=null===(I=u.components)||void 0===I?void 0:I[1])||void 0===k?void 0:k.type),[F,Y]=t.useState(m===o.CHANNEL_TYPE.EMAIL||O?"desktop":"mobile"),[B,W]=t.useState(C),[z,U]=t.useState(!1),[$,R]=t.useState(u),[G,J]=t.useState(null!=h?h:[]),[K,Q]=t.useState(!1),[X,Z]=t.useState(-1);const ee=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(b)),[b]);return e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:$,setTemplate:R,device:F,setDevice:Y,display_content:B,setDisplayContent:W,originalVariableList:G,setOriginalVariableList:J,isError:z,setIsError:U,channel:m,globalNormalizedPlaceholders:ee,templateSelectionTriggered:K,setTemplateSelectionTriggered:Q,enabledCustomText:L,disableEditVariable:A,pod:y,extras:N,isWhatsappCarousel:O,selectedCarouselIndex:X,setSelectedCarouselIndex:Z,isProductCarouselType:u.isProductCarouselType,cardCount:null===(H=null===(q=u.components)||void 0===q?void 0:q[1].cards)||void 0===H?void 0:H.length,pickerConf:V}},{children:S?e.jsx(r.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:T,centralContainerStyles:{width:O?900:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:800},open:!0,onClose:()=>{null==c||c()},headingTitle:null==$?void 0:$.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(_=null==$?void 0:$.category)&&void 0!==_?_:"")} • ${null!==(D=null==$?void 0:$.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==M||M()}},{children:[e.jsx(r.default,{showSampleValues:w,showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:g,showVariableModal:x,variableList:E,discountCode:P,setDiscountCode:j,variableListForImage:f&&(null==f?void 0:f.length)>0?f:E}),v?e.jsx(i.default,{isWhatsappCarousel:null!=O&&O,onSelect:function(){const e=null==v?void 0:v($,G,null!=B?B:"");e?U(!!e):Q(!0)}}):e.jsx(e.Fragment,{})]}))}))};
|
|
@@ -30,6 +30,7 @@ export declare const TemplateModalContext: React.Context<{
|
|
|
30
30
|
selectedCarouselIndex?: number | undefined;
|
|
31
31
|
setSelectedCarouselIndex?: React.Dispatch<React.SetStateAction<number>> | undefined;
|
|
32
32
|
isProductCarouselType?: boolean | undefined;
|
|
33
|
+
cardCount?: number | undefined;
|
|
33
34
|
pickerConf?: {
|
|
34
35
|
searchInCollection: any;
|
|
35
36
|
searchProducts: any;
|
|
@@ -62,6 +63,7 @@ export declare const useTemplateModalContext: () => {
|
|
|
62
63
|
selectedCarouselIndex?: number | undefined;
|
|
63
64
|
setSelectedCarouselIndex?: React.Dispatch<React.SetStateAction<number>> | undefined;
|
|
64
65
|
isProductCarouselType?: boolean | undefined;
|
|
66
|
+
cardCount?: number | undefined;
|
|
65
67
|
pickerConf?: {
|
|
66
68
|
searchInCollection: any;
|
|
67
69
|
searchProducts: any;
|
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/PlusIcon.js"),i=require("react"),s=require("styled-components"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/PlusIcon.js"),i=require("react"),s=require("styled-components"),r=require("../../add-variableV2/AddVariableV2SideModal.js");require("../../../_virtual/_tslib.js"),require("../../add-variableV2/AddVariableV2.styled.js");var a=require("../../button/Button.js"),o=require("../../icon-button/IconButton.js");require("../../input/Input.js"),require("../../tooltips/Tooltip.js");var l=require("../../../constants/Theme.js");require("../../modals/modal.styled.js"),require("../../switch/Switch.js");var n=require("../../TypographyStyle.js"),d=require("../../product-picker-v2/modal.js"),c=require("../context/templateModalContext.js"),u=require("./EditWhatsAppTemplateV2.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../curtain/CurtainHelper.js"),require("../../template-preview/models/TemplateMeta.js");var p=require("../../template-preview/models/WhatsAppTemplate.js"),m=require("../../../assets/icons/box.svg.js"),f=require("../../../assets/icons/delete.svg.js"),h=require("../../../assets/icons/edit.svg.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const j=t=>{const{cardBody:i,deleteItem:s,editItem:r}=t;return e.jsxs(x,Object.assign({width:"100%"},{children:[e.jsx("div",Object.assign({style:{width:36,height:36}},{children:e.jsx(m.default,{})})),e.jsx("div",Object.assign({className:"card-body"},{children:e.jsx(n.TitleRegular,{children:i})})),e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[r&&e.jsx(o.IconButton,{style:{display:"flex"},Icon:h.default,onClick:e=>{r(),e.stopPropagation()}}),e.jsx(o.IconButton,{style:{display:"flex",color:"#919191"},Icon:f.default,onClick:e=>{s(),e.stopPropagation()}})]}))]}))},x=g(s).default.div`
|
|
2
2
|
width: ${e=>e.width};
|
|
3
3
|
padding: 12px;
|
|
4
4
|
display: flex;
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
color: #000000;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`;exports.default=s=>{let{template:
|
|
47
|
+
`;exports.default=s=>{let{template:o,whatsappSpecificPickerMeta:m,showVariableModal:f,variableList:h,variableListForImage:g,discountCode:x,setDiscountCode:y}=s;const{selectedCarouselIndex:b,setTemplate:v,pickerConf:I,isProductCarouselType:w,pod:C,cardCount:q}=c.useTemplateModalContext(),[O,T]=i.useState(-1==b?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[k,P]=i.useState(!1),[S,B]=i.useState(!1),[V,A]=i.useState([]);i.useEffect((()=>{T(-1==b?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[b]);return e.jsxs("div",{children:[e.jsx(n.TitleMedium,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:O})),w&&V.length>0&&null!=b&&b>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,flexDirection:"column"}},{children:[e.jsx(j,{editItem:()=>P(!k),cardBody:`${V.length} Products Selected`,deleteItem:()=>{A([])}}),e.jsx(a.Button,{disabled:V.length<=1,style:{alignSelf:"flex-end",background:l.COLORS.surface.subdued},onClick:()=>{P(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),w&&0===V.length&&null!=b&&b>=0&&e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12},size:"medium",buttonText:"Add Product(s)",buttonType:"dashBold",LeadingIcon:t.default,onClick:e=>{P(!0)}}),C===p.POD.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(n.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:t.default,onClick:e=>{B(!0)}})]})]})),e.jsx(u.default,{whatsappSpecificPickerMeta:m,template:o,onTemplateChange:e=>{null==v||v(e)},showVariableModal:f,variableList:h,variableListForImage:g,discountCode:x,setDiscountCode:y}),k&&I&&e.jsx(d.ProductPickerModal,{zIndex:200,limit:null!=q?q:1,storeId:I.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const i of e){const e=null==i?void 0:i.collectionId,s=i.productId,r=i.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),s in t[e].products||(t[e].products[s]={variants:{},name:(null==i?void 0:i.productName)||"",image:(null==i?void 0:i.productImage)||""}),t[e].products[s].variants[r]={name:(null==i?void 0:i.name)||"",price:"",image:(null==i?void 0:i.image)||"",quantity:i.quantity||0,displayOrder:i.displayOrder}}return t}return{}})(V),collectionFetcher:I.fetchCollections,productFetcher:I.fetchProducts,onAdd:(e,t)=>{const i=[];delete e.isCustom;for(const t of Object.keys(e)){const s=e[t].products;if(void 0!==s&&Object.keys(s).length)for(const e of Object.keys(s)){const r=s[e].variants;if(void 0!==r&&Object.keys(r).length)for(const a of Object.keys(r)){const{name:o,image:l,quantity:n,displayOrder:d}=r[a],c={name:o,image:l,quantity:n,variantId:a,productId:e,displayOrder:d,collectionId:t,productName:s[e].name,productImage:s[e].image};i.push(c)}}}const s=i.sort(((e,t)=>e.displayOrder-t.displayOrder));A(s),P(!1)},searchInCollectionFetcher:I.searchInCollection,searchFetcher:I.searchProducts,visible:k,onClose:()=>{P(!1)}}),S&&e.jsx(r.AddVariableV2SideModal,{zIndex:2e3,data:null!=h?h:[],showVariable:S,setShowVariable:B,placeholder:"Add a variable",customTrigger:e=>{}})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("lodash"),o=require("react"),t=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),l=require("../custom-hooks/useAdditionalVariables.js"),s=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),d=require("./DiscountCodeComponent.js"),r=require("./EditMediaV2.style.js"),p=require("./EditWhatsAppTemplateMediaV2.js"),u=require("./VariableConnector.js"),c=require("./VariableConnectorsPanel.js"),m=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=g=>{let{template:h,onTemplateChange:f,whatsappSpecificPickerMeta:C,showVariableModal:j,variableList:x,variableListForImage:T,discountCode:V,setDiscountCode:B}=g;var O,y,q,E,k,D,L,w,I,A,M,S,U,N,P,R,F,H;const{originalVariableList:_,pod:Q,extras:W,selectedCarouselIndex:Y}=i.useTemplateModalContext(),{descriptionComponents:K,urlBtns:$,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}=s.getAllDataFromTemplateComponent(h),[Z,ee]=o.useState(!1),[ne,oe]=o.useState(-1===Y?{descriptionComponents:K,urlBtns:$,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}:{}),[te,ie]=o.useState(!1);function le(e,o){var t,i,l,s,a,d,r;const p=null!=Y&&Y>-1?{components:null===(t=Object.assign({},h).components[1].cards)||void 0===t?void 0:t[Y].components,mapping:null===(i=Object.assign({},h).mapping.cards)||void 0===i?void 0:i[Y]}:Object.assign({},h),u=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==u&&u>-1){const n=null===(l=null==p?void 0:p.components[u].buttons)||void 0===l?void 0:l.findIndex((e=>"URL"===e.type));if(void 0!==n&&n>-1){const t="custom"===o&&"string"==typeof e,i=[...null!==(d=null===(a=null===(s=p.components)||void 0===s?void 0:s[u])||void 0===a?void 0:a.buttons)&&void 0!==d?d:[]];i[n]=Object.assign(Object.assign({},i[n]),{url:"https://d.bik.ai/{{1}}",example:[t?e:"string"!=typeof e?e.defaultValue:""]});const l=Object.assign(Object.assign({},p.components[u]),{buttons:i}),r=Object.assign(Object.assign({},p.mapping),{buttons:t?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});p.mapping=r;const c=[...p.components];c[u]=l,p.components=c}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(r=e.placeHolder)||void 0===r?void 0:r.slice(2,-2))?ee(!0):(ee(!1),null==B||B(""))}if(null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=p.components,e.mapping.cards[Y]=p.mapping,null==f||f(Object.assign({},e))}else null==f||f(p)}function se(e,o,t){var i,l,s;console.log("template 55: ",h),console.log("qrbBtns 55: ",X),console.log("urlBtns 55: ",$);const a=null!=Y&&Y>-1?{components:null===(i=Object.assign({},h).components[1].cards)||void 0===i?void 0:i[Y].components,mapping:null===(l=Object.assign({},h).mapping.cards)||void 0===l?void 0:l[Y]}:Object.assign({},h),d=null==a?void 0:a.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const n=null===(s=null==a?void 0:a.components[d].buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));n&&(n[t]=Object.assign(Object.assign({},n[t]),{flowId:e.flowId,flowName:e.flowName}));const o=Object.assign(Object.assign({},a.components[d]),{buttons:n}),i=[...a.components];i[d]=o,a.components=i}if(null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=a.components,e.mapping.cards[Y]=a.mapping,null==f||f(Object.assign({},e))}else null==f||f(a)}o.useEffect((()=>{var e,n;if(null===(e=h.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))ee(!0);else{ee(!1);const e=null===(n=null==W?void 0:W.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[h]),o.useEffect((()=>{var e,n,o,t;if(null!=Y&&Y>-1){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Y].components,mapping:null===(t=null===(o=null==h?void 0:h.mapping)||void 0===o?void 0:o.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=s.getAllDataFromTemplateComponent(i);oe({descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}),console.log("urlBtns 89: ",a),console.log("urlBtns 89: ",a)}else if(null!=Y&&-1===Y){const{descriptionComponents:e,urlBtns:n,qrbBtns:o,imageComponent:t,bodyVariables:i,headerVariables:l}=s.getAllDataFromTemplateComponent(h);oe({descriptionComponents:e,urlBtns:n,qrbBtns:o,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Y]),o.useEffect((()=>{var e,n,o,t;if(console.log("right panel selectedCarouselIndex: ",Y),null!=Y&&Y>-1&&te){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Y].components,mapping:null===(t=null===(o=null==h?void 0:h.mapping)||void 0===o?void 0:o.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=s.getAllDataFromTemplateComponent(i);oe({descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}),ie(!1)}}),[te]);const ae=l.useAdditionalVariables({variableList:x,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(c.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!ne.imageComponent&&e.jsx(r.EditTemplateMediaContainer,{children:e.jsx(p.default,{whatsappSpecificPickerMeta:C,mediaComponent:ne.imageComponent,updateTemplateImageUrl:function(e,o){var t,i,l,s,a;let d;d=null!=Y&&Y>-1?{components:null===(i=null===(t=h.components[1])||void 0===t?void 0:t.cards)||void 0===i?void 0:i[Y].components,mapping:null===(s=null===(l=null==h?void 0:h.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[Y]}:Object.assign({},h);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const n=Object.assign(Object.assign({},d.components[r]),{format:o,example:{header_handle:[e]}}),t=[...d.components];t[r]=n,d=Object.assign(Object.assign({},d),{components:t})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=d.components,e.mapping.cards[Y]=d.mapping,null==f||f(Object.assign({},e)),ie(!0)}else null==f||f(Object.assign({},d))},template:h,variableListForImage:T})}),(ne.bodyVariables.length>0||ne.headerVariables.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:ne.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(O=ne.descriptionComponents)||void 0===O?void 0:O.map(((n,o)=>e.jsx(m.default,{originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,type:n.type,descriptionComponent:n.component,showVariableModal:j,variableList:x},o))),(null===(q=null===(y=ne.urlBtns[0])||void 0===y?void 0:y.component)||void 0===q?void 0:q.buttons)&&(null===(D=null===(k=null===(E=ne.urlBtns[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)||void 0===D?void 0:D.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(L=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===L?void 0:L.map(((n,o)=>{if("URL"===n.type)return e.jsx(b.default,{variableListIndex:o,CTAoptions:null==C?void 0:C.CTAoptions,button:n,originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,updateSelectedURLTemplateBtn:le,variableList:x},`${o}`)})),(null===(I=null===(w=ne.qrbBtns[0])||void 0===w?void 0:w.component)||void 0===I?void 0:I.buttons)&&(null===(S=null===(M=null===(A=ne.qrbBtns[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===S?void 0:S.length)>0&&(Q!==t.POD.CHATBOT?e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(a.BackTrackComponent,{backTrackMessage:null===(U=null==W?void 0:W.backTrackExtra)||void 0===U?void 0:U[0],setBackTrackMessage:null===(N=null==W?void 0:W.backTrackExtra)||void 0===N?void 0:N[1]})),null===(P=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===P?void 0:P.map(((n,o)=>{if("QUICK_REPLY"===n.type)return e.jsx(b.default,{variableListIndex:o,QRBoptions:null==C?void 0:C.QRBoptions,button:n,originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,updateSelectedQRBTemplateBtn:se},`${o}`)})),Q===t.POD.CHATBOT&&Z&&e.jsx(d.DiscountCodeComponent,{discountCode:null===(R=null==W?void 0:W.discountCodeExtra)||void 0===R?void 0:R[0],setDiscountCode:null===(F=null==W?void 0:W.discountCodeExtra)||void 0===F?void 0:F[1],variableList:x}),null===(H=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===H?void 0:H.map(((n,o)=>{var t,i,l;if("COPY_CODE"===n.type)return e.jsx(u.default,{index:o,variable:{variableName:null!==(t=n.text)&&void 0!==t?t:"",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=n.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:ae,componentType:"BUTTONS"},o)}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),o=require("react"),n=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),l=require("../custom-hooks/useAdditionalVariables.js"),a=require("../utils/getDataFromTemplateComponent.js"),s=require("./BackTrackComponent.js"),d=require("./DiscountCodeComponent.js"),r=require("./EditMediaV2.style.js"),p=require("./EditWhatsAppTemplateMediaV2.js"),u=require("./VariableConnector.js"),c=require("./VariableConnectorsPanel.js"),m=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=g=>{let{template:C,onTemplateChange:f,whatsappSpecificPickerMeta:h,showVariableModal:j,variableList:x,variableListForImage:T,discountCode:y,setDiscountCode:V}=g;var O,B,E,L,q,k,D,I,w,U,A,R,P,M;const{originalVariableList:S,pod:_,extras:N,selectedCarouselIndex:Q,isProductCarouselType:F}=i.useTemplateModalContext(),{descriptionComponents:H,urlBtns:Y,qrbBtns:K,imageComponent:W,bodyVariables:$,headerVariables:X}=a.getAllDataFromTemplateComponent(C),[z,G]=o.useState(!1),[J,Z]=o.useState(-1===Q?{descriptionComponents:H,urlBtns:Y,qrbBtns:K,imageComponent:W,bodyVariables:$,headerVariables:X}:{}),[ee,te]=o.useState(!1);function oe(e,o,n){var i,l,a,s,d,r,p,u;const c=null!=Q&&Q>-1?{components:null===(i=Object.assign({},C).components[1].cards)||void 0===i?void 0:i[Q].components,mapping:null===(l=Object.assign({},C).mapping.cards)||void 0===l?void 0:l[Q]}:Object.assign({},C),m=null==c?void 0:c.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==m&&m>-1){const t=null===(a=null==c?void 0:c.components[m].buttons)||void 0===a?void 0:a.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===o&&"string"==typeof e,l=i?e:"string"!=typeof e?e.defaultValue:"";let a=t[n];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]}),console.log("templateCopy test: ",n,a,o,e);const u=[...null!==(r=null===(d=null===(s=c.components)||void 0===s?void 0:s[m])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),v=Object.assign(Object.assign({},c.components[m]),{buttons:u}),b=null===(p=c.mapping)||void 0===p?void 0:p.buttons;b&&b.length>0&&(b[n]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const g=Object.assign(Object.assign({},c.mapping),{buttons:b});c.mapping=g;const C=[...c.components];C[m]=v,c.components=C}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(u=e.placeHolder)||void 0===u?void 0:u.slice(2,-2))?G(!0):(G(!1),null==V||V(""))}if(null!=Q&&Q>-1){const e=t.cloneDeep(C);e.components[1].cards[Q].components=c.components,e.mapping.cards[Q]=c.mapping,console.log("templateCopy: ",e),null==f||f(Object.assign({},e))}else null==f||f(c)}function ne(e,o,n){var i,l,a,s,d,r;const p=null!=Q&&Q>-1?{components:null===(i=Object.assign({},C).components[1].cards)||void 0===i?void 0:i[Q].components,mapping:null===(l=Object.assign({},C).mapping.cards)||void 0===l?void 0:l[Q]}:Object.assign({},C),u=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==u&&u>-1){const t=null===(a=null==p?void 0:p.components[u].buttons)||void 0===a?void 0:a.filter((e=>"QUICK_REPLY"===e.type));if(t){let i=t[n];i=Object.assign(Object.assign({},i),{flowId:e.flowId,flowName:e.flowName}),console.log("templateCopy 2 test: ",n,i,o,e);const l=[...null!==(r=null===(d=null===(s=p.components)||void 0===s?void 0:s[u])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==i?void 0:i.text)?i:e)),a=Object.assign(Object.assign({},p.components[u]),{buttons:l}),c=[...p.components];c[u]=a,p.components=c}}if(null!=Q&&Q>-1){const e=t.cloneDeep(C);e.components[1].cards[Q].components=p.components,e.mapping.cards[Q]=p.mapping,console.log("templateCopy 2: ",e),null==f||f(Object.assign({},e))}else null==f||f(p)}o.useEffect((()=>{var e,t;if(null===(e=C.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))G(!0);else{G(!1);const e=null===(t=null==N?void 0:N.discountCodeExtra)||void 0===t?void 0:t[1];null==e||e("")}}),[C]),o.useEffect((()=>{console.log("templateComponentData: ",J)}),[J]),o.useEffect((()=>{var e,t,o,n;if(null!=Q&&Q>-1){const i={components:null===(t=null===(e=C.components[1])||void 0===e?void 0:e.cards)||void 0===t?void 0:t[Q].components,mapping:null===(n=null===(o=null==C?void 0:C.mapping)||void 0===o?void 0:o.cards)||void 0===n?void 0:n[Q]},{descriptionComponents:l,urlBtns:s,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=a.getAllDataFromTemplateComponent(i);Z({descriptionComponents:l,urlBtns:s,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u})}else if(null!=Q&&-1===Q){const{descriptionComponents:e,urlBtns:t,qrbBtns:o,imageComponent:n,bodyVariables:i,headerVariables:l}=a.getAllDataFromTemplateComponent(C);Z({descriptionComponents:e,urlBtns:t,qrbBtns:o,imageComponent:n,bodyVariables:i,headerVariables:l})}}),[Q]),o.useEffect((()=>{var e,t,o,n;if(console.log("right panel selectedCarouselIndex: ",Q),null!=Q&&Q>-1&&ee){const i={components:null===(t=null===(e=C.components[1])||void 0===e?void 0:e.cards)||void 0===t?void 0:t[Q].components,mapping:null===(n=null===(o=null==C?void 0:C.mapping)||void 0===o?void 0:o.cards)||void 0===n?void 0:n[Q]},{descriptionComponents:l,urlBtns:s,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=a.getAllDataFromTemplateComponent(i);Z({descriptionComponents:l,urlBtns:s,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}),te(!1)}}),[ee]);const ie=l.useAdditionalVariables({variableList:x,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(c.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!J.imageComponent&&!F&&e.jsx(r.EditTemplateMediaContainer,{children:e.jsx(p.default,{whatsappSpecificPickerMeta:h,mediaComponent:J.imageComponent,updateTemplateImageUrl:function(e,o){var n,i,l,a,s;let d;d=null!=Q&&Q>-1?{components:null===(i=null===(n=C.components[1])||void 0===n?void 0:n.cards)||void 0===i?void 0:i[Q].components,mapping:null===(a=null===(l=null==C?void 0:C.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Q]}:Object.assign({},C);const r=null===(s=null==d?void 0:d.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const t=Object.assign(Object.assign({},d.components[r]),{format:o,example:{header_handle:[e]}}),n=[...d.components];n[r]=t,d=Object.assign(Object.assign({},d),{components:n})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=Q&&Q>-1){const e=t.cloneDeep(C);e.components[1].cards[Q].components=d.components,e.mapping.cards[Q]=d.mapping,null==f||f(Object.assign({},e)),te(!0)}else null==f||f(Object.assign({},d))},template:C,variableListForImage:T})}),(J.bodyVariables.length>0||J.headerVariables.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:J.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(O=J.descriptionComponents)||void 0===O?void 0:O.map(((t,o)=>e.jsx(m.default,{originalVariableList:null!=Q&&Q>-1?S.cards[Q]:S,type:t.type,descriptionComponent:t.component,showVariableModal:j,variableList:x},o))),(null===(E=null===(B=null!=Q&&Q>-1?S.cards[Q].buttons:null==S?void 0:S.buttons)||void 0===B?void 0:B.filter((e=>"URL"===e.type)))||void 0===E?void 0:E.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(q=null===(L=null!=Q&&Q>-1?S.cards[Q].buttons:null==S?void 0:S.buttons)||void 0===L?void 0:L.filter((e=>"URL"===e.type)))||void 0===q?void 0:q.map(((t,o)=>{if("URL"===t.type)return e.jsx(b.default,{variableListIndex:o,CTAoptions:null==h?void 0:h.CTAoptions,button:t,currentVariableList:null!=Q&&Q>-1?S.cards[Q]:S,updateSelectedURLTemplateBtn:oe,variableList:x},`${o}_${Q}`)})),(null===(D=null===(k=null!=Q&&Q>-1?S.cards[Q].buttons:null==S?void 0:S.buttons)||void 0===k?void 0:k.filter((e=>"QUICK_REPLY"===e.type)))||void 0===D?void 0:D.length)>0&&(_!==n.POD.CHATBOT?e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(s.BackTrackComponent,{backTrackMessage:null===(I=null==N?void 0:N.backTrackExtra)||void 0===I?void 0:I[0],setBackTrackMessage:null===(w=null==N?void 0:N.backTrackExtra)||void 0===w?void 0:w[1]})),null===(A=null===(U=null!=Q&&Q>-1?S.cards[Q].buttons:null==S?void 0:S.buttons)||void 0===U?void 0:U.filter((e=>"QUICK_REPLY"===e.type)))||void 0===A?void 0:A.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(b.default,{variableListIndex:o,QRBoptions:null==h?void 0:h.QRBoptions,button:t,currentVariableList:null!=Q&&Q>-1?S.cards[Q]:S,updateSelectedQRBTemplateBtn:ne},`${o}_${Q}`)})),_===n.POD.CHATBOT&&z&&e.jsx(d.DiscountCodeComponent,{discountCode:null===(R=null==N?void 0:N.discountCodeExtra)||void 0===R?void 0:R[0],setDiscountCode:null===(P=null==N?void 0:N.discountCodeExtra)||void 0===P?void 0:P[1],variableList:x}),null===(M=null!=Q&&Q>-1?S.cards[Q].buttons:null==S?void 0:S.buttons)||void 0===M?void 0:M.map(((t,o)=>{var n,i,l;if("COPY_CODE"===t.type)return e.jsx(u.default,{index:o,variable:{variableName:null!==(n=t.text)&&void 0!==n?n:"",updatedValue:null!==(i=t.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=t.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:ie,componentType:"BUTTONS"},o)}))]}))};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("lodash"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("lodash"),n=require("react"),i=require("styled-components"),o=require("../../add-variableV2/AddVariableV2SideModal.js"),s=require("../../custom-date-time/CustomDateTime.js"),u=require("../../dropdown/Dropdown.js"),d=require("../../input/Input.js"),r=require("../../product-picker-v2/collectionScreen.js"),c=require("../../template-preview/constants/regexPatterns.js"),p=require("../../template-preview/models/Channels.js"),m=require("../../template-preview/models/WhatsAppTemplate.js"),v=require("../../TypographyStyle.js"),b=require("../../../utils/StringUtils.js"),g=require("../../../constants/Theme.js"),h=require("../context/templateModalContext.js"),x=require("../utils/getVariableNameEmail.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const O=j(i).default.div`
|
|
2
2
|
/* surface/$color-background-warning-light */
|
|
3
3
|
|
|
4
4
|
background: ${e=>e.focused&&e.channel===p.CHANNEL_TYPE.EMAIL?g.COLORS.background.warning.light:"transparent"};
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
padding: 8px 10px;
|
|
7
|
-
`,_={value:"custom_link",label:"Custom URL"},f={value:"custom_text",label:"Custom text"},E={value:"static_expiry",label:"Static Expiry"};exports.Container=O,exports.default=n=>{let{onFocus:j,variable:y,index:T,showVariableModal:A,variableList:N,setShowDiscountCheckBox:C,componentType:S,CTAoptions:P}=n;var V,L;const[k,H]=i.useState(!1),[w,D]=i.useState(""),[B,q]=i.useState([]),[Y,M]=i.useState(),[R,U]=i.useState(!1),[I,W]=i.useState(!1),{device:$,channel:z,isError:Z,originalVariableList:F,template:G,templateSelectionTriggered:K,setTemplate:J,setDisplayContent:Q,setOriginalVariableList:X,globalNormalizedPlaceholders:ee,enabledCustomText:te,pod:le,selectedCarouselIndex:ae}=h.useTemplateModalContext();function ie(){var e,t;const l=[];let a=[];if(z!==p.CHANNEL_TYPE.MESSAGE||te){"link"===(null==y?void 0:y.type)?(l.push({label:"",options:[_,f]}),M(_)):"date_time"===(null==y?void 0:y.type)?(l.push({label:"",options:[_,f]}),M(E)):(l.push({label:"",options:[_,f,E]}),M(f));const e=null!=ee?ee:[];q([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ee?ee:[];q([{label:"",options:[f,_]},...e]),a=[{label:"",options:[f,_]},...e]}if((z===p.CHANNEL_TYPE.WHATSAPP||z===p.CHANNEL_TYPE.EMAIL||z===p.CHANNEL_TYPE.MESSAGE)&&y.updatedValue)if(c.placeHolderNamePattern.test(y.updatedValue)&&z===p.CHANNEL_TYPE.WHATSAPP||y.updatedValue.startsWith("{{")&&z!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(A){let t=e.updatedValue;if(le===m.POD.CHATBOT&&"BUTTONS"===S){const l=null==P?void 0:P.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(y,a,z);e.value&&M(e)}else"date_time"===y.type?(M(E),D(y.updatedValue),ue(null!==(e=y.index)&&void 0!==e?e:0,y.updatedValue)):(null===(t=y.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(M(_),D(y.updatedValue.split("https://")[1])):(M(f),D(y.updatedValue))}function ne(e,t){var l,a,i;const n=e;D(""),M(n),z===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(oe(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ue||ue(null!==(a=y.index)&&void 0!==a?a:0,n.value,!0)):(null==ue||ue(null!==(i=y.index)&&void 0!==i?i:0,w,!0,n.value),oe("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?oe(n.value,"url"===n.bikPlaceholderType?"link":"string"):(D(""),oe("",n.value))}function se(e,t){var l;D(t);const a="custom_link"===(null==Y?void 0:Y.value)&&t?t.includes("https")?t:`https://${t}`:t;oe(a,"static_expiry"===e?"string":e),z===p.CHANNEL_TYPE.WHATSAPP&&(null==ue||ue(null!==(l=y.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function oe(e,t){var l,i,n,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(z!==p.CHANNEL_TYPE.WHATSAPP){const a=x.getVariableNameForEmailByIndex(T+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===$?"template_html_mobile":"template_html_desktop"),n=z===p.CHANNEL_TYPE.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:y.variableName);const s=F.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==X||X(s)}if(z===p.CHANNEL_TYPE.WHATSAPP){const l=null!=ae&&ae>-1?F.cards[ae]:F;let u=l.body,d=l.header,r=l.buttons;if(console.log("variableList: ",l),"BODY"===S?u=null===(i=l.body)||void 0===i?void 0:i.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===S?d=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===S&&(r=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===T?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=ae&&ae>-1){const e=a.cloneDeep(F.cards);e[ae]={header:d,body:u,buttons:r},null==X||X((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==X||X((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:r})))}}function ue(e,t,l,i){var n,s,o,u,d,r;const c=null!=ae&&ae>-1?{components:null===(n=Object.assign({},G).components[1].cards)||void 0===n?void 0:n[ae].components,mapping:null===(s=Object.assign({},G).mapping.cards)||void 0===s?void 0:s[ae]}:Object.assign({},G),p=null===(o=null==c?void 0:c.components)||void 0===o?void 0:o.map((l=>{var a,i,n,s,o,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===S){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(o=null===(s=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===S){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===S){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===S)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(c.components=p,l)if("BODY"===S&&(null===(u=null==c?void 0:c.mapping)||void 0===u?void 0:u.body))c.mapping=Object.assign(Object.assign({},c.mapping),{body:c.mapping.body.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===S&&(null===(d=null==c?void 0:c.mapping)||void 0===d?void 0:d.header))c.mapping=Object.assign(Object.assign({},c.mapping),{header:c.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===S&&(null===(r=null==c?void 0:c.mapping)||void 0===r?void 0:r.buttons)){let l=-1,a=-1;p.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),c.mapping=Object.assign(Object.assign({},c.mapping),{buttons:c.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=ae&&ae>-1&&G){const e=a.cloneDeep(G);e.components[1].cards[ae].components=c.components,e.mapping.cards[ae]=c.mapping,null==J||J(e)}else null==J||J(Object.assign({},c))}return i.useEffect((()=>{k&&(null==j||j())}),[k]),i.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===$?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==s?void 0:s.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);z===p.CHANNEL_TYPE.EMAIL&&(null==Q||Q(o))}()}),[K]),i.useEffect((()=>{ie()}),[]),i.useEffect((()=>{ie()}),[ae]),i.useEffect((()=>{$&&Y&&w&&setTimeout((()=>{oe("custom_link"===(null==Y?void 0:Y.value)&&w?w.includes("https")?w:`https://${w}`:w,Y.value)}),100)}),[$]),i.useEffect((()=>{!I&&Y&&y.updatedValue&&setTimeout((()=>{oe("custom_link"===(null==Y?void 0:Y.value)&&y.updatedValue?y.updatedValue.includes("https")?y.updatedValue:`https://${y.updatedValue}`:y.updatedValue,Y.value),W(!0)}),100)}),[Y]),e.jsxs(O,Object.assign({channel:z,focused:k,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:Z&&!Y?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(V=y.variableName)||void 0===V?void 0:V.replace("{{","").replace("}}","")," ","link"===(null==y?void 0:y.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:A?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==Y?void 0:Y.label)?"space-between":"flex-end"}},{children:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:le===m.POD.CHATBOT?null==Y?void 0:Y.value:r.truncate(null!==(L=null==Y?void 0:Y.label)&&void 0!==L?L:"",20,!0)})),e.jsx(t.default,{onClick:()=>{U(!R)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{options:B,isSearchable:!1,onSelect:ne,defaultOptions:Y?[Object.assign(Object.assign({},Y),{selected:!0})]:[]})})),("custom_text"===(null==Y?void 0:Y.value)||"custom_link"===(null==Y?void 0:Y.value))&&e.jsx(d.Input,{labelText:"custom_text"===(null==Y?void 0:Y.value)?"Custom text value":"custom_link"===(null==Y?void 0:Y.value)?"Custom URL value":"",id:`variable-value-${null==Y?void 0:Y.value}-${T}`,value:w,errorMessage:Z?w&&0!==w.trim().length?"custom_link"!==Y.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${w.trim()}`)&&0!==w.trim().length?"custom_link"!==Y.value&&w.length>30?"Length cannot be more than 30":"BUTTONS"===S&&"custom_link"!==Y.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==Y?void 0:Y.value)?2e3:"BUTTONS"===S?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==Y?void 0:Y.value)?"https://":"",placeholder:"link"===y.type||"custom_link"===Y.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{se(Y.value,e)}}),"static_expiry"===(null==Y?void 0:Y.value)&&e.jsx(o.CustomDateTime,{placement:"auto",time:w?l.format(new Date(w),"hh:mm a"):l.format(new Date,"hh:mm a"),date:w?new Date(w):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{se("static_expiry",e.toISOString())}}),R&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=N?N:[],showVariable:R,setShowVariable:U,placeholder:"Add a variable",customTrigger:e=>{null==C||C(!1),"{{custom.url}}"===e.actualValue?ne({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ne({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ne({label:e.displayName,selected:!0,value:"static_expiry"}):ne({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
|
|
7
|
+
`,_={value:"custom_link",label:"Custom URL"},f={value:"custom_text",label:"Custom text"},E={value:"static_expiry",label:"Static Expiry"};exports.Container=O,exports.default=i=>{let{onFocus:j,variable:y,index:T,showVariableModal:A,variableList:N,setShowDiscountCheckBox:C,componentType:S,CTAoptions:P}=i;var V,L;const[k,H]=n.useState(!1),[w,D]=n.useState(""),[B,q]=n.useState([]),[Y,M]=n.useState(),[R,U]=n.useState(!1),[I,W]=n.useState(!1),{device:$,channel:z,isError:Z,originalVariableList:F,template:G,templateSelectionTriggered:K,setTemplate:J,setDisplayContent:Q,setOriginalVariableList:X,globalNormalizedPlaceholders:ee,enabledCustomText:te,pod:le,selectedCarouselIndex:ae}=h.useTemplateModalContext();function ne(){var e,t;const l=[];let a=[];if(z!==p.CHANNEL_TYPE.MESSAGE||te){"link"===(null==y?void 0:y.type)?(l.push({label:"",options:[_,f]}),M(_)):"date_time"===(null==y?void 0:y.type)?(l.push({label:"",options:[_,f]}),M(E)):(l.push({label:"",options:[_,f,E]}),M(f));const e=null!=ee?ee:[];q([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ee?ee:[];q([{label:"",options:[f,_]},...e]),a=[{label:"",options:[f,_]},...e]}if((z===p.CHANNEL_TYPE.WHATSAPP||z===p.CHANNEL_TYPE.EMAIL||z===p.CHANNEL_TYPE.MESSAGE)&&y.updatedValue)if(c.placeHolderNamePattern.test(y.updatedValue)&&z===p.CHANNEL_TYPE.WHATSAPP||y.updatedValue.startsWith("{{")&&z!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(A){let t=e.updatedValue;if(le===m.POD.CHATBOT&&"BUTTONS"===S){const l=null==P?void 0:P.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}n={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(y,a,z);e.value&&M(e)}else"date_time"===y.type?(M(E),D(y.updatedValue),ue(null!==(e=y.index)&&void 0!==e?e:0,y.updatedValue)):(null===(t=y.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(M(_),D(y.updatedValue.split("https://")[1])):(M(f),D(y.updatedValue))}function ie(e,t){var l,a,n;const i=e;D(""),M(i),z===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value&&"static_expiry"!==i.value?(se(null!==(l=i.value)&&void 0!==l?l:"","string"),null==ue||ue(null!==(a=y.index)&&void 0!==a?a:0,i.value,!0)):(null==ue||ue(null!==(n=y.index)&&void 0!==n?n:0,w,!0,i.value),se("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?se(i.value,"url"===i.bikPlaceholderType?"link":"string"):(D(""),se("",i.value))}function oe(e,t){var l;D(t);const a="custom_link"===(null==Y?void 0:Y.value)&&t?t.includes("https")?t:`https://${t}`:t;se(a,"static_expiry"===e?"string":e),console.log("test compo: ",y,Y,a,e),z===p.CHANNEL_TYPE.WHATSAPP&&(null==ue||ue(null!==(l=y.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function se(e,t){var l,n,i,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(z!==p.CHANNEL_TYPE.WHATSAPP){const a=x.getVariableNameForEmailByIndex(T+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===$?"template_html_mobile":"template_html_desktop"),i=z===p.CHANNEL_TYPE.EMAIL?null===(l=null==n?void 0:n.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==t&&"custom_link"!==t||e?e:y.variableName);const o=F.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==X||X(o)}if(z===p.CHANNEL_TYPE.WHATSAPP){const l=null!=ae&&ae>-1?F.cards[ae]:F;let u=l.body,d=l.header,r=l.buttons;if(console.log("variableList: ",l),"BODY"===S?u=null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===S?d=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===S&&(r=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===T?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=ae&&ae>-1){const e=a.cloneDeep(F.cards);e[ae]={header:d,body:u,buttons:r},null==X||X((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==X||X((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:r})))}}function ue(e,t,l,n){var i,o,s,u,d,r;const c=null!=ae&&ae>-1?{components:null===(i=Object.assign({},G).components[1].cards)||void 0===i?void 0:i[ae].components,mapping:null===(o=Object.assign({},G).mapping.cards)||void 0===o?void 0:o[ae]}:Object.assign({},G);console.log("test compo 666: ",c);const p=null===(s=null==c?void 0:c.components)||void 0===s?void 0:s.map((l=>{var a,n,i,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===S){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const l=[...null!==(s=null===(o=null===(i=m.example)||void 0===i?void 0:i.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===S){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===S){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===S)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(c.components=p,l)if("BODY"===S&&(null===(u=null==c?void 0:c.mapping)||void 0===u?void 0:u.body))c.mapping=Object.assign(Object.assign({},c.mapping),{body:c.mapping.body.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===S&&(null===(d=null==c?void 0:c.mapping)||void 0===d?void 0:d.header))c.mapping=Object.assign(Object.assign({},c.mapping),{header:c.mapping.header.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===S&&(null===(r=null==c?void 0:c.mapping)||void 0===r?void 0:r.buttons)){let l=-1,a=-1;p.forEach((t=>{var n;"BUTTONS"===t.type&&(null===(n=t.buttons)||void 0===n||n.forEach(((t,n)=>{"URL"===t.type&&(l++,n===e&&"URL"==t.type&&(a=l))})))})),c.mapping=Object.assign(Object.assign({},c.mapping),{buttons:c.mapping.buttons.map(((e,l)=>l===a?"custom_link"===n?"((customPlaceholderName))":t:e))})}if(null!=ae&&ae>-1&&G){const e=a.cloneDeep(G);e.components[1].cards[ae].components=c.components,e.mapping.cards[ae]=c.mapping,null==J||J(e)}else null==J||J(Object.assign({},c))}return n.useEffect((()=>{k&&(null==j||j())}),[k]),n.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===$?"template_html_mobile":"template_html_desktop",o=document.getElementById(i),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(n=null==o?void 0:o.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);z===p.CHANNEL_TYPE.EMAIL&&(null==Q||Q(s))}()}),[K]),n.useEffect((()=>{ne()}),[]),n.useEffect((()=>{ne()}),[ae]),n.useEffect((()=>{$&&Y&&w&&setTimeout((()=>{se("custom_link"===(null==Y?void 0:Y.value)&&w?w.includes("https")?w:`https://${w}`:w,Y.value)}),100)}),[$]),n.useEffect((()=>{!I&&Y&&y.updatedValue&&setTimeout((()=>{se("custom_link"===(null==Y?void 0:Y.value)&&y.updatedValue?y.updatedValue.includes("https")?y.updatedValue:`https://${y.updatedValue}`:y.updatedValue,Y.value),W(!0)}),100)}),[Y]),e.jsxs(O,Object.assign({channel:z,focused:k,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:Z&&!Y?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(V=y.variableName)||void 0===V?void 0:V.replace("{{","").replace("}}","")," ","link"===(null==y?void 0:y.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:A?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==Y?void 0:Y.label)?"space-between":"flex-end"}},{children:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:le===m.POD.CHATBOT?null==Y?void 0:Y.value:r.truncate(null!==(L=null==Y?void 0:Y.label)&&void 0!==L?L:"",20,!0)})),e.jsx(t.default,{onClick:()=>{U(!R)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{options:B,isSearchable:!1,onSelect:ie,defaultOptions:Y?[Object.assign(Object.assign({},Y),{selected:!0})]:[]})})),("custom_text"===(null==Y?void 0:Y.value)||"custom_link"===(null==Y?void 0:Y.value))&&e.jsx(d.Input,{labelText:"custom_text"===(null==Y?void 0:Y.value)?"Custom text value":"custom_link"===(null==Y?void 0:Y.value)?"Custom URL value":"",id:`variable-value-${null==Y?void 0:Y.value}-${T}`,value:w,errorMessage:Z?w&&0!==w.trim().length?"custom_link"!==Y.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${w.trim()}`)&&0!==w.trim().length?"custom_link"!==Y.value&&w.length>30?"Length cannot be more than 30":"BUTTONS"===S&&"custom_link"!==Y.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==Y?void 0:Y.value)?2e3:"BUTTONS"===S?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==Y?void 0:Y.value)?"https://":"",placeholder:"link"===y.type||"custom_link"===Y.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{oe(Y.value,e)}}),"static_expiry"===(null==Y?void 0:Y.value)&&e.jsx(s.CustomDateTime,{placement:"auto",time:w?l.format(new Date(w),"hh:mm a"):l.format(new Date,"hh:mm a"),date:w?new Date(w):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{oe("static_expiry",e.toISOString())}}),R&&e.jsx(o.AddVariableV2SideModal,{zIndex:2e3,data:null!=N?N:[],showVariable:R,setShowVariable:U,placeholder:"Add a variable",customTrigger:e=>{null==C||C(!1),"{{custom.url}}"===e.actualValue?ie({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ie({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ie({label:e.displayName,selected:!0,value:"static_expiry"}):ie({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
|
package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../input/Input.js"),i=require("../../TypographyStyle.js"),l=require("../../../constants/Theme.js"),t=require("../context/templateModalContext.js"),r=require("../custom-hooks/useAdditionalVariables.js"),d=require("./VariableConnector.js");exports.default=s=>{let{descriptionComponent:o,type:n,showVariableModal:p,variableList:b}=s;var c,u,x,v,y,m;const{originalVariableList:j,disableEditVariable:h,selectedCarouselIndex:V}=t.useTemplateModalContext(),g=r.useAdditionalVariables({variableList:b,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});return"BODY"===o.type?e.jsx("div",{children:null===(c=null!=V&&V>-1?j.cards[V].body:null==j?void 0:j.body)||void 0===c?void 0:c.map(((t,r)=>h||!t.isEditableVariable?e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(i.BodySecondary,Object.assign({style:{color:l.COLORS.content.primary}},{children:["HEADER"===n?"Header":""," Locked variable ",r+1]})),e.jsx(a.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),r):e.jsx(d.default,{index:r,variable:t,showVariableModal:p,variableList:b,componentType:o.type},`${r}-${t.index}`)))}):"HEADER"===o.type?e.jsx("div",{children:null===(u=null!=V&&V>-1?j.cards[V].header:null==j?void 0:j.header)||void 0===u?void 0:u.map(((t,r)=>t.isEditableVariable?e.jsx(d.default,{index:r,variable:t,showVariableModal:p,variableList:b,componentType:o.type},`${r}-${t.index}`):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(i.BodySecondary,Object.assign({style:{color:l.COLORS.content.primary}},{children:["HEADER"===n?"Header":""," Locked variable ",r+1]})),e.jsx(a.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),r)))}):"limited_time_offer"===o.type?e.jsx("div",{children:e.jsx(d.default,{index:0,variable:{variableName:null!==(v=null===(x=null==o?void 0:o.limited_time_offer)||void 0===x?void 0:x.text)&&void 0!==v?v:"Expires after",updatedValue:null!==(m=null===(y=o.example)||void 0===y?void 0:y.limited_time_offer)&&void 0!==m?m:(new Date).toISOString(),type:"date_time",isEditableVariable:!0,index:0},showVariableModal:p,variableList:g,componentType:o.type},`${o.type}`)}):e.jsx(e.Fragment,{})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../input/Input.js"),i=require("../../TypographyStyle.js"),l=require("../../../constants/Theme.js"),t=require("../context/templateModalContext.js"),r=require("../custom-hooks/useAdditionalVariables.js"),d=require("./VariableConnector.js");exports.default=s=>{let{descriptionComponent:o,type:n,showVariableModal:p,variableList:b}=s;var c,u,x,v,y,m;const{originalVariableList:j,disableEditVariable:h,selectedCarouselIndex:V}=t.useTemplateModalContext(),g=r.useAdditionalVariables({variableList:b,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});return console.log("originalVariableList: ",j),"BODY"===o.type?e.jsx("div",{children:null===(c=null!=V&&V>-1?j.cards[V].body:null==j?void 0:j.body)||void 0===c?void 0:c.map(((t,r)=>h||!t.isEditableVariable?e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(i.BodySecondary,Object.assign({style:{color:l.COLORS.content.primary}},{children:["HEADER"===n?"Header":""," Locked variable ",r+1]})),e.jsx(a.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),r):e.jsx(d.default,{index:r,variable:t,showVariableModal:p,variableList:b,componentType:o.type},`${r}-${t.index}`)))}):"HEADER"===o.type?e.jsx("div",{children:null===(u=null!=V&&V>-1?j.cards[V].header:null==j?void 0:j.header)||void 0===u?void 0:u.map(((t,r)=>t.isEditableVariable?e.jsx(d.default,{index:r,variable:t,showVariableModal:p,variableList:b,componentType:o.type},`${r}-${t.index}`):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(i.BodySecondary,Object.assign({style:{color:l.COLORS.content.primary}},{children:["HEADER"===n?"Header":""," Locked variable ",r+1]})),e.jsx(a.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),r)))}):"limited_time_offer"===o.type?e.jsx("div",{children:e.jsx(d.default,{index:0,variable:{variableName:null!==(v=null===(x=null==o?void 0:o.limited_time_offer)||void 0===x?void 0:x.text)&&void 0!==v?v:"Expires after",updatedValue:null!==(m=null===(y=o.example)||void 0===y?void 0:y.limited_time_offer)&&void 0!==m?m:(new Date).toISOString(),type:"date_time",isEditableVariable:!0,index:0},showVariableModal:p,variableList:g,componentType:o.type},`${o.type}`)}):e.jsx(e.Fragment,{})};
|
package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAp
|
|
|
5
5
|
export type URLBtnUpdateFunctionType = (val: CTABtnValType, mode: 'custom' | 'placeholder', btnIndex?: number) => void;
|
|
6
6
|
export type QRBBtnUpdateFunctionType = (val: QRBBtnValType, mode: 'custom' | 'placeholder', btnIndex?: number) => void;
|
|
7
7
|
export interface WhatsAppTemplateCardButtonV2Props {
|
|
8
|
-
|
|
8
|
+
currentVariableList: WhatsAppTemplateVariables;
|
|
9
9
|
updateSelectedURLTemplateBtn?: URLBtnUpdateFunctionType;
|
|
10
10
|
updateSelectedQRBTemplateBtn?: QRBBtnUpdateFunctionType;
|
|
11
11
|
button: TEMPLATE_BUTTON;
|
|
@@ -14,5 +14,5 @@ export interface WhatsAppTemplateCardButtonV2Props {
|
|
|
14
14
|
variableList?: VariableListInterfaceV2[];
|
|
15
15
|
variableListIndex: number;
|
|
16
16
|
}
|
|
17
|
-
declare const WhatsAppTemplateCardButtonV2: ({ variableListIndex, button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn,
|
|
17
|
+
declare const WhatsAppTemplateCardButtonV2: ({ variableListIndex, button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, currentVariableList, CTAoptions, QRBoptions, variableList, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
export default WhatsAppTemplateCardButtonV2;
|
package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../dropdown/Dropdown.js"),a=require("../../input/Input.js"),s=require("../../template-preview/constants/regexPatterns.js"),i=require("../../template-preview/models/TemplateMeta.js"),n=require("../../template-preview/models/WhatsAppTemplate.js"),o=require("../../TypographyStyle.js"),r=require("../../../constants/Theme.js"),u=require("../context/templateModalContext.js"),d=require("../custom-hooks/useAdditionalVariables.js"),c=require("../utils/validateIsUrl.js"),b=require("./VariableConnector.js");exports.default=p=>{let{variableListIndex:m,button:j,updateSelectedURLTemplateBtn:v,updateSelectedQRBTemplateBtn:x,currentVariableList:g,CTAoptions:O,QRBoptions:f,variableList:y}=p;var L,h,V,R;const[U,C]=t.useState(""),[T,q]=t.useState(),w=d.useAdditionalVariables({variableList:y,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom URL",variableValue:"{{custom.url}}"}),{isError:I,disableEditVariable:S,pod:B,selectedCarouselIndex:N,originalVariableList:E,setOriginalVariableList:M}=u.useTemplateModalContext();function P(e){C(e);let t=g.buttons.filter((e=>"URL"===e.type))[m];t=Object.assign(Object.assign({},t),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const l=g.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),a=Object.assign({},null!=N&&N>-1?E.cards[N]:E);if(a.buttons=l,null!=N&&N>-1){const e=[...E.cards];e[N]=a,null==M||M((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==M||M((e=>Object.assign(Object.assign({},e),{buttons:[...l]})));null==v||v(`https://${e}`,"custom",m)}return t.useEffect((()=>{var e;if(j.buttonVariable&&s.editableVarPattern.test(j.buttonVariable))q(i.CUSTOM_URL_NAME),C((null===(e=j.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===j.type?O:f;e="URL"===j.type?t.findIndex((e=>e.placeHolder===j.buttonVariable)):t.findIndex((e=>e.label===j.flowName)),e>-1&&q(t[e])}}),[]),B!==n.POD.CHATBOT?e.jsxs(b.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(o.BodySecondary,Object.assign({style:{color:r.COLORS.content.primary}},{children:[j.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(l.Dropdown,{disabled:S,options:"URL"===j.type?O:f,isSearchable:!1,onSelect:function(e,t){const l=e;q(l);const a=("URL"===j.type?O:f).find((e=>e.placeHolder===l.placeHolder));if(a)if("custom_link"!==a.value){let e;if("URL"===j.type){let t=g.buttons.filter((e=>"URL"===e.type))[m];t=Object.assign(Object.assign({},t),{buttonVariable:l.placeHolder}),e=g.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==v||v({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder",m)}else{let t=g.buttons.filter((e=>"QUICK_REPLY"===e.type))[m];t=Object.assign(Object.assign({},t),{flowName:l.label,flowId:l.value}),e=g.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==x||x({flowName:l.label,flowId:l.value},"placeholder",m)}console.log("templateCopy updatedVariables: ",e);const t=Object.assign({},null!=N&&N>-1?E.cards[N]:E);if(t.buttons=e,null!=N&&N>-1){const e=[...E.cards];e[N]=t,null==M||M((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==M||M((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else P("")},defaultOptions:T?[Object.assign(Object.assign({},T),{selected:!0})]:[]})})),"custom_link"===(null==T?void 0:T.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(a.Input,{state:S?"disabled":"none",errorMessage:I?U?c.validateIsUrl(U)?"":"Enter valid URL":"Required field":"",value:U,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:P,maxCharLimit:2e3})}))]}):e.jsx(b.default,{index:m,variable:{variableName:null!==(L=j.text)&&void 0!==L?L:"",updatedValue:"((customPlaceholderName))"===j.buttonVariable?`${null===(h=j.example)||void 0===h?void 0:h[0]}`:null!==(V=j.buttonVariable)&&void 0!==V?V:"",type:"link",isEditableVariable:!0,index:null!==(R=j.index)&&void 0!==R?R:0},showVariableModal:!0,componentType:"BUTTONS",variableList:w,CTAoptions:O})};
|
|
@@ -31,7 +31,6 @@ export interface TemplateContextMapperProps {
|
|
|
31
31
|
disableEditVariable?: boolean;
|
|
32
32
|
pod?: POD;
|
|
33
33
|
extras?: ExtrasWhatsapp;
|
|
34
|
-
isProductCarouselType?: boolean;
|
|
35
34
|
pickerConf?: {
|
|
36
35
|
searchInCollection: any;
|
|
37
36
|
searchProducts: any;
|
|
@@ -40,4 +39,4 @@ export interface TemplateContextMapperProps {
|
|
|
40
39
|
storeId: string;
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
|
-
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras,
|
|
42
|
+
export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras, pickerConf, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as l,Fragment as t}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import s from"../../utils/StringUtils.js";import{StyledModal as
|
|
1
|
+
import{jsx as e,jsxs as l,Fragment as t}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import s from"../../utils/StringUtils.js";import{StyledModal as n}from"../modals/styledModal.js";import{CHANNEL_TYPE as r}from"../template-preview/models/Channels.js";import{TemplateModalContext as d}from"./context/templateModalContext.js";import c from"./modalElements/Footer.js";import p from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as m}from"./utils/convertPlaceholdersToBikDropdown.js";const u=u=>{let{selectedTemplate:h,closeDialog:v,showVariableMapping:C,channel:b,htmlContent:g,templateVariables:S,onTemplateSelect:f,globalPlaceholders:T,showOnlyContent:P,whatsappSpecificPickerMeta:w,zIndex:x,showVariableModal:M,variableList:L,discountCode:V,setDiscountCode:j,onBackPress:y,enabledCustomText:E,variableListForImage:I,showSampleValues:k,disableEditVariable:A,pod:D,extras:O,pickerConf:F}=u;var W,z,B,H,U,$;o((()=>{G(g)}),[g]);const N=b===r.WHATSAPP&&"CAROUSEL"===(null===(z=null===(W=h.components)||void 0===W?void 0:W[1])||void 0===z?void 0:z.type),[R,_]=a(b===r.EMAIL||N?"desktop":"mobile"),[q,G]=a(g),[J,K]=a(!1),[Q,X]=a(h),[Y,Z]=a(null!=S?S:[]),[ee,le]=a(!1),[te,oe]=a(-1);const ae=i((()=>m(T)),[T]);return e(d.Provider,Object.assign({value:{template:Q,setTemplate:X,device:R,setDevice:_,display_content:q,setDisplayContent:G,originalVariableList:Y,setOriginalVariableList:Z,isError:J,setIsError:K,channel:b,globalNormalizedPlaceholders:ae,templateSelectionTriggered:ee,setTemplateSelectionTriggered:le,enabledCustomText:E,disableEditVariable:A,pod:D,extras:O,isWhatsappCarousel:N,selectedCarouselIndex:te,setSelectedCarouselIndex:oe,isProductCarouselType:h.isProductCarouselType,cardCount:null===(H=null===(B=h.components)||void 0===B?void 0:B[1].cards)||void 0===H?void 0:H.length,pickerConf:F}},{children:P?e(p,{channel:r.EMAIL,hideHeader:!0}):l(n,Object.assign({zIndex:x,centralContainerStyles:{width:N?900:b===r.EMAIL&&C?1e3:800},open:!0,onClose:()=>{null==v||v()},headingTitle:null==Q?void 0:Q.label,headingSubtitle:b===r.WHATSAPP?`${s.capitaliseFirstLetterOfString(null!==(U=null==Q?void 0:Q.category)&&void 0!==U?U:"")} • ${null!==($=null==Q?void 0:Q.templateCategory)&&void 0!==$?$:""}`:"",onBackPress:()=>{null==y||y()}},{children:[e(p,{showSampleValues:k,showVariableMapping:C,channel:b,whatsappSpecificPickerMeta:w,showVariableModal:M,variableList:L,discountCode:V,setDiscountCode:j,variableListForImage:I&&(null==I?void 0:I.length)>0?I:L}),f?e(c,{isWhatsappCarousel:null!=N&&N,onSelect:function(){const e=null==f?void 0:f(Q,Y,null!=q?q:"");e?K(!!e):le(!0)}}):e(t,{})]}))}))};export{u as TemplateContextMapper};
|
|
@@ -30,6 +30,7 @@ export declare const TemplateModalContext: React.Context<{
|
|
|
30
30
|
selectedCarouselIndex?: number | undefined;
|
|
31
31
|
setSelectedCarouselIndex?: React.Dispatch<React.SetStateAction<number>> | undefined;
|
|
32
32
|
isProductCarouselType?: boolean | undefined;
|
|
33
|
+
cardCount?: number | undefined;
|
|
33
34
|
pickerConf?: {
|
|
34
35
|
searchInCollection: any;
|
|
35
36
|
searchProducts: any;
|
|
@@ -62,6 +63,7 @@ export declare const useTemplateModalContext: () => {
|
|
|
62
63
|
selectedCarouselIndex?: number | undefined;
|
|
63
64
|
setSelectedCarouselIndex?: React.Dispatch<React.SetStateAction<number>> | undefined;
|
|
64
65
|
isProductCarouselType?: boolean | undefined;
|
|
66
|
+
cardCount?: number | undefined;
|
|
65
67
|
pickerConf?: {
|
|
66
68
|
searchInCollection: any;
|
|
67
69
|
searchProducts: any;
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import o from"../../../assets/icons/PlusIcon.js";import{useState as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import o from"../../../assets/icons/PlusIcon.js";import{useState as r,useEffect as s}from"react";import a from"styled-components";import{AddVariableV2SideModal as l}from"../../add-variableV2/AddVariableV2SideModal.js";import"../../../_virtual/_tslib.js";import"../../add-variableV2/AddVariableV2.styled.js";import{Button as n}from"../../button/Button.js";import{IconButton as d}from"../../icon-button/IconButton.js";import"../../input/Input.js";import"../../tooltips/Tooltip.js";import{COLORS as c}from"../../../constants/Theme.js";import"../../modals/modal.styled.js";import"../../switch/Switch.js";import{TitleMedium as p,BodyCaption as m,TitleRegular as u}from"../../TypographyStyle.js";import{ProductPickerModal as f}from"../../product-picker-v2/modal.js";import{useTemplateModalContext as h}from"../context/templateModalContext.js";import g from"./EditWhatsAppTemplateV2.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import"../../curtain/CurtainHelper.js";import"../../template-preview/models/TemplateMeta.js";import{POD as y}from"../../template-preview/models/WhatsAppTemplate.js";import b from"../../../assets/icons/box.svg.js";import v from"../../../assets/icons/delete.svg.js";import j from"../../../assets/icons/edit.svg.js";const x=a=>{let{template:d,whatsappSpecificPickerMeta:u,showVariableModal:b,variableList:v,variableListForImage:j,discountCode:x,setDiscountCode:w}=a;const{selectedCarouselIndex:C,setTemplate:O,pickerConf:T,isProductCarouselType:k,pod:P,cardCount:A}=h(),[S,V]=r(-1==C?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[B,L]=r(!1),[M,F]=r(!1),[W,_]=r([]);s((()=>{V(-1==C?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[C]);return e("div",{children:[t(p,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:S})),k&&W.length>0&&null!=C&&C>=0&&e("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,flexDirection:"column"}},{children:[t(I,{editItem:()=>L(!B),cardBody:`${W.length} Products Selected`,deleteItem:()=>{_([])}}),t(n,{disabled:W.length<=1,style:{alignSelf:"flex-end",background:c.surface.subdued},onClick:()=>{L(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),k&&0===W.length&&null!=C&&C>=0&&e("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[t(n,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12},size:"medium",buttonText:"Add Product(s)",buttonType:"dashBold",LeadingIcon:o,onClick:e=>{L(!0)}}),P===y.CHATBOT&&e(i,{children:[e("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),t(m,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),t(n,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:o,onClick:e=>{F(!0)}})]})]})),t(g,{whatsappSpecificPickerMeta:u,template:d,onTemplateChange:e=>{null==O||O(e)},showVariableModal:b,variableList:v,variableListForImage:j,discountCode:x,setDiscountCode:w}),B&&T&&t(f,{zIndex:200,limit:null!=A?A:1,storeId:T.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const i of e){const e=null==i?void 0:i.collectionId,o=i.productId,r=i.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),o in t[e].products||(t[e].products[o]={variants:{},name:(null==i?void 0:i.productName)||"",image:(null==i?void 0:i.productImage)||""}),t[e].products[o].variants[r]={name:(null==i?void 0:i.name)||"",price:"",image:(null==i?void 0:i.image)||"",quantity:i.quantity||0,displayOrder:i.displayOrder}}return t}return{}})(W),collectionFetcher:T.fetchCollections,productFetcher:T.fetchProducts,onAdd:(e,t)=>{const i=[];delete e.isCustom;for(const t of Object.keys(e)){const o=e[t].products;if(void 0!==o&&Object.keys(o).length)for(const e of Object.keys(o)){const r=o[e].variants;if(void 0!==r&&Object.keys(r).length)for(const s of Object.keys(r)){const{name:a,image:l,quantity:n,displayOrder:d}=r[s],c={name:a,image:l,quantity:n,variantId:s,productId:e,displayOrder:d,collectionId:t,productName:o[e].name,productImage:o[e].image};i.push(c)}}}const o=i.sort(((e,t)=>e.displayOrder-t.displayOrder));_(o),L(!1)},searchInCollectionFetcher:T.searchInCollection,searchFetcher:T.searchProducts,visible:B,onClose:()=>{L(!1)}}),M&&t(l,{zIndex:2e3,data:null!=v?v:[],showVariable:M,setShowVariable:F,placeholder:"Add a variable",customTrigger:e=>{}})]})},I=i=>{const{cardBody:o,deleteItem:r,editItem:s}=i;return e(w,Object.assign({width:"100%"},{children:[t("div",Object.assign({style:{width:36,height:36}},{children:t(b,{})})),t("div",Object.assign({className:"card-body"},{children:t(u,{children:o})})),e("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[s&&t(d,{style:{display:"flex"},Icon:j,onClick:e=>{s(),e.stopPropagation()}}),t(d,{style:{display:"flex",color:"#919191"},Icon:v,onClick:e=>{r(),e.stopPropagation()}})]}))]}))},w=a.div`
|
|
2
2
|
width: ${e=>e.width};
|
|
3
3
|
padding: 12px;
|
|
4
4
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as o,jsx as
|
|
1
|
+
import{jsxs as o,jsx as e}from"react/jsx-runtime";import{cloneDeep as n}from"lodash";import{useState as t,useEffect as i}from"react";import{POD as l}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as s}from"../context/templateModalContext.js";import{useAdditionalVariables as a}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as d}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as r}from"./BackTrackComponent.js";import{DiscountCodeComponent as p}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as c}from"./EditMediaV2.style.js";import u from"./EditWhatsAppTemplateMediaV2.js";import m from"./VariableConnector.js";import{Container as v}from"./VariableConnectorsPanel.js";import b from"./VariableConnectorWhatsApp.js";import g from"./VariableEditorHeader.js";import f from"./WhatsAppTemplateCardButtonV2.js";const h=h=>{let{template:C,onTemplateChange:j,whatsappSpecificPickerMeta:y,showVariableModal:T,variableList:V,variableListForImage:x,discountCode:O,setDiscountCode:B}=h;var E,L,k,I,w,U,R,A,P,D,M,N,_,q;const{originalVariableList:Q,pod:S,extras:H,selectedCarouselIndex:Y,isProductCarouselType:K}=s(),{descriptionComponents:W,urlBtns:$,qrbBtns:F,imageComponent:X,bodyVariables:z,headerVariables:G}=d(C),[J,Z]=t(!1),[oo,eo]=t(-1===Y?{descriptionComponents:W,urlBtns:$,qrbBtns:F,imageComponent:X,bodyVariables:z,headerVariables:G}:{}),[no,to]=t(!1);function io(o,e,t){var i,l,s,a,d,r,p,c;const u=null!=Y&&Y>-1?{components:null===(i=Object.assign({},C).components[1].cards)||void 0===i?void 0:i[Y].components,mapping:null===(l=Object.assign({},C).mapping.cards)||void 0===l?void 0:l[Y]}:Object.assign({},C),m=null==u?void 0:u.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==m&&m>-1){const n=null===(s=null==u?void 0:u.components[m].buttons)||void 0===s?void 0:s.filter((o=>"URL"===o.type));if((null==n?void 0:n.length)>0){const i="custom"===e&&"string"==typeof o,l=i?o:"string"!=typeof o?o.defaultValue:"";let s=n[t];s=Object.assign(Object.assign({},s),{url:"https://d.bik.ai/{{1}}",example:[l]}),console.log("templateCopy test: ",t,s,e,o);const c=[...null!==(r=null===(d=null===(a=u.components)||void 0===a?void 0:a[m])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==s?void 0:s.text)?s:o)),v=Object.assign(Object.assign({},u.components[m]),{buttons:c}),b=null===(p=u.mapping)||void 0===p?void 0:p.buttons;b&&b.length>0&&(b[t]=i?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:"");const g=Object.assign(Object.assign({},u.mapping),{buttons:b});u.mapping=g;const f=[...u.components];f[m]=v,u.components=f}}if("string"!=typeof o){"checkout.checkoutUrl"===(null===(c=o.placeHolder)||void 0===c?void 0:c.slice(2,-2))?Z(!0):(Z(!1),null==B||B(""))}if(null!=Y&&Y>-1){const o=n(C);o.components[1].cards[Y].components=u.components,o.mapping.cards[Y]=u.mapping,console.log("templateCopy: ",o),null==j||j(Object.assign({},o))}else null==j||j(u)}function lo(o,e,t){var i,l,s,a,d,r;const p=null!=Y&&Y>-1?{components:null===(i=Object.assign({},C).components[1].cards)||void 0===i?void 0:i[Y].components,mapping:null===(l=Object.assign({},C).mapping.cards)||void 0===l?void 0:l[Y]}:Object.assign({},C),c=null==p?void 0:p.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==c&&c>-1){const n=null===(s=null==p?void 0:p.components[c].buttons)||void 0===s?void 0:s.filter((o=>"QUICK_REPLY"===o.type));if(n){let i=n[t];i=Object.assign(Object.assign({},i),{flowId:o.flowId,flowName:o.flowName}),console.log("templateCopy 2 test: ",t,i,e,o);const l=[...null!==(r=null===(d=null===(a=p.components)||void 0===a?void 0:a[c])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==i?void 0:i.text)?i:o)),s=Object.assign(Object.assign({},p.components[c]),{buttons:l}),u=[...p.components];u[c]=s,p.components=u}}if(null!=Y&&Y>-1){const o=n(C);o.components[1].cards[Y].components=p.components,o.mapping.cards[Y]=p.mapping,console.log("templateCopy 2: ",o),null==j||j(Object.assign({},o))}else null==j||j(p)}i((()=>{var o,e;if(null===(o=C.mapping.buttons)||void 0===o?void 0:o.find((o=>"checkout.checkoutUrl"===o.slice(2,-2))))Z(!0);else{Z(!1);const o=null===(e=null==H?void 0:H.discountCodeExtra)||void 0===e?void 0:e[1];null==o||o("")}}),[C]),i((()=>{console.log("templateComponentData: ",oo)}),[oo]),i((()=>{var o,e,n,t;if(null!=Y&&Y>-1){const i={components:null===(e=null===(o=C.components[1])||void 0===o?void 0:o.cards)||void 0===e?void 0:e[Y].components,mapping:null===(t=null===(n=null==C?void 0:C.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);eo({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c})}else if(null!=Y&&-1===Y){const{descriptionComponents:o,urlBtns:e,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=d(C);eo({descriptionComponents:o,urlBtns:e,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Y]),i((()=>{var o,e,n,t;if(console.log("right panel selectedCarouselIndex: ",Y),null!=Y&&Y>-1&&no){const i={components:null===(e=null===(o=C.components[1])||void 0===o?void 0:o.cards)||void 0===e?void 0:e[Y].components,mapping:null===(t=null===(n=null==C?void 0:C.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);eo({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}),to(!1)}}),[no]);const so=a({variableList:V,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return o(v,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!oo.imageComponent&&!K&&e(c,{children:e(u,{whatsappSpecificPickerMeta:y,mediaComponent:oo.imageComponent,updateTemplateImageUrl:function(o,e){var t,i,l,s,a;let d;d=null!=Y&&Y>-1?{components:null===(i=null===(t=C.components[1])||void 0===t?void 0:t.cards)||void 0===i?void 0:i[Y].components,mapping:null===(s=null===(l=null==C?void 0:C.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[Y]}:Object.assign({},C);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((o=>{if("HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const n=Object.assign(Object.assign({},d.components[r]),{format:e,example:{header_handle:[o]}}),t=[...d.components];t[r]=n,d=Object.assign(Object.assign({},d),{components:t})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=Y&&Y>-1){const o=n(C);o.components[1].cards[Y].components=d.components,o.mapping.cards[Y]=d.mapping,null==j||j(Object.assign({},o)),to(!0)}else null==j||j(Object.assign({},d))},template:C,variableListForImage:x})}),(oo.bodyVariables.length>0||oo.headerVariables.length>0)&&e(g,{containerStyle:{paddingTop:oo.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(E=oo.descriptionComponents)||void 0===E?void 0:E.map(((o,n)=>e(b,{originalVariableList:null!=Y&&Y>-1?Q.cards[Y]:Q,type:o.type,descriptionComponent:o.component,showVariableModal:T,variableList:V},n))),(null===(k=null===(L=null!=Y&&Y>-1?Q.cards[Y].buttons:null==Q?void 0:Q.buttons)||void 0===L?void 0:L.filter((o=>"URL"===o.type)))||void 0===k?void 0:k.length)>0&&e(g,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(w=null===(I=null!=Y&&Y>-1?Q.cards[Y].buttons:null==Q?void 0:Q.buttons)||void 0===I?void 0:I.filter((o=>"URL"===o.type)))||void 0===w?void 0:w.map(((o,n)=>{if("URL"===o.type)return e(f,{variableListIndex:n,CTAoptions:null==y?void 0:y.CTAoptions,button:o,currentVariableList:null!=Y&&Y>-1?Q.cards[Y]:Q,updateSelectedURLTemplateBtn:io,variableList:V},`${n}_${Y}`)})),(null===(R=null===(U=null!=Y&&Y>-1?Q.cards[Y].buttons:null==Q?void 0:Q.buttons)||void 0===U?void 0:U.filter((o=>"QUICK_REPLY"===o.type)))||void 0===R?void 0:R.length)>0&&(S!==l.CHATBOT?e(g,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e(r,{backTrackMessage:null===(A=null==H?void 0:H.backTrackExtra)||void 0===A?void 0:A[0],setBackTrackMessage:null===(P=null==H?void 0:H.backTrackExtra)||void 0===P?void 0:P[1]})),null===(M=null===(D=null!=Y&&Y>-1?Q.cards[Y].buttons:null==Q?void 0:Q.buttons)||void 0===D?void 0:D.filter((o=>"QUICK_REPLY"===o.type)))||void 0===M?void 0:M.map(((o,n)=>{if("QUICK_REPLY"===o.type)return e(f,{variableListIndex:n,QRBoptions:null==y?void 0:y.QRBoptions,button:o,currentVariableList:null!=Y&&Y>-1?Q.cards[Y]:Q,updateSelectedQRBTemplateBtn:lo},`${n}_${Y}`)})),S===l.CHATBOT&&J&&e(p,{discountCode:null===(N=null==H?void 0:H.discountCodeExtra)||void 0===N?void 0:N[0],setDiscountCode:null===(_=null==H?void 0:H.discountCodeExtra)||void 0===_?void 0:_[1],variableList:V}),null===(q=null!=Y&&Y>-1?Q.cards[Y].buttons:null==Q?void 0:Q.buttons)||void 0===q?void 0:q.map(((o,n)=>{var t,i,l;if("COPY_CODE"===o.type)return e(m,{index:n,variable:{variableName:null!==(t=o.text)&&void 0!==t?t:"",updatedValue:null!==(i=o.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=o.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:so,componentType:"BUTTONS"},n)}))]}))};export{h as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/icons/edit.svg.js";import{format as a}from"date-fns";import{cloneDeep as i}from"lodash";import{useState as n,useEffect as o}from"react";import s from"styled-components";import{AddVariableV2SideModal as u}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as d}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/icons/edit.svg.js";import{format as a}from"date-fns";import{cloneDeep as i}from"lodash";import{useState as n,useEffect as o}from"react";import s from"styled-components";import{AddVariableV2SideModal as u}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as d}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as c}from"../../dropdown/Dropdown.js";import{Input as r}from"../../input/Input.js";import{truncate as p}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as m}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as v}from"../../template-preview/models/Channels.js";import{POD as b}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as g,BodyPrimary as h}from"../../TypographyStyle.js";import f from"../../../utils/StringUtils.js";import{COLORS as x}from"../../../constants/Theme.js";import{useTemplateModalContext as O}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as j}from"../utils/getVariableNameEmail.js";const y=s.div`
|
|
2
2
|
/* surface/$color-background-warning-light */
|
|
3
3
|
|
|
4
4
|
background: ${e=>e.focused&&e.channel===v.EMAIL?x.background.warning.light:"transparent"};
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
padding: 8px 10px;
|
|
7
|
-
`,_={value:"custom_link",label:"Custom URL"},T={value:"custom_text",label:"Custom text"},k={value:"static_expiry",label:"Static Expiry"},V=s=>{let{onFocus:V,variable:A,index:E,showVariableModal:S,variableList:w,setShowDiscountCheckBox:C,componentType:P,CTAoptions:B}=s;var L,D;const[N,H]=n(!1),[U,M]=n(""),[W,I]=n([]),[R,$]=n(),[z,Y]=n(!1),[Z,G]=n(!1),{device:q,channel:F,isError:K,originalVariableList:J,template:Q,templateSelectionTriggered:X,setTemplate:ee,setDisplayContent:te,setOriginalVariableList:le,globalNormalizedPlaceholders:ae,enabledCustomText:ie,pod:ne,selectedCarouselIndex:oe}=O();function se(){var e,t;const l=[];let a=[];if(F!==v.MESSAGE||ie){"link"===(null==A?void 0:A.type)?(l.push({label:"",options:[_,T]}),$(_)):"date_time"===(null==A?void 0:A.type)?(l.push({label:"",options:[_,T]}),$(k)):(l.push({label:"",options:[_,T,k]}),$(T));const e=null!=ae?ae:[];I([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:f.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ae?ae:[];I([{label:"",options:[T,_]},...e]),a=[{label:"",options:[T,_]},...e]}if((F===v.WHATSAPP||F===v.EMAIL||F===v.MESSAGE)&&A.updatedValue)if(m.test(A.updatedValue)&&F===v.WHATSAPP||A.updatedValue.startsWith("{{")&&F!==v.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===v.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(S){let t=e.updatedValue;if(ne===b.CHATBOT&&"BUTTONS"===P){const l=null==B?void 0:B.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(A,a,F);e.value&&$(e)}else"date_time"===A.type?($(k),M(A.updatedValue),ce(null!==(e=A.index)&&void 0!==e?e:0,A.updatedValue)):(null===(t=A.updatedValue)||void 0===t?void 0:t.startsWith("https"))?($(_),M(A.updatedValue.split("https://")[1])):($(T),M(A.updatedValue))}function ue(e,t){var l,a,i;const n=e;M(""),$(n),F===v.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(re(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ce||ce(null!==(a=A.index)&&void 0!==a?a:0,n.value,!0)):(null==ce||ce(null!==(i=A.index)&&void 0!==i?i:0,U,!0,n.value),re("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?re(n.value,"url"===n.bikPlaceholderType?"link":"string"):(M(""),re("",n.value))}function de(e,t){var l;M(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;re(a,"static_expiry"===e?"string":e),F===v.WHATSAPP&&(null==ce||ce(null!==(l=A.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function re(e,t){var l,a,n,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(F!==v.WHATSAPP){const a=j(E+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===q?"template_html_mobile":"template_html_desktop"),n=F===v.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:A.variableName);const o=J.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==le||le(o)}if(F===v.WHATSAPP){const l=null!=oe&&oe>-1?J.cards[oe]:J;let u=l.body,d=l.header,r=l.buttons;if(console.log("variableList: ",l),"BODY"===P?u=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===P?d=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===P&&(r=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===E?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=oe&&oe>-1){const e=i(J.cards);e[oe]={header:d,body:u,buttons:r},null==le||le((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==le||le((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:r})))}}function ce(e,t,l,a){var n,o,s,u,d,r;const c=null!=oe&&oe>-1?{components:null===(n=Object.assign({},Q).components[1].cards)||void 0===n?void 0:n[oe].components,mapping:null===(o=Object.assign({},Q).mapping.cards)||void 0===o?void 0:o[oe]}:Object.assign({},Q),p=null===(s=null==c?void 0:c.components)||void 0===s?void 0:s.map((l=>{var a,i,n,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===P){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(c.components=p,l)if("BODY"===P&&(null===(u=null==c?void 0:c.mapping)||void 0===u?void 0:u.body))c.mapping=Object.assign(Object.assign({},c.mapping),{body:c.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===P&&(null===(d=null==c?void 0:c.mapping)||void 0===d?void 0:d.header))c.mapping=Object.assign(Object.assign({},c.mapping),{header:c.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===P&&(null===(r=null==c?void 0:c.mapping)||void 0===r?void 0:r.buttons)){let l=-1,i=-1;p.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),c.mapping=Object.assign(Object.assign({},c.mapping),{buttons:c.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=oe&&oe>-1&&Q){const e=i(Q);e.components[1].cards[oe].components=c.components,e.mapping.cards[oe]=c.mapping,null==ee||ee(e)}else null==ee||ee(Object.assign({},c))}return o((()=>{N&&(null==V||V())}),[N]),o((()=>{!function(){var e,t,l,a,i;const n="mobile"===q?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);F===v.EMAIL&&(null==te||te(s))}()}),[X]),o((()=>{se()}),[]),o((()=>{se()}),[oe]),o((()=>{q&&R&&U&&setTimeout((()=>{re("custom_link"===(null==R?void 0:R.value)&&U?U.includes("https")?U:`https://${U}`:U,R.value)}),100)}),[q]),o((()=>{!Z&&R&&A.updatedValue&&setTimeout((()=>{re("custom_link"===(null==R?void 0:R.value)&&A.updatedValue?A.updatedValue.includes("https")?A.updatedValue:`https://${A.updatedValue}`:A.updatedValue,R.value),G(!0)}),100)}),[R]),e(y,Object.assign({channel:F,focused:N,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(g,Object.assign({style:{color:K&&!R?x.content.negative:x.content.primary}},{children:[null===(L=A.variableName)||void 0===L?void 0:L.replace("{{","").replace("}}","")," ","link"===(null==A?void 0:A.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:S?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[t(h,Object.assign({numberOfLines:1},{children:ne===b.CHATBOT?null==R?void 0:R.value:p(null!==(D=null==R?void 0:R.label)&&void 0!==D?D:"",20,!0)})),t(l,{onClick:()=>{Y(!z)},width:24,height:24,color:x.content.primary})]})):t(r,{options:W,isSearchable:!1,onSelect:ue,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&t(c,{labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${E}`,value:U,errorMessage:K?U&&0!==U.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${U.trim()}`)&&0!==U.trim().length?"custom_link"!==R.value&&U.length>30?"Length cannot be more than 30":"BUTTONS"===P&&"custom_link"!==R.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===P?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===A.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{de(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&t(d,{placement:"auto",time:a(U?new Date(U):new Date,"hh:mm a"),date:U?new Date(U):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{de("static_expiry",e.toISOString())}}),z&&t(u,{zIndex:2e3,data:null!=w?w:[],showVariable:z,setShowVariable:Y,placeholder:"Add a variable",customTrigger:e=>{null==C||C(!1),"{{custom.url}}"===e.actualValue?ue({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ue({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ue({label:e.displayName,selected:!0,value:"static_expiry"}):ue({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{y as Container,V as default};
|
|
7
|
+
`,_={value:"custom_link",label:"Custom URL"},T={value:"custom_text",label:"Custom text"},k={value:"static_expiry",label:"Static Expiry"},V=s=>{let{onFocus:V,variable:A,index:E,showVariableModal:S,variableList:w,setShowDiscountCheckBox:C,componentType:P,CTAoptions:B}=s;var L,D;const[N,H]=n(!1),[U,M]=n(""),[W,I]=n([]),[R,$]=n(),[z,Y]=n(!1),[Z,G]=n(!1),{device:q,channel:F,isError:K,originalVariableList:J,template:Q,templateSelectionTriggered:X,setTemplate:ee,setDisplayContent:te,setOriginalVariableList:le,globalNormalizedPlaceholders:ae,enabledCustomText:ie,pod:ne,selectedCarouselIndex:oe}=O();function se(){var e,t;const l=[];let a=[];if(F!==v.MESSAGE||ie){"link"===(null==A?void 0:A.type)?(l.push({label:"",options:[_,T]}),$(_)):"date_time"===(null==A?void 0:A.type)?(l.push({label:"",options:[_,T]}),$(k)):(l.push({label:"",options:[_,T,k]}),$(T));const e=null!=ae?ae:[];I([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:f.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ae?ae:[];I([{label:"",options:[T,_]},...e]),a=[{label:"",options:[T,_]},...e]}if((F===v.WHATSAPP||F===v.EMAIL||F===v.MESSAGE)&&A.updatedValue)if(m.test(A.updatedValue)&&F===v.WHATSAPP||A.updatedValue.startsWith("{{")&&F!==v.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===v.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(S){let t=e.updatedValue;if(ne===b.CHATBOT&&"BUTTONS"===P){const l=null==B?void 0:B.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(A,a,F);e.value&&$(e)}else"date_time"===A.type?($(k),M(A.updatedValue),re(null!==(e=A.index)&&void 0!==e?e:0,A.updatedValue)):(null===(t=A.updatedValue)||void 0===t?void 0:t.startsWith("https"))?($(_),M(A.updatedValue.split("https://")[1])):($(T),M(A.updatedValue))}function ue(e,t){var l,a,i;const n=e;M(""),$(n),F===v.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(ce(null!==(l=n.value)&&void 0!==l?l:"","string"),null==re||re(null!==(a=A.index)&&void 0!==a?a:0,n.value,!0)):(null==re||re(null!==(i=A.index)&&void 0!==i?i:0,U,!0,n.value),ce("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ce(n.value,"url"===n.bikPlaceholderType?"link":"string"):(M(""),ce("",n.value))}function de(e,t){var l;M(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;ce(a,"static_expiry"===e?"string":e),console.log("test compo: ",A,R,a,e),F===v.WHATSAPP&&(null==re||re(null!==(l=A.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function ce(e,t){var l,a,n,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(F!==v.WHATSAPP){const a=j(E+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===q?"template_html_mobile":"template_html_desktop"),n=F===v.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:A.variableName);const o=J.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==le||le(o)}if(F===v.WHATSAPP){const l=null!=oe&&oe>-1?J.cards[oe]:J;let u=l.body,d=l.header,c=l.buttons;if(console.log("variableList: ",l),"BODY"===P?u=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===P?d=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===P&&(c=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===E?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=oe&&oe>-1){const e=i(J.cards);e[oe]={header:d,body:u,buttons:c},null==le||le((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==le||le((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:c})))}}function re(e,t,l,a){var n,o,s,u,d,c;const r=null!=oe&&oe>-1?{components:null===(n=Object.assign({},Q).components[1].cards)||void 0===n?void 0:n[oe].components,mapping:null===(o=Object.assign({},Q).mapping.cards)||void 0===o?void 0:o[oe]}:Object.assign({},Q);console.log("test compo 666: ",r);const p=null===(s=null==r?void 0:r.components)||void 0===s?void 0:s.map((l=>{var a,i,n,o,s,u,d,c,r,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(c=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===P){if(null===(p=null===(r=l.buttons)||void 0===r?void 0:r[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(r.components=p,l)if("BODY"===P&&(null===(u=null==r?void 0:r.mapping)||void 0===u?void 0:u.body))r.mapping=Object.assign(Object.assign({},r.mapping),{body:r.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===P&&(null===(d=null==r?void 0:r.mapping)||void 0===d?void 0:d.header))r.mapping=Object.assign(Object.assign({},r.mapping),{header:r.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===P&&(null===(c=null==r?void 0:r.mapping)||void 0===c?void 0:c.buttons)){let l=-1,i=-1;p.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),r.mapping=Object.assign(Object.assign({},r.mapping),{buttons:r.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=oe&&oe>-1&&Q){const e=i(Q);e.components[1].cards[oe].components=r.components,e.mapping.cards[oe]=r.mapping,null==ee||ee(e)}else null==ee||ee(Object.assign({},r))}return o((()=>{N&&(null==V||V())}),[N]),o((()=>{!function(){var e,t,l,a,i;const n="mobile"===q?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);F===v.EMAIL&&(null==te||te(s))}()}),[X]),o((()=>{se()}),[]),o((()=>{se()}),[oe]),o((()=>{q&&R&&U&&setTimeout((()=>{ce("custom_link"===(null==R?void 0:R.value)&&U?U.includes("https")?U:`https://${U}`:U,R.value)}),100)}),[q]),o((()=>{!Z&&R&&A.updatedValue&&setTimeout((()=>{ce("custom_link"===(null==R?void 0:R.value)&&A.updatedValue?A.updatedValue.includes("https")?A.updatedValue:`https://${A.updatedValue}`:A.updatedValue,R.value),G(!0)}),100)}),[R]),e(y,Object.assign({channel:F,focused:N,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(g,Object.assign({style:{color:K&&!R?x.content.negative:x.content.primary}},{children:[null===(L=A.variableName)||void 0===L?void 0:L.replace("{{","").replace("}}","")," ","link"===(null==A?void 0:A.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:S?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[t(h,Object.assign({numberOfLines:1},{children:ne===b.CHATBOT?null==R?void 0:R.value:p(null!==(D=null==R?void 0:R.label)&&void 0!==D?D:"",20,!0)})),t(l,{onClick:()=>{Y(!z)},width:24,height:24,color:x.content.primary})]})):t(c,{options:W,isSearchable:!1,onSelect:ue,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&t(r,{labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${E}`,value:U,errorMessage:K?U&&0!==U.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${U.trim()}`)&&0!==U.trim().length?"custom_link"!==R.value&&U.length>30?"Length cannot be more than 30":"BUTTONS"===P&&"custom_link"!==R.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===P?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===A.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{de(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&t(d,{placement:"auto",time:a(U?new Date(U):new Date,"hh:mm a"),date:U?new Date(U):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{de("static_expiry",e.toISOString())}}),z&&t(u,{zIndex:2e3,data:null!=w?w:[],showVariable:z,setShowVariable:Y,placeholder:"Add a variable",customTrigger:e=>{null==C||C(!1),"{{custom.url}}"===e.actualValue?ue({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ue({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ue({label:e.displayName,selected:!0,value:"static_expiry"}):ue({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{y as Container,V as default};
|
package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as i,Fragment as a}from"react/jsx-runtime";import{Input as
|
|
1
|
+
import{jsx as e,jsxs as i,Fragment as a}from"react/jsx-runtime";import{Input as l}from"../../input/Input.js";import{BodySecondary as t}from"../../TypographyStyle.js";import{COLORS as r}from"../../../constants/Theme.js";import{useTemplateModalContext as o}from"../context/templateModalContext.js";import{useAdditionalVariables as d}from"../custom-hooks/useAdditionalVariables.js";import n from"./VariableConnector.js";const s=s=>{let{descriptionComponent:p,type:m,showVariableModal:b,variableList:c}=s;var v,y,u,x,h,f;const{originalVariableList:V,disableEditVariable:g,selectedCarouselIndex:E}=o(),j=d({variableList:c,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});return console.log("originalVariableList: ",V),"BODY"===p.type?e("div",{children:null===(v=null!=E&&E>-1?V.cards[E].body:null==V?void 0:V.body)||void 0===v?void 0:v.map(((a,o)=>g||!a.isEditableVariable?i("div",Object.assign({style:{margin:"16px 8px"}},{children:[i(t,Object.assign({style:{color:r.content.primary}},{children:["HEADER"===m?"Header":""," Locked variable ",o+1]})),e(l,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),o):e(n,{index:o,variable:a,showVariableModal:b,variableList:c,componentType:p.type},`${o}-${a.index}`)))}):"HEADER"===p.type?e("div",{children:null===(y=null!=E&&E>-1?V.cards[E].header:null==V?void 0:V.header)||void 0===y?void 0:y.map(((a,o)=>a.isEditableVariable?e(n,{index:o,variable:a,showVariableModal:b,variableList:c,componentType:p.type},`${o}-${a.index}`):i("div",Object.assign({style:{margin:"16px 8px"}},{children:[i(t,Object.assign({style:{color:r.content.primary}},{children:["HEADER"===m?"Header":""," Locked variable ",o+1]})),e(l,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),o)))}):"limited_time_offer"===p.type?e("div",{children:e(n,{index:0,variable:{variableName:null!==(x=null===(u=null==p?void 0:p.limited_time_offer)||void 0===u?void 0:u.text)&&void 0!==x?x:"Expires after",updatedValue:null!==(f=null===(h=p.example)||void 0===h?void 0:h.limited_time_offer)&&void 0!==f?f:(new Date).toISOString(),type:"date_time",isEditableVariable:!0,index:0},showVariableModal:b,variableList:j,componentType:p.type},`${p.type}`)}):e(a,{})};export{s as default};
|
package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAp
|
|
|
5
5
|
export type URLBtnUpdateFunctionType = (val: CTABtnValType, mode: 'custom' | 'placeholder', btnIndex?: number) => void;
|
|
6
6
|
export type QRBBtnUpdateFunctionType = (val: QRBBtnValType, mode: 'custom' | 'placeholder', btnIndex?: number) => void;
|
|
7
7
|
export interface WhatsAppTemplateCardButtonV2Props {
|
|
8
|
-
|
|
8
|
+
currentVariableList: WhatsAppTemplateVariables;
|
|
9
9
|
updateSelectedURLTemplateBtn?: URLBtnUpdateFunctionType;
|
|
10
10
|
updateSelectedQRBTemplateBtn?: QRBBtnUpdateFunctionType;
|
|
11
11
|
button: TEMPLATE_BUTTON;
|
|
@@ -14,5 +14,5 @@ export interface WhatsAppTemplateCardButtonV2Props {
|
|
|
14
14
|
variableList?: VariableListInterfaceV2[];
|
|
15
15
|
variableListIndex: number;
|
|
16
16
|
}
|
|
17
|
-
declare const WhatsAppTemplateCardButtonV2: ({ variableListIndex, button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn,
|
|
17
|
+
declare const WhatsAppTemplateCardButtonV2: ({ variableListIndex, button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, currentVariableList, CTAoptions, QRBoptions, variableList, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
export default WhatsAppTemplateCardButtonV2;
|
package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as a}from"react";import{Dropdown as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as a}from"react";import{Dropdown as s}from"../../dropdown/Dropdown.js";import{Input as o}from"../../input/Input.js";import{editableVarPattern as i}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as n}from"../../template-preview/models/TemplateMeta.js";import{POD as r}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as d}from"../../TypographyStyle.js";import{COLORS as p}from"../../../constants/Theme.js";import{useTemplateModalContext as c}from"../context/templateModalContext.js";import{useAdditionalVariables as u}from"../custom-hooks/useAdditionalVariables.js";import{validateIsUrl as b}from"../utils/validateIsUrl.js";import m,{Container as v}from"./VariableConnector.js";const f=f=>{let{variableListIndex:j,button:g,updateSelectedURLTemplateBtn:x,updateSelectedQRBTemplateBtn:O,currentVariableList:y,CTAoptions:h,QRBoptions:L,variableList:V}=f;var R,U,T,C;const[w,I]=l(""),[B,N]=l(),E=u({variableList:V,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom URL",variableValue:"{{custom.url}}"}),{isError:H,disableEditVariable:S,pod:A,selectedCarouselIndex:P,originalVariableList:k,setOriginalVariableList:M}=c();function Q(e){I(e);let t=y.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]});const l=y.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),a=Object.assign({},null!=P&&P>-1?k.cards[P]:k);if(a.buttons=l,null!=P&&P>-1){const e=[...k.cards];e[P]=a,null==M||M((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==M||M((e=>Object.assign(Object.assign({},e),{buttons:[...l]})));null==x||x(`https://${e}`,"custom",j)}return a((()=>{var e;if(g.buttonVariable&&i.test(g.buttonVariable))N(n),I((null===(e=g.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===g.type?h:L;e="URL"===g.type?t.findIndex((e=>e.placeHolder===g.buttonVariable)):t.findIndex((e=>e.label===g.flowName)),e>-1&&N(t[e])}}),[]),A!==r.CHATBOT?e(v,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(d,Object.assign({style:{color:p.content.primary}},{children:[g.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(s,{disabled:S,options:"URL"===g.type?h:L,isSearchable:!1,onSelect:function(e,t){const l=e;N(l);const a=("URL"===g.type?h:L).find((e=>e.placeHolder===l.placeHolder));if(a)if("custom_link"!==a.value){let e;if("URL"===g.type){let t=y.buttons.filter((e=>"URL"===e.type))[j];t=Object.assign(Object.assign({},t),{buttonVariable:l.placeHolder}),e=y.buttons.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==x||x({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder",j)}else{let t=y.buttons.filter((e=>"QUICK_REPLY"===e.type))[j];t=Object.assign(Object.assign({},t),{flowName:l.label,flowId:l.value}),e=y.buttons.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),null==O||O({flowName:l.label,flowId:l.value},"placeholder",j)}console.log("templateCopy updatedVariables: ",e);const t=Object.assign({},null!=P&&P>-1?k.cards[P]:k);if(t.buttons=e,null!=P&&P>-1){const e=[...k.cards];e[P]=t,null==M||M((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==M||M((t=>Object.assign(Object.assign({},t),{buttons:[...e]})))}else Q("")},defaultOptions:B?[Object.assign(Object.assign({},B),{selected:!0})]:[]})})),"custom_link"===(null==B?void 0:B.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(o,{state:S?"disabled":"none",errorMessage:H?w?b(w)?"":"Enter valid URL":"Required field":"",value:w,prefixText:"https://",placeholder:"Enter custom URL here",onChangeText:Q,maxCharLimit:2e3})}))]}):t(m,{index:j,variable:{variableName:null!==(R=g.text)&&void 0!==R?R:"",updatedValue:"((customPlaceholderName))"===g.buttonVariable?`${null===(U=g.example)||void 0===U?void 0:U[0]}`:null!==(T=g.buttonVariable)&&void 0!==T?T:"",type:"link",isEditableVariable:!0,index:null!==(C=g.index)&&void 0!==C?C:0},showVariableModal:!0,componentType:"BUTTONS",variableList:E,CTAoptions:h})};export{f as default};
|