@bikdotai/bik-component-library 0.0.66 → 0.0.67
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/VariableConnector.js +3 -3
- package/dist/cjs/components/template-preview/EmailTemplateThumbnailPreview.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +1 -1
- package/dist/esm/components/template-preview/EmailTemplateThumbnailPreview.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("styled-components"),n=require("../../dropdown/Dropdown.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("styled-components"),n=require("../../dropdown/Dropdown.js"),i=require("../../input/Input.js"),o=require("../../template-preview/constants/regexPatterns.js"),a=require("../../template-preview/models/Channels.js"),u=require("../../TypographyStyle.js"),s=require("../../../utils/StringUtils.js"),r=require("../../../constants/Theme.js"),d=require("../context/templateModalContext.js"),c=require("../utils/getVariableNameEmail.js"),v=require("../utils/validateIsUrl.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const m=p(l).default.div`
|
|
2
2
|
/* surface/$color-background-warning-light */
|
|
3
3
|
|
|
4
|
-
background: ${e=>e.focused&&e.channel===
|
|
4
|
+
background: ${e=>e.focused&&e.channel===a.CHANNEL_TYPE.EMAIL?r.COLORS.background.warning.light:"transparent"};
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
padding: 8px 10px;
|
|
7
|
-
`,b={value:"custom_link",label:"Custom URL"},
|
|
7
|
+
`,b={value:"custom_link",label:"Custom URL"},g={value:"custom_text",label:"Custom text"};exports.Container=m,exports.default=l=>{let{onFocus:p,variable:E,index:_}=l;var x;const[j,A]=t.useState(!1),[P,N]=t.useState(""),[h,T]=t.useState([]),[f,y]=t.useState(),{device:L,channel:C,isError:O,originalVariableList:k,template:H,templateSelectionTriggered:S,setTemplate:Y,setDisplayContent:q,setOriginalVariableList:M,globalNormalizedPlaceholders:I}=d.useTemplateModalContext();function V(e,t){var l,n;const i="custom_link"===t?"link":"custom_text"===t?"string":t;if(C!==a.CHANNEL_TYPE.WHATSAPP){const n=c.getVariableNameForEmailByIndex(_+1),o=null===document||void 0===document?void 0:document.getElementById("mobile"===L?"template_html_mobile":"template_html_desktop"),u=C===a.CHANNEL_TYPE.EMAIL?null===(l=null==o?void 0:o.contentWindow)||void 0===l?void 0:l.document.getElementById(n):document.getElementById(n);u&&(u.textContent="custom_text"!==t&&"custom_link"!==t||e?e:E.variableName);const s=k.map(((t,l)=>l===_?Object.assign(Object.assign({},t),{type:i,updatedValue:e}):t));null==M||M(s)}if(C===a.CHANNEL_TYPE.WHATSAPP){const t=null===(n=k.body)||void 0===n?void 0:n.map(((t,l)=>l===_?Object.assign(Object.assign({},t),{type:i,updatedValue:e}):t));null==M||M((e=>Object.assign(Object.assign({},e),{body:t,buttons:k.buttons})))}}function W(e,t){var l;const n=Object.assign({},H),i=null===(l=null==n?void 0:n.components)||void 0===l?void 0:l.map((l=>{var n,i,o,a,u;const s=Object.assign({},l);if("BODY"===l.type&&(null===(i=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===i?void 0:i[0])){const l=[...null!==(u=null===(a=null===(o=s.example)||void 0===o?void 0:o.body_text)||void 0===a?void 0:a[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const n=Object.assign(Object.assign({},s.example),{body_text:[l]});return Object.assign(Object.assign({},s),{example:n})}return l}));n.components=i,null==Y||Y(n)}return t.useEffect((()=>{j&&(null==p||p())}),[j]),t.useEffect((()=>{!function(){var e,t,l,n,i;const o="mobile"===L?"template_html_mobile":"template_html_desktop",u=document.getElementById(o),s=(null!==(n=null===(l=null===(t=null===(e=null==u?void 0:u.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==n?n:"")+(null===(i=null==u?void 0:u.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);C===a.CHANNEL_TYPE.EMAIL&&(null==q||q(s))}()}),[S]),t.useEffect((()=>{var e;const t=[];let l=[];if(C===a.CHANNEL_TYPE.MESSAGE){const e=null!=I?I:[];T([{label:"",options:[g,b]},...e]),l=[{label:"",options:[g,b]},...e]}else{"link"===(null==E?void 0:E.type)?(t.push({label:"",options:[b,g]}),y(b)):(t.push({label:"",options:[b,g]}),y(g));const e=null!=I?I:[];T([...t,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:s.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((C===a.CHANNEL_TYPE.WHATSAPP||C===a.CHANNEL_TYPE.EMAIL||C===a.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(o.placeHolderNamePattern.test(E.updatedValue)&&C===a.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&C!==a.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){let n={label:"",value:""};const i=l===a.CHANNEL_TYPE.WHATSAPP?e.replace("[[","").replace("]]",""):e.replace("{{","").replace("}}","");return 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)}))})),n}(E.updatedValue,l,C);e.value&&y(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(y(b),N(E.updatedValue.split("https://")[1])):(y(g),N(E.updatedValue))}),[]),e.jsxs(m,Object.assign({channel:C,focused:j,onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(u.BodySecondary,Object.assign({style:{color:O&&!f?r.COLORS.content.negative:r.COLORS.content.primary}},{children:[null===(x=E.variableName)||void 0===x?void 0:x.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(n.Dropdown,{options:h,isSearchable:!1,onSelect:function(e,t){var l,n,i;const o=e;N(""),y(o),C===a.CHANNEL_TYPE.WHATSAPP?"custom_text"!==o.value&&"custom_link"!==o.value?(V(null!==(l=o.value)&&void 0!==l?l:"","string"),null==W||W(null!==(n=E.index)&&void 0!==n?n:0,`[[${o.value}]]`)):(null==W||W(null!==(i=E.index)&&void 0!==i?i:0,E.variableName),V("","url"===o.bikPlaceholderType?"link":"string")):"custom_text"!==o.value&&"custom_link"!==o.value?V(o.value,"url"===o.bikPlaceholderType?"link":"string"):(N(""),V("",o.value))},defaultOptions:f?[Object.assign(Object.assign({},f),{selected:!0})]:[]})})),("custom_text"===(null==f?void 0:f.value)||"custom_link"===(null==f?void 0:f.value))&&e.jsx(i.Input,{labelText:"custom_text"===(null==f?void 0:f.value)?"Custom text value":"custom_link"===(null==f?void 0:f.value)?"Custom URL value":"",id:`variable-value-${null==f?void 0:f.value}-${_}`,value:P,errorMessage:O?P?"custom_link"!==f.value||v.validateIsUrl(P)?"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==f?void 0:f.value)?void 0:30,prefixText:"custom_link"===(null==f?void 0:f.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===f.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>function(e,t){var l;N(t);const n="custom_link"===(null==f?void 0:f.value)?`https://${t}`:t;V(n,e),C===a.CHANNEL_TYPE.WHATSAPP&&(null==W||W(null!==(l=E.index)&&void 0!==l?l:0,n))}(f.value,e)})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../button/Button.js"),i=require("../TypographyStyle.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../button/Button.js"),i=require("../TypographyStyle.js"),r=require("./EmailTemplatePreview.styled.js");exports.default=n=>{let{template:l,handleViewTemplate:a,hideHeader:s,hideViewButton:d,containerStyle:o,emailHtmlContainerId:u,emailDisplayContent:c}=n;return e.jsxs(r.EmailContainer,Object.assign({hideHeader:s,style:Object.assign({},null!=o?o:{})},{children:[!s&&e.jsx(r.Header,{children:e.jsx(i.TitleRegular,Object.assign({style:{maxWidth:"100%"}},{children:l.name}))}),c?e.jsx("iframe",{title:"Email template preview",id:null!=u?u:"",width:"100%",srcDoc:c,height:"100%",style:{pointerEvents:"none"}}):e.jsx(r.ImageContainer,Object.assign({hideHeader:s},{children:e.jsx("img",{alt:"",src:l.thumbnailUrl,style:{objectFit:"contain",width:"100%"}})})),!d&&e.jsx(r.ViewButton,{children:e.jsx(t.Button,{buttonType:"tertiary",buttonText:"View",onClick:()=>{a&&a()}})})]}))};
|
|
@@ -4,4 +4,4 @@ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect
|
|
|
4
4
|
background: ${e=>e.focused&&e.channel===u.EMAIL?c.background.warning.light:"transparent"};
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
padding: 8px 10px;
|
|
7
|
-
`,g={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"},
|
|
7
|
+
`,g={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"},h=o=>{let{onFocus:h,variable:f,index:j}=o;var _;const[y,k]=l(!1),[A,O]=l(""),[P,T]=l([]),[E,S]=l(),{device:L,channel:W,isError:C,originalVariableList:M,template:V,templateSelectionTriggered:w,setTemplate:H,setDisplayContent:I,setOriginalVariableList:B,globalNormalizedPlaceholders:$}=m();function U(e,t){var l,n;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(W!==u.WHATSAPP){const n=v(j+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===L?"template_html_mobile":"template_html_desktop"),a=W===u.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(n):document.getElementById(n);a&&(a.textContent="custom_text"!==t&&"custom_link"!==t||e?e:f.variableName);const s=M.map(((t,l)=>l===j?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==B||B(s)}if(W===u.WHATSAPP){const t=null===(n=M.body)||void 0===n?void 0:n.map(((t,l)=>l===j?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==B||B((e=>Object.assign(Object.assign({},e),{body:t,buttons:M.buttons})))}}function N(e,t){var l;const n=Object.assign({},V),o=null===(l=null==n?void 0:n.components)||void 0===l?void 0:l.map((l=>{var n,o,i,a,s;const u=Object.assign({},l);if("BODY"===l.type&&(null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])){const l=[...null!==(s=null===(a=null===(i=u.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const n=Object.assign(Object.assign({},u.example),{body_text:[l]});return Object.assign(Object.assign({},u),{example:n})}return l}));n.components=o,null==H||H(n)}return n((()=>{y&&(null==h||h())}),[y]),n((()=>{!function(){var e,t,l,n,o;const i="mobile"===L?"template_html_mobile":"template_html_desktop",a=document.getElementById(i),s=(null!==(n=null===(l=null===(t=null===(e=null==a?void 0:a.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==n?n:"")+(null===(o=null==a?void 0:a.contentWindow)||void 0===o?void 0:o.document.head.innerHTML);W===u.EMAIL&&(null==I||I(s))}()}),[w]),n((()=>{var e;const t=[];let l=[];if(W===u.MESSAGE){const e=null!=$?$:[];T([{label:"",options:[x,g]},...e]),l=[{label:"",options:[x,g]},...e]}else{"link"===(null==f?void 0:f.type)?(t.push({label:"",options:[g,x]}),S(g)):(t.push({label:"",options:[g,x]}),S(x));const e=null!=$?$:[];T([...t,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:d.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===u.WHATSAPP||W===u.EMAIL||W===u.MESSAGE)&&f.updatedValue)if(s.test(f.updatedValue)&&W===u.WHATSAPP||f.updatedValue.startsWith("{{")&&W!==u.WHATSAPP){const e=function(e,t,l){let n={label:"",value:""};const o=l===u.WHATSAPP?e.replace("[[","").replace("]]",""):e.replace("{{","").replace("}}","");return t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===o.trim()&&(n=e)}))})),n}(f.updatedValue,l,W);e.value&&S(e)}else(null===(e=f.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(S(g),O(f.updatedValue.split("https://")[1])):(S(x),O(f.updatedValue))}),[]),e(b,Object.assign({channel:W,focused:y,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(r,Object.assign({style:{color:C&&!E?c.content.negative:c.content.primary}},{children:[null===(_=f.variableName)||void 0===_?void 0:_.replace("{{","").replace("}}","")," ","link"===(null==f?void 0:f.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(i,{options:P,isSearchable:!1,onSelect:function(e,t){var l,n,o;const i=e;O(""),S(i),W===u.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(U(null!==(l=i.value)&&void 0!==l?l:"","string"),null==N||N(null!==(n=f.index)&&void 0!==n?n:0,`[[${i.value}]]`)):(null==N||N(null!==(o=f.index)&&void 0!==o?o:0,f.variableName),U("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?U(i.value,"url"===i.bikPlaceholderType?"link":"string"):(O(""),U("",i.value))},defaultOptions:E?[Object.assign(Object.assign({},E),{selected:!0})]:[]})})),("custom_text"===(null==E?void 0:E.value)||"custom_link"===(null==E?void 0:E.value))&&t(a,{labelText:"custom_text"===(null==E?void 0:E.value)?"Custom text value":"custom_link"===(null==E?void 0:E.value)?"Custom URL value":"",id:`variable-value-${null==E?void 0:E.value}-${j}`,value:A,errorMessage:C?A?"custom_link"!==E.value||p(A)?"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==E?void 0:E.value)?void 0:30,prefixText:"custom_link"===(null==E?void 0:E.value)?"https://":"",placeholder:"link"===f.type||"custom_link"===E.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>function(e,t){var l;O(t);const n="custom_link"===(null==E?void 0:E.value)?`https://${t}`:t;U(n,e),W===u.WHATSAPP&&(null==N||N(null!==(l=f.index)&&void 0!==l?l:0,n))}(E.value,e)})]}))};export{b as Container,h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Button as i}from"../button/Button.js";import{TitleRegular as n}from"../TypographyStyle.js";import{EmailContainer as l,Header as r,ImageContainer as a,ViewButton as o}from"./EmailTemplatePreview.styled.js";const
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Button as i}from"../button/Button.js";import{TitleRegular as n}from"../TypographyStyle.js";import{EmailContainer as l,Header as r,ImageContainer as a,ViewButton as o}from"./EmailTemplatePreview.styled.js";const m=m=>{let{template:s,handleViewTemplate:d,hideHeader:c,hideViewButton:h,containerStyle:p,emailHtmlContainerId:y,emailDisplayContent:u}=m;return e(l,Object.assign({hideHeader:c,style:Object.assign({},null!=p?p:{})},{children:[!c&&t(r,{children:t(n,Object.assign({style:{maxWidth:"100%"}},{children:s.name}))}),u?t("iframe",{title:"Email template preview",id:null!=y?y:"",width:"100%",srcDoc:u,height:"100%",style:{pointerEvents:"none"}}):t(a,Object.assign({hideHeader:c},{children:t("img",{alt:"",src:s.thumbnailUrl,style:{objectFit:"contain",width:"100%"}})})),!h&&t(o,{children:t(i,{buttonType:"tertiary",buttonText:"View",onClick:()=>{d&&d()}})})]}))};export{m as default};
|