@bikdotai/bik-component-library 0.0.433-beta.18 → 0.0.433-beta.19

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.
@@ -41,5 +41,6 @@ export interface TemplateContextMapperProps {
41
41
  fetchProducts: any;
42
42
  storeId: string;
43
43
  };
44
+ disableEditExpiry?: boolean;
44
45
  }
45
- export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras, pickerConf, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
46
+ export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras, pickerConf, disableEditExpiry, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),o=require("../template-preview/models/Channels.js"),s=require("./context/templateModalContext.js"),r=require("./modalElements/Footer.js"),i=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:u,closeDialog:c,showVariableMapping:p,channel:m,htmlContent:v,templateVariables:C,onTemplateSelect:h,globalPlaceholders:S,showOnlyContent:b,whatsappSpecificPickerMeta:x,zIndex:g,showVariableModal:T,variableList:E,discountCode:P,setDiscountCode:j,onBackPress:M,enabledCustomText:L,variableListForImage:I,showSampleValues:f,disableEditVariable:w,pod:A,extras:y,pickerConf:N}=d;var V,k,q,H,_,D;t.useEffect((()=>{W(v)}),[v]);const O=m===o.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(k=null===(V=u.components)||void 0===V?void 0:V[1])||void 0===k?void 0:k.type),[F,Y]=t.useState(m===o.CHANNEL_TYPE.EMAIL||O?"desktop":"mobile"),[B,W]=t.useState(v),[z,U]=t.useState(!1),[$,R]=t.useState([]),[G,J]=t.useState(u),[K,Q]=t.useState(null!=C?C:[]),[X,Z]=t.useState(!1),[ee,te]=t.useState(-1);const le=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(S)),[S]);return e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:G,setTemplate:J,device:F,setDevice:Y,display_content:B,setDisplayContent:W,originalVariableList:K,setOriginalVariableList:Q,isError:z,setIsError:U,channel:m,globalNormalizedPlaceholders:le,templateSelectionTriggered:X,setTemplateSelectionTriggered:Z,enabledCustomText:L,disableEditVariable:w,pod:A,extras:y,isWhatsappCarousel:O,selectedCarouselIndex:ee,setSelectedCarouselIndex:te,isProductCarouselType:u.isProductCarouselType,cardCount:null===(H=null===(q=u.components)||void 0===q?void 0:q[1].cards)||void 0===H?void 0:H.length,errorIndexes:$,setErrorIndexes:R,pickerConf:N}},{children:b?e.jsx(i.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:g,centralContainerStyles:{width:O?900:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:800},open:!0,onClose:()=>{null==c||c()},headingTitle:null==G?void 0:G.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(_=null==G?void 0:G.category)&&void 0!==_?_:"")} • ${null!==(D=null==G?void 0:G.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==M||M()}},{children:[e.jsx(i.default,{showSampleValues:f,showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:x,showVariableModal:T,variableList:E,discountCode:P,setDiscountCode:j,variableListForImage:I&&(null==I?void 0:I.length)>0?I:E}),h?e.jsx(r.default,{isWhatsappCarousel:null!=O&&O,onSelect:function(){const e=null==h?void 0:h(G,K,null!=B?B:"");(null==e?void 0:e.errorIndexes)?R(e.errorIndexes):(null==e?void 0:e.error)?U(!!(null==e?void 0:e.error)):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"),r=require("./modalElements/Footer.js"),i=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:u,closeDialog:c,showVariableMapping:p,channel:m,htmlContent:v,templateVariables:C,onTemplateSelect:h,globalPlaceholders:b,showOnlyContent:x,whatsappSpecificPickerMeta:E,zIndex:S,showVariableModal:g,variableList:T,discountCode:P,setDiscountCode:j,onBackPress:M,enabledCustomText:L,variableListForImage:y,showSampleValues:I,disableEditVariable:f,pod:w,extras:A,pickerConf:N,disableEditExpiry:V}=d;var k,q,H,_,D,O;t.useEffect((()=>{z(v)}),[v]);const F=m===o.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(q=null===(k=u.components)||void 0===k?void 0:k[1])||void 0===q?void 0:q.type),[Y,B]=t.useState(m===o.CHANNEL_TYPE.EMAIL||F?"desktop":"mobile"),[W,z]=t.useState(v),[U,$]=t.useState(!1),[R,G]=t.useState([]),[J,K]=t.useState(u),[Q,X]=t.useState(null!=C?C:[]),[Z,ee]=t.useState(!1),[te,le]=t.useState(-1);const ae=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(b)),[b]);return e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:J,setTemplate:K,device:Y,setDevice:B,display_content:W,setDisplayContent:z,originalVariableList:Q,setOriginalVariableList:X,isError:U,setIsError:$,channel:m,globalNormalizedPlaceholders:ae,templateSelectionTriggered:Z,setTemplateSelectionTriggered:ee,enabledCustomText:L,disableEditVariable:f,pod:w,extras:A,isWhatsappCarousel:F,selectedCarouselIndex:te,setSelectedCarouselIndex:le,isProductCarouselType:u.isProductCarouselType,cardCount:null===(_=null===(H=u.components)||void 0===H?void 0:H[1].cards)||void 0===_?void 0:_.length,errorIndexes:R,setErrorIndexes:G,pickerConf:N,disableEditExpiry:V}},{children:x?e.jsx(i.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:S,centralContainerStyles:{width:F?900:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:800},open:!0,onClose:()=>{null==c||c()},headingTitle:null==J?void 0:J.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(D=null==J?void 0:J.category)&&void 0!==D?D:"")} • ${null!==(O=null==J?void 0:J.templateCategory)&&void 0!==O?O:""}`:"",onBackPress:()=>{null==M||M()}},{children:[e.jsx(i.default,{showSampleValues:I,showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:E,showVariableModal:g,variableList:T,discountCode:P,setDiscountCode:j,variableListForImage:y&&(null==y?void 0:y.length)>0?y:T}),h?e.jsx(r.default,{isWhatsappCarousel:null!=F&&F,onSelect:function(){const e=null==h?void 0:h(J,Q,null!=W?W:"");(null==e?void 0:e.errorIndexes)?G(e.errorIndexes):(null==e?void 0:e.error)?$(!!(null==e?void 0:e.error)):ee(!0)}}):e.jsx(e.Fragment,{})]}))}))};
@@ -40,6 +40,7 @@ export declare const TemplateModalContext: React.Context<{
40
40
  fetchProducts: any;
41
41
  storeId: string;
42
42
  } | undefined;
43
+ disableEditExpiry?: boolean | undefined;
43
44
  }>;
44
45
  export declare const useTemplateModalContext: () => {
45
46
  device: DEVICE_TYPES;
@@ -75,4 +76,5 @@ export declare const useTemplateModalContext: () => {
75
76
  fetchProducts: any;
76
77
  storeId: string;
77
78
  } | undefined;
79
+ disableEditExpiry?: boolean | undefined;
78
80
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../template-preview/models/Channels.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=l(e).default.createContext({device:"desktop",templateSelectionTriggered:!1,display_content:null,originalVariableList:[],channel:t.CHANNEL_TYPE.EMAIL,template:null,isError:!1,enabledCustomText:!1,disableEditVariable:!1});exports.TemplateModalContext=a,exports.useTemplateModalContext=()=>e.useContext(a);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../template-preview/models/Channels.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=l(e).default.createContext({device:"desktop",templateSelectionTriggered:!1,display_content:null,originalVariableList:[],channel:t.CHANNEL_TYPE.EMAIL,template:null,isError:!1,enabledCustomText:!1,disableEditVariable:!1,disableEditExpiry:!1});exports.TemplateModalContext=a,exports.useTemplateModalContext=()=>e.useContext(a);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("lodash"),n=require("react"),i=require("styled-components"),s=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../custom-date-time/CustomDateTime.js"),u=require("../../dropdown/Dropdown.js"),d=require("../../input/Input.js"),r=require("../../product-picker-v2/collectionScreen.js"),c=require("../../template-preview/constants/regexPatterns.js"),p=require("../../template-preview/models/Channels.js"),m=require("../../template-preview/models/WhatsAppTemplate.js"),v=require("../../TypographyStyle.js"),b=require("../../../utils/StringUtils.js"),g=require("../../../constants/Theme.js"),j=require("../context/templateModalContext.js"),O=require("../utils/getVariableNameEmail.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=x(i);const y=h.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("date-fns"),a=require("lodash"),i=require("react"),n=require("styled-components"),s=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../custom-date-time/CustomDateTime.js"),u=require("../../dropdown/Dropdown.js"),d=require("../../input/Input.js"),r=require("../../product-picker-v2/collectionScreen.js"),c=require("../../template-preview/constants/regexPatterns.js"),p=require("../../template-preview/models/Channels.js"),m=require("../../template-preview/models/WhatsAppTemplate.js"),v=require("../../TypographyStyle.js"),b=require("../../../utils/StringUtils.js"),g=require("../../../constants/Theme.js"),j=require("../context/templateModalContext.js"),O=require("../utils/getVariableNameEmail.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=x(n);const y=h.default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===p.CHANNEL_TYPE.EMAIL?g.COLORS.background.warning.light:"transparent"};
@@ -13,4 +13,4 @@
13
13
  background-color: rgba(0, 0, 0, 0.1);
14
14
  z-index: 1000;
15
15
  cursor: not-allowed;
16
- `,f={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"};exports.Container=y,exports.default=i=>{let{onFocus:x,variable:h,index:A,showVariableModal:C,variableList:N,setShowDiscountCheckBox:S,componentType:V,CTAoptions:P}=i;var k,L;const[H,w]=n.useState(!1),[D,B]=n.useState(""),[q,Y]=n.useState([]),[M,R]=n.useState(),[U,I]=n.useState(!1),[W,$]=n.useState(!1),{device:z,channel:Z,isError:F,originalVariableList:G,template:K,templateSelectionTriggered:J,setTemplate:Q,setDisplayContent:X,setOriginalVariableList:ee,globalNormalizedPlaceholders:te,enabledCustomText:le,pod:ae,selectedCarouselIndex:ne,isProductCarouselType:ie,disableEditVariable:se}=j.useTemplateModalContext();function oe(){var e,t;const l=[];let a=[];if(Z!==p.CHANNEL_TYPE.MESSAGE||le){"link"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),R(f)):"date_time"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),R(T)):(l.push({label:"",options:[f,E,T]}),R(E));const e=null!=te?te:[];Y([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=te?te:[];Y([{label:"",options:[E,f]},...e]),a=[{label:"",options:[E,f]},...e]}if((Z===p.CHANNEL_TYPE.WHATSAPP||Z===p.CHANNEL_TYPE.EMAIL||Z===p.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(c.placeHolderNamePattern.test(h.updatedValue)&&Z===p.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&Z!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(ae===m.POD.CHATBOT&&"BUTTONS"===V){const l=null==P?void 0:P.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}n={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(h,a,Z);e.value&&R(e)}else"date_time"===h.type?(R(T),B(h.updatedValue),ce(null!==(e=h.index)&&void 0!==e?e:0,h.updatedValue)):(null===(t=h.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(R(f),B(h.updatedValue.split("https://")[1])):(R(E),B(h.updatedValue))}function ue(e,t){var l,a,n;const i=e;B(""),R(i),Z===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value&&"static_expiry"!==i.value?(re(null!==(l=i.value)&&void 0!==l?l:"","string"),null==ce||ce(null!==(a=h.index)&&void 0!==a?a:0,i.value,!0)):(null==ce||ce(null!==(n=h.index)&&void 0!==n?n:0,D,!0,i.value),re("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?re(i.value,"url"===i.bikPlaceholderType?"link":"string"):(B(""),re("",i.value))}function de(e,t){var l;B(t);const a="custom_link"===(null==M?void 0:M.value)&&t?t.includes("https")?t:`https://${t}`:t;re(a,"static_expiry"===e?"string":e),Z===p.CHANNEL_TYPE.WHATSAPP&&(null==ce||ce(null!==(l=h.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function re(e,t){var l,n,i,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(Z!==p.CHANNEL_TYPE.WHATSAPP){const a=O.getVariableNameForEmailByIndex(A+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===z?"template_html_mobile":"template_html_desktop"),i=Z===p.CHANNEL_TYPE.EMAIL?null===(l=null==n?void 0:n.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const s=G.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==ee||ee(s)}if(Z===p.CHANNEL_TYPE.WHATSAPP){if(null!=ne&&ne>-1&&ie){const t=Object.assign({},G).cards.map(((t,l)=>{var a;return Object.assign(Object.assign({},t),{body:null===(a=t.body)||void 0===a?void 0:a.map(((l,a)=>A===a?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):t))})}));return void(null==ee||ee((e=>Object.assign(Object.assign({},e),{cards:t}))))}const l=null!=ne&&ne>-1?G.cards[ne]:G;let u=l.body,d=l.header,r=l.buttons;if("BODY"===V?u=null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===V?d=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===V&&(r=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===A?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=ne&&ne>-1){const e=a.cloneDeep(G.cards);e[ne]={header:d,body:u,buttons:r},null==ee||ee((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ee||ee((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:r})))}}function ce(e,t,l,n){var i,s,o,u,d,r,c;if(null!=ne&&ne>-1&&ie){const s=Object.assign({},K).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,n,i,s,o;if("BODY"!==l.type)return l;if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const a=[...null!==(o=null===(s=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const n=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:n})}}))})))}):l})),o=a.cloneDeep(K);if(l){const l=null===(i=Object.assign({},K).mapping.cards)||void 0===i?void 0:i.map((l=>{var a;return Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))})}));o.mapping.cards=l}return o.components=s,console.log("mappingComponent templateCopy: ",o),void(null==Q||Q(o))}const p=null!=ne&&ne>-1?{components:null===(s=Object.assign({},K).components[1].cards)||void 0===s?void 0:s[ne].components,mapping:null===(o=Object.assign({},K).mapping.cards)||void 0===o?void 0:o[ne]}:Object.assign({},K),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,n,i,s,o,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===V){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const l=[...null!==(o=null===(s=null===(i=m.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===V){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===V){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===V)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(p.components=m,l)if("BODY"===V&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===V&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===V&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.buttons)){let l=-1,a=-1;m.forEach((t=>{var n;"BUTTONS"===t.type&&(null===(n=t.buttons)||void 0===n||n.forEach(((t,n)=>{"URL"===t.type&&(l++,n===e&&"URL"==t.type&&(a=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===a?"custom_link"===n?"((customPlaceholderName))":t:e))})}if(null!=ne&&ne>-1&&K){const e=a.cloneDeep(K);e.components[1].cards[ne].components=p.components,e.mapping.cards[ne]=p.mapping,null==Q||Q(e)}else null==Q||Q(Object.assign({},p))}return n.useEffect((()=>{H&&(null==x||x())}),[H]),n.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===z?"template_html_mobile":"template_html_desktop",s=document.getElementById(i),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(n=null==s?void 0:s.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);Z===p.CHANNEL_TYPE.EMAIL&&(null==X||X(o))}()}),[J]),n.useEffect((()=>{oe()}),[]),n.useEffect((()=>{oe()}),[ne]),n.useEffect((()=>{z&&M&&D&&setTimeout((()=>{re("custom_link"===(null==M?void 0:M.value)&&D?D.includes("https")?D:`https://${D}`:D,M.value)}),100)}),[z]),n.useEffect((()=>{!W&&M&&h.updatedValue&&setTimeout((()=>{re("custom_link"===(null==M?void 0:M.value)&&h.updatedValue?h.updatedValue.includes("https")?h.updatedValue:`https://${h.updatedValue}`:h.updatedValue,M.value),$(!0)}),100)}),[M]),e.jsxs(y,Object.assign({channel:Z,focused:H,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:F&&!M?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(k=h.variableName)||void 0===k?void 0:k.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:C?e.jsxs("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:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:ae===m.POD.CHATBOT?null==M?void 0:M.value:r.truncate(null!==(L=null==M?void 0:M.label)&&void 0!==L?L:"",20,!0)})),e.jsx(t.default,{onClick:()=>{I(!U)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{disabled:se,options:q,isSearchable:!1,onSelect:ue,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))&&e.jsx(d.Input,{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}-${A}`,value:D,errorMessage:F?D&&0!==D.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://${D.trim()}`)&&0!==D.trim().length?"custom_link"!==M.value&&D.length>30?"Length cannot be more than 30":"BUTTONS"===V&&"custom_link"!==M.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==M?void 0:M.value)?2e3:"BUTTONS"===V?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==M?void 0:M.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===M.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{de(M.value,e)}}),"static_expiry"===(null==M?void 0:M.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[se&&e.jsx(_,{onClick:e=>e.preventDefault()}),e.jsx(o.CustomDateTime,{placement:"auto",time:D?l.format(new Date(D),"hh:mm a"):l.format(new Date,"hh:mm a"),date:D?new Date(D):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{de("static_expiry",e.toISOString())}})]})),U&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=N?N:[],showVariable:U,setShowVariable:I,placeholder:"Add a variable",customTrigger:e=>{null==S||S(!1),"{{custom.url}}"===e.actualValue?ue({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ue({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ue({label:e.displayName,selected:!0,value:"static_expiry"}):ue({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
16
+ `,f={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"};exports.Container=y,exports.default=n=>{let{onFocus:x,variable:h,index:A,showVariableModal:C,variableList:N,setShowDiscountCheckBox:S,componentType:V,CTAoptions:P}=n;var k,L;const[H,w]=i.useState(!1),[D,B]=i.useState(""),[q,Y]=i.useState([]),[M,R]=i.useState(),[U,I]=i.useState(!1),[W,$]=i.useState(!1),{device:z,channel:Z,isError:F,originalVariableList:G,template:K,templateSelectionTriggered:J,setTemplate:Q,setDisplayContent:X,setOriginalVariableList:ee,globalNormalizedPlaceholders:te,enabledCustomText:le,pod:ae,selectedCarouselIndex:ie,isProductCarouselType:ne,disableEditVariable:se,disableEditExpiry:oe}=j.useTemplateModalContext();function ue(){var e,t;const l=[];let a=[];if(Z!==p.CHANNEL_TYPE.MESSAGE||le){"link"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),R(f)):"date_time"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),R(T)):(l.push({label:"",options:[f,E,T]}),R(E));const e=null!=te?te:[];Y([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=te?te:[];Y([{label:"",options:[E,f]},...e]),a=[{label:"",options:[E,f]},...e]}if((Z===p.CHANNEL_TYPE.WHATSAPP||Z===p.CHANNEL_TYPE.EMAIL||Z===p.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(c.placeHolderNamePattern.test(h.updatedValue)&&Z===p.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&Z!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(ae===m.POD.CHATBOT&&"BUTTONS"===V){const l=null==P?void 0:P.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(h,a,Z);e.value&&R(e)}else"date_time"===h.type?(R(T),B(h.updatedValue),pe(null!==(e=h.index)&&void 0!==e?e:0,h.updatedValue)):(null===(t=h.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(R(f),B(h.updatedValue.split("https://")[1])):(R(E),B(h.updatedValue))}function de(e,t){var l,a,i;const n=e;B(""),R(n),Z===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(ce(null!==(l=n.value)&&void 0!==l?l:"","string"),null==pe||pe(null!==(a=h.index)&&void 0!==a?a:0,n.value,!0)):(null==pe||pe(null!==(i=h.index)&&void 0!==i?i:0,D,!0,n.value),ce("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ce(n.value,"url"===n.bikPlaceholderType?"link":"string"):(B(""),ce("",n.value))}function re(e,t){var l;B(t);const a="custom_link"===(null==M?void 0:M.value)&&t?t.includes("https")?t:`https://${t}`:t;ce(a,"static_expiry"===e?"string":e),Z===p.CHANNEL_TYPE.WHATSAPP&&(null==pe||pe(null!==(l=h.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function ce(e,t){var l,i,n,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(Z!==p.CHANNEL_TYPE.WHATSAPP){const a=O.getVariableNameForEmailByIndex(A+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===z?"template_html_mobile":"template_html_desktop"),n=Z===p.CHANNEL_TYPE.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const s=G.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==ee||ee(s)}if(Z===p.CHANNEL_TYPE.WHATSAPP){if(null!=ie&&ie>-1&&ne){const t=Object.assign({},G).cards.map(((t,l)=>{var a;return Object.assign(Object.assign({},t),{body:null===(a=t.body)||void 0===a?void 0:a.map(((l,a)=>A===a?Object.assign(Object.assign({},l),{type:o,updatedValue:e}):t))})}));return void(null==ee||ee((e=>Object.assign(Object.assign({},e),{cards:t}))))}const l=null!=ie&&ie>-1?G.cards[ie]:G;let u=l.body,d=l.header,r=l.buttons;if("BODY"===V?u=null===(i=l.body)||void 0===i?void 0:i.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===V?d=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===V&&(r=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===A?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=ie&&ie>-1){const e=a.cloneDeep(G.cards);e[ie]={header:d,body:u,buttons:r},null==ee||ee((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ee||ee((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:r})))}}function pe(e,t,l,i){var n,s,o,u,d,r,c;if(null!=ie&&ie>-1&&ne){const s=Object.assign({},K).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,s,o;if("BODY"!==l.type)return l;if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(o=null===(s=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}}))})))}):l})),o=a.cloneDeep(K);if(l){const l=null===(n=Object.assign({},K).mapping.cards)||void 0===n?void 0:n.map((l=>{var a;return Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))})}));o.mapping.cards=l}return o.components=s,console.log("mappingComponent templateCopy: ",o),void(null==Q||Q(o))}const p=null!=ie&&ie>-1?{components:null===(s=Object.assign({},K).components[1].cards)||void 0===s?void 0:s[ie].components,mapping:null===(o=Object.assign({},K).mapping.cards)||void 0===o?void 0:o[ie]}:Object.assign({},K),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,i,n,s,o,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===V){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(o=null===(s=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===V){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===V){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===V)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(p.components=m,l)if("BODY"===V&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===V&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===V&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.buttons)){let l=-1,a=-1;m.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=ie&&ie>-1&&K){const e=a.cloneDeep(K);e.components[1].cards[ie].components=p.components,e.mapping.cards[ie]=p.mapping,null==Q||Q(e)}else null==Q||Q(Object.assign({},p))}return i.useEffect((()=>{H&&(null==x||x())}),[H]),i.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===z?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==s?void 0:s.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);Z===p.CHANNEL_TYPE.EMAIL&&(null==X||X(o))}()}),[J]),i.useEffect((()=>{ue()}),[]),i.useEffect((()=>{ue()}),[ie]),i.useEffect((()=>{z&&M&&D&&setTimeout((()=>{ce("custom_link"===(null==M?void 0:M.value)&&D?D.includes("https")?D:`https://${D}`:D,M.value)}),100)}),[z]),i.useEffect((()=>{!W&&M&&h.updatedValue&&setTimeout((()=>{ce("custom_link"===(null==M?void 0:M.value)&&h.updatedValue?h.updatedValue.includes("https")?h.updatedValue:`https://${h.updatedValue}`:h.updatedValue,M.value),$(!0)}),100)}),[M]),e.jsxs(y,Object.assign({channel:Z,focused:H,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:F&&!M?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(k=h.variableName)||void 0===k?void 0:k.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:C?e.jsxs("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:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:ae===m.POD.CHATBOT?null==M?void 0:M.value:r.truncate(null!==(L=null==M?void 0:M.label)&&void 0!==L?L:"",20,!0)})),se||"date_time"===(null==h?void 0:h.type)&&oe?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{I(!U)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{disabled:se,options:q,isSearchable:!1,onSelect:de,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))&&e.jsx(d.Input,{state:se?"disabled":"none",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}-${A}`,value:D,errorMessage:F?D&&0!==D.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://${D.trim()}`)&&0!==D.trim().length?"custom_link"!==M.value&&D.length>30?"Length cannot be more than 30":"BUTTONS"===V&&"custom_link"!==M.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==M?void 0:M.value)?2e3:"BUTTONS"===V?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==M?void 0:M.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===M.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{re(M.value,e)}}),"static_expiry"===(null==M?void 0:M.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[se&&e.jsx(_,{onClick:e=>e.preventDefault()}),e.jsx(o.CustomDateTime,{placement:"auto",time:D?l.format(new Date(D),"hh:mm a"):l.format(new Date,"hh:mm a"),date:D?new Date(D):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{re("static_expiry",e.toISOString())}})]})),U&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=N?N:[],showVariable:U,setShowVariable:I,placeholder:"Add a variable",customTrigger:e=>{null==S||S(!1),"{{custom.url}}"===e.actualValue?de({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?de({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?de({label:e.displayName,selected:!0,value:"static_expiry"}):de({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
@@ -41,5 +41,6 @@ export interface TemplateContextMapperProps {
41
41
  fetchProducts: any;
42
42
  storeId: string;
43
43
  };
44
+ disableEditExpiry?: boolean;
44
45
  }
45
- export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras, pickerConf, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
46
+ export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, showSampleValues, disableEditVariable, pod, extras, pickerConf, disableEditExpiry, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as l,Fragment as o}from"react/jsx-runtime";import{useEffect as t,useState as a,useMemo as r}from"react";import i from"../../utils/StringUtils.js";import{StyledModal as s}from"../modals/styledModal.js";import{CHANNEL_TYPE as n}from"../template-preview/models/Channels.js";import{TemplateModalContext as d}from"./context/templateModalContext.js";import c from"./modalElements/Footer.js";import p from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as m}from"./utils/convertPlaceholdersToBikDropdown.js";const u=u=>{let{selectedTemplate:v,closeDialog:h,showVariableMapping:C,channel:b,htmlContent:g,templateVariables:S,onTemplateSelect:x,globalPlaceholders:f,showOnlyContent:T,whatsappSpecificPickerMeta:I,zIndex:P,showVariableModal:w,variableList:M,discountCode:E,setDiscountCode:L,onBackPress:V,enabledCustomText:j,variableListForImage:y,showSampleValues:k,disableEditVariable:A,pod:D,extras:O,pickerConf:F}=u;var W,z,B,H,U,$;t((()=>{G(g)}),[g]);const N=b===n.WHATSAPP&&"CAROUSEL"===(null===(z=null===(W=v.components)||void 0===W?void 0:W[1])||void 0===z?void 0:z.type),[R,_]=a(b===n.EMAIL||N?"desktop":"mobile"),[q,G]=a(g),[J,K]=a(!1),[Q,X]=a([]),[Y,Z]=a(v),[ee,le]=a(null!=S?S:[]),[oe,te]=a(!1),[ae,re]=a(-1);const ie=r((()=>m(f)),[f]);return e(d.Provider,Object.assign({value:{template:Y,setTemplate:Z,device:R,setDevice:_,display_content:q,setDisplayContent:G,originalVariableList:ee,setOriginalVariableList:le,isError:J,setIsError:K,channel:b,globalNormalizedPlaceholders:ie,templateSelectionTriggered:oe,setTemplateSelectionTriggered:te,enabledCustomText:j,disableEditVariable:A,pod:D,extras:O,isWhatsappCarousel:N,selectedCarouselIndex:ae,setSelectedCarouselIndex:re,isProductCarouselType:v.isProductCarouselType,cardCount:null===(H=null===(B=v.components)||void 0===B?void 0:B[1].cards)||void 0===H?void 0:H.length,errorIndexes:Q,setErrorIndexes:X,pickerConf:F}},{children:T?e(p,{channel:n.EMAIL,hideHeader:!0}):l(s,Object.assign({zIndex:P,centralContainerStyles:{width:N?900:b===n.EMAIL&&C?1e3:800},open:!0,onClose:()=>{null==h||h()},headingTitle:null==Y?void 0:Y.label,headingSubtitle:b===n.WHATSAPP?`${i.capitaliseFirstLetterOfString(null!==(U=null==Y?void 0:Y.category)&&void 0!==U?U:"")} • ${null!==($=null==Y?void 0:Y.templateCategory)&&void 0!==$?$:""}`:"",onBackPress:()=>{null==V||V()}},{children:[e(p,{showSampleValues:k,showVariableMapping:C,channel:b,whatsappSpecificPickerMeta:I,showVariableModal:w,variableList:M,discountCode:E,setDiscountCode:L,variableListForImage:y&&(null==y?void 0:y.length)>0?y:M}),x?e(c,{isWhatsappCarousel:null!=N&&N,onSelect:function(){const e=null==x?void 0:x(Y,ee,null!=q?q:"");(null==e?void 0:e.errorIndexes)?X(e.errorIndexes):(null==e?void 0:e.error)?K(!!(null==e?void 0:e.error)):te(!0)}}):e(o,{})]}))}))};export{u as TemplateContextMapper};
1
+ import{jsx as e,jsxs as l,Fragment as o}from"react/jsx-runtime";import{useEffect as t,useState as i,useMemo as a}from"react";import r from"../../utils/StringUtils.js";import{StyledModal as s}from"../modals/styledModal.js";import{CHANNEL_TYPE as n}from"../template-preview/models/Channels.js";import{TemplateModalContext as d}from"./context/templateModalContext.js";import c from"./modalElements/Footer.js";import p from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as m}from"./utils/convertPlaceholdersToBikDropdown.js";const u=u=>{let{selectedTemplate:v,closeDialog:h,showVariableMapping:b,channel:C,htmlContent:g,templateVariables:x,onTemplateSelect:S,globalPlaceholders:f,showOnlyContent:E,whatsappSpecificPickerMeta:T,zIndex:I,showVariableModal:P,variableList:w,discountCode:y,setDiscountCode:M,onBackPress:L,enabledCustomText:V,variableListForImage:j,showSampleValues:k,disableEditVariable:A,pod:D,extras:O,pickerConf:F,disableEditExpiry:W}=u;var z,B,H,U,$,N;t((()=>{J(g)}),[g]);const R=C===n.WHATSAPP&&"CAROUSEL"===(null===(B=null===(z=v.components)||void 0===z?void 0:z[1])||void 0===B?void 0:B.type),[_,q]=i(C===n.EMAIL||R?"desktop":"mobile"),[G,J]=i(g),[K,Q]=i(!1),[X,Y]=i([]),[Z,ee]=i(v),[le,oe]=i(null!=x?x:[]),[te,ie]=i(!1),[ae,re]=i(-1);const se=a((()=>m(f)),[f]);return e(d.Provider,Object.assign({value:{template:Z,setTemplate:ee,device:_,setDevice:q,display_content:G,setDisplayContent:J,originalVariableList:le,setOriginalVariableList:oe,isError:K,setIsError:Q,channel:C,globalNormalizedPlaceholders:se,templateSelectionTriggered:te,setTemplateSelectionTriggered:ie,enabledCustomText:V,disableEditVariable:A,pod:D,extras:O,isWhatsappCarousel:R,selectedCarouselIndex:ae,setSelectedCarouselIndex:re,isProductCarouselType:v.isProductCarouselType,cardCount:null===(U=null===(H=v.components)||void 0===H?void 0:H[1].cards)||void 0===U?void 0:U.length,errorIndexes:X,setErrorIndexes:Y,pickerConf:F,disableEditExpiry:W}},{children:E?e(p,{channel:n.EMAIL,hideHeader:!0}):l(s,Object.assign({zIndex:I,centralContainerStyles:{width:R?900:C===n.EMAIL&&b?1e3:800},open:!0,onClose:()=>{null==h||h()},headingTitle:null==Z?void 0:Z.label,headingSubtitle:C===n.WHATSAPP?`${r.capitaliseFirstLetterOfString(null!==($=null==Z?void 0:Z.category)&&void 0!==$?$:"")} • ${null!==(N=null==Z?void 0:Z.templateCategory)&&void 0!==N?N:""}`:"",onBackPress:()=>{null==L||L()}},{children:[e(p,{showSampleValues:k,showVariableMapping:b,channel:C,whatsappSpecificPickerMeta:T,showVariableModal:P,variableList:w,discountCode:y,setDiscountCode:M,variableListForImage:j&&(null==j?void 0:j.length)>0?j:w}),S?e(c,{isWhatsappCarousel:null!=R&&R,onSelect:function(){const e=null==S?void 0:S(Z,le,null!=G?G:"");(null==e?void 0:e.errorIndexes)?Y(e.errorIndexes):(null==e?void 0:e.error)?Q(!!(null==e?void 0:e.error)):ie(!0)}}):e(o,{})]}))}))};export{u as TemplateContextMapper};
@@ -40,6 +40,7 @@ export declare const TemplateModalContext: React.Context<{
40
40
  fetchProducts: any;
41
41
  storeId: string;
42
42
  } | undefined;
