yt-uikit 0.7.344-shadowdomBundle.52 → 0.7.344-shadowdomBundle.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/Cart/Cart.d.ts +1 -1
- package/dist/esm/components/Cart/StickyCart.d.ts +1 -1
- package/dist/esm/index.js +8 -7
- package/dist/esm/types/components/Cart/Cart.d.ts +1 -1
- package/dist/esm/types/components/Cart/StickyCart.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -200,7 +200,7 @@ export interface CartProps {
|
|
|
200
200
|
cartOffersCarousalData?: CartOffersCarousalProps;
|
|
201
201
|
freebieMilestoneData?: freebieMilestoneProps;
|
|
202
202
|
cartOffersCarouselHeight?: number;
|
|
203
|
-
stickyBarBuyNowFunction?: (
|
|
203
|
+
stickyBarBuyNowFunction?: (variantId: string, quantity: number) => Promise<void>;
|
|
204
204
|
gstSectionCustomizationData?: GSTSectionCustomizationProps;
|
|
205
205
|
noteSectionTitle?: string;
|
|
206
206
|
checkoutSectionMessage?: string;
|
|
@@ -39,7 +39,7 @@ export type StickyAddToCartProps = {
|
|
|
39
39
|
cartComponentsCornerType?: "rounded" | "sharp";
|
|
40
40
|
cartComponentsCornerRadius?: number;
|
|
41
41
|
stickyCartCustomizationData?: stickyCartCustomizationDataProps;
|
|
42
|
-
checkoutFunction?: (
|
|
42
|
+
checkoutFunction?: (variantId: string, quantity: number) => Promise<void>;
|
|
43
43
|
backgroundColor?: string;
|
|
44
44
|
primaryTextColor?: string;
|
|
45
45
|
comboBundleData?: BundlePayload;
|
package/dist/esm/index.js
CHANGED
|
@@ -1900,17 +1900,18 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
1900
1900
|
`,Os=({themeColor:e,themeTextColor:n,disabledDates:r=[]})=>{const[o,i]=c(!1),[d,s]=Xt(an),p=Zt(nn),u=t.useRef(null),m=d?new Date(d):null,f=Array.isArray(r)?r:[r],g=a((()=>{const e=new Date;return e.setDate(e.getDate()+1),e}),[]),h=a((e=>f.some((t=>t instanceof Date&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())))),[f]),x=a((e=>{if(!e)return!1;const t=g(),n=new Date(e.getFullYear(),e.getMonth(),e.getDate());return n>=new Date(t.getFullYear(),t.getMonth(),t.getDate())&&!h(n)}),[g,h]);l((()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&i(!1)};return o&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[o]),l((()=>{const e=x(m);p((t=>t.isDateValid!==e?{...t,isDateValid:e}:t))}),[m,x,p]);const y=a((({date:e,view:t})=>{if("month"===t){const t=g(),n=new Date(e.getFullYear(),e.getMonth(),e.getDate());if(n>=new Date(t.getFullYear(),t.getMonth(),t.getDate())&&!h(n)){const e=d?new Date(d):null;return e&&n.getFullYear()===e.getFullYear()&&n.getMonth()===e.getMonth()&&n.getDate()===e.getDate()?"active-date":"black-date"}}return null}),[g,d,h]);return t.createElement("div",{className:"custom-date-picker"},t.createElement("div",{className:"date-display",onClick:()=>i(!o)},t.createElement("span",{style:{fontSize:"12px"}},(b=d?new Date(d):null)?b.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}).replace(/\//g,"/"):"Select a date"),t.createElement(M,null)),o&&t.createElement("div",{className:"calendar-container",ref:u},t.createElement(_s,{onChange:(e,t)=>{e instanceof Date&&!h(e)&&(s(e.toISOString()),i(!1));const n=x(e instanceof Date?e:null);p((e=>e.isDateValid!==n?{...e,isDateValid:n}:e))},value:d?new Date(d):null,className:"custom-calendar",minDate:g(),tileBackgroundColor:e,tileTextColor:n,tileHoverColor:En(e,.2),tileClassName:y,tileDisabled:({date:e,view:t})=>"month"===t&&h(e)})));var b},As=({title:e="Cart Item(s) available in NCR only",backgroundColor:n="#F6EFDD78",tag:r="NCR",postalCodeList:i=[110001,110002,110003,110004,110005],themeColor:d,themeTextColor:s,enableSlotPicker:p,deliveryHeaderTitle:u,deliveryAvailableText:m,deliveryNotAvailableText:f,disabledDates:g})=>{const[h,x]=c(!1),[y,b]=Xt(Lo),[v,w]=Xt(nn),[C,k]=Xt(on),E=Yt(rn),T=o(null),S=a((e=>{const t=i.includes(e);x(!t),w((e=>({...e,isPostalCodeValid:t})))}),[i,w]);return l((()=>{k("specific")}),[]),l((()=>{void 0!==y&&S(y)}),[y,S]),l((()=>{!1===p&&w((e=>e.isDateValid?e:{...e,isDateValid:!0}))}),[p,w]),t.createElement("div",null,u&&t.createElement("div",{className:"shipment-header"},t.createElement("h2",{className:"shipment-header-text"},u)),t.createElement("div",{className:"availability-check",style:{border:`2px solid ${d||"black"}`,padding:"12px",borderRadius:"8px",margin:"8px 1rem"}},t.createElement("div",{className:"availability-title"},"Check Shipment Availability"),t.createElement("input",{className:"availability-input",type:"text",placeholder:"Enter Postal Code",value:y||"",onChange:e=>{const t=e.target.value;if(""===t)return b(void 0),x(!1),void w((e=>({...e,isPostalCodeValid:!1})));if(!/^\d+$/.test(t))return;const n=Number(t);b(n),x(!1),w((e=>({...e,isPostalCodeValid:!1}))),T.current&&clearTimeout(T.current),T.current=setTimeout((()=>{S(n)}),1e3)},onBlur:()=>{T.current&&clearTimeout(T.current),void 0!==y&&S(y)}}),h&&t.createElement("div",{className:"error-message"},f||"Cart items aren't available at your address"),v.isPostalCodeValid&&p&&t.createElement("div",{className:"slot"},t.createElement("label",{className:"slot-label"},"Select Delivery Slot"),t.createElement(Os,{themeColor:d,themeTextColor:s,disabledDates:g})),E&&t.createElement("div",{className:"success-message"},m||"Voila! Local delivery is available")))},Ms=({postalCodeList:e=[110001,110002,110003,110004,110005],themeColor:n,themeTextColor:r,enableSlotPicker:i,disabledDates:d})=>{const[s,p]=c("standard"),[u,m]=c(!1),[f,g]=Xt(Lo),[h,x]=Xt(nn),[y,b]=Xt(on),v=Yt(rn),w=o(null),C=a((t=>{const n=e.includes(t);t?(m(!n),x((e=>({...e,isPostalCodeValid:n})))):x((e=>({...e,isPostalCodeValid:!1})))}),[e,x]);return l((()=>{b("delhi-ncr"===s?"specific":"standard"),f&&C(f)}),[s]),t.createElement("div",{className:"shipment-container"},t.createElement("div",{className:"shipment-header"},t.createElement("p",{className:"shipment-header-text"},"Cart Item(s) are available for standard shipment")),t.createElement("div",{className:"shipment-option "+("standard"===s?"selected":""),onClick:()=>p("standard")},t.createElement("div",{className:"option-content"},t.createElement("div",{className:"option-text"},t.createElement("div",{className:"option-title"},"Pan India"),t.createElement("div",{className:"option-subtitle"},"7-10 days")),"standard"===s&&t.createElement(it,{className:"checkmark"}))),t.createElement("div",{className:"shipment-option "+("delhi-ncr"===s?"selected":""),onClick:()=>p("delhi-ncr")},t.createElement("div",{className:"option-content"},t.createElement("div",{className:"option-text"},t.createElement("div",{className:"option-title"},"Delhi NCR"),t.createElement("div",{className:"option-subtitle"},"Single day delivery")),"delhi-ncr"===s&&t.createElement(it,{className:"checkmark"})),"delhi-ncr"===s&&t.createElement("div",{className:"availability-check"},t.createElement("div",{className:"availability-title"},"Check Product Availability"),t.createElement("input",{className:"availability-input",type:"text",placeholder:"Enter Postal Code",value:f,onChange:e=>{const t=e.target.value;if(""===t)return g(void 0),m(!1),void x((e=>({...e,isPostalCodeValid:!1})));if(!/^\d+$/.test(t))return;const n=Number(t);g(n),m(!1),x((e=>({...e,isPostalCodeValid:!1}))),w.current&&clearTimeout(w.current),w.current=setTimeout((()=>{C(n)}),1e3)},onBlur:()=>{w.current&&clearTimeout(w.current),C(f)}}),u&&t.createElement("div",{className:"error-message"},"Cart items aren't available on your selected pincode for quick shipment"),h.isPostalCodeValid&&i&&t.createElement("div",{className:"slot"},t.createElement("label",{className:"slot-label"},"Pick a Selivery Slot"),t.createElement(Os,{themeColor:n,themeTextColor:r,disabledDates:d})),v&&t.createElement("div",{className:"success-message"},"Voila! Local delivery is available"))))},Fs=tn("gift_wrap",!1);tn("gift_wrap_id","");const Rs=x.div`
|
|
1901
1901
|
display: flex;
|
|
1902
1902
|
flex-direction: column;
|
|
1903
|
-
|
|
1904
|
-
margin: 16px;
|
|
1903
|
+
margin-left: 16px;
|
|
1904
|
+
margin-right: 16px;
|
|
1905
1905
|
`,Ls=x.div`
|
|
1906
1906
|
display: flex;
|
|
1907
1907
|
justify-content: space-between;
|
|
1908
1908
|
align-items: center;
|
|
1909
1909
|
height: fit-content;
|
|
1910
|
+
margin-top: 6px;
|
|
1910
1911
|
padding: 6px 12px;
|
|
1911
|
-
border-radius: 5px;
|
|
1912
|
-
border-width: 2px;
|
|
1913
|
-
border-color: lightgray;
|
|
1912
|
+
border-radius: 5px !important;
|
|
1913
|
+
border-width: 2px !important;
|
|
1914
|
+
border-color: lightgray !important;
|
|
1914
1915
|
// box-shadow: 0px 0px 2px 2px rgb(193, 193, 193);
|
|
1915
1916
|
`,js=x.span`
|
|
1916
1917
|
display: flex;
|
|
@@ -2235,7 +2236,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
2235
2236
|
font-weight: 400;
|
|
2236
2237
|
min-width: 14px;
|
|
2237
2238
|
line-height: 14px;
|
|
2238
|
-
`,Bp=({isOpen:e,setIsOpen:n,backgroundColor:r="white",backgroundSubdued:a="#3947821F",tertiaryColor:i="#067D431A",tertiaryTextColor:d="#000000",exploreCTAColor:s,checkoutFontSize:p,cartTitle:u="My Cart",emptyCartTitle:m,emptyCartDescription:f,emptyCartButtons:g,removeCartItem:h,handleIncrement:x,handleDecrement:y,addCartItem:b,isUserSignedIn:v,showBundle:w,showCouponOptions:C,bundleProducts:k,discountAmountOff:E,loyaltyIcon:T,pointsToBeUsed:S,rewardMultiplier:B,redemptionMultiplier:$,discountApplied:z,removeDiscount:N,applyDiscount:I,rewardCoupons:D,userTotalPoints:P,checkoutFunction:_,joinNowFunction:O,guestLoyaltyPercentage:A,isDev:M,recProductsList:F,showMultiStepProgressBar:R,cartCheckpoints:L,redemptionRate:j,pointsRewardRate:V,showCartLevelAltPay:W,guestRewardCoupon:H,showGuestDiscountCoupon:q,applyTemplateDiscount:U,exploreCtaRedirectLink:Q,discountAmountApplied:G,minimumCartValue:Y,discountInCheckoutButton:Z,isStickyCheckout:X,showDiscountsListToGuestUsers:K,showApplyCouponsButtonToGuestUsers:J,handleCheckpointCrossed:ee,customCartProgressBarCriteria:te,checkoutButtonColor:ne="#252E69",ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,productRecsCtaButtonText:le,productRecsTitleText:ce,emptyProductRecsTitleText:de,showProductRecsOnDesktop:se,showProductRecsOnMobile:pe,themeColor:ue,themeTextColor:me,companyName:fe,gstNumber:ge,showGSTOption:he,applyGSTToCart:xe,showMOVForProgressTiers:ye,freeProduct:be,showLoyaltyCta:ve=!1,freeProductAdjustedCartTotal:we,minimumOrderValueToAvailDiscount:Ce,signinCTAButtonVisible:ke,cartSigninCTAMainText:Ee,applyNoteToCart:Te,note:Se,showNoteOption:Be,inlineCartOfferInfoText:$e,inlineCartOfferInfoRedirectLink:ze,cartOfferTermsAndConditionsText:Ne,showEditOptionOnProducts:Ie,onSetLoading:De,showVariantSelectionDropdownInProductRecs:Pe,originalCartSubtotal:_e,freebieProductsInCart:Oe,showFreebieClaim:Ae,addFreebieToCart:Me,freebiesInCart:Fe,effectiveQuantityForProgressBar:Re,productPercentageOffMapping:Le,productTagsMapping:je,removeFreebieFromCart:Ve,postalCodeList:We,enableGeoLocationDeliveryRestriction:He=!1,getProductDetailsByVariantId:qe,applyPostalCodeAndDeliverySlotToCart:Ue,showDeleteOnFreebies:Qe,freebieCouponTemplates:Ge,freebieFlowCheckpoints:Ye,freebieClaimData:Ze,postalCodeBasedItemTrackingParameter:Xe,enableSlotPicker:Ke,deliveryHeaderTitle:Je,deliveryAvailableText:et,deliveryNotAvailableText:tt,giftWrapSetupData:nt,giftWrapProductDetail:rt,progressBarFreeProductIconType:ot,enableCustomCartOnCartPage:at,isCartPage:it,showCartTimer:lt,showFreebieMilestone:st,freebieMilestoneData:pt,cartTimerInMinutes:ut,cartTimerCustomText:mt,productRecsCardLayout:gt,productRecsCardListVariant:xt,imageAspectSelector:yt,cartComponentsCornerType:bt,cartComponentsCornerRadius:vt,cartOffersCarousalData:wt,gstSectionCustomizationData:Ct,noteSectionTitle:kt,checkoutSectionMessage:Et,checkoutSectionMessageDisplay:Tt,showVariantSelectionDropdownInProductClaim:St,loyaltyDiscount:Bt,brandTokenName:$t,showDiscountOnMRP:zt,switchWidthVariant:Nt,prefixMessageText:It,suffixMessageText:Dt,successMessageText:Pt,toggleDecimal:_t,cartOffersCarouselHeight:Ot,disableCheckoutButton:At,showEmptyCartRecommendations:Mt=!1,checkoutButtonBottomSpacing:Ft,showPoweredByBadge:Rt,applyCouponCode:Lt,showApplyCoupon:jt,enableConfetti:Vt,checkoutSectionMessageRedirectLink:Wt,showCheckoutButtonPaymentIcons:Ht,shouldCheckInventoryQuantity:qt})=>{const Ut=Yt(Kt),Qt=Yt(ln),[Gt,Zt]=c(!1),[Jt,en]=Xt(sn),[tn,pn]=c(!1),[un,mn]=c(!0),{setLoading:fn}=cn();t.useEffect((()=>{De&&De(fn)}),[De]);const hn=o(!1);l((()=>{const t=()=>{n(!1)};return e?(hn.current||window.history.pushState({ytCustomCartDrawer:"open"},""),window.addEventListener("popstate",t),hn.current=!0):(hn.current&&"open"===window.history.state?.ytCustomCartDrawer&&window.history.back(),hn.current=!1),()=>{window.removeEventListener("popstate",t)}}),[e,n]);const[xn,yn]=c(!1);l((()=>{const t=document.querySelector("body");if(t)return at&&it?(t.classList.remove("drawer-open"),void t.classList.remove("drawer-closed")):void(xn?(t.classList.remove("drawer-open"),t.classList.remove("drawer-closed")):e?(t.classList.add("drawer-open"),t.classList.remove("drawer-closed")):(t.classList.remove("drawer-open"),t.classList.add("drawer-closed")))}),[e,at,it,xn]),l((()=>{function e(){const e=window.innerWidth;yn(e>=450)}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]);const bn=Ut?.items?.reduce(((e,t)=>e+t?.quantity),0),vn=o(null);l((()=>{function e(e){vn.current&&!vn.current.contains(e.target)&&en(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]),l((()=>{const e=()=>{Zt(!0),window.setTimeout((()=>Zt(!1)),3e3)};return window.addEventListener("yt:autoFreebieAdded",e),()=>window.removeEventListener("yt:autoFreebieAdded",e)}),[]);const[wn,Cn]=c("normal"),[kn,En]=c("normal"),[Tn,Sn]=c("auto");l((()=>{CSS.supports("font-weight","500")?Cn("500"):CSS.supports("font-weight","400")?Cn("400"):CSS.supports("font-weight","600")&&Cn("600"),CSS.supports("font-weight","400")?En("400"):CSS.supports("font-weight","300")?En("300"):CSS.supports("font-weight","200")&&En("200"),CSS.supports("width","-webkit-fill-available")?Sn("-webkit-fill-available"):CSS.supports("width","-moz-available")&&Sn("-moz-available")}),[]),l((()=>{document.documentElement.style.setProperty("--yt-cart-font-weight",wn),document.documentElement.style.setProperty("--yt-cart-product-rec-price-font-weight",kn),document.documentElement.style.setProperty("--yt-cart-custom-fill-width",Tn)}),[wn,kn]);const[Bn]=Xt(nn);Yt(rn);const[$n]=Xt(an),[zn]=Xt(on);l((()=>{const e=Ut?.items.some((e=>(je?.get(String(e.product_id))||[]).includes("Delhi-NCR")));pn(e)}),[Ut?.items,je]);l((()=>{mn(!("all-products"!==Xe&&("specific-tags"!==Xe||Bn.isPostalCodeValid||Ke)&&("specific-tags"!==Xe||Bn.isPostalCodeValid||$n||!Ke)&&("specific-tags"===Xe&&"standard"===zn||tn&&(Ke?Bn.isPostalCodeValid&&$n:Bn.isPostalCodeValid))))}),[Bn.isPostalCodeValid,$n,tn,Xe,Ke]),Xt(dn);const[Nn,In]=c(!0);l((()=>{"true"===localStorage.getItem("cartTimerRanOnce")&&In(!1);const e=localStorage.getItem("cartTimerTimeLeft");e&&parseInt(e,10)<=0&&In(!1)}),[]);const Dn=new Date("2024-11-01");return gn(Ut?.items_subtotal_price,Ut?.currency),t.createElement(Tp,{className:"yt-cart-drawer",$isDev:M,$isOpen:e,$backgroundColor:r,$enableCustomCartOnCartPage:at,$isCartPage:it,$isLargeScreen:xn,$switchWidthVariant:Nt},Qt.cartLoading?t.createElement("div",{style:{backgroundColor:"#fff",width:"100%",height:"100%",alignItems:"center",justifyContent:"center",display:"flex",position:"absolute",opacity:0,zIndex:51}},Qt.showLoader&&!Qt.showSkeletonLoader&&t.createElement("div",{className:"loader"},"")):t.createElement(t.Fragment,null),t.createElement(t.Fragment,null,Jt&&t.createElement("div",{style:{position:"fixed",inset:0,zIndex:40,backgroundColor:"rgba(128,128,128,0.7)"}},""),t.createElement("div",{style:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"space-between"}},t.createElement("div",{style:{}},t.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",margin:"1rem 1rem 0px"}},t.createElement("span",{className:"yt-cart-title-container",style:{fontWeight:"var(--yt-cart-font-weight, bold)",color:ae,fontSize:"16px"}},t.createElement("span",{style:{whiteSpace:"nowrap",flexShrink:0}},u),Ut?.item_count>0&&W&&!(ve&&W)&&V>0&&t.createElement(kp,{pointsRewardRate:V,loyaltyIcon:T,brandTokenName:$t,themeColor:ue,themeTextColor:me,rewardMultiplier:B}),bn>0&&t.createElement(Sp,{$backgroundSubdued:a},bn)),t.createElement("div",{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center"}},!(at&&it)&&t.createElement("div",{className:"close-button",style:{backgroundColor:a||"#cacaca30"}},t.createElement(ht,{style:{height:"auto",width:"auto",color:ae},fontSize:24,cursor:"pointer",onClick:()=>n(!e)})))),Qt&&t.createElement(bp,{$themeColor:ue,show:Qt.showLoader}),wt?.enableCartOffersCarousel&&t.createElement(gp,{themeColor:ue,cartOffersCarousalData:wt,cartOffersCarouselHeight:Ot,cartData:Ut}),lt&&Nn&&Ut?.item_count?t.createElement(Gs,{minutes:ut,customText:mt,onTimerComplete:()=>{In(!1),localStorage.setItem("cartTimerRanOnce","true"),localStorage.removeItem("timeLeft"),localStorage.removeItem("lastUpdate")}}):null,Gt&&Vt&&t.createElement(Qr,{particleCount:50,spread:90,origin:{y:.3}}),$e?t.createElement(El,{inlineCartOfferInfoText:$e,inlineCartOfferInfoRedirectLink:ze,themeColor:ue,tooltipText:Ne,themeTextColor:me}):null),R&&Ut?.items_subtotal_price>0&&Ut?.currency&&!!L&&function(e,t,n,r,o){if(!e||0===e.length)return!1;const a=[...e].sort(((e,t)=>"minimum_order_value"===r?e?.minimumOrderValue-t?.minimumOrderValue:e?.quantityThreshold-t?.quantityThreshold));return a.filter((e=>0!==e?.[Rr(r)]&&("minimum_order_value"!==r||1!==e?.[Rr(r)]))).some(((e,i)=>Lr(e,i,a,o,{currentCartAmount:t,effectiveQuantityForProgressBar:n,customCartProgressBarCriteria:r,checkpoints:a}).progressPercentage>0))}(L,gn(void 0!==_e?_e:Ut?.items_subtotal_price,Ut.currency),void 0===Re?Ut?.item_count:Re,te??"minimum_order_value",Ut?.item_count)&&t.createElement(t.Fragment,null,t.createElement(Bo,{customCartProgressBarCriteria:te??"minimum_order_value",handleCheckpointCrossed:ee,checkpoints:L,effectiveQuantityForProgressBar:void 0===Re?Ut?.item_count:Re,currentCartAmount:gn(void 0!==_e?_e:Ut?.items_subtotal_price,Ut.currency),themeColor:ue,themeTextColor:me,primaryTextColor:ae,secondaryTextColor:ie,showMOVForProgressTiers:ye,progressBarFreeProductIconType:ot,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,prefixMessageText:It,suffixMessageText:Dt,successMessageText:Pt,enableConfetti:Vt})),Ut?.item_count>0&&t.createElement("div",{style:{display:"flex",height:"12px",background:"#87878717"}}),0===Ut?.items?.length&&0===Ut?.item_count&&!1===Qt?.showSkeletonLoader?t.createElement(Po,{showLoyaltyCta:ve,joinNowFunction:O,emptyCartTitle:m,emptyCartDescription:f,exploreCTAColor:s,isUserSignedIn:v,exploreCtaRedirectLink:Q,themeColor:ue,emptyCartButtons:g,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,themeTextColor:me,recProductsList:F,addCartItem:b,productRecsCtaButtonText:le,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,showVariantSelectionDropdownInProductRecs:Pe,emptyProductRecsTitleText:de,backgroundSubdued:a,showEmptyCartRecommendations:Mt,tertiaryColor:i,tertiaryTextColor:d}):t.createElement("div",{style:{display:"flex",flexDirection:"column",overflowY:"auto",flex:1,overflowX:"hidden",height:"100%",scrollbarWidth:"none"}},t.createElement(ni,{isDev:M,themeColor:ue,handleDecrement:y,handleIncrement:x,removeCartItem:h,addCartItem:b,primaryTextColor:ae,secondaryTextColor:ie,freeProduct:be,themeTextColor:me,showEditOptionOnProducts:Ie,productPercentageOffMapping:Le,productTagsMapping:je,removeFreebieFromCart:Ve,showDeleteOnFreebies:Qe,freebieCouponTemplates:Ge??[],freebieFlowCheckpoints:Ye??[],cartCheckpoints:L,freeProductAdjustedCartTotal:we,imageAspectSelector:yt,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,giftWrapVariantId:rt?.variants?.nodes[0]?.id,giftWrapProductId:nt?.giftProductId,showGiftWrapAsLineItem:nt?.showGiftWrapAsLineItem,backgroundSubdued:a,tertiaryColor:i,tertiaryTextColor:d,backgroundColor:r,showDiscountOnMRP:zt,checkoutSectionMessage:Et,checkoutSectionMessageRedirectLink:Wt,showFreebieMilestone:st,freebieMilestoneData:pt}),xn&&se&&!!F&&F?.length>0&&Ut?.item_count>0&&b&&t.createElement(br,{addCartItem:b,products:F,productRecsCtaButtonText:le,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,productRecsTitleText:ce,themeColor:ue,primaryTextColor:ae,secondaryTextColor:ie,showVariantSelectionDropdownInProductRecs:Pe,cardLayout:gt,variant:xt,cartComponentsCornerType:bt,cartComponentsCornerRadius:vt,backgroundSubdued:a,backgroundColor:r,tertiaryColor:i,tertiaryTextColor:d}),!xn&&pe&&!!F&&F?.length>0&&Ut?.item_count>0&&b&&t.createElement(br,{addCartItem:b,products:F,productRecsCtaButtonText:le,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,productRecsTitleText:ce,themeColor:ue,primaryTextColor:ae,secondaryTextColor:ie,showVariantSelectionDropdownInProductRecs:Pe,cardLayout:gt,variant:xt,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,backgroundSubdued:a,tertiaryColor:i,tertiaryTextColor:d})),t.createElement(Go,null,Ut?.item_count>0&&w&&k&&t.createElement(oi,{bundleProducts:k}),he&&!!xe&&Ut?.item_count>0&&t.createElement(xi,{companyName:fe,gstNumber:ge,themeColor:ue,iconColor:Ct?.iconColor,showIcon:Ct?.showIcon,backgroundColor:Ct?.backgroundColor,textColor:Ct?.textColor,title:Ct?.title}),!!Ut&&Ut?.item_count>0&&!!Me&&!!Oe&&!!Fe&&Oe.length>0&&t.createElement(kl,{freebieProductsInCart:Oe,themeColor:ue,themeTextColor:me,primaryTextColor:ae,addFreebieToCart:Me,freebiesInCart:Fe,imageAspectSelector:yt,freebieCouponTemplates:Ge,freebieClaimData:Ze,cartCheckpoints:L,isCartDrawerOpen:e,shouldCheckInventoryQuantity:qt}),He&&(We?.length??0)>0&&!!Ue&&Ut?.item_count>0&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"6px 1rem 1rem 1rem"},onClick:()=>mn(!un)},t.createElement("span",{style:{fontSize:"12px",display:"flex",gap:"5px",alignItems:"center"}},"Shipping ",t.createElement(ft,null)),t.createElement("div",{className:"icon-transition"},un?t.createElement(ct,null):t.createElement(dt,null))),"all-products"===Xe&&un?t.createElement(As,{postalCodeList:We,themeColor:ue,themeTextColor:me,enableSlotPicker:Ke,deliveryHeaderTitle:Je,deliveryAvailableText:et,deliveryNotAvailableText:tt,disabledDates:Dn}):un&&(tn?t.createElement(As,{postalCodeList:We,themeColor:ue,themeTextColor:me,enableSlotPicker:Ke,deliveryHeaderTitle:Je,deliveryAvailableText:et,deliveryNotAvailableText:tt,disabledDates:Dn}):t.createElement(Ms,{postalCodeList:We,themeColor:ue,themeTextColor:me,enableSlotPicker:Ke,disabledDates:Dn}))),Be&&!!Te&&Ut?.item_count>0&&t.createElement(yi,{note:Se,noteSectionTitle:kt}),nt?.showGiftWrapOption&&Ut?.item_count>0&&t.createElement(qs,{themeColor:ue,id:nt?.giftProductId,detail:rt,showPrice:nt?.showPrice,errorText:nt?.errorText,customText:nt?.customText,showGiftIcon:nt?.showGiftIcon,addCartItem:b,removeCartItem:h}),Ut?.item_count>0&&jt&&!ve&&Lt&&t.createElement(Ep,{backgroundSubdued:a,themeColor:ue,themeTextColor:me,primaryTextColor:ae,cartComponentsCornerRadius:vt,applyCouponCode:Lt,removeDiscount:N,enableConfetti:Vt}),Ut?.item_count>0&&C&&I&&!Bt&&U&&D&&D?.length>0?t.createElement(t.Fragment,null,v||v&&J?t.createElement(xa,{themeColor:ue,showGuestDiscountCoupon:q,guestRewardCoupon:H,ref:vn,discountAmountOff:E,userTotalPoints:P??0,applyDiscount:I,applyTemplateDiscount:U,rewardCoupons:D,isCouponSelectionOpen:Jt,setIsCouponSelectionOpen:en,pointsToBeUsed:S,joinNowFunction:O,guestLoyaltyPercentage:A,isUserSignedIn:v,showDiscountsListToGuestUsers:K}):!!A&&ve&&!!O&&t.createElement(Uo,{cartSigninCTAMainText:Ee,signinCTAButtonVisible:ke,guestLoyaltyPercentage:A,joinNowFunction:O,themeColor:ue,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,showCartLevelAltPay:W})):Ut?.item_count>0&&t.createElement(t.Fragment,null,v||!ve||Bt?!Bt&&Ut?.item_count>0&&void 0!==E&&void 0!==S&&!!T&&ve&&!!I&&t.createElement(pa,{themeColor:ue,applyDiscount:I,discountAmountOff:E,loyaltyIcon:T,pointsToBeUsed:S,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,minimumOrderValueToAvailDiscount:Ce,brandTokenName:$t,showCartLevelAltPay:W,redemptionMultiplier:$}):Ut?.item_count>0&&!!A&&!!O&&t.createElement(Uo,{cartSigninCTAMainText:Ee,signinCTAButtonVisible:ke,themeColor:ue,joinNowFunction:O,guestLoyaltyPercentage:A,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,showCartLevelAltPay:W})),Ut?.item_count>0&&!!Bt&&!!N&&ve&&Bt&&void 0!==S&&t.createElement(la,{themeColor:ue,removeDiscount:N,loyaltyDiscount:Bt,isDev:M,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,pointsToBeUsed:S,brandTokenName:$t,showCartLevelAltPay:W}),ve&&W&&j&&T&&Ut?.item_count>0&&t.createElement(wp,{loyaltyIcon:T,backgroundSubdued:a,primaryTextColor:ae,pointsRewardRate:V,rewardMultiplier:B}),ve&&Ut&&Ut.item_count>0&&!!Ce&&Ce>1&&t.createElement("span",{className:"yt-cart-loyalty-mov-text",style:{fontSize:"10px",color:ue??"#50D1AA",fontWeight:600,display:"flex",justifyContent:ke?"space-between":"center"}},"Minimum order value to use ",$t,":"," ",Ce),Ut&&_&&Ut?.item_count>0&&t.createElement("div",null,t.createElement(jo,{disableCheckoutButton:!!At||Qt.cartLoading,discountApplied:z,checkoutFunction:_,checkoutButtonColor:ne,checkoutFontSize:p,discountInCheckoutButton:Z,isStickyCheckout:X,discountAmountApplied:G,minimumCartValue:Y,themeTextColor:me,applyGSTToCart:xe,showGSTOption:he,applyNoteToCart:Te,showNoteOption:Be,enableGeoLocationDeliveryRestriction:He,applyPostalCodeAndDeliverySlotToCart:Ue,enableSlotPicker:Ke,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,checkoutSectionMessage:Et,checkoutSectionMessageDisplay:Tt,checkoutSectionMessageRedirectLink:Wt,showDiscountOnMRP:zt,tertiaryColor:i,tertiaryTextColor:d,cartCheckpoints:L,toggleDecimal:_t,checkoutButtonBottomSpacing:Ft,showPoweredByBadge:Rt,showCheckoutButtonPaymentIcons:Ht,primaryTextColor:ae}))))))},$p=x.div`
|
|
2239
|
+
`,Bp=({isOpen:e,setIsOpen:n,backgroundColor:r="white",backgroundSubdued:a="#3947821F",tertiaryColor:i="#067D431A",tertiaryTextColor:d="#000000",exploreCTAColor:s,checkoutFontSize:p,cartTitle:u="My Cart",emptyCartTitle:m,emptyCartDescription:f,emptyCartButtons:g,removeCartItem:h,handleIncrement:x,handleDecrement:y,addCartItem:b,isUserSignedIn:v,showBundle:w,showCouponOptions:C,bundleProducts:k,discountAmountOff:E,loyaltyIcon:T,pointsToBeUsed:S,rewardMultiplier:B,redemptionMultiplier:$,discountApplied:z,removeDiscount:N,applyDiscount:I,rewardCoupons:D,userTotalPoints:P,checkoutFunction:_,joinNowFunction:O,guestLoyaltyPercentage:A,isDev:M,recProductsList:F,showMultiStepProgressBar:R,cartCheckpoints:L,redemptionRate:j,pointsRewardRate:V,showCartLevelAltPay:W,guestRewardCoupon:H,showGuestDiscountCoupon:q,applyTemplateDiscount:U,exploreCtaRedirectLink:Q,discountAmountApplied:G,minimumCartValue:Y,discountInCheckoutButton:Z,isStickyCheckout:X,showDiscountsListToGuestUsers:K,showApplyCouponsButtonToGuestUsers:J,handleCheckpointCrossed:ee,customCartProgressBarCriteria:te,checkoutButtonColor:ne="#252E69",ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,productRecsCtaButtonText:le,productRecsTitleText:ce,emptyProductRecsTitleText:de,showProductRecsOnDesktop:se,showProductRecsOnMobile:pe,themeColor:ue,themeTextColor:me,companyName:fe,gstNumber:ge,showGSTOption:he,applyGSTToCart:xe,showMOVForProgressTiers:ye,freeProduct:be,showLoyaltyCta:ve=!1,freeProductAdjustedCartTotal:we,minimumOrderValueToAvailDiscount:Ce,signinCTAButtonVisible:ke,cartSigninCTAMainText:Ee,applyNoteToCart:Te,note:Se,showNoteOption:Be,inlineCartOfferInfoText:$e,inlineCartOfferInfoRedirectLink:ze,cartOfferTermsAndConditionsText:Ne,showEditOptionOnProducts:Ie,onSetLoading:De,showVariantSelectionDropdownInProductRecs:Pe,originalCartSubtotal:_e,freebieProductsInCart:Oe,showFreebieClaim:Ae,addFreebieToCart:Me,freebiesInCart:Fe,effectiveQuantityForProgressBar:Re,productPercentageOffMapping:Le,productTagsMapping:je,removeFreebieFromCart:Ve,postalCodeList:We,enableGeoLocationDeliveryRestriction:He=!1,getProductDetailsByVariantId:qe,applyPostalCodeAndDeliverySlotToCart:Ue,showDeleteOnFreebies:Qe,freebieCouponTemplates:Ge,freebieFlowCheckpoints:Ye,freebieClaimData:Ze,postalCodeBasedItemTrackingParameter:Xe,enableSlotPicker:Ke,deliveryHeaderTitle:Je,deliveryAvailableText:et,deliveryNotAvailableText:tt,giftWrapSetupData:nt,giftWrapProductDetail:rt,progressBarFreeProductIconType:ot,enableCustomCartOnCartPage:at,isCartPage:it,showCartTimer:lt,showFreebieMilestone:st,freebieMilestoneData:pt,cartTimerInMinutes:ut,cartTimerCustomText:mt,productRecsCardLayout:gt,productRecsCardListVariant:xt,imageAspectSelector:yt,cartComponentsCornerType:bt,cartComponentsCornerRadius:vt,cartOffersCarousalData:wt,gstSectionCustomizationData:Ct,noteSectionTitle:kt,checkoutSectionMessage:Et,checkoutSectionMessageDisplay:Tt,showVariantSelectionDropdownInProductClaim:St,loyaltyDiscount:Bt,brandTokenName:$t,showDiscountOnMRP:zt,switchWidthVariant:Nt,prefixMessageText:It,suffixMessageText:Dt,successMessageText:Pt,toggleDecimal:_t,cartOffersCarouselHeight:Ot,disableCheckoutButton:At,showEmptyCartRecommendations:Mt=!1,checkoutButtonBottomSpacing:Ft,showPoweredByBadge:Rt,applyCouponCode:Lt,showApplyCoupon:jt,enableConfetti:Vt,checkoutSectionMessageRedirectLink:Wt,showCheckoutButtonPaymentIcons:Ht,shouldCheckInventoryQuantity:qt})=>{const Ut=Yt(Kt),Qt=Yt(ln),[Gt,Zt]=c(!1),[Jt,en]=Xt(sn),[tn,pn]=c(!1),[un,mn]=c(!0),{setLoading:fn}=cn();t.useEffect((()=>{De&&De(fn)}),[De]);const hn=o(!1);l((()=>{const t=()=>{n(!1)};return e?(hn.current||window.history.pushState({ytCustomCartDrawer:"open"},""),window.addEventListener("popstate",t),hn.current=!0):(hn.current&&"open"===window.history.state?.ytCustomCartDrawer&&window.history.back(),hn.current=!1),()=>{window.removeEventListener("popstate",t)}}),[e,n]);const[xn,yn]=c(!1);l((()=>{const t=document.querySelector("body");if(t)return at&&it?(t.classList.remove("drawer-open"),void t.classList.remove("drawer-closed")):void(xn?(t.classList.remove("drawer-open"),t.classList.remove("drawer-closed")):e?(t.classList.add("drawer-open"),t.classList.remove("drawer-closed")):(t.classList.remove("drawer-open"),t.classList.add("drawer-closed")))}),[e,at,it,xn]),l((()=>{function e(){const e=window.innerWidth;yn(e>=450)}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]);const bn=Ut?.items?.reduce(((e,t)=>e+t?.quantity),0),vn=o(null);l((()=>{function e(e){vn.current&&!vn.current.contains(e.target)&&en(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]),l((()=>{const e=()=>{Zt(!0),window.setTimeout((()=>Zt(!1)),3e3)};return window.addEventListener("yt:autoFreebieAdded",e),()=>window.removeEventListener("yt:autoFreebieAdded",e)}),[]);const[wn,Cn]=c("normal"),[kn,En]=c("normal"),[Tn,Sn]=c("auto");l((()=>{CSS.supports("font-weight","500")?Cn("500"):CSS.supports("font-weight","400")?Cn("400"):CSS.supports("font-weight","600")&&Cn("600"),CSS.supports("font-weight","400")?En("400"):CSS.supports("font-weight","300")?En("300"):CSS.supports("font-weight","200")&&En("200"),CSS.supports("width","-webkit-fill-available")?Sn("-webkit-fill-available"):CSS.supports("width","-moz-available")&&Sn("-moz-available")}),[]),l((()=>{document.documentElement.style.setProperty("--yt-cart-font-weight",wn),document.documentElement.style.setProperty("--yt-cart-product-rec-price-font-weight",kn),document.documentElement.style.setProperty("--yt-cart-custom-fill-width",Tn)}),[wn,kn]);const[Bn]=Xt(nn);Yt(rn);const[$n]=Xt(an),[zn]=Xt(on);l((()=>{const e=Ut?.items.some((e=>(je?.get(String(e.product_id))||[]).includes("Delhi-NCR")));pn(e)}),[Ut?.items,je]);l((()=>{mn(!("all-products"!==Xe&&("specific-tags"!==Xe||Bn.isPostalCodeValid||Ke)&&("specific-tags"!==Xe||Bn.isPostalCodeValid||$n||!Ke)&&("specific-tags"===Xe&&"standard"===zn||tn&&(Ke?Bn.isPostalCodeValid&&$n:Bn.isPostalCodeValid))))}),[Bn.isPostalCodeValid,$n,tn,Xe,Ke]),Xt(dn);const[Nn,In]=c(!0);l((()=>{"true"===localStorage.getItem("cartTimerRanOnce")&&In(!1);const e=localStorage.getItem("cartTimerTimeLeft");e&&parseInt(e,10)<=0&&In(!1)}),[]);const Dn=new Date("2024-11-01");return gn(Ut?.items_subtotal_price,Ut?.currency),t.createElement(Tp,{className:"yt-cart-drawer",$isDev:M,$isOpen:e,$backgroundColor:r,$enableCustomCartOnCartPage:at,$isCartPage:it,$isLargeScreen:xn,$switchWidthVariant:Nt},Qt.cartLoading?t.createElement("div",{style:{backgroundColor:"#fff",width:"100%",height:"100%",alignItems:"center",justifyContent:"center",display:"flex",position:"absolute",opacity:0,zIndex:51}},Qt.showLoader&&!Qt.showSkeletonLoader&&t.createElement("div",{className:"loader"},"")):t.createElement(t.Fragment,null),t.createElement(t.Fragment,null,Jt&&t.createElement("div",{style:{position:"fixed",inset:0,zIndex:40,backgroundColor:"rgba(128,128,128,0.7)"}},""),t.createElement("div",{className:"yt-cart-drawer-content",style:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"space-between"}},t.createElement("div",{style:{}},t.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",margin:"1rem 1rem 0px"}},t.createElement("span",{className:"yt-cart-title-container",style:{fontWeight:"var(--yt-cart-font-weight, bold)",color:ae,fontSize:"16px"}},t.createElement("span",{style:{whiteSpace:"nowrap",flexShrink:0}},u),Ut?.item_count>0&&W&&!(ve&&W)&&V>0&&t.createElement(kp,{pointsRewardRate:V,loyaltyIcon:T,brandTokenName:$t,themeColor:ue,themeTextColor:me,rewardMultiplier:B}),bn>0&&t.createElement(Sp,{$backgroundSubdued:a},bn)),t.createElement("div",{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center"}},!(at&&it)&&t.createElement("div",{className:"close-button",style:{backgroundColor:a||"#cacaca30"}},t.createElement(ht,{style:{height:"auto",width:"auto",color:ae},fontSize:24,cursor:"pointer",onClick:()=>n(!e)})))),Qt&&t.createElement(bp,{$themeColor:ue,show:Qt.showLoader}),wt?.enableCartOffersCarousel&&t.createElement(gp,{themeColor:ue,cartOffersCarousalData:wt,cartOffersCarouselHeight:Ot,cartData:Ut}),lt&&Nn&&Ut?.item_count?t.createElement(Gs,{minutes:ut,customText:mt,onTimerComplete:()=>{In(!1),localStorage.setItem("cartTimerRanOnce","true"),localStorage.removeItem("timeLeft"),localStorage.removeItem("lastUpdate")}}):null,Gt&&Vt&&t.createElement(Qr,{particleCount:50,spread:90,origin:{y:.3}}),$e?t.createElement(El,{inlineCartOfferInfoText:$e,inlineCartOfferInfoRedirectLink:ze,themeColor:ue,tooltipText:Ne,themeTextColor:me}):null),R&&Ut?.items_subtotal_price>0&&Ut?.currency&&!!L&&function(e,t,n,r,o){if(!e||0===e.length)return!1;const a=[...e].sort(((e,t)=>"minimum_order_value"===r?e?.minimumOrderValue-t?.minimumOrderValue:e?.quantityThreshold-t?.quantityThreshold));return a.filter((e=>0!==e?.[Rr(r)]&&("minimum_order_value"!==r||1!==e?.[Rr(r)]))).some(((e,i)=>Lr(e,i,a,o,{currentCartAmount:t,effectiveQuantityForProgressBar:n,customCartProgressBarCriteria:r,checkpoints:a}).progressPercentage>0))}(L,gn(void 0!==_e?_e:Ut?.items_subtotal_price,Ut.currency),void 0===Re?Ut?.item_count:Re,te??"minimum_order_value",Ut?.item_count)&&t.createElement(t.Fragment,null,t.createElement(Bo,{customCartProgressBarCriteria:te??"minimum_order_value",handleCheckpointCrossed:ee,checkpoints:L,effectiveQuantityForProgressBar:void 0===Re?Ut?.item_count:Re,currentCartAmount:gn(void 0!==_e?_e:Ut?.items_subtotal_price,Ut.currency),themeColor:ue,themeTextColor:me,primaryTextColor:ae,secondaryTextColor:ie,showMOVForProgressTiers:ye,progressBarFreeProductIconType:ot,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,prefixMessageText:It,suffixMessageText:Dt,successMessageText:Pt,enableConfetti:Vt})),Ut?.item_count>0&&t.createElement("div",{style:{display:"flex",height:"12px",background:"#87878717"}}),0===Ut?.items?.length&&0===Ut?.item_count&&!1===Qt?.showSkeletonLoader?t.createElement(Po,{showLoyaltyCta:ve,joinNowFunction:O,emptyCartTitle:m,emptyCartDescription:f,exploreCTAColor:s,isUserSignedIn:v,exploreCtaRedirectLink:Q,themeColor:ue,emptyCartButtons:g,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,themeTextColor:me,recProductsList:F,addCartItem:b,productRecsCtaButtonText:le,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,showVariantSelectionDropdownInProductRecs:Pe,emptyProductRecsTitleText:de,backgroundSubdued:a,showEmptyCartRecommendations:Mt,tertiaryColor:i,tertiaryTextColor:d}):t.createElement("div",{style:{display:"flex",flexDirection:"column",overflowY:"auto",flex:1,overflowX:"hidden",height:"100%",scrollbarWidth:"none"}},t.createElement(ni,{isDev:M,themeColor:ue,handleDecrement:y,handleIncrement:x,removeCartItem:h,addCartItem:b,primaryTextColor:ae,secondaryTextColor:ie,freeProduct:be,themeTextColor:me,showEditOptionOnProducts:Ie,productPercentageOffMapping:Le,productTagsMapping:je,removeFreebieFromCart:Ve,showDeleteOnFreebies:Qe,freebieCouponTemplates:Ge??[],freebieFlowCheckpoints:Ye??[],cartCheckpoints:L,freeProductAdjustedCartTotal:we,imageAspectSelector:yt,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,giftWrapVariantId:rt?.variants?.nodes[0]?.id,giftWrapProductId:nt?.giftProductId,showGiftWrapAsLineItem:nt?.showGiftWrapAsLineItem,backgroundSubdued:a,tertiaryColor:i,tertiaryTextColor:d,backgroundColor:r,showDiscountOnMRP:zt,checkoutSectionMessage:Et,checkoutSectionMessageRedirectLink:Wt,showFreebieMilestone:st,freebieMilestoneData:pt}),xn&&se&&!!F&&F?.length>0&&Ut?.item_count>0&&b&&t.createElement(br,{addCartItem:b,products:F,productRecsCtaButtonText:le,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,productRecsTitleText:ce,themeColor:ue,primaryTextColor:ae,secondaryTextColor:ie,showVariantSelectionDropdownInProductRecs:Pe,cardLayout:gt,variant:xt,cartComponentsCornerType:bt,cartComponentsCornerRadius:vt,backgroundSubdued:a,backgroundColor:r,tertiaryColor:i,tertiaryTextColor:d}),!xn&&pe&&!!F&&F?.length>0&&Ut?.item_count>0&&b&&t.createElement(br,{addCartItem:b,products:F,productRecsCtaButtonText:le,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,productRecsTitleText:ce,themeColor:ue,primaryTextColor:ae,secondaryTextColor:ie,showVariantSelectionDropdownInProductRecs:Pe,cardLayout:gt,variant:xt,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,backgroundSubdued:a,tertiaryColor:i,tertiaryTextColor:d})),t.createElement(Go,null,Ut?.item_count>0&&w&&k&&t.createElement(oi,{bundleProducts:k}),he&&!!xe&&Ut?.item_count>0&&t.createElement(xi,{companyName:fe,gstNumber:ge,themeColor:ue,iconColor:Ct?.iconColor,showIcon:Ct?.showIcon,backgroundColor:Ct?.backgroundColor,textColor:Ct?.textColor,title:Ct?.title}),!!Ut&&Ut?.item_count>0&&!!Me&&!!Oe&&!!Fe&&Oe.length>0&&t.createElement(kl,{freebieProductsInCart:Oe,themeColor:ue,themeTextColor:me,primaryTextColor:ae,addFreebieToCart:Me,freebiesInCart:Fe,imageAspectSelector:yt,freebieCouponTemplates:Ge,freebieClaimData:Ze,cartCheckpoints:L,isCartDrawerOpen:e,shouldCheckInventoryQuantity:qt}),He&&(We?.length??0)>0&&!!Ue&&Ut?.item_count>0&&t.createElement("div",{className:"form-group"},t.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"6px 1rem 1rem 1rem"},onClick:()=>mn(!un)},t.createElement("span",{style:{fontSize:"12px",display:"flex",gap:"5px",alignItems:"center"}},"Shipping ",t.createElement(ft,null)),t.createElement("div",{className:"icon-transition"},un?t.createElement(ct,null):t.createElement(dt,null))),"all-products"===Xe&&un?t.createElement(As,{postalCodeList:We,themeColor:ue,themeTextColor:me,enableSlotPicker:Ke,deliveryHeaderTitle:Je,deliveryAvailableText:et,deliveryNotAvailableText:tt,disabledDates:Dn}):un&&(tn?t.createElement(As,{postalCodeList:We,themeColor:ue,themeTextColor:me,enableSlotPicker:Ke,deliveryHeaderTitle:Je,deliveryAvailableText:et,deliveryNotAvailableText:tt,disabledDates:Dn}):t.createElement(Ms,{postalCodeList:We,themeColor:ue,themeTextColor:me,enableSlotPicker:Ke,disabledDates:Dn}))),Be&&!!Te&&Ut?.item_count>0&&t.createElement(yi,{note:Se,noteSectionTitle:kt}),nt?.showGiftWrapOption&&Ut?.item_count>0&&t.createElement(qs,{themeColor:ue,id:nt?.giftProductId,detail:rt,showPrice:nt?.showPrice,errorText:nt?.errorText,customText:nt?.customText,showGiftIcon:nt?.showGiftIcon,addCartItem:b,removeCartItem:h}),Ut?.item_count>0&&jt&&!ve&&Lt&&t.createElement(Ep,{backgroundSubdued:a,themeColor:ue,themeTextColor:me,primaryTextColor:ae,cartComponentsCornerRadius:vt,applyCouponCode:Lt,removeDiscount:N,enableConfetti:Vt}),Ut?.item_count>0&&C&&I&&!Bt&&U&&D&&D?.length>0?t.createElement(t.Fragment,null,v||v&&J?t.createElement(xa,{themeColor:ue,showGuestDiscountCoupon:q,guestRewardCoupon:H,ref:vn,discountAmountOff:E,userTotalPoints:P??0,applyDiscount:I,applyTemplateDiscount:U,rewardCoupons:D,isCouponSelectionOpen:Jt,setIsCouponSelectionOpen:en,pointsToBeUsed:S,joinNowFunction:O,guestLoyaltyPercentage:A,isUserSignedIn:v,showDiscountsListToGuestUsers:K}):!!A&&ve&&!!O&&t.createElement(Uo,{cartSigninCTAMainText:Ee,signinCTAButtonVisible:ke,guestLoyaltyPercentage:A,joinNowFunction:O,themeColor:ue,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,showCartLevelAltPay:W})):Ut?.item_count>0&&t.createElement(t.Fragment,null,v||!ve||Bt?!Bt&&Ut?.item_count>0&&void 0!==E&&void 0!==S&&!!T&&ve&&!!I&&t.createElement(pa,{themeColor:ue,applyDiscount:I,discountAmountOff:E,loyaltyIcon:T,pointsToBeUsed:S,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,minimumOrderValueToAvailDiscount:Ce,brandTokenName:$t,showCartLevelAltPay:W,redemptionMultiplier:$}):Ut?.item_count>0&&!!A&&!!O&&t.createElement(Uo,{cartSigninCTAMainText:Ee,signinCTAButtonVisible:ke,themeColor:ue,joinNowFunction:O,guestLoyaltyPercentage:A,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,showCartLevelAltPay:W})),Ut?.item_count>0&&!!Bt&&!!N&&ve&&Bt&&void 0!==S&&t.createElement(la,{themeColor:ue,removeDiscount:N,loyaltyDiscount:Bt,isDev:M,ctaButtonBackgroundColor:re,ctaButtonTextColor:oe,primaryTextColor:ae,secondaryTextColor:ie,pointsToBeUsed:S,brandTokenName:$t,showCartLevelAltPay:W}),ve&&W&&j&&T&&Ut?.item_count>0&&t.createElement(wp,{loyaltyIcon:T,backgroundSubdued:a,primaryTextColor:ae,pointsRewardRate:V,rewardMultiplier:B}),ve&&Ut&&Ut.item_count>0&&!!Ce&&Ce>1&&t.createElement("span",{className:"yt-cart-loyalty-mov-text",style:{fontSize:"10px",color:ue??"#50D1AA",fontWeight:600,display:"flex",justifyContent:ke?"space-between":"center"}},"Minimum order value to use ",$t,":"," ",Ce),Ut&&_&&Ut?.item_count>0&&t.createElement("div",null,t.createElement(jo,{disableCheckoutButton:!!At||Qt.cartLoading,discountApplied:z,checkoutFunction:_,checkoutButtonColor:ne,checkoutFontSize:p,discountInCheckoutButton:Z,isStickyCheckout:X,discountAmountApplied:G,minimumCartValue:Y,themeTextColor:me,applyGSTToCart:xe,showGSTOption:he,applyNoteToCart:Te,showNoteOption:Be,enableGeoLocationDeliveryRestriction:He,applyPostalCodeAndDeliverySlotToCart:Ue,enableSlotPicker:Ke,cartComponentsCornerRadius:vt,cartComponentsCornerType:bt,checkoutSectionMessage:Et,checkoutSectionMessageDisplay:Tt,checkoutSectionMessageRedirectLink:Wt,showDiscountOnMRP:zt,tertiaryColor:i,tertiaryTextColor:d,cartCheckpoints:L,toggleDecimal:_t,checkoutButtonBottomSpacing:Ft,showPoweredByBadge:Rt,showCheckoutButtonPaymentIcons:Ht,primaryTextColor:ae}))))))},$p=x.div`
|
|
2239
2240
|
position: relative;
|
|
2240
2241
|
`,zp=x.button`
|
|
2241
2242
|
border: 1px solid #ccc;
|
|
@@ -2437,7 +2438,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
2437
2438
|
transform: scale(1.01);
|
|
2438
2439
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
|
|
2439
2440
|
}
|
|
2440
|
-
`,qp={showPrice:!0,productImage:{id:"",path:""},buyNowCtaTitle:"BUY NOW",desktopBarType:"stretch",showProductName:!0,showBuyNowButton:!1,showProductImage:!0,addToCartCtaTitle:"ADD TO CART",showAddToCartButton:!0,showVariantSelector:!1,productInfoVisibility:!0,excludeProducts:[],showBarOnDesktop:!0,ctaButtonFontSize:18,startsAppearingAtHeight:200,fullyAppearsAtHeight:400},Up=({showStickyCart:e,product:n,addCartItem:r,onSetLoading:i,themeColor:d,cartData:s,isCartOpen:p,setIsCartOpen:u,ctaButtonBackgroundColor:m,ctaButtonTextColor:f,addToStickyCart:g,cartComponentsCornerType:h,cartComponentsCornerRadius:x,themeTextColor:y,stickyCartCustomizationData:b,checkoutFunction:v,backgroundColor:w,primaryTextColor:C,comboBundleData:k,comboBundleAddToCartFunction:E})=>{const[T,S]=c(""),[B,$]=c(null),[z,N]=c({}),I=Ta(),[D,P]=c(null),_=o(null);l((()=>{const e=e=>{_.current&&!_.current.contains(e.target)&&P(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);const O=a((()=>k&&"combo"===k.type?k?.products?.[0]?.productDetails?.variants?.edges?.find((e=>e?.node?.availableForSale))?.node:n?.variants?.find((e=>e?.available))),[k,n]),[A,M]=c((()=>{if(!k||"combo"!==k.type)return{};const e={};return k?.products?.forEach(((t,n)=>{const r=t?.productDetails?.variants?.edges?.find((e=>e?.node?.availableForSale))?.node;r&&(e[n]=r.id)})),e})),F=a((e=>{if(!k||"combo"!==k.type)return;const t={};k?.products?.forEach(((n,r)=>{const o=n?.productDetails?.variants?.edges?.find((t=>{const r=t?.node;return n?.productDetails?.options?.every(((t,n)=>{const o=e?.[t?.name],a=r?.title?.split(" / ")?.at(n);return!(!o||!a)&&o.trim().toLowerCase()===a.trim().toLowerCase()}))}));o?.node?.id&&(t[r]=o.node.id)})),Object.keys(t).length>0&&M((e=>({...e,...t})))}),[k]);l((()=>{const e=O();if(e){S(String(e.id)),$(e);const t={};n?.options&&Array.isArray(n.options)&&n.options.forEach(((n,r)=>{const o=`option${r+1}`;e?.[o]&&(t[n?.name]=e[o])})),N(t)}}),[n,O]);const R=a((()=>new URLSearchParams(window.location.search).get("variant")||""),[]),L=()=>{const e=R();if(e){const t=n?.variants?.find((t=>String(t?.id)===String(e)));if(t&&t?.available){S(String(t.id)),$(t);const e={};n?.options?.forEach(((n,r)=>{const o=`option${r+1}`;t?.[o]&&(e[n?.name]=t[o])})),N(e)}else{const e=O();e&&(S(String(e.id)),$(e))}}};l((()=>{L();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,r=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(r.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",L),()=>{t=!1,window.removeEventListener("urlChange",L),window.history.pushState=n,window.history.replaceState=r}}),[R,n,O,B,T]);const j=o(null),[V,W]=c(1),H=xn(s,s?.currency);l((()=>{(async()=>{try{n&&T&&$(n?.variants?.filter((e=>String(e?.id)===String(T)))[0])}catch(e){console.error("Error getting selected product variant id")}})()}),[n,T]);const{cartLoading:q}=cn(),U=o(null),[Q,G]=c(0);l((()=>{U.current&&G(U.current.offsetWidth)}),[]);const Y=n?.options?.find((e=>e?.name?.toLowerCase()?.includes("color")))?.name,Z=Y?z?.[Y]:null,X=b&&(K=b,0!==Object.keys(K).length||K.constructor!==Object)?b:qp;var K;const{showProductName:J,showPrice:ee,showVariantSelector:te,showBuyNowButton:ne,showAddToCartButton:re,desktopBarType:oe,showProductImage:ae,buyNowCtaTitle:ie,addToCartCtaTitle:le,productInfoVisibility:ce,showBarOnDesktop:de,ctaButtonFontSize:se,startsAppearingAtHeight:pe,fullyAppearsAtHeight:ue,topRibbonText:me}=X,[fe,ge]=c(0),[he,xe]=c(100),[ye,be]=c(!1);if(l((()=>{const e=()=>{const e=window.scrollY;document.documentElement.scrollHeight;const t=pe||200,n=ue||400;if(e>t){const r=Math.min((e-t)/(n-t),1);ge(r),xe(100-100*r)}else ge(0),xe(100)};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]),l((()=>{const e=()=>{const e=window.innerWidth<768;be(e||!1!==de)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[de]),n?.variants?.length<1)return null;const ve=n?.available??!0,we=O(),Ce=k&&"combo"===k.type?k?.products?.[0]?.productDetails?.variants?.edges?.find((e=>e?.node?.id===A?.[0]))?.node?.price:B?.price??we?.price??n?.variants?.[0]?.price;if(0===Number(Ce))return null;if(!e||!ye)return null;if(b?.excludeProducts?.includes(n?.handle))return null;const ke=k&&"combo"===k.type?Object.values(A).length>0:B?.available??!0;return t.createElement(Mp,{className:"yt-sticky-bar-container",$opacity:fe,$translateY:he,$desktopBarType:oe||"stretch"},t.createElement(Fp,{className:"yt-sticky-bar-inner-container",$desktopBarType:oe||"stretch",$themeColor:d,$cornerType:h??"sharp",$cornerRadius:x??20,$themeTextColor:y,$productInfoVisibility:ce,$topRibbonText:me,$backgroundColor:w},ce&&t.createElement(Rp,null,ae&&t.createElement(Lp,{className:"yt-sticky-bar-product-image",src:((e,t)=>"string"==typeof e?.featured_image?e.featured_image:e?.featured_image?.src?e.featured_image.src:t?.featured_image)(B,n),alt:B?.name}),t.createElement(jp,{ref:U,className:"yt-sticky-bar-product-details"},J&&t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},t.createElement("span",{style:{fontSize:"20px",fontWeight:"500",color:C,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",lineHeight:"normal"}},`${n?.title}`),Z&&t.createElement("span",{style:{fontSize:"11px",color:"#666",backgroundColor:"#f1f1f1",padding:"2px 6px",borderRadius:"10px",border:"1px solid #ddd"}},Z)),n?.variants?.length>1&&te&&t.createElement(Op,{className:"yt-sticky-bar-option-container",ref:_},n?.options?.map((e=>{const r=I?.options?.find((t=>t.name.trim().toLowerCase()===e.name.trim().toLowerCase())),o=z[e.name],a=D===e.name,i=t=>{((e,t)=>{const r={...z,[e]:t};N(r);const o=n?.variants?.find((e=>n?.options?.every(((t,n)=>{const o=r?.[t?.name],a=e?.[`option${n+1}`];return"string"==typeof o&&"string"==typeof a?o.trim().toLowerCase()===a.trim().toLowerCase():o===a}))));o&&(S(String(o.id)),$(o)),k&&"combo"===k?.type&&F(r)})(e.name,t),P(null)},l=Ea(r,o);return t.createElement("div",{key:e.name,style:{display:"flex",alignItems:"center",gap:"8px"}},t.createElement(Ap,null,e.name),t.createElement($p,null,t.createElement(zp,{onClick:()=>{P(a?null:e.name)},className:"yt-sticky-bar-dropdown-button"},"color"===r?.type&&l?.value?t.createElement(Dp,{$colorValue:l.value}):"image"===r?.type&&l?.value?t.createElement(Pp,{src:l.value}):null,o,t.createElement(_p,{size:8,$isOpen:a})),a&&t.createElement(Np,{$backgroundColor:w,className:"yt-sticky-bar-dropdown-panel"},e.values.map((e=>{const n=Ea(r,e);return t.createElement(Ip,{className:"yt-sticky-bar-dropdown-item",key:e,onClick:()=>i(e)},"color"===r?.type&&n?.value?t.createElement(Dp,{$colorValue:n.value}):"image"===r?.type&&n?.value?t.createElement(Pp,{src:n.value}):null,e)})))))}))),ee&&t.createElement(t.Fragment,null,B?.compare_at_price&&B?.compare_at_price>B?.price?t.createElement("div",{style:{display:"flex",flexDirection:"row",gap:5,alignItems:"center"}},t.createElement("span",{style:{fontWeight:"500",fontSize:18,color:C},className:"yt-sticky-bar-product-price"},`${H}`,gn(B?.price,s?.currency)),t.createElement("span",{style:{textDecoration:"line-through",color:"#6b7280",fontSize:14},className:"yt-sticky-bar-product-compare-price"},`${H}`,gn(B?.compare_at_price,s?.currency)),t.createElement("span",{style:{backgroundColor:d??"black",color:y??"white",padding:"3px 9px",fontSize:"12px",borderRadius:"rounded"===h?`${x}px`:"0"},className:"yt-sticky-bar-product-discount"},"Save ",`${H}`,gn(B?.compare_at_price-B?.price,s?.currency))):t.createElement(t.Fragment,null,t.createElement("span",{style:{fontWeight:"500",fontSize:18,color:C},className:"yt-sticky-bar-product-price"},`${H}`,gn(B?.price,s?.currency)))),t.createElement("span",{style:{color:"#6E747B",fontSize:10},className:"yt-sticky-bar-product-tax-inclusion"},"Inclusive of all taxes"))),ve&&t.createElement(Vp,{className:"yt-sticky-bar-product-line-item-control",$flexDirection:ce?"row":"column"},re&&t.createElement(Hp,{ref:j,onClick:async()=>{if(k&&"combo"===k.type){if(!E)return void console.error("[StickyCart.tsx] comboBundleAddToCartFunction is undefined");const e=Object.entries(A);if(0===e.length)return;const t=e.map((([,e])=>e)),n=e.map((([e,t])=>{const n=k?.products?.[Number(e)],r=n?.productDetails?.variants?.edges?.find((e=>e?.node?.id===t))?.node;return r?{variantId:t,price:Number(r?.price),compareAtPrice:Number(r?.compareAtPrice||r?.price)}:null})).filter((e=>null!==e)),r=n.reduce(((e,t)=>e+Math.max(t.compareAtPrice,t.price)),0),o=n.reduce(((e,t)=>e+t.price),0);let a=Math.min(r,o);k?.percentageOff?a=o*(1-k.percentageOff/100):k?.dealAmount?a=k.dealAmount:k?.amountOff&&(a=o-k.amountOff);const i=n.map((({variantId:e,price:t})=>({variantId:e,price:t})));await E(Number(r.toFixed(2)),t,Number(a.toFixed(2)),i)}else g&&await g(String(T)??String(n?.variants[0]?.id),V)},disabled:q.cartLoading||!ke,$bgColor:ke?m:"#d1d5db",$textColor:ke?f:"#6b7280",className:"yt-sticky-add-to-cart-button",$cornerType:h??"sharp",$cornerRadius:x??20,$fontSize:se,style:{cursor:ke?"pointer":"not-allowed",opacity:ke?1:.6}},q.cartLoading?t.createElement(ta,{color:"white",loading:q.cartLoading,size:15}):t.createElement(t.Fragment,null,ke?le??"Add to Cart":"Out of Stock")),ne&&t.createElement(Wp,{onClick:async
|
|
2441
|
+
`,qp={showPrice:!0,productImage:{id:"",path:""},buyNowCtaTitle:"BUY NOW",desktopBarType:"stretch",showProductName:!0,showBuyNowButton:!1,showProductImage:!0,addToCartCtaTitle:"ADD TO CART",showAddToCartButton:!0,showVariantSelector:!1,productInfoVisibility:!0,excludeProducts:[],showBarOnDesktop:!0,ctaButtonFontSize:18,startsAppearingAtHeight:200,fullyAppearsAtHeight:400},Up=({showStickyCart:e,product:n,addCartItem:r,onSetLoading:i,themeColor:d,cartData:s,isCartOpen:p,setIsCartOpen:u,ctaButtonBackgroundColor:m,ctaButtonTextColor:f,addToStickyCart:g,cartComponentsCornerType:h,cartComponentsCornerRadius:x,themeTextColor:y,stickyCartCustomizationData:b,checkoutFunction:v,backgroundColor:w,primaryTextColor:C,comboBundleData:k,comboBundleAddToCartFunction:E})=>{const[T,S]=c(""),[B,$]=c(null),[z,N]=c({}),I=Ta(),[D,P]=c(null),_=o(null);l((()=>{const e=e=>{_.current&&!_.current.contains(e.target)&&P(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);const O=a((()=>k&&"combo"===k.type?k?.products?.[0]?.productDetails?.variants?.edges?.find((e=>e?.node?.availableForSale))?.node:n?.variants?.find((e=>e?.available))),[k,n]),[A,M]=c((()=>{if(!k||"combo"!==k.type)return{};const e={};return k?.products?.forEach(((t,n)=>{const r=t?.productDetails?.variants?.edges?.find((e=>e?.node?.availableForSale))?.node;r&&(e[n]=r.id)})),e})),F=a((e=>{if(!k||"combo"!==k.type)return;const t={};k?.products?.forEach(((n,r)=>{const o=n?.productDetails?.variants?.edges?.find((t=>{const r=t?.node;return n?.productDetails?.options?.every(((t,n)=>{const o=e?.[t?.name],a=r?.title?.split(" / ")?.at(n);return!(!o||!a)&&o.trim().toLowerCase()===a.trim().toLowerCase()}))}));o?.node?.id&&(t[r]=o.node.id)})),Object.keys(t).length>0&&M((e=>({...e,...t})))}),[k]);l((()=>{const e=O();if(e){S(String(e.id)),$(e);const t={};n?.options&&Array.isArray(n.options)&&n.options.forEach(((n,r)=>{const o=`option${r+1}`;e?.[o]&&(t[n?.name]=e[o])})),N(t)}}),[n,O]);const R=a((()=>new URLSearchParams(window.location.search).get("variant")||""),[]),L=()=>{const e=R();if(e){const t=n?.variants?.find((t=>String(t?.id)===String(e)));if(t&&t?.available){S(String(t.id)),$(t);const e={};n?.options?.forEach(((n,r)=>{const o=`option${r+1}`;t?.[o]&&(e[n?.name]=t[o])})),N(e)}else{const e=O();e&&(S(String(e.id)),$(e))}}};l((()=>{L();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,r=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(r.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",L),()=>{t=!1,window.removeEventListener("urlChange",L),window.history.pushState=n,window.history.replaceState=r}}),[R,n,O,B,T]);const j=o(null),[V,W]=c(1),H=xn(s,s?.currency);l((()=>{(async()=>{try{n&&T&&$(n?.variants?.filter((e=>String(e?.id)===String(T)))[0])}catch(e){console.error("Error getting selected product variant id")}})()}),[n,T]);const{cartLoading:q}=cn(),U=o(null),[Q,G]=c(0);l((()=>{U.current&&G(U.current.offsetWidth)}),[]);const Y=n?.options?.find((e=>e?.name?.toLowerCase()?.includes("color")))?.name,Z=Y?z?.[Y]:null,X=b&&(K=b,0!==Object.keys(K).length||K.constructor!==Object)?b:qp;var K;const{showProductName:J,showPrice:ee,showVariantSelector:te,showBuyNowButton:ne,showAddToCartButton:re,desktopBarType:oe,showProductImage:ae,buyNowCtaTitle:ie,addToCartCtaTitle:le,productInfoVisibility:ce,showBarOnDesktop:de,ctaButtonFontSize:se,startsAppearingAtHeight:pe,fullyAppearsAtHeight:ue,topRibbonText:me}=X,[fe,ge]=c(0),[he,xe]=c(100),[ye,be]=c(!1);if(l((()=>{const e=()=>{const e=window.scrollY;document.documentElement.scrollHeight;const t=pe||200,n=ue||400;if(e>t){const r=Math.min((e-t)/(n-t),1);ge(r),xe(100-100*r)}else ge(0),xe(100)};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]),l((()=>{const e=()=>{const e=window.innerWidth<768;be(e||!1!==de)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[de]),n?.variants?.length<1)return null;const ve=n?.available??!0,we=O(),Ce=k&&"combo"===k.type?k?.products?.[0]?.productDetails?.variants?.edges?.find((e=>e?.node?.id===A?.[0]))?.node?.price:B?.price??we?.price??n?.variants?.[0]?.price;if(0===Number(Ce))return null;if(!e||!ye)return null;if(b?.excludeProducts?.includes(n?.handle))return null;const ke=k&&"combo"===k.type?Object.values(A).length>0:B?.available??!0;return t.createElement(Mp,{className:"yt-sticky-bar-container",$opacity:fe,$translateY:he,$desktopBarType:oe||"stretch"},t.createElement(Fp,{className:"yt-sticky-bar-inner-container",$desktopBarType:oe||"stretch",$themeColor:d,$cornerType:h??"sharp",$cornerRadius:x??20,$themeTextColor:y,$productInfoVisibility:ce,$topRibbonText:me,$backgroundColor:w},ce&&t.createElement(Rp,null,ae&&t.createElement(Lp,{className:"yt-sticky-bar-product-image",src:((e,t)=>"string"==typeof e?.featured_image?e.featured_image:e?.featured_image?.src?e.featured_image.src:t?.featured_image)(B,n),alt:B?.name}),t.createElement(jp,{ref:U,className:"yt-sticky-bar-product-details"},J&&t.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},t.createElement("span",{style:{fontSize:"20px",fontWeight:"500",color:C,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",lineHeight:"normal"}},`${n?.title}`),Z&&t.createElement("span",{style:{fontSize:"11px",color:"#666",backgroundColor:"#f1f1f1",padding:"2px 6px",borderRadius:"10px",border:"1px solid #ddd"}},Z)),n?.variants?.length>1&&te&&t.createElement(Op,{className:"yt-sticky-bar-option-container",ref:_},n?.options?.map((e=>{const r=I?.options?.find((t=>t.name.trim().toLowerCase()===e.name.trim().toLowerCase())),o=z[e.name],a=D===e.name,i=t=>{((e,t)=>{const r={...z,[e]:t};N(r);const o=n?.variants?.find((e=>n?.options?.every(((t,n)=>{const o=r?.[t?.name],a=e?.[`option${n+1}`];return"string"==typeof o&&"string"==typeof a?o.trim().toLowerCase()===a.trim().toLowerCase():o===a}))));o&&(S(String(o.id)),$(o)),k&&"combo"===k?.type&&F(r)})(e.name,t),P(null)},l=Ea(r,o);return t.createElement("div",{key:e.name,style:{display:"flex",alignItems:"center",gap:"8px"}},t.createElement(Ap,null,e.name),t.createElement($p,null,t.createElement(zp,{onClick:()=>{P(a?null:e.name)},className:"yt-sticky-bar-dropdown-button"},"color"===r?.type&&l?.value?t.createElement(Dp,{$colorValue:l.value}):"image"===r?.type&&l?.value?t.createElement(Pp,{src:l.value}):null,o,t.createElement(_p,{size:8,$isOpen:a})),a&&t.createElement(Np,{$backgroundColor:w,className:"yt-sticky-bar-dropdown-panel"},e.values.map((e=>{const n=Ea(r,e);return t.createElement(Ip,{className:"yt-sticky-bar-dropdown-item",key:e,onClick:()=>i(e)},"color"===r?.type&&n?.value?t.createElement(Dp,{$colorValue:n.value}):"image"===r?.type&&n?.value?t.createElement(Pp,{src:n.value}):null,e)})))))}))),ee&&t.createElement(t.Fragment,null,B?.compare_at_price&&B?.compare_at_price>B?.price?t.createElement("div",{style:{display:"flex",flexDirection:"row",gap:5,alignItems:"center"}},t.createElement("span",{style:{fontWeight:"500",fontSize:18,color:C},className:"yt-sticky-bar-product-price"},`${H}`,gn(B?.price,s?.currency)),t.createElement("span",{style:{textDecoration:"line-through",color:"#6b7280",fontSize:14},className:"yt-sticky-bar-product-compare-price"},`${H}`,gn(B?.compare_at_price,s?.currency)),t.createElement("span",{style:{backgroundColor:d??"black",color:y??"white",padding:"3px 9px",fontSize:"12px",borderRadius:"rounded"===h?`${x}px`:"0"},className:"yt-sticky-bar-product-discount"},"Save ",`${H}`,gn(B?.compare_at_price-B?.price,s?.currency))):t.createElement(t.Fragment,null,t.createElement("span",{style:{fontWeight:"500",fontSize:18,color:C},className:"yt-sticky-bar-product-price"},`${H}`,gn(B?.price,s?.currency)))),t.createElement("span",{style:{color:"#6E747B",fontSize:10},className:"yt-sticky-bar-product-tax-inclusion"},"Inclusive of all taxes"))),ve&&t.createElement(Vp,{className:"yt-sticky-bar-product-line-item-control",$flexDirection:ce?"row":"column"},re&&t.createElement(Hp,{ref:j,onClick:async()=>{if(k&&"combo"===k.type){if(!E)return void console.error("[StickyCart.tsx] comboBundleAddToCartFunction is undefined");const e=Object.entries(A);if(0===e.length)return;const t=e.map((([,e])=>e)),n=e.map((([e,t])=>{const n=k?.products?.[Number(e)],r=n?.productDetails?.variants?.edges?.find((e=>e?.node?.id===t))?.node;return r?{variantId:t,price:Number(r?.price),compareAtPrice:Number(r?.compareAtPrice||r?.price)}:null})).filter((e=>null!==e)),r=n.reduce(((e,t)=>e+Math.max(t.compareAtPrice,t.price)),0),o=n.reduce(((e,t)=>e+t.price),0);let a=Math.min(r,o);k?.percentageOff?a=o*(1-k.percentageOff/100):k?.dealAmount?a=k.dealAmount:k?.amountOff&&(a=o-k.amountOff);const i=n.map((({variantId:e,price:t})=>({variantId:e,price:t})));await E(Number(r.toFixed(2)),t,Number(a.toFixed(2)),i)}else g&&await g(String(T)??String(n?.variants[0]?.id),V)},disabled:q.cartLoading||!ke,$bgColor:ke?m:"#d1d5db",$textColor:ke?f:"#6b7280",className:"yt-sticky-add-to-cart-button",$cornerType:h??"sharp",$cornerRadius:x??20,$fontSize:se,style:{cursor:ke?"pointer":"not-allowed",opacity:ke?1:.6}},q.cartLoading?t.createElement(ta,{color:"white",loading:q.cartLoading,size:15}):t.createElement(t.Fragment,null,ke?le??"Add to Cart":"Out of Stock")),ne&&t.createElement(Wp,{onClick:async()=>{try{v&&await v(String(T)??String(n?.variants[0]?.id),V)}catch(e){console.error("Error checking out from sticky bar")}},id:"yt-checkout-button",className:"yt-checkout-button",disabled:q.cartLoading||!ke,$bgColor:ke?d:"#d1d5db",$textColor:ke?y:"#6b7280",$cornerType:h??"sharp",$cornerRadius:x??20,$fontSize:se,style:{cursor:ke?"pointer":"not-allowed",opacity:ke?1:.6}},q.cartLoading?t.createElement(ta,{color:"white",loading:q.cartLoading,size:15}):t.createElement(t.Fragment,null,ke?ie??"Buy Now":"Out of Stock")))))},Qp=x.div`
|
|
2441
2442
|
width: 100%;
|
|
2442
2443
|
height: 100%;
|
|
2443
2444
|
display: flex;
|
|
@@ -200,7 +200,7 @@ export interface CartProps {
|
|
|
200
200
|
cartOffersCarousalData?: CartOffersCarousalProps;
|
|
201
201
|
freebieMilestoneData?: freebieMilestoneProps;
|
|
202
202
|
cartOffersCarouselHeight?: number;
|
|
203
|
-
stickyBarBuyNowFunction?: (
|
|
203
|
+
stickyBarBuyNowFunction?: (variantId: string, quantity: number) => Promise<void>;
|
|
204
204
|
gstSectionCustomizationData?: GSTSectionCustomizationProps;
|
|
205
205
|
noteSectionTitle?: string;
|
|
206
206
|
checkoutSectionMessage?: string;
|
|
@@ -39,7 +39,7 @@ export type StickyAddToCartProps = {
|
|
|
39
39
|
cartComponentsCornerType?: "rounded" | "sharp";
|
|
40
40
|
cartComponentsCornerRadius?: number;
|
|
41
41
|
stickyCartCustomizationData?: stickyCartCustomizationDataProps;
|
|
42
|
-
checkoutFunction?: (
|
|
42
|
+
checkoutFunction?: (variantId: string, quantity: number) => Promise<void>;
|
|
43
43
|
backgroundColor?: string;
|
|
44
44
|
primaryTextColor?: string;
|
|
45
45
|
comboBundleData?: BundlePayload;
|
package/dist/index.d.ts
CHANGED
|
@@ -702,7 +702,7 @@ interface CartProps {
|
|
|
702
702
|
cartOffersCarousalData?: CartOffersCarousalProps;
|
|
703
703
|
freebieMilestoneData?: freebieMilestoneProps;
|
|
704
704
|
cartOffersCarouselHeight?: number;
|
|
705
|
-
stickyBarBuyNowFunction?: (
|
|
705
|
+
stickyBarBuyNowFunction?: (variantId: string, quantity: number) => Promise<void>;
|
|
706
706
|
gstSectionCustomizationData?: GSTSectionCustomizationProps;
|
|
707
707
|
noteSectionTitle?: string;
|
|
708
708
|
checkoutSectionMessage?: string;
|