@bikdotai/bik-component-library 0.0.400 → 0.0.401-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.d.ts +2 -1
- package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
- package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +3 -1
- package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.d.ts +2 -1
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
- package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +3 -1
- package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),n=require("../context/templateModalContext.js"),i=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),l=require("./DiscountCodeComponent.js"),s=require("./EditMediaV2.style.js"),d=require("./EditWhatsAppTemplateMediaV2.js"),r=require("./VariableConnectorsPanel.js"),u=require("./VariableConnectorWhatsApp.js"),c=require("./VariableEditorHeader.js"),p=require("./WhatsAppTemplateCardButtonV2.js");exports.default=v=>{let{template:m,onTemplateChange:b,whatsappSpecificPickerMeta:g,showVariableModal:h,variableList:f,variableListForImage:j,discountCode:T,setDiscountCode:x}=v;var C,O,E,k,y,B,V,w,q,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),n=require("../context/templateModalContext.js"),i=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),l=require("./DiscountCodeComponent.js"),s=require("./EditMediaV2.style.js"),d=require("./EditWhatsAppTemplateMediaV2.js"),r=require("./VariableConnectorsPanel.js"),u=require("./VariableConnectorWhatsApp.js"),c=require("./VariableEditorHeader.js"),p=require("./WhatsAppTemplateCardButtonV2.js");exports.default=v=>{let{template:m,onTemplateChange:b,whatsappSpecificPickerMeta:g,showVariableModal:h,variableList:f,variableListForImage:j,discountCode:T,setDiscountCode:x}=v;var C,O,E,k,y,B,V,w,L,q,I,M,A,D,R,U;const{originalVariableList:P,pod:H,extras:S}=n.useTemplateModalContext(),{descriptionComponents:N,urlBtns:Q,qrbBtns:_,imageComponent:F,bodyVariables:W,headerVariables:K}=i.getAllDataFromTemplateComponent(m),[Y,$]=t.useState(!1);function X(e,t){var o,n,i,a,l;const s=Object.assign({},m),d=null==s?void 0:s.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const l=null===(o=null==s?void 0:s.components[d].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==l&&l>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(i=null===(n=s.components)||void 0===n?void 0:n[d])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const u=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});s.mapping=c;const p=[...s.components];p[d]=u,s.components=p}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(l=e.placeHolder)||void 0===l?void 0:l.slice(2,-2))?$(!0):($(!1),null==x||x(""))}null==b||b(s)}function z(e,t,o){var n;const i=Object.assign({},m),a=null==i?void 0:i.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(n=null==i?void 0:i.components[a].buttons)||void 0===n?void 0:n.filter((e=>"QUICK_REPLY"===e.type));t&&(t[o]=Object.assign(Object.assign({},t[o]),{flowId:e.flowId,flowName:e.flowName}));const l=Object.assign(Object.assign({},i.components[a]),{buttons:t}),s=[...i.components];s[a]=l,i.components=s}null==b||b(i)}return t.useEffect((()=>{var e;const t=null===(e=m.mapping.buttons)||void 0===e?void 0:e[0];"checkout.checkoutUrl"===(null==t?void 0:t.slice(2,-2))?$(!0):($(!1),null==x||x(""))}),[m]),e.jsxs(r.Container,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!F&&e.jsx(s.EditTemplateMediaContainer,{children:e.jsx(d.default,{whatsappSpecificPickerMeta:g,mediaComponent:F,updateTemplateImageUrl:function(e,t){var o;let n=Object.assign({},m);const i=null===(o=null==n?void 0:n.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const o=Object.assign(Object.assign({},n.components[i]),{format:t,example:{header_handle:[e]}}),a=[...n.components];a[i]=o,n=Object.assign(Object.assign({},n),{components:a})}n.mapping&&(n.mapping=Object.assign(Object.assign({},n.mapping),{header:void 0})),null==b||b(Object.assign({},n))},template:m,variableListForImage:j})}),(W.length>0||K.length>0)&&e.jsx(c.default,{containerStyle:{paddingTop:F?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==N?void 0:N.map(((t,o)=>e.jsx(u.default,{originalVariableList:P,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?m.mapping.header:m.mapping.body,showVariableModal:h,variableList:f},o))),(null===(O=null===(C=Q[0])||void 0===C?void 0:C.component)||void 0===O?void 0:O.buttons)&&(null===(y=null===(k=null===(E=Q[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)||void 0===y?void 0:y.length)>0&&e.jsx(c.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(B=null==P?void 0:P.buttons)||void 0===B?void 0:B.map(((t,o)=>{if("URL"===t.type)return e.jsx(p.default,{CTAoptions:null==g?void 0:g.CTAoptions,button:t,originalVariableList:P,updateSelectedURLTemplateBtn:X,variableList:f},`${o}`)})),(null===(w=null===(V=_[0])||void 0===V?void 0:V.component)||void 0===w?void 0:w.buttons)&&(null===(I=null===(q=null===(L=_[0])||void 0===L?void 0:L.component)||void 0===q?void 0:q.buttons)||void 0===I?void 0:I.length)>0&&(H!==o.POD.CHATBOT?e.jsx(c.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===(M=null==S?void 0:S.backTrackExtra)||void 0===M?void 0:M[0],setBackTrackMessage:null===(A=null==S?void 0:S.backTrackExtra)||void 0===A?void 0:A[1]})),null===(D=null==P?void 0:P.buttons)||void 0===D?void 0:D.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(p.default,{QRBoptions:null==g?void 0:g.QRBoptions,button:t,originalVariableList:P,updateSelectedQRBTemplateBtn:z},`${o}`)})),H===o.POD.CHATBOT&&Y&&e.jsx(l.DiscountCodeComponent,{discountCode:null===(R=null==S?void 0:S.discountCodeExtra)||void 0===R?void 0:R[0],setDiscountCode:null===(U=null==S?void 0:S.discountCodeExtra)||void 0===U?void 0:U[1],variableList:f})]}))};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
|
|
3
3
|
import { CHANNEL_TYPE } from "../../template-preview/models/Channels";
|
|
4
|
-
import { CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
|
|
4
|
+
import { ButtonPlaceHolderOptions, CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
|
|
5
5
|
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
6
6
|
focused?: boolean | undefined;
|
|
7
7
|
channel?: CHANNEL_TYPE | undefined;
|
|
@@ -15,6 +15,7 @@ export interface VariableConnectorProps {
|
|
|
15
15
|
variableList?: VariableListInterfaceV2[];
|
|
16
16
|
setShowDiscountCheckBox?: any;
|
|
17
17
|
componentType?: 'HEADER' | 'BODY' | 'BUTTONS' | 'FOOTER';
|
|
18
|
+
CTAoptions?: ButtonPlaceHolderOptions[];
|
|
18
19
|
}
|
|
19
20
|
declare const VariableConnector: React.FC<VariableConnectorProps>;
|
|
20
21
|
export default VariableConnector;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),l=require("../../../assets/icons/edit.svg.js"),t=require("react"),a=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),i=require("../../dropdown/Dropdown.js"),o=require("../../input/Input.js"),s=require("../../product-picker-v2/collectionScreen.js"),u=require("../../template-preview/constants/regexPatterns.js"),d=require("../../template-preview/models/Channels.js"),r=require("../../template-preview/models/WhatsAppTemplate.js"),c=require("../../TypographyStyle.js"),p=require("../../../utils/StringUtils.js"),v=require("../../../constants/Theme.js"),m=require("../context/templateModalContext.js"),b=require("../utils/getVariableNameEmail.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const j=g(a).default.div`
|
|
2
2
|
/* surface/$color-background-warning-light */
|
|
3
3
|
|
|
4
|
-
background: ${e=>e.focused&&e.channel===d.CHANNEL_TYPE.EMAIL?
|
|
4
|
+
background: ${e=>e.focused&&e.channel===d.CHANNEL_TYPE.EMAIL?v.COLORS.background.warning.light:"transparent"};
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
padding: 8px 10px;
|
|
7
|
-
`,h={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"};exports.Container=
|
|
7
|
+
`,h={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"};exports.Container=j,exports.default=a=>{let{onFocus:g,variable:E,index:_,showVariableModal:y,variableList:O,setShowDiscountCheckBox:T,componentType:A,CTAoptions:f}=a;var V,N;const[C,P]=t.useState(!1),[k,L]=t.useState(""),[S,H]=t.useState([]),[w,Y]=t.useState(),[B,q]=t.useState(!1),[M,R]=t.useState(!1),{device:W,channel:D,isError:I,originalVariableList:$,template:U,templateSelectionTriggered:z,setTemplate:Z,setDisplayContent:F,setOriginalVariableList:G,globalNormalizedPlaceholders:J,enabledCustomText:K,pod:Q}=m.useTemplateModalContext();function X(e,l){var t,a,n;const i=e;L(""),Y(i),D===d.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(ee(null!==(t=i.value)&&void 0!==t?t:"","string"),null==le||le(null!==(a=E.index)&&void 0!==a?a:0,i.value,!0)):(null==le||le(null!==(n=E.index)&&void 0!==n?n:0,E.variableName,!0,"custom_text"),ee("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?ee(i.value,"url"===i.bikPlaceholderType?"link":"string"):(L(""),ee("",i.value))}function ee(e,l){var t,a,n,i;console.log("vj: updatevarlist",{updateValue:e,type:l});const o="custom_link"===l?"link":"custom_text"===l?"string":l;if(D!==d.CHANNEL_TYPE.WHATSAPP){const a=b.getVariableNameForEmailByIndex(_+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===W?"template_html_mobile":"template_html_desktop"),i=D===d.CHANNEL_TYPE.EMAIL?null===(t=null==n?void 0:n.contentWindow)||void 0===t?void 0:t.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==l&&"custom_link"!==l||e?e:E.variableName);const s=$.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==G||G(s)}if(D===d.CHANNEL_TYPE.WHATSAPP){const l=$;let t=l.body,s=l.header,u=l.buttons;"BODY"===A?t=null===(a=l.body)||void 0===a?void 0:a.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l)):"HEADER"===A?s=null===(n=l.header)||void 0===n?void 0:n.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l)):"BUTTONS"===A&&(u=null===(i=l.buttons)||void 0===i?void 0:i.map(((l,t)=>(console.log("vj: check",{normalizedType:o,ind:t,index:_,currVar:l}),t===_?Object.assign(Object.assign({},l),{type:r.BUTTON_TYPE.URL,buttonVariable:e}):l)))),console.log("vj: buttonvariablelist",u),null==G||G((e=>Object.assign(Object.assign({},e),{header:s,body:t,buttons:u})))}}function le(e,l,t,a){var n,i,o;const s=Object.assign({},U);console.log("vj: update component",{index:e,newValue:l});const u=null===(n=null==s?void 0:s.components)||void 0===n?void 0:n.map((t=>{var a,n,i,o,s,u,d,r;const c=Object.assign({},t);if("BODY"===t.type&&"BODY"===A){if(null===(n=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const t=[...null!==(s=null===(o=null===(i=c.example)||void 0===i?void 0:i.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{body_text:[t]});return Object.assign(Object.assign({},c),{example:a})}}else if("HEADER"===t.type&&"HEADER"===A&&(null===(u=t.example)||void 0===u?void 0:u.header_text)){const t=[...null!==(r=null===(d=c.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{header_text:t});return Object.assign(Object.assign({},c),{example:a})}return t}));s.components=u,t&&("BODY"===A&&(null===(i=null==s?void 0:s.mapping)||void 0===i?void 0:i.body)?s.mapping=Object.assign(Object.assign({},s.mapping),{body:s.mapping.body.map(((t,n)=>e===n?"custom_text"===a?`((editableVariable${n+10}))`:l:t))}):"HEADER"===A&&(null===(o=null==s?void 0:s.mapping)||void 0===o?void 0:o.header)&&(s.mapping=Object.assign(Object.assign({},s.mapping),{header:s.mapping.header.map(((t,n)=>e===n?"custom_text"===a?`((editableVariable${n+20}))`:l:t))}))),null==Z||Z(Object.assign({},s))}return console.log("vj: variableconnector",{variable:E,originalVariableList:$}),t.useEffect((()=>{C&&(null==g||g())}),[C]),t.useEffect((()=>{!function(){var e,l,t,a,n;const i="mobile"===W?"template_html_mobile":"template_html_desktop",o=document.getElementById(i),s=(null!==(a=null===(t=null===(l=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===l?void 0:l.body)||void 0===t?void 0:t.innerHTML)&&void 0!==a?a:"")+(null===(n=null==o?void 0:o.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);D===d.CHANNEL_TYPE.EMAIL&&(null==F||F(s))}()}),[z]),t.useEffect((()=>{var e;const l=[];let t=[];if(D!==d.CHANNEL_TYPE.MESSAGE||K){"link"===(null==E?void 0:E.type)?(l.push({label:"",options:[h,x]}),console.log("vj: variable type is link"),Y(h)):(l.push({label:"",options:[h,x]}),Y(x));const e=null!=J?J:[];H([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:p.default.toCapitilize(null===(t=null===(l=e.label)||void 0===l?void 0:l.replace(/([A-Z])/g," $1"))||void 0===t?void 0:t.toLowerCase())})}))]),t=[...l,...e],console.log("vj: alloptions",t)}else{const e=null!=J?J:[];H([{label:"",options:[x,h]},...e]),t=[{label:"",options:[x,h]},...e]}if((D===d.CHANNEL_TYPE.WHATSAPP||D===d.CHANNEL_TYPE.EMAIL||D===d.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(u.placeHolderNamePattern.test(E.updatedValue)&&D===d.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&D!==d.CHANNEL_TYPE.WHATSAPP){const e=function(e,l,t){var a;let n={label:"",value:""};const i=t===d.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");y?n={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(E,t,D);console.log("vj: preselected option",e),e.value&&Y(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(Y(h),L(E.updatedValue.split("https://")[1])):(Y(x),L(E.updatedValue))}),[]),t.useEffect((()=>{W&&w&&k&&setTimeout((()=>{ee("custom_link"===(null==w?void 0:w.value)&&k?k.includes("https")?k:`https://${k}`:k,w.value)}),100)}),[W]),t.useEffect((()=>{console.log("vj:",{renderFirstTime:M,selectedOption:w,variable:E,enteredVariableValue:k}),!M&&w&&E.updatedValue&&setTimeout((()=>{const e="custom_link"===(null==w?void 0:w.value)&&k?k.includes("https")?E.updatedValue:`https://${E.updatedValue}`:E.updatedValue;console.log("vj: inputvalue",e),ee(e,w.value),R(!0)}),100)}),[w]),e.jsxs(j,Object.assign({channel:D,focused:C,onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(c.BodySecondary,Object.assign({style:{color:I&&!w?v.COLORS.content.negative:v.COLORS.content.primary}},{children:[null===(V=E.variableName)||void 0===V?void 0:V.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:y?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==w?void 0:w.label)?"space-between":"flex-end"}},{children:[e.jsx(c.BodyPrimary,{children:s.truncate(null!==(N=null==w?void 0:w.label)&&void 0!==N?N:"",20,!0)}),e.jsx(l.default,{onClick:()=>{q(!B)},width:24,height:24,color:v.COLORS.content.primary})]})):e.jsx(i.Dropdown,{options:S,isSearchable:!1,onSelect:X,defaultOptions:w?[Object.assign(Object.assign({},w),{selected:!0})]:[]})})),("custom_text"===(null==w?void 0:w.value)||"custom_link"===(null==w?void 0:w.value))&&e.jsx(o.Input,{labelText:"custom_text"===(null==w?void 0:w.value)?"Custom text value":"custom_link"===(null==w?void 0:w.value)?"Custom URL value":"",id:`variable-value-${null==w?void 0:w.value}-${_}`,value:k,errorMessage:I?k&&0!==k.trim().length?"custom_link"!==w.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${k.trim()}`)&&0!==k.trim().length?"custom_link"!==w.value&&k.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==w?void 0:w.value)?void 0:30,prefixText:"custom_link"===(null==w?void 0:w.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===w.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;L(l);const a="custom_link"===(null==w?void 0:w.value)&&l?l.includes("https")?l:`https://${l}`:l;ee(a,e),D===d.CHANNEL_TYPE.WHATSAPP&&(null==le||le(null!==(t=E.index)&&void 0!==t?t:0,a))}(w.value,e)}}),B&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=O?O:[],showVariable:B,setShowVariable:q,placeholder:"Add a variable",customTrigger:e=>{if(console.log("vj: customtrigger",e),null==T||T(!1),"{{custom.url}}"===e.actualValue)X({label:e.displayName,selected:!0,value:"custom_link"});else if("{{custom.text}}"==e.actualValue)X({label:e.displayName,selected:!0,value:"custom_text"});else if(Q===r.POD.CHATBOT&&"BUTTONS"===A){const l=null==f?void 0:f.filter((l=>l.placeHolder===e.actualValue));console.log("vj: CTAoptions",{CTAoptions:f,isVariableInCtaOptions:l}),l&&l.length>0?X({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"}):X({label:e.displayName,selected:!0,value:"custom_link"})}else X({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
|
package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
|
|
1
2
|
import { ButtonPlaceHolderOptions } from "../../template-preview/models/TemplateMeta";
|
|
2
3
|
import { CTABtnValType, QRBBtnValType, TEMPLATE_BUTTON } from "../../template-preview/models/WhatsAppTemplate";
|
|
3
4
|
import { WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAppTemplate";
|
|
@@ -10,6 +11,7 @@ export interface WhatsAppTemplateCardButtonV2Props {
|
|
|
10
11
|
button: TEMPLATE_BUTTON;
|
|
11
12
|
CTAoptions?: ButtonPlaceHolderOptions[];
|
|
12
13
|
QRBoptions?: ButtonPlaceHolderOptions[];
|
|
14
|
+
variableList?: VariableListInterfaceV2[];
|
|
13
15
|
}
|
|
14
|
-
declare const WhatsAppTemplateCardButtonV2: ({ button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const WhatsAppTemplateCardButtonV2: ({ button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, variableList, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
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"),a=require("../../dropdown/Dropdown.js"),l=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"),d=require("../context/templateModalContext.js"),u=require("../utils/validateIsUrl.js"),p=require("./VariableConnector.js");exports.default=b=>{let{button:c,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:m,originalVariableList:v,CTAoptions:x,QRBoptions:O,variableList:g}=b;var y,f;const[h,T]=t.useState(""),[L,U]=t.useState(),{setOriginalVariableList:R,isError:V,disableEditVariable:q,pod:w}=d.useTemplateModalContext();function B(e){T(e);const t=[Object.assign(Object.assign({},v.buttons[0]),{type:n.BUTTON_TYPE.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==R||R((e=>Object.assign(Object.assign({},e),{body:[...v.body],buttons:[...t]}))),null==j||j(`https://${e}`,"custom")}return t.useEffect((()=>{var e;if(c.buttonVariable&&s.editableVarPattern.test(c.buttonVariable))U(i.CUSTOM_URL_NAME),T((null===(e=c.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===c.type?x:O;e="URL"===c.type?t.findIndex((e=>e.placeHolder===c.buttonVariable)):t.findIndex((e=>e.label===c.flowName)),e>-1&&U(t[e])}}),[]),e.jsxs(p.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(o.BodySecondary,Object.assign({style:{color:r.COLORS.content.primary}},{children:[c.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:w!==n.POD.CHATBOT?e.jsx(a.Dropdown,{disabled:q,options:"URL"===c.type?x:O,isSearchable:!1,onSelect:function(e,t){const a=e;U(a);const l=("URL"===c.type?x:O).find((e=>e.placeHolder===a.placeHolder));if(l)if("custom_link"!==l.value){let e;"URL"===c.type?(e=[Object.assign(Object.assign({},v.buttons[0]),{type:"URL",buttonVariable:a.placeHolder,example:["https://bik.ai/"]})],null==j||j({defaultValue:l.value,placeHolder:l.placeHolder},"placeholder")):(e=v.buttons.map(((e,t)=>t===c.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:a.label,flowId:a.value}):e)),null==m||m({flowName:a.label,flowId:a.value},"placeholder",c.index)),null==R||R((t=>Object.assign(Object.assign({},t),{body:[...v.body],buttons:[...e]})))}else B("")},defaultOptions:L?[Object.assign(Object.assign({},L),{selected:!0})]:[]}):e.jsx(p.default,{index:c.index||0,variable:{variableName:null!==(y=c.buttonVariable)&&void 0!==y?y:"",updatedValue:null!==(f=c.buttonVariable)&&void 0!==f?f:"",type:"link",isEditableVariable:!0},showVariableModal:!0,componentType:"BUTTONS",variableList:g,CTAoptions:x})})),"custom_link"===(null==L?void 0:L.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(l.Input,{state:q?"disabled":"none",errorMessage:V?h?u.validateIsUrl(h)?"":"Enter valid URL":"Required field":"",value:h,prefixText:"custom_link"===(null==L?void 0:L.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:B})}))]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as e,useEffect as n}from"react";import{POD as i}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as a}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as s}from"./BackTrackComponent.js";import{DiscountCodeComponent as d}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as r}from"./EditMediaV2.style.js";import p from"./EditWhatsAppTemplateMediaV2.js";import{Container as c}from"./VariableConnectorsPanel.js";import u from"./VariableConnectorWhatsApp.js";import m from"./VariableEditorHeader.js";import v from"./WhatsAppTemplateCardButtonV2.js";const b=b=>{let{template:g,onTemplateChange:h,whatsappSpecificPickerMeta:f,showVariableModal:T,variableList:j,variableListForImage:C,discountCode:O,setDiscountCode:x}=b;var E,k,y,V,w,B,L,I,A,M,R,U,H,D,S,N;const{originalVariableList:P,pod:Q,extras:W}=l(),{descriptionComponents:F,urlBtns:_,qrbBtns:K,imageComponent:Y,bodyVariables:$,headerVariables:q}=a(g),[X,z]=e(!1);function G(t,o){var e,n,i,l,a;const s=Object.assign({},g),d=null==s?void 0:s.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==d&&d>-1){const a=null===(e=null==s?void 0:s.components[d].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==a&&a>-1){const e="custom"===o&&"string"==typeof t,r=[...null!==(l=null===(i=null===(n=s.components)||void 0===n?void 0:n[d])||void 0===i?void 0:i.buttons)&&void 0!==l?l:[]];r[a]=Object.assign(Object.assign({},r[a]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const p=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});s.mapping=c;const u=[...s.components];u[d]=p,s.components=u}}if("string"!=typeof t){"checkout.checkoutUrl"===(null===(a=t.placeHolder)||void 0===a?void 0:a.slice(2,-2))?z(!0):(z(!1),null==x||x(""))}null==h||h(s)}function J(t,o,e){var n;const i=Object.assign({},g),l=null==i?void 0:i.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==l&&l>-1){const o=null===(n=null==i?void 0:i.components[l].buttons)||void 0===n?void 0:n.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const a=Object.assign(Object.assign({},i.components[l]),{buttons:o}),s=[...i.components];s[l]=a,i.components=s}null==h||h(i)}return n((()=>{var t;const o=null===(t=g.mapping.buttons)||void 0===t?void 0:t[0];"checkout.checkoutUrl"===(null==o?void 0:o.slice(2,-2))?z(!0):(z(!1),null==x||x(""))}),[g]),t(c,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!Y&&o(r,{children:o(p,{whatsappSpecificPickerMeta:f,mediaComponent:Y,updateTemplateImageUrl:function(t,o){var e;let n=Object.assign({},g);const i=null===(e=null==n?void 0:n.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const e=Object.assign(Object.assign({},n.components[i]),{format:o,example:{header_handle:[t]}}),l=[...n.components];l[i]=e,n=Object.assign(Object.assign({},n),{components:l})}n.mapping&&(n.mapping=Object.assign(Object.assign({},n.mapping),{header:void 0})),null==h||h(Object.assign({},n))},template:g,variableListForImage:C})}),($.length>0||q.length>0)&&o(m,{containerStyle:{paddingTop:Y?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==F?void 0:F.map(((t,e)=>o(u,{originalVariableList:P,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?g.mapping.header:g.mapping.body,showVariableModal:T,variableList:j},e))),(null===(k=null===(E=_[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)&&(null===(w=null===(V=null===(y=_[0])||void 0===y?void 0:y.component)||void 0===V?void 0:V.buttons)||void 0===w?void 0:w.length)>0&&o(m,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(B=null==P?void 0:P.buttons)||void 0===B?void 0:B.map(((t,e)=>{if("URL"===t.type)return o(v,{CTAoptions:null==f?void 0:f.CTAoptions,button:t,originalVariableList:P,updateSelectedURLTemplateBtn:G},`${e}`)})),(null===(I=null===(L=K[0])||void 0===L?void 0:L.component)||void 0===I?void 0:I.buttons)&&(null===(R=null===(M=null===(A=K[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===R?void 0:R.length)>0&&(Q!==i.CHATBOT?o(m,{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"}):o(s,{backTrackMessage:null===(U=null==W?void 0:W.backTrackExtra)||void 0===U?void 0:U[0],setBackTrackMessage:null===(H=null==W?void 0:W.backTrackExtra)||void 0===H?void 0:H[1]})),null===(D=null==P?void 0:P.buttons)||void 0===D?void 0:D.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(v,{QRBoptions:null==f?void 0:f.QRBoptions,button:t,originalVariableList:P,updateSelectedQRBTemplateBtn:J},`${e}`)})),Q===i.CHATBOT&&X&&o(d,{discountCode:null===(S=null==W?void 0:W.discountCodeExtra)||void 0===S?void 0:S[0],setDiscountCode:null===(N=null==W?void 0:W.discountCodeExtra)||void 0===N?void 0:N[1],variableList:j})]}))};export{b as default};
|
|
1
|
+
import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as e,useEffect as n}from"react";import{POD as i}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as a}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as s}from"./BackTrackComponent.js";import{DiscountCodeComponent as d}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as r}from"./EditMediaV2.style.js";import p from"./EditWhatsAppTemplateMediaV2.js";import{Container as c}from"./VariableConnectorsPanel.js";import u from"./VariableConnectorWhatsApp.js";import m from"./VariableEditorHeader.js";import v from"./WhatsAppTemplateCardButtonV2.js";const b=b=>{let{template:g,onTemplateChange:h,whatsappSpecificPickerMeta:f,showVariableModal:T,variableList:j,variableListForImage:C,discountCode:O,setDiscountCode:x}=b;var E,k,y,V,w,B,L,I,A,M,R,U,H,D,S,N;const{originalVariableList:P,pod:Q,extras:W}=l(),{descriptionComponents:F,urlBtns:_,qrbBtns:K,imageComponent:Y,bodyVariables:$,headerVariables:q}=a(g),[X,z]=e(!1);function G(t,o){var e,n,i,l,a;const s=Object.assign({},g),d=null==s?void 0:s.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==d&&d>-1){const a=null===(e=null==s?void 0:s.components[d].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==a&&a>-1){const e="custom"===o&&"string"==typeof t,r=[...null!==(l=null===(i=null===(n=s.components)||void 0===n?void 0:n[d])||void 0===i?void 0:i.buttons)&&void 0!==l?l:[]];r[a]=Object.assign(Object.assign({},r[a]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const p=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});s.mapping=c;const u=[...s.components];u[d]=p,s.components=u}}if("string"!=typeof t){"checkout.checkoutUrl"===(null===(a=t.placeHolder)||void 0===a?void 0:a.slice(2,-2))?z(!0):(z(!1),null==x||x(""))}null==h||h(s)}function J(t,o,e){var n;const i=Object.assign({},g),l=null==i?void 0:i.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==l&&l>-1){const o=null===(n=null==i?void 0:i.components[l].buttons)||void 0===n?void 0:n.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const a=Object.assign(Object.assign({},i.components[l]),{buttons:o}),s=[...i.components];s[l]=a,i.components=s}null==h||h(i)}return n((()=>{var t;const o=null===(t=g.mapping.buttons)||void 0===t?void 0:t[0];"checkout.checkoutUrl"===(null==o?void 0:o.slice(2,-2))?z(!0):(z(!1),null==x||x(""))}),[g]),t(c,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!Y&&o(r,{children:o(p,{whatsappSpecificPickerMeta:f,mediaComponent:Y,updateTemplateImageUrl:function(t,o){var e;let n=Object.assign({},g);const i=null===(e=null==n?void 0:n.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const e=Object.assign(Object.assign({},n.components[i]),{format:o,example:{header_handle:[t]}}),l=[...n.components];l[i]=e,n=Object.assign(Object.assign({},n),{components:l})}n.mapping&&(n.mapping=Object.assign(Object.assign({},n.mapping),{header:void 0})),null==h||h(Object.assign({},n))},template:g,variableListForImage:C})}),($.length>0||q.length>0)&&o(m,{containerStyle:{paddingTop:Y?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==F?void 0:F.map(((t,e)=>o(u,{originalVariableList:P,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?g.mapping.header:g.mapping.body,showVariableModal:T,variableList:j},e))),(null===(k=null===(E=_[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)&&(null===(w=null===(V=null===(y=_[0])||void 0===y?void 0:y.component)||void 0===V?void 0:V.buttons)||void 0===w?void 0:w.length)>0&&o(m,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(B=null==P?void 0:P.buttons)||void 0===B?void 0:B.map(((t,e)=>{if("URL"===t.type)return o(v,{CTAoptions:null==f?void 0:f.CTAoptions,button:t,originalVariableList:P,updateSelectedURLTemplateBtn:G,variableList:j},`${e}`)})),(null===(I=null===(L=K[0])||void 0===L?void 0:L.component)||void 0===I?void 0:I.buttons)&&(null===(R=null===(M=null===(A=K[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===R?void 0:R.length)>0&&(Q!==i.CHATBOT?o(m,{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"}):o(s,{backTrackMessage:null===(U=null==W?void 0:W.backTrackExtra)||void 0===U?void 0:U[0],setBackTrackMessage:null===(H=null==W?void 0:W.backTrackExtra)||void 0===H?void 0:H[1]})),null===(D=null==P?void 0:P.buttons)||void 0===D?void 0:D.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(v,{QRBoptions:null==f?void 0:f.QRBoptions,button:t,originalVariableList:P,updateSelectedQRBTemplateBtn:J},`${e}`)})),Q===i.CHATBOT&&X&&o(d,{discountCode:null===(S=null==W?void 0:W.discountCodeExtra)||void 0===S?void 0:S[0],setDiscountCode:null===(N=null==W?void 0:W.discountCodeExtra)||void 0===N?void 0:N[1],variableList:j})]}))};export{b as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
|
|
3
3
|
import { CHANNEL_TYPE } from "../../template-preview/models/Channels";
|
|
4
|
-
import { CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
|
|
4
|
+
import { ButtonPlaceHolderOptions, CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
|
|
5
5
|
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
6
6
|
focused?: boolean | undefined;
|
|
7
7
|
channel?: CHANNEL_TYPE | undefined;
|
|
@@ -15,6 +15,7 @@ export interface VariableConnectorProps {
|
|
|
15
15
|
variableList?: VariableListInterfaceV2[];
|
|
16
16
|
setShowDiscountCheckBox?: any;
|
|
17
17
|
componentType?: 'HEADER' | 'BODY' | 'BUTTONS' | 'FOOTER';
|
|
18
|
+
CTAoptions?: ButtonPlaceHolderOptions[];
|
|
18
19
|
}
|
|
19
20
|
declare const VariableConnector: React.FC<VariableConnectorProps>;
|
|
20
21
|
export default VariableConnector;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsxs as e,jsx as l}from"react/jsx-runtime";import t from"../../../assets/icons/edit.svg.js";import{useState as a,useEffect as
|
|
1
|
+
import{jsxs as e,jsx as l}from"react/jsx-runtime";import t from"../../../assets/icons/edit.svg.js";import{useState as a,useEffect as o}from"react";import i from"styled-components";import{AddVariableV2SideModal as n}from"../../add-variableV2/AddVariableV2SideModal.js";import{Dropdown as s}from"../../dropdown/Dropdown.js";import{Input as u}from"../../input/Input.js";import{truncate as d}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as r}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as c}from"../../template-preview/models/Channels.js";import{POD as p,BUTTON_TYPE as m}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as v,BodyPrimary as b}from"../../TypographyStyle.js";import g from"../../../utils/StringUtils.js";import{COLORS as h}from"../../../constants/Theme.js";import{useTemplateModalContext as j}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as x}from"../utils/getVariableNameEmail.js";const y=i.div`
|
|
2
2
|
/* surface/$color-background-warning-light */
|
|
3
3
|
|
|
4
|
-
background: ${e=>e.focused&&e.channel===c.EMAIL?
|
|
4
|
+
background: ${e=>e.focused&&e.channel===c.EMAIL?h.background.warning.light:"transparent"};
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
padding: 8px 10px;
|
|
7
|
-
`,
|
|
7
|
+
`,O={value:"custom_link",label:"Custom URL"},f={value:"custom_text",label:"Custom text"},_=i=>{let{onFocus:_,variable:V,index:k,showVariableModal:T,variableList:A,setShowDiscountCheckBox:E,componentType:S,CTAoptions:P}=i;var w,C;const[L,H]=a(!1),[B,M]=a(""),[W,N]=a([]),[$,D]=a(),[I,R]=a(!1),[U,z]=a(!1),{device:Y,channel:Z,isError:F,originalVariableList:G,template:q,templateSelectionTriggered:J,setTemplate:K,setDisplayContent:Q,setOriginalVariableList:X,globalNormalizedPlaceholders:ee,enabledCustomText:le,pod:te}=j();function ae(e,l){var t,a,o;const i=e;M(""),D(i),Z===c.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(oe(null!==(t=i.value)&&void 0!==t?t:"","string"),null==ie||ie(null!==(a=V.index)&&void 0!==a?a:0,i.value,!0)):(null==ie||ie(null!==(o=V.index)&&void 0!==o?o:0,V.variableName,!0,"custom_text"),oe("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?oe(i.value,"url"===i.bikPlaceholderType?"link":"string"):(M(""),oe("",i.value))}function oe(e,l){var t,a,o,i;console.log("vj: updatevarlist",{updateValue:e,type:l});const n="custom_link"===l?"link":"custom_text"===l?"string":l;if(Z!==c.WHATSAPP){const a=x(k+1),o=null===document||void 0===document?void 0:document.getElementById("mobile"===Y?"template_html_mobile":"template_html_desktop"),i=Z===c.EMAIL?null===(t=null==o?void 0:o.contentWindow)||void 0===t?void 0:t.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==l&&"custom_link"!==l||e?e:V.variableName);const s=G.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l));null==X||X(s)}if(Z===c.WHATSAPP){const l=G;let t=l.body,s=l.header,u=l.buttons;"BODY"===S?t=null===(a=l.body)||void 0===a?void 0:a.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l)):"HEADER"===S?s=null===(o=l.header)||void 0===o?void 0:o.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l)):"BUTTONS"===S&&(u=null===(i=l.buttons)||void 0===i?void 0:i.map(((l,t)=>(console.log("vj: check",{normalizedType:n,ind:t,index:k,currVar:l}),t===k?Object.assign(Object.assign({},l),{type:m.URL,buttonVariable:e}):l)))),console.log("vj: buttonvariablelist",u),null==X||X((e=>Object.assign(Object.assign({},e),{header:s,body:t,buttons:u})))}}function ie(e,l,t,a){var o,i,n;const s=Object.assign({},q);console.log("vj: update component",{index:e,newValue:l});const u=null===(o=null==s?void 0:s.components)||void 0===o?void 0:o.map((t=>{var a,o,i,n,s,u,d,r;const c=Object.assign({},t);if("BODY"===t.type&&"BODY"===S){if(null===(o=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===o?void 0:o[0]){const t=[...null!==(s=null===(n=null===(i=c.example)||void 0===i?void 0:i.body_text)||void 0===n?void 0:n[0])&&void 0!==s?s:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{body_text:[t]});return Object.assign(Object.assign({},c),{example:a})}}else if("HEADER"===t.type&&"HEADER"===S&&(null===(u=t.example)||void 0===u?void 0:u.header_text)){const t=[...null!==(r=null===(d=c.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{header_text:t});return Object.assign(Object.assign({},c),{example:a})}return t}));s.components=u,t&&("BODY"===S&&(null===(i=null==s?void 0:s.mapping)||void 0===i?void 0:i.body)?s.mapping=Object.assign(Object.assign({},s.mapping),{body:s.mapping.body.map(((t,o)=>e===o?"custom_text"===a?`((editableVariable${o+10}))`:l:t))}):"HEADER"===S&&(null===(n=null==s?void 0:s.mapping)||void 0===n?void 0:n.header)&&(s.mapping=Object.assign(Object.assign({},s.mapping),{header:s.mapping.header.map(((t,o)=>e===o?"custom_text"===a?`((editableVariable${o+20}))`:l:t))}))),null==K||K(Object.assign({},s))}return console.log("vj: variableconnector",{variable:V,originalVariableList:G}),o((()=>{L&&(null==_||_())}),[L]),o((()=>{!function(){var e,l,t,a,o;const i="mobile"===Y?"template_html_mobile":"template_html_desktop",n=document.getElementById(i),s=(null!==(a=null===(t=null===(l=null===(e=null==n?void 0:n.contentWindow)||void 0===e?void 0:e.document)||void 0===l?void 0:l.body)||void 0===t?void 0:t.innerHTML)&&void 0!==a?a:"")+(null===(o=null==n?void 0:n.contentWindow)||void 0===o?void 0:o.document.head.innerHTML);Z===c.EMAIL&&(null==Q||Q(s))}()}),[J]),o((()=>{var e;const l=[];let t=[];if(Z!==c.MESSAGE||le){"link"===(null==V?void 0:V.type)?(l.push({label:"",options:[O,f]}),console.log("vj: variable type is link"),D(O)):(l.push({label:"",options:[O,f]}),D(f));const e=null!=ee?ee:[];N([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:g.toCapitilize(null===(t=null===(l=e.label)||void 0===l?void 0:l.replace(/([A-Z])/g," $1"))||void 0===t?void 0:t.toLowerCase())})}))]),t=[...l,...e],console.log("vj: alloptions",t)}else{const e=null!=ee?ee:[];N([{label:"",options:[f,O]},...e]),t=[{label:"",options:[f,O]},...e]}if((Z===c.WHATSAPP||Z===c.EMAIL||Z===c.MESSAGE)&&V.updatedValue)if(r.test(V.updatedValue)&&Z===c.WHATSAPP||V.updatedValue.startsWith("{{")&&Z!==c.WHATSAPP){const e=function(e,l,t){var a;let o={label:"",value:""};const i=t===c.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");T?o={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===i.trim()&&(o=e)}))}));return o}(V,t,Z);console.log("vj: preselected option",e),e.value&&D(e)}else(null===(e=V.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(D(O),M(V.updatedValue.split("https://")[1])):(D(f),M(V.updatedValue))}),[]),o((()=>{Y&&$&&B&&setTimeout((()=>{oe("custom_link"===(null==$?void 0:$.value)&&B?B.includes("https")?B:`https://${B}`:B,$.value)}),100)}),[Y]),o((()=>{console.log("vj:",{renderFirstTime:U,selectedOption:$,variable:V,enteredVariableValue:B}),!U&&$&&V.updatedValue&&setTimeout((()=>{const e="custom_link"===(null==$?void 0:$.value)&&B?B.includes("https")?V.updatedValue:`https://${V.updatedValue}`:V.updatedValue;console.log("vj: inputvalue",e),oe(e,$.value),z(!0)}),100)}),[$]),e(y,Object.assign({channel:Z,focused:L,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:e(v,Object.assign({style:{color:F&&!$?h.content.negative:h.content.primary}},{children:[null===(w=V.variableName)||void 0===w?void 0:w.replace("{{","").replace("}}","")," ","link"===(null==V?void 0:V.type)?"link":"variable"]}))})),l("div",Object.assign({style:{marginBottom:12}},{children:T?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==$?void 0:$.label)?"space-between":"flex-end"}},{children:[l(b,{children:d(null!==(C=null==$?void 0:$.label)&&void 0!==C?C:"",20,!0)}),l(t,{onClick:()=>{R(!I)},width:24,height:24,color:h.content.primary})]})):l(s,{options:W,isSearchable:!1,onSelect:ae,defaultOptions:$?[Object.assign(Object.assign({},$),{selected:!0})]:[]})})),("custom_text"===(null==$?void 0:$.value)||"custom_link"===(null==$?void 0:$.value))&&l(u,{labelText:"custom_text"===(null==$?void 0:$.value)?"Custom text value":"custom_link"===(null==$?void 0:$.value)?"Custom URL value":"",id:`variable-value-${null==$?void 0:$.value}-${k}`,value:B,errorMessage:F?B&&0!==B.trim().length?"custom_link"!==$.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${B.trim()}`)&&0!==B.trim().length?"custom_link"!==$.value&&B.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==$?void 0:$.value)?void 0:30,prefixText:"custom_link"===(null==$?void 0:$.value)?"https://":"",placeholder:"link"===V.type||"custom_link"===$.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;M(l);const a="custom_link"===(null==$?void 0:$.value)&&l?l.includes("https")?l:`https://${l}`:l;oe(a,e),Z===c.WHATSAPP&&(null==ie||ie(null!==(t=V.index)&&void 0!==t?t:0,a))}($.value,e)}}),I&&l(n,{zIndex:2e3,data:null!=A?A:[],showVariable:I,setShowVariable:R,placeholder:"Add a variable",customTrigger:e=>{if(console.log("vj: customtrigger",e),null==E||E(!1),"{{custom.url}}"===e.actualValue)ae({label:e.displayName,selected:!0,value:"custom_link"});else if("{{custom.text}}"==e.actualValue)ae({label:e.displayName,selected:!0,value:"custom_text"});else if(te===p.CHATBOT&&"BUTTONS"===S){const l=null==P?void 0:P.filter((l=>l.placeHolder===e.actualValue));console.log("vj: CTAoptions",{CTAoptions:P,isVariableInCtaOptions:l}),l&&l.length>0?ae({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"}):ae({label:e.displayName,selected:!0,value:"custom_link"})}else ae({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{y as Container,_ as default};
|
package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
|
|
1
2
|
import { ButtonPlaceHolderOptions } from "../../template-preview/models/TemplateMeta";
|
|
2
3
|
import { CTABtnValType, QRBBtnValType, TEMPLATE_BUTTON } from "../../template-preview/models/WhatsAppTemplate";
|
|
3
4
|
import { WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAppTemplate";
|
|
@@ -10,6 +11,7 @@ export interface WhatsAppTemplateCardButtonV2Props {
|
|
|
10
11
|
button: TEMPLATE_BUTTON;
|
|
11
12
|
CTAoptions?: ButtonPlaceHolderOptions[];
|
|
12
13
|
QRBoptions?: ButtonPlaceHolderOptions[];
|
|
14
|
+
variableList?: VariableListInterfaceV2[];
|
|
13
15
|
}
|
|
14
|
-
declare const WhatsAppTemplateCardButtonV2: ({ button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const WhatsAppTemplateCardButtonV2: ({ button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, variableList, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
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
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as a}from"react";import{Dropdown as o}from"../../dropdown/Dropdown.js";import{Input as i}from"../../input/Input.js";import{editableVarPattern as n}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as s}from"../../template-preview/models/TemplateMeta.js";import{POD as r,BUTTON_TYPE as p}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as d}from"../../TypographyStyle.js";import{COLORS as b}from"../../../constants/Theme.js";import{useTemplateModalContext as c}from"../context/templateModalContext.js";import{validateIsUrl as m}from"../utils/validateIsUrl.js";import u,{Container as f}from"./VariableConnector.js";const j=j=>{let{button:v,updateSelectedURLTemplateBtn:g,updateSelectedQRBTemplateBtn:y,originalVariableList:h,CTAoptions:O,QRBoptions:x,variableList:L}=j;var T,V;const[R,U]=l(""),[w,B]=l(),{setOriginalVariableList:C,isError:H,disableEditVariable:I,pod:E}=c();function N(e){U(e);const t=[Object.assign(Object.assign({},h.buttons[0]),{type:p.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==C||C((e=>Object.assign(Object.assign({},e),{body:[...h.body],buttons:[...t]}))),null==g||g(`https://${e}`,"custom")}return a((()=>{var e;if(v.buttonVariable&&n.test(v.buttonVariable))B(s),U((null===(e=v.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===v.type?O:x;e="URL"===v.type?t.findIndex((e=>e.placeHolder===v.buttonVariable)):t.findIndex((e=>e.label===v.flowName)),e>-1&&B(t[e])}}),[]),e(f,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(d,Object.assign({style:{color:b.content.primary}},{children:[v.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:E!==r.CHATBOT?t(o,{disabled:I,options:"URL"===v.type?O:x,isSearchable:!1,onSelect:function(e,t){const l=e;B(l);const a=("URL"===v.type?O:x).find((e=>e.placeHolder===l.placeHolder));if(a)if("custom_link"!==a.value){let e;"URL"===v.type?(e=[Object.assign(Object.assign({},h.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==g||g({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder")):(e=h.buttons.map(((e,t)=>t===v.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==y||y({flowName:l.label,flowId:l.value},"placeholder",v.index)),null==C||C((t=>Object.assign(Object.assign({},t),{body:[...h.body],buttons:[...e]})))}else N("")},defaultOptions:w?[Object.assign(Object.assign({},w),{selected:!0})]:[]}):t(u,{index:v.index||0,variable:{variableName:null!==(T=v.buttonVariable)&&void 0!==T?T:"",updatedValue:null!==(V=v.buttonVariable)&&void 0!==V?V:"",type:"link",isEditableVariable:!0},showVariableModal:!0,componentType:"BUTTONS",variableList:L,CTAoptions:O})})),"custom_link"===(null==w?void 0:w.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(i,{state:I?"disabled":"none",errorMessage:H?R?m(R)?"":"Enter valid URL":"Required field":"",value:R,prefixText:"custom_link"===(null==w?void 0:w.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:N})}))]})};export{j as default};
|