@bikdotai/bik-component-library 0.0.314-beta.10 → 0.0.314-beta.13

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,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1,7 +1,7 @@
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"),u=require("../../template-preview/constants/regexPatterns.js"),s=require("../../template-preview/models/Channels.js"),r=require("../../TypographyStyle.js"),d=require("../../../utils/StringUtils.js"),c=require("../../../constants/Theme.js"),v=require("../context/templateModalContext.js"),p=require("../utils/getVariableNameEmail.js"),m=require("../utils/validateIsUrl.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const g=b(a).default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("react"),a=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),i=require("../../dropdown/Dropdown.js"),o=require("../../input/Input.js"),u=require("../../template-preview/constants/regexPatterns.js"),s=require("../../template-preview/models/Channels.js"),r=require("../../TypographyStyle.js"),d=require("../../../utils/StringUtils.js"),c=require("../../../constants/Theme.js"),v=require("../context/templateModalContext.js"),p=require("../utils/getVariableNameEmail.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const b=m(a).default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===s.CHANNEL_TYPE.EMAIL?c.COLORS.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,x={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"};exports.Container=g,exports.default=a=>{let{onFocus:b,variable:_,index:h,showVariableModal:j,variableList:A,setShowDiscountCheckBox:N}=a;var P;const[T,y]=t.useState(!1),[C,L]=t.useState(""),[f,O]=t.useState([]),[S,k]=t.useState(),[V,H]=t.useState(!1),{device:M,channel:q,isError:w,originalVariableList:I,template:Y,templateSelectionTriggered:W,setTemplate:B,setDisplayContent:R,setOriginalVariableList:U,globalNormalizedPlaceholders:$}=v.useTemplateModalContext();function D(e,l){var t,a,n;const i=e;L(""),k(i),q===s.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(z(null!==(t=i.value)&&void 0!==t?t:"","string"),null==F||F(null!==(a=_.index)&&void 0!==a?a:0,`[[${i.value}]]`)):(null==F||F(null!==(n=_.index)&&void 0!==n?n:0,_.variableName),z("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?z(i.value,"url"===i.bikPlaceholderType?"link":"string"):(L(""),z("",i.value))}function z(e,l){var t,a;const n="custom_link"===l?"link":"custom_text"===l?"string":l;if(q!==s.CHANNEL_TYPE.WHATSAPP){const a=p.getVariableNameForEmailByIndex(h+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===M?"template_html_mobile":"template_html_desktop"),o=q===s.CHANNEL_TYPE.EMAIL?null===(t=null==i?void 0:i.contentWindow)||void 0===t?void 0:t.document.getElementById(a):document.getElementById(a);o&&(o.textContent="custom_text"!==l&&"custom_link"!==l||e?e:_.variableName);const u=I.map(((l,t)=>t===h?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l));null==U||U(u)}if(q===s.CHANNEL_TYPE.WHATSAPP){const l=null===(a=I.body)||void 0===a?void 0:a.map(((l,t)=>t===h?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l));null==U||U((e=>Object.assign(Object.assign({},e),{body:l,buttons:I.buttons})))}}function F(e,l){var t;const a=Object.assign({},Y),n=null===(t=null==a?void 0:a.components)||void 0===t?void 0:t.map((t=>{var a,n,i,o,u;const s=Object.assign({},t);if("BODY"===t.type&&(null===(n=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0])){const t=[...null!==(u=null===(o=null===(i=s.example)||void 0===i?void 0:i.body_text)||void 0===o?void 0:o[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 t}));a.components=n,null==B||B(a)}return t.useEffect((()=>{T&&(null==b||b())}),[T]),t.useEffect((()=>{!function(){var e,l,t,a,n;const i="mobile"===M?"template_html_mobile":"template_html_desktop",o=document.getElementById(i),u=(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);q===s.CHANNEL_TYPE.EMAIL&&(null==R||R(u))}()}),[W]),t.useEffect((()=>{var e;const l=[];let t=[];if(q===s.CHANNEL_TYPE.MESSAGE){const e=null!=$?$:[];O([{label:"",options:[E,x]},...e]),t=[{label:"",options:[E,x]},...e]}else{"link"===(null==_?void 0:_.type)?(l.push({label:"",options:[x,E]}),k(x)):(l.push({label:"",options:[x,E]}),k(E));const e=null!=$?$:[];O([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:d.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]}if((q===s.CHANNEL_TYPE.WHATSAPP||q===s.CHANNEL_TYPE.EMAIL||q===s.CHANNEL_TYPE.MESSAGE)&&_.updatedValue)if(u.placeHolderNamePattern.test(_.updatedValue)&&q===s.CHANNEL_TYPE.WHATSAPP||_.updatedValue.startsWith("{{")&&q!==s.CHANNEL_TYPE.WHATSAPP){const e=function(e,l,t){var a;let n={label:"",value:""};const i=t===s.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");j?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}(_,t,q);e.value&&k(e)}else(null===(e=_.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(k(x),L(_.updatedValue.split("https://")[1])):(k(E),L(_.updatedValue))}),[]),e.jsxs(g,Object.assign({channel:q,focused:T,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:w&&!S?c.COLORS.content.negative:c.COLORS.content.primary}},{children:[null===(P=_.variableName)||void 0===P?void 0:P.replace("{{","").replace("}}","")," ","link"===(null==_?void 0:_.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:j?e.jsx(o.Input,{state:"none",value:S?S.label:"Custom text",onChangeText:()=>{},rightIcon:{icon:()=>e.jsx(l.default,{onClick:()=>{H(!V)},width:24,height:24,color:c.COLORS.content.primary})}}):e.jsx(i.Dropdown,{options:f,isSearchable:!1,onSelect:D,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(o.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}-${h}`,value:C,errorMessage:w?C?"custom_link"!==S.value||m.validateIsUrl(C)?"":"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"===_.type||"custom_link"===S.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>function(e,l){var t;L(l);const a="custom_link"===(null==S?void 0:S.value)?`https://${l}`:l;z(a,e),q===s.CHANNEL_TYPE.WHATSAPP&&(null==F||F(null!==(t=_.index)&&void 0!==t?t:0,a))}(S.value,e)}),V&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:V,setShowVariable:H,placeholder:"Add a variable",customTrigger:e=>{N(!1),"{{custom.url}}"===e.actualValue?D({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?D({label:e.displayName,selected:!0,value:"custom_text"}):D({label:e.actualValue.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
7
+ `,g={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"};exports.Container=b,exports.default=a=>{let{onFocus:m,variable:h,index:E,showVariableModal:_,variableList:j,setShowDiscountCheckBox:A}=a;var N;const[P,T]=l.useState(!1),[y,C]=l.useState(""),[L,f]=l.useState([]),[O,S]=l.useState(),[k,V]=l.useState(!1),{device:H,channel:w,isError:M,originalVariableList:q,template:Y,templateSelectionTriggered:I,setTemplate:W,setDisplayContent:B,setOriginalVariableList:R,globalNormalizedPlaceholders:$}=v.useTemplateModalContext();function z(e,t){var l,a,n;const i=e;C(""),S(i),w===s.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(D(null!==(l=i.value)&&void 0!==l?l:"","string"),null==U||U(null!==(a=h.index)&&void 0!==a?a:0,`[[${i.value}]]`)):(null==U||U(null!==(n=h.index)&&void 0!==n?n:0,h.variableName),D("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?D(i.value,"url"===i.bikPlaceholderType?"link":"string"):(C(""),D("",i.value))}function D(e,t){var l,a;const n="custom_link"===t?"link":"custom_text"===t?"string":t;if(w!==s.CHANNEL_TYPE.WHATSAPP){const a=p.getVariableNameForEmailByIndex(E+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===H?"template_html_mobile":"template_html_desktop"),o=w===s.CHANNEL_TYPE.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);o&&(o.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const u=q.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:n,updatedValue:e}):t));null==R||R(u)}if(w===s.CHANNEL_TYPE.WHATSAPP){const t=null===(a=q.body)||void 0===a?void 0:a.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:n,updatedValue:e}):t));null==R||R((e=>Object.assign(Object.assign({},e),{body:t,buttons:q.buttons})))}}function U(e,t){var l;const a=Object.assign({},Y),n=null===(l=null==a?void 0:a.components)||void 0===l?void 0:l.map((l=>{var a,n,i,o,u;const s=Object.assign({},l);if("BODY"===l.type&&(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0])){const l=[...null!==(u=null===(o=null===(i=s.example)||void 0===i?void 0:i.body_text)||void 0===o?void 0:o[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},s.example),{body_text:[l]});return Object.assign(Object.assign({},s),{example:a})}return l}));a.components=n,null==W||W(a)}return l.useEffect((()=>{P&&(null==m||m())}),[P]),l.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===H?"template_html_mobile":"template_html_desktop",o=document.getElementById(i),u=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(n=null==o?void 0:o.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);w===s.CHANNEL_TYPE.EMAIL&&(null==B||B(u))}()}),[I]),l.useEffect((()=>{var e;const t=[];let l=[];if(w===s.CHANNEL_TYPE.MESSAGE){const e=null!=$?$:[];f([{label:"",options:[x,g]},...e]),l=[{label:"",options:[x,g]},...e]}else{"link"===(null==h?void 0:h.type)?(t.push({label:"",options:[g,x]}),S(g)):(t.push({label:"",options:[g,x]}),S(x));const e=null!=$?$:[];f([...t,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:d.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),l=[...t,...e]}if((w===s.CHANNEL_TYPE.WHATSAPP||w===s.CHANNEL_TYPE.EMAIL||w===s.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(u.placeHolderNamePattern.test(h.updatedValue)&&w===s.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&w!==s.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===s.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");_?n={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}:t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(h,l,w);e.value&&S(e)}else(null===(e=h.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(S(g),C(h.updatedValue.split("https://")[1])):(S(x),C(h.updatedValue))}),[]),e.jsxs(b,Object.assign({channel:w,focused:P,onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:M&&!O?c.COLORS.content.negative:c.COLORS.content.primary}},{children:[null===(N=h.variableName)||void 0===N?void 0:N.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:_?e.jsx(o.Input,{state:"none",value:O?O.label:"Custom text",onChangeText:()=>{},rightIcon:{icon:()=>e.jsx(t.default,{onClick:()=>{V(!k)},width:24,height:24,color:c.COLORS.content.primary})}}):e.jsx(i.Dropdown,{options:L,isSearchable:!1,onSelect:z,defaultOptions:O?[Object.assign(Object.assign({},O),{selected:!0})]:[]})})),("custom_text"===(null==O?void 0:O.value)||"custom_link"===(null==O?void 0:O.value))&&e.jsx(o.Input,{labelText:"custom_text"===(null==O?void 0:O.value)?"Custom text value":"custom_link"===(null==O?void 0:O.value)?"Custom URL value":"",id:`variable-value-${null==O?void 0:O.value}-${E}`,value:y,errorMessage:M?y?"custom_link"!==O.value||y.match(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/)?y.length>30?"Length cannot be more that 30":0===y.trim().length?"Required field":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==O?void 0:O.value)?void 0:30,prefixText:"custom_link"===(null==O?void 0:O.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===O.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>function(e,t){var l;C(t);const a="custom_link"===(null==O?void 0:O.value)?`https://${t}`:t;D(a,e),w===s.CHANNEL_TYPE.WHATSAPP&&(null==U||U(null!==(l=h.index)&&void 0!==l?l:0,a))}(O.value,e)}),k&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=j?j:[],showVariable:k,setShowVariable:V,placeholder:"Add a variable",customTrigger:e=>{A(!1),"{{custom.url}}"===e.actualValue?z({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?z({label:e.displayName,selected:!0,value:"custom_text"}):z({label:e.actualValue.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../../assets/icons/info.svg.js"),t=require("react"),i=require("styled-components"),l=require("../../add-variableV2/AddVariableV2SideModal.js"),s=require("../../../assets/icons/plus.svg.js");require("../../add-variableV2/AddVariableV2.styled.js"),require("../../button/Button.js"),require("../../icon-button/IconButton.js");var r=require("../../input/Input.js"),o=require("../../tooltips/Tooltip.js"),n=require("../../../constants/Theme.js"),d=require("../../TypographyStyle.js"),c=require("../../checkBox/CheckBox.js"),u=require("../../template-preview/models/Channels.js"),h=require("../context/templateModalContext.js"),p=require("./VariableConnector.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=x(i);const g=b.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../../assets/icons/info.svg.js"),t=require("react"),i=require("styled-components"),s=require("../../add-variableV2/AddVariableV2SideModal.js"),l=require("../../../assets/icons/plus.svg.js");require("../../add-variableV2/AddVariableV2.styled.js"),require("../../button/Button.js"),require("../../icon-button/IconButton.js");var r=require("../../input/Input.js"),o=require("../../tooltips/Tooltip.js"),n=require("../../../constants/Theme.js"),d=require("../../TypographyStyle.js"),c=require("../../checkBox/CheckBox.js"),u=require("../../template-preview/models/Channels.js"),h=require("../context/templateModalContext.js"),p=require("./VariableConnector.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=x(i);const g=b.default.div`
2
2
  overflow-y: auto;
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -25,4 +25,4 @@
25
25
  display: flex;
26
26
  align-items: center;
27
27
  }
28
- `;exports.AddVariableStyled=j,exports.Container=g,exports.default=i=>{let{onFocus:x,showVariableModal:b,variableList:f,discountCode:v,setDiscountCode:y}=i;const{originalVariableList:m,channel:V}=h.useTemplateModalContext(),[O,C]=t.useState(!1),[w,S]=t.useState(!1),[k,q]=t.useState(!1),[T,L]=t.useState(!1),[B,E]=t.useState(""),A=t.useRef(),M=t.useRef();return t.useEffect((()=>{y&&y(v+B)}),[B]),t.useEffect((()=>{console.log("originalVariableList: ",m),m.forEach((e=>{console.log("variable.updatedValue: ",e.updatedValue),console.log("variable.value: ","checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")),"checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")&&(C(!0),v&&S(!0))})),console.log("showDiscountCheckBox: ",O)}),[m]),t.useEffect((()=>{console.log("showDiscountCheckBox22: ",O)}),[O]),e.jsxs(g,{children:[e.jsxs("div",Object.assign({style:{padding:8}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:8}},{children:[e.jsx(d.TitleRegular,Object.assign({style:{color:n.COLORS.content.primary}},{children:"Edit variables and links"})),e.jsx(o.Tooltip,Object.assign({body:"Variables are placeholder texts which can either be filled by data, eg: customer name or can have any custom text within them"},{children:e.jsx("div",{children:e.jsx(a.default,{width:20,height:20,color:n.COLORS.content.placeholder})})}))]})),e.jsx(d.BodySecondary,Object.assign({style:{color:n.COLORS.content.secondary}},{children:"You can view variables and links on the left underlined in purple colour."}))]})),null==m?void 0:m.map(((a,t)=>V!==u.CHANNEL_TYPE.EMAIL||a.isEditableVariable?e.jsx("div",Object.assign({style:{marginTop:16}},{children:e.jsx(p.default,{index:t,variable:a,onFocus:()=>null==x?void 0:x(t),showVariableModal:b,variableList:f,setShowDiscountCheckBox:C})}),t):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:n.COLORS.content.primary}},{children:["Locked variable ",t+1]})),e.jsx(r.Input,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),t))),(O||v)&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8}},{children:[e.jsx(c.CheckBox,{isChecked:w,onValueChange:()=>{S(!w)}}),e.jsx(d.TitleSmall,Object.assign({style:{marginLeft:8}},{children:"Add discount codes"}))]})),w&&e.jsxs("div",Object.assign({ref:A,style:{margin:10}},{children:[e.jsx(r.Input,{placeholder:"Enter your discount code",onChangeText:e=>{y&&y(e)},value:v,onFocus:()=>{q(!0)},onBlur:e=>{var a;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)?(A.current&&A.current.focus(),q(!0)):(q(!1),L(!1))}}),k&&e.jsx(j,Object.assign({ref:M,id:"addVar",onClick:e=>{e.stopPropagation(),L(!0)}},{children:e.jsxs("div",Object.assign({className:"add"},{children:[e.jsx(s.default,{width:20,height:20,color:"white"}),e.jsx("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),T&&e.jsx(l.AddVariableV2SideModal,{zIndex:2e3,data:null!=f?f:[],showVariable:T,setShowVariable:L,variableValue:B,setVariableValue:E,placeholder:"Add a variable",customTrigger:e=>{E(e.actualValue),q(!1)}})]})};
28
+ `;exports.AddVariableStyled=j,exports.Container=g,exports.default=i=>{let{onFocus:x,showVariableModal:b,variableList:f,discountCode:v,setDiscountCode:y}=i;const{originalVariableList:m,channel:V}=h.useTemplateModalContext(),[O,C]=t.useState(!1),[w,S]=t.useState(!1),[k,q]=t.useState(!1),[T,L]=t.useState(!1),[B,E]=t.useState(""),A=t.useRef(),I=t.useRef();return t.useEffect((()=>{y&&y(v+B)}),[B]),t.useEffect((()=>{console.log("originalVariableList: ",m),m.forEach((e=>{console.log("variable.updatedValue: ",e.updatedValue),console.log("variable.value: ","checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")),"checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")&&(C(!0),v&&S(!0))})),console.log("showDiscountCheckBox: ",O)}),[m]),t.useEffect((()=>{console.log("showDiscountCheckBox22: ",O)}),[O]),e.jsxs(g,{children:[e.jsxs("div",Object.assign({style:{padding:8}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:8,alignItems:"center",marginBottom:4}},{children:[e.jsx(d.TitleRegular,Object.assign({style:{color:n.COLORS.content.primary}},{children:"Edit variables and links"})),e.jsx(o.Tooltip,Object.assign({body:"Variables are placeholder texts which can either be filled by data, eg: customer name or can have any custom text within them"},{children:e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(a.default,{width:20,height:20,color:n.COLORS.content.placeholder})}))}))]})),e.jsx(d.BodySecondary,Object.assign({style:{color:n.COLORS.content.secondary}},{children:"You can view variables and links on the left underlined in purple colour."}))]})),null==m?void 0:m.map(((a,t)=>V!==u.CHANNEL_TYPE.EMAIL||a.isEditableVariable?e.jsx("div",Object.assign({style:{marginTop:16}},{children:e.jsx(p.default,{index:t,variable:a,onFocus:()=>null==x?void 0:x(t),showVariableModal:b,variableList:f,setShowDiscountCheckBox:C})}),t):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:n.COLORS.content.primary}},{children:["Locked variable ",t+1]})),e.jsx(r.Input,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),t))),(O||v)&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8}},{children:[e.jsx(c.CheckBox,{isChecked:w,onValueChange:()=>{S(!w)}}),e.jsx(d.TitleSmall,Object.assign({style:{marginLeft:8}},{children:"Add discount codes"}))]})),w&&e.jsxs("div",Object.assign({ref:A,style:{margin:10}},{children:[e.jsx(r.Input,{placeholder:"Enter your discount code",onChangeText:e=>{y&&y(e)},value:v,onFocus:()=>{q(!0)},onBlur:e=>{var a;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)?(A.current&&A.current.focus(),q(!0)):(q(!1),L(!1))}}),k&&e.jsx(j,Object.assign({ref:I,id:"addVar",onClick:e=>{e.stopPropagation(),L(!0)}},{children:e.jsxs("div",Object.assign({className:"add"},{children:[e.jsx(l.default,{width:20,height:20,color:"white"}),e.jsx("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),T&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=f?f:[],showVariable:T,setShowVariable:L,variableValue:B,setVariableValue:E,placeholder:"Add a variable",customTrigger:e=>{E(e.actualValue),q(!1)}})]})};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -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 o}from"react";import n from"styled-components";import{AddVariableV2SideModal as i}from"../../add-variableV2/AddVariableV2SideModal.js";import{Dropdown as u}from"../../dropdown/Dropdown.js";import{Input as s}from"../../input/Input.js";import{placeHolderNamePattern as r}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as d}from"../../template-preview/models/Channels.js";import{BodySecondary as c}from"../../TypographyStyle.js";import m from"../../../utils/StringUtils.js";import{COLORS as v}from"../../../constants/Theme.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as b}from"../utils/getVariableNameEmail.js";import{validateIsUrl as g}from"../utils/validateIsUrl.js";const h=n.div`
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 n from"styled-components";import{AddVariableV2SideModal as i}from"../../add-variableV2/AddVariableV2SideModal.js";import{Dropdown as u}from"../../dropdown/Dropdown.js";import{Input as s}from"../../input/Input.js";import{placeHolderNamePattern as r}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as d}from"../../template-preview/models/Channels.js";import{BodySecondary as c}from"../../TypographyStyle.js";import m from"../../../utils/StringUtils.js";import{COLORS as v}from"../../../constants/Theme.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as b}from"../utils/getVariableNameEmail.js";const g=n.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===d.EMAIL?v.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,x={value:"custom_link",label:"Custom URL"},f={value:"custom_text",label:"Custom text"},j=n=>{let{onFocus:j,variable:_,index:y,showVariableModal:k,variableList:V,setShowDiscountCheckBox:A}=n;var O;const[T,P]=a(!1),[S,E]=a(""),[C,L]=a([]),[w,M]=a(),[W,I]=a(!1),{device:H,channel:B,isError:N,originalVariableList:$,template:U,templateSelectionTriggered:R,setTemplate:D,setDisplayContent:z,setOriginalVariableList:G,globalNormalizedPlaceholders:q}=p();function F(e,l){var t,a,o;const n=e;E(""),M(n),B===d.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(Y(null!==(t=n.value)&&void 0!==t?t:"","string"),null==Z||Z(null!==(a=_.index)&&void 0!==a?a:0,`[[${n.value}]]`)):(null==Z||Z(null!==(o=_.index)&&void 0!==o?o:0,_.variableName),Y("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?Y(n.value,"url"===n.bikPlaceholderType?"link":"string"):(E(""),Y("",n.value))}function Y(e,l){var t,a;const o="custom_link"===l?"link":"custom_text"===l?"string":l;if(B!==d.WHATSAPP){const a=b(y+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===H?"template_html_mobile":"template_html_desktop"),i=B===d.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:_.variableName);const u=$.map(((l,t)=>t===y?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==G||G(u)}if(B===d.WHATSAPP){const l=null===(a=$.body)||void 0===a?void 0:a.map(((l,t)=>t===y?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==G||G((e=>Object.assign(Object.assign({},e),{body:l,buttons:$.buttons})))}}function Z(e,l){var t;const a=Object.assign({},U),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 t}));a.components=o,null==D||D(a)}return o((()=>{T&&(null==j||j())}),[T]),o((()=>{!function(){var e,l,t,a,o;const n="mobile"===H?"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);B===d.EMAIL&&(null==z||z(u))}()}),[R]),o((()=>{var e;const l=[];let t=[];if(B===d.MESSAGE){const e=null!=q?q:[];L([{label:"",options:[f,x]},...e]),t=[{label:"",options:[f,x]},...e]}else{"link"===(null==_?void 0:_.type)?(l.push({label:"",options:[x,f]}),M(x)):(l.push({label:"",options:[x,f]}),M(f));const e=null!=q?q:[];L([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:m.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]}if((B===d.WHATSAPP||B===d.EMAIL||B===d.MESSAGE)&&_.updatedValue)if(r.test(_.updatedValue)&&B===d.WHATSAPP||_.updatedValue.startsWith("{{")&&B!==d.WHATSAPP){const e=function(e,l,t){var a;let o={label:"",value:""};const n=t===d.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");k?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 o}(_,t,B);e.value&&M(e)}else(null===(e=_.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(M(x),E(_.updatedValue.split("https://")[1])):(M(f),E(_.updatedValue))}),[]),e(h,Object.assign({channel:B,focused:T,onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:e(c,Object.assign({style:{color:N&&!w?v.content.negative:v.content.primary}},{children:[null===(O=_.variableName)||void 0===O?void 0:O.replace("{{","").replace("}}","")," ","link"===(null==_?void 0:_.type)?"link":"variable"]}))})),l("div",Object.assign({style:{marginBottom:12}},{children:k?l(s,{state:"none",value:w?w.label:"Custom text",onChangeText:()=>{},rightIcon:{icon:()=>l(t,{onClick:()=>{I(!W)},width:24,height:24,color:v.content.primary})}}):l(u,{options:C,isSearchable:!1,onSelect:F,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(s,{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}-${y}`,value:S,errorMessage:N?S?"custom_link"!==w.value||g(S)?"":"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"===_.type||"custom_link"===w.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>function(e,l){var t;E(l);const a="custom_link"===(null==w?void 0:w.value)?`https://${l}`:l;Y(a,e),B===d.WHATSAPP&&(null==Z||Z(null!==(t=_.index)&&void 0!==t?t:0,a))}(w.value,e)}),W&&l(i,{zIndex:2e3,data:null!=V?V:[],showVariable:W,setShowVariable:I,placeholder:"Add a variable",customTrigger:e=>{A(!1),"{{custom.url}}"===e.actualValue?F({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?F({label:e.displayName,selected:!0,value:"custom_text"}):F({label:e.actualValue.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{h as Container,j as default};
7
+ `,h={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"},f=n=>{let{onFocus:f,variable:_,index:j,showVariableModal:y,variableList:k,setShowDiscountCheckBox:A}=n;var V;const[O,T]=a(!1),[P,S]=a(""),[w,E]=a([]),[L,C]=a(),[M,W]=a(!1),{device:I,channel:H,isError:B,originalVariableList:$,template:N,templateSelectionTriggered:z,setTemplate:R,setDisplayContent:U,setOriginalVariableList:D,globalNormalizedPlaceholders:Z}=p();function q(e,l){var t,a,o;const n=e;S(""),C(n),H===d.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(G(null!==(t=n.value)&&void 0!==t?t:"","string"),null==F||F(null!==(a=_.index)&&void 0!==a?a:0,`[[${n.value}]]`)):(null==F||F(null!==(o=_.index)&&void 0!==o?o:0,_.variableName),G("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?G(n.value,"url"===n.bikPlaceholderType?"link":"string"):(S(""),G("",n.value))}function G(e,l){var t,a;const o="custom_link"===l?"link":"custom_text"===l?"string":l;if(H!==d.WHATSAPP){const a=b(j+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===I?"template_html_mobile":"template_html_desktop"),i=H===d.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:_.variableName);const u=$.map(((l,t)=>t===j?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==D||D(u)}if(H===d.WHATSAPP){const l=null===(a=$.body)||void 0===a?void 0:a.map(((l,t)=>t===j?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):l));null==D||D((e=>Object.assign(Object.assign({},e),{body:l,buttons:$.buttons})))}}function F(e,l){var t;const a=Object.assign({},N),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 t}));a.components=o,null==R||R(a)}return o((()=>{O&&(null==f||f())}),[O]),o((()=>{!function(){var e,l,t,a,o;const n="mobile"===I?"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);H===d.EMAIL&&(null==U||U(u))}()}),[z]),o((()=>{var e;const l=[];let t=[];if(H===d.MESSAGE){const e=null!=Z?Z:[];E([{label:"",options:[x,h]},...e]),t=[{label:"",options:[x,h]},...e]}else{"link"===(null==_?void 0:_.type)?(l.push({label:"",options:[h,x]}),C(h)):(l.push({label:"",options:[h,x]}),C(x));const e=null!=Z?Z:[];E([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:m.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]}if((H===d.WHATSAPP||H===d.EMAIL||H===d.MESSAGE)&&_.updatedValue)if(r.test(_.updatedValue)&&H===d.WHATSAPP||_.updatedValue.startsWith("{{")&&H!==d.WHATSAPP){const e=function(e,l,t){var a;let o={label:"",value:""};const n=t===d.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");y?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 o}(_,t,H);e.value&&C(e)}else(null===(e=_.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(C(h),S(_.updatedValue.split("https://")[1])):(C(x),S(_.updatedValue))}),[]),e(g,Object.assign({channel:H,focused:O,onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:e(c,Object.assign({style:{color:B&&!L?v.content.negative:v.content.primary}},{children:[null===(V=_.variableName)||void 0===V?void 0:V.replace("{{","").replace("}}","")," ","link"===(null==_?void 0:_.type)?"link":"variable"]}))})),l("div",Object.assign({style:{marginBottom:12}},{children:y?l(s,{state:"none",value:L?L.label:"Custom text",onChangeText:()=>{},rightIcon:{icon:()=>l(t,{onClick:()=>{W(!M)},width:24,height:24,color:v.content.primary})}}):l(u,{options:w,isSearchable:!1,onSelect:q,defaultOptions:L?[Object.assign(Object.assign({},L),{selected:!0})]:[]})})),("custom_text"===(null==L?void 0:L.value)||"custom_link"===(null==L?void 0:L.value))&&l(s,{labelText:"custom_text"===(null==L?void 0:L.value)?"Custom text value":"custom_link"===(null==L?void 0:L.value)?"Custom URL value":"",id:`variable-value-${null==L?void 0:L.value}-${j}`,value:P,errorMessage:B?P?"custom_link"!==L.value||P.match(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/)?P.length>30?"Length cannot be more that 30":0===P.trim().length?"Required field":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==L?void 0:L.value)?void 0:30,prefixText:"custom_link"===(null==L?void 0:L.value)?"https://":"",placeholder:"link"===_.type||"custom_link"===L.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>function(e,l){var t;S(l);const a="custom_link"===(null==L?void 0:L.value)?`https://${l}`:l;G(a,e),H===d.WHATSAPP&&(null==F||F(null!==(t=_.index)&&void 0!==t?t:0,a))}(L.value,e)}),M&&l(i,{zIndex:2e3,data:null!=k?k:[],showVariable:M,setShowVariable:W,placeholder:"Add a variable",customTrigger:e=>{A(!1),"{{custom.url}}"===e.actualValue?q({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?q({label:e.displayName,selected:!0,value:"custom_text"}):q({label:e.actualValue.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{g as Container,f as default};
@@ -1,9 +1,9 @@
1
- import{jsxs as e,jsx as o}from"react/jsx-runtime";import a from"../../../assets/icons/info.svg.js";import{useState as i,useRef as t,useEffect as l}from"react";import r from"styled-components";import{AddVariableV2SideModal as n}from"../../add-variableV2/AddVariableV2SideModal.js";import s from"../../../assets/icons/plus.svg.js";import"../../add-variableV2/AddVariableV2.styled.js";import"../../button/Button.js";import"../../icon-button/IconButton.js";import{Input as c}from"../../input/Input.js";import{Tooltip as d}from"../../tooltips/Tooltip.js";import{COLORS as p}from"../../../constants/Theme.js";import{TitleRegular as h,BodySecondary as u,TitleSmall as m}from"../../TypographyStyle.js";import{CheckBox as b}from"../../checkBox/CheckBox.js";import{CHANNEL_TYPE as g}from"../../template-preview/models/Channels.js";import{useTemplateModalContext as f}from"../context/templateModalContext.js";import v from"./VariableConnector.js";const x=r.div`
1
+ import{jsxs as e,jsx as o}from"react/jsx-runtime";import a from"../../../assets/icons/info.svg.js";import{useState as i,useRef as t,useEffect as l}from"react";import r from"styled-components";import{AddVariableV2SideModal as n}from"../../add-variableV2/AddVariableV2SideModal.js";import s from"../../../assets/icons/plus.svg.js";import"../../add-variableV2/AddVariableV2.styled.js";import"../../button/Button.js";import"../../icon-button/IconButton.js";import{Input as c}from"../../input/Input.js";import{Tooltip as d}from"../../tooltips/Tooltip.js";import{COLORS as p}from"../../../constants/Theme.js";import{TitleRegular as h,BodySecondary as m,TitleSmall as u}from"../../TypographyStyle.js";import{CheckBox as g}from"../../checkBox/CheckBox.js";import{CHANNEL_TYPE as b}from"../../template-preview/models/Channels.js";import{useTemplateModalContext as f}from"../context/templateModalContext.js";import v from"./VariableConnector.js";const x=r.div`
2
2
  overflow-y: auto;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  height: 100%;
6
- `,j=r=>{let{onFocus:j,showVariableModal:V,variableList:w,discountCode:k,setDiscountCode:C}=r;const{originalVariableList:O,channel:T}=f(),[B,L]=i(!1),[A,D]=i(!1),[E,I]=i(!1),[M,S]=i(!1),[F,N]=i(""),z=t(),U=t();return l((()=>{C&&C(k+F)}),[F]),l((()=>{console.log("originalVariableList: ",O),O.forEach((e=>{console.log("variable.updatedValue: ",e.updatedValue),console.log("variable.value: ","checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")),"checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")&&(L(!0),k&&D(!0))})),console.log("showDiscountCheckBox: ",B)}),[O]),l((()=>{console.log("showDiscountCheckBox22: ",B)}),[B]),e(x,{children:[e("div",Object.assign({style:{padding:8}},{children:[e("div",Object.assign({style:{display:"flex",gap:8}},{children:[o(h,Object.assign({style:{color:p.content.primary}},{children:"Edit variables and links"})),o(d,Object.assign({body:"Variables are placeholder texts which can either be filled by data, eg: customer name or can have any custom text within them"},{children:o("div",{children:o(a,{width:20,height:20,color:p.content.placeholder})})}))]})),o(u,Object.assign({style:{color:p.content.secondary}},{children:"You can view variables and links on the left underlined in purple colour."}))]})),null==O?void 0:O.map(((a,i)=>T!==g.EMAIL||a.isEditableVariable?o("div",Object.assign({style:{marginTop:16}},{children:o(v,{index:i,variable:a,onFocus:()=>null==j?void 0:j(i),showVariableModal:V,variableList:w,setShowDiscountCheckBox:L})}),i):e("div",Object.assign({style:{margin:"16px 8px"}},{children:[e(u,Object.assign({style:{color:p.content.primary}},{children:["Locked variable ",i+1]})),o(c,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),i))),(B||k)&&e("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8}},{children:[o(b,{isChecked:A,onValueChange:()=>{D(!A)}}),o(m,Object.assign({style:{marginLeft:8}},{children:"Add discount codes"}))]})),A&&e("div",Object.assign({ref:z,style:{margin:10}},{children:[o(c,{placeholder:"Enter your discount code",onChangeText:e=>{C&&C(e)},value:k,onFocus:()=>{I(!0)},onBlur:e=>{var o;"addVar"===(null===(o=e.relatedTarget)||void 0===o?void 0:o.id)?(z.current&&z.current.focus(),I(!0)):(I(!1),S(!1))}}),E&&o(y,Object.assign({ref:U,id:"addVar",onClick:e=>{e.stopPropagation(),S(!0)}},{children:e("div",Object.assign({className:"add"},{children:[o(s,{width:20,height:20,color:"white"}),o("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),M&&o(n,{zIndex:2e3,data:null!=w?w:[],showVariable:M,setShowVariable:S,variableValue:F,setVariableValue:N,placeholder:"Add a variable",customTrigger:e=>{N(e.actualValue),I(!1)}})]})},y=r.button`
6
+ `,y=r=>{let{onFocus:y,showVariableModal:V,variableList:w,discountCode:k,setDiscountCode:O}=r;const{originalVariableList:C,channel:B}=f(),[T,L]=i(!1),[A,I]=i(!1),[D,E]=i(!1),[M,S]=i(!1),[F,N]=i(""),z=t(),U=t();return l((()=>{O&&O(k+F)}),[F]),l((()=>{console.log("originalVariableList: ",C),C.forEach((e=>{console.log("variable.updatedValue: ",e.updatedValue),console.log("variable.value: ","checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")),"checkout.checkoutUrl"===e.updatedValue.replace("{{","").replace("}}","")&&(L(!0),k&&I(!0))})),console.log("showDiscountCheckBox: ",T)}),[C]),l((()=>{console.log("showDiscountCheckBox22: ",T)}),[T]),e(x,{children:[e("div",Object.assign({style:{padding:8}},{children:[e("div",Object.assign({style:{display:"flex",gap:8,alignItems:"center",marginBottom:4}},{children:[o(h,Object.assign({style:{color:p.content.primary}},{children:"Edit variables and links"})),o(d,Object.assign({body:"Variables are placeholder texts which can either be filled by data, eg: customer name or can have any custom text within them"},{children:o("div",Object.assign({style:{display:"flex"}},{children:o(a,{width:20,height:20,color:p.content.placeholder})}))}))]})),o(m,Object.assign({style:{color:p.content.secondary}},{children:"You can view variables and links on the left underlined in purple colour."}))]})),null==C?void 0:C.map(((a,i)=>B!==b.EMAIL||a.isEditableVariable?o("div",Object.assign({style:{marginTop:16}},{children:o(v,{index:i,variable:a,onFocus:()=>null==y?void 0:y(i),showVariableModal:V,variableList:w,setShowDiscountCheckBox:L})}),i):e("div",Object.assign({style:{margin:"16px 8px"}},{children:[e(m,Object.assign({style:{color:p.content.primary}},{children:["Locked variable ",i+1]})),o(c,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),i))),(T||k)&&e("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8}},{children:[o(g,{isChecked:A,onValueChange:()=>{I(!A)}}),o(u,Object.assign({style:{marginLeft:8}},{children:"Add discount codes"}))]})),A&&e("div",Object.assign({ref:z,style:{margin:10}},{children:[o(c,{placeholder:"Enter your discount code",onChangeText:e=>{O&&O(e)},value:k,onFocus:()=>{E(!0)},onBlur:e=>{var o;"addVar"===(null===(o=e.relatedTarget)||void 0===o?void 0:o.id)?(z.current&&z.current.focus(),E(!0)):(E(!1),S(!1))}}),D&&o(j,Object.assign({ref:U,id:"addVar",onClick:e=>{e.stopPropagation(),S(!0)}},{children:e("div",Object.assign({className:"add"},{children:[o(s,{width:20,height:20,color:"white"}),o("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),M&&o(n,{zIndex:2e3,data:null!=w?w:[],showVariable:M,setShowVariable:S,variableValue:F,setVariableValue:N,placeholder:"Add a variable",customTrigger:e=>{N(e.actualValue),E(!1)}})]})},j=r.button`
7
7
  padding: 2px 8px;
8
8
  cursor: pointer;
9
9
  color: white;
@@ -25,4 +25,4 @@ import{jsxs as e,jsx as o}from"react/jsx-runtime";import a from"../../../assets/
25
25
  display: flex;
26
26
  align-items: center;
27
27
  }
28
- `;export{y as AddVariableStyled,x as Container,j as default};
28
+ `;export{j as AddVariableStyled,x as Container,y as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.314-beta.10",
3
+ "version": "0.0.314-beta.13",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",