yt-uikit 0.9.2 → 0.9.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.
@@ -92,10 +92,10 @@ export interface CartProps {
92
92
  switchWidthVariant?: boolean;
93
93
  addCartItem?: (product: any, quantity?: number, triggeredFrom?: string, freebieReplace?: boolean, productHandle?: string) => Promise<any>;
94
94
  removeCartItem: (lineItemKey: string, triggeredFrom?: string, ytRequest?: boolean) => Promise<any>;
95
- handleIncrement: (productId: number, newQuantity: number, properties?: {
95
+ handleIncrement: (lineItemKey: string | number, newQuantity: number, properties?: {
96
96
  [key: string]: string;
97
97
  }) => Promise<any>;
98
- handleDecrement: (productId: number, newQuantity?: number) => Promise<any>;
98
+ handleDecrement: (lineItemKey: string | number, newQuantity?: number) => Promise<any>;
99
99
  bundleProducts?: any;
100
100
  showBundle?: boolean;
101
101
  isUserSignedIn?: boolean;
@@ -4,10 +4,10 @@ import { freebieMilestoneProps } from "./NextFreebieRow";
4
4
  type CartProductsListProps = {
5
5
  addCartItem?: (product: any, quantity?: number, triggeredFrom?: string) => Promise<any>;
6
6
  removeCartItem: (product: any) => Promise<any>;
7
- handleIncrement: (productId: number, newQuantity: number, properties?: {
7
+ handleIncrement: (lineItemKey: string | number, newQuantity: number, properties?: {
8
8
  [key: string]: string;
9
9
  }) => Promise<any>;
10
- handleDecrement: (productId: number) => Promise<any>;
10
+ handleDecrement: (lineItemKey: string | number, newQuantity?: number) => Promise<any>;
11
11
  isDev?: boolean;
12
12
  themeColor?: string;
13
13
  primaryTextColor?: string;
@@ -3,10 +3,10 @@ declare const ProductCard: ({ product: variant, handleDecrement, handleIncrement
3
3
  product: any;
4
4
  addCartItem?: ((product: any) => Promise<any>) | undefined;
5
5
  removeCartItem?: ((product: any) => Promise<any>) | undefined;
6
- handleIncrement?: ((productId: number, newQuantity: number, properties?: {
6
+ handleIncrement?: ((lineItemKey: string | number, newQuantity: number, properties?: {
7
7
  [key: string]: string;
8
8
  } | undefined) => Promise<any>) | undefined;
9
- handleDecrement?: ((productId: number, newQuantity?: number) => Promise<any>) | undefined;
9
+ handleDecrement?: ((lineItemKey: string | number, newQuantity?: number) => Promise<any>) | undefined;
10
10
  isDev?: boolean | undefined;
11
11
  themeColor?: string | undefined;
12
12
  primaryTextColor?: string | undefined;
package/dist/esm/index.js CHANGED
@@ -1352,7 +1352,7 @@ import e,{useState as t,useEffect as n,useMemo as o,useRef as r,useCallback as i
1352
1352
  padding: 2px 0px 4px 0px;
1353
1353
  border-bottom-left-radius: 8px;
1354
1354
  border-bottom-right-radius: 8px;
1355
- `,Br=({imageUrl:t,overlayText:n,themeColor:o,themeTextColor:r})=>e.createElement("div",{style:{position:"relative",width:"100%",height:"100%"}},e.createElement("img",{src:t,alt:"Free Gift",style:{width:"100%",height:"100%",objectFit:"fill",borderRadius:"8px"}}),e.createElement($r,{className:"yt-cart-product-freebie-overlay-text",$themeColor:o,$themeTextColor:r},n)),zr=({product:o,handleDecrement:i,handleIncrement:a,removeCartItem:l,addCartItem:c,isDev:s,themeColor:d,primaryTextColor:p,secondaryTextColor:u,tertiaryColor:m,tertiaryTextColor:g,showQtySelector:x=!0,themeTextColor:f,showEditOptionOnProducts:y,percentageOff:b,removeFreebieFromCart:h,showDeleteOnFreebies:v,imageAspectSelector:w,cartComponentsCornerType:C,cartComponentsCornerRadius:E,backgroundSubdued:k,backgroundColor:T,showDiscountOnMRP:S,freeLabelText:$})=>{const{setLoading:B}=Jt(),z=ae(Ut),[N,I]=ie(Jo),[F,D]=t(!1),P=le(en),A=ir(),_=!!o.properties?._isYtFreebie,L=!!o.properties?._isStealDeal,M=_&&"number"==typeof o.final_line_price&&o.final_line_price>0&&"number"==typeof o.original_line_price&&o.original_line_price>o.final_line_price;n(()=>{function e(){const e=window.innerWidth;D(e>=450)}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);const j=r(null),[V,W]=t(0);n(()=>{let e=null;return j.current&&(e=new ResizeObserver(e=>{e[0]&&W(e[0].contentRect.width)}),e.observe(j.current)),()=>{e&&e.disconnect()}},[]),n(()=>{const e=setTimeout(()=>{j.current&&W(j.current.offsetWidth)},100);return()=>clearTimeout(e)},[]);const H=an(o.product_title,V<200?100:120,V,"","16px"),q=()=>{if(o.line_level_discount_allocations&&o.line_level_discount_allocations.length>0&&o.line_level_discount_allocations[0].discount_application){const e=o.line_level_discount_allocations[0].discount_application.title,t=xn(e);switch(o.line_level_discount_allocations[0].discount_application.value_type){case"amount":return`${t})`;case"percentage":case"fixed_amount":return t;default:return""}}};let Q=on(z,z?.currency);const U=["__Added with Frequently Bought Together button","_has_gpo","_y"],Y=o?.options_with_values&&o.options_with_values.filter(e=>"Title"!==e.name).length>0||o?.properties&&Object.keys(o.properties).filter(e=>!U.includes(e)&&!e.startsWith("_")&&!e.startsWith("__")).length>0||y,G=V?70/V*100:100,X=q(),Z=X&&(X.length>25||!F)?an(X,G,V,"","10px"):X,K=(()=>{const e=o?.properties?._bundleImage;if(!e||"string"!=typeof e)return;const t=e.trim();return t.length>0?t:void 0})(),J=!!K,ne=(()=>{const e=o?.properties?.itemsInBundle;return"string"!=typeof e?[]:e.split(/,\s*/).map(e=>e.trim()).filter(e=>e.length>0)})(),oe=(()=>{const e=o?.properties?._bundleItems;if("string"==typeof e&&e.trim().length>0)try{const t=JSON.parse(e);if(Array.isArray(t)){const e=t.reduce((e,t)=>{const n=Number(t?.quantity);return e+(isNaN(n)?0:n)},0);if(e>0)return e}}catch(e){}let t=0;for(const e of ne){const n=e.match(/^(\d+)\s*x\s*/i);t+=n?parseInt(n[1],10)||0:1}return t})(),re=(()=>{try{const e=Number(o?.compare_at_price),t=Number(o?.quantity)||1;if(Number.isFinite(e)&&e>0)return e*t}catch(e){}return null})(),[ce,se]=t(!0),de=F?"250px":"190px";return e.createElement(ur,{className:"yt-cart-product-card",$hasVariantInfo:Y||J,$backgroundColor:T,style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"0 1rem"}},e.createElement("a",{href:`${window.location.origin}${o.url}`,style:{textDecoration:"none",display:"contents"}},e.createElement(gr,{className:"yt-cart-product-image-wrapper",$isBundle:J},e.createElement(mr,{className:"yt-cart-product-image",$imageAspectSelector:w,$isBundle:J},x?e.createElement("img",{style:{height:"100%",width:"100%",opacity:0===o.quantity?.5:1},src:gn(K??o.image,200,85,"webp"),alt:(e=>e.title?`Product image - ${e.title}`:"Product image")(o),loading:"lazy"}):e.createElement(Br,{imageUrl:gn(K??o.image??o?.featuredImage?.url??"/placeholder.svg",200,85,"webp"),overlayText:L?"Steal Deal":M||b?"Special Offer":"Free Gift",themeColor:d,themeTextColor:f})),(x||o?.quantity>1)&&e.createElement(xr,{className:"yt-cart-product-quantity-badge"},o.quantity))),e.createElement("div",{className:"yt-cart-product-details",style:{display:"flex",flexDirection:"column",flex:1,padding:"4px 0"}},e.createElement("div",{className:"yt-cart-product-header",style:{display:"flex",flexDirection:"row",alignItems:"flex-start"}},e.createElement(pr,{className:"yt-cart-product-title",$themeColor:d,$primaryTextColor:p,href:`${window.location.origin}${o.url}`,ref:j},H),e.createElement("div",{className:"yt-cart-product-actions",style:{marginLeft:"auto",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("div",{style:{marginLeft:"3px",display:"flex",alignItems:"center",justifyContent:"center"}},(x||v)&&e.createElement(br,{onClick:x?async()=>{B&&B(!0,!0);try{l&&await l(o.key)}catch(e){}B&&B(!1,!1)}:async()=>{B&&B(!0,!0);try{h&&await h(o.key)}catch(e){}B&&B(!1,!1)}},e.createElement(fr,null,e.createElement(ee,{className:"outline"}),e.createElement(te,{className:"filled"})))))),J?e.createElement("div",{className:"yt-cart-product-bundle-info",style:{display:"flex",flexDirection:"column",marginBottom:"4px"}},e.createElement("div",{className:"yt-cart-product-bundle-toggle",role:"button",onClick:()=>se(!ce),style:{display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"#F8F9FA",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.1)",padding:"4px 6px",width:"fit-content",cursor:"pointer",userSelect:"none",fontSize:"12px",fontWeight:600,color:u??"#1a1a1a"}},e.createElement("span",null,`Contain ${oe} Items`),ce?e.createElement(R,null):e.createElement(O,null)),ce&&ne.length>0&&e.createElement("div",{style:{marginTop:"4px",backgroundColor:"#F8F9FA",borderRadius:"8px",padding:"8px 10px",border:"1px solid rgba(0,0,0,0.06)",maxWidth:de,width:"fit-content"}},e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"4px",maxWidth:de}},ne.map((t,n)=>e.createElement("div",{key:`${t}-${n}`,style:{color:u??"#1a1a1a",fontSize:"12px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:de},title:t},t))))):Y&&e.createElement("div",{className:"yt-cart-product-variant-info",style:{display:"flex",flexDirection:"column",marginBottom:"4px"}},e.createElement(ar,{className:"yt-cart-product-variant-container"},o?.options_with_values?.filter(e=>"Title"!==e.name).map(t=>{const n=A?.options?.find(e=>e.name.trim().toLowerCase()===t.name.trim().toLowerCase()),o=rr(n,t.value);return"color"===n?.type?.toLowerCase()&&o?e.createElement(lr,{key:t.name,$colorValue:o.value,style:{display:"block"}}):"image"===n?.type?.toLowerCase()&&o?e.createElement(cr,{key:t.name,src:gn(o.value,36,85,"webp"),alt:t.value}):t.value.length>15||t.value.includes("#")?null:e.createElement(yr,{className:"yt-cart-variant-text",key:t.name,$secondaryTextColor:u,style:{display:"flex",alignItems:"center",borderRadius:"6px",border:"1px solid rgb(117 117 117 / 50%)",padding:"1px 3px"}},t.value)}),o?.properties&&Object.entries(o.properties).filter(([e])=>!U.includes(e)&&!e.startsWith("_")&&!e.startsWith("__")).map(([t,n])=>{const o=String(n);return o.includes("#")||(A?.options??[]).some(e=>e.name.trim().toLowerCase()===t.trim().toLowerCase()&&e.values.some(e=>e.name.trim().toLowerCase()===o.trim().toLowerCase()))?null:e.createElement(yr,{key:t,$secondaryTextColor:u,style:{display:"flex",alignItems:"center",backgroundColor:"#F8F9FA",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.1)",padding:"1px 3px"}},o)}),y&&!o?.product_has_only_default_variant&&e.createElement(br,{onClick:()=>{const e=!!o.properties?._isYtFreebie;let t;if(e){const e=o.properties?._yt_allowed_variants;if(e&&"string"==typeof e)try{t=JSON.parse(e)}catch(n){console.error(`ProductCard: Failed to parse _yt_allowed_variants for ${o.key}:`,e,n),t=[String(o.variant_id)]}else console.warn(`ProductCard: No allowed variants property found for freebie ${o.key}. Defaulting to current variant.`),t=[String(o.variant_id)]}P({open:!0,variantId:String(o.variant_id),quantity:o.quantity,handle:o.handle,lineItemKey:o.key,freebieSelection:e,productId:String(o.product_id),allowedVariantIds:t})},style:{display:"flex",alignItems:"center"}},e.createElement(Ie,null))),o?.options_with_values?.filter(e=>"Title"!==e.name&&e.value.length>15).map(t=>{const n=A?.options?.find(e=>e.name.trim().toLowerCase()===t.name.trim().toLowerCase());if(rr(n,t.value)&&["color","image"].includes((n?.type??"").toLowerCase()))return null;if(t.value.includes("#"))return null;const o=F?t.value:an(t.value,V?120/V*100:100,V,"","10px");return e.createElement(yr,{key:t.name,$secondaryTextColor:u,style:{display:"flex",alignItems:"center",backgroundColor:"#F8F9FA",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.1)",padding:"1px 3px",width:"fit-content"}},o)})),e.createElement(hr,{className:"yt-cart-product-bottom-row"},e.createElement("div",{className:"yt-cart-product-pricing-row",style:{display:"flex",flexDirection:F?"row":"column",alignItems:F?"center":"flex-start",gap:F?"0px":"4px"}},e.createElement(vr,{className:"yt-cart-product-price-container"},J?e.createElement(e.Fragment,null,e.createElement(wr,{$primaryTextColor:p},Q,un(tn(o.final_line_price,z?.currency))),re&&re>Number(o.final_line_price)&&S&&e.createElement(Cr,null,Q,un(tn(re,z?.currency)))):e.createElement(wr,{$primaryTextColor:p},0===tn(o.final_line_price,z?.currency)?e.createElement(Sr,{$primaryColor:p,$themeColor:d,$backgroundSubdued:k},$||"FREE"):e.createElement(e.Fragment,null,Q,un(tn(o.final_line_price,z?.currency)))),!J&&(o.compare_at_price&&Number(o.compare_at_price)*o.quantity>Number(o.final_line_price)||!o.compare_at_price&&q()&&o.original_line_price)&&S&&e.createElement(Cr,null,Q,o.compare_at_price?un(tn(Number(o.compare_at_price)*o.quantity,z?.currency)):un(tn(o.original_line_price,z?.currency))),F&&(x||M)&&q()&&e.createElement(kr,{className:"yt-cart-product-discount",$tertiaryColor:m},e.createElement(Te,{size:14,color:g}),e.createElement(Tr,{$tertiaryTextColor:g},Z))),!F&&(x||M)&&q()&&e.createElement(kr,{className:"yt-cart-product-discount",$tertiaryColor:m},e.createElement(Te,{size:12,color:g}),e.createElement(Tr,{$tertiaryTextColor:g},Z))),e.createElement(Er,{className:"yt-cart-product-quantity-controls"},x?e.createElement(Ko,{handleItemQuantityDecrement:async()=>{B&&B(!0,!0);try{i&&await i(o.key,o.quantity-1)}catch(e){}B&&B(!1,!1)},handleItemQuantityIncrement:async()=>{B&&B(!0,!0);try{if(a){-1===await a(o.id,o.quantity+1,o.properties)&&(I(o?.key),setTimeout(()=>I(void 0),3e3))}}catch(e){}B&&B(!1,!1)},value:o.quantity,isDev:s,themeColor:d,cartComponentsCornerType:C,cartComponentsCornerRadius:E,backgroundSubdued:k}):!L||M||b?e.createElement("span",{className:"yt-cart-line-item-freebie-badge",style:{padding:"2px 8px",fontSize:"10px",backgroundColor:m,color:g??"#000",borderRadius:"4px"}},M&&o.original_line_price?`${((o.original_line_price-o.final_line_price)/o.original_line_price*100).toFixed(0)}% off`:b&&o?.properties?._isYtFreebie?`${b}% Off`:"Freebie"):null)),N&&N===o?.key&&e.createElement("span",{style:{fontSize:"10px",color:"red",marginTop:"4px"}},"⚠️You've reached the maximum quantity for this item")))},Nr=c.div`
1355
+ `,Br=({imageUrl:t,overlayText:n,themeColor:o,themeTextColor:r})=>e.createElement("div",{style:{position:"relative",width:"100%",height:"100%"}},e.createElement("img",{src:t,alt:"Free Gift",style:{width:"100%",height:"100%",objectFit:"fill",borderRadius:"8px"}}),e.createElement($r,{className:"yt-cart-product-freebie-overlay-text",$themeColor:o,$themeTextColor:r},n)),zr=({product:o,handleDecrement:i,handleIncrement:a,removeCartItem:l,addCartItem:c,isDev:s,themeColor:d,primaryTextColor:p,secondaryTextColor:u,tertiaryColor:m,tertiaryTextColor:g,showQtySelector:x=!0,themeTextColor:f,showEditOptionOnProducts:y,percentageOff:b,removeFreebieFromCart:h,showDeleteOnFreebies:v,imageAspectSelector:w,cartComponentsCornerType:C,cartComponentsCornerRadius:E,backgroundSubdued:k,backgroundColor:T,showDiscountOnMRP:S,freeLabelText:$})=>{const{setLoading:B}=Jt(),z=ae(Ut),[N,I]=ie(Jo),[F,D]=t(!1),P=le(en),A=ir(),_=!!o.properties?._isYtFreebie,L=!!o.properties?._isStealDeal,M=_&&"number"==typeof o.final_line_price&&o.final_line_price>0&&"number"==typeof o.original_line_price&&o.original_line_price>o.final_line_price;n(()=>{function e(){const e=window.innerWidth;D(e>=450)}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);const j=r(null),[V,W]=t(0);n(()=>{let e=null;return j.current&&(e=new ResizeObserver(e=>{e[0]&&W(e[0].contentRect.width)}),e.observe(j.current)),()=>{e&&e.disconnect()}},[]),n(()=>{const e=setTimeout(()=>{j.current&&W(j.current.offsetWidth)},100);return()=>clearTimeout(e)},[]);const H=an(o.product_title,V<200?100:120,V,"","16px"),q=()=>{if(o.line_level_discount_allocations&&o.line_level_discount_allocations.length>0&&o.line_level_discount_allocations[0].discount_application){const e=o.line_level_discount_allocations[0].discount_application.title,t=xn(e);switch(o.line_level_discount_allocations[0].discount_application.value_type){case"amount":return`${t})`;case"percentage":case"fixed_amount":return t;default:return""}}};let Q=on(z,z?.currency);const U=["__Added with Frequently Bought Together button","_has_gpo","_y"],Y=o?.options_with_values&&o.options_with_values.filter(e=>"Title"!==e.name).length>0||o?.properties&&Object.keys(o.properties).filter(e=>!U.includes(e)&&!e.startsWith("_")&&!e.startsWith("__")).length>0||y,G=V?70/V*100:100,X=q(),Z=X&&(X.length>25||!F)?an(X,G,V,"","10px"):X,K=(()=>{const e=o?.properties?._bundleImage;if(!e||"string"!=typeof e)return;const t=e.trim();return t.length>0?t:void 0})(),J=!!K,ne=(()=>{const e=o?.properties?.itemsInBundle;return"string"!=typeof e?[]:e.split(/,\s*/).map(e=>e.trim()).filter(e=>e.length>0)})(),oe=(()=>{const e=o?.properties?._bundleItems;if("string"==typeof e&&e.trim().length>0)try{const t=JSON.parse(e);if(Array.isArray(t)){const e=t.reduce((e,t)=>{const n=Number(t?.quantity);return e+(isNaN(n)?0:n)},0);if(e>0)return e}}catch(e){}let t=0;for(const e of ne){const n=e.match(/^(\d+)\s*x\s*/i);t+=n?parseInt(n[1],10)||0:1}return t})(),re=(()=>{try{const e=Number(o?.compare_at_price),t=Number(o?.quantity)||1;if(Number.isFinite(e)&&e>0)return e*t}catch(e){}return null})(),[ce,se]=t(!0),de=F?"250px":"190px";return e.createElement(ur,{className:"yt-cart-product-card",$hasVariantInfo:Y||J,$backgroundColor:T,style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"0 1rem"}},e.createElement("a",{href:`${window.location.origin}${o.url}`,style:{textDecoration:"none",display:"contents"}},e.createElement(gr,{className:"yt-cart-product-image-wrapper",$isBundle:J},e.createElement(mr,{className:"yt-cart-product-image",$imageAspectSelector:w,$isBundle:J},x?e.createElement("img",{style:{height:"100%",width:"100%",opacity:0===o.quantity?.5:1},src:gn(K??o.image,200,85,"webp"),alt:(e=>e.title?`Product image - ${e.title}`:"Product image")(o),loading:"lazy"}):e.createElement(Br,{imageUrl:gn(K??o.image??o?.featuredImage?.url??"/placeholder.svg",200,85,"webp"),overlayText:L?"Steal Deal":M||b?"Special Offer":"Free Gift",themeColor:d,themeTextColor:f})),(x||o?.quantity>1)&&e.createElement(xr,{className:"yt-cart-product-quantity-badge"},o.quantity))),e.createElement("div",{className:"yt-cart-product-details",style:{display:"flex",flexDirection:"column",flex:1,padding:"4px 0"}},e.createElement("div",{className:"yt-cart-product-header",style:{display:"flex",flexDirection:"row",alignItems:"flex-start"}},e.createElement(pr,{className:"yt-cart-product-title",$themeColor:d,$primaryTextColor:p,href:`${window.location.origin}${o.url}`,ref:j},H),e.createElement("div",{className:"yt-cart-product-actions",style:{marginLeft:"auto",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("div",{style:{marginLeft:"3px",display:"flex",alignItems:"center",justifyContent:"center"}},(x||v)&&e.createElement(br,{onClick:x?async()=>{B&&B(!0,!0);try{l&&await l(o.key)}catch(e){}B&&B(!1,!1)}:async()=>{B&&B(!0,!0);try{h&&await h(o.key)}catch(e){}B&&B(!1,!1)}},e.createElement(fr,null,e.createElement(ee,{className:"outline"}),e.createElement(te,{className:"filled"})))))),J?e.createElement("div",{className:"yt-cart-product-bundle-info",style:{display:"flex",flexDirection:"column",marginBottom:"4px"}},e.createElement("div",{className:"yt-cart-product-bundle-toggle",role:"button",onClick:()=>se(!ce),style:{display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"#F8F9FA",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.1)",padding:"4px 6px",width:"fit-content",cursor:"pointer",userSelect:"none",fontSize:"12px",fontWeight:600,color:u??"#1a1a1a"}},e.createElement("span",null,`Contain ${oe} Items`),ce?e.createElement(R,null):e.createElement(O,null)),ce&&ne.length>0&&e.createElement("div",{style:{marginTop:"4px",backgroundColor:"#F8F9FA",borderRadius:"8px",padding:"8px 10px",border:"1px solid rgba(0,0,0,0.06)",maxWidth:de,width:"fit-content"}},e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"4px",maxWidth:de}},ne.map((t,n)=>e.createElement("div",{key:`${t}-${n}`,style:{color:u??"#1a1a1a",fontSize:"12px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:de},title:t},t))))):Y&&e.createElement("div",{className:"yt-cart-product-variant-info",style:{display:"flex",flexDirection:"column",marginBottom:"4px"}},e.createElement(ar,{className:"yt-cart-product-variant-container"},o?.options_with_values?.filter(e=>"Title"!==e.name).map(t=>{const n=A?.options?.find(e=>e.name.trim().toLowerCase()===t.name.trim().toLowerCase()),o=rr(n,t.value);return"color"===n?.type?.toLowerCase()&&o?e.createElement(lr,{key:t.name,$colorValue:o.value,style:{display:"block"}}):"image"===n?.type?.toLowerCase()&&o?e.createElement(cr,{key:t.name,src:gn(o.value,36,85,"webp"),alt:t.value}):t.value.length>15||t.value.includes("#")?null:e.createElement(yr,{className:"yt-cart-variant-text",key:t.name,$secondaryTextColor:u,style:{display:"flex",alignItems:"center",borderRadius:"6px",border:"1px solid rgb(117 117 117 / 50%)",padding:"1px 3px"}},t.value)}),o?.properties&&Object.entries(o.properties).filter(([e])=>!U.includes(e)&&!e.startsWith("_")&&!e.startsWith("__")).map(([t,n])=>{const o=String(n);return o.includes("#")||(A?.options??[]).some(e=>e.name.trim().toLowerCase()===t.trim().toLowerCase()&&e.values.some(e=>e.name.trim().toLowerCase()===o.trim().toLowerCase()))?null:e.createElement(yr,{key:t,$secondaryTextColor:u,style:{display:"flex",alignItems:"center",backgroundColor:"#F8F9FA",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.1)",padding:"1px 3px"}},o)}),y&&!o?.product_has_only_default_variant&&e.createElement(br,{onClick:()=>{const e=!!o.properties?._isYtFreebie;let t;if(e){const e=o.properties?._yt_allowed_variants;if(e&&"string"==typeof e)try{t=JSON.parse(e)}catch(n){console.error(`ProductCard: Failed to parse _yt_allowed_variants for ${o.key}:`,e,n),t=[String(o.variant_id)]}else console.warn(`ProductCard: No allowed variants property found for freebie ${o.key}. Defaulting to current variant.`),t=[String(o.variant_id)]}P({open:!0,variantId:String(o.variant_id),quantity:o.quantity,handle:o.handle,lineItemKey:o.key,freebieSelection:e,productId:String(o.product_id),allowedVariantIds:t})},style:{display:"flex",alignItems:"center"}},e.createElement(Ie,null))),o?.options_with_values?.filter(e=>"Title"!==e.name&&e.value.length>15).map(t=>{const n=A?.options?.find(e=>e.name.trim().toLowerCase()===t.name.trim().toLowerCase());if(rr(n,t.value)&&["color","image"].includes((n?.type??"").toLowerCase()))return null;if(t.value.includes("#"))return null;const o=F?t.value:an(t.value,V?120/V*100:100,V,"","10px");return e.createElement(yr,{key:t.name,$secondaryTextColor:u,style:{display:"flex",alignItems:"center",backgroundColor:"#F8F9FA",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.1)",padding:"1px 3px",width:"fit-content"}},o)})),e.createElement(hr,{className:"yt-cart-product-bottom-row"},e.createElement("div",{className:"yt-cart-product-pricing-row",style:{display:"flex",flexDirection:F?"row":"column",alignItems:F?"center":"flex-start",gap:F?"0px":"4px"}},e.createElement(vr,{className:"yt-cart-product-price-container"},J?e.createElement(e.Fragment,null,e.createElement(wr,{$primaryTextColor:p},Q,un(tn(o.final_line_price,z?.currency))),re&&re>Number(o.final_line_price)&&S&&e.createElement(Cr,null,Q,un(tn(re,z?.currency)))):e.createElement(wr,{$primaryTextColor:p},0===tn(o.final_line_price,z?.currency)?e.createElement(Sr,{$primaryColor:p,$themeColor:d,$backgroundSubdued:k},$||"FREE"):e.createElement(e.Fragment,null,Q,un(tn(o.final_line_price,z?.currency)))),!J&&(o.compare_at_price&&Number(o.compare_at_price)*o.quantity>Number(o.final_line_price)||!o.compare_at_price&&q()&&o.original_line_price)&&S&&e.createElement(Cr,null,Q,o.compare_at_price?un(tn(Number(o.compare_at_price)*o.quantity,z?.currency)):un(tn(o.original_line_price,z?.currency))),F&&(x||M)&&q()&&e.createElement(kr,{className:"yt-cart-product-discount",$tertiaryColor:m},e.createElement(Te,{size:14,color:g}),e.createElement(Tr,{$tertiaryTextColor:g},Z))),!F&&(x||M)&&q()&&e.createElement(kr,{className:"yt-cart-product-discount",$tertiaryColor:m},e.createElement(Te,{size:12,color:g}),e.createElement(Tr,{$tertiaryTextColor:g},Z))),e.createElement(Er,{className:"yt-cart-product-quantity-controls"},x?e.createElement(Ko,{handleItemQuantityDecrement:async()=>{B&&B(!0,!0);try{i&&await i(o.key,o.quantity-1)}catch(e){}B&&B(!1,!1)},handleItemQuantityIncrement:async()=>{B&&B(!0,!0);try{if(a){-1===await a(o.key,o.quantity+1,o.properties)&&(I(o?.key),setTimeout(()=>I(void 0),3e3))}}catch(e){}B&&B(!1,!1)},value:o.quantity,isDev:s,themeColor:d,cartComponentsCornerType:C,cartComponentsCornerRadius:E,backgroundSubdued:k}):!L||M||b?e.createElement("span",{className:"yt-cart-line-item-freebie-badge",style:{padding:"2px 8px",fontSize:"10px",backgroundColor:m,color:g??"#000",borderRadius:"4px"}},M&&o.original_line_price?`${((o.original_line_price-o.final_line_price)/o.original_line_price*100).toFixed(0)}% off`:b&&o?.properties?._isYtFreebie?`${b}% Off`:"Freebie"):null)),N&&N===o?.key&&e.createElement("span",{style:{fontSize:"10px",color:"red",marginTop:"4px"}},"⚠️You've reached the maximum quantity for this item")))},Nr=c.div`
1356
1356
  margin: 8px 0 6px 0;
1357
1357
  padding: 12px;
1358
1358
  background: ${e=>e.$backgroundColor??"rgba(0,0,0,0.04)"};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yt-uikit",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "YourToken UI Kit",
5
5
  "scripts": {
6
6
  "rollup": "rm -rf dist && tsc && rollup -c",