yt-uikit 0.8.31 → 0.8.32
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/index.js +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2201,7 +2201,7 @@ import e,{useState as t,useEffect as n,useMemo as o,useRef as r,useCallback as i
|
|
|
2201
2201
|
left: 150%;
|
|
2202
2202
|
}
|
|
2203
2203
|
}
|
|
2204
|
-
`,Ta=({loyaltyIcon:t,pointsRewardRate:n=0,brandTokenName:o,themeColor:r,themeTextColor:i,rewardMultiplier:a})=>{const l=M(St),c=.01*n*_t(l?.items_subtotal_price,l?.currency),d="number"==typeof a&&a>0?c*a:c;return n<=0?null:e.createElement(ka,{$themeColor:r,$themeTextColor:i},"Get"," ",t&&e.createElement("img",{src:t,height:"18px",width:"18px",style:{width:"18px",height:"18px"}}),Number(d.toFixed(0))," ",o??"points"," ",e.createElement("div",{className:"shine-container"},e.createElement("div",{className:"shine-element"})))},$a=({backgroundSubdued:o,themeColor:i,themeTextColor:a,primaryTextColor:l,cartComponentsCornerRadius:c,applyCouponCode:d,removeDiscount:s,enableConfetti:p})=>{const m=M(St),[u,g]=t(""),[x,f]=t(null),[y,h]=t(!1),[b,v]=t(!1),[w,C]=t(!1),{setLoading:E}=Pt(),[k,T]=t(null),[$,S]=t(!1),[B,z]=t(!1),I=r(null);n(()=>{if(k){S(!0);const e=setTimeout(()=>{S(!1)},4e3),t=setTimeout(()=>{T(null)},4500);return()=>{clearTimeout(e),clearTimeout(t)}}S(!1)},[k]),n(()=>{if(m&&m.discount_codes&&x){const e=m.discount_codes.find(e=>e.code===x);e&&(e.applicable?(T({message:"Coupon applied successfully!",type:"success"}),p&&(z(!0),setTimeout(()=>z(!1),5e3))):T({message:"Coupon not applicable",type:"error"}),f(null))}},[m,x]);const N=async()=>{if(d&&u&&!y){T(null),h(!0),f(u);try{await d(u),g("")}catch(e){T({message:"Failed to apply coupon.",type:"error"}),f(null)}finally{h(!1)}}},F=async()=>{if(s&&!w){T(null),C(!0),E&&E(!0,!1,!1,!0);try{await s()}catch(e){T({message:"Failed to remove coupon.",type:"error"})}finally{E&&E(!1,!1,!1,!1),C(!1)}}},P="error"===k?.type,D=m?.discount_codes?.filter(e=>!1!==e?.applicable);return e.createElement("div",{ref:I,style:{marginTop:"10px",padding:"0 16px",marginBottom:"10px"}},B&&p&&e.createElement(Jn,{particleCount:100,spread:160,origin:{y:.6},checkpointPosition:.5}),e.createElement("div",{style:{display:"flex",alignItems:"stretch",border:P?"0.5px solid #FF4E4E":b?`1px solid ${i||"#007bff"}`:"1px solid #e0e0e0",borderRadius:c??4,transition:"border-color 0.5s ease-in-out",overflow:"hidden"}},e.createElement("input",{type:"text",placeholder:"Have a Coupon Code?",value:u,disabled:y,onFocus:()=>{v(!0),setTimeout(()=>{I.current&&window.innerWidth<=768&&I.current.scrollIntoView({behavior:"smooth",block:"nearest"})},300)},onBlur:()=>v(!1),onChange:e=>{g(e.target.value),k&&T(null)},onKeyDown:e=>{"Enter"===e.key&&N()},style:{flexGrow:1,border:"none",padding:"10px",outline:"none",fontSize:"14px",fontWeight:"bold",borderTopLeftRadius:c??4,borderBottomLeftRadius:c??4,backgroundColor:o,color:l,boxShadow:"none",cursor:y?"not-allowed":"auto",margin:"0"}}),e.createElement("button",{onClick:N,disabled:!u||y,style:{padding:"10px 15px",border:"none",backgroundColor:P?"#D98181":u?i||"#007bff":"#cccccc",color:u||P?a||"#ffffff":"#666666",cursor:!u||y?"not-allowed":"pointer",fontSize:"14px",fontWeight:"bold",borderTopRightRadius:c??4,borderBottomRightRadius:c??4,transition:"background-color 0.5s ease-in-out, opacity 0.2s ease-in-out",minWidth:"80px",display:"flex",justifyContent:"center",alignItems:"center",opacity:y?.7:1}},y?e.createElement(Ae,{color:a||"#ffffff",size:18}):"Apply")),k&&e.createElement("div",{style:{color:"success"===k.type?"#28a745":"#dc3545",fontSize:"12px",marginTop:"4px",fontStyle:"italic",transition:"opacity 0.5s ease-in-out, transform 0.5s ease-in-out, max-height 0.5s ease-in-out",opacity:$?1:0,transform:$?"translateY(0)":"translateY(-10px)",maxHeight:$?"50px":"0",overflow:"hidden"}},k.message),D&&D.length>0&&e.createElement("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"}},D.map(t=>e.createElement("div",{key:t.code,style:{display:"flex",alignItems:"center",fontSize:"12px",fontStyle:"italic"}},e.createElement("div",{style:{display:"flex",alignItems:"center",color:"#333333",backgroundColor:o,paddingInlineStart:"6px",gap:"4px"}},e.createElement(Ie,{size:12,color:"#4D4D4D"}),e.createElement("span",{style:{fontWeight:"bold",fontStyle:"normal"}},t.code)," applied!",e.createElement("button",{onClick:F,disabled:w,style:{background:"#E2E2E2",border:"0.5px solid #B5B5B5",cursor:"pointer",marginLeft:"4px",padding:"0",display:"flex",alignItems:"center"}},w?e.createElement(Ae,{color:i||"#007bff",size:14}):e.createElement(J,{size:16})))))))};function Sa({showDiscountOnMRP:i,cartCheckpoints:a,toggleDecimal:l,primaryTextColor:c,discountApplied:d,showPoweredByBadge:s=!0}){const p=M(St),m=Rt(p,p?.currency),[u,g]=t(!1),x=r(null),[f,y]=t("0px"),h=_t(p?.original_total_price,p?.currency),b=o(()=>a?.find(e=>"free_delivery"===e.couponType&&void 0!==e.discountValue),[a]),v=o(()=>!(!b||!b.minimumOrderValue)&&h>=b.minimumOrderValue,[b,h]),w=v&&b&&b.discountValue||0,C=o(()=>{if(!p?.items?.length)return 0;const e=p.items.reduce((e,t)=>e+(i&&t?.compare_at_price&&t?.compare_at_price>t?.original_price?t.compare_at_price:t.original_price)*t.quantity,0);return _t(e,p?.currency)},[p?.items,i]),E=o(()=>v?C+w:C,[v,C,w]),k=o(()=>p?.items?.length?p.items.reduce((e,t)=>t.compare_at_price&&t.compare_at_price>t.original_price?e+(t.compare_at_price-t.original_price)*t.quantity:e,0):0,[p?.items]),T=_t(k,p?.currency??"INR"),$=o(()=>{const e={};return p?.items?.length?(p.items.forEach(t=>{t.discounts&&Array.isArray(t.discounts)&&t.discounts.forEach(t=>{e[t.title]=(e[t.title]||0)+t.amount})}),e):e},[p?.items]),S=o(()=>{const e=[];for(const t in $)if(Object.prototype.hasOwnProperty.call($,t)){const n=$[t],o=_t(n,p?.currency??"INR"),r=Gt(t);e.push({title:r,amount:o})}return e},[$,p?.currency]),B=o(()=>{let e=0;return i&&(e+=T),S.forEach(t=>{e+=t.amount}),v&&(e+=w),e},[T,S,i,v,w]),z=h;n(()=>{x.current&&y(u?`${x.current.scrollHeight}px`:"0px")},[u,S,v]);const I=T>0||d&&S.length>0||v&&w>0;return p?.item_count?e.createElement("div",{className:"yt-cart-subtotal-section-scroll",style:{backgroundColor:"rgba(138, 138, 138, 0.08)",padding:"10px 1rem",marginTop:"8px"}},e.createElement("div",{style:{display:"flex",flexDirection:"column",rowGap:"2px",color:c}},I&&B>0&&e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px"}},"Subtotal"),e.createElement("span",{style:{fontSize:"14px"}},m,qt(v?l?E.toFixed(2):E.toFixed(0):l?C.toFixed(2):C.toFixed(0)))),e.createElement("div",{style:{display:"flex",flexDirection:"column",paddingBottom:"5px"}},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center"}},"Discounts Applied",e.createElement("button",{onClick:()=>{g(!u)},className:"yt-cart-details-button",style:{marginBottom:"0",marginLeft:"5px",background:"none",border:"none",color:"#7E7E7E",cursor:"pointer",fontSize:"12px",fontWeight:"600",textDecoration:"underline",padding:"0 !important",minHeight:"10px !important",boxShadow:"none",minWidth:"fit-content",height:"auto",lineHeight:"normal",marginTop:"0"}},u?"Hide details":"See details")),e.createElement("span",{style:{fontSize:"14px",color:"#D3122A",fontWeight:"600"}},"-",m,qt(l?B.toFixed(2):B.toFixed(0)))),e.createElement("div",{ref:x,style:{height:f,overflow:"hidden",transition:"height 0.3s ease, opacity 0.3s ease",opacity:u?1:0,marginTop:u?"5px":"0",borderTop:u?"1px solid #E5E7EB":"none",paddingTop:u?"5px":"0",fontWeight:"600"}},i&&T>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Discount on MRP"),e.createElement("span",{style:{color:"#D3122A"}},"-",m,qt(l?T.toFixed(2):T.toFixed(0)))),v&&w>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Free Shipping"),e.createElement("span",{style:{color:"#D3122A"}},"-",m,qt(l?w.toFixed(2):w.toFixed(0)))),S.map(t=>e.createElement("div",{key:t.title,style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,t.title),e.createElement("span",{style:{color:"#D3122A"}},"-",m,qt(l?t.amount.toFixed(2):t.amount.toFixed(0))))))),e.createElement("hr",{className:"yt-cart-checkout-divider",style:{height:"1px",margin:"2px 0",backgroundColor:"#E5E7EB",border:"none",maxWidth:"unset"}})),e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"14px",fontWeight:"600"}},"Total"),e.createElement("span",{style:{fontSize:"16px",fontWeight:"var(--yt-cart-font-weight)"}},m,qt(l?z.toFixed(2):z.toFixed(0))))),s&&e.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingBlock:"6px 0"}},e.createElement("img",{src:"https://r2.yourtoken.io/
|
|
2204
|
+
`,Ta=({loyaltyIcon:t,pointsRewardRate:n=0,brandTokenName:o,themeColor:r,themeTextColor:i,rewardMultiplier:a})=>{const l=M(St),c=.01*n*_t(l?.items_subtotal_price,l?.currency),d="number"==typeof a&&a>0?c*a:c;return n<=0?null:e.createElement(ka,{$themeColor:r,$themeTextColor:i},"Get"," ",t&&e.createElement("img",{src:t,height:"18px",width:"18px",style:{width:"18px",height:"18px"}}),Number(d.toFixed(0))," ",o??"points"," ",e.createElement("div",{className:"shine-container"},e.createElement("div",{className:"shine-element"})))},$a=({backgroundSubdued:o,themeColor:i,themeTextColor:a,primaryTextColor:l,cartComponentsCornerRadius:c,applyCouponCode:d,removeDiscount:s,enableConfetti:p})=>{const m=M(St),[u,g]=t(""),[x,f]=t(null),[y,h]=t(!1),[b,v]=t(!1),[w,C]=t(!1),{setLoading:E}=Pt(),[k,T]=t(null),[$,S]=t(!1),[B,z]=t(!1),I=r(null);n(()=>{if(k){S(!0);const e=setTimeout(()=>{S(!1)},4e3),t=setTimeout(()=>{T(null)},4500);return()=>{clearTimeout(e),clearTimeout(t)}}S(!1)},[k]),n(()=>{if(m&&m.discount_codes&&x){const e=m.discount_codes.find(e=>e.code===x);e&&(e.applicable?(T({message:"Coupon applied successfully!",type:"success"}),p&&(z(!0),setTimeout(()=>z(!1),5e3))):T({message:"Coupon not applicable",type:"error"}),f(null))}},[m,x]);const N=async()=>{if(d&&u&&!y){T(null),h(!0),f(u);try{await d(u),g("")}catch(e){T({message:"Failed to apply coupon.",type:"error"}),f(null)}finally{h(!1)}}},F=async()=>{if(s&&!w){T(null),C(!0),E&&E(!0,!1,!1,!0);try{await s()}catch(e){T({message:"Failed to remove coupon.",type:"error"})}finally{E&&E(!1,!1,!1,!1),C(!1)}}},P="error"===k?.type,D=m?.discount_codes?.filter(e=>!1!==e?.applicable);return e.createElement("div",{ref:I,style:{marginTop:"10px",padding:"0 16px",marginBottom:"10px"}},B&&p&&e.createElement(Jn,{particleCount:100,spread:160,origin:{y:.6},checkpointPosition:.5}),e.createElement("div",{style:{display:"flex",alignItems:"stretch",border:P?"0.5px solid #FF4E4E":b?`1px solid ${i||"#007bff"}`:"1px solid #e0e0e0",borderRadius:c??4,transition:"border-color 0.5s ease-in-out",overflow:"hidden"}},e.createElement("input",{type:"text",placeholder:"Have a Coupon Code?",value:u,disabled:y,onFocus:()=>{v(!0),setTimeout(()=>{I.current&&window.innerWidth<=768&&I.current.scrollIntoView({behavior:"smooth",block:"nearest"})},300)},onBlur:()=>v(!1),onChange:e=>{g(e.target.value),k&&T(null)},onKeyDown:e=>{"Enter"===e.key&&N()},style:{flexGrow:1,border:"none",padding:"10px",outline:"none",fontSize:"14px",fontWeight:"bold",borderTopLeftRadius:c??4,borderBottomLeftRadius:c??4,backgroundColor:o,color:l,boxShadow:"none",cursor:y?"not-allowed":"auto",margin:"0"}}),e.createElement("button",{onClick:N,disabled:!u||y,style:{padding:"10px 15px",border:"none",backgroundColor:P?"#D98181":u?i||"#007bff":"#cccccc",color:u||P?a||"#ffffff":"#666666",cursor:!u||y?"not-allowed":"pointer",fontSize:"14px",fontWeight:"bold",borderTopRightRadius:c??4,borderBottomRightRadius:c??4,transition:"background-color 0.5s ease-in-out, opacity 0.2s ease-in-out",minWidth:"80px",display:"flex",justifyContent:"center",alignItems:"center",opacity:y?.7:1}},y?e.createElement(Ae,{color:a||"#ffffff",size:18}):"Apply")),k&&e.createElement("div",{style:{color:"success"===k.type?"#28a745":"#dc3545",fontSize:"12px",marginTop:"4px",fontStyle:"italic",transition:"opacity 0.5s ease-in-out, transform 0.5s ease-in-out, max-height 0.5s ease-in-out",opacity:$?1:0,transform:$?"translateY(0)":"translateY(-10px)",maxHeight:$?"50px":"0",overflow:"hidden"}},k.message),D&&D.length>0&&e.createElement("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"}},D.map(t=>e.createElement("div",{key:t.code,style:{display:"flex",alignItems:"center",fontSize:"12px",fontStyle:"italic"}},e.createElement("div",{style:{display:"flex",alignItems:"center",color:"#333333",backgroundColor:o,paddingInlineStart:"6px",gap:"4px"}},e.createElement(Ie,{size:12,color:"#4D4D4D"}),e.createElement("span",{style:{fontWeight:"bold",fontStyle:"normal"}},t.code)," applied!",e.createElement("button",{onClick:F,disabled:w,style:{background:"#E2E2E2",border:"0.5px solid #B5B5B5",cursor:"pointer",marginLeft:"4px",padding:"0",display:"flex",alignItems:"center"}},w?e.createElement(Ae,{color:i||"#007bff",size:14}):e.createElement(J,{size:16})))))))};function Sa({showDiscountOnMRP:i,cartCheckpoints:a,toggleDecimal:l,primaryTextColor:c,discountApplied:d,showPoweredByBadge:s=!0}){const p=M(St),m=Rt(p,p?.currency),[u,g]=t(!1),x=r(null),[f,y]=t("0px"),h=_t(p?.original_total_price,p?.currency),b=o(()=>a?.find(e=>"free_delivery"===e.couponType&&void 0!==e.discountValue),[a]),v=o(()=>!(!b||!b.minimumOrderValue)&&h>=b.minimumOrderValue,[b,h]),w=v&&b&&b.discountValue||0,C=o(()=>{if(!p?.items?.length)return 0;const e=p.items.reduce((e,t)=>e+(i&&t?.compare_at_price&&t?.compare_at_price>t?.original_price?t.compare_at_price:t.original_price)*t.quantity,0);return _t(e,p?.currency)},[p?.items,i]),E=o(()=>v?C+w:C,[v,C,w]),k=o(()=>p?.items?.length?p.items.reduce((e,t)=>t.compare_at_price&&t.compare_at_price>t.original_price?e+(t.compare_at_price-t.original_price)*t.quantity:e,0):0,[p?.items]),T=_t(k,p?.currency??"INR"),$=o(()=>{const e={};return p?.items?.length?(p.items.forEach(t=>{t.discounts&&Array.isArray(t.discounts)&&t.discounts.forEach(t=>{e[t.title]=(e[t.title]||0)+t.amount})}),e):e},[p?.items]),S=o(()=>{const e=[];for(const t in $)if(Object.prototype.hasOwnProperty.call($,t)){const n=$[t],o=_t(n,p?.currency??"INR"),r=Gt(t);e.push({title:r,amount:o})}return e},[$,p?.currency]),B=o(()=>{let e=0;return i&&(e+=T),S.forEach(t=>{e+=t.amount}),v&&(e+=w),e},[T,S,i,v,w]),z=h;n(()=>{x.current&&y(u?`${x.current.scrollHeight}px`:"0px")},[u,S,v]);const I=T>0||d&&S.length>0||v&&w>0;return p?.item_count?e.createElement("div",{className:"yt-cart-subtotal-section-scroll",style:{backgroundColor:"rgba(138, 138, 138, 0.08)",padding:"10px 1rem",marginTop:"8px"}},e.createElement("div",{style:{display:"flex",flexDirection:"column",rowGap:"2px",color:c}},I&&B>0&&e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px"}},"Subtotal"),e.createElement("span",{style:{fontSize:"14px"}},m,qt(v?l?E.toFixed(2):E.toFixed(0):l?C.toFixed(2):C.toFixed(0)))),e.createElement("div",{style:{display:"flex",flexDirection:"column",paddingBottom:"5px"}},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center"}},"Discounts Applied",e.createElement("button",{onClick:()=>{g(!u)},className:"yt-cart-details-button",style:{marginBottom:"0",marginLeft:"5px",background:"none",border:"none",color:"#7E7E7E",cursor:"pointer",fontSize:"12px",fontWeight:"600",textDecoration:"underline",padding:"0 !important",minHeight:"10px !important",boxShadow:"none",minWidth:"fit-content",height:"auto",lineHeight:"normal",marginTop:"0"}},u?"Hide details":"See details")),e.createElement("span",{style:{fontSize:"14px",color:"#D3122A",fontWeight:"600"}},"-",m,qt(l?B.toFixed(2):B.toFixed(0)))),e.createElement("div",{ref:x,style:{height:f,overflow:"hidden",transition:"height 0.3s ease, opacity 0.3s ease",opacity:u?1:0,marginTop:u?"5px":"0",borderTop:u?"1px solid #E5E7EB":"none",paddingTop:u?"5px":"0",fontWeight:"600"}},i&&T>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Discount on MRP"),e.createElement("span",{style:{color:"#D3122A"}},"-",m,qt(l?T.toFixed(2):T.toFixed(0)))),v&&w>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Free Shipping"),e.createElement("span",{style:{color:"#D3122A"}},"-",m,qt(l?w.toFixed(2):w.toFixed(0)))),S.map(t=>e.createElement("div",{key:t.title,style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,t.title),e.createElement("span",{style:{color:"#D3122A"}},"-",m,qt(l?t.amount.toFixed(2):t.amount.toFixed(0))))))),e.createElement("hr",{className:"yt-cart-checkout-divider",style:{height:"1px",margin:"2px 0",backgroundColor:"#E5E7EB",border:"none",maxWidth:"unset"}})),e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"14px",fontWeight:"600"}},"Total"),e.createElement("span",{style:{fontSize:"16px",fontWeight:"var(--yt-cart-font-weight)"}},m,qt(l?z.toFixed(2):z.toFixed(0))))),s&&e.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingBlock:"6px 0"}},e.createElement("img",{src:"https://r2.yourtoken.io/Frame%2038702.png",alt:"Powered by YourToken",style:{height:"auto",width:"340px"}}))):null}const Ba=c.div`
|
|
2205
2205
|
line-height: normal;
|
|
2206
2206
|
position: ${e=>e.$enableCustomCartOnCartPage&&e.$isCartPage?"relative":"fixed"};
|
|
2207
2207
|
top: ${e=>e.$enableCustomCartOnCartPage&&e.$isCartPage?"auto":"0"};
|