@bikdotai/bik-component-library 0.0.44-2.beta.link.4 → 0.0.44-2.beta.link.5

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
  import 'pure-react-carousel/dist/react-carousel.es.css';
2
3
  import { VariableListInterfaceV2 } from "../add-variableV2/AddVariableV2";
3
4
  import { CarouselProduct } from "./modalElements/EditWhatsAppCarouselTemplateV2";
@@ -45,5 +46,6 @@ export interface TemplateContextMapperProps {
45
46
  selectedCarouselProducts?: CarouselProduct[];
46
47
  disableEditExpiry?: boolean;
47
48
  cardWidth?: number;
49
+ onDeleteSelectedProducts?: () => void;
48
50
  }
49
- 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, selectedCarouselProducts, disableEditExpiry, cardWidth, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
51
+ export declare const TemplateContextMapper: React.FC<TemplateContextMapperProps>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),l=require("react"),t=require("../../utils/StringUtils.js"),o=require("../modals/styledModal.js"),a=require("../template-preview/models/Channels.js"),r=require("./context/templateModalContext.js"),s=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:v,htmlContent:h,templateVariables:m,onTemplateSelect:C,globalPlaceholders:E,showOnlyContent:x,whatsappSpecificPickerMeta:S,zIndex:b,showVariableModal:g,variableList:P,discountCode:T,setDiscountCode:f,onBackPress:j,enabledCustomText:M,variableListForImage:I,showSampleValues:L,disableEditVariable:y,pod:A,extras:w,pickerConf:N,selectedCarouselProducts:V,disableEditExpiry:k,cardWidth:q}=d;var H,_,D,O,W,F;l.useEffect((()=>{$(h)}),[h]);const Y=v===a.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(_=null===(H=u.components)||void 0===H?void 0:H[1])||void 0===_?void 0:_.type),B=u.isProductCarouselType,[z,R]=l.useState(v===a.CHANNEL_TYPE.EMAIL||Y?"desktop":"mobile"),[U,$]=l.useState(h),[G,J]=l.useState(!1),[K,Q]=l.useState([]),[X,Z]=l.useState(u),[ee,le]=l.useState([]),[te,oe]=l.useState(!1),[ae,re]=l.useState(null!=m?m:[]),[se,ie]=l.useState(!1),[ne,de]=l.useState(-1),[ue,ce]=l.useState([]);l.useEffect((()=>{V?ce(V):B&&ce([])}),[V]),l.useEffect((()=>{var e;if(!te&&B){const l=null===(e=null==X?void 0:X.components)||void 0===e?void 0:e[1].cards,t=[];null==l||l.forEach((e=>{var l;null===(l=null==e?void 0:e.components)||void 0===l||l.forEach((e=>{var l,o,a;"HEADER"===e.type&&t.push(null!==(a=null===(o=null===(l=e.example)||void 0===l?void 0:l.header_handle)||void 0===o?void 0:o[0])&&void 0!==a?a:"")}))})),le(t),oe(!0)}}),[te]);const pe=l.useMemo((()=>n.convertPlaceholdersToBikDropdown(E)),[E]);return e.jsx(r.TemplateModalContext.Provider,Object.assign({value:{template:X,setTemplate:Z,device:z,setDevice:R,display_content:U,setDisplayContent:$,originalVariableList:ae,setOriginalVariableList:re,isError:G,setIsError:J,channel:v,globalNormalizedPlaceholders:pe,templateSelectionTriggered:se,setTemplateSelectionTriggered:ie,enabledCustomText:M,disableEditVariable:y,pod:A,extras:w,isWhatsappCarousel:Y,selectedCarouselIndex:ne,setSelectedCarouselIndex:de,isProductCarouselType:B,cardCount:null===(O=null===(D=u.components)||void 0===D?void 0:D[1].cards)||void 0===O?void 0:O.length,errorIndexes:K,setErrorIndexes:Q,pickerConf:N,carouselProducts:ue,setCarouselProducts:ce,disableEditExpiry:k,cardWidth:q,cardImages:ee}},{children:x?e.jsx(i.default,{channel:a.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(o.StyledModal,Object.assign({zIndex:b,centralContainerStyles:{width:Y?p||B?900:480:v===a.CHANNEL_TYPE.EMAIL&&p?1e3:800},open:!0,onClose:()=>{null==c||c()},headingTitle:null==X?void 0:X.label,headingSubtitle:v===a.CHANNEL_TYPE.WHATSAPP?`${t.default.capitaliseFirstLetterOfString(null!==(W=null==X?void 0:X.category)&&void 0!==W?W:"")} • ${null!==(F=null==X?void 0:X.templateCategory)&&void 0!==F?F:""}`:"",onBackPress:()=>{null==j||j()}},{children:[e.jsx(i.default,{showSampleValues:L,showVariableMapping:p,channel:v,whatsappSpecificPickerMeta:S,showVariableModal:g,variableList:P,discountCode:T,setDiscountCode:f,variableListForImage:I&&(null==I?void 0:I.length)>0?I:P}),C?e.jsx(s.default,{isWhatsappCarousel:null!=Y&&Y,onSelect:function(){if((null==ue?void 0:ue.length)<1&&B)return void J(!0);const e=null==C?void 0:C(X,ae,null!=U?U:"",ue);(null==e?void 0:e.errorIndexes)||(null==e?void 0:e.error)?((null==e?void 0:e.errorIndexes)&&Q(e.errorIndexes),(null==e?void 0:e.error)&&J(!!(null==e?void 0:e.error))):ie(!0)}}):e.jsx(e.Fragment,{})]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),l=require("react"),t=require("../../utils/StringUtils.js"),o=require("../modals/styledModal.js"),a=require("../template-preview/models/Channels.js"),r=require("./context/templateModalContext.js"),s=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:v,htmlContent:h,templateVariables:m,onTemplateSelect:C,globalPlaceholders:E,showOnlyContent:S,whatsappSpecificPickerMeta:x,zIndex:b,showVariableModal:g,variableList:P,discountCode:T,setDiscountCode:f,onBackPress:j,enabledCustomText:M,variableListForImage:I,showSampleValues:L,disableEditVariable:y,pod:A,extras:w,pickerConf:N,selectedCarouselProducts:V,disableEditExpiry:D,cardWidth:k,onDeleteSelectedProducts:q}=d;var H,_,O,W,F,Y;l.useEffect((()=>{G(h)}),[h]);const B=v===a.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(_=null===(H=u.components)||void 0===H?void 0:H[1])||void 0===_?void 0:_.type),z=u.isProductCarouselType,[R,U]=l.useState(v===a.CHANNEL_TYPE.EMAIL||B?"desktop":"mobile"),[$,G]=l.useState(h),[J,K]=l.useState(!1),[Q,X]=l.useState([]),[Z,ee]=l.useState(u),[le,te]=l.useState([]),[oe,ae]=l.useState(!1),[re,se]=l.useState(null!=m?m:[]),[ie,ne]=l.useState(!1),[de,ue]=l.useState(-1),[ce,pe]=l.useState([]);l.useEffect((()=>{V?pe(V):z&&pe([])}),[V]),l.useEffect((()=>{var e;if(!oe&&z){const l=null===(e=null==Z?void 0:Z.components)||void 0===e?void 0:e[1].cards,t=[];null==l||l.forEach((e=>{var l;null===(l=null==e?void 0:e.components)||void 0===l||l.forEach((e=>{var l,o,a;"HEADER"===e.type&&t.push(null!==(a=null===(o=null===(l=e.example)||void 0===l?void 0:l.header_handle)||void 0===o?void 0:o[0])&&void 0!==a?a:"")}))})),te(t),ae(!0)}}),[oe]);const ve=l.useMemo((()=>n.convertPlaceholdersToBikDropdown(E)),[E]);return e.jsx(r.TemplateModalContext.Provider,Object.assign({value:{template:Z,setTemplate:ee,device:R,setDevice:U,display_content:$,setDisplayContent:G,originalVariableList:re,setOriginalVariableList:se,isError:J,setIsError:K,channel:v,globalNormalizedPlaceholders:ve,templateSelectionTriggered:ie,setTemplateSelectionTriggered:ne,enabledCustomText:M,disableEditVariable:y,pod:A,extras:w,isWhatsappCarousel:B,selectedCarouselIndex:de,setSelectedCarouselIndex:ue,isProductCarouselType:z,cardCount:null===(W=null===(O=u.components)||void 0===O?void 0:O[1].cards)||void 0===W?void 0:W.length,errorIndexes:Q,setErrorIndexes:X,pickerConf:N,carouselProducts:ce,setCarouselProducts:pe,disableEditExpiry:D,cardWidth:k,cardImages:le,onDeleteSelectedProducts:q}},{children:S?e.jsx(i.default,{channel:a.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(o.StyledModal,Object.assign({zIndex:b,centralContainerStyles:{width:B?p||z?900:480:v===a.CHANNEL_TYPE.EMAIL&&p?1e3:800},open:!0,onClose:()=>{null==c||c()},headingTitle:null==Z?void 0:Z.label,headingSubtitle:v===a.CHANNEL_TYPE.WHATSAPP?`${t.default.capitaliseFirstLetterOfString(null!==(F=null==Z?void 0:Z.category)&&void 0!==F?F:"")} • ${null!==(Y=null==Z?void 0:Z.templateCategory)&&void 0!==Y?Y:""}`:"",onBackPress:()=>{null==j||j()}},{children:[e.jsx(i.default,{showSampleValues:L,showVariableMapping:p,channel:v,whatsappSpecificPickerMeta:x,showVariableModal:g,variableList:P,discountCode:T,setDiscountCode:f,variableListForImage:I&&(null==I?void 0:I.length)>0?I:P}),C?e.jsx(s.default,{isWhatsappCarousel:null!=B&&B,onSelect:function(){if((null==ce?void 0:ce.length)<1&&z)return void K(!0);const e=null==C?void 0:C(Z,re,null!=$?$:"",ce);(null==e?void 0:e.errorIndexes)||(null==e?void 0:e.error)?((null==e?void 0:e.errorIndexes)&&X(e.errorIndexes),(null==e?void 0:e.error)&&K(!!(null==e?void 0:e.error))):ne(!0)}}):e.jsx(e.Fragment,{})]}))}))};
@@ -46,6 +46,7 @@ export declare const TemplateModalContext: React.Context<{
46
46
  disableEditExpiry?: boolean | undefined;
47
47
  cardWidth?: number | undefined;
48
48
  cardImages?: string[] | undefined;
49
+ onDeleteSelectedProducts?: (() => void) | undefined;
49
50
  }>;
50
51
  export declare const useTemplateModalContext: () => {
51
52
  device: DEVICE_TYPES;
@@ -86,4 +87,5 @@ export declare const useTemplateModalContext: () => {
86
87
  disableEditExpiry?: boolean | undefined;
87
88
  cardWidth?: number | undefined;
88
89
  cardImages?: string[] | undefined;
90
+ onDeleteSelectedProducts?: (() => void) | undefined;
89
91
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VariableListInterfaceV2 } from "../../add-variableV2";
2
3
  import { WhatsAppPickerMeta } from "../../template-preview";
3
4
  import { WhatsAppCarouselTemplate } from "../../template-preview/models/WhatsappCarouselTemplate";
@@ -21,5 +22,5 @@ export interface CarouselProduct {
21
22
  productName: string;
22
23
  productImage: string;
23
24
  }
24
- declare const EditWhatsAppCarouselTemplateV2: ({ template, whatsappSpecificPickerMeta, showVariableModal, variableList, variableListForImage, discountCode, setDiscountCode, }: EditWhatsAppCarouselTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
25
+ declare const EditWhatsAppCarouselTemplateV2: React.FC<EditWhatsAppCarouselTemplateV2Props>;
25
26
  export default EditWhatsAppCarouselTemplateV2;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/PlusIcon.js"),i=require("lodash"),s=require("react"),r=require("styled-components"),a=require("../../add-variableV2/AddVariableV2SideModal.js");require("../../../_virtual/_tslib.js"),require("../../add-variableV2/AddVariableV2.styled.js");var l=require("../../button/Button.js"),o=require("../../icon-button/IconButton.js");require("../../input/Input.js"),require("../../tooltips/Tooltip.js");var n=require("../../../constants/Theme.js");require("../../modals/modal.styled.js"),require("../../switch/Switch.js");var d=require("../../TypographyStyle.js"),c=require("../../product-picker-v2/modal.js"),u=require("../context/templateModalContext.js"),p=require("./EditWhatsAppTemplateV2.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../curtain/CurtainHelper.js"),require("../../template-preview/models/TemplateMeta.js");var m=require("../../template-preview/models/WhatsAppTemplate.js"),h=require("../../../assets/icons/box.svg.js"),f=require("../../../assets/icons/delete.svg.js"),g=require("../../../assets/icons/edit.svg.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const x=t=>{const{cardBody:i,deleteItem:s,editItem:r}=t;return e.jsxs(y,Object.assign({width:"100%"},{children:[e.jsx("div",Object.assign({style:{width:36,height:36}},{children:e.jsx(h.default,{})})),e.jsx("div",Object.assign({className:"card-body"},{children:e.jsx(d.TitleRegular,{children:i})})),e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[r&&e.jsx(o.IconButton,{style:{display:"flex"},Icon:g.default,onClick:e=>{r(),e.stopPropagation()}}),e.jsx(o.IconButton,{style:{display:"flex",color:"#919191"},Icon:f.default,onClick:e=>{s(),e.stopPropagation()}})]}))]}))},y=j(r).default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/PlusIcon.js"),i=require("lodash"),s=require("react"),r=require("styled-components"),l=require("../../add-variableV2/AddVariableV2SideModal.js");require("../../../_virtual/_tslib.js"),require("../../add-variableV2/AddVariableV2.styled.js");var a=require("../../button/Button.js"),o=require("../../icon-button/IconButton.js");require("../../input/Input.js"),require("../../tooltips/Tooltip.js");var n=require("../../../constants/Theme.js");require("../../modals/modal.styled.js"),require("../../switch/Switch.js");var d=require("../../TypographyStyle.js"),c=require("../../product-picker-v2/modal.js"),u=require("../context/templateModalContext.js"),p=require("./EditWhatsAppTemplateV2.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../curtain/CurtainHelper.js"),require("../../template-preview/models/TemplateMeta.js");var m=require("../../template-preview/models/WhatsAppTemplate.js"),h=require("../../../assets/icons/box.svg.js"),f=require("../../../assets/icons/delete.svg.js"),g=require("../../../assets/icons/edit.svg.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const x=t=>{const{cardBody:i,deleteItem:s,editItem:r}=t;return e.jsxs(y,Object.assign({width:"100%"},{children:[e.jsx("div",Object.assign({style:{width:36,height:36}},{children:e.jsx(h.default,{})})),e.jsx("div",Object.assign({className:"card-body"},{children:e.jsx(d.TitleRegular,{children:i})})),e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[r&&e.jsx(o.IconButton,{style:{display:"flex"},Icon:g.default,onClick:e=>{r(),e.stopPropagation()}}),e.jsx(o.IconButton,{style:{display:"flex",color:"#919191"},Icon:f.default,onClick:e=>{s(),e.stopPropagation()}})]}))]}))},y=j(r).default.div`
2
2
  width: ${e=>e.width};
3
3
  padding: 12px;
4
4
  display: flex;
@@ -44,4 +44,4 @@
44
44
  color: #000000;
45
45
  }
46
46
  }
47
- `;exports.default=r=>{let{template:o,whatsappSpecificPickerMeta:h,showVariableModal:f,variableList:g,variableListForImage:j,discountCode:y,setDiscountCode:v}=r;var b,I;const{selectedCarouselIndex:C,setTemplate:w,pickerConf:q,isProductCarouselType:O,pod:T,cardCount:P,carouselProducts:k,setCarouselProducts:S,isError:B,cardImages:V,disableEditVariable:A}=u.useTemplateModalContext(),[M,E]=s.useState(-1==C?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[L,_]=s.useState(!1),[F,D]=s.useState(!1),[W,z]=s.useState(!1);s.useEffect((()=>{E(-1==C?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[C]);return e.jsxs("div",{children:[e.jsx(d.TitleMedium,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:M})),O&&(null!==(b=null==k?void 0:k.length)&&void 0!==b?b:0)>0&&null!=C&&C>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,flexDirection:"column"}},{children:[e.jsx(x,{editItem:()=>_(!L),cardBody:`${null==k?void 0:k.length} Products Selected`,deleteItem:()=>{const e=i.cloneDeep(Object.assign({},o));e&&(null==V||V.forEach(((t,i)=>{var s;e.components[1].cards[i].components[0].example.header_handle=[null!==(s=V[i])&&void 0!==s?s:""]})),null==w||w(e)),null==S||S([])}}),e.jsx(l.Button,{disabled:(null!==(I=null==k?void 0:k.length)&&void 0!==I?I:0)<=1,style:{alignSelf:"flex-end",background:n.COLORS.surface.subdued},onClick:()=>{D(!0),_(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!A&&O&&0===(null==k?void 0:k.length)&&null!=C&&C>=0&&e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(l.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:B?`2px dashed ${n.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:B?"tertiaryGray":"dashBold",LeadingIcon:t.default,onClick:e=>{_(!0)}}),T===m.POD.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(d.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(l.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:t.default,onClick:e=>{z(!0)}})]})]})),e.jsx(p.default,{whatsappSpecificPickerMeta:h,template:o,onTemplateChange:e=>{null==w||w(e)},showVariableModal:f,variableList:g,variableListForImage:j,discountCode:y,setDiscountCode:v}),L&&q&&e.jsx(c.ProductPickerModal,{zIndex:200,rearrangeEnabled:F,limit:null!=P?P:1,storeId:q.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const i of e){const e=null==i?void 0:i.collectionId,s=i.productId,r=i.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),s in t[e].products||(t[e].products[s]={variants:{},name:(null==i?void 0:i.productName)||"",image:(null==i?void 0:i.productImage)||""}),t[e].products[s].variants[r]={name:(null==i?void 0:i.name)||"",price:"",image:(null==i?void 0:i.image)||"",quantity:i.quantity||0,displayOrder:i.displayOrder}}return t}return{}})(null!=k?k:[]),collectionFetcher:q.fetchCollections,productFetcher:q.fetchProducts,onAdd:(e,t)=>{D(!1);const s=[];delete e.isCustom;for(const t of Object.keys(e)){const i=e[t].products;if(void 0!==i&&Object.keys(i).length)for(const e of Object.keys(i)){const r=i[e].variants;if(void 0!==r&&Object.keys(r).length)for(const a of Object.keys(r)){const{name:l,image:o,quantity:n,displayOrder:d}=r[a],c={name:l,image:o,quantity:n,variantId:a,productId:e,displayOrder:d,collectionId:t,productName:i[e].name,productImage:i[e].image};s.push(c)}}}const r=s.sort(((e,t)=>e.displayOrder-t.displayOrder)),a=s.map((e=>e.image)),l=i.cloneDeep(Object.assign({},o));l&&(a.forEach(((e,t)=>{var i;l.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(i=null==V?void 0:V[t])&&void 0!==i?i:""]})),null==w||w(l)),null==S||S(r),_(!1)},searchInCollectionFetcher:q.searchInCollection,searchFetcher:q.searchProducts,visible:L,onClose:()=>{_(!1)}}),W&&e.jsx(a.AddVariableV2SideModal,{zIndex:2e3,data:null!=g?g:[],showVariable:W,setShowVariable:z,placeholder:"Add a variable",customTrigger:e=>{}})]})};
47
+ `;exports.default=r=>{let{template:o,whatsappSpecificPickerMeta:h,showVariableModal:f,variableList:g,variableListForImage:j,discountCode:y,setDiscountCode:v}=r;var b,I;const{selectedCarouselIndex:C,setTemplate:w,pickerConf:q,isProductCarouselType:O,pod:P,cardCount:T,carouselProducts:k,setCarouselProducts:S,isError:B,cardImages:V,disableEditVariable:A,onDeleteSelectedProducts:M}=u.useTemplateModalContext(),[E,L]=s.useState(-1==C?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[_,D]=s.useState(!1),[F,W]=s.useState(!1),[z,R]=s.useState(!1);s.useEffect((()=>{L(-1==C?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[C]);return e.jsxs("div",{children:[e.jsx(d.TitleMedium,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:E})),O&&(null!==(b=null==k?void 0:k.length)&&void 0!==b?b:0)>0&&null!=C&&C>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,flexDirection:"column"}},{children:[e.jsx(x,{editItem:()=>D(!_),cardBody:`${null==k?void 0:k.length} Products Selected`,deleteItem:()=>{const e=i.cloneDeep(Object.assign({},o));e&&(null==V||V.forEach(((t,i)=>{var s;e.components[1].cards[i].components[0].example.header_handle=[null!==(s=V[i])&&void 0!==s?s:""]})),null==w||w(e)),null==S||S([]),null==M||M()}}),e.jsx(a.Button,{disabled:(null!==(I=null==k?void 0:k.length)&&void 0!==I?I:0)<=1,style:{alignSelf:"flex-end",background:n.COLORS.surface.subdued},onClick:()=>{W(!0),D(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!A&&O&&0===(null==k?void 0:k.length)&&null!=C&&C>=0&&e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:B?`2px dashed ${n.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:B?"tertiaryGray":"dashBold",LeadingIcon:t.default,onClick:e=>{D(!0)}}),P===m.POD.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(d.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:t.default,onClick:e=>{R(!0)}})]})]})),e.jsx(p.default,{whatsappSpecificPickerMeta:h,template:o,onTemplateChange:e=>{null==w||w(e)},showVariableModal:f,variableList:g,variableListForImage:j,discountCode:y,setDiscountCode:v}),_&&q&&e.jsx(c.ProductPickerModal,{zIndex:200,rearrangeEnabled:F,limit:null!=T?T:1,storeId:q.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const i of e){const e=null==i?void 0:i.collectionId,s=i.productId,r=i.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),s in t[e].products||(t[e].products[s]={variants:{},name:(null==i?void 0:i.productName)||"",image:(null==i?void 0:i.productImage)||""}),t[e].products[s].variants[r]={name:(null==i?void 0:i.name)||"",price:"",image:(null==i?void 0:i.image)||"",quantity:i.quantity||0,displayOrder:i.displayOrder}}return t}return{}})(null!=k?k:[]),collectionFetcher:q.fetchCollections,productFetcher:q.fetchProducts,onAdd:(e,t)=>{W(!1);const s=[];delete e.isCustom;for(const t of Object.keys(e)){const i=e[t].products;if(void 0!==i&&Object.keys(i).length)for(const e of Object.keys(i)){const r=i[e].variants;if(void 0!==r&&Object.keys(r).length)for(const l of Object.keys(r)){const{name:a,image:o,quantity:n,displayOrder:d}=r[l],c={name:a,image:o,quantity:n,variantId:l,productId:e,displayOrder:d,collectionId:t,productName:i[e].name,productImage:i[e].image};s.push(c)}}}const r=s.sort(((e,t)=>e.displayOrder-t.displayOrder)),l=s.map((e=>e.image)),a=i.cloneDeep(Object.assign({},o));a&&(l.forEach(((e,t)=>{var i;a.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(i=null==V?void 0:V[t])&&void 0!==i?i:""]})),null==w||w(a)),null==S||S(r),D(!1)},searchInCollectionFetcher:q.searchInCollection,searchFetcher:q.searchProducts,visible:_,onClose:()=>{D(!1)}}),z&&e.jsx(l.AddVariableV2SideModal,{zIndex:2e3,data:null!=g?g:[],showVariable:z,setShowVariable:R,placeholder:"Add a variable",customTrigger:e=>{}})]})};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import 'pure-react-carousel/dist/react-carousel.es.css';
2
3
  import { VariableListInterfaceV2 } from "../add-variableV2/AddVariableV2";
3
4
  import { CarouselProduct } from "./modalElements/EditWhatsAppCarouselTemplateV2";
@@ -45,5 +46,6 @@ export interface TemplateContextMapperProps {
45
46
  selectedCarouselProducts?: CarouselProduct[];
46
47
  disableEditExpiry?: boolean;
47
48
  cardWidth?: number;
49
+ onDeleteSelectedProducts?: () => void;
48
50
  }
49
- 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, selectedCarouselProducts, disableEditExpiry, cardWidth, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
51
+ export declare const TemplateContextMapper: React.FC<TemplateContextMapperProps>;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as l,Fragment as o}from"react/jsx-runtime";import{useEffect as t,useState as r,useMemo as i}from"react";import a from"../../utils/StringUtils.js";import{StyledModal as n}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as d}from"./context/templateModalContext.js";import c from"./modalElements/Footer.js";import u from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const m=m=>{let{selectedTemplate:v,closeDialog:h,showVariableMapping:C,channel:b,htmlContent:g,templateVariables:x,onTemplateSelect:f,globalPlaceholders:E,showOnlyContent:P,whatsappSpecificPickerMeta:S,zIndex:I,showVariableModal:T,variableList:y,discountCode:w,setDiscountCode:M,onBackPress:L,enabledCustomText:V,variableListForImage:j,showSampleValues:A,disableEditVariable:k,pod:D,extras:O,pickerConf:W,selectedCarouselProducts:F,disableEditExpiry:H,cardWidth:z}=m;var B,R,U,$,_,N;t((()=>{X(g)}),[g]);const q=b===s.WHATSAPP&&"CAROUSEL"===(null===(R=null===(B=v.components)||void 0===B?void 0:B[1])||void 0===R?void 0:R.type),G=v.isProductCarouselType,[J,K]=r(b===s.EMAIL||q?"desktop":"mobile"),[Q,X]=r(g),[Y,Z]=r(!1),[ee,le]=r([]),[oe,te]=r(v),[re,ie]=r([]),[ae,ne]=r(!1),[se,de]=r(null!=x?x:[]),[ce,ue]=r(!1),[pe,me]=r(-1),[ve,he]=r([]);t((()=>{F?he(F):G&&he([])}),[F]),t((()=>{var e;if(!ae&&G){const l=null===(e=null==oe?void 0:oe.components)||void 0===e?void 0:e[1].cards,o=[];null==l||l.forEach((e=>{var l;null===(l=null==e?void 0:e.components)||void 0===l||l.forEach((e=>{var l,t,r;"HEADER"===e.type&&o.push(null!==(r=null===(t=null===(l=e.example)||void 0===l?void 0:l.header_handle)||void 0===t?void 0:t[0])&&void 0!==r?r:"")}))})),ie(o),ne(!0)}}),[ae]);const Ce=i((()=>p(E)),[E]);return e(d.Provider,Object.assign({value:{template:oe,setTemplate:te,device:J,setDevice:K,display_content:Q,setDisplayContent:X,originalVariableList:se,setOriginalVariableList:de,isError:Y,setIsError:Z,channel:b,globalNormalizedPlaceholders:Ce,templateSelectionTriggered:ce,setTemplateSelectionTriggered:ue,enabledCustomText:V,disableEditVariable:k,pod:D,extras:O,isWhatsappCarousel:q,selectedCarouselIndex:pe,setSelectedCarouselIndex:me,isProductCarouselType:G,cardCount:null===($=null===(U=v.components)||void 0===U?void 0:U[1].cards)||void 0===$?void 0:$.length,errorIndexes:ee,setErrorIndexes:le,pickerConf:W,carouselProducts:ve,setCarouselProducts:he,disableEditExpiry:H,cardWidth:z,cardImages:re}},{children:P?e(u,{channel:s.EMAIL,hideHeader:!0}):l(n,Object.assign({zIndex:I,centralContainerStyles:{width:q?C||G?900:480:b===s.EMAIL&&C?1e3:800},open:!0,onClose:()=>{null==h||h()},headingTitle:null==oe?void 0:oe.label,headingSubtitle:b===s.WHATSAPP?`${a.capitaliseFirstLetterOfString(null!==(_=null==oe?void 0:oe.category)&&void 0!==_?_:"")} • ${null!==(N=null==oe?void 0:oe.templateCategory)&&void 0!==N?N:""}`:"",onBackPress:()=>{null==L||L()}},{children:[e(u,{showSampleValues:A,showVariableMapping:C,channel:b,whatsappSpecificPickerMeta:S,showVariableModal:T,variableList:y,discountCode:w,setDiscountCode:M,variableListForImage:j&&(null==j?void 0:j.length)>0?j:y}),f?e(c,{isWhatsappCarousel:null!=q&&q,onSelect:function(){if((null==ve?void 0:ve.length)<1&&G)return void Z(!0);const e=null==f?void 0:f(oe,se,null!=Q?Q:"",ve);(null==e?void 0:e.errorIndexes)||(null==e?void 0:e.error)?((null==e?void 0:e.errorIndexes)&&le(e.errorIndexes),(null==e?void 0:e.error)&&Z(!!(null==e?void 0:e.error))):ue(!0)}}):e(o,{})]}))}))};export{m as TemplateContextMapper};
1
+ import{jsx as e,jsxs as l,Fragment as o}from"react/jsx-runtime";import{useEffect as t,useState as r,useMemo as i}from"react";import a from"../../utils/StringUtils.js";import{StyledModal as n}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as d}from"./context/templateModalContext.js";import c from"./modalElements/Footer.js";import u from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const m=m=>{let{selectedTemplate:v,closeDialog:h,showVariableMapping:C,channel:b,htmlContent:g,templateVariables:x,onTemplateSelect:f,globalPlaceholders:E,showOnlyContent:P,whatsappSpecificPickerMeta:S,zIndex:I,showVariableModal:T,variableList:y,discountCode:w,setDiscountCode:M,onBackPress:L,enabledCustomText:V,variableListForImage:j,showSampleValues:A,disableEditVariable:D,pod:k,extras:O,pickerConf:W,selectedCarouselProducts:F,disableEditExpiry:H,cardWidth:z,onDeleteSelectedProducts:B}=m;var R,U,$,_,N,q;t((()=>{Y(g)}),[g]);const G=b===s.WHATSAPP&&"CAROUSEL"===(null===(U=null===(R=v.components)||void 0===R?void 0:R[1])||void 0===U?void 0:U.type),J=v.isProductCarouselType,[K,Q]=r(b===s.EMAIL||G?"desktop":"mobile"),[X,Y]=r(g),[Z,ee]=r(!1),[le,oe]=r([]),[te,re]=r(v),[ie,ae]=r([]),[ne,se]=r(!1),[de,ce]=r(null!=x?x:[]),[ue,pe]=r(!1),[me,ve]=r(-1),[he,Ce]=r([]);t((()=>{F?Ce(F):J&&Ce([])}),[F]),t((()=>{var e;if(!ne&&J){const l=null===(e=null==te?void 0:te.components)||void 0===e?void 0:e[1].cards,o=[];null==l||l.forEach((e=>{var l;null===(l=null==e?void 0:e.components)||void 0===l||l.forEach((e=>{var l,t,r;"HEADER"===e.type&&o.push(null!==(r=null===(t=null===(l=e.example)||void 0===l?void 0:l.header_handle)||void 0===t?void 0:t[0])&&void 0!==r?r:"")}))})),ae(o),se(!0)}}),[ne]);const be=i((()=>p(E)),[E]);return e(d.Provider,Object.assign({value:{template:te,setTemplate:re,device:K,setDevice:Q,display_content:X,setDisplayContent:Y,originalVariableList:de,setOriginalVariableList:ce,isError:Z,setIsError:ee,channel:b,globalNormalizedPlaceholders:be,templateSelectionTriggered:ue,setTemplateSelectionTriggered:pe,enabledCustomText:V,disableEditVariable:D,pod:k,extras:O,isWhatsappCarousel:G,selectedCarouselIndex:me,setSelectedCarouselIndex:ve,isProductCarouselType:J,cardCount:null===(_=null===($=v.components)||void 0===$?void 0:$[1].cards)||void 0===_?void 0:_.length,errorIndexes:le,setErrorIndexes:oe,pickerConf:W,carouselProducts:he,setCarouselProducts:Ce,disableEditExpiry:H,cardWidth:z,cardImages:ie,onDeleteSelectedProducts:B}},{children:P?e(u,{channel:s.EMAIL,hideHeader:!0}):l(n,Object.assign({zIndex:I,centralContainerStyles:{width:G?C||J?900:480:b===s.EMAIL&&C?1e3:800},open:!0,onClose:()=>{null==h||h()},headingTitle:null==te?void 0:te.label,headingSubtitle:b===s.WHATSAPP?`${a.capitaliseFirstLetterOfString(null!==(N=null==te?void 0:te.category)&&void 0!==N?N:"")} • ${null!==(q=null==te?void 0:te.templateCategory)&&void 0!==q?q:""}`:"",onBackPress:()=>{null==L||L()}},{children:[e(u,{showSampleValues:A,showVariableMapping:C,channel:b,whatsappSpecificPickerMeta:S,showVariableModal:T,variableList:y,discountCode:w,setDiscountCode:M,variableListForImage:j&&(null==j?void 0:j.length)>0?j:y}),f?e(c,{isWhatsappCarousel:null!=G&&G,onSelect:function(){if((null==he?void 0:he.length)<1&&J)return void ee(!0);const e=null==f?void 0:f(te,de,null!=X?X:"",he);(null==e?void 0:e.errorIndexes)||(null==e?void 0:e.error)?((null==e?void 0:e.errorIndexes)&&oe(e.errorIndexes),(null==e?void 0:e.error)&&ee(!!(null==e?void 0:e.error))):pe(!0)}}):e(o,{})]}))}))};export{m as TemplateContextMapper};
@@ -46,6 +46,7 @@ export declare const TemplateModalContext: React.Context<{
46
46
  disableEditExpiry?: boolean | undefined;
47
47
  cardWidth?: number | undefined;
48
48
  cardImages?: string[] | undefined;
49
+ onDeleteSelectedProducts?: (() => void) | undefined;
49
50
  }>;
50
51
  export declare const useTemplateModalContext: () => {
51
52
  device: DEVICE_TYPES;
@@ -86,4 +87,5 @@ export declare const useTemplateModalContext: () => {
86
87
  disableEditExpiry?: boolean | undefined;
87
88
  cardWidth?: number | undefined;
88
89
  cardImages?: string[] | undefined;
90
+ onDeleteSelectedProducts?: (() => void) | undefined;
89
91
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VariableListInterfaceV2 } from "../../add-variableV2";
2
3
  import { WhatsAppPickerMeta } from "../../template-preview";
3
4
  import { WhatsAppCarouselTemplate } from "../../template-preview/models/WhatsappCarouselTemplate";
@@ -21,5 +22,5 @@ export interface CarouselProduct {
21
22
  productName: string;
22
23
  productImage: string;
23
24
  }
24
- declare const EditWhatsAppCarouselTemplateV2: ({ template, whatsappSpecificPickerMeta, showVariableModal, variableList, variableListForImage, discountCode, setDiscountCode, }: EditWhatsAppCarouselTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
25
+ declare const EditWhatsAppCarouselTemplateV2: React.FC<EditWhatsAppCarouselTemplateV2Props>;
25
26
  export default EditWhatsAppCarouselTemplateV2;
@@ -1,4 +1,4 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as r}from"lodash";import{useState as l,useEffect as s}from"react";import a from"styled-components";import{AddVariableV2SideModal as n}from"../../add-variableV2/AddVariableV2SideModal.js";import"../../../_virtual/_tslib.js";import"../../add-variableV2/AddVariableV2.styled.js";import{Button as d}from"../../button/Button.js";import{IconButton as c}from"../../icon-button/IconButton.js";import"../../input/Input.js";import"../../tooltips/Tooltip.js";import{COLORS as p}from"../../../constants/Theme.js";import"../../modals/modal.styled.js";import"../../switch/Switch.js";import{TitleMedium as m,BodyCaption as u,TitleRegular as h}from"../../TypographyStyle.js";import{ProductPickerModal as f}from"../../product-picker-v2/modal.js";import{useTemplateModalContext as g}from"../context/templateModalContext.js";import y from"./EditWhatsAppTemplateV2.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import"../../curtain/CurtainHelper.js";import"../../template-preview/models/TemplateMeta.js";import{POD as v}from"../../template-preview/models/WhatsAppTemplate.js";import b from"../../../assets/icons/box.svg.js";import j from"../../../assets/icons/delete.svg.js";import x from"../../../assets/icons/edit.svg.js";const I=a=>{let{template:c,whatsappSpecificPickerMeta:h,showVariableModal:b,variableList:j,variableListForImage:x,discountCode:I,setDiscountCode:C}=a;var O,T;const{selectedCarouselIndex:k,setTemplate:P,pickerConf:V,isProductCarouselType:A,pod:S,cardCount:E,carouselProducts:B,setCarouselProducts:L,isError:_,cardImages:M,disableEditVariable:F}=g(),[W,z]=l(-1==k?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[D,q]=l(!1),[R,N]=l(!1),[$,G]=l(!1);s((()=>{z(-1==k?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[k]);return e("div",{children:[t(m,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:W})),A&&(null!==(O=null==B?void 0:B.length)&&void 0!==O?O:0)>0&&null!=k&&k>=0&&e("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,flexDirection:"column"}},{children:[t(w,{editItem:()=>q(!D),cardBody:`${null==B?void 0:B.length} Products Selected`,deleteItem:()=>{const e=r(Object.assign({},c));e&&(null==M||M.forEach(((t,o)=>{var i;e.components[1].cards[o].components[0].example.header_handle=[null!==(i=M[o])&&void 0!==i?i:""]})),null==P||P(e)),null==L||L([])}}),t(d,{disabled:(null!==(T=null==B?void 0:B.length)&&void 0!==T?T:0)<=1,style:{alignSelf:"flex-end",background:p.surface.subdued},onClick:()=>{N(!0),q(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!F&&A&&0===(null==B?void 0:B.length)&&null!=k&&k>=0&&e("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[t(d,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:_?`2px dashed ${p.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:i,onClick:e=>{q(!0)}}),S===v.CHATBOT&&e(o,{children:[e("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),t(u,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),t(d,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:i,onClick:e=>{G(!0)}})]})]})),t(y,{whatsappSpecificPickerMeta:h,template:c,onTemplateChange:e=>{null==P||P(e)},showVariableModal:b,variableList:j,variableListForImage:x,discountCode:I,setDiscountCode:C}),D&&V&&t(f,{zIndex:200,rearrangeEnabled:R,limit:null!=E?E:1,storeId:V.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const o of e){const e=null==o?void 0:o.collectionId,i=o.productId,r=o.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),i in t[e].products||(t[e].products[i]={variants:{},name:(null==o?void 0:o.productName)||"",image:(null==o?void 0:o.productImage)||""}),t[e].products[i].variants[r]={name:(null==o?void 0:o.name)||"",price:"",image:(null==o?void 0:o.image)||"",quantity:o.quantity||0,displayOrder:o.displayOrder}}return t}return{}})(null!=B?B:[]),collectionFetcher:V.fetchCollections,productFetcher:V.fetchProducts,onAdd:(e,t)=>{N(!1);const o=[];delete e.isCustom;for(const t of Object.keys(e)){const i=e[t].products;if(void 0!==i&&Object.keys(i).length)for(const e of Object.keys(i)){const r=i[e].variants;if(void 0!==r&&Object.keys(r).length)for(const l of Object.keys(r)){const{name:s,image:a,quantity:n,displayOrder:d}=r[l],c={name:s,image:a,quantity:n,variantId:l,productId:e,displayOrder:d,collectionId:t,productName:i[e].name,productImage:i[e].image};o.push(c)}}}const i=o.sort(((e,t)=>e.displayOrder-t.displayOrder)),l=o.map((e=>e.image)),s=r(Object.assign({},c));s&&(l.forEach(((e,t)=>{var o;s.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(o=null==M?void 0:M[t])&&void 0!==o?o:""]})),null==P||P(s)),null==L||L(i),q(!1)},searchInCollectionFetcher:V.searchInCollection,searchFetcher:V.searchProducts,visible:D,onClose:()=>{q(!1)}}),$&&t(n,{zIndex:2e3,data:null!=j?j:[],showVariable:$,setShowVariable:G,placeholder:"Add a variable",customTrigger:e=>{}})]})},w=o=>{const{cardBody:i,deleteItem:r,editItem:l}=o;return e(C,Object.assign({width:"100%"},{children:[t("div",Object.assign({style:{width:36,height:36}},{children:t(b,{})})),t("div",Object.assign({className:"card-body"},{children:t(h,{children:i})})),e("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[l&&t(c,{style:{display:"flex"},Icon:x,onClick:e=>{l(),e.stopPropagation()}}),t(c,{style:{display:"flex",color:"#919191"},Icon:j,onClick:e=>{r(),e.stopPropagation()}})]}))]}))},C=a.div`
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as r}from"lodash";import{useState as l,useEffect as s}from"react";import a from"styled-components";import{AddVariableV2SideModal as n}from"../../add-variableV2/AddVariableV2SideModal.js";import"../../../_virtual/_tslib.js";import"../../add-variableV2/AddVariableV2.styled.js";import{Button as d}from"../../button/Button.js";import{IconButton as c}from"../../icon-button/IconButton.js";import"../../input/Input.js";import"../../tooltips/Tooltip.js";import{COLORS as p}from"../../../constants/Theme.js";import"../../modals/modal.styled.js";import"../../switch/Switch.js";import{TitleMedium as m,BodyCaption as u,TitleRegular as h}from"../../TypographyStyle.js";import{ProductPickerModal as f}from"../../product-picker-v2/modal.js";import{useTemplateModalContext as g}from"../context/templateModalContext.js";import y from"./EditWhatsAppTemplateV2.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import"../../curtain/CurtainHelper.js";import"../../template-preview/models/TemplateMeta.js";import{POD as v}from"../../template-preview/models/WhatsAppTemplate.js";import b from"../../../assets/icons/box.svg.js";import j from"../../../assets/icons/delete.svg.js";import x from"../../../assets/icons/edit.svg.js";const I=a=>{let{template:c,whatsappSpecificPickerMeta:h,showVariableModal:b,variableList:j,variableListForImage:x,discountCode:I,setDiscountCode:C}=a;var O,T;const{selectedCarouselIndex:k,setTemplate:P,pickerConf:S,isProductCarouselType:V,pod:A,cardCount:E,carouselProducts:B,setCarouselProducts:L,isError:_,cardImages:M,disableEditVariable:F,onDeleteSelectedProducts:W}=g(),[z,D]=l(-1==k?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[q,R]=l(!1),[N,$]=l(!1),[G,H]=l(!1);s((()=>{D(-1==k?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[k]);return e("div",{children:[t(m,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:z})),V&&(null!==(O=null==B?void 0:B.length)&&void 0!==O?O:0)>0&&null!=k&&k>=0&&e("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,flexDirection:"column"}},{children:[t(w,{editItem:()=>R(!q),cardBody:`${null==B?void 0:B.length} Products Selected`,deleteItem:()=>{const e=r(Object.assign({},c));e&&(null==M||M.forEach(((t,o)=>{var i;e.components[1].cards[o].components[0].example.header_handle=[null!==(i=M[o])&&void 0!==i?i:""]})),null==P||P(e)),null==L||L([]),null==W||W()}}),t(d,{disabled:(null!==(T=null==B?void 0:B.length)&&void 0!==T?T:0)<=1,style:{alignSelf:"flex-end",background:p.surface.subdued},onClick:()=>{$(!0),R(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!F&&V&&0===(null==B?void 0:B.length)&&null!=k&&k>=0&&e("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[t(d,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:_?`2px dashed ${p.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:i,onClick:e=>{R(!0)}}),A===v.CHATBOT&&e(o,{children:[e("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),t(u,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),t(d,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:i,onClick:e=>{H(!0)}})]})]})),t(y,{whatsappSpecificPickerMeta:h,template:c,onTemplateChange:e=>{null==P||P(e)},showVariableModal:b,variableList:j,variableListForImage:x,discountCode:I,setDiscountCode:C}),q&&S&&t(f,{zIndex:200,rearrangeEnabled:N,limit:null!=E?E:1,storeId:S.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const o of e){const e=null==o?void 0:o.collectionId,i=o.productId,r=o.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),i in t[e].products||(t[e].products[i]={variants:{},name:(null==o?void 0:o.productName)||"",image:(null==o?void 0:o.productImage)||""}),t[e].products[i].variants[r]={name:(null==o?void 0:o.name)||"",price:"",image:(null==o?void 0:o.image)||"",quantity:o.quantity||0,displayOrder:o.displayOrder}}return t}return{}})(null!=B?B:[]),collectionFetcher:S.fetchCollections,productFetcher:S.fetchProducts,onAdd:(e,t)=>{$(!1);const o=[];delete e.isCustom;for(const t of Object.keys(e)){const i=e[t].products;if(void 0!==i&&Object.keys(i).length)for(const e of Object.keys(i)){const r=i[e].variants;if(void 0!==r&&Object.keys(r).length)for(const l of Object.keys(r)){const{name:s,image:a,quantity:n,displayOrder:d}=r[l],c={name:s,image:a,quantity:n,variantId:l,productId:e,displayOrder:d,collectionId:t,productName:i[e].name,productImage:i[e].image};o.push(c)}}}const i=o.sort(((e,t)=>e.displayOrder-t.displayOrder)),l=o.map((e=>e.image)),s=r(Object.assign({},c));s&&(l.forEach(((e,t)=>{var o;s.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(o=null==M?void 0:M[t])&&void 0!==o?o:""]})),null==P||P(s)),null==L||L(i),R(!1)},searchInCollectionFetcher:S.searchInCollection,searchFetcher:S.searchProducts,visible:q,onClose:()=>{R(!1)}}),G&&t(n,{zIndex:2e3,data:null!=j?j:[],showVariable:G,setShowVariable:H,placeholder:"Add a variable",customTrigger:e=>{}})]})},w=o=>{const{cardBody:i,deleteItem:r,editItem:l}=o;return e(C,Object.assign({width:"100%"},{children:[t("div",Object.assign({style:{width:36,height:36}},{children:t(b,{})})),t("div",Object.assign({className:"card-body"},{children:t(h,{children:i})})),e("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[l&&t(c,{style:{display:"flex"},Icon:x,onClick:e=>{l(),e.stopPropagation()}}),t(c,{style:{display:"flex",color:"#919191"},Icon:j,onClick:e=>{r(),e.stopPropagation()}})]}))]}))},C=a.div`
2
2
  width: ${e=>e.width};
3
3
  padding: 12px;
4
4
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.442.beta.link.4",
3
+ "version": "0.0.442.beta.link.5",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",