@gem-sdk/components 7.0.4 → 8.0.0-dev.20

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.
Files changed (59) hide show
  1. package/dist/cjs/carousel-v3/components/swiper/Swiper.js +1 -1
  2. package/dist/cjs/countdown-timer/common/helpers.js +1 -1
  3. package/dist/cjs/countdown-timer/hooks/useTimeLeft.js +1 -1
  4. package/dist/cjs/post-purchase/product/components/ProductPrice.js +1 -1
  5. package/dist/cjs/post-purchase/product/constants/ProductOfferPlaceholder.js +1 -1
  6. package/dist/cjs/post-purchase/product/hooks/useGetMoneyLines.js +1 -1
  7. package/dist/cjs/product/components/product-badge/ProductBadge.liquid.js +10 -10
  8. package/dist/cjs/product/components/product-badge/common/styles.js +1 -1
  9. package/dist/cjs/product/components/product-badge/utils/common.js +1 -1
  10. package/dist/cjs/product/components/product-badge/utils/renderBadgeLiquid.js +3 -4
  11. package/dist/cjs/product/components/product-button/hooks/useAddToCart.js +1 -1
  12. package/dist/cjs/product/components/product-discount-tag/hooks/useGpDiscountTag.js +1 -1
  13. package/dist/cjs/product/components/product-images-v3/components/feature-gallery/FeatureImageWithGallery.liquid.js +5 -5
  14. package/dist/cjs/product/components/product-list-v3/ProductList.js +1 -1
  15. package/dist/cjs/product/components/product-price/hooks/useGpPrice.js +1 -1
  16. package/dist/cjs/product/components/product-variants/OptionVariantsNewFormat.liquid.js +41 -0
  17. package/dist/cjs/product/components/product-variants/OptionVariantsOldFormat.liquid.js +66 -0
  18. package/dist/cjs/product/components/product-variants/ProductVariants.liquid.js +25 -79
  19. package/dist/cjs/product/components/product-variants/common/base/styles.js +1 -1
  20. package/dist/cjs/product/components/product-variants/common/const.js +1 -0
  21. package/dist/cjs/product/components/product-variants/components/color/color.liquid.js +3 -3
  22. package/dist/cjs/product/components/product-view-more/ProductViewMore.liquid.js +1 -1
  23. package/dist/cjs/product/components/product-view-more/common/helpers.js +1 -1
  24. package/dist/cjs/product/components/product-wrap/Product.liquid.js +12 -10
  25. package/dist/cjs/product/helpers/product-bundle.js +1 -1
  26. package/dist/cjs/third-party/components/Trustoo.liquid.js +6 -5
  27. package/dist/cjs/third-party/settings/BonLoyaltyRewardsReferrals/index.js +1 -1
  28. package/dist/cjs/third-party/settings/Trustoo/index.js +1 -1
  29. package/dist/cjs/third-party/settings/Trustoo/uiV2.js +1 -1
  30. package/dist/esm/carousel-v3/components/swiper/Swiper.js +1 -1
  31. package/dist/esm/countdown-timer/common/helpers.js +1 -1
  32. package/dist/esm/countdown-timer/hooks/useTimeLeft.js +1 -1
  33. package/dist/esm/post-purchase/product/components/ProductPrice.js +1 -1
  34. package/dist/esm/post-purchase/product/constants/ProductOfferPlaceholder.js +1 -1
  35. package/dist/esm/post-purchase/product/hooks/useGetMoneyLines.js +1 -1
  36. package/dist/esm/product/components/product-badge/ProductBadge.liquid.js +21 -21
  37. package/dist/esm/product/components/product-badge/common/styles.js +1 -1
  38. package/dist/esm/product/components/product-badge/utils/common.js +1 -1
  39. package/dist/esm/product/components/product-badge/utils/renderBadgeLiquid.js +3 -4
  40. package/dist/esm/product/components/product-button/hooks/useAddToCart.js +1 -1
  41. package/dist/esm/product/components/product-discount-tag/hooks/useGpDiscountTag.js +1 -1
  42. package/dist/esm/product/components/product-images-v3/components/feature-gallery/FeatureImageWithGallery.liquid.js +18 -18
  43. package/dist/esm/product/components/product-list-v3/ProductList.js +1 -1
  44. package/dist/esm/product/components/product-price/hooks/useGpPrice.js +1 -1
  45. package/dist/esm/product/components/product-variants/OptionVariantsNewFormat.liquid.js +41 -0
  46. package/dist/esm/product/components/product-variants/OptionVariantsOldFormat.liquid.js +66 -0
  47. package/dist/esm/product/components/product-variants/ProductVariants.liquid.js +40 -94
  48. package/dist/esm/product/components/product-variants/common/base/styles.js +1 -1
  49. package/dist/esm/product/components/product-variants/common/const.js +1 -0
  50. package/dist/esm/product/components/product-variants/components/color/color.liquid.js +3 -3
  51. package/dist/esm/product/components/product-view-more/ProductViewMore.liquid.js +1 -1
  52. package/dist/esm/product/components/product-view-more/common/helpers.js +1 -1
  53. package/dist/esm/product/components/product-wrap/Product.liquid.js +33 -31
  54. package/dist/esm/product/helpers/product-bundle.js +1 -1
  55. package/dist/esm/third-party/components/Trustoo.liquid.js +8 -7
  56. package/dist/esm/third-party/settings/BonLoyaltyRewardsReferrals/index.js +1 -1
  57. package/dist/esm/third-party/settings/Trustoo/index.js +1 -1
  58. package/dist/esm/third-party/settings/Trustoo/uiV2.js +1 -1
  59. package/package.json +4 -4
@@ -1 +1 @@
1
- import{cls as e,formatMoney as t,makeStyleResponsive as r,getResponsiveValueByScreen as i}from"@gem-sdk/core";import{applyBundleDiscountAmount as n}from"../../../helpers/product-bundle.js";import{DiscountType as o}from"../../constants/product-bundle.js";let removeTrailingZeros=e=>e.replace(/\.00$/,""),getPriceDiffByPercent=(e,t)=>{if(!t)return"0";let r=1e3*t-1e3*e;return Math.round(100*r/(1e3*t))},getPriceDiffByValue=(e,r,i)=>removeTrailingZeros(t(r?(r-e).toFixed(2):"0",i)),getMinPrice=(e,r)=>{let i=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let t=e?.price;void 0!==t&&t<i&&(i=t)}),removeTrailingZeros(t(i.toString(),r))},checkNoDiscountState=(e,t)=>{let{discountPercentAmount:r}=n({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===o.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},getBadgeContent=(e,r,i)=>{if(!e.detail||!r?.trim()?.length)return r;let{detail:u,currentVariant:c}=e,{discountPercentAmount:l,discountAmount:a}=n({currentVariant:c,bundleItem:e?.bundleItem,options:{moneyFormat:i,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),d=()=>e?.bundleItem?.discountType!==o.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${l}%`:`${getPriceDiffByPercent(c?.price||0,c?.salePrice||0)||0}%`:"0%",s=()=>e?.bundleItem?.discountType!==o.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?a:getPriceDiffByValue(c?.price||0,c?.salePrice||0,i):t("0",i),p=new Map([["{percent_discount}",d],["{amount_discount}",s],["{min_price}",()=>getMinPrice(u.variants,i)||0],["{inventory_quantity}",()=>c?.inventoryQuantity||0]]);return[...p.entries()].reduce((e,[t,r])=>e.replaceAll(t,r()),r)},checkDiscountContentProductBadge=e=>{if(!e)return!1;let t=/\{percent_discount\}|\{amount_discount\}/;return t.test(e)},getShapePlacementClass=(e,t,r="desktop")=>e?t?.[`--pos${deviceWithSurfix(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${deviceWithSurfix(r)}`]?"":"!gp-inline-block gp-w-fit",getAlignShape=(t,r)=>r?"":e("gp-flex",{"gp-justify-start":t?.desktop==="left","gp-justify-center":t?.desktop==="center","gp-justify-end":t?.desktop==="right","tablet:gp-justify-start":t?.tablet==="left","tablet:gp-justify-center":t?.tablet==="center","tablet:gp-justify-end":t?.tablet==="right","mobile:gp-justify-start":t?.mobile==="left","mobile:gp-justify-center":t?.mobile==="center","mobile:gp-justify-end":t?.mobile==="right"}),convertToStyle=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),n=i.get(t)||t;return{...e,[n]:r}},{}),getWrapperStyle=e=>({[e?"z-index":"zIndex"]:2}),getWidthByShapeSize=(e,t)=>{let r={},n=["desktop","mobile","tablet"];return n.forEach(n=>{let o=i(e,n,null),u=o?.width||t?.wrapperWidth;u&&(r={...r,[n]:u})}),r},getHeightByShapeSize=(e,t)=>{let r={},n=["desktop","mobile","tablet"];return n.forEach(n=>{let o=i(e,n,null);r={...r,[n]:o?.height||t?.wrapperHeight}}),r},getSize=(e,t)=>{let i=r("w",getWidthByShapeSize(t,e)),n=r("h",getHeightByShapeSize(t,e));return{...i,...n}},getShapeWrapperPadding=e=>{let t={};if(1!==e)return t;let r=["desktop","mobile","tablet"];return r.forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},deviceWithSurfix=e=>"desktop"===e?"":`-${e}`,getDeviceSpecificStyle=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},getIsNoDiscountState=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:n})=>{let{setting:o,"bundle-item":u}=e,c=checkDiscountContentProductBadge(o?.displayContent);return c&&checkNoDiscountState({detail:t,currentVariant:r,bundleItem:u,useProductCompareAtPrice:n},i)};export{checkDiscountContentProductBadge,checkNoDiscountState,convertToStyle,deviceWithSurfix,getAlignShape,getBadgeContent,getDeviceSpecificStyle,getIsNoDiscountState,getShapePlacementClass,getShapeWrapperPadding,getSize,getWidthByShapeSize,getWrapperStyle};
1
+ import{cls as e,convertDecimalToNumber as t,formatMoney as r,makeStyleResponsive as i,getResponsiveValueByScreen as n}from"@gem-sdk/core";import{applyBundleDiscountAmount as o}from"../../../helpers/product-bundle.js";import{DiscountType as u}from"../../constants/product-bundle.js";let removeTrailingZeros=e=>e.replace(/\.00$/,""),getPriceDiffByPercent=(e,t)=>{if(!t)return"0";let r=1e3*t-1e3*e;return Math.round(100*r/(1e3*t))},getPriceDiffByValue=(e,t,i)=>removeTrailingZeros(r(t?(t-e).toFixed(2):"0",i)),getMinPrice=(e,i)=>{let n=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let r=t(e?.price);void 0!==r&&r<n&&(n=r)}),removeTrailingZeros(r(n.toString(),i))},checkNoDiscountState=(e,t)=>{let{discountPercentAmount:r}=o({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===u.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},getBadgeContent=(e,i,n)=>{if(!e.detail||!i?.trim()?.length)return i;let{detail:c,currentVariant:l}=e,{discountPercentAmount:a,discountAmount:d}=o({currentVariant:l,bundleItem:e?.bundleItem,options:{moneyFormat:n,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),s=()=>e?.bundleItem?.discountType!==u.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${a}%`:`${getPriceDiffByPercent(t(l?.price)??0,t(l?.salePrice)??0)||0}%`:"0%",p=()=>e?.bundleItem?.discountType!==u.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?d:getPriceDiffByValue(t(l?.price)??0,t(l?.salePrice)??0,n):r("0",n),g=new Map([["{percent_discount}",s],["{amount_discount}",p],["{min_price}",()=>getMinPrice(c.variants,n)||0],["{inventory_quantity}",()=>l?.inventoryQuantity||0]]);return[...g.entries()].reduce((e,[t,r])=>e.replaceAll(t,r()),i)},checkDiscountContentProductBadge=e=>{if(!e)return!1;let t=/\{percent_discount\}|\{amount_discount\}/;return t.test(e)},getShapePlacementClass=(e,t,r="desktop")=>e?t?.[`--pos${deviceWithSurfix(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${deviceWithSurfix(r)}`]?"":"!gp-inline-block gp-w-fit",getAlignShape=(t,r)=>r?"":e("gp-flex",{"gp-justify-start":t?.desktop==="left","gp-justify-center":t?.desktop==="center","gp-justify-end":t?.desktop==="right","tablet:gp-justify-start":t?.tablet==="left","tablet:gp-justify-center":t?.tablet==="center","tablet:gp-justify-end":t?.tablet==="right","mobile:gp-justify-start":t?.mobile==="left","mobile:gp-justify-center":t?.mobile==="center","mobile:gp-justify-end":t?.mobile==="right"}),convertToStyle=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),n=i.get(t)||t;return{...e,[n]:r}},{}),getWrapperStyle=e=>({[e?"z-index":"zIndex"]:2}),getWidthByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=n(e,i,null),u=o?.width||t?.wrapperWidth;u&&(r={...r,[i]:u})}),r},getHeightByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=n(e,i,null);r={...r,[i]:o?.height||t?.wrapperHeight}}),r},getSize=(e,t)=>{let r=i("w",getWidthByShapeSize(t,e)),n=i("h",getHeightByShapeSize(t,e));return{...r,...n}},getShapeWrapperPadding=e=>{let t={};if(1!==e)return t;let r=["desktop","mobile","tablet"];return r.forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},deviceWithSurfix=e=>"desktop"===e?"":`-${e}`,getDeviceSpecificStyle=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},getIsNoDiscountState=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:n})=>{let{setting:o,"bundle-item":u}=e,c=checkDiscountContentProductBadge(o?.displayContent);return c&&checkNoDiscountState({detail:t,currentVariant:r,bundleItem:u,useProductCompareAtPrice:n},i)};export{checkDiscountContentProductBadge,checkNoDiscountState,convertToStyle,deviceWithSurfix,getAlignShape,getBadgeContent,getDeviceSpecificStyle,getIsNoDiscountState,getShapePlacementClass,getShapeWrapperPadding,getSize,getWidthByShapeSize,getWrapperStyle};
@@ -1,4 +1,4 @@
1
- import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.ABOVE?0:i===e.BELOW?2:1,renderBadgeInFirstTime=(e,i,n)=>`
1
+ import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.ABOVE?0:i===e.BELOW?2:1,renderBadgeInFirstTime=(e,i)=>`
2
2
  {% assign isShow = true %}