43
+ disableEditExpiry?: boolean | undefined;
43
44
  }>;
44
45
  export declare const useTemplateModalContext: () => {
45
46
  device: DEVICE_TYPES;
@@ -75,4 +76,5 @@ export declare const useTemplateModalContext: () => {
75
76
  fetchProducts: any;
76
77
  storeId: string;
77
78
  } | undefined;
79
+ disableEditExpiry?: boolean | undefined;
78
80
  };
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";import{CHANNEL_TYPE as l}from"../../template-preview/models/Channels.js";const r=e.createContext({device:"desktop",templateSelectionTriggered:!1,display_content:null,originalVariableList:[],channel:l.EMAIL,template:null,isError:!1,enabledCustomText:!1,disableEditVariable:!1}),a=()=>t(r);export{r as TemplateModalContext,a as useTemplateModalContext};
1
+ import e,{useContext as t}from"react";import{CHANNEL_TYPE as i}from"../../template-preview/models/Channels.js";const l=e.createContext({device:"desktop",templateSelectionTriggered:!1,display_content:null,originalVariableList:[],channel:i.EMAIL,template:null,isError:!1,enabledCustomText:!1,disableEditVariable:!1,disableEditExpiry:!1}),r=()=>t(l);export{l as TemplateModalContext,r as useTemplateModalContext};
@@ -1,10 +1,10 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/icons/edit.svg.js";import{format as a}from"date-fns";import{cloneDeep as i}from"lodash";import{useState as n,useEffect as o}from"react";import s from"styled-components";import{AddVariableV2SideModal as d}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as u}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as c}from"../../dropdown/Dropdown.js";import{Input as r}from"../../input/Input.js";import{truncate as p}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as m}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as v}from"../../template-preview/models/Channels.js";import{POD as b}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as g,BodyPrimary as O}from"../../TypographyStyle.js";import h from"../../../utils/StringUtils.js";import{COLORS as j}from"../../../constants/Theme.js";import{useTemplateModalContext as x}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as f}from"../utils/getVariableNameEmail.js";const y=s.div`
1
+ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import a from"../../../assets/icons/edit.svg.js";import{format as i}from"date-fns";import{cloneDeep as n}from"lodash";import{useState as o,useEffect as s}from"react";import d from"styled-components";import{AddVariableV2SideModal as u}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as c}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as r}from"../../dropdown/Dropdown.js";import{Input as p}from"../../input/Input.js";import{truncate as m}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as v}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as b}from"../../template-preview/models/Channels.js";import{POD as g}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as O,BodyPrimary as h}from"../../TypographyStyle.js";import j from"../../../utils/StringUtils.js";import{COLORS as x}from"../../../constants/Theme.js";import{useTemplateModalContext as y}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as f}from"../utils/getVariableNameEmail.js";const _=d.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
- background: ${e=>e.focused&&e.channel===v.EMAIL?j.background.warning.light:"transparent"};
4
+ background: ${e=>e.focused&&e.channel===b.EMAIL?x.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,_=s.div`
7
+ `,T=d.div`
8
8
  position: absolute;
9
9
  top: 0;
10
10
  left: 0;
@@ -13,4 +13,4 @@ import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/
13
13
  background-color: rgba(0, 0, 0, 0.1);
14
14
  z-index: 1000;
15
15
  cursor: not-allowed;
16
- `,T={value:"custom_link",label:"Custom URL"},V={value:"custom_text",label:"Custom text"},k={value:"static_expiry",label:"Static Expiry"},A=s=>{let{onFocus:A,variable:E,index:S,showVariableModal:w,variableList:C,setShowDiscountCheckBox:P,componentType:B,CTAoptions:D}=s;var L,N;const[H,U]=n(!1),[M,W]=n(""),[R,$]=n([]),[I,z]=n(),[Y,Z]=n(!1),[G,q]=n(!1),{device:F,channel:K,isError:J,originalVariableList:Q,template:X,templateSelectionTriggered:ee,setTemplate:te,setDisplayContent:le,setOriginalVariableList:ae,globalNormalizedPlaceholders:ie,enabledCustomText:ne,pod:oe,selectedCarouselIndex:se,isProductCarouselType:de,disableEditVariable:ue}=x();function ce(){var e,t;const l=[];let a=[];if(K!==v.MESSAGE||ne){"link"===(null==E?void 0:E.type)?(l.push({label:"",options:[T,V]}),z(T)):"date_time"===(null==E?void 0:E.type)?(l.push({label:"",options:[T,V]}),z(k)):(l.push({label:"",options:[T,V,k]}),z(V));const e=null!=ie?ie:[];$([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:h.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ie?ie:[];$([{label:"",options:[V,T]},...e]),a=[{label:"",options:[V,T]},...e]}if((K===v.WHATSAPP||K===v.EMAIL||K===v.MESSAGE)&&E.updatedValue)if(m.test(E.updatedValue)&&K===v.WHATSAPP||E.updatedValue.startsWith("{{")&&K!==v.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===v.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(w){let t=e.updatedValue;if(oe===b.CHATBOT&&"BUTTONS"===B){const l=null==D?void 0:D.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(E,a,K);e.value&&z(e)}else"date_time"===E.type?(z(k),W(E.updatedValue),ve(null!==(e=E.index)&&void 0!==e?e:0,E.updatedValue)):(null===(t=E.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(z(T),W(E.updatedValue.split("https://")[1])):(z(V),W(E.updatedValue))}function re(e,t){var l,a,i;const n=e;W(""),z(n),K===v.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(me(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ve||ve(null!==(a=E.index)&&void 0!==a?a:0,n.value,!0)):(null==ve||ve(null!==(i=E.index)&&void 0!==i?i:0,M,!0,n.value),me("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?me(n.value,"url"===n.bikPlaceholderType?"link":"string"):(W(""),me("",n.value))}function pe(e,t){var l;W(t);const a="custom_link"===(null==I?void 0:I.value)&&t?t.includes("https")?t:`https://${t}`:t;me(a,"static_expiry"===e?"string":e),K===v.WHATSAPP&&(null==ve||ve(null!==(l=E.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function me(e,t){var l,a,n,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(K!==v.WHATSAPP){const a=f(S+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===F?"template_html_mobile":"template_html_desktop"),n=K===v.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:E.variableName);const o=Q.map(((t,l)=>l===S?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==ae||ae(o)}if(K===v.WHATSAPP){if(null!=se&&se>-1&&de){const t=Object.assign({},Q).cards.map(((t,l)=>{var a;return Object.assign(Object.assign({},t),{body:null===(a=t.body)||void 0===a?void 0:a.map(((l,a)=>S===a?Object.assign(Object.assign({},l),{type:s,updatedValue:e}):t))})}));return void(null==ae||ae((e=>Object.assign(Object.assign({},e),{cards:t}))))}const l=null!=se&&se>-1?Q.cards[se]:Q;let d=l.body,u=l.header,c=l.buttons;if("BODY"===B?d=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===S?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===B?u=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===S?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===B&&(c=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===S?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=se&&se>-1){const e=i(Q.cards);e[se]={header:u,body:d,buttons:c},null==ae||ae((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ae||ae((e=>Object.assign(Object.assign({},e),{header:u,body:d,buttons:c})))}}function ve(e,t,l,a){var n,o,s,d,u,c,r;if(null!=se&&se>-1&&de){const o=Object.assign({},X).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,o,s;if("BODY"!==l.type)return l;if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}}))})))}):l})),s=i(X);if(l){const l=null===(n=Object.assign({},X).mapping.cards)||void 0===n?void 0:n.map((l=>{var i;return Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))})}));s.mapping.cards=l}return s.components=o,console.log("mappingComponent templateCopy: ",s),void(null==te||te(s))}const p=null!=se&&se>-1?{components:null===(o=Object.assign({},X).components[1].cards)||void 0===o?void 0:o[se].components,mapping:null===(s=Object.assign({},X).mapping.cards)||void 0===s?void 0:s[se]}:Object.assign({},X),m=null===(d=null==p?void 0:p.components)||void 0===d?void 0:d.map((l=>{var a,i,n,o,s,d,u,c,r,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===B){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===B){if(null===(d=l.example)||void 0===d?void 0:d.header_text){const l=[...null!==(c=null===(u=m.example)||void 0===u?void 0:u.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===B){if(null===(p=null===(r=l.buttons)||void 0===r?void 0:r[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===B)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(p.components=m,l)if("BODY"===B&&(null===(u=null==p?void 0:p.mapping)||void 0===u?void 0:u.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===B&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===B&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,i=-1;m.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=se&&se>-1&&X){const e=i(X);e.components[1].cards[se].components=p.components,e.mapping.cards[se]=p.mapping,null==te||te(e)}else null==te||te(Object.assign({},p))}return o((()=>{H&&(null==A||A())}),[H]),o((()=>{!function(){var e,t,l,a,i;const n="mobile"===F?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);K===v.EMAIL&&(null==le||le(s))}()}),[ee]),o((()=>{ce()}),[]),o((()=>{ce()}),[se]),o((()=>{F&&I&&M&&setTimeout((()=>{me("custom_link"===(null==I?void 0:I.value)&&M?M.includes("https")?M:`https://${M}`:M,I.value)}),100)}),[F]),o((()=>{!G&&I&&E.updatedValue&&setTimeout((()=>{me("custom_link"===(null==I?void 0:I.value)&&E.updatedValue?E.updatedValue.includes("https")?E.updatedValue:`https://${E.updatedValue}`:E.updatedValue,I.value),q(!0)}),100)}),[I]),e(y,Object.assign({channel:K,focused:H,onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(g,Object.assign({style:{color:J&&!I?j.content.negative:j.content.primary}},{children:[null===(L=E.variableName)||void 0===L?void 0:L.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:w?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==I?void 0:I.label)?"space-between":"flex-end"}},{children:[t(O,Object.assign({numberOfLines:1},{children:oe===b.CHATBOT?null==I?void 0:I.value:p(null!==(N=null==I?void 0:I.label)&&void 0!==N?N:"",20,!0)})),t(l,{onClick:()=>{Z(!Y)},width:24,height:24,color:j.content.primary})]})):t(c,{disabled:ue,options:R,isSearchable:!1,onSelect:re,defaultOptions:I?[Object.assign(Object.assign({},I),{selected:!0})]:[]})})),("custom_text"===(null==I?void 0:I.value)||"custom_link"===(null==I?void 0:I.value))&&t(r,{labelText:"custom_text"===(null==I?void 0:I.value)?"Custom text value":"custom_link"===(null==I?void 0:I.value)?"Custom URL value":"",id:`variable-value-${null==I?void 0:I.value}-${S}`,value:M,errorMessage:J?M&&0!==M.trim().length?"custom_link"!==I.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${M.trim()}`)&&0!==M.trim().length?"custom_link"!==I.value&&M.length>30?"Length cannot be more than 30":"BUTTONS"===B&&"custom_link"!==I.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==I?void 0:I.value)?2e3:"BUTTONS"===B?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==I?void 0:I.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===I.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{pe(I.value,e)}}),"static_expiry"===(null==I?void 0:I.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[ue&&t(_,{onClick:e=>e.preventDefault()}),t(u,{placement:"auto",time:a(M?new Date(M):new Date,"hh:mm a"),date:M?new Date(M):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{pe("static_expiry",e.toISOString())}})]})),Y&&t(d,{zIndex:2e3,data:null!=C?C:[],showVariable:Y,setShowVariable:Z,placeholder:"Add a variable",customTrigger:e=>{null==P||P(!1),"{{custom.url}}"===e.actualValue?re({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?re({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?re({label:e.displayName,selected:!0,value:"static_expiry"}):re({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{y as Container,A as default};
16
+ `,V={value:"custom_link",label:"Custom URL"},k={value:"custom_text",label:"Custom text"},E={value:"static_expiry",label:"Static Expiry"},A=d=>{let{onFocus:A,variable:S,index:w,showVariableModal:C,variableList:P,setShowDiscountCheckBox:B,componentType:D,CTAoptions:L}=d;var N,H;const[U,M]=o(!1),[W,R]=o(""),[$,I]=o([]),[z,Y]=o(),[Z,G]=o(!1),[q,F]=o(!1),{device:K,channel:J,isError:Q,originalVariableList:X,template:ee,templateSelectionTriggered:te,setTemplate:le,setDisplayContent:ae,setOriginalVariableList:ie,globalNormalizedPlaceholders:ne,enabledCustomText:oe,pod:se,selectedCarouselIndex:de,isProductCarouselType:ue,disableEditVariable:ce,disableEditExpiry:re}=y();function pe(){var e,t;const l=[];let a=[];if(J!==b.MESSAGE||oe){"link"===(null==S?void 0:S.type)?(l.push({label:"",options:[V,k]}),Y(V)):"date_time"===(null==S?void 0:S.type)?(l.push({label:"",options:[V,k]}),Y(E)):(l.push({label:"",options:[V,k,E]}),Y(k));const e=null!=ne?ne:[];I([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:j.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ne?ne:[];I([{label:"",options:[k,V]},...e]),a=[{label:"",options:[k,V]},...e]}if((J===b.WHATSAPP||J===b.EMAIL||J===b.MESSAGE)&&S.updatedValue)if(v.test(S.updatedValue)&&J===b.WHATSAPP||S.updatedValue.startsWith("{{")&&J!==b.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===b.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(se===g.CHATBOT&&"BUTTONS"===D){const l=null==L?void 0:L.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(S,a,J);e.value&&Y(e)}else"date_time"===S.type?(Y(E),R(S.updatedValue),ge(null!==(e=S.index)&&void 0!==e?e:0,S.updatedValue)):(null===(t=S.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(Y(V),R(S.updatedValue.split("https://")[1])):(Y(k),R(S.updatedValue))}function me(e,t){var l,a,i;const n=e;R(""),Y(n),J===b.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(be(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ge||ge(null!==(a=S.index)&&void 0!==a?a:0,n.value,!0)):(null==ge||ge(null!==(i=S.index)&&void 0!==i?i:0,W,!0,n.value),be("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?be(n.value,"url"===n.bikPlaceholderType?"link":"string"):(R(""),be("",n.value))}function ve(e,t){var l;R(t);const a="custom_link"===(null==z?void 0:z.value)&&t?t.includes("https")?t:`https://${t}`:t;be(a,"static_expiry"===e?"string":e),J===b.WHATSAPP&&(null==ge||ge(null!==(l=S.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function be(e,t){var l,a,i,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(J!==b.WHATSAPP){const a=f(w+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===K?"template_html_mobile":"template_html_desktop"),n=J===b.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:S.variableName);const o=X.map(((t,l)=>l===w?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==ie||ie(o)}if(J===b.WHATSAPP){if(null!=de&&de>-1&&ue){const t=Object.assign({},X).cards.map(((t,l)=>{var a;return Object.assign(Object.assign({},t),{body:null===(a=t.body)||void 0===a?void 0:a.map(((l,a)=>w===a?Object.assign(Object.assign({},l),{type:s,updatedValue:e}):t))})}));return void(null==ie||ie((e=>Object.assign(Object.assign({},e),{cards:t}))))}const l=null!=de&&de>-1?X.cards[de]:X;let d=l.body,u=l.header,c=l.buttons;if("BODY"===D?d=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===w?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===D?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===w?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===D&&(c=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===w?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null!=de&&de>-1){const e=n(X.cards);e[de]={header:u,body:d,buttons:c},null==ie||ie((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ie||ie((e=>Object.assign(Object.assign({},e),{header:u,body:d,buttons:c})))}}function ge(e,t,l,a){var i,o,s,d,u,c,r;if(null!=de&&de>-1&&ue){const o=Object.assign({},ee).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,o,s;if("BODY"!==l.type)return l;if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}}))})))}):l})),s=n(ee);if(l){const l=null===(i=Object.assign({},ee).mapping.cards)||void 0===i?void 0:i.map((l=>{var i;return Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))})}));s.mapping.cards=l}return s.components=o,console.log("mappingComponent templateCopy: ",s),void(null==le||le(s))}const p=null!=de&&de>-1?{components:null===(o=Object.assign({},ee).components[1].cards)||void 0===o?void 0:o[de].components,mapping:null===(s=Object.assign({},ee).mapping.cards)||void 0===s?void 0:s[de]}:Object.assign({},ee),m=null===(d=null==p?void 0:p.components)||void 0===d?void 0:d.map((l=>{var a,i,n,o,s,d,u,c,r,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===D){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===D){if(null===(d=l.example)||void 0===d?void 0:d.header_text){const l=[...null!==(c=null===(u=m.example)||void 0===u?void 0:u.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===D){if(null===(p=null===(r=l.buttons)||void 0===r?void 0:r[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===D)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(p.components=m,l)if("BODY"===D&&(null===(u=null==p?void 0:p.mapping)||void 0===u?void 0:u.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===D&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===D&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,i=-1;m.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=de&&de>-1&&ee){const e=n(ee);e.components[1].cards[de].components=p.components,e.mapping.cards[de]=p.mapping,null==le||le(e)}else null==le||le(Object.assign({},p))}return s((()=>{U&&(null==A||A())}),[U]),s((()=>{!function(){var e,t,l,a,i;const n="mobile"===K?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);J===b.EMAIL&&(null==ae||ae(s))}()}),[te]),s((()=>{pe()}),[]),s((()=>{pe()}),[de]),s((()=>{K&&z&&W&&setTimeout((()=>{be("custom_link"===(null==z?void 0:z.value)&&W?W.includes("https")?W:`https://${W}`:W,z.value)}),100)}),[K]),s((()=>{!q&&z&&S.updatedValue&&setTimeout((()=>{be("custom_link"===(null==z?void 0:z.value)&&S.updatedValue?S.updatedValue.includes("https")?S.updatedValue:`https://${S.updatedValue}`:S.updatedValue,z.value),F(!0)}),100)}),[z]),e(_,Object.assign({channel:J,focused:U,onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(O,Object.assign({style:{color:Q&&!z?x.content.negative:x.content.primary}},{children:[null===(N=S.variableName)||void 0===N?void 0:N.replace("{{","").replace("}}","")," ","link"===(null==S?void 0:S.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:C?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==z?void 0:z.label)?"space-between":"flex-end"}},{children:[t(h,Object.assign({numberOfLines:1},{children:se===g.CHATBOT?null==z?void 0:z.value:m(null!==(H=null==z?void 0:z.label)&&void 0!==H?H:"",20,!0)})),ce||"date_time"===(null==S?void 0:S.type)&&re?t(l,{}):t(a,{onClick:()=>{G(!Z)},width:24,height:24,color:x.content.primary})]})):t(r,{disabled:ce,options:$,isSearchable:!1,onSelect:me,defaultOptions:z?[Object.assign(Object.assign({},z),{selected:!0})]:[]})})),("custom_text"===(null==z?void 0:z.value)||"custom_link"===(null==z?void 0:z.value))&&t(p,{state:ce?"disabled":"none",labelText:"custom_text"===(null==z?void 0:z.value)?"Custom text value":"custom_link"===(null==z?void 0:z.value)?"Custom URL value":"",id:`variable-value-${null==z?void 0:z.value}-${w}`,value:W,errorMessage:Q?W&&0!==W.trim().length?"custom_link"!==z.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"!==z.value&&W.length>30?"Length cannot be more than 30":"BUTTONS"===D&&"custom_link"!==z.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==z?void 0:z.value)?2e3:"BUTTONS"===D?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==z?void 0:z.value)?"https://":"",placeholder:"link"===S.type||"custom_link"===z.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{ve(z.value,e)}}),"static_expiry"===(null==z?void 0:z.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[ce&&t(T,{onClick:e=>e.preventDefault()}),t(c,{placement:"auto",time:i(W?new Date(W):new Date,"hh:mm a"),date:W?new Date(W):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{ve("static_expiry",e.toISOString())}})]})),Z&&t(u,{zIndex:2e3,data:null!=P?P:[],showVariable:Z,setShowVariable:G,placeholder:"Add a variable",customTrigger:e=>{null==B||B(!1),"{{custom.url}}"===e.actualValue?me({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?me({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?me({label:e.displayName,selected:!0,value:"static_expiry"}):me({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{_ as Container,A as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.433-beta.18",
3
+ "version": "0.0.433-beta.19",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",