yt-uikit 0.7.399 → 0.7.401
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 +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1616,7 +1616,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
1616
1616
|
transition: all 0.2s ease;
|
|
1617
1617
|
letter-spacing: 0.8px;
|
|
1618
1618
|
font-family: 'Poppins';
|
|
1619
|
-
`,_i=({freebieProductsInCart:e,themeColor:n,themeTextColor:r,primaryTextColor:a,addFreebieToCart:
|
|
1619
|
+
`,_i=({freebieProductsInCart:e,themeColor:n,themeTextColor:r,primaryTextColor:a,addFreebieToCart:d,freebiesInCart:s,imageAspectSelector:p,freebieCouponTemplates:u,maxFreebiesInTier:m=1,tierName:f="Freebie",freebieClaimData:g,shouldCheckInventoryQuantity:h})=>{const[x,y]=c(0),[b,v]=c(0),[w,C]=c([]),[k,E]=c(!1),[T,S]=c(!1),$=o(null),B=o(null),z=o(null),D=o(!1),I=m>1,_=w.length,O=w.length>=m,A=`${_}/${m} selected`,F=_===m&&_>0,R=g?.freebieSectionTitle,L=g?.productClaimCtaButtonText,j=i((()=>e?.length?e.filter((e=>(e?.variants?.edges||[]).some((e=>!h||e?.node?.inventoryQuantity>0)))):[]),[e,h]);l((()=>{C((e=>e.filter((e=>j.some((t=>String(t?.id)===e))))))}),[j]);l((()=>{if($.current){const e=$.current.offsetWidth,t=window.innerWidth<=768;v(t?Math.min(.95*e,280):Math.min(.8*e,320))}}),[j.length]);const V=Math.max(0,(j.length||0)-1);l((()=>{x>V&&y(V)}),[V,x]);const H=()=>{y((e=>0===e?V:e-1))},W=()=>{y((e=>e===V?0:e+1))};return 0===j.length?null:t.createElement("div",{style:{display:"flex",flexDirection:"column",marginTop:"5px"}},t.createElement(Ti,{onClick:()=>E((e=>!e))},t.createElement(Si,{$primaryTextColor:a},t.createElement($i,{$isCollapsed:k},t.createElement(M,{size:16})),R??"Freebies",I&&!F&&` • ${A}`),t.createElement(Bi,null)),t.createElement(zi,{$isCollapsed:k},t.createElement(yi,{ref:$,onTouchStart:e=>{const t=e.touches[0];B.current=t.clientX,z.current=t.clientY,D.current=!1},onTouchMove:e=>{if(null===B.current||null===z.current)return;const t=e.touches[0],n=t.clientX-B.current,r=t.clientY-z.current;Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(D.current=!0,e.preventDefault())},onTouchEnd:e=>{if(null===B.current)return;const t=e.changedTouches[0].clientX-B.current;Math.abs(t)>50&&(t<0?W():H()),B.current=null,z.current=null,D.current=!1}},j.length>1&&t.createElement(ki,{onClick:H},t.createElement(N,{size:30,color:"#4D4D4D",className:"yt-freebie-carousel-icon"})),t.createElement(vi,{position:"left",style:{display:"flex"}}),t.createElement(vi,{position:"right",style:{display:"flex"}}),t.createElement(bi,{$cardWidth:b},t.createElement(wi,{$translate:x*(b+10)},j.map(((e,o)=>t.createElement("div",{key:`${e?.id}-${w.includes(String(e.id))?"selected":"unselected"}`,style:{width:`${b}px`,flexShrink:0}},t.createElement(hi,{addFreebieToCart:d,product:e,themeColor:n,themeTextColor:r,productClaimCtaButtonText:L,imageAspectSelector:p,freebieCouponTemplates:u,isMultiClaim:I,isSelected:w.includes(String(e.id)),isDisabled:I&&!w.includes(String(e.id))&&O,shouldCheckInventoryQuantity:h,onToggleSelection:I?e=>{C((t=>{const n=String(e);if(t.includes(n))return t.filter((e=>e!==n));if(t.length<m){return t.length+1<m&&setTimeout((()=>{W()}),600),[...t,n]}return t}))}:void 0})))))),j.length>1&&t.createElement(Ei,{onClick:W},t.createElement(P,{size:30,color:"#4D4D4D",className:"yt-freebie-carousel-icon"})))),I&&F&&t.createElement(Di,null,t.createElement(Ii,{$themeColor:n,$themeTextColor:r,$disabled:T,onClick:async()=>{if(d&&0!==w.length&&!T){S(!0);try{await xi(w,e,d),C([])}catch(e){console.error("Failed to claim gifts:",e)}finally{S(!1)}}},disabled:T},T?"Adding to Cart...":`${L} • ${_}/${m} added`)))};function Oi(e){return _({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M14 0h-12c-1.1 0-2 0.9-2 2v12c0 1.1 0.9 2 2 2h12c1.1 0 2-0.9 2-2v-12c0-1.1-0.9-2-2-2zM7 12.414l-3.707-3.707 1.414-1.414 2.293 2.293 4.793-4.793 1.414 1.414-6.207 6.207z"},child:[]}]})(e)}function Ni(e){return _({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M14 0h-12c-1.1 0-2 0.9-2 2v12c0 1.1 0.9 2 2 2h12c1.1 0 2-0.9 2-2v-12c0-1.1-0.9-2-2-2zM14 14h-12v-12h12v12z"},child:[]}]})(e)}const Pi="yt-multiclaim-selection",Ai=e=>{try{if("undefined"==typeof window||!window.sessionStorage)return;sessionStorage.setItem(Pi,JSON.stringify(e))}catch{}},Fi=_t((()=>{try{if("undefined"==typeof window||!window.sessionStorage)return null;const e=sessionStorage.getItem(Pi);return e?JSON.parse(e):null}catch{return null}})()??{selectedProducts:[],maxAllowed:1,tierName:""}),Mi=_t((e=>{const t=e(Fi);return t.selectedProducts.length>=t.maxAllowed})),Ri=_t((e=>e(Fi).selectedProducts.length)),Li=_t(null,((e,t,n)=>{const r=e(Fi);let o;if(r.selectedProducts.includes(n))o={...r,selectedProducts:r.selectedProducts.filter((e=>e!==n))};else{if(!(r.selectedProducts.length<r.maxAllowed))return;o={...r,selectedProducts:[...r.selectedProducts,n]}}t(Fi,o),Ai(o)})),ji=_t(null,((e,t)=>{const n={...e(Fi),selectedProducts:[]};t(Fi,n),Ai(n)})),Vi=_t(null,((e,t,n,r)=>{const o={selectedProducts:[],maxAllowed:n,tierName:r};t(Fi,o),Ai(o)})),Hi=x.div`
|
|
1620
1620
|
display: flex;
|
|
1621
1621
|
flex-direction: row;
|
|
1622
1622
|
align-items: center;
|
|
@@ -2152,7 +2152,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
2152
2152
|
display: flex !important;
|
|
2153
2153
|
align-items: center !important;
|
|
2154
2154
|
column-gap: 3px !important;
|
|
2155
|
-
`,mp=({loyaltyIcon:e,backgroundSubdued:n,primaryTextColor:r,pointsRewardRate:o,rewardMultiplier:a})=>{const i=Wt(Gt),l=.01*o*sn(i?.items_subtotal_price,i?.currency),c="number"==typeof a&&a>0?l*a:l;return t.createElement("div",{style:{paddingTop:"10px",paddingBottom:"5px",justifyContent:"center",display:"flex",fontSize:"11px",alignItems:"center",margin:"0px 1rem 5px",borderBottomLeftRadius:"10px",borderBottomRightRadius:"10px",border:"0.2px solid #00000040",borderTop:"none",transform:"translateY(-5px)",background:n??"#9090901F",color:r??"#000000"}},t.createElement(up,null,"you earn"," ",t.createElement("img",{style:{alignSelf:"center"},src:e,height:"18px",width:"18px"})," ",t.createElement("span",{style:{fontWeight:600}},c.toFixed(2)," points")," ","on this order"))},fp=x.span`
|
|
2155
|
+
`,mp=({loyaltyIcon:e,backgroundSubdued:n,primaryTextColor:r,pointsRewardRate:o,rewardMultiplier:a})=>{const i=Wt(Gt),l=.01*o*sn(i?.items_subtotal_price,i?.currency),c="number"==typeof a&&a>0?l*a:l;return t.createElement("div",{style:{paddingTop:"10px",paddingBottom:"5px",justifyContent:"center",display:"flex",fontSize:"11px",alignItems:"center",margin:"0px 1rem 5px",borderBottomLeftRadius:"10px",borderBottomRightRadius:"10px",border:"0.2px solid #00000040",borderTop:"none",transform:"translateY(-5px)",background:n??"#9090901F",color:r??"#000000"}},t.createElement(up,null,"you earn"," ",t.createElement("img",{style:{alignSelf:"center",height:"18px",width:"18px"},src:e,height:"18px",width:"18px"})," ",t.createElement("span",{style:{fontWeight:600}},c.toFixed(2)," points")," ","on this order"))},fp=x.span`
|
|
2156
2156
|
position: relative;
|
|
2157
2157
|
overflow: hidden;
|
|
2158
2158
|
border-radius: 9999px;
|