@bikdotai/bik-component-library 0.0.359-beta.7 → 0.0.359-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.
@@ -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"),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:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:h,templateVariables:g,onTemplateSelect:C,globalPlaceholders:b,showOnlyContent:S,whatsappSpecificPickerMeta:T,zIndex:v,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:P,onBackPress:E,enabledCustomText:L}=d;var f,w;t.useEffect((()=>{A(h)}),[h]);const[N,q]=t.useState(m===o.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[y,A]=t.useState(h),[k,D]=t.useState(!1),[V,_]=t.useState(c),[H,I]=t.useState(null!=g?g:[]),[O,z]=t.useState(!1);const B=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(b)),[b]);return console.log("globalNormalizedPlaceholders",B),e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:V,setTemplate:_,device:N,setDevice:q,display_content:y,setDisplayContent:A,originalVariableList:H,setOriginalVariableList:I,isError:k,setIsError:D,channel:m,globalNormalizedPlaceholders:B,templateSelectionTriggered:O,setTemplateSelectionTriggered:z,enabledCustomText:L}},{children:S?e.jsx(r.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:v,centralContainerStyles:{width:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==V?void 0:V.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(f=null==V?void 0:V.category)&&void 0!==f?f:"")} • ${null!==(w=null==V?void 0:V.templateCategory)&&void 0!==w?w:""}`:"",onBackPress:()=>{null==E||E()}},{children:[e.jsx(r.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:T,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:P}),C?e.jsx(i.default,{onSelect:function(){const e=null==C?void 0:C(V,H,null!=y?y:"");e?D(!!e):z(!0)}}):e.jsx(e.Fragment,{})]}))}))};
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"),n=require("./modalElements/TemplateSelectModalContent.js"),r=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:g,templateVariables:h,onTemplateSelect:b,globalPlaceholders:C,showOnlyContent:S,whatsappSpecificPickerMeta:T,zIndex:v,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:P,onBackPress:E,enabledCustomText:L}=d;var f,w;t.useEffect((()=>{A(g)}),[g]);const[y,N]=t.useState(m===o.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[q,A]=t.useState(g),[V,_]=t.useState(!1),[k,D]=t.useState(c),[H,I]=t.useState(null!=h?h:[]),[O,z]=t.useState(!1);const B=t.useMemo((()=>r.convertPlaceholdersToBikDropdown(C)),[C]);return console.log("globalNormalizedPlaceholders",B),e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:k,setTemplate:D,device:y,setDevice:N,display_content:q,setDisplayContent:A,originalVariableList:H,setOriginalVariableList:I,isError:V,setIsError:_,channel:m,globalNormalizedPlaceholders:B,templateSelectionTriggered:O,setTemplateSelectionTriggered:z,enabledCustomText:L}},{children:S?e.jsx(n.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:v,centralContainerStyles:{width:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==k?void 0:k.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(f=null==k?void 0:k.category)&&void 0!==f?f:"")} • ${null!==(w=null==k?void 0:k.templateCategory)&&void 0!==w?w:""}`:"",onBackPress:()=>{null==E||E()}},{children:[e.jsx(n.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:T,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:P}),b?e.jsx(i.default,{onSelect:function(){const e=null==b?void 0:b(k,H,null!=q?q:"");console.log("error",e),console.log("template",k),console.log("originalVariableList",H),console.log("display_content",q),e?_(!!e):z(!0)}}):e.jsx(e.Fragment,{})]}))}))};
@@ -4,4 +4,4 @@
4
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
- `,x={value:"custom_link",label:"Custom URL"},h={value:"custom_text",label:"Custom text"};exports.Container=g,exports.default=a=>{let{onFocus:b,variable:E,index:_,showVariableModal:j,variableList:A,setShowDiscountCheckBox:y}=a;var f;const[T,O]=t.useState(!1),[P,C]=t.useState(""),[N,L]=t.useState([]),[k,S]=t.useState(),[V,H]=t.useState(!1),[w,M]=t.useState(!1),{device:q,channel:Y,isError:W,originalVariableList:I,template:B,templateSelectionTriggered:$,setTemplate:R,setDisplayContent:z,setOriginalVariableList:D,globalNormalizedPlaceholders:U,enabledCustomText:Z}=p.useTemplateModalContext();function F(e,l){var t,a,o;const n=e;C(""),S(n),console.log("singleOption",n),console.log("variable",E),Y===d.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(G(null!==(t=n.value)&&void 0!==t?t:"","string"),null==J||J(null!==(a=E.index)&&void 0!==a?a:0,`{{${n.value}}}`)):(null==J||J(null!==(o=E.index)&&void 0!==o?o:0,E.variableName),G("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?G(n.value,"url"===n.bikPlaceholderType?"link":"string"):(C(""),G("",n.value))}function G(e,l){var t,a;const o="custom_link"===l?"link":"custom_text"===l?"string":l;if(Y!==d.CHANNEL_TYPE.WHATSAPP){const a=m.getVariableNameForEmailByIndex(_+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===q?"template_html_mobile":"template_html_desktop"),i=Y===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 u=I.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==D||D(u)}if(console.log("originalVariableList",I),Y===d.CHANNEL_TYPE.WHATSAPP){const l=null===(a=I.body)||void 0===a?void 0:a.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==D||D((e=>Object.assign(Object.assign({},e),{body:l,buttons:I.buttons})))}}function J(e,l){var t;const a=Object.assign({},B),o=null===(t=null==a?void 0:a.components)||void 0===t?void 0:t.map((t=>{var a,o,n,i,u;const s=Object.assign({},t);if("BODY"===t.type&&(null===(o=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===o?void 0:o[0])){const t=[...null!==(u=null===(i=null===(n=s.example)||void 0===n?void 0:n.body_text)||void 0===i?void 0:i[0])&&void 0!==u?u:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},s.example),{body_text:[t]});return Object.assign(Object.assign({},s),{example:a})}return console.log("updateComponent",s),t}));a.components=o,null==R||R(a)}return t.useEffect((()=>{T&&(null==b||b())}),[T]),t.useEffect((()=>{!function(){var e,l,t,a,o;const n="mobile"===q?"template_html_mobile":"template_html_desktop",i=document.getElementById(n),u=(null!==(a=null===(t=null===(l=null===(e=null==i?void 0:i.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==i?void 0:i.contentWindow)||void 0===o?void 0:o.document.head.innerHTML);Y===d.CHANNEL_TYPE.EMAIL&&(null==z||z(u))}()}),[$]),t.useEffect((()=>{var e;const l=[];let t=[];if(Y!==d.CHANNEL_TYPE.MESSAGE||Z){"link"===(null==E?void 0:E.type)?(l.push({label:"",options:[x,h]}),S(x)):(l.push({label:"",options:[x,h]}),S(h));const e=null!=U?U:[];console.log("globalOptions",e),L([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:c.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("allOptions",t)}else{const e=null!=U?U:[];console.log("globalOptions",e),L([{label:"",options:[h,x]},...e]),t=[{label:"",options:[h,x]},...e]}if((Y===d.CHANNEL_TYPE.WHATSAPP||Y===d.CHANNEL_TYPE.EMAIL||Y===d.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(s.placeHolderNamePattern.test(E.updatedValue)&&Y===d.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&Y!==d.CHANNEL_TYPE.WHATSAPP){const e=function(e,l,t){var a;let o={label:"",value:""};const n=t===d.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");j?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())===n.trim()&&(o=e)}))}));return console.log("preSelectedOption",o),o}(E,t,Y);e.value&&S(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(S(x),C(E.updatedValue.split("https://")[1])):(S(h),C(E.updatedValue))}),[]),t.useEffect((()=>{q&&k&&P&&setTimeout((()=>{G("custom_link"===(null==k?void 0:k.value)?`https://${P}`:P,k.value)}),100)}),[q]),t.useEffect((()=>{!w&&k&&E.updatedValue&&setTimeout((()=>{G("custom_link"===(null==k?void 0:k.value)?`https://${E.updatedValue}`:E.updatedValue,k.value),M(!0)}),100)}),[k]),e.jsxs(g,Object.assign({channel:Y,focused:T,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsx(r.BodySecondary,Object.assign({style:{color:W&&!k?v.COLORS.content.negative:v.COLORS.content.primary}},{children:"link"===(null==E?void 0:E.type)?"link":"variable"}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:j?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==k?void 0:k.label)?"space-between":"flex-end"}},{children:[e.jsx(r.BodyPrimary,{children:u.truncate(null!==(f=null==k?void 0:k.label)&&void 0!==f?f:"",20,!0)}),e.jsx(l.default,{onClick:()=>{H(!V)},width:24,height:24,color:v.COLORS.content.primary})]})):e.jsx(n.Dropdown,{options:N,isSearchable:!1,onSelect:F,defaultOptions:k?[Object.assign(Object.assign({},k),{selected:!0})]:[]})})),("custom_text"===(null==k?void 0:k.value)||"custom_link"===(null==k?void 0:k.value))&&e.jsx(i.Input,{labelText:"custom_text"===(null==k?void 0:k.value)?"Custom text value":"custom_link"===(null==k?void 0:k.value)?"Custom URL value":"",id:`variable-value-${null==k?void 0:k.value}-${_}`,value:P,errorMessage:W?P&&0!==P.trim().length?"custom_link"!==k.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${P.trim()}`)&&0!==P.trim().length?"custom_link"!==k.value&&P.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==k?void 0:k.value)?void 0:30,prefixText:"custom_link"===(null==k?void 0:k.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===k.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;C(l);const a="custom_link"===(null==k?void 0:k.value)?`https://${l}`:l;G(a,e),Y===d.CHANNEL_TYPE.WHATSAPP&&(null==J||J(null!==(t=E.index)&&void 0!==t?t:0,a))}(k.value,e)}}),V&&e.jsx(o.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:V,setShowVariable:H,placeholder:"Add a variable",customTrigger:e=>{console.log("variable",e),null==y||y(!1),"{{custom.url}}"===e.actualValue?F({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?(console.log("393variable",e),F({label:e.displayName,selected:!0,value:"custom_text"})):F({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.defaultValue||e.actualValue,bikPlaceholderType:"string"})}})]}))};
7
+ `,x={value:"custom_link",label:"Custom URL"},h={value:"custom_text",label:"Custom text"};exports.Container=g,exports.default=a=>{let{onFocus:b,variable:E,index:_,showVariableModal:j,variableList:A,setShowDiscountCheckBox:y}=a;var f,T;const[N,O]=t.useState(!1),[P,C]=t.useState(""),[L,k]=t.useState([]),[S,V]=t.useState(),[H,w]=t.useState(!1),[M,q]=t.useState(!1),{device:Y,channel:W,isError:I,originalVariableList:B,template:$,templateSelectionTriggered:R,setTemplate:z,setDisplayContent:D,setOriginalVariableList:U,globalNormalizedPlaceholders:Z,enabledCustomText:F}=p.useTemplateModalContext();function G(e,l){var t,a,o;const n=e;C(""),V(n),console.log("singleOption",n),console.log("variable",E),W===d.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(J(null!==(t=n.value)&&void 0!==t?t:"","string"),null==K||K(null!==(a=E.index)&&void 0!==a?a:0,`{{${n.value}}}`)):(null==K||K(null!==(o=E.index)&&void 0!==o?o:0,E.variableName),J("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?J(n.value,"url"===n.bikPlaceholderType?"link":"string"):(C(""),J("",n.value))}function J(e,l){var t,a;const o="custom_link"===l?"link":"custom_text"===l?"string":l;if(W!==d.CHANNEL_TYPE.WHATSAPP){const a=m.getVariableNameForEmailByIndex(_+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===Y?"template_html_mobile":"template_html_desktop"),i=W===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 u=B.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==U||U(u)}if(console.log("originalVariableList",B),W===d.CHANNEL_TYPE.WHATSAPP){const l=null===(a=B.body)||void 0===a?void 0:a.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));console.log("lib-updatedVariables",l),null==U||U((e=>Object.assign(Object.assign({},e),{body:l,buttons:B.buttons})))}}function K(e,l){var t;const a=Object.assign({},$),o=null===(t=null==a?void 0:a.components)||void 0===t?void 0:t.map((t=>{var a,o,n,i,u;const s=Object.assign({},t);if("BODY"===t.type&&(null===(o=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===o?void 0:o[0])){const t=[...null!==(u=null===(i=null===(n=s.example)||void 0===n?void 0:n.body_text)||void 0===i?void 0:i[0])&&void 0!==u?u:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},s.example),{body_text:[t]});return Object.assign(Object.assign({},s),{example:a})}return console.log("updateComponent",s),t}));a.components=o,null==z||z(a)}return t.useEffect((()=>{N&&(null==b||b())}),[N]),t.useEffect((()=>{!function(){var e,l,t,a,o;const n="mobile"===Y?"template_html_mobile":"template_html_desktop",i=document.getElementById(n),u=(null!==(a=null===(t=null===(l=null===(e=null==i?void 0:i.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==i?void 0:i.contentWindow)||void 0===o?void 0:o.document.head.innerHTML);W===d.CHANNEL_TYPE.EMAIL&&(null==D||D(u))}()}),[R]),t.useEffect((()=>{var e;const l=[];let t=[];if(W!==d.CHANNEL_TYPE.MESSAGE||F){"link"===(null==E?void 0:E.type)?(l.push({label:"",options:[x,h]}),V(x)):(l.push({label:"",options:[x,h]}),V(h));const e=null!=Z?Z:[];console.log("globalOptions",e),k([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:c.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("allOptions",t)}else{const e=null!=Z?Z:[];console.log("globalOptions",e),k([{label:"",options:[h,x]},...e]),t=[{label:"",options:[h,x]},...e]}if((W===d.CHANNEL_TYPE.WHATSAPP||W===d.CHANNEL_TYPE.EMAIL||W===d.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(s.placeHolderNamePattern.test(E.updatedValue)&&W===d.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&W!==d.CHANNEL_TYPE.WHATSAPP){const e=function(e,l,t){var a;let o={label:"",value:""};const n=t===d.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");j?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())===n.trim()&&(o=e)}))}));return console.log("preSelectedOption",o),o}(E,t,W);e.value&&V(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(V(x),C(E.updatedValue.split("https://")[1])):(V(h),C(E.updatedValue))}),[]),t.useEffect((()=>{Y&&S&&P&&setTimeout((()=>{J("custom_link"===(null==S?void 0:S.value)?`https://${P}`:P,S.value)}),100)}),[Y]),t.useEffect((()=>{!M&&S&&E.updatedValue&&setTimeout((()=>{J("custom_link"===(null==S?void 0:S.value)?`https://${E.updatedValue}`:E.updatedValue,S.value),q(!0)}),100)}),[S]),e.jsxs(g,Object.assign({channel:W,focused:N,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:I&&!S?v.COLORS.content.negative:v.COLORS.content.primary}},{children:[null===(f=E.variableName)||void 0===f?void 0:f.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:j?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==S?void 0:S.label)?"space-between":"flex-end"}},{children:[e.jsx(r.BodyPrimary,{children:u.truncate(null!==(T=null==S?void 0:S.label)&&void 0!==T?T:"",20,!0)}),e.jsx(l.default,{onClick:()=>{w(!H)},width:24,height:24,color:v.COLORS.content.primary})]})):e.jsx(n.Dropdown,{options:L,isSearchable:!1,onSelect:G,defaultOptions:S?[Object.assign(Object.assign({},S),{selected:!0})]:[]})})),("custom_text"===(null==S?void 0:S.value)||"custom_link"===(null==S?void 0:S.value))&&e.jsx(i.Input,{labelText:"custom_text"===(null==S?void 0:S.value)?"Custom text value":"custom_link"===(null==S?void 0:S.value)?"Custom URL value":"",id:`variable-value-${null==S?void 0:S.value}-${_}`,value:P,errorMessage:I?P&&0!==P.trim().length?"custom_link"!==S.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${P.trim()}`)&&0!==P.trim().length?"custom_link"!==S.value&&P.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==S?void 0:S.value)?void 0:30,prefixText:"custom_link"===(null==S?void 0:S.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===S.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;C(l);const a="custom_link"===(null==S?void 0:S.value)?`https://${l}`:l;J(a,e),W===d.CHANNEL_TYPE.WHATSAPP&&(null==K||K(null!==(t=E.index)&&void 0!==t?t:0,a))}(S.value,e)}}),H&&e.jsx(o.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:H,setShowVariable:w,placeholder:"Add a variable",customTrigger:e=>{console.log("variable",e),null==y||y(!1),"{{custom.url}}"===e.actualValue?G({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?(console.log("393variable",e),G({label:e.displayName,selected:!0,value:"custom_text"})):G({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/\{\{[A-Za-z0-9 .]+\}\}/g,t=e;exports.editableBracketPattern=/[((|))]/,exports.editableVarPattern=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,exports.globalHalfVariablePattern=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,exports.globalVariablePattern=e,exports.lockedVarPattern=/\[\[[A-Za-z0-9 .]+\]\]/,exports.placeHolderNamePattern=/(\[\[|\{\{||\(\()(.*)(\)\)|\}\}|\]\])/,exports.previewLinkMDFormatPattern=/\[([^[]+)\](\(.*\))/,exports.specialCharPattern=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,exports.templateVariablePattern=t,exports.variablePattern=/\{\{[A-Za-z0-9 ._]+\}\}/,exports.variablePatternGlobal=/\{\{[A-Za-z0-9 _]+\}\}/g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/\{\{[A-Za-z0-9 .]+\}\}/g,t=e;exports.editableBracketPattern=/[((|))]/,exports.editableVarPattern=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,exports.globalHalfVariablePattern=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,exports.globalVariablePattern=e,exports.lockedVarPattern=/\[\[[A-Za-z0-9 .]+\]\]/,exports.placeHolderNamePattern=/(\[\[|\{\{|\(\()(.*?)(\)\)|\}\}|\]\])/,exports.previewLinkMDFormatPattern=/\[([^[]+)\](\(.*\))/,exports.specialCharPattern=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,exports.templateVariablePattern=t,exports.variablePattern=/\{\{[A-Za-z0-9 ._]+\}\}/,exports.variablePatternGlobal=/\{\{[A-Za-z0-9 _]+\}\}/g;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import n from"../../utils/StringUtils.js";import{StyledModal as r}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as c}from"./context/templateModalContext.js";import d from"./modalElements/Footer.js";import m from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const h=h=>{let{selectedTemplate:u,closeDialog:g,showVariableMapping:b,channel:v,htmlContent:C,templateVariables:f,onTemplateSelect:M,globalPlaceholders:S,showOnlyContent:T,whatsappSpecificPickerMeta:P,zIndex:j,showVariableModal:w,variableList:x,discountCode:L,setDiscountCode:y,onBackPress:E,enabledCustomText:V}=h;var k,D;o((()=>{z(C)}),[C]);const[I,A]=a(v===s.EMAIL?"desktop":"mobile"),[O,z]=a(C),[B,F]=a(!1),[H,N]=a(u),[$,U]=a(null!=f?f:[]),[W,_]=a(!1);const q=i((()=>p(S)),[S]);return console.log("globalNormalizedPlaceholders",q),e(c.Provider,Object.assign({value:{template:H,setTemplate:N,device:I,setDevice:A,display_content:O,setDisplayContent:z,originalVariableList:$,setOriginalVariableList:U,isError:B,setIsError:F,channel:v,globalNormalizedPlaceholders:q,templateSelectionTriggered:W,setTemplateSelectionTriggered:_,enabledCustomText:V}},{children:T?e(m,{channel:s.EMAIL,hideHeader:!0}):t(r,Object.assign({zIndex:j,centralContainerStyles:{width:v===s.EMAIL&&b?1e3:650},open:!0,onClose:()=>{null==g||g()},headingTitle:null==H?void 0:H.label,headingSubtitle:v===s.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(k=null==H?void 0:H.category)&&void 0!==k?k:"")} • ${null!==(D=null==H?void 0:H.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==E||E()}},{children:[e(m,{showVariableMapping:b,channel:v,whatsappSpecificPickerMeta:P,showVariableModal:w,variableList:x,discountCode:L,setDiscountCode:y}),M?e(d,{onSelect:function(){const e=null==M?void 0:M(H,$,null!=O?O:"");e?F(!!e):_(!0)}}):e(l,{})]}))}))};export{h as TemplateContextMapper};
1
+ import{jsx as e,jsxs as l,Fragment as o}from"react/jsx-runtime";import{useEffect as t,useState as a,useMemo as i}from"react";import n from"../../utils/StringUtils.js";import{StyledModal as r}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as c}from"./context/templateModalContext.js";import d from"./modalElements/Footer.js";import m from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const g=g=>{let{selectedTemplate:h,closeDialog:u,showVariableMapping:b,channel:v,htmlContent:C,templateVariables:f,onTemplateSelect:M,globalPlaceholders:S,showOnlyContent:T,whatsappSpecificPickerMeta:P,zIndex:j,showVariableModal:w,variableList:L,discountCode:x,setDiscountCode:y,onBackPress:V,enabledCustomText:E}=g;var k,D;t((()=>{z(C)}),[C]);const[I,A]=a(v===s.EMAIL?"desktop":"mobile"),[O,z]=a(C),[B,F]=a(!1),[H,N]=a(h),[$,_]=a(null!=f?f:[]),[U,W]=a(!1);const q=i((()=>p(S)),[S]);return console.log("globalNormalizedPlaceholders",q),e(c.Provider,Object.assign({value:{template:H,setTemplate:N,device:I,setDevice:A,display_content:O,setDisplayContent:z,originalVariableList:$,setOriginalVariableList:_,isError:B,setIsError:F,channel:v,globalNormalizedPlaceholders:q,templateSelectionTriggered:U,setTemplateSelectionTriggered:W,enabledCustomText:E}},{children:T?e(m,{channel:s.EMAIL,hideHeader:!0}):l(r,Object.assign({zIndex:j,centralContainerStyles:{width:v===s.EMAIL&&b?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==H?void 0:H.label,headingSubtitle:v===s.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(k=null==H?void 0:H.category)&&void 0!==k?k:"")} • ${null!==(D=null==H?void 0:H.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==V||V()}},{children:[e(m,{showVariableMapping:b,channel:v,whatsappSpecificPickerMeta:P,showVariableModal:w,variableList:L,discountCode:x,setDiscountCode:y}),M?e(d,{onSelect:function(){const e=null==M?void 0:M(H,$,null!=O?O:"");console.log("error",e),console.log("template",H),console.log("originalVariableList",$),console.log("display_content",O),e?F(!!e):W(!0)}}):e(o,{})]}))}))};export{g as TemplateContextMapper};
@@ -4,4 +4,4 @@ import{jsxs as e,jsx as l}from"react/jsx-runtime";import t from"../../../assets/
4
4
  background: ${e=>e.focused&&e.channel===c.EMAIL?b.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,f={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},j=n=>{let{onFocus:j,variable:y,index:k,showVariableModal:V,variableList:O,setShowDiscountCheckBox:A}=n;var T;const[S,E]=o(!1),[P,w]=o(""),[L,C]=o([]),[M,W]=o(),[$,H]=o(!1),[I,B]=o(!1),{device:N,channel:z,isError:R,originalVariableList:U,template:D,templateSelectionTriggered:Z,setTemplate:G,setDisplayContent:q,setOriginalVariableList:F,globalNormalizedPlaceholders:Y,enabledCustomText:J}=g();function K(e,l){var t,o,a;const n=e;w(""),W(n),console.log("singleOption",n),console.log("variable",y),z===c.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(Q(null!==(t=n.value)&&void 0!==t?t:"","string"),null==X||X(null!==(o=y.index)&&void 0!==o?o:0,`{{${n.value}}}`)):(null==X||X(null!==(a=y.index)&&void 0!==a?a:0,y.variableName),Q("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?Q(n.value,"url"===n.bikPlaceholderType?"link":"string"):(w(""),Q("",n.value))}function Q(e,l){var t,o;const a="custom_link"===l?"link":"custom_text"===l?"string":l;if(z!==c.WHATSAPP){const o=h(k+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===N?"template_html_mobile":"template_html_desktop"),i=z===c.EMAIL?null===(t=null==n?void 0:n.contentWindow)||void 0===t?void 0:t.document.getElementById(o):document.getElementById(o);i&&(i.textContent="custom_text"!==l&&"custom_link"!==l||e?e:y.variableName);const s=U.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:a,updatedValue:e}):l));null==F||F(s)}if(console.log("originalVariableList",U),z===c.WHATSAPP){const l=null===(o=U.body)||void 0===o?void 0:o.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:a,updatedValue:e}):l));null==F||F((e=>Object.assign(Object.assign({},e),{body:l,buttons:U.buttons})))}}function X(e,l){var t;const o=Object.assign({},D),a=null===(t=null==o?void 0:o.components)||void 0===t?void 0:t.map((t=>{var o,a,n,i,s;const u=Object.assign({},t);if("BODY"===t.type&&(null===(a=null===(o=t.example)||void 0===o?void 0:o.body_text)||void 0===a?void 0:a[0])){const t=[...null!==(s=null===(i=null===(n=u.example)||void 0===n?void 0:n.body_text)||void 0===i?void 0:i[0])&&void 0!==s?s:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const o=Object.assign(Object.assign({},u.example),{body_text:[t]});return Object.assign(Object.assign({},u),{example:o})}return console.log("updateComponent",u),t}));o.components=a,null==G||G(o)}return a((()=>{S&&(null==j||j())}),[S]),a((()=>{!function(){var e,l,t,o,a;const n="mobile"===N?"template_html_mobile":"template_html_desktop",i=document.getElementById(n),s=(null!==(o=null===(t=null===(l=null===(e=null==i?void 0:i.contentWindow)||void 0===e?void 0:e.document)||void 0===l?void 0:l.body)||void 0===t?void 0:t.innerHTML)&&void 0!==o?o:"")+(null===(a=null==i?void 0:i.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);z===c.EMAIL&&(null==q||q(s))}()}),[Z]),a((()=>{var e;const l=[];let t=[];if(z!==c.MESSAGE||J){"link"===(null==y?void 0:y.type)?(l.push({label:"",options:[f,_]}),W(f)):(l.push({label:"",options:[f,_]}),W(_));const e=null!=Y?Y:[];console.log("globalOptions",e),C([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:v.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("allOptions",t)}else{const e=null!=Y?Y:[];console.log("globalOptions",e),C([{label:"",options:[_,f]},...e]),t=[{label:"",options:[_,f]},...e]}if((z===c.WHATSAPP||z===c.EMAIL||z===c.MESSAGE)&&y.updatedValue)if(r.test(y.updatedValue)&&z===c.WHATSAPP||y.updatedValue.startsWith("{{")&&z!==c.WHATSAPP){const e=function(e,l,t){var o;let a={label:"",value:""};const n=t===c.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");V?a={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(o=e.updatedValue)&&void 0!==o?o:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===n.trim()&&(a=e)}))}));return console.log("preSelectedOption",a),a}(y,t,z);e.value&&W(e)}else(null===(e=y.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(W(f),w(y.updatedValue.split("https://")[1])):(W(_),w(y.updatedValue))}),[]),a((()=>{N&&M&&P&&setTimeout((()=>{Q("custom_link"===(null==M?void 0:M.value)?`https://${P}`:P,M.value)}),100)}),[N]),a((()=>{!I&&M&&y.updatedValue&&setTimeout((()=>{Q("custom_link"===(null==M?void 0:M.value)?`https://${y.updatedValue}`:y.updatedValue,M.value),B(!0)}),100)}),[M]),e(x,Object.assign({channel:z,focused:S,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:l(p,Object.assign({style:{color:R&&!M?b.content.negative:b.content.primary}},{children:"link"===(null==y?void 0:y.type)?"link":"variable"}))})),l("div",Object.assign({style:{marginBottom:12}},{children:V?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==M?void 0:M.label)?"space-between":"flex-end"}},{children:[l(m,{children:d(null!==(T=null==M?void 0:M.label)&&void 0!==T?T:"",20,!0)}),l(t,{onClick:()=>{H(!$)},width:24,height:24,color:b.content.primary})]})):l(s,{options:L,isSearchable:!1,onSelect:K,defaultOptions:M?[Object.assign(Object.assign({},M),{selected:!0})]:[]})})),("custom_text"===(null==M?void 0:M.value)||"custom_link"===(null==M?void 0:M.value))&&l(u,{labelText:"custom_text"===(null==M?void 0:M.value)?"Custom text value":"custom_link"===(null==M?void 0:M.value)?"Custom URL value":"",id:`variable-value-${null==M?void 0:M.value}-${k}`,value:P,errorMessage:R?P&&0!==P.trim().length?"custom_link"!==M.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${P.trim()}`)&&0!==P.trim().length?"custom_link"!==M.value&&P.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==M?void 0:M.value)?void 0:30,prefixText:"custom_link"===(null==M?void 0:M.value)?"https://":"",placeholder:"link"===y.type||"custom_link"===M.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;w(l);const o="custom_link"===(null==M?void 0:M.value)?`https://${l}`:l;Q(o,e),z===c.WHATSAPP&&(null==X||X(null!==(t=y.index)&&void 0!==t?t:0,o))}(M.value,e)}}),$&&l(i,{zIndex:2e3,data:null!=O?O:[],showVariable:$,setShowVariable:H,placeholder:"Add a variable",customTrigger:e=>{console.log("variable",e),null==A||A(!1),"{{custom.url}}"===e.actualValue?K({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?(console.log("393variable",e),K({label:e.displayName,selected:!0,value:"custom_text"})):K({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.defaultValue||e.actualValue,bikPlaceholderType:"string"})}})]}))};export{x as Container,j as default};
7
+ `,f={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},j=n=>{let{onFocus:j,variable:y,index:k,showVariableModal:V,variableList:O,setShowDiscountCheckBox:A}=n;var T,S;const[E,P]=o(!1),[w,L]=o(""),[C,M]=o([]),[W,$]=o(),[H,I]=o(!1),[B,N]=o(!1),{device:z,channel:R,isError:U,originalVariableList:D,template:Z,templateSelectionTriggered:G,setTemplate:q,setDisplayContent:F,setOriginalVariableList:Y,globalNormalizedPlaceholders:J,enabledCustomText:K}=g();function Q(e,l){var t,o,a;const n=e;L(""),$(n),console.log("singleOption",n),console.log("variable",y),R===c.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(X(null!==(t=n.value)&&void 0!==t?t:"","string"),null==ee||ee(null!==(o=y.index)&&void 0!==o?o:0,`{{${n.value}}}`)):(null==ee||ee(null!==(a=y.index)&&void 0!==a?a:0,y.variableName),X("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?X(n.value,"url"===n.bikPlaceholderType?"link":"string"):(L(""),X("",n.value))}function X(e,l){var t,o;const a="custom_link"===l?"link":"custom_text"===l?"string":l;if(R!==c.WHATSAPP){const o=h(k+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===z?"template_html_mobile":"template_html_desktop"),i=R===c.EMAIL?null===(t=null==n?void 0:n.contentWindow)||void 0===t?void 0:t.document.getElementById(o):document.getElementById(o);i&&(i.textContent="custom_text"!==l&&"custom_link"!==l||e?e:y.variableName);const s=D.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:a,updatedValue:e}):l));null==Y||Y(s)}if(console.log("originalVariableList",D),R===c.WHATSAPP){const l=null===(o=D.body)||void 0===o?void 0:o.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:a,updatedValue:e}):l));console.log("lib-updatedVariables",l),null==Y||Y((e=>Object.assign(Object.assign({},e),{body:l,buttons:D.buttons})))}}function ee(e,l){var t;const o=Object.assign({},Z),a=null===(t=null==o?void 0:o.components)||void 0===t?void 0:t.map((t=>{var o,a,n,i,s;const u=Object.assign({},t);if("BODY"===t.type&&(null===(a=null===(o=t.example)||void 0===o?void 0:o.body_text)||void 0===a?void 0:a[0])){const t=[...null!==(s=null===(i=null===(n=u.example)||void 0===n?void 0:n.body_text)||void 0===i?void 0:i[0])&&void 0!==s?s:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const o=Object.assign(Object.assign({},u.example),{body_text:[t]});return Object.assign(Object.assign({},u),{example:o})}return console.log("updateComponent",u),t}));o.components=a,null==q||q(o)}return a((()=>{E&&(null==j||j())}),[E]),a((()=>{!function(){var e,l,t,o,a;const n="mobile"===z?"template_html_mobile":"template_html_desktop",i=document.getElementById(n),s=(null!==(o=null===(t=null===(l=null===(e=null==i?void 0:i.contentWindow)||void 0===e?void 0:e.document)||void 0===l?void 0:l.body)||void 0===t?void 0:t.innerHTML)&&void 0!==o?o:"")+(null===(a=null==i?void 0:i.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);R===c.EMAIL&&(null==F||F(s))}()}),[G]),a((()=>{var e;const l=[];let t=[];if(R!==c.MESSAGE||K){"link"===(null==y?void 0:y.type)?(l.push({label:"",options:[f,_]}),$(f)):(l.push({label:"",options:[f,_]}),$(_));const e=null!=J?J:[];console.log("globalOptions",e),M([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:v.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("allOptions",t)}else{const e=null!=J?J:[];console.log("globalOptions",e),M([{label:"",options:[_,f]},...e]),t=[{label:"",options:[_,f]},...e]}if((R===c.WHATSAPP||R===c.EMAIL||R===c.MESSAGE)&&y.updatedValue)if(r.test(y.updatedValue)&&R===c.WHATSAPP||y.updatedValue.startsWith("{{")&&R!==c.WHATSAPP){const e=function(e,l,t){var o;let a={label:"",value:""};const n=t===c.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");V?a={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(o=e.updatedValue)&&void 0!==o?o:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===n.trim()&&(a=e)}))}));return console.log("preSelectedOption",a),a}(y,t,R);e.value&&$(e)}else(null===(e=y.updatedValue)||void 0===e?void 0:e.startsWith("https"))?($(f),L(y.updatedValue.split("https://")[1])):($(_),L(y.updatedValue))}),[]),a((()=>{z&&W&&w&&setTimeout((()=>{X("custom_link"===(null==W?void 0:W.value)?`https://${w}`:w,W.value)}),100)}),[z]),a((()=>{!B&&W&&y.updatedValue&&setTimeout((()=>{X("custom_link"===(null==W?void 0:W.value)?`https://${y.updatedValue}`:y.updatedValue,W.value),N(!0)}),100)}),[W]),e(x,Object.assign({channel:R,focused:E,onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:e(p,Object.assign({style:{color:U&&!W?b.content.negative:b.content.primary}},{children:[null===(T=y.variableName)||void 0===T?void 0:T.replace("{{","").replace("}}","")," ","link"===(null==y?void 0:y.type)?"link":"variable"]}))})),l("div",Object.assign({style:{marginBottom:12}},{children:V?e("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:[l(m,{children:d(null!==(S=null==W?void 0:W.label)&&void 0!==S?S:"",20,!0)}),l(t,{onClick:()=>{I(!H)},width:24,height:24,color:b.content.primary})]})):l(s,{options:C,isSearchable:!1,onSelect:Q,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))&&l(u,{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}-${k}`,value:w,errorMessage:U?w&&0!==w.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://${w.trim()}`)&&0!==w.trim().length?"custom_link"!==W.value&&w.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"===y.type||"custom_link"===W.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;L(l);const o="custom_link"===(null==W?void 0:W.value)?`https://${l}`:l;X(o,e),R===c.WHATSAPP&&(null==ee||ee(null!==(t=y.index)&&void 0!==t?t:0,o))}(W.value,e)}}),H&&l(i,{zIndex:2e3,data:null!=O?O:[],showVariable:H,setShowVariable:I,placeholder:"Add a variable",customTrigger:e=>{console.log("variable",e),null==A||A(!1),"{{custom.url}}"===e.actualValue?Q({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?(console.log("393variable",e),Q({label:e.displayName,selected:!0,value:"custom_text"})):Q({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{x as Container,j as default};
@@ -1 +1 @@
1
- const a=/\[\[[A-Za-z0-9 .]+\]\]/,z=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,A=/(\[\[|\{\{||\(\()(.*)(\)\)|\}\}|\]\])/,Z=/\{\{[A-Za-z0-9 .]+\}\}/g,g=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,_=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,o=/\{\{[A-Za-z0-9 ._]+\}\}/,t=/\{\{[A-Za-z0-9 _]+\}\}/g,c=Z,e=/\[([^[]+)\](\(.*\))/,n=/[((|))]/;export{n as editableBracketPattern,z as editableVarPattern,g as globalHalfVariablePattern,Z as globalVariablePattern,a as lockedVarPattern,A as placeHolderNamePattern,e as previewLinkMDFormatPattern,_ as specialCharPattern,c as templateVariablePattern,o as variablePattern,t as variablePatternGlobal};
1
+ const a=/\[\[[A-Za-z0-9 .]+\]\]/,z=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,A=/(\[\[|\{\{|\(\()(.*?)(\)\)|\}\}|\]\])/,Z=/\{\{[A-Za-z0-9 .]+\}\}/g,g=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,_=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,o=/\{\{[A-Za-z0-9 ._]+\}\}/,t=/\{\{[A-Za-z0-9 _]+\}\}/g,c=Z,e=/\[([^[]+)\](\(.*\))/,n=/[((|))]/;export{n as editableBracketPattern,z as editableVarPattern,g as globalHalfVariablePattern,Z as globalVariablePattern,a as lockedVarPattern,A as placeHolderNamePattern,e as previewLinkMDFormatPattern,_ as specialCharPattern,c as templateVariablePattern,o as variablePattern,t as variablePatternGlobal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.359-beta.7",
3
+ "version": "0.0.359-beta.9",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",