3
3
  {% assign conditionTriggers = "" %}
4
4
  {% assign isInventoryStatus = false %}
@@ -16,9 +16,8 @@ import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.A
16
16
  {% assign price = variant.price | times: 1.0 %}
17
17
  {% assign salePrice = variant.compare_at_price | times: 1.0 %}
18
18
  {% assign priceSave = salePrice | minus: price %}
19
- {% assign isDiscountContent = ${i} %}
20
- {% assign isTextBadge = ${n} %}
21
- {% if priceSave <= 0 or isDiscountContent == false or isTextBadge == false %}
19
+ {% assign isEmptyBadgeContent = ${!i} %}
20
+ {% if priceSave <= 0 or isEmptyBadgeContent == true %}
22
21
  {% assign isShow = false %}
23
22
  {% endif %}
24
23
  {% if isShow %}
@@ -1 +1 @@
1
- import{useRenderMode as e,useProduct as t,useCurrency as r,useQuantity as i,useProductProperties as s,useCurrentVariant as n,useHasPreSelected as o,useStickyStore as a,useProductStore as u,useCreateCart as l,useAddToCart as c,useCurrentVariantInStock as m}from"@gem-sdk/core";import{useRef as b,useEffect as d,useCallback as f}from"react";import{addToCartTracking as p}from"../../../helpers/tracking.js";import{useDispatchAfterSubmitEvent as v}from"./useDispatchAfterSubmitEvent.js";import{useCartMessage as g}from"./useCartMessage.js";import{useCartOperations as I}from"./useCartOperations.js";let useBtnAddToCart=({styles:k,setting:D,builderProps:S})=>{let E=b(null),{isEditMode:h,isPreviewSharePageMode:j}=e(),y=t(),{currency:C}=r(),{quantity:A}=i(),M=s(),O=n(),{hasPreSelected:w}=o(),B=a(e=>e.setStickyVisible),T=u(e=>e.updateIsSubmit),q=v(S?.uid),{showMessage:x,notiComponent:L}=g(k,D),{handleSuccess:U,handleError:V,cartId:z}=I(D,x,q),{isMutating:F,trigger:G}=l({onSuccess:U,onError:V}),{isMutating:H,trigger:J}=c({onSuccess:U,onError:V});d(()=>{let e=new IntersectionObserver(e=>{let t=e[0];B(t?.isIntersecting)},{threshold:.1}),t=E.current;return E.current&&e.observe(E.current),()=>{t&&e.unobserve(t)}},[B]);let K=f(()=>{if(!O?.baseID||!A||!y?.baseID||void 0!==w&&!w||h||j)return;let e=M?.some(e=>e.required&&!e.value);if(T(!0),e)return;let t=M?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));p({quantity:A,currency:C,id:y?.baseID,name:y?.title,brand:y?.vendor,sku:O.sku,price:O?.price,variant:O.title});let r={quantity:A,attributes:t,variantId:O.baseID};D?.actionEffect!=="buy-now"&&z?J({cartId:z,lines:[r]}):G({items:[r]})},[h,j,z,C,A,M,w,y?.title,y?.vendor,y?.baseID,O?.sku,O?.price,O?.title,O?.baseID,D?.actionEffect,G,J,T]),N=m(),P=F||H,Q=O?D?.outOfStockLabel:"Unavailable";return{addToCartRef:E,isLoading:P,isInStock:N,notiComponent:L,outOfStockLabel:Q,addToCart:K}};export{useBtnAddToCart};
1
+ import{useRenderMode as e,useProduct as t,useCurrency as r,useQuantity as i,useProductProperties as s,useCurrentVariant as n,useHasPreSelected as o,useStickyStore as a,useProductStore as u,useCreateCart as l,useAddToCart as c,convertDecimalToNumber as m,useCurrentVariantInStock as b}from"@gem-sdk/core";import{useRef as d,useEffect as f,useCallback as p}from"react";import{addToCartTracking as v}from"../../../helpers/tracking.js";import{useDispatchAfterSubmitEvent as g}from"./useDispatchAfterSubmitEvent.js";import{useCartMessage as I}from"./useCartMessage.js";import{useCartOperations as k}from"./useCartOperations.js";let useBtnAddToCart=({styles:D,setting:S,builderProps:E})=>{let h=d(null),{isEditMode:j,isPreviewSharePageMode:y}=e(),C=t(),{currency:A}=r(),{quantity:M}=i(),O=s(),w=n(),{hasPreSelected:B}=o(),T=a(e=>e.setStickyVisible),q=u(e=>e.updateIsSubmit),x=g(E?.uid),{showMessage:L,notiComponent:U}=I(D,S),{handleSuccess:V,handleError:z,cartId:F}=k(S,L,x),{isMutating:G,trigger:H}=l({onSuccess:V,onError:z}),{isMutating:J,trigger:K}=c({onSuccess:V,onError:z});f(()=>{let e=new IntersectionObserver(e=>{let t=e[0];T(t?.isIntersecting)},{threshold:.1}),t=h.current;return h.current&&e.observe(h.current),()=>{t&&e.unobserve(t)}},[T]);let N=p(()=>{if(!w?.baseID||!M||!C?.baseID||void 0!==B&&!B||j||y)return;let e=O?.some(e=>e.required&&!e.value);if(q(!0),e)return;let t=O?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));v({quantity:M,currency:A,id:C?.baseID,name:C?.title,brand:C?.vendor,sku:w.sku,price:m(w?.price),variant:w.title});let r={quantity:M,attributes:t,variantId:w.baseID};S?.actionEffect!=="buy-now"&&F?K({cartId:F,lines:[r]}):H({items:[r]})},[j,y,F,A,M,O,B,C?.title,C?.vendor,C?.baseID,w?.sku,w?.price,w?.title,w?.baseID,S?.actionEffect,H,K,q]),P=b(),Q=G||J,R=w?S?.outOfStockLabel:"Unavailable";return{addToCartRef:h,isLoading:Q,isInStock:P,notiComponent:U,outOfStockLabel:R,addToCart:N}};export{useBtnAddToCart};
@@ -1 +1 @@
1
- import{useMoneyFormat as e,useEditorMode as t,useProduct as r,useCurrentVariant as n,useQuantity as o,useFormatMoney as u,useProductBundleDiscount as i,formatMoney as p}from"@gem-sdk/core";import{useMemo as c}from"react";import{applyBundleDiscountAmount as s}from"../../../helpers/product-bundle.js";import{DiscountType as a}from"../../constants/product-bundle.js";let useGpDiscountTag=m=>{let{setting:l,...d}=m,{customContent:g}=l??{},f=d["bundle-item"],{moneyFormat:b}=e(),h=t(),D=r(),$=n(),{quantity:j,hasUpdatePrice:y}=o(),G=c(()=>y&&g?.unit!=="percentage"?j??1:1,[y,g?.unit,j]),P=$?.price??0,T=$?.salePrice??0,k=(T-P)*G,x=u(k<0?0:k,l?.moneyWithCurrentFormat||!1),C=c(()=>{if(!T&&0!==T||!P&&0!==P)return`${g?.unit==="percentage"?"0%":x}`;if(g?.unit==="percentage"){let e=Math.round(k/(T/100));return`${e<0?0:e}%`}return`${x}`},[g?.unit,x,P,k,T]),{useProductCompareAtPrice:F}=i(),{discountPercentAmount:I}=s({currentVariant:$,bundleItem:f,options:{moneyFormat:b,useProductCompareAtPrice:F}}),M=c(()=>{if(!f)return 0;let{discountPercentAmount:e,discountAmount:t}=s({currentVariant:$,bundleItem:f,options:{moneyFormat:b,useProductCompareAtPrice:F}}),{discountType:r}=f,{unit:n}=g||{};return r!==a.NoDiscount||F?"percentage"===n?`${e}%`:t:"percentage"===n?"0%":p("0",b)},[f,$,b,F,g]),N=c(()=>f?M:C,[M,f,C]),W=D?.baseID?.replace("gid://shopify/Product/",""),q=c(()=>{let e=f?I<=0:k<=0;return"edit"===h&&e},[f,I,h,k]);return{mode:h,product:D,salePrice:T,priceSave:k,currentProductId:W,unitCustomDisplay:N,shouldPlaceholderNoDiscount:q}};export{useGpDiscountTag};
1
+ import{useMoneyFormat as e,useEditorMode as t,useProduct as r,useCurrentVariant as n,useQuantity as o,convertDecimalToNumber as u,useFormatMoney as i,useProductBundleDiscount as p,formatMoney as c}from"@gem-sdk/core";import{useMemo as s}from"react";import{applyBundleDiscountAmount as a}from"../../../helpers/product-bundle.js";import{DiscountType as m}from"../../constants/product-bundle.js";let useGpDiscountTag=l=>{let{setting:d,...g}=l,{customContent:f}=d??{},b=g["bundle-item"],{moneyFormat:h}=e(),D=t(),$=r(),j=n(),{quantity:y,hasUpdatePrice:G}=o(),P=s(()=>G&&f?.unit!=="percentage"?y??1:1,[G,f?.unit,y]),T=u(j?.price)??0,k=u(j?.salePrice)??0,x=(k-T)*P,C=i(x<0?0:x,d?.moneyWithCurrentFormat||!1),F=s(()=>{if(!k&&0!==k||!T&&0!==T)return`${f?.unit==="percentage"?"0%":C}`;if(f?.unit==="percentage"){let e=Math.round(x/(k/100));return`${e<0?0:e}%`}return`${C}`},[f?.unit,C,T,x,k]),{useProductCompareAtPrice:I}=p(),{discountPercentAmount:M}=a({currentVariant:j,bundleItem:b,options:{moneyFormat:h,useProductCompareAtPrice:I}}),N=s(()=>{if(!b)return 0;let{discountPercentAmount:e,discountAmount:t}=a({currentVariant:j,bundleItem:b,options:{moneyFormat:h,useProductCompareAtPrice:I}}),{discountType:r}=b,{unit:n}=f||{};return r!==m.NoDiscount||I?"percentage"===n?`${e}%`:t:"percentage"===n?"0%":c("0",h)},[b,j,h,I,f]),W=s(()=>b?N:F,[N,b,F]),q=$?.baseID?.replace("gid://shopify/Product/",""),v=s(()=>{let e=b?M<=0:x<=0;return"edit"===D&&e},[b,M,D,x]);return{mode:D,product:$,salePrice:k,priceSave:x,currentProductId:q,unitCustomDisplay:W,shouldPlaceholderNoDiscount:v}};export{useGpDiscountTag};
@@ -1,4 +1,4 @@
1
- import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";import{getAspectRatio as t,getPaddingBottomByShapeSetting as r,getSrcImage as s}from"../../common/common.js";import{checkRenderFeaturedCarousel as d,getVideoHeight as o,getZoomImageClass as u,getZoomLenClass as l}from"../../common/productFeaturedImage.js";import m from"../../../../../video/components/HTML5Embed.liquid.js";import g from"../../../../../image/components/Modal3d.liquid.js";import p from"../../../../../image/components/NextImage.liquid.js";import n from"../../../../../image/components/Video.liquid.js";import{getStyleOfObject as c}from"../../../../helpers/function.js";import{getProductImagesStyles as f}from"../../composables/getProductImagesStyles.js";import{getProductImagesClassName as h}from"../../composables/getProductImagesClassName.js";import{getProductImagesAttr as y}from"../../composables/getProductImagesAttr.js";import{LiquidIf as M,LiquidFor as b,Liquid as $,If as _,createStyle as v}from"@gem-sdk/system";import w from"../../../../../carousel-v3/components/root/Carousel.liquid.js";import I from"../../../../../carousel-v3/components/item/CarouselItem.liquid.js";let FeatureImageWithGallery=({builderPropUID:x,children:q,enableLazyLoadImage:j,...z})=>{let{featuredImageCarouselClasses:S,galleryItemClasses:L,featuredCarouselItemClasses:P}=h({...z,builderProps:{uid:x}}),{featuredImageCarouselStyle:R,featureImageStyle:W,featureImageCarouselOnlyOneImageStyle:C,featureImageOnlyOneImageStyle:T,featureImageCarouselItemStyle:N}=f(z),{featuredImageCarouselSettingAttrs:k}=y(z),E=t(z.ftShape),O=()=>`
1
+ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";import{getAspectRatio as t,getPaddingBottomByShapeSetting as r,getSrcImage as s}from"../../common/common.js";import{checkRenderFeaturedCarousel as d,getVideoHeight as o,getZoomImageClass as u,getZoomLenClass as l}from"../../common/productFeaturedImage.js";import m from"../../../../../video/components/HTML5Embed.liquid.js";import p from"../../../../../image/components/Modal3d.liquid.js";import g from"../../../../../image/components/NextImage.liquid.js";import n from"../../../../../image/components/Video.liquid.js";import{getStyleOfObject as c}from"../../../../helpers/function.js";import{getProductImagesStyles as f}from"../../composables/getProductImagesStyles.js";import{getProductImagesClassName as h}from"../../composables/getProductImagesClassName.js";import{getProductImagesAttr as y}from"../../composables/getProductImagesAttr.js";import{LiquidIf as M,LiquidFor as _,Liquid as b,If as $,createStyle as v}from"@gem-sdk/system";import w from"../../../../../carousel-v3/components/root/Carousel.liquid.js";import I from"../../../../../carousel-v3/components/item/CarouselItem.liquid.js";let FeatureImageWithGallery=({builderPropUID:x,children:q,enableLazyLoadImage:j,...z})=>{let{featuredImageCarouselClasses:S,galleryItemClasses:L,featuredCarouselItemClasses:P}=h({...z,builderProps:{uid:x}}),{featuredImageCarouselStyle:R,featureImageStyle:W,featureImageCarouselOnlyOneImageStyle:T,featureImageOnlyOneImageStyle:C,featureImageCarouselItemStyle:N}=f(z),{featuredImageCarouselSettingAttrs:k}=y(z),E=t(z.ftShape),O=()=>`
2
2
  {% case featureMedia.media_type %}
