yt-uikit 0.8.2 → 0.8.3
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 +1 -1
- 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
|
@@ -2437,7 +2437,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
2437
2437
|
transform: scale(1.01);
|
|
2438
2438
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
|
|
2439
2439
|
}
|
|
2440
|
-
`,Up={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},Qp=({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,I]=c({}),N=Ta(),[D,_]=c(null),P=o(null);l((()=>{const e=e=>{P.current&&!P.current.contains(e.target)&&_(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);const A=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]),[O,F]=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})),M=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&&F((e=>({...e,...t})))}),[k]);l((()=>{const e=A();if(e){S(String(e.id)),B(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])})),I(t)}}),[n,A]);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)),B(t);const e={};n?.options?.forEach(((n,r)=>{const o=`option${r+1}`;t?.[o]&&(e[n?.name]=t[o])})),I(e)}else{const e=A();e&&(S(String(e.id)),B(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,A,$,T]);const j=o(null),[V,W]=c(1),H=yn(s,s?.currency);l((()=>{(async()=>{try{n&&T&&B(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}=dn(),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:Up;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=A(),Ce=k&&"combo"===k.type?k?.products?.[0]?.productDetails?.variants?.edges?.find((e=>e?.node?.id===O?.[0]))?.node?.price:$?.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(O).length>0:$?.available??!0;return t.createElement(Mp,{className:"yt-sticky-bar-container",$opacity:fe,$translateY:he,$desktopBarType:oe||"stretch"},t.createElement(Rp,{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(Lp,null,ae&&t.createElement(jp,{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)($,n),alt:$?.name}),t.createElement(Vp,{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:P},n?.options?.map((e=>{const r=N?.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};I(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)),B(o)),k&&"combo"===k?.type&&M(r)})(e.name,t),_(null)},l=Ea(r,o);return t.createElement("div",{key:e.name,style:{display:"flex",alignItems:"center",gap:"8px"}},t.createElement(Fp,null,e.name),t.createElement(zp,null,t.createElement(Ip,{onClick:()=>{_(a?null:e.name)},className:"yt-sticky-bar-dropdown-button"},"color"===r?.type&&l?.value?t.createElement(_p,{$colorValue:l.value}):"image"===r?.type&&l?.value?t.createElement(Pp,{src:l.value}):null,o,t.createElement(Ap,{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(Dp,{className:"yt-sticky-bar-dropdown-item",key:e,onClick:()=>i(e)},"color"===r?.type&&n?.value?t.createElement(_p,{$colorValue:n.value}):"image"===r?.type&&n?.value?t.createElement(Pp,{src:n.value}):null,e)})))))}))),ee&&t.createElement(t.Fragment,null,$?.compare_at_price&&$?.compare_at_price>$?.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}`,hn($?.price,s?.currency)),t.createElement("span",{style:{textDecoration:"line-through",color:"#6b7280",fontSize:14},className:"yt-sticky-bar-product-compare-price"},`${H}`,hn($?.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}`,hn($?.compare_at_price-$?.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}`,hn($?.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(Wp,{className:"yt-sticky-bar-product-line-item-control",$flexDirection:ce?"row":"column"},re&&t.createElement(qp,{ref:j,onClick:async()=>{if(k&&"combo"===k.type){if(!E)return void console.error("[StickyCart.tsx] comboBundleAddToCartFunction is undefined");const e=Object.entries(O);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(Hp,{onClick:async
|
|
2440
|
+
`,Up={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},Qp=({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,I]=c({}),N=Ta(),[D,_]=c(null),P=o(null);l((()=>{const e=e=>{P.current&&!P.current.contains(e.target)&&_(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);const A=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]),[O,F]=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})),M=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&&F((e=>({...e,...t})))}),[k]);l((()=>{const e=A();if(e){S(String(e.id)),B(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])})),I(t)}}),[n,A]);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)),B(t);const e={};n?.options?.forEach(((n,r)=>{const o=`option${r+1}`;t?.[o]&&(e[n?.name]=t[o])})),I(e)}else{const e=A();e&&(S(String(e.id)),B(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,A,$,T]);const j=o(null),[V,W]=c(1),H=yn(s,s?.currency);l((()=>{(async()=>{try{n&&T&&B(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}=dn(),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:Up;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=A(),Ce=k&&"combo"===k.type?k?.products?.[0]?.productDetails?.variants?.edges?.find((e=>e?.node?.id===O?.[0]))?.node?.price:$?.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(O).length>0:$?.available??!0;return t.createElement(Mp,{className:"yt-sticky-bar-container",$opacity:fe,$translateY:he,$desktopBarType:oe||"stretch"},t.createElement(Rp,{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(Lp,null,ae&&t.createElement(jp,{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)($,n),alt:$?.name}),t.createElement(Vp,{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:P},n?.options?.map((e=>{const r=N?.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};I(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)),B(o)),k&&"combo"===k?.type&&M(r)})(e.name,t),_(null)},l=Ea(r,o);return t.createElement("div",{key:e.name,style:{display:"flex",alignItems:"center",gap:"8px"}},t.createElement(Fp,null,e.name),t.createElement(zp,null,t.createElement(Ip,{onClick:()=>{_(a?null:e.name)},className:"yt-sticky-bar-dropdown-button"},"color"===r?.type&&l?.value?t.createElement(_p,{$colorValue:l.value}):"image"===r?.type&&l?.value?t.createElement(Pp,{src:l.value}):null,o,t.createElement(Ap,{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(Dp,{className:"yt-sticky-bar-dropdown-item",key:e,onClick:()=>i(e)},"color"===r?.type&&n?.value?t.createElement(_p,{$colorValue:n.value}):"image"===r?.type&&n?.value?t.createElement(Pp,{src:n.value}):null,e)})))))}))),ee&&t.createElement(t.Fragment,null,$?.compare_at_price&&$?.compare_at_price>$?.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}`,hn($?.price,s?.currency)),t.createElement("span",{style:{textDecoration:"line-through",color:"#6b7280",fontSize:14},className:"yt-sticky-bar-product-compare-price"},`${H}`,hn($?.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}`,hn($?.compare_at_price-$?.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}`,hn($?.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(Wp,{className:"yt-sticky-bar-product-line-item-control",$flexDirection:ce?"row":"column"},re&&t.createElement(qp,{ref:j,onClick:async()=>{if(k&&"combo"===k.type){if(!E)return void console.error("[StickyCart.tsx] comboBundleAddToCartFunction is undefined");const e=Object.entries(O);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(Hp,{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")))))},Gp=x.div`
|
|
2441
2441
|
width: 100%;
|
|
2442
2442
|
height: 100%;
|
|
2443
2443
|
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
|
@@ -701,7 +701,7 @@ interface CartProps {
|
|
|
701
701
|
cartOffersCarousalData?: CartOffersCarousalProps;
|
|
702
702
|
freebieMilestoneData?: freebieMilestoneProps;
|
|
703
703
|
cartOffersCarouselHeight?: number;
|
|
704
|
-
stickyBarBuyNowFunction?: (
|
|
704
|
+
stickyBarBuyNowFunction?: (variantId: string, quantity: number) => Promise<void>;
|
|
705
705
|
gstSectionCustomizationData?: GSTSectionCustomizationProps;
|
|
706
706
|
noteSectionTitle?: string;
|
|
707
707
|
checkoutSectionMessage?: string;
|