@ikas/popup-renderer 1.0.155 → 1.0.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import e from"react";import{observer as t}from"mobx-react";import{PopupTypeEnum as o,PopupPositonEnum as i}from"../models/modal/index.js";import n from"../assets/x-close.js";import{CloseButtonPositionTypeEnum as r,CloseIconTypeEnum as l,CloseButtonDisplayTypeEnum as s}from"../models/modal/close-settings/index.js";import{PopupElementTypeEnum as d,ComponentVerticalAlignmentEnum as a}from"../models/modal/step/elements/base/index.js";import c from"./text-element-renderer/index.js";import m from"./button-element-renderer/index.js";import p from"./space-element-renderer/index.js";import u from"./divider-element-renderer/index.js";import f from"./social-element-renderer/index.js";import P from"./image-element-renderer/index.js";import x from"./image-column-element-renderer/index.js";import E from"./product-list-renderer/index.js";import v from"./form-element-renderer/index.js";import{ImageColumnPositionEnum as g,MobileImageColumnPositionEnum as T}from"../models/modal/step/elements/image-column/index.js";var b=t((function(t){var b,y,O,I,_=t.popup,h=t.dynamicData,C=t.dashboardComponents,M=t.previewMode,w=t.sfProps,A=t.isMobile,D=_.modal,R=D.teaser,S=!!D.selectedStep.isTeaser,k=D.selectedStep.elements.find((function(e){return e.type===d.IMAGE_COLUMN})),N=S?R.backgroundSettings:D.backgroundSettings,L=S?R.windowSettings:D.windowSettings,j=S?R.closeSettings:D.closeSettings,U=N.allowScrollingWhenPopupOpen,B=_.isPreviewMode||M,H=!!B||D.isVisible;document.body.style.overflow=H&&!U?"hidden":"auto";var W=N.overlay,F=N.border,V="center",G="center";switch(S?o.POPUP:D.type){case o.POPUP:var z=S?R.position:D.position;z===i.POPUP_TOP_LEFT?(V="flex-start",G="flex-start"):z===i.POPUP_TOP_CENTER?(V="center",G="flex-start"):z===i.POPUP_TOP_RIGHT?(V="flex-end",G="flex-start"):z===i.POPUP_MIDDLE_LEFT?(V="flex-start",G="center"):z===i.POPUP_MIDDLE_CENTER?(V="center",G="center"):z===i.POPUP_MIDDLE_RIGHT?(V="flex-end",G="center"):z===i.POPUP_BOTTOM_LEFT?(V="flex-start",G="flex-end"):z===i.POPUP_BOTTOM_CENTER?(V="center",G="flex-end"):z===i.POPUP_BOTTOM_RIGHT&&(V="flex-end",G="flex-end");break;case o.DRAWER:D.position===i.DRAWER_LEFT?(V="flex-start",G="center"):D.position===i.DRAWER_RIGHT&&(V="flex-end",G="center");break;case o.NOTIFICATION_BAR:D.position===i.NOTIFICATION_BAR_UP?(V="center",G="flex-start"):D.position===i.NOTIFICATION_BAR_DOWN&&(V="center",G="flex-end")}var K=e.useMemo((function(){return 2147483644}),[]),X=e.useMemo((function(){return K+1}),[]),Y=e.useMemo((function(){return X+1}),[]),q=e.useMemo((function(){return Y+1}),[]),J={position:"fixed",display:"flex",justifyContent:V,alignItems:G,top:0,left:0,right:0,bottom:0,zIndex:K,overflow:"hidden",padding:"".concat(L.outerVerticalPadding,"px ").concat(L.outerHorizontalPadding,"px"),opacity:H?1:0,visibility:H?"visible":"hidden",transition:"opacity 0.3s ease, visibility 0.3s ease"},Q={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:X,backgroundColor:W?W.bgColor:"",opacity:W?(W.bgOpacity||100)/100:void 0},Z={position:"relative",zIndex:Y,backgroundColor:N.bgColor,border:F?"".concat(F.borderWidth,"px ").concat(F.borderStyle," ").concat(F.borderColor):"",borderRadius:"".concat(L.borderRadius,"px"),maxWidth:"100%",maxHeight:"100%",width:L.takeFullWidth?"100%":void 0,minHeight:L.minHeight,height:L.takeFullHeight?"100%":void 0,boxShadow:N.shadow?"0 0 10px ".concat(N.shadow.color):"",overflow:"auto",opacity:H?1:0,visibility:H?"visible":"hidden",transition:"opacity 0.3s ease, visibility 0.3s ease"},$="";switch(null==k?void 0:k.verticalAlignment){case a.BOTTOM:$="flex-end";break;case a.MIDDLE:$="center";break;case a.TOP:$="flex-start"}var ee=k?k.imagePosition===g.LEFT_ALIGN?"row-reverse":"row":"",te=k?k.mobilePosition===T.TOP?"column-reverse":"column":"",oe={display:"flex",flexDirection:k?A?te:ee:"column"},ie={width:L.takeFullWidth?"100%":L.maxWidth,maxWidth:"100%",overflow:"auto",display:"flex",flexDirection:"column",justifyContent:$,padding:"".concat(L.innerVerticalPadding,"px ").concat(L.innerHorizontalPadding,"px")},ne={position:j.closeButtonPositionType===r.TAKE_SPACE?"relative":"absolute",float:j.closeButtonPositionType===r.TAKE_SPACE?"right":"none",top:8,right:8,zIndex:q},re={position:"sticky",padding:"6px",marginLeft:j.closeButtonPositionType===r.TAKE_SPACE?"14px":void 0,display:"flex",justifyContent:"center",alignItems:"center",border:(null===(b=j.iconSettings)||void 0===b?void 0:b.type)===l.WITH_BORDER?"1px solid ".concat(null===(y=j.iconSettings)||void 0===y?void 0:y.color):"",borderRadius:"50%",backgroundColor:null===(O=j.iconSettings)||void 0===O?void 0:O.backgroundColor},le={color:null===(I=j.iconSettings)||void 0===I?void 0:I.color,cursor:"pointer"},se=function(t){var o=t.type,i=C&&C[o]&&C[o].length?C[o][0]:null,n=i&&_.marketingPopupViewModel?e.createElement(i,{element:t,marketingPopupViewModel:_.marketingPopupViewModel}):void 0;switch(o){case d.TEXT:return e.createElement(c,{element:t});case d.IMAGE:return e.createElement(P,{element:t,popup:_,editModeChildren:n});case d.IMAGE_COLUMN:return A&&k.mobilePosition===T.HIDE?null:e.createElement(x,{element:t,popup:_,editModeChildren:n,isMobile:A});case d.BUTTON:return e.createElement(m,{element:t});case d.DIVIDER:return e.createElement(u,{element:t});case d.FORM:return e.createElement(v,{element:t,popup:_,isPreviewMode:!!B,sfProps:w});case d.PRODUCT_LIST:return e.createElement(E,{element:t,products:h.products[t.id],popup:_,editModeChildren:n,isPreviewMode:!!B,sfProps:w,onClose:de});case d.SOCIAL_MEDIA:return e.createElement(f,{element:t,popup:_,editModeChildren:n});case d.SPACE:return e.createElement(p,{element:t})}},de=function(e){B||D.isVisible&&(D.isVisible=!1,w&&w.onModalClose(e))};return e.createElement("div",{className:"ikas-popup-default-styles",id:"ikas-popup-container",style:J},e.createElement("div",{style:Z},j.closeButtonDisplayType!==s.ALWAYS_HIDDEN&&e.createElement("div",{style:ne,onClick:function(){return de()}},e.createElement("div",{style:re,className:j.closeButtonDisplayType===s.VISIBLE_ON_HOVER?"visible-on-hover":""},e.createElement(n,{style:le}))),e.createElement("div",{style:oe,onClick:function(e){S&&(D.selectedStep=D.steps[0])}},e.createElement("div",{style:ie},D.selectedStep.elements.filter((function(e){return e.type!==d.IMAGE_COLUMN})).slice().sort((function(e,t){return e.order-t.order})).map((function(e){return se(e)}))),k&&se(k))),e.createElement("div",{style:Q,onClick:function(){return de()}}))}));export{b as default};
1
+ import e from"react";import{observer as t}from"mobx-react";import{PopupTypeEnum as o,PopupPositonEnum as i}from"../models/modal/index.js";import n from"../assets/x-close.js";import{CloseButtonPositionTypeEnum as r,CloseIconTypeEnum as l,CloseButtonDisplayTypeEnum as s}from"../models/modal/close-settings/index.js";import{PopupElementTypeEnum as d,ComponentVerticalAlignmentEnum as a}from"../models/modal/step/elements/base/index.js";import c from"./text-element-renderer/index.js";import m from"./button-element-renderer/index.js";import p from"./space-element-renderer/index.js";import u from"./divider-element-renderer/index.js";import f from"./social-element-renderer/index.js";import P from"./image-element-renderer/index.js";import x from"./image-column-element-renderer/index.js";import E from"./product-list-renderer/index.js";import v from"./form-element-renderer/index.js";import{ImageColumnPositionEnum as g,MobileImageColumnPositionEnum as T}from"../models/modal/step/elements/image-column/index.js";var b=t((function(t){var b,y,O,I,_=t.popup,h=t.dynamicData,C=t.dashboardComponents,M=t.previewMode,w=t.sfProps,A=t.isMobile,D=_.modal,R=D.teaser,S=!!D.selectedStep.isTeaser,k=D.selectedStep.elements.find((function(e){return e.type===d.IMAGE_COLUMN})),N=S?R.backgroundSettings:D.backgroundSettings,L=S?R.windowSettings:D.windowSettings,j=S?R.closeSettings:D.closeSettings,U=N.allowScrollingWhenPopupOpen,B=_.isPreviewMode||M,H=!!B||D.isVisible;document.body.style.overflow=H&&!U?"hidden":"auto";var W=N.overlay,F=N.border,V="center",G="center";switch(S?o.POPUP:D.type){case o.POPUP:var z=S?R.position:D.position;z===i.POPUP_TOP_LEFT?(V="flex-start",G="flex-start"):z===i.POPUP_TOP_CENTER?(V="center",G="flex-start"):z===i.POPUP_TOP_RIGHT?(V="flex-end",G="flex-start"):z===i.POPUP_MIDDLE_LEFT?(V="flex-start",G="center"):z===i.POPUP_MIDDLE_CENTER?(V="center",G="center"):z===i.POPUP_MIDDLE_RIGHT?(V="flex-end",G="center"):z===i.POPUP_BOTTOM_LEFT?(V="flex-start",G="flex-end"):z===i.POPUP_BOTTOM_CENTER?(V="center",G="flex-end"):z===i.POPUP_BOTTOM_RIGHT&&(V="flex-end",G="flex-end");break;case o.DRAWER:D.position===i.DRAWER_LEFT?(V="flex-start",G="center"):D.position===i.DRAWER_RIGHT&&(V="flex-end",G="center");break;case o.NOTIFICATION_BAR:D.position===i.NOTIFICATION_BAR_UP?(V="center",G="flex-start"):D.position===i.NOTIFICATION_BAR_DOWN&&(V="center",G="flex-end")}var K=e.useMemo((function(){return 2147483644}),[]),X=e.useMemo((function(){return K+1}),[]),Y=e.useMemo((function(){return X+1}),[]),q=e.useMemo((function(){return Y+1}),[]),J={position:"fixed",display:"flex",justifyContent:V,alignItems:G,top:0,left:0,right:0,bottom:0,zIndex:K,overflow:"hidden",padding:"".concat(L.outerVerticalPadding,"px ").concat(L.outerHorizontalPadding,"px"),opacity:H?1:0,visibility:H?"visible":"hidden",transition:"opacity 0.3s ease, visibility 0.3s ease"},Q={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:X,backgroundColor:W?W.bgColor:"",opacity:W?(W.bgOpacity||100)/100:void 0},Z={position:"relative",zIndex:Y,backgroundColor:N.bgColor,border:F?"".concat(F.borderWidth,"px ").concat(F.borderStyle," ").concat(F.borderColor):"",borderRadius:"".concat(L.borderRadius,"px"),maxWidth:"100%",maxHeight:"100%",width:L.takeFullWidth?"100%":void 0,minHeight:L.minHeight,height:L.takeFullHeight?"100%":void 0,boxShadow:N.shadow?"0 0 10px ".concat(N.shadow.color):"",overflow:"auto",opacity:H?1:0,visibility:H?"visible":"hidden",transition:"opacity 0.3s ease, visibility 0.3s ease"},$="";switch(null==k?void 0:k.verticalAlignment){case a.BOTTOM:$="flex-end";break;case a.MIDDLE:$="center";break;case a.TOP:$="flex-start"}var ee=k?k.imagePosition===g.LEFT_ALIGN?"row-reverse":"row":"",te=k?k.mobilePosition===T.TOP?"column-reverse":"column":"",oe={display:"flex",flexDirection:k?A?te:ee:"column",overflow:"hidden"},ie={width:L.takeFullWidth?"100%":L.maxWidth,maxWidth:"100%",overflow:"auto",display:"flex",flexDirection:"column",justifyContent:$,padding:"".concat(L.innerVerticalPadding,"px ").concat(L.innerHorizontalPadding,"px")},ne={position:j.closeButtonPositionType===r.TAKE_SPACE?"relative":"absolute",float:j.closeButtonPositionType===r.TAKE_SPACE?"right":"none",top:8,right:8,zIndex:q},re={position:"sticky",padding:"6px",marginLeft:j.closeButtonPositionType===r.TAKE_SPACE?"14px":void 0,display:"flex",justifyContent:"center",alignItems:"center",border:(null===(b=j.iconSettings)||void 0===b?void 0:b.type)===l.WITH_BORDER?"1px solid ".concat(null===(y=j.iconSettings)||void 0===y?void 0:y.color):"",borderRadius:"50%",backgroundColor:null===(O=j.iconSettings)||void 0===O?void 0:O.backgroundColor},le={color:null===(I=j.iconSettings)||void 0===I?void 0:I.color,cursor:"pointer"},se=function(t){var o=t.type,i=C&&C[o]&&C[o].length?C[o][0]:null,n=i&&_.marketingPopupViewModel?e.createElement(i,{element:t,marketingPopupViewModel:_.marketingPopupViewModel}):void 0;switch(o){case d.TEXT:return e.createElement(c,{element:t});case d.IMAGE:return e.createElement(P,{element:t,popup:_,editModeChildren:n});case d.IMAGE_COLUMN:return A&&k.mobilePosition===T.HIDE?null:e.createElement(x,{element:t,popup:_,editModeChildren:n,isMobile:A});case d.BUTTON:return e.createElement(m,{element:t});case d.DIVIDER:return e.createElement(u,{element:t});case d.FORM:return e.createElement(v,{element:t,popup:_,isPreviewMode:!!B,sfProps:w});case d.PRODUCT_LIST:return e.createElement(E,{element:t,products:h.products[t.id],popup:_,editModeChildren:n,isPreviewMode:!!B,sfProps:w,onClose:de});case d.SOCIAL_MEDIA:return e.createElement(f,{element:t,popup:_,editModeChildren:n});case d.SPACE:return e.createElement(p,{element:t})}},de=function(e){B||D.isVisible&&(D.isVisible=!1,w&&w.onModalClose(e))};return e.createElement("div",{className:"ikas-popup-default-styles",id:"ikas-popup-container",style:J},e.createElement("div",{style:Z},j.closeButtonDisplayType!==s.ALWAYS_HIDDEN&&e.createElement("div",{style:ne,onClick:function(){return de()}},e.createElement("div",{style:re,className:j.closeButtonDisplayType===s.VISIBLE_ON_HOVER?"visible-on-hover":""},e.createElement(n,{style:le}))),e.createElement("div",{style:oe,onClick:function(e){S&&(D.selectedStep=D.steps[0])}},e.createElement("div",{style:ie},D.selectedStep.elements.filter((function(e){return e.type!==d.IMAGE_COLUMN})).slice().sort((function(e,t){return e.order-t.order})).map((function(e){return se(e)}))),k&&se(k))),e.createElement("div",{style:Q,onClick:function(){return de()}}))}));export{b as default};
@@ -1 +1 @@
1
- import{__spreadArray as t,__assign as e,__awaiter as o,__generator as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import i from"react";import{observer as l}from"mobx-react";import{getHorizontalAlignment as r,injectFontScript as d}from"../../helpers/index.js";import{ProductListTypeEnum as a,ProductListLayoutEnum as c}from"../../models/modal/step/elements/product/index.js";import u from"../button-element-renderer/index.js";import{Navigation as s,Scrollbar as v}from"swiper/modules";import{Swiper as m,SwiperSlide as g}from"swiper/react";import p from"../../assets/left-arrow.js";import f from"../../assets/right-arrow.js";import{ProductActionTypeEnum as b}from"../../models/modal/step/elements/product/detail-settings/index.js";var h=l((function(l){var h,x=l.element,y=l.products,C=l.popup,E=l.editModeChildren,w=l.isPreviewMode,P=l.sfProps,S=l.onClose,R=i.useState(null),z=R[0],W=R[1],j=i.useState(!1),I=j[0],D=j[1],F=i.useState(!1),k=F[0],A=F[1],T=x,N=[];if(y&&(N=T.listType===a.SPECIFIC?(null===(h=T.variantPairs)||void 0===h?void 0:h.length)?y.slice().sort((function(t,e){return T.variantPairs.findIndex((function(e){return e.variantId===t.variantId}))-T.variantPairs.findIndex((function(t){return t.variantId===e.variantId}))})):[]:t([],y,!0)),N.length>T.maxProductsToShow&&(N.length=T.maxProductsToShow),!(N&&N.length||!C.isPreviewMode)&&E)return E;if(!N||!N.length)return null;T.gapBetweenProductElements;var _=T.productDetailSettings.image,B=T.productDetailSettings.button,M=T.buttonSettings,O=T.productDetailSettings.discountRatio,L=T.productDetailSettings.finalPrice,U=T.productDetailSettings.originalPrice,H=T.productDetailSettings.name,V=r(T.horizontalAlignment),$=1;T.layout===c.ONE_COLUMN?$=1:T.layout===c.TWO_COLUMN?$=2:T.layout===c.THREE_COLUMN&&($=3);var q={padding:"".concat(T.outerVerticalPadding,"px ").concat(T.outerHorizontalPadding,"px"),backgroundColor:T.productBgColor,width:"100%",height:"max-content"},G={display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center",height:"100%"},J={display:"flex",justifyContent:V,alignItems:"center",width:"100%",backgroundColor:null==_?void 0:_.bgColor,borderRadius:(null==_?void 0:_.borderRadius)?"".concat(_.borderRadius,"px"):void 0},K={width:"".concat(null==_?void 0:_.maxWidth,"%"),objectFit:"contain",borderRadius:(null==_?void 0:_.borderRadius)?"".concat(_.borderRadius,"px"):void 0},Q={display:"flex",flexDirection:"column",width:"100%"},X={display:"flex",flexDirection:"column"},Y={backgroundColor:null==H?void 0:H.bgColor,color:null==H?void 0:H.color,fontFamily:H?d(H.fontFamily):void 0,fontSize:null==H?void 0:H.fontSize,fontWeight:null==H?void 0:H.fontWeight,padding:"".concat(null==H?void 0:H.verticalPadding,"px ").concat(null==H?void 0:H.horizontalPadding,"px"),width:"100%",textAlign:null==H?void 0:H.horizontalAlignment,border:"".concat(null==H?void 0:H.borderWidth,"px ").concat(null==H?void 0:H.borderStyle," ").concat(null==H?void 0:H.borderColor),borderRadius:null==H?void 0:H.borderRadius},Z={backgroundColor:null==O?void 0:O.bgColor,color:null==O?void 0:O.color,fontFamily:O?d(O.fontFamily):void 0,fontSize:null==O?void 0:O.fontSize,fontWeight:null==O?void 0:O.fontWeight,padding:"".concat(null==O?void 0:O.verticalPadding,"px ").concat(null==O?void 0:O.horizontalPadding,"px"),width:"100%",textAlign:null==O?void 0:O.horizontalAlignment,border:"".concat(null==O?void 0:O.borderWidth,"px ").concat(null==O?void 0:O.borderStyle," ").concat(null==O?void 0:O.borderColor),borderRadius:null==O?void 0:O.borderRadius},tt={textDecoration:"line-through",backgroundColor:null==U?void 0:U.bgColor,color:null==U?void 0:U.color,fontFamily:U?d(U.fontFamily):void 0,fontSize:null==U?void 0:U.fontSize,fontWeight:null==U?void 0:U.fontWeight,padding:"".concat(null==U?void 0:U.verticalPadding,"px ").concat(null==U?void 0:U.horizontalPadding,"px"),width:"100%",textAlign:null==U?void 0:U.horizontalAlignment,border:"".concat(null==U?void 0:U.borderWidth,"px ").concat(null==U?void 0:U.borderStyle," ").concat(null==U?void 0:U.borderColor),borderRadius:null==U?void 0:U.borderRadius},et={backgroundColor:null==L?void 0:L.bgColor,color:null==L?void 0:L.color,fontFamily:L?d(L.fontFamily):void 0,fontSize:null==L?void 0:L.fontSize,fontWeight:null==L?void 0:L.fontWeight,padding:"".concat(null==L?void 0:L.verticalPadding,"px ").concat(null==L?void 0:L.horizontalPadding,"px"),width:"100%",textAlign:null==L?void 0:L.horizontalAlignment,border:"".concat(null==L?void 0:L.borderWidth,"px ").concat(null==L?void 0:L.borderStyle," ").concat(null==L?void 0:L.borderColor),borderRadius:null==L?void 0:L.borderRadius},ot={width:"".concat(M.width,"%"),minWidth:"fit-content"},nt=e({display:"flex",justifyContent:"center",width:"100%",gap:"10px"},1===$?{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"space-between",zIndex:10}:void 0),it={padding:10,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",border:"1px solid #EEF2F6",cursor:"pointer"};return i.createElement("div",{style:q},i.createElement(m,{onSwiper:W,modules:[s,v],spaceBetween:T.gapBetweenProducts,slidesPerView:$,navigation:{nextEl:".custom-next-button",prevEl:".custom-prev-button"},scrollbar:void 0},N.map((function(t,e){return i.createElement(g,{style:{height:"auto"},key:t.variantId},i.createElement("div",{style:G,onClick:function(){return function(t){return o(void 0,void 0,void 0,(function(){var e,o;return n(this,(function(n){switch(n.label){case 0:return w||!t.url?[3,4]:(null===(o=T.productDetailSettings.button)||void 0===o?void 0:o.action)===b.ADD_TO_CART&&P?[4,P.addProductToCart(t)]:[3,2];case 1:return n.sent(),[3,3];case 2:(e=document.createElement("a")).href=t.url,e.target="_self",e.click(),n.label=3;case 3:S(!0),n.label=4;case 4:return[2]}}))}))}(t)}},i.createElement("div",{style:Q},!!_&&t.imageURL&&i.createElement("div",{style:J},i.createElement("img",{src:t.imageURL||void 0,alt:t.name||void 0,style:K})),(!!H||!!O)&&i.createElement("div",{style:X},!!H&&i.createElement("div",{style:Y},t.name),!!O&&!!t.discountPrice&&i.createElement("div",{style:Z},t.$discountRatio)),(!!U||!!L)&&i.createElement("div",null,!!U&&!!t.discountPrice&&i.createElement("div",{style:tt},t.price),!!L&&i.createElement("div",{style:et},t.discountPrice||t.price))),!!B&&i.createElement("div",{style:ot}," ",i.createElement(u,{element:M})," ")))})),i.createElement("div",{style:nt},i.createElement("div",{className:"custom-prev-button",style:e(e({},it),I?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){z&&(z.slidePrev(),A(z.isEnd),D(z.isBeginning))}},i.createElement(p,null)),i.createElement("div",{className:"custom-next-button",style:e(e({},it),k?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){z&&(z.slideNext(),A(z.isEnd),D(z.isBeginning))}},i.createElement(f,null)))))}));export{h as default};
1
+ import{__spreadArray as e,__assign as t,__awaiter as o,__generator as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import i from"react";import{observer as l}from"mobx-react";import{getHorizontalAlignment as r,injectFontScript as d}from"../../helpers/index.js";import{ProductListTypeEnum as a,ProductListLayoutEnum as c}from"../../models/modal/step/elements/product/index.js";import u from"../button-element-renderer/index.js";import{Navigation as s,Scrollbar as v}from"swiper/modules";import{Swiper as m,SwiperSlide as g}from"swiper/react";import p from"../../assets/left-arrow.js";import f from"../../assets/right-arrow.js";import{ProductActionTypeEnum as b}from"../../models/modal/step/elements/product/detail-settings/index.js";var h=l((function(l){var h,x=l.element,y=l.products,C=l.popup,E=l.editModeChildren,w=l.isPreviewMode,P=l.sfProps,S=l.onClose,R=i.useState(null),z=R[0],W=R[1],j=i.useState(!1),I=j[0],D=j[1],k=i.useState(!1),F=k[0],A=k[1],T=x,N=[];if(y&&(N=T.listType===a.SPECIFIC?(null===(h=T.variantPairs)||void 0===h?void 0:h.length)?y.slice().sort((function(e,t){return T.variantPairs.findIndex((function(t){return t.variantId===e.variantId}))-T.variantPairs.findIndex((function(e){return e.variantId===t.variantId}))})):[]:e([],y,!0)),N.length>T.maxProductsToShow&&(N.length=T.maxProductsToShow),!(N&&N.length||!C.isPreviewMode)&&E)return E;if(!N||!N.length)return null;T.gapBetweenProductElements;var _=T.productDetailSettings.image,B=T.productDetailSettings.button,M=T.buttonSettings,O=T.productDetailSettings.discountRatio,L=T.productDetailSettings.finalPrice,U=T.productDetailSettings.originalPrice,H=T.productDetailSettings.name,V=r(T.horizontalAlignment),$=1;T.layout===c.ONE_COLUMN?$=1:T.layout===c.TWO_COLUMN?$=2:T.layout===c.THREE_COLUMN&&($=3);var q={padding:"".concat(T.outerVerticalPadding,"px ").concat(T.outerHorizontalPadding,"px"),backgroundColor:T.productBgColor,width:"100%",height:"max-content"},G={display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center",height:"100%"},J={display:"flex",justifyContent:V,alignItems:"center",width:"100%",backgroundColor:null==_?void 0:_.bgColor,borderRadius:(null==_?void 0:_.borderRadius)?"".concat(_.borderRadius,"px"):void 0},K={width:"".concat(null==_?void 0:_.maxWidth,"%"),objectFit:"contain",borderRadius:(null==_?void 0:_.borderRadius)?"".concat(_.borderRadius,"px"):void 0},Q={display:"flex",flexDirection:"column",width:"100%"},X={display:"flex",flexDirection:"column"},Y={backgroundColor:null==H?void 0:H.bgColor,color:null==H?void 0:H.color,fontFamily:H?d(H.fontFamily):void 0,fontSize:null==H?void 0:H.fontSize,fontWeight:null==H?void 0:H.fontWeight,padding:"".concat(null==H?void 0:H.verticalPadding,"px ").concat(null==H?void 0:H.horizontalPadding,"px"),width:"100%",textAlign:null==H?void 0:H.horizontalAlignment,border:"".concat(null==H?void 0:H.borderWidth,"px ").concat(null==H?void 0:H.borderStyle," ").concat(null==H?void 0:H.borderColor),borderRadius:null==H?void 0:H.borderRadius},Z={backgroundColor:null==O?void 0:O.bgColor,color:null==O?void 0:O.color,fontFamily:O?d(O.fontFamily):void 0,fontSize:null==O?void 0:O.fontSize,fontWeight:null==O?void 0:O.fontWeight,padding:"".concat(null==O?void 0:O.verticalPadding,"px ").concat(null==O?void 0:O.horizontalPadding,"px"),width:"100%",textAlign:null==O?void 0:O.horizontalAlignment,border:"".concat(null==O?void 0:O.borderWidth,"px ").concat(null==O?void 0:O.borderStyle," ").concat(null==O?void 0:O.borderColor),borderRadius:null==O?void 0:O.borderRadius},ee={textDecoration:"line-through",backgroundColor:null==U?void 0:U.bgColor,color:null==U?void 0:U.color,fontFamily:U?d(U.fontFamily):void 0,fontSize:null==U?void 0:U.fontSize,fontWeight:null==U?void 0:U.fontWeight,padding:"".concat(null==U?void 0:U.verticalPadding,"px ").concat(null==U?void 0:U.horizontalPadding,"px"),width:"100%",textAlign:null==U?void 0:U.horizontalAlignment,border:"".concat(null==U?void 0:U.borderWidth,"px ").concat(null==U?void 0:U.borderStyle," ").concat(null==U?void 0:U.borderColor),borderRadius:null==U?void 0:U.borderRadius},te={backgroundColor:null==L?void 0:L.bgColor,color:null==L?void 0:L.color,fontFamily:L?d(L.fontFamily):void 0,fontSize:null==L?void 0:L.fontSize,fontWeight:null==L?void 0:L.fontWeight,padding:"".concat(null==L?void 0:L.verticalPadding,"px ").concat(null==L?void 0:L.horizontalPadding,"px"),width:"100%",textAlign:null==L?void 0:L.horizontalAlignment,border:"".concat(null==L?void 0:L.borderWidth,"px ").concat(null==L?void 0:L.borderStyle," ").concat(null==L?void 0:L.borderColor),borderRadius:null==L?void 0:L.borderRadius},oe={width:"".concat(M.width,"%"),minWidth:"fit-content"},ne=t({display:"flex",justifyContent:"center",width:"100%",gap:"10px"},1===$?{position:"absolute",top:"calc(50% - 25px)",alignItems:"center",justifyContent:"space-between",zIndex:10}:void 0),ie={padding:10,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",border:"1px solid #EEF2F6",cursor:"pointer"};return i.createElement("div",{style:q},i.createElement(m,{onSwiper:W,modules:[s,v],spaceBetween:T.gapBetweenProducts,slidesPerView:$,navigation:{nextEl:".custom-next-button",prevEl:".custom-prev-button"},scrollbar:void 0},N.map((function(e,t){return i.createElement(g,{style:{height:"auto"},key:e.variantId},i.createElement("div",{style:G,onClick:function(){return function(e){return o(void 0,void 0,void 0,(function(){var t,o;return n(this,(function(n){switch(n.label){case 0:return console.log("onClick"),console.log(w),console.log(e.url),w||!e.url?[3,4]:(null===(o=T.productDetailSettings.button)||void 0===o?void 0:o.action)===b.ADD_TO_CART&&P?[4,P.addProductToCart(e)]:[3,2];case 1:return n.sent(),[3,3];case 2:(t=document.createElement("a")).href=e.url,t.target="_self",t.click(),n.label=3;case 3:S(!0),n.label=4;case 4:return[2]}}))}))}(e)}},i.createElement("div",{style:Q},!!_&&e.imageURL&&i.createElement("div",{style:J},i.createElement("img",{src:e.imageURL||void 0,alt:e.name||void 0,style:K})),(!!H||!!O)&&i.createElement("div",{style:X},!!H&&i.createElement("div",{style:Y},e.name),!!O&&!!e.discountPrice&&i.createElement("div",{style:Z},e.$discountRatio)),(!!U||!!L)&&i.createElement("div",null,!!U&&!!e.discountPrice&&i.createElement("div",{style:ee},e.price),!!L&&i.createElement("div",{style:te},e.discountPrice||e.price))),!!B&&i.createElement("div",{style:oe}," ",i.createElement(u,{element:M})," ")))})),i.createElement("div",{style:ne},i.createElement("div",{className:"custom-prev-button",style:t(t({},ie),I?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){z&&(z.slidePrev(),console.log("handle prev"),A(z.isEnd),D(z.isBeginning))}},i.createElement(p,null)),i.createElement("div",{className:"custom-next-button",style:t(t({},ie),F?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){z&&(z.slideNext(),console.log("handle next"),A(z.isEnd),D(z.isBeginning))}},i.createElement(f,null)))))}));export{h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/popup-renderer",
3
- "version": "1.0.155",
3
+ "version": "1.0.157",
4
4
  "description": "",
5
5
  "author": "ucy",
6
6
  "license": "ISC",