3
3
  {% when 'image' %}
4
4
  ${F()}
@@ -13,15 +13,15 @@ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";impor
13
13
  {% else %}
14
14
  ${G()}
15
15
  {% endcase %}
16
- `,A=()=>g({src:M("featureMedia.sources.first.url contains '.glb'","{{ featureMedia.sources.first.url }}","{{featureMedia.sources.last.url}}"),alt:"{{featureMedia.preview_image.alt}}",poster:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",cameraControls:!0,arStatus:"not-presenting",style:{width:"100%"},aspectRatio:E}),D=()=>n({src:"{{mediaSourceVideo}}",alt:"{{featureMedia.alt | escape}}",autoplay:!1,allowfullscreen:!0,controls:!0,style:{width:"100%",height:"100%"},aspectRatio:E}),V=()=>{let a=v({...o(z?.ftLayout),...e("objf",z?.ftLayout)}),i=v({...o(z?.ftLayout)});return m({src:"{{mediaSourceVideo}}",title:"{{featureMedia.alt | escape}}",autoplay:!1,controls:!0,thumbnail:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",isCheckLoaded:!0,wrapperStyles:i,style:{width:"100%","max-height":"100%",...a},className:"gp-invisible"})},F=()=>a`
16
+ `,A=()=>p({src:M("featureMedia.sources.first.url contains '.glb'","{{ featureMedia.sources.first.url }}","{{featureMedia.sources.last.url}}"),alt:"{{featureMedia.preview_image.alt}}",poster:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",cameraControls:!0,arStatus:"not-presenting",style:{width:"100%"},aspectRatio:E}),D=()=>n({src:"{{mediaSourceVideo}}",alt:"{{featureMedia.alt | escape}}",autoplay:!1,allowfullscreen:!0,controls:!0,style:{width:"100%",height:"100%"},aspectRatio:E}),V=()=>{let a=v({...o(z?.ftLayout),...e("objf",z?.ftLayout)}),i=v({...o(z?.ftLayout)});return m({src:"{{mediaSourceVideo}}",title:"{{featureMedia.alt | escape}}",autoplay:!1,controls:!0,thumbnail:"{{featureMedia.preview_image.src | product_img_url: '1024x1024'}}",isCheckLoaded:!0,wrapperStyles:i,poster:{altText:"{{featureMedia.preview_image.alt}}"},style:{width:"100%","max-height":"100%",...a},className:"gp-invisible"})},F=()=>a`
17
17
  ${H(i("gp-w-full gp-transition-opacity",{"group-hover:gp-opacity-0":"other"==z.hoverEffect},"{{shouldHidden}}"))}
18
- ${_(z?.hoverEffect!=="none",`<div class="${i("zoom-element !gp-max-w-none",u())}">
18
+ ${$(z?.hoverEffect!=="none",`<div class="${i("zoom-element !gp-max-w-none",u())}">
19
19
  ${H("image-zoom",!0)}
20
20
  </div>`," ")}
21
- ${_(z?.hoverEffect=="zoom"&&z?.zoomType=="glasses",`<div class="${i("zoom-lens-element",l())}" style="opacity: 0; background-image: url('{{ featureMedia.src | img_url: "1024x1024"}}')"></div>`," ")}
21
+ ${$(z?.hoverEffect=="zoom"&&z?.zoomType=="glasses",`<div class="${i("zoom-lens-element",l())}" style="opacity: 0; background-image: url('{{ featureMedia.src | img_url: "1024x1024"}}')"></div>`," ")}
22
22
  `,H=(e,i)=>a`
23
23
  {% assign src = featureMedia.src %}
24
- ${_(i&&"other"==z.hoverEffect,`{% assign media_length = product.media | size %}
24
+ ${$(i&&"other"==z.hoverEffect,`{% assign media_length = product.media | size %}
25
25
  {% assign other_image_index = ${z.otherImage} | plus: 0 %}
26
26
  {% if other_image_index >= media_length %}
27
27
  {% assign other_image_index = media_length | minus: 1 %}
@@ -29,9 +29,9 @@ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";impor
29
29
  {% assign otherImage = product.media[other_image_index] %}
30
30
  ${M("otherImage.media_type != 'image'","{% assign src = otherImage.preview_image.src %}","{% assign src = otherImage.src %}")}
31
31
  `)}
32
- ${p({srcIsLiquidCode:!0,src:M("src != null",s("src"),"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif"),id:M("featureMedia != null","{{featureMedia.id}}"),width:"{{featureMedia.width}}",height:"{{featureMedia.height}}",alt:"{{featureMedia.alt | escape}}",srcset:`${s("src")}`,baseSrc:"{{src | image_url}}",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},priority:z?.preload,className:`gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none ${e??""}`,enableLazyLoadImage:j})}`,G=()=>a`
33
- ${p({srcIsLiquidCode:!0,src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",alt:"No Image",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},priority:z?.preload,className:"gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none",enableLazyLoadImage:j})}`,B=r(z.ftShape),J=a=>`
34
- ${$(`{% assign productImageWidth = 0 %}
32
+ ${g({srcIsLiquidCode:!0,src:M("src != null",s("src"),"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif"),id:M("featureMedia != null","{{featureMedia.id}}"),width:"{{featureMedia.width}}",height:"{{featureMedia.height}}",alt:"{{featureMedia.alt | escape}}",srcset:`${s("src")}`,baseSrc:"{{src | image_url}}",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},priority:z?.preload,className:`gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none ${e??""}`,enableLazyLoadImage:j})}`,G=()=>a`
33
+ ${g({srcIsLiquidCode:!0,src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",alt:"No Image",sizes:"(max-width: 768px) 50vw, 100vw",setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},priority:z?.preload,className:"gp-w-full gp-h-full gp-absolute gp-top-0 gp-left-0 featured-image-only gp-cursor-pointer !gp-rounded-none",enableLazyLoadImage:j})}`,B=r(z.ftShape),J=a=>`
34
+ ${b(`{% assign productImageWidth = 0 %}
35
35
  {% case featureMedia.media_type %}
36
36
  {% when 'image' %}
37
37
  {% assign productImageWidth = featureMedia.width %}
@@ -46,24 +46,24 @@ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";impor
46
46
  ${O()}
47
47
  </div>
48
48
  `})}`,K=d(z),Q="gp-featured-image-wrapper",U=M("product.media.size > 0",`{% assign largestRatio = 0 %}
49
- ${b("featureMedia in product.media",`
49
+ ${_("featureMedia in product.media",`
50
50
  {% assign height = featureMedia.height | times: 1.0 %}
51
51
  {% assign width = featureMedia.width | times: 1.0 %}
52
52
  {% assign ratio = height | divided_by: width %}
53
53
  ${M("ratio > largestRatio","{% assign largestRatio = ratio %}")}
54
54
  `)}
55
- ${b("featureMedia in product.media",`${M("featureMedia.media_type == 'image'",`${b("image in product.images",M("image.src == featureMedia.src","{% assign imageID = image.id %}{% break %}"))}`,"{% assign imageID = '' %}")}
55
+ ${_("featureMedia in product.media",`${M("featureMedia.media_type == 'image'",`${_("image in product.images",M("image.src == featureMedia.src","{% assign imageID = image.id %}{% break %}"))}`,"{% assign imageID = '' %}")}
56
56
  ${J()}`)}
57
- `,p({src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",id:"noImageError",width:"480",height:"480",alt:"no image",priority:z?.preload,setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},style:{height:"100%"},className:"gp-w-full featured-image-only !gp-rounded-none",customLazyload:!0,enableLazyLoadImage:j})),X=()=>`
57
+ `,g({src:"https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",id:"noImageError",width:"480",height:"480",alt:"no image",priority:z?.preload,setting:{layout:z?.ftLayout,aspectRatio:E,qualityType:z?.qualityType,qualityPercent:z?.qualityPercent},style:{height:"100%"},className:"gp-w-full featured-image-only !gp-rounded-none",customLazyload:!0,enableLazyLoadImage:j})),X=()=>`
58
58
  ${w({builderProps:{uid:x},rootId:`ft-${x}-{{section.id}}-{{product.id}}`,conditionAppendJs:"product.media.size > 1",wrapperClass:Q,rootClass:`${S}`,rootAttrs:{type:"gp-feature-image-carousel","product-id":"{{product.id}}","product-media":"{{product.media.size}}"},isHiddenArrowWhenDisabled:!0,setting:k,rootStyles:W,styles:R,style:{playSpeed:600},disableMarginAuto:!0,children:U,productBadgeLiquid:q||""})}
59
59
  `,Y=()=>{switch(z?.preDisplay){case"1st-images":return`
60
60
  {% assign featureMedia = product.media.first %}
61
- `;case"1st-3d-mode":return b("media in product.media",M("media.media_type == 'model'","{% assign featureMedia = media %}{% break %}"));case"1st-video":return b("media in product.media",M("media.media_type == 'video' or media.media_type == 'external_video'","{% assign featureMedia = media %}{% break %}"));default:return`
61
+ `;case"1st-3d-mode":return _("media in product.media",M("media.media_type == 'model'","{% assign featureMedia = media %}{% break %}"));case"1st-video":return _("media in product.media",M("media.media_type == 'video' or media.media_type == 'external_video'","{% assign featureMedia = media %}{% break %}"));default:return`
62
62
  {% assign featureMedia = variant.featured_media %}
63
63
  {% unless featureMedia %}
64
64
  {% assign featureMedia = product.featured_media %}
65
65
  {% endunless %}
66
- `}},Z=()=>$(`
66
+ `}},Z=()=>b(`
67
67
  {% assign featureMedia = variant.featured_media %}
68
68
  {% unless featureMedia %}
69
69
  {% assign featureMedia = product.featured_media %}
@@ -88,7 +88,7 @@ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";impor
88
88
  >
89
89
  <div
90
90
  class="gp-relative"
91
- style="${c(T)}"
91
+ style="${c(C)}"
92
92
  >
93
93
  ${q}
94
94
  <div
@@ -96,7 +96,7 @@ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";impor
96
96
  product-id="{{product.id}}"
97
97
  product-media="{{product.media.size}}"
98
98
  class="${P(Q)}"
99
- style="${c(C)}"
99
+ style="${c(T)}"
100
100
  >
101
101
  <div
102
102
  class="gp-w-full gp-relative ${M("featureMedia == null or featureMedia.media_type == 'image'","{{ 'gp-h-0' }}","{{ 'gp-h-full !gp-pb-0' }}")}"
@@ -107,12 +107,12 @@ import{makeStyleResponsive as e,template as a,cls as i}from"@gem-sdk/core";impor
107
107
  </div>
108
108
  </div>
109
109
  </div>
110
- `);return $(`
110
+ `);return b(`
111
111
  {% capture featureImageOnlyOne %}
112
112
  ${Z()}
113
113
  {% endcapture %}
114
114
  ${M("product.media.size > 1",`
115
- ${_(K,X()," ")}
116
- ${_(!K,"{{ featureImageOnlyOne }}"," ")}
115
+ ${$(K,X()," ")}
116
+ ${$(!K,"{{ featureImageOnlyOne }}"," ")}
117
117
  `,"{{ featureImageOnlyOne }}")}
118
118
  `)};export{FeatureImageWithGallery as default};
@@ -1 +1 @@
1
- import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import r from"next/dynamic";import d from"../../../common/components/Loading.js";import{useState as l,useMemo as i,useEffect as a}from"react";import{useRenderMode as c,useCurrentDevice as n,usePageType as s,usePageStore as u,useFetchHandle as m,hasPublicStoreFrontData as g,createStoreFrontFetcher as h,useProductQuery as p,useProductsQueryAll as P,useProductsQuery as f,useCollectionQuery as b,flattenConnection as k,ProductListProvider as T,filterToolbarPreview as I}from"@gem-sdk/core";import v from"../SalePageProductListWarning.js";import y from"next/head";import O from"./ProductListGridLayout.js";import N from"./ProductListCarouselLayout.js";import{getStyle as S}from"./common/styles.js";import{If as C}from"@gem-sdk/system";import{getClass as E}from"./common/classes.js";import{getData as w}from"./common/helpers.js";import{getPropertyByDevice as L}from"../../../dialog/common/helpers.js";let ProductNotFound=r(()=>import("../ProductNotFound.js"),{loading:d}),ProductList=r=>{let{children:W,styles:j,builderProps:x,setting:G,builderAttrs:M}=r,{isRelatedProduct:B,productSetting:A}=w(r),F=A.relatedTag&&A.relatedTag[0],{isEditMode:Q,isPreviewSharePageMode:z}=c(),D=n(),H=s(),R=u(e=>e.dynamicProduct),$=u(e=>e.dynamicCollection),[_,V]=l(1),[q,U]=l(!0),[J,K]=l(),[X,Y]=l(!1),Z="GP_FUNNEL_PAGE"===H,ee="GP_COLLECTION"==H;ee&&(A.productSrc="DynamicCollection",A.collectionId=$?.collectionId??"latest");let et=A?.productSrc??"Collection",eo=R?.productId&&R?.productId!==A.relatedProductId?R?.productId:A.relatedProductId,er=m(),ed=u(e=>e.publicStoreFrontData),el=i(()=>g(ed)?h(ed):er,[ed]),{data:ei}=p(B&&eo?eo:void 0,{revalidateOnMount:Q||z},el),ea=A.relatedTag&&"tags"===A.relatedTag[0]&&(!ei?.tags||ei?.tags.length===0),ec=A.relatedTag&&"collection"===A.relatedTag[0]&&(!ei?.collections?.edges||ei?.collections.edges.length===0),en=A.relatedTag&&"vendor"===A.relatedTag[0]&&!ei?.vendor,es=ea||ec||en,eu=P(J,{revalidateOnMount:Q||z},el),em=Q||z,eg=f("PickProduct"===et?A?.productIds:void 0,{revalidateOnMount:em},{defaultSelectedProductCount:A?.numOfSelectedProducts}),eh=i(()=>({id:A?.collectionId??"latest",numberOfProducts:G?.numberOfProducts??4,orderBy:G?.orderBy}),[A?.collectionId,Number(G?.numberOfProducts),G?.orderBy]),ep=b("PickProduct"!==et?eh:void 0,{revalidateOnMount:em});a(()=>{if(B&&ei&&A.relatedTag&&"recommended-product"!==A.relatedType){let e;switch(Y(!1),A.hasRelatedExclude&&(e=A?.relatedExclude&&A.relatedExclude.split(",").map(e=>e.trim())),A.relatedTag[0]){case"vendor":K({vendor:A.relatedTag&&"vendor"===A.relatedTag[0]?ei?.vendor:"",limit:G?.numberOfProducts,idNEQ:ei.id});break;case"collection":{let t;let o=ei?.collections?.edges.map(e=>e.node?.id);if(!o||o?.length===0){Y(!0);break}K(t=e&&e.length>0?{idNEQ:ei.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:o},{titleNotIn:e}]}],limit:G?.numberOfProducts}:{idNEQ:ei.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:o}]}],limit:G?.numberOfProducts});break}case"tags":{let t;if(!ei.tags||0===ei.tags.length){Y(!0);break}K(t=e&&e.length>0?{idNEQ:ei.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:ei.tags},{nameNotIn:e}]}],limit:G?.numberOfProducts}:{idNEQ:ei.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:ei.tags}]}],limit:G?.numberOfProducts})}}}},[ei,A.relatedType,A.relatedTag,G?.numberOfProducts,A.relatedExclude,A.hasRelatedExclude,B]);let eP="PickProduct"===et?eg.isValidating:ep.isValidating,ef="PickProduct"===et?eg.isLoading:ep.isLoading,eb="PickProduct"===et?eg.error:ep.error,ek=ep.data?.collections?.edges?.[0]?.node,eT="PickProduct"===et?k(eg.data?.products):k(ek?.products),eI=eu?.data?.products?k(eu?.data?.products):void 0,ev=B&&eI?eI:"PickProduct"===et&&A?.productIds?.length?A?.productIds?.map(e=>eT?.find(t=>t?.baseID===e)).filter(Boolean)??eT:"PickProduct"!==et?eT:eT.filter((e,t)=>t<(A?.numOfSelectedProducts??4)),ey=i(()=>X&&B&&Q||!ev.length&&!ef&&q&&Q,[q,ef,X,B,Q,ev.length]),eO=i(()=>!ev||X&&B,[X,B,ev]),eN=i(()=>{if(!G?.sameHeight)return[];let e=0,t=Math.ceil((ev?.length??0)/+(G?.slidesToShow?.[D]??1));return Array.from(Array(ev?.length??0)).map((o,r)=>(r>=+(G?.slidesToShow?.[D]??1)*(e+1)&&++e,{gridRow:`${1+_*e}/${_+1+_*e}`,marginBottom:e+1<t?L(j?.horizontalGutter,D):void 0}))},[G?.sameHeight,G?.slidesToShow,_,ev?.length,D,j?.horizontalGutter]),eS=i(()=>eP||ef||eb||!ev||X&&B,[eb,ef,X,B,eP,ev]);a(()=>{eS||setTimeout(()=>{let{builderData:e}=x??{},t=e?.childrens?.[0];if(!t)return;let o=document.querySelector(`[data-id=${t}] div`);o&&V(o.childElementCount||1)},Q?0:500)},[x,eS,Q]);let eC=i(()=>({collection:ek,products:ev,settings:{loop:G?.loop??{desktop:!1},scrollMode:G?.scrollMode??{desktop:"snap"},slidesToShow:G?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:j?.layout,dot:G?.dot,dotStyle:G?.dotStyle,arrow:G?.arrow,controlOverContent:G?.controlOverContent},styles:{horizontalGutter:j?.horizontalGutter,verticalGutter:j?.verticalGutter,fullWidth:j?.fullWidth,spacing:j?.spacing,width:j?.width,height:j?.height}}),[ek,ev,G,j]);if(x?.isPreview&&Z)return e(t,{});if(ey)return e(t,{children:C(q,e(ProductNotFound,{builderAttrs:M,collectionHandle:ek?.handle,productSrc:et,onClose:()=>U(!1),children:W,relatedTagString:F,assignProductNoTags:es,noAssignedProduct:!eo}))});let{productListWrapStyle:eE,productListContentStyle:ew,productListWrapAlignStyle:eL}=S(r),{productListWrapClass:eW}=E(r),ej=()=>e(t,{children:C(j?.layout==="grid",e(O,{...r,productSortedById:ev,generateGridRowArray:eN}),e(N,{...r,productSortedById:ev}))});return o("div",{...M,className:eW,style:eE,children:[!!j?.preloadBgImage&&o(y,{children:[!!j.backgroundImage?.desktop?.image?.src&&e("link",{rel:"preload",href:j.backgroundImage.desktop.image.src,as:"image"}),!!j.backgroundImage?.tablet?.image?.src&&e("link",{rel:"preload",href:j.backgroundImage?.tablet?.image?.src,as:"image"}),!!j.backgroundImage?.mobile?.image?.src&&e("link",{rel:"preload",href:j.backgroundImage?.mobile?.image?.src,as:"image"})]}),eP||ef?e(d,{}):eb?o("div",{children:["Error: ",eb?.message]}):eO?e("div",{children:"Products not found"}):e(T,{...eC,children:e("div",{className:"gp-flex gp-w-full",style:eL,children:o("div",{style:ew,children:[Z&&e(v,{}),ej()]})})}),I(W,!0)]})};export{ProductList as default};
1
+ import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import r from"next/dynamic";import d from"../../../common/components/Loading.js";import{useState as l,useMemo as i,useEffect as a}from"react";import{useRenderMode as c,useCurrentDevice as s,usePageType as n,usePageStore as u,useFetchHandle as m,hasPublicStoreFrontData as g,createStoreFrontFetcher as h,useProductQuery as p,useProductsQueryAll as P,useProductsQuery as f,useCollectionQuery as b,flattenConnection as k,ProductListProvider as I,filterToolbarPreview as T}from"@gem-sdk/core";import y from"../SalePageProductListWarning.js";import v from"next/head";import O from"./ProductListGridLayout.js";import N from"./ProductListCarouselLayout.js";import{getStyle as S}from"./common/styles.js";import{If as C}from"@gem-sdk/system";import{getClass as E}from"./common/classes.js";import{getData as w}from"./common/helpers.js";import{getPropertyByDevice as L}from"../../../dialog/common/helpers.js";let ProductNotFound=r(()=>import("../ProductNotFound.js"),{loading:d}),ProductList=r=>{let{children:W,styles:j,builderProps:x,setting:G,builderAttrs:A}=r,{isRelatedProduct:M,productSetting:B}=w(r),F=B.relatedTag&&B.relatedTag[0],{isEditMode:Q,isPreviewSharePageMode:z}=c(),D=s(),H=n(),R=u(e=>e.dynamicProduct),$=u(e=>e.dynamicCollection),[_,V]=l(1),[q,U]=l(!0),[J,K]=l(),[X,Y]=l(!1),Z="GP_FUNNEL_PAGE"===H,ee="GP_COLLECTION"==H;ee&&(B.productSrc="DynamicCollection",B.collectionId=$?.collectionId??"latest");let et=B?.productSrc??"Collection",eo=R?.productId&&R?.productId!==B.relatedProductId?R?.productId:B.relatedProductId,er=m(),ed=u(e=>e.publicStoreFrontData),el=i(()=>g(ed)?h(ed):er,[ed]),{data:ei}=p(M&&eo?eo:void 0,{revalidateOnMount:Q||z},el),ea=B.relatedTag&&"tags"===B.relatedTag[0]&&(!ei?.tags||ei?.tags.length===0),ec=B.relatedTag&&"collection"===B.relatedTag[0]&&(!ei?.collections?.edges||ei?.collections.edges.length===0),es=B.relatedTag&&"vendor"===B.relatedTag[0]&&!ei?.vendor,en=ea||ec||es,eu=P(J,{revalidateOnMount:Q||z},el),em=Q||z,eg=f("PickProduct"===et?B?.productIds:void 0,{revalidateOnMount:em},{defaultSelectedProductCount:B?.numOfSelectedProducts}),eh=i(()=>({id:B?.collectionId??"latest",numberOfProducts:G?.numberOfProducts??4,orderBy:G?.orderBy}),[B?.collectionId,Number(G?.numberOfProducts),G?.orderBy]),ep=b("PickProduct"!==et?eh:void 0,{revalidateOnMount:em});a(()=>{if(M&&ei&&B.relatedTag&&"recommended-product"!==B.relatedType){let e;switch(Y(!1),B.hasRelatedExclude&&(e=B?.relatedExclude&&B.relatedExclude.split(",").map(e=>e.trim())),B.relatedTag[0]){case"vendor":K({vendor:B.relatedTag&&"vendor"===B.relatedTag[0]?ei?.vendor:"",limit:G?.numberOfProducts,idNEQ:ei.id});break;case"collection":{let t;let o=ei?.collections?.edges.map(e=>e.node?.id);if(!o||o?.length===0){Y(!0);break}K(t=e&&e.length>0?{idNEQ:ei.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:o},{titleNotIn:e}]}],limit:G?.numberOfProducts}:{idNEQ:ei.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:o}]}],limit:G?.numberOfProducts});break}case"tags":{let t;if(!ei.tags||0===ei.tags.length){Y(!0);break}K(t=e&&e.length>0?{idNEQ:ei.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:ei.tags},{nameNotIn:e}]}],limit:G?.numberOfProducts}:{idNEQ:ei.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:ei.tags}]}],limit:G?.numberOfProducts})}}}},[ei,B.relatedType,B.relatedTag,G?.numberOfProducts,B.relatedExclude,B.hasRelatedExclude,M]);let eP="PickProduct"===et?eg.isValidating:ep.isValidating,ef="PickProduct"===et?eg.isLoading:ep.isLoading,eb="PickProduct"===et?eg.error:ep.error,ek=ep.data?.collections?.edges?.[0]?.node,eI="PickProduct"===et?k(eg.data?.products):k(ek?.products),eT=u(e=>e.assignedProductIds),ey=u(e=>e.isApplyAllProducts),ev=i(()=>(eT??[]).length>0&&!ey||ey,[eT,ey]),eO=eu?.data?.products&&ev?k(eu?.data?.products):[],eN=M?eO:"PickProduct"===et&&B?.productIds?.length?B?.productIds?.map(e=>eI?.find(t=>t?.baseID===e)).filter(Boolean)??eI:"PickProduct"!==et?eI:eI.filter((e,t)=>t<(B?.numOfSelectedProducts??4)),eS=i(()=>X&&M&&Q||!eN.length&&!ef&&q&&Q,[q,ef,X,M,Q,eN.length]),eC=i(()=>!eN||X&&M,[X,M,eN]),eE=i(()=>{if(!G?.sameHeight)return[];let e=0,t=Math.ceil((eN?.length??0)/+(G?.slidesToShow?.[D]??1));return Array.from(Array(eN?.length??0)).map((o,r)=>(r>=+(G?.slidesToShow?.[D]??1)*(e+1)&&++e,{gridRow:`${1+_*e}/${_+1+_*e}`,marginBottom:e+1<t?L(j?.horizontalGutter,D):void 0}))},[G?.sameHeight,G?.slidesToShow,_,eN?.length,D,j?.horizontalGutter]),ew=i(()=>eP||ef||eb||!eN||X&&M,[eb,ef,X,M,eP,eN]);a(()=>{ew||setTimeout(()=>{let{builderData:e}=x??{},t=e?.childrens?.[0];if(!t)return;let o=document.querySelector(`[data-id=${t}] div`);o&&V(o.childElementCount||1)},Q?0:500)},[x,ew,Q]);let eL=i(()=>({collection:ek,products:eN,settings:{loop:G?.loop??{desktop:!1},scrollMode:G?.scrollMode??{desktop:"snap"},slidesToShow:G?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:j?.layout,dot:G?.dot,dotStyle:G?.dotStyle,arrow:G?.arrow,controlOverContent:G?.controlOverContent},styles:{horizontalGutter:j?.horizontalGutter,verticalGutter:j?.verticalGutter,fullWidth:j?.fullWidth,spacing:j?.spacing,width:j?.width,height:j?.height}}),[ek,eN,G,j]);if(x?.isPreview&&Z)return e(t,{});if(eS)return e(t,{children:C(q,e(ProductNotFound,{builderAttrs:A,collectionHandle:ek?.handle,productSrc:et,onClose:()=>U(!1),children:W,relatedTagString:F,assignProductNoTags:en,noAssignedProduct:!eo}))});let{productListWrapStyle:eW,productListContentStyle:ej,productListWrapAlignStyle:ex}=S(r),{productListWrapClass:eG}=E(r),eA=()=>e(t,{children:C(j?.layout==="grid",e(O,{...r,productSortedById:eN,generateGridRowArray:eE}),e(N,{...r,productSortedById:eN}))});return o("div",{...A,className:eG,style:eW,children:[!!j?.preloadBgImage&&o(v,{children:[!!j.backgroundImage?.desktop?.image?.src&&e("link",{rel:"preload",href:j.backgroundImage.desktop.image.src,as:"image"}),!!j.backgroundImage?.tablet?.image?.src&&e("link",{rel:"preload",href:j.backgroundImage?.tablet?.image?.src,as:"image"}),!!j.backgroundImage?.mobile?.image?.src&&e("link",{rel:"preload",href:j.backgroundImage?.mobile?.image?.src,as:"image"})]}),eP||ef?e(d,{}):eb?o("div",{children:["Error: ",eb?.message]}):eC?e("div",{children:"Products not found"}):e(I,{...eL,children:e("div",{className:"gp-flex gp-w-full",style:ex,children:o("div",{style:ej,children:[Z&&e(y,{}),eA()]})})}),T(W,!0)]})};export{ProductList as default};
@@ -1 +1 @@
1
- import{useRef as e,useMemo as r}from"react";import{useTransition as t}from"../../product-variants/common/common.js";import{useEditorMode as c,useQuantity as i,useCurrentVariant as a,useProductBundleDiscount as n,useInteraction as o,useProduct as u,useShopStore as p,useFormatMoney as d}from"@gem-sdk/core";let useGpPrice=l=>{let{setting:m,builderProps:s}=l,g=e(null),b=c(),{quantity:h,hasUpdatePrice:y}=i(),P=a(),{useProductCompareAtPrice:v}=n(),f=l["bundle-item"],w=P?.price??0,V=P?.salePrice??0,k=m?.priceType==="compare",{trigger:q}=o(),T=u(),x=T?.baseID?.replace("gid://shopify/Product/",""),C=p(e=>e.showPriceCurrency),E=r(()=>f?.quantity?f.quantity:y&&h||1,[h,y,f?.quantity]),G=r(()=>{let e=Number(f?.discountValue);return f?.discountType==="percentage"?w*E*e/100:e},[f?.discountType,f?.discountValue,w,E]),$=r(()=>f?.discountValue?v?(V||w)*E:w*E:V*E,[f?.discountValue,w,E,V,v]),j=r(()=>{let e=w*E;return k?$:G?Math.max(0,e-G):e},[w,E,G,$,k]),D=(e,r)=>{q({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${s?.uid}"]`,element:g.current}),q({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${s?.uid}"]`,element:g.current})};t(e=>{e!==w&&D(w,"price")},[w]),t(e=>{e!==V&&D(V,"compare")},[V]);let I=()=>{if("edit"!==b)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:s?.uid,value:!j&&k,tag:"ProductPrice"}});window.dispatchEvent(e)},M=d(j??0,C||!1),N=k&&!j,z="edit"!==b&&N;return{elementRef:g,moneyFormatted:M,currentProductId:x,isNoComparePrice:N,isNoComparePriceILP:z,emitNoDataSignal:I}};export{useGpPrice};
1
+ import{useRef as e,useMemo as r}from"react";import{useTransition as t}from"../../product-variants/common/common.js";import{useEditorMode as c,useQuantity as i,useCurrentVariant as a,useProductBundleDiscount as n,convertDecimalToNumber as o,useInteraction as u,useProduct as p,useShopStore as d,useFormatMoney as l}from"@gem-sdk/core";let useGpPrice=m=>{let{setting:s,builderProps:g}=m,b=e(null),h=c(),{quantity:y,hasUpdatePrice:P}=i(),v=a(),{useProductCompareAtPrice:f}=n(),w=m["bundle-item"],V=o(v?.price)??0,k=o(v?.salePrice)??0,q=s?.priceType==="compare",{trigger:T}=u(),x=p(),C=x?.baseID?.replace("gid://shopify/Product/",""),E=d(e=>e.showPriceCurrency),G=r(()=>w?.quantity?w.quantity:P&&y||1,[y,P,w?.quantity]),$=r(()=>{let e=Number(w?.discountValue);return w?.discountType==="percentage"?V*G*e/100:e},[w?.discountType,w?.discountValue,V,G]),j=r(()=>w?.discountValue?f?(k||V)*G:V*G:k*G,[w?.discountValue,V,G,k,f]),D=r(()=>{let e=V*G;return q?j:$?Math.max(0,e-$):e},[V,G,$,j,q]),I=(e,r)=>{T({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${g?.uid}"]`,element:b.current}),T({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${g?.uid}"]`,element:b.current})};t(e=>{e!==V&&I(V,"price")},[V]),t(e=>{e!==k&&I(k,"compare")},[k]);let M=()=>{if("edit"!==h)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:g?.uid,value:!D&&q,tag:"ProductPrice"}});window.dispatchEvent(e)},N=l(D??0,E||!1),z=q&&!D,A="edit"!==h&&z;return{elementRef:b,moneyFormatted:N,currentProductId:C,isNoComparePrice:z,isNoComparePriceILP:A,emitNoDataSignal:M}};export{useGpPrice};
@@ -0,0 +1,41 @@
1
+ import{template as e}from"@gem-sdk/core";import{Liquid as s,LiquidIf as i}from"@gem-sdk/system";import{OPTION_VALUES_DELIMITER as n}from"./common/const.js";let renderOptionValuesNewFormatSwatches=t=>{let{renderVariantItem:o,variantPresetsLiquid:r}=t;return e`
2
+ ${s("{%- assign optionRendered = false -%}")}
3
+ ${s("{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}")}
4
+
5
+ ${s(`{% for swatch in swatches %}
6
+ {%- assign optionTitle = swatch.optionTitle -%}
7
+ {%- assign optionType = swatch.optionType -%}
8
+ {%- assign labelsString = "" -%}
9
+ {%- assign colorArraysString = "" -%}
10
+ {%- assign imageUrlsString = "" -%}
11
+
12
+ {% for optionValue in swatch.optionValues %}
13
+ {%- assign labelsString = labelsString | append: optionValue.label | append: '${n}' -%}
14
+ {%- assign colorsJoined = optionValue.colors | join: '${n}' -%}
15
+ {%- assign colorArraysString = colorArraysString | append: colorsJoined | append: '${n}' -%}
16
+ {%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: '${n}' -%}
17
+ {% endfor %}
18
+
19
+ {%- assign labels = labelsString | split: '${n}' | slice: 0, labelsString.size -%}
20
+ {%- assign colorStrings = colorArraysString | split: '${n}' | slice: 0, colorArraysString.size -%}
21
+ {%- assign imageUrls = imageUrlsString | split: '${n}' | slice: 0, imageUrlsString.size -%}
22
+
23
+ {% if optionTitle == option.name %}
24
+ {%- assign variantPresetString = "${r}" -%}
25
+ {%- assign optionName = option.name | replace: "'", "'" | replace: '"', '"' -%}
26
+ {%- assign items = variantPresetString | split: '($2)' -%}
27
+ {%- assign type = 'dropdown' -%}
28
+
29
+ {% for item in items %}
30
+ {%- assign itemPreset = item | split: '($1)' -%}
31
+ {% if itemPreset[0] == optionName %}{%- assign type = itemPreset[1] -%}{% endif %}
32
+ {% if itemPreset[0] == 'base' %}{%- assign type = itemPreset[1] -%}{% endif %}
33
+ {% endfor %}
34
+ {%- assign optionRendered = true -%}
35
+
36
+ ${o({showDropdown:!0})}
37
+ {% endif %}
38
+ {% endfor %}`)}
39
+
40
+ ${i("optionRendered == false",o({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
41
+ `};export{renderOptionValuesNewFormatSwatches};
@@ -0,0 +1,66 @@
1
+ import{Liquid as e,LiquidFor as s,LiquidIf as t}from"@gem-sdk/system";import{template as i}from"@gem-sdk/core";let renderOptionValuesOld=a=>{let{renderVariantItem:n,variantPresetsLiquid:o}=a;return i`
2
+ ${e("{%- assign optionRendered = false -%}")}
3
+ ${e("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
4
+ ${e("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
5
+
6
+ ${s("swatchesItem in swatchesItems",`
7
+ ${e('{%- assign colorArraysString = "" -%}')}
8
+ ${e('{%- assign labelsString = "" -%}')}
9
+ ${e('{%- assign imageUrlsString = "" -%}')}
10
+ ${e("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
11
+
12
+ ${s("attrItem in attrItems",`
13
+ ${e("{%- assign attrs = attrItem | split: '($2)' -%}")}
14
+ ${e("{%- assign optionKey = attrs[0] -%}")}
15
+ ${e("{%- assign optionValue = attrs[1] -%}")}
16
+ ${e(`
17
+ {% if optionKey == 'optionTitle' %}
18
+ {% assign optionTitle = optionValue %}
19
+ {% elsif optionKey == 'optionType' %}
20
+ {% assign optionType = optionValue %}
21
+ {% endif %}
22
+ `)}
23
+
24
+ ${t('optionKey == "optionValues"',`
25
+ ${e("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
26
+ ${s("opValueItem in opValueItems",`
27
+ ${e("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
28
+ ${s("opValueItemAttr in opValueItemAttrs",`
29
+ ${e("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
30
+ ${e("{%- assign opValueItemKey = attrs[0] -%}")}
31
+ ${e("{%- assign opValueItemValue = attrs[1] -%}")}
32
+
33
+ ${t('opValueItemKey == "label"',`${e("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}
34
+ ${e('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
35
+
36
+ ${t('opValueItemKey == "colors"',`${e("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}
37
+ ${e('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
38
+
39
+ ${t('opValueItemKey == "imageUrl"',`${e("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}
40
+ ${e('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}
41
+ `)}
42
+ `)}
43
+ `)}
44
+ `)}
45
+
46
+ ${e("{%- assign labels = labelsString | split: '($8)' -%}")}
47
+ ${e("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
48
+ ${e("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
49
+
50
+ ${t("optionTitle == option.name",`
51
+ ${e(`{%- assign variantPresetString = "${o}" -%}`)}
52
+ ${e('{%- assign optionName = option.name | replace: "\'", "&apos;" | replace: \'"\', "&quot;" -%}')}
53
+ ${e("{%- assign items = variantPresetString | split:'($2)' -%}")}
54
+ ${e("{%- assign type = 'dropdown' -%}")}
55
+ ${s("item in items",`
56
+ ${e("{%- assign itemPreset = item | split:'($1)' -%}")}
57
+ ${t("itemPreset[0] == optionName",e("{%- assign type = itemPreset[1] -%}"))}
58
+ ${t('itemPreset[0] == "base"',e("{%- assign type = itemPreset[1] -%}"))}
59
+ `)}
60
+ ${e("{%- assign optionRendered = true -%}")}
61
+ ${n({showDropdown:!0})}
62
+ `)}
63
+ `)}
64
+
65
+ ${t("optionRendered == false",n({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
66
+ `};export{renderOptionValuesOld};
@@ -1,8 +1,10 @@
1
- import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as i,isLocalEnv as a,baseAssetURL as o}from"@gem-sdk/core";import n from"../../../text/components/Text.liquid.js";import r from"./components/variants/index.liquid.js";import p from"./components/dropdown-swatches/Dropdown.liquid.js";import l from"./components/dropdown-group/DropdownGroup.liquid.js";import{getSettingPreloadData as m}from"../../../helpers.js";import{mappingVariantStyles as d}from"./utils/mappingVariantStyles.js";import{createClass as c,createStyle as u,createStateOrContext as g,createAttr as $,Liquid as v,LiquidFor as f,LiquidIf as y,If as _}from"@gem-sdk/system";import{getAttrs as h}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as S,getWrapperStyle as V}from"./common/main/styles.js";import{getVariantOptionGroupClass as j,getWrapDropdownClass as I}from"./common/main/classes.js";import{getTextVariantTitleData as b,getDropdownGroupData as w}from"./common/main/getData.js";import{getWrapVariantOptionClass as A}from"./common/variants/classes.js";import{getStyleOfObject as P}from"../../helpers/function.js";import{getMarginBottomStyle as T}from"./common/variants/styles.js";let DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=N=>{let{builderProps:D,styles:x,setting:E,advanced:O}=N,{align:U,swatchItemWidth:C,dropdownItemWidth:K,swatchSpacing:q,optionTypo:k,marginBottom:F}=x??{},{label:G,optionType:J,showAsSwatches:L,layout:R,hasPreSelected:W}=E??{},z=O?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:H}=D??{},M="groupOption"===J,Q=()=>{let e={};return s.forEach(t=>{let s=i(C,t);e[t]="auto"===s}),e},Y=()=>{let e={};return s.forEach(t=>{e[t]=K?.[t]==="fill"}),e},B=e(()=>{let e=d(E?.variantPresets,x);return{...E,variantPresets:e}},[E?.variantPresets,x]),X=e=>{let t={"'":"&apos;",'"':"&quot;"},s=e;for(let i in t)e.indexOf(i)>=0&&(s=s.replaceAll(i,t[i]));return s},Z=()=>E?.variantPresets?.map(e=>`${X(e.optionName)}($2)${e.optionType}`).join("($1)"),ee=()=>E?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),et=c(j(U)),es=u(S(q,q)),ei=b(N,"Liquid"),ea=c(A(R,U)),eo=()=>t`
2
- ${v(`{%- assign presets = "${Z()}" | split: '($1)' -%}`)}
3
- ${v(`{% assign hiddenPresetOptions = "${ee()}" | split: ',' %}`)}
1
+ import{template as e,isLocalEnv as t,baseAssetURL as s,DEVICES as i,getResponsiveValueByScreen as o}from"@gem-sdk/core";import a from"../../../text/components/Text.liquid.js";import n from"./components/variants/index.liquid.js";import r from"./components/dropdown-swatches/Dropdown.liquid.js";import p from"./components/dropdown-group/DropdownGroup.liquid.js";import{getSettingPreloadData as l}from"../../../helpers.js";import{mappingVariantStyles as d}from"./utils/mappingVariantStyles.js";import{createClass as m,createStyle as c,createAttr as u,Liquid as f,LiquidIf as v,If as $,LiquidFor as _}from"@gem-sdk/system";import{getAttrs as g}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as h,getWrapperStyle as y}from"./common/main/styles.js";import{getVariantOptionGroupClass as j,getWrapDropdownClass as w}from"./common/main/classes.js";import{getTextVariantTitleData as S,getDropdownGroupData as A}from"./common/main/getData.js";import{getWrapVariantOptionClass as P}from"./common/variants/classes.js";import{getStyleOfObject as D}from"../../helpers/function.js";import{getMarginBottomStyle as V}from"./common/variants/styles.js";import{renderOptionValuesNewFormatSwatches as b}from"./OptionVariantsNewFormat.liquid.js";import{renderOptionValuesOld as E}from"./OptionVariantsOldFormat.liquid.js";let DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=N=>{let{builderProps:T,styles:O,setting:x,advanced:q}=N,{align:G,swatchItemWidth:C,dropdownItemWidth:F,swatchSpacing:I,optionTypo:k,marginBottom:L}=O??{},{label:J,optionType:z,showAsSwatches:M,layout:U,hasPreSelected:W}=x??{},R=q?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:Y}=T??{},H="groupOption"===z,K=()=>{let e={};return i.forEach(t=>{let s=o(C,t);e[t]="auto"===s}),e},Q=()=>{let e={};return i.forEach(t=>{e[t]=F?.[t]==="fill"}),e},B=x?.variantPresets?d(x?.variantPresets,O):[],X=B?.map(e=>({...e,presets:{[e.optionType]:e.presets[e.optionType]}})),Z={...x,variantPresetsOptionType:X},ee=e=>{let t={"'":"&apos;",'"':"&quot;"},s=e;for(let i in t)e.indexOf(i)>=0&&(s=s.replaceAll(i,t[i]));return s},et=()=>x?.variantPresets?.map(e=>`${ee(e.optionName)}($2)${e.optionType}`).join("($1)"),es=()=>x?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),ei=({showDropdown:t,isRenderDefault:s,typeOfOption:i})=>e`
2
+ ${_("value in values",n({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:M,uid:Y,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:i,activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...O,...Z,swatchAutoWidth:K(),optionTypo:k,isRenderDefault:s}))}
3
+ ${v(t?'type == "dropdown"':"false",r({...O,...Z,swatchAutoWidth:Q(),optionTypo:k}))}`,eo=x?.variantPresets?.map(e=>({name:ee(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),ea={renderVariantItem:ei,variantPresetsLiquid:eo??""},en=m(j(G)),er=c(h(I,I)),ep=S(N,"Liquid"),el=m(P(U,G)),ed=()=>e`
4
+ ${f(`{%- assign presets = "${et()}" | split: '($1)' -%}`)}
5
+ ${f(`{% assign hiddenPresetOptions = "${es()}" | split: ',' %}`)}
4
6
 
5
- ${v(`{% assign all_option_names = options | map: 'name' %}
7
+ ${f(`{% assign all_option_names = options | map: 'name' %}
6
8
  {% assign filtered_options_string = '' %}
7
9
  {% assign delimiter = '||' %}
8
10
 
@@ -25,29 +27,29 @@ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as
25
27
 
26
28
  {% assign filtered_options_array = filtered_options_string | split: delimiter %}`)}
27
29
 
28
- ${v("{% assign last_option_name = filtered_options_array | last %}")}
30
+ ${f("{% assign last_option_name = filtered_options_array | last %}")}
29
31
 
30
- ${f("option in options",`
32
+ ${_("option in options",`
31
33
  <div
32
34
  option-name="{{option.name | escape}}"
33
- class="${ea} ${y("hiddenPresetOptions contains option.name","gp-hidden")}"
34
- style="${P(T(F))}${v("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
35
+ class="${el} ${v("hiddenPresetOptions contains option.name","gp-hidden")}"
36
+ style="${D(V(L))}${f("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
35
37
  >
36
- ${v("{%- assign showVariantClass = 'variant-display' -%}")}
37
- ${v("{%- assign optionName = option.name -%}")}
38
- ${f("preset in presets",`
39
- ${v("{%- assign presetDetail = preset | split: '($2)' -%}")}
40
- ${y("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${v("{%- assign showVariantClass = '' -%}")} ${v("{%- break -%}")}`)}
38
+ ${f("{%- assign showVariantClass = 'variant-display' -%}")}
39
+ ${f("{%- assign optionName = option.name -%}")}
40
+ ${_("preset in presets",`
41
+ ${f("{%- assign presetDetail = preset | split: '($2)' -%}")}
42
+ ${v("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${f("{%- assign showVariantClass = '' -%}")} ${f("{%- break -%}")}`)}
41
43
  `)}
42
- ${_(G,n(ei)," ")}
44
+ ${$(J,a(ep)," ")}
43
45
  <div
44
46
  variant-option-name="{{option.name | escape}}"
45
- class="${et}"
46
- style="${P(es)}"
47
+ class="${en}"
48
+ style="${D(er)}"
47
49
  >
48
- ${v("{%- assign values = option.values -%}")}
49
- ${v("{%- assign rootForloop = forloop.index0 -%}")}
50
- ${v(`
50
+ ${f("{%- assign values = option.values -%}")}
51
+ ${f("{%- assign rootForloop = forloop.index0 -%}")}
52
+ ${f(`
51
53
  {%- if option.position == 1 -%}
52
54
  {%- assign selectedValue = variant.option1 -%}
53
55
  {%- elsif option.position == 2 -%}
@@ -56,78 +58,22 @@ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as
56
58
  {%- assign selectedValue = variant.option3 -%}
57
59
  {%- endif -%}
58
60
  `)}
59
- ${_(!W,v("{%- assign selectedValue = null -%}"),"")}
60
- ${_(L,er(),ep())}
61
+ ${$(!W,f("{%- assign selectedValue = null -%}"),"")}
62
+ ${$(M,em(),ei({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
61
63
  </div>
62
64
  </div>`)}
63
- `,en=E?.variantPresets?.map(e=>({name:X(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),er=()=>t`
64
- ${v("{%- assign optionRendered = false -%}")}
65
- ${v("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
66
- ${v("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
67
-
68
- ${f("swatchesItem in swatchesItems",`
69
- ${v('{%- assign colorArraysString = "" -%}')}
70
- ${v('{%- assign labelsString = "" -%}')}
71
- ${v('{%- assign imageUrlsString = "" -%}')}
72
- ${v("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
73
-
74
- ${f("attrItem in attrItems",`${v("{%- assign attrs = attrItem | split: '($2)' -%}")}
75
- ${v("{%- assign optionKey = attrs[0] -%}")}
76
- ${v("{%- assign optionValue = attrs[1] -%}")}
77
- ${v(`
78
- {% if optionKey == 'optionTitle' %}
79
- {% assign optionTitle = optionValue %}
80
- {% elsif optionKey == 'optionType' %}
81
- {% assign optionType = optionValue %}
82
- {% endif %}
83
- `)}
84
-
85
- ${y("optionKey == 'optionValues'",`${v("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
86
- ${f("opValueItem in opValueItems",`${v("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
87
- ${f("opValueItemAttr in opValueItemAttrs",`${v("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
88
- ${v("{%- assign opValueItemKey = attrs[0] -%}")}
89
- ${v("{%- assign opValueItemValue = attrs[1] -%}")}
90
-
91
- ${y("opValueItemKey == 'label'",`${v("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}${v('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
92
-
93
- ${y("opValueItemKey == 'colors'",`${v("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}${v('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
94
-
95
- ${y("opValueItemKey == 'imageUrl'",`${v("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}${v('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}`)}`)}`)}
96
- `)}
97
-
98
- ${v("{%- assign labels = labelsString | split: '($8)' -%}")}
99
- ${v("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
100
- ${v("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
101
-
102
- ${y("optionTitle == option.name",`
103
- ${v(`{%- assign variantPresetString = "${en}" -%}`)}
104
- ${v('{%- assign optionName = option.name | replace: "\'", "&apos;" | replace: \'"\', "&quot;" -%}')}
105
- ${v("{%- assign items = variantPresetString | split:'($2)' -%}")}
106
- ${v("{%- assign type = 'dropdown' -%}")}
107
- ${f("item in items",`
108
- ${v("{%- assign itemPreset = item | split:'($1)' -%}")}
109
- ${y("itemPreset[0] == optionName",v("{%- assign type = itemPreset[1] -%}"))}
110
- ${y('itemPreset[0] == "base"',v("{%- assign type = itemPreset[1] -%}"))}
111
- `)}
112
- ${v("{%- assign optionRendered = true -%}")}
113
- ${f("value in values",r({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:L,uid:H,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",optionType:"optionType",activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...x,...B,swatchAutoWidth:Q(),optionTypo:k}))}
114
- ${y("type == 'dropdown'",p({...x,...B,swatchAutoWidth:Y(),optionTypo:k}))}
115
- `)}
116
- `)}
117
-
118
- ${y("optionRendered == false",ep())}
119
- `,ep=()=>f("value in values",r({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:L,uid:H,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...x,...B,swatchAutoWidth:Q(),optionTypo:k,isRenderDefault:!0})),el=c(I(U)),em=w(N),ed=()=>`
120
- <div className="${el}">
121
- ${l(em)}
65
+ `,em=()=>e`
66
+ ${v("shop.metafields.GEMPAGES.swatches and shop.metafields.GEMPAGES.swatchesJSONFormat != blank",b(ea),E(ea))}
67
+ `,ec=m(w(G)),eu=A(N),ef=()=>`
68
+ <div className="${ec}">
69
+ ${p(eu)}
122
70
  </div>
123
- `;g({setting:B,styles:JSON.stringify(x),variants:"{{ product.variants | json | escape }}",optionsWithValues:"{{ product.options_with_values | json | escape }}",variantSelected:"{{ variant | json | escape }}",variantInventoryQuantity:"{{ product.variants | map: 'inventory_quantity' | json | escape }}",variantInventoryPolicy:"{{ product.variants | map: 'inventory_policy' | json | escape }}",moneyFormat:"{{ shop.money_format | json | escape }}",productId:"{{ product.id | json | escape }}",productUrl:"{{ product.url | json | escape }}",productHandle:"{{ product.handle | json | escape }}",displayState:`${JSON.stringify(z)}`,totalVariantCombinations:"{{ total_combinations }}",firstAvailableVariant:"{{ product.selected_or_first_available_variant | json | escape }}"});let ec=$(h({uid:H,hasPreSelected:W,cssClass:O?.cssClass})),eu=u(V(N)),eg=c({"gp-flex gp-flex-col !gp-ml-0":!0}),e$=()=>{let e=a?"{{ 'gp-product-variant-v7-5.js' | asset_url }}":`${o}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${m('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return t`
124
- ${v("{%- assign total_combinations = 1 -%}")}
125
- ${f("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
71
+ `,ev=u(g({uid:Y,hasPreSelected:W,cssClass:q?.cssClass})),e$=c(y(N)),e_=m({"gp-flex gp-flex-col !gp-ml-0":!0}),eg=()=>{let e=t?"{{ 'gp-product-variant-v7-5.js' | asset_url }}":`${s}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${l('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return e`
126
72
  <gp-product-variants
127
- ${ec}
73
+ ${ev}
128
74
  gp-data='{
129
- "setting":${JSON.stringify(B)?.replaceAll("'","&#039;")},
130
- "styles":${JSON.stringify(x)},
75
+ "setting":${JSON.stringify(Z)?.replaceAll("'","&#039;")},
76
+ "styles":${JSON.stringify(O)},
131
77
  "variants":{{product.variants | json | escape}},
132
78
  "optionsWithValues": {{product.options_with_values | json | escape}},
133
79
  "variantSelected": {{ variant | json | escape }},
@@ -137,21 +83,21 @@ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as
137
83
  "productId": {{product.id | json | escape}},
138
84
  "productUrl": {{product.url | json | escape}},
139
85
  "productHandle": {{product.handle | json | escape}},
140
- "displayState": ${JSON.stringify(z)},
86
+ "displayState": ${JSON.stringify(R)},
141
87
  "totalVariantCombinations": {{total_combinations}},
142
88
  "firstAvailableVariant": {{product.selected_or_first_available_variant | json | escape}}
143
89
  }
144
90
  '>
145
91
  <div class="gp-hidden" style="--hvr-shadow: none; --hvr-shadow-tablet: none; --hvr-shadow-mobile: none"></div>
146
- ${v("{%- assign options = product.options_with_values -%}")}
147
- ${v("{%- assign variants = product.variants -%}")}
148
- ${y("options.size == 0 or options.size == 1 and variants.size == 1 and variants[0].title == 'Default Title' and variants[0].option1 == 'Default Title'","<div></div>",t`<div
149
- class="${eg}"
150
- style="${eu}"
92
+ ${f("{%- assign options = product.options_with_values -%}")}
93
+ ${f("{%- assign variants = product.variants -%}")}
94
+ ${v("options.size == 0 or options.size == 1 and variants.size == 1 and variants[0].title == 'Default Title' and variants[0].option1 == 'Default Title'","<div></div>",e`<div
95
+ class="${e_}"
96
+ style="${e$}"
151
97
  >
152
- ${_(M,ed(),eo())}
98
+ ${$(H,ef(),ed())}
153
99
  </div>`)}
154
100
  </gp-product-variants>
155
101
 
156
- ${e$()}
102
+ ${eg()}
157
103
  `};export{ProductVariants as default};
@@ -1 +1 @@
1
- import{composeTypographyStyle as e,getRadiusStyleActiveState as t,getStyleShadow as o,makeStyle as r,getSingleColorVariable as l,composeRadius as i,getGlobalColorStateStyle as p,handleConvertBorderStyle as a,handleConvertBorderWidth as n,handleConvertBorderColor as d,makeStyleResponsive as h}from"@gem-sdk/core";import{filterTruthyObject as c}from"../../../../../helpers.js";let getColorStyleWidth=e=>{let t=e?.height||"32px",o=e?.width||{desktop:t},r=Object.fromEntries(Object.entries(o).map(([e,o])=>{let r=o&&"undefined"!==o&&"auto"!==o?o:t;return[e,r]}));return h("minw",r)},getWrapperStyleActive=i=>{let{preset:p,optionTypography:a,optionTypo:n,typeOfOption:d}=i,h=p?.optionBgColor,g=p?.optionTextColor,s=p?.optionBorder,b=p?.optionHasShadow,m=p?.optionShadow,u=p?.optionRounded,w="color"===d,x="image"===d||"image_shopify"===d,y=e(n,a),S=e=>{let t=h?.active??h?.normal,o=s?.active??s?.normal;return r({bg:e&&l(t),bs:o?.border,bw:o?.width,bc:l(o?.color)})},v=m?.active??m?.normal,C=b?.active??b?.normal,f=g?.active??g?.normal;return c({...S(!w),...t(u),...o({value:v,state:"active",styleAppliedFor:"box-shadow",isEnableShadow:C},!0),...y,...!w&&!x&&r({c:l(f)}),...w&&getColorStyleWidth(p),...r({h:p?.height})})},getWrapperStyleNormalAndHover=e=>{let{preset:t,optionTransform:l,optionTypography:h,optionTypo:g,typeOfOption:s}=e,b=t?.optionBgColor,m=t?.optionTextColor,u=t?.optionBorder,w=t?.optionHasShadow,x=t?.optionShadow,y=t?.optionRounded,S="color"===s,v="image"===s||"image_shopify"===s,C=["normal","hover"].reduce((e,t)=>({...e,...o({value:x?.[t],state:t,styleAppliedFor:"box-shadow",isEnableShadow:w?.[t]})}),{});return c({...i(y),...C,...!S&&p("bg",b),...!S&&a(u),...!S&&n(u),...!S&&d(u),...!S&&!v&&r({c:l}),...!S&&!v&&p("c",m),...typoStyleNotIn(g,h,["--c"]),...S&&getColorStyleWidth(t),...r({h:t?.height})})};function typoStyleNotIn(t,o,r){let l=e(t,o);return r&&0!==r.length?Object.fromEntries(Object.entries(l).filter(([e])=>!r.includes(e))):l}let getWrapperTextStyle=e=>{let{preset:o,typeOfOption:r,checked:l}=e,p=o?.optionBorder,h=o?.optionRounded,g="color"===r,s=()=>{let e="16px",t={"--pl":"0px","--pr":"0px","--pl-tablet":"0px","--pr-tablet":"0px","--pl-mobile":"0px","--pr-mobile":"0px","--pt":"0px","--pb":"0px"};return o?.width?.desktop?.toLowerCase()!=="auto"&&o?.width?.desktop||(t["--pl"]=e,t["--pr"]=e),o?.width?.tablet?.toLowerCase()!=="auto"&&o?.width?.tablet||(t["--pl-tablet"]=e,t["--pr-tablet"]=e),o?.width?.mobile?.toLowerCase()!=="auto"&&o?.width?.mobile||(t["--pl-mobile"]=e,t["--pr-mobile"]=e),(o?.height?.toLowerCase()==="auto"||o?.height)&&(t["--pt"]="8px",t["--pb"]="8px"),t},b={...h,active:{...h?.active||{},radiusType:"custom"}},m=l?t(b):i(h),u=!l&&g?{...a(p),...n(p),...d(p)}:{};return c({...!g&&s(),...g&&m,...u})},getColorStyle=({optionBorder:e,optionRounded:t,isActive:o,color:r})=>{let l=()=>r?r?.startsWith("linear-gradient")?{backgroundImage:r}:{backgroundColor:r}:{},p=t=>t?{"--bs":"none"}:a(e),h=o=>({"--d":"flex","--jc":"center"," --ai":"center","--w":"100%","--h":"100%","--of":"hidden",...p(o),...n(e),...d(e),...i(t),...l()});return h(!!o)},getTextStyle=({optionTypo:t,optionTypography:o})=>{let r=e(t,o);return delete r["--c"],c({...r})};export{getColorStyle,getTextStyle,getWrapperStyleActive,getWrapperStyleNormalAndHover,getWrapperTextStyle};
1
+ import{composeTypographyStyle as e,getRadiusStyleActiveState as t,getStyleShadow as o,makeStyle as r,getSingleColorVariable as l,composeRadius as i,getGlobalColorStateStyle as p,handleConvertBorderStyle as a,handleConvertBorderWidth as n,handleConvertBorderColor as d,makeStyleResponsive as h}from"@gem-sdk/core";import{filterTruthyObject as c}from"../../../../../helpers.js";let getColorStyleWidth=e=>{let t=e?.height||"32px",o=e?.width||{desktop:t},r=Object.fromEntries(Object.entries(o).map(([e,o])=>{let r=o&&"undefined"!==o&&"auto"!==o?o:t;return[e,r]}));return h("minw",r)},getWrapperStyleActive=i=>{let{preset:p,optionTypography:a,optionTypo:n,typeOfOption:d}=i,h=p?.optionBgColor,s=p?.optionTextColor,g=p?.optionBorder,b=p?.optionHasShadow,m=p?.optionShadow,u=p?.optionRounded,w="color"===d,x="image"===d||"image_shopify"===d,y=e(n,a),S=e=>{let t=h?.active??h?.normal,o=g?.active??g?.normal;return r({bg:e&&l(t),bs:o?.border,bw:o?.width,bc:l(o?.color)})},v=m?.active??m?.normal,C=b?.active??b?.normal,f=s?.active??s?.normal;return c({...S(!w),...t(u),...o({value:v,state:"active",styleAppliedFor:"box-shadow",isEnableShadow:C},!0),...y,...!w&&!x&&r({c:l(f)}),...w&&getColorStyleWidth(p),...r({h:p?.height})})},getWrapperStyleNormalAndHover=e=>{let{preset:t,optionTransform:l,optionTypography:h,optionTypo:s,typeOfOption:g}=e,b=t?.optionBgColor,m=t?.optionTextColor,u=t?.optionBorder,w=t?.optionHasShadow,x=t?.optionShadow,y=t?.optionRounded,S="color"===g,v="image"===g||"image_shopify"===g,C=["normal","hover"].reduce((e,t)=>({...e,...o({value:x?.[t],state:t,styleAppliedFor:"box-shadow",isEnableShadow:w?.[t]})}),{});return c({...i(y),...C,...!S&&p("bg",b),...!S&&a(u),...!S&&n(u),...!S&&d(u),...!S&&!v&&r({c:l}),...!S&&!v&&p("c",m),...typoStyleNotIn(s,h,["--c"]),...S&&getColorStyleWidth(t),...r({h:t?.height})})};function typoStyleNotIn(t,o,r){let l=e(t,o);return r&&0!==r.length?Object.fromEntries(Object.entries(l).filter(([e])=>!r.includes(e))):l}let getWrapperTextStyle=e=>{let{preset:o,typeOfOption:r,checked:l}=e,p=o?.optionBorder,h=o?.optionRounded,s="color"===r,g=()=>{let e="16px",t={"--pl":"0px","--pr":"0px","--pl-tablet":"0px","--pr-tablet":"0px","--pl-mobile":"0px","--pr-mobile":"0px","--pt":"0px","--pb":"0px"};return o?.width?.desktop?.toLowerCase()!=="auto"&&o?.width?.desktop||(t["--pl"]=e,t["--pr"]=e),o?.width?.tablet?.toLowerCase()!=="auto"&&o?.width?.tablet||(t["--pl-tablet"]=e,t["--pr-tablet"]=e),o?.width?.mobile?.toLowerCase()!=="auto"&&o?.width?.mobile||(t["--pl-mobile"]=e,t["--pr-mobile"]=e),(o?.height?.toLowerCase()==="auto"||o?.height)&&(t["--pt"]="8px",t["--pb"]="8px"),t},b={...h,active:{...h?.active||{},radiusType:"custom"}},m=l?t(b):i(h),u=!l&&s?{...a(p),...n(p),...d(p)}:{};return c({...!s&&g(),...s&&m,...u})},getColorStyle=({optionBorder:e,optionRounded:t,isActive:o,color:r})=>{let l=()=>r?r?.startsWith("linear-gradient")?{backgroundImage:r}:{backgroundColor:r}:{},p=t=>t?{"--bs":"none"}:a(e),h=o=>({"--d":"flex","--jc":"center"," --ai":"center","--w":"100%","--h":"100%","--of":"hidden","--hvr-c":"unset",...p(o),...n(e),...d(e),...i(t),...l()});return h(!!o)},getTextStyle=({optionTypo:t,optionTypography:o})=>{let r=e(t,o);return delete r["--c"],c({...r})};export{getColorStyle,getTextStyle,getWrapperStyleActive,getWrapperStyleNormalAndHover,getWrapperTextStyle};
@@ -0,0 +1 @@
1
+ let OPTION_VALUES_DELIMITER="|||";export{OPTION_VALUES_DELIMITER};