@dropins/storefront-pdp 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/chunks/Zoom.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as H,jsx as L,Fragment as _e}from"@dropins/tools/preact-jsx-runtime.js";import*as J from"@dropins/tools/preact-compat.js";import{useState as k,Children as z,useRef as ae,useMemo as ve,useEffect as B,useCallback as I}from"@dropins/tools/preact-compat.js";import{debounce as be,classes as M}from"@dropins/tools/lib.js";import{Button as he,Icon as Ne}from"@dropins/tools/components.js";/* empty css */import{useText as S}from"@dropins/tools/i18n.js";import{cloneElement as Ee}from"@dropins/tools/preact.js";const We=i=>J.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},J.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Le=i=>J.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},J.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),J.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),ke=24,ye=16,Y=2,De="32";var Ce=(i=>(i[i.small=16]="small",i[i.medium=24]="medium",i[i.large=64]="large",i))(Ce||{});const He=({show:i=1,scrollbar:p=!1,peak:b=!1,arrows:m=!1,controls:l="dots",arrowsOnMainImage:W=!1,loop:n=!1,gap:C=null,direction:P="horizontal",width:N="100%",height:O="100%",defaultIndex:D=0,className:ce,children:E,thumbnails:Z=null,isZoomed:Q,...G})=>{const ee=S("PDP.Carousel.label").label,te=S("PDP.Carousel.Slide.label").label,re=S("PDP.Carousel.Previous.label").label,oe=S("PDP.Carousel.Next.label").label,ie=S("PDP.Carousel.Controls.label").label,se=S("PDP.Carousel.Controls.Button.label").label,[d,ue]=k(()=>we(i)),r=Math.ceil(z.count(E)/d),h=b?ke:0,y=C?Ce[C]:0,x=z.count(E)%d,[a,j]=k(n?w()?D-1:D+1:D),A=ae([]),[R,X]=k(0),[F,Me]=k(0),fe=ve(()=>z.toArray(Z),[Z]),g=ve(()=>{const e=z.toArray(E).reduce((t,s,o)=>o%d===0?[...t,[s]]:[...t.slice(0,-1),[...t[t.length-1],s]],[]);return!n||e.length===1?e:n&&z.count(E)%d===0?[e[r-1]].concat(e).concat([e[0],e[1]]):[z.toArray(E).slice(-d)].concat(e).concat([e[0],e[1]])},[E,d,r,n]),K=ae(null),pe=ae(null),_=l==="thumbnailsRow"||l==="thumbnailsColumn";B(()=>{const e=K.current;if(!e)return;const t=be(()=>{X(e.offsetWidth??0),Me(e.offsetHeight??0);const o=window.innerWidth,u=we(i,o);u!==d&&ue(u)},50),s=new ResizeObserver(t);return s.observe(e),()=>{s.unobserve(e)}},[d,i]);const q=I(e=>{const t=n?e-1:e,s=A==null?void 0:A.current[0],o=(s==null?void 0:s.offsetWidth)+ye,u=(s==null?void 0:s.offsetHeight)+ye,c=pe.current,T=l==="thumbnailsRow",le=l==="thumbnailsColumn",$=T?c==null?void 0:c.offsetWidth:c==null?void 0:c.offsetHeight,f=T?o:u;(T||le)&&$&&(f*(t+1)>$&&(c.style.scrollBehavior="smooth",T?c.scrollLeft=w()?c.scrollWidth-c.clientWidth-(t+Y)*f:(t+Y)*f:c.scrollTop=(t+Y)*f),(w()&&(T?c.scrollLeft:c.scrollTop)<=-f*t||!w()&&(T?c.scrollLeft:c.scrollTop)>f*t)&&(c.style.scrollBehavior="smooth",T?c.scrollLeft=w()?-(t-Y)*f:(t-Y)*f:c.scrollTop=(t-Y)*f))},[l,n]);B(()=>{q(a)},[a,q]);const v=I((e,t,s)=>{_&&q(e);const o=K.current,u=h?o.offsetWidth-h:o.offsetWidth-h+y;if(!Array.from(o.querySelectorAll("[data-index]")).filter($=>{const f=Number($.getAttribute("data-index"));return!isNaN(f)&&f>-1})[e])return;if(s){const $=e===0?r:0,f=u*(r+(x||d)/d);if(w()){if(o.scrollLeft<=0&&o.scrollLeft>-(u-5)){v(1,!0);return}if(o.scrollLeft<u-f&&o.scrollLeft>=-f){v(r,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=$===0?0:-f,v($===0?1:r,!0)}else{if(o.scrollLeft>=0&&o.scrollLeft<u-5){v(1,!0);return}if(o.scrollLeft>f-u&&o.scrollLeft<=f){v(r,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=$===0?0:f,v($===0?1:r,!0);return}}const le=(o.offsetWidth-y)/d*g[e].length-h;o.style.scrollBehavior=t?"smooth":"auto",o.scrollLeft=w()?-(g[e].length===d?u*e:u*(e-1)-le):g[e].length===d?u*e:u*(e-1)+le},[y,r,h,d,x,g,q,l]),U=I(()=>{if(n){const t=a-1;v(t,!0,w()?a===r-1:a===1);return}const e=a<=0?0:a-1;v(e,!0)},[a,v,n]),V=I(()=>{const e=g.length-1;if(n){const s=a+1;v(s,!0,w()?a===0:a===r);return}const t=a>=e?e:a+1;v(t,!0)},[g.length,n,a,v,r]);B(()=>{const e=t=>{t.key==="ArrowLeft"&&(t.preventDefault(),w()?V():U()),t.key==="ArrowRight"&&(t.preventDefault(),w()?U():V())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[V,U]),B(()=>{v(n?D+1:D,!1)},[D,v,n]);const de=be(()=>{const e=K.current,t=h?e.offsetWidth-h:e.offsetWidth-h+y,s=Math.abs(e.scrollLeft)/t,o=Math.abs(Math.round(s)-s<1?Math.round(s):Math.ceil(s));if(_&&q(o),n){const u=t*(r+(x||d)/d),c=w()?-e.scrollLeft:e.scrollLeft;if(Math.ceil(Math.abs(c))>=Math.ceil(u)-5){e.style.scrollBehavior="auto",e.scrollLeft=w()?-e.offsetWidth+(Math.ceil(c)-Math.ceil(u)-h):e.offsetWidth+(Math.ceil(c)-Math.ceil(u)-h);return}if(Math.abs(c)===0){e.style.scrollBehavior="auto",e.scrollLeft=w()?-(u-e.offsetWidth+h):u-e.offsetWidth+h;return}}a!==o&&j(o)},100);B(()=>{const e=K.current;return e==null||e.addEventListener("scroll",de),()=>{e==null||e.removeEventListener("scroll",de)}},[de]);const ne=(e,t,s)=>L(he,{className:M([["pdp-carousel__button",!e],[`pdp-carousel__button--${t}`,!e],[`pdp-carousel__button--${l}`,e]]),style:{"--height":`${F}px`},variant:"tertiary","aria-label":t==="next"?oe:re,onClick:s,disabled:n?!1:t==="next"?a>=g.length-1:a<1,children:L(Ne,{className:M([["pdp-carousel__button__icon",!e],[`pdp-carousel__button__icon--${t}`,!e],[`pdp-carousel__button__icon--${l}--${t}`,e]]),size:De,source:We})}),me=m&&g.length!=1&&ne(_,"prev",U),ge=m&&g.length!=1&&ne(_,"next",V),Pe=m&&g.length!=1&&ne(!1,"prev",U),xe=m&&g.length!=1&&ne(!1,"next",V);return H("div",{role:"region","aria-roledescription":ee,className:M(["pdp-carousel",["pdp-carousel--main-image-controls",W],["pdp-carousel--arrows",m&&!_],[`pdp-carousel--${l}`,_],ce]),style:{"--flex-carousel":l==="thumbnailsColumn"?"row-reverse":"column","--gap":_?"0":"var(--spacing-small)","--width":N},...G,children:[L("div",{ref:K,className:M(["pdp-carousel__wrapper",`pdp-carousel__wrapper--${P}`,["pdp-carousel__wrapper--scrollbar",p],["pdp-carousel__wrapper--peak",b]]),style:{"--total-width":l==="thumbnailsColumn"?"81.6%":"100%","--height":l==="thumbnailsColumn"?"auto":O,"--gap":C?`var(--spacing-${C})`:"0px","--per-page":d},tabIndex:0,children:g.map((e,t)=>{const s=e.length<d;return L("div",{role:"group","aria-roledescription":te,"data-index":t,className:M(["pdp-carousel__slide",`pdp-carousel__slide--${P}`,["pdp-carousel__slide--active",a===t],["pdp-carousel__slide--orphan",s]]),style:{"--length":e.length},children:e},t)})}),!_&&H(_e,{children:[me,ge]}),_&&W&&H(_e,{children:[Pe,xe]}),l&&g.length!=1&&H("div",{className:M([[`pdp-carousel__controls__container--${l}`,_],["pdp-carousel__controls__container--no-arrows",!m||W]]),style:{"--width":l==="thumbnailsRow"?`${R}px`:N,"--height":`${F}px`,"--nr-thumbnails":fe.length},children:[(_||Q)&&!W&&me,L("div",{ref:pe,className:M([[`pdp-carousel__controls__wrapper--${l}`,_],["pdp-carousel__controls__wrapper",_]]),children:L("div",{role:"group","aria-label":ie,className:M(["pdp-carousel__controls",[`pdp-carousel__controls--${l}`,_]]),children:(n?g.slice(0,r):g).map((e,t)=>{const s=n?r:g.length,o=n?a-1===t:a===t;return _?H("label",{className:M(["pdp-carousel__thumbnail__container"]),ref:u=>{u&&(A.current[t]=u)},children:[L("input",{type:"radio",name:"carousel-thumbnails","aria-label":se.replace("{key}",String(t+1)).replace("{total}",String(s)),checked:o&&R!==0,onChange:()=>{v(n?t+1:t,!0)},...G,className:M(["pdp-carousel__thumbnail",["pdp-carousel__thumbnail--selected",o&&R!==0]])}),L("span",{className:M(["pdp-carousel__thumbnail__span"]),children:fe[t]})]},t):L("button",{"aria-label":se.replace("{key}",String(t+1)).replace("{total}",String(s)),onClick:()=>{v(n?t+1:t,!0)},className:M(["pdp-carousel__controls__button",["pdp-carousel__controls__button--active",o]])},t)})})}),(_||Q)&&!W&&ge]})]})};function we(i,p=0){if(typeof i=="number")return i;const{small:b,medium:m,large:l}=i,n=[{breakpoint:1024,value:l},{breakpoint:786,value:m},{breakpoint:0,value:b}].find(({breakpoint:C})=>p>C);return n?n.value:b}function w(){return document.documentElement.dir==="rtl"}const Xe=({centered:i,onClose:p,className:b,children:m,...l})=>{const W=S("PDP.Overlay.Close.label").label,n=ae(null),C=I(()=>{p==null||p()},[p]);return B(()=>{const P=N=>{N.key==="Escape"&&C()};return document.addEventListener("keydown",P),()=>{document.removeEventListener("keydown",P)}},[C]),B(()=>{const P=n.current;P==null||P.focus();const N=document.scrollingElement,O=N.style.overflow;return N.style.overflow="hidden",()=>{N.style.overflow=O}},[]),H("div",{...l,className:M(["pdp-overlay",["pdp-overlay--centered",i],b]),ref:n,role:"dialog","aria-describedby":"overlay-content",tabindex:0,children:[L("div",{className:"pdp-overlay__content",id:"overlay-content",children:m}),L(he,{"aria-label":W,variant:"tertiary",className:"pdp-overlay__close-button",onClick:C,icon:L(Le,{})})]})},Ye=({children:i,scale:p=2,closeButton:b=!0})=>{const[m,l]=k(!1),[W,n]=k("pdp-zoom"),[C,P]=k(!1),[N,O]=k({x:0,y:0}),[D,ce]=k({x:0,y:0}),[E,Z]=k({x:0,y:0}),Q=r=>{!m||r.type!=="touchstart"||(O({x:r.touches[0].clientX,y:r.touches[0].clientY}),ce({x:E.x,y:E.y}),P(!0))},G=r=>{var F;if(!C||r.type!=="touchmove")return;const h=(F=r.currentTarget)==null?void 0:F.getBoundingClientRect(),y=(100-100/p)/2,x=r.touches[0].clientX-N.x,a=r.touches[0].clientY-N.y,j=x*100/(h.width*p),A=a*100/(h.height*p),R=D.x+j,X=D.y+A;Z({x:Math.max(-y,Math.min(R,y))||0,y:Math.max(-y,Math.min(X,y))||0}),r.preventDefault()},ee=r=>{var X;const h=(X=r.currentTarget)==null?void 0:X.getBoundingClientRect(),y=(100-100/p)/2;let x;if("touches"in r)x=r.touches[0];else if(r instanceof MouseEvent)x=r;else return;const a=(x.clientX-h.left)/h.width*100,j=(x.clientY-h.top)/h.height*100,A=(50-a)*(p-1)/p,R=(50-j)*(p-1)/p;Z({x:Math.max(-y,Math.min(A,y))||0,y:Math.max(-y,Math.min(R,y))||0})},te=r=>{if(!C){if(m){if(b&&"touches"in r){Q(r);return}b||l(!1)}else l(!0),ee(r);r.preventDefault()}},re=r=>{if(b&&"touches"in r){G(r);return}m&&ee(r)},oe=()=>{if(b){P(!1);return}l(!1)},ie=r=>{l(!1),r.stopPropagation()},se=m?`scale(${p}) translateX(${E.x}%) translateY(${E.y}%)`:"none",d=S("PDP.Zoom.Close.label").label,ue=Ee(z.only(i),{draggable:!1,style:{"--transform":se}});return B(()=>{n(m?`pdp-zoom ${b?"pdp-zoom--no-effects":"pdp-zoom--zoomed"}`:"pdp-zoom")},[m,b]),H("figure",{className:W,onClick:te,onMouseMove:re,onMouseLeave:oe,onTouchStart:te,onTouchMove:re,onTouchEnd:oe,children:[ue,b&&m&&L(he,{"aria-label":d,variant:"tertiary",className:"pdp-zoom__close-button",icon:L(Le,{}),onClick:ie})]})};export{He as C,Xe as O,Ye as Z};
3
+ import{jsxs as F,jsx as C,Fragment as bt}from"@dropins/tools/preact-jsx-runtime.js";import*as ot from"@dropins/tools/preact-compat.js";import{useState as X,Children as j,useRef as K,useMemo as vt,useEffect as R,useCallback as rt}from"@dropins/tools/preact-compat.js";import{debounce as yt,classes as N}from"@dropins/tools/lib.js";import{Button as mt,Icon as Wt}from"@dropins/tools/components.js";/* empty css */import{useText as A}from"@dropins/tools/i18n.js";import{cloneElement as Et}from"@dropins/tools/preact.js";const kt=c=>ot.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},ot.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Ct=c=>ot.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},ot.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),ot.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),$t=24,wt=16,Xt="32";var Mt=(c=>(c[c.small=16]="small",c[c.medium=24]="medium",c[c.large=64]="large",c))(Mt||{});const Ht=({show:c=1,scrollbar:m=!1,peak:_=!1,arrows:i=!1,controls:n="dots",arrowsOnMainImage:$=!1,loop:l=!1,gap:b=null,direction:M="horizontal",width:W="100%",height:J="100%",defaultIndex:Y=0,className:ct,children:E,thumbnails:Q=null,isZoomed:P,...V})=>{const z=A("PDP.Carousel.label").label,at=A("PDP.Carousel.Slide.label").label,it=A("PDP.Carousel.Previous.label").label,B=A("PDP.Carousel.Next.label").label,ut=A("PDP.Carousel.Controls.label").label,nt=A("PDP.Carousel.Controls.Button.label").label,[h,ht]=X(()=>Lt(c)),g=Math.ceil(j.count(E)/h),L=_?$t:0,q=b?Mt[b]:0,H=j.count(E)%h,[u,ft]=X(l?k()?Y-1:Y+1:Y),e=K([]),[y,x]=X(0),[w,O]=X(0),I=vt(()=>j.toArray(Q),[Q]),f=vt(()=>{const t=j.toArray(E).reduce((r,s,o)=>o%h===0?[...r,[s]]:[...r.slice(0,-1),[...r[r.length-1],s]],[]);return!l||t.length===1?t:l&&j.count(E)%h===0?[t[g-1]].concat(t).concat([t[0],t[1]]):[j.toArray(E).slice(-h)].concat(t).concat([t[0],t[1]])},[E,h,g,l]),S=K(null),Z=K(null),d=n==="thumbnailsRow"||n==="thumbnailsColumn";R(()=>{const t=S.current;if(!t)return;const r=yt(()=>{x(t.offsetWidth??0),O(t.offsetHeight??0);const o=window.innerWidth,a=Lt(c,o);a!==h&&ht(a)},50),s=new ResizeObserver(r);return s.observe(t),()=>{s.unobserve(t)}},[h,c]);const G=rt(t=>{const r=l?t-1:t,s=e==null?void 0:e.current[0],o=(s==null?void 0:s.offsetWidth)+wt,a=(s==null?void 0:s.offsetHeight)+wt,p=Z.current,U=n==="thumbnailsRow",lt=n==="thumbnailsColumn",T=U?p==null?void 0:p.offsetWidth:p==null?void 0:p.offsetHeight,D=U?o:a;if((U||lt)&&T){const Nt=Math.floor((U?p.clientWidth:p.clientHeight)/D),Dt=Math.floor(Nt/2),pt=(r-Dt)*D;p.style.scrollBehavior="smooth",U?p.scrollLeft=k()?-(p.scrollWidth-p.clientWidth-pt):pt:p.scrollTop=pt}},[n,l]);R(()=>{G(u)},[u,G]);const v=rt((t,r,s)=>{d&&G(t);const o=S.current,a=L?o.offsetWidth-L:o.offsetWidth-L+q;if(!Array.from(o.querySelectorAll("[data-index]")).filter(T=>{const D=Number(T.getAttribute("data-index"));return!isNaN(D)&&D>-1})[t])return;if(s){const T=t===0?g:0,D=a*(g+(H||h)/h);if(k()){if(o.scrollLeft<=0&&o.scrollLeft>-(a-5)){v(1,!0);return}if(o.scrollLeft<a-D&&o.scrollLeft>=-D){v(g,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=T===0?0:-D,v(T===0?1:g,!0)}else{if(o.scrollLeft>=0&&o.scrollLeft<a-5){v(1,!0);return}if(o.scrollLeft>D-a&&o.scrollLeft<=D){v(g,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=T===0?0:D,v(T===0?1:g,!0);return}}const lt=(o.offsetWidth-q)/h*f[t].length-L;o.style.scrollBehavior=r?"smooth":"auto",o.scrollLeft=k()?-(f[t].length===h?a*t:a*(t-1)-lt):f[t].length===h?a*t:a*(t-1)+lt},[q,g,L,h,H,f,G,n]),tt=rt(()=>{if(l){const r=u-1;v(r,!0,k()?u===g-1:u===1);return}const t=u<=0?0:u-1;v(t,!0)},[u,v,l]),et=rt(()=>{const t=f.length-1;if(l){const s=u+1;v(s,!0,k()?u===0:u===g);return}const r=u>=t?t:u+1;v(r,!0)},[f.length,l,u,v,g]);R(()=>{const t=r=>{r.key==="ArrowLeft"&&(r.preventDefault(),k()?et():tt()),r.key==="ArrowRight"&&(r.preventDefault(),k()?tt():et())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[et,tt]),R(()=>{v(l?Y+1:Y,!1)},[Y,v,l]);const dt=yt(()=>{const t=S.current,r=L?t.offsetWidth-L:t.offsetWidth-L+q,s=Math.abs(t.scrollLeft)/r,o=Math.abs(Math.round(s)-s<1?Math.round(s):Math.ceil(s));if(d&&G(o),l){const a=r*(g+(H||h)/h),p=k()?-t.scrollLeft:t.scrollLeft;if(Math.ceil(Math.abs(p))>=Math.ceil(a)-5){t.style.scrollBehavior="auto",t.scrollLeft=k()?-t.offsetWidth+(Math.ceil(p)-Math.ceil(a)-L):t.offsetWidth+(Math.ceil(p)-Math.ceil(a)-L);return}if(Math.abs(p)===0){t.style.scrollBehavior="auto",t.scrollLeft=k()?-(a-t.offsetWidth+L):a-t.offsetWidth+L;return}}u!==o&&ft(o)},100);R(()=>{const t=S.current;return t==null||t.addEventListener("scroll",dt),()=>{t==null||t.removeEventListener("scroll",dt)}},[dt]);const st=(t,r,s)=>C(mt,{className:N([["pdp-carousel__button",!t],[`pdp-carousel__button--${r}`,!t],[`pdp-carousel__button--${n}`,t]]),style:{"--height":`${w}px`},variant:"tertiary","aria-label":r==="next"?B:it,onClick:s,disabled:l?!1:r==="next"?u>=f.length-1:u<1,children:C(Wt,{className:N([["pdp-carousel__button__icon",!t],[`pdp-carousel__button__icon--${r}`,!t],[`pdp-carousel__button__icon--${n}--${r}`,t]]),size:Xt,source:kt})}),gt=i&&f.length!=1&&st(d,"prev",tt),_t=i&&f.length!=1&&st(d,"next",et),Pt=i&&f.length!=1&&st(!1,"prev",tt),xt=i&&f.length!=1&&st(!1,"next",et);return F("div",{role:"region","aria-roledescription":z,className:N(["pdp-carousel",["pdp-carousel--main-image-controls",$],["pdp-carousel--arrows",i&&!d],[`pdp-carousel--${n}`,d],ct]),style:{"--flex-carousel":n==="thumbnailsColumn"?"row-reverse":"column","--gap":d?"0":"var(--spacing-small)","--width":W},...V,children:[C("div",{ref:S,className:N(["pdp-carousel__wrapper",`pdp-carousel__wrapper--${M}`,["pdp-carousel__wrapper--scrollbar",m],["pdp-carousel__wrapper--peak",_]]),style:{"--total-width":n==="thumbnailsColumn"?"81.6%":"100%","--height":n==="thumbnailsColumn"?"auto":J,"--gap":b?`var(--spacing-${b})`:"0px","--per-page":h},tabIndex:0,children:f.map((t,r)=>{const s=t.length<h;return C("div",{role:"group","aria-roledescription":at,"data-index":r,className:N(["pdp-carousel__slide",`pdp-carousel__slide--${M}`,["pdp-carousel__slide--active",u===r],["pdp-carousel__slide--orphan",s]]),style:{"--length":t.length},children:t},r)})}),!d&&F(bt,{children:[gt,_t]}),d&&$&&F(bt,{children:[Pt,xt]}),n&&f.length!=1&&F("div",{className:N([[`pdp-carousel__controls__container--${n}`,d],["pdp-carousel__controls__container--no-arrows",!i||$]]),style:{"--width":n==="thumbnailsRow"?`${y}px`:W,"--height":`${w}px`,"--nr-thumbnails":I.length},children:[(d||P)&&!$&&gt,C("div",{ref:Z,className:N([[`pdp-carousel__controls__wrapper--${n}`,d],["pdp-carousel__controls__wrapper",d]]),children:C("div",{role:"group","aria-label":ut,className:N(["pdp-carousel__controls",[`pdp-carousel__controls--${n}`,d]]),children:(l?f.slice(0,g):f).map((t,r)=>{const s=l?g:f.length,o=l?u-1===r:u===r;return d?F("label",{className:N(["pdp-carousel__thumbnail__container"]),ref:a=>{a&&(e.current[r]=a)},children:[C("input",{type:"radio",name:"carousel-thumbnails","aria-label":nt.replace("{key}",String(r+1)).replace("{total}",String(s)),checked:o&&y!==0,onChange:()=>{v(l?r+1:r,!0)},...V,className:N(["pdp-carousel__thumbnail",["pdp-carousel__thumbnail--selected",o&&y!==0]])}),C("span",{className:N(["pdp-carousel__thumbnail__span"]),children:I[r]})]},r):C("button",{"aria-label":nt.replace("{key}",String(r+1)).replace("{total}",String(s)),onClick:()=>{v(l?r+1:r,!0)},className:N(["pdp-carousel__controls__button",["pdp-carousel__controls__button--active",o]])},r)})})}),(d||P)&&!$&&_t]})]})};function Lt(c,m=0){if(typeof c=="number")return c;const{small:_,medium:i,large:n}=c,l=[{breakpoint:1024,value:n},{breakpoint:786,value:i},{breakpoint:0,value:_}].find(({breakpoint:b})=>m>b);return l?l.value:_}function k(){return document.documentElement.dir==="rtl"}const Ot=({centered:c,onClose:m,className:_,children:i,...n})=>{const $=A("PDP.Overlay.Close.label").label,l=K(null),b=rt(()=>{m==null||m()},[m]);return R(()=>{const M=W=>{W.key==="Escape"&&b()};return document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}},[b]),R(()=>{const M=l.current;M==null||M.focus();const W=document.scrollingElement,J=W.style.overflow;return W.style.overflow="hidden",()=>{W.style.overflow=J}},[]),F("div",{...n,className:N(["pdp-overlay",["pdp-overlay--centered",c],_]),ref:l,role:"dialog","aria-describedby":"overlay-content",tabindex:0,children:[C("div",{className:"pdp-overlay__content",id:"overlay-content",children:i}),C(mt,{"aria-label":$,variant:"tertiary",className:"pdp-overlay__close-button",onClick:b,icon:C(Ct,{})})]})},Zt=({children:c,scale:m=2,closeButton:_=!0})=>{const[i,n]=X(!1),[$,l]=X("pdp-zoom"),[b,M]=X(!1),[W,J]=X({x:0,y:0}),[Y,ct]=X({x:0,y:0}),[E,Q]=X({x:0,y:0}),P=K(null),V=K(!1),z=K(null),at=e=>{!i||e.type!=="touchstart"||(J({x:e.touches[0].clientX,y:e.touches[0].clientY}),ct({x:E.x,y:E.y}),M(!0))},it=e=>{var d;if(!b||e.type!=="touchmove")return;const y=(d=e.currentTarget)==null?void 0:d.getBoundingClientRect(),x=(100-100/m)/2,w=e.touches[0].clientX-W.x,O=e.touches[0].clientY-W.y,I=w*100/(y.width*m),f=O*100/(y.height*m),S=Y.x+I,Z=Y.y+f;Q({x:Math.max(-x,Math.min(S,x))||0,y:Math.max(-x,Math.min(Z,x))||0}),e.preventDefault()},B=e=>{var Z;const y=(Z=e.currentTarget)==null?void 0:Z.getBoundingClientRect(),x=(100-100/m)/2;let w=null;if("touches"in e)if(e.touches.length>0)w=e.touches[0],z.current={clientX:w.clientX,clientY:w.clientY};else if(e.type==="touchend"&&P.current)w={clientX:P.current.x,clientY:P.current.y};else if(z.current)w=z.current;else return;else if(e instanceof MouseEvent)w=e;else return;const O=(w.clientX-y.left)/y.width*100,I=(w.clientY-y.top)/y.height*100,f=(50-O)*(m-1)/m,S=(50-I)*(m-1)/m;Q({x:Math.max(-x,Math.min(f,x))||0,y:Math.max(-x,Math.min(S,x))||0})},ut=e=>{if(_)P.current={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()},z.current={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY},V.current=!1,i&&at(e);else{if(b)return;!i&&B(e),n(!i),e.preventDefault()}},nt=e=>{if(e.touches.length!==0){if(z.current={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY},_){if(!P.current)return;if(b){it(e);return}const y=e.touches[0].clientX,x=e.touches[0].clientY,w=Math.abs(y-P.current.x),O=Math.abs(x-P.current.y);(w>10||O>10)&&(V.current=!0)}i&&B(e)}},h=e=>{if(_){if(!P.current)return;const y=Date.now()-P.current.time;!V.current&&y<300&&!b&&(n(!0),B(e),e.preventDefault()),M(!1),P.current=null}else n(!1)},ht=e=>{"touches"in e||b||(i?!_&&n(!1):(n(!0),B(e)),e.preventDefault())},g=e=>{"touches"in e||i&&B(e)},L=e=>{if(!("touches"in e)){if(_){M(!1);return}n(!1)}},q=e=>{n(!1),e.stopPropagation()},H=i?`scale(${m}) translateX(${E.x}%) translateY(${E.y}%)`:"none",u=A("PDP.Zoom.Close.label").label,ft=Et(j.only(c),{draggable:!1,style:{"--transform":H}});return R(()=>{l(i?`pdp-zoom ${_?"pdp-zoom--no-effects":"pdp-zoom--zoomed"}`:"pdp-zoom")},[i,_]),F("figure",{className:$,onClick:ht,onMouseMove:g,onMouseLeave:L,onTouchStart:ut,onTouchMove:nt,onTouchEnd:h,children:[ft,_&&i&&C(mt,{"aria-label":u,variant:"tertiary",className:"pdp-zoom__close-button",icon:C(Ct,{}),onClick:q})]})};export{Ht as C,Ot as O,Zt as Z};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{events as o}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const a=t=>{const s=e(),n=t(s);JSON.stringify(s)!==JSON.stringify(n)&&o.emit("pdp/values",{...n})},e=()=>{var t;return((t=o._lastEvent["pdp/values"])==null?void 0:t.payload)??null};export{e as g,a as s};
3
+ import{events as o}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const u=t=>{const e=n(),s=t(e);o.emit("pdp/values",{...s})},n=()=>{var t;return((t=o._lastEvent["pdp/values"])==null?void 0:t.payload)??null};export{n as g,u as s};
@@ -43,4 +43,4 @@ ${ne}
43
43
  }
44
44
  }
45
45
  }
46
- `).join("")}function Ue(e,n=[],r){const i=Object.values(e).filter(s=>!!s).reduce((s,u)=>u.options?[...s,...u.options]:[...s],[]),t=new Map(n.map(s=>[s.id,s]));return i.forEach(s=>{r!=null&&r.includes(s.id)||t.set(s.id,s)}),[...t.values()]}function ve(e,n,r){const i=[];let t;return e.forEach(s=>{var u,a,o,m;r.includes(s.id)?t=((a=(u=s.values)==null?void 0:u.find(l=>n.includes(l==null?void 0:l.id)))==null?void 0:a.id)||((o=s.values[0])==null?void 0:o.id):t=(m=s.values[0])==null?void 0:m.id,i.push(t)}),i}const te=async(e,n)=>{const{anchors:r,optionsUIDs:i}=p.getConfig(),{optionsUIDs:t=i,anchors:s=r,preselectFirstOption:u,isBundle:a,skipTransform:o}=n??{};return!a&&t?await ke(e,t,s,o):await Se(e,{preselectFirstOption:u,optionsUIDs:t},o)},Ae=e=>{const n=Ie(),r=e(n);n!==r&&L.emit("pdp/valid",r)},Ie=()=>{var e;return((e=L._lastEvent["pdp/valid"])==null?void 0:e.payload)??null};export{Qe as a,He as b,p as c,Se as d,ke as e,se as f,Ke as g,te as h,K as i,Ae as j,Ie as k,$e as l,we as p,je as r,Le as s,X as t};
46
+ `).join("")}function Ue(e,n=[],r){const i=Object.values(e).filter(s=>!!s).reduce((s,u)=>u.options?[...s,...u.options]:[...s],[]),t=new Map(n.map(s=>[s.id,s]));return i.forEach(s=>{r!=null&&r.includes(s.id)||t.set(s.id,s)}),[...t.values()]}function ve(e,n,r){const i=[];let t;return e.forEach(s=>{var u,a,o,m;r.includes(s.id)?t=((a=(u=s.values)==null?void 0:u.find(l=>n.includes(l==null?void 0:l.id)))==null?void 0:a.id)||((o=s.values[0])==null?void 0:o.id):t=(m=s.values[0])==null?void 0:m.id,i.push(t)}),i}const te=async(e,n)=>{const{anchors:r,optionsUIDs:i}=p.getConfig(),{optionsUIDs:t=i,anchors:s=r,preselectFirstOption:u,isBundle:a,skipTransform:o}=n??{};return!a&&t?await ke(e,t,s,o):await Se(e,{preselectFirstOption:u,optionsUIDs:t},o)},Ae=e=>{const n=Ie(),r=e(n);L.emit("pdp/valid",r)},Ie=()=>{var e;return((e=L._lastEvent["pdp/valid"])==null?void 0:e.payload)??null};export{Qe as a,He as b,p as c,Se as d,ke as e,se as f,Ke as g,te as h,K as i,Ae as j,Ie as k,$e as l,we as p,je as r,Le as s,X as t};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-pdp", "version": "1.1.0", "@dropins/tools": "^0.42.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-pdp", "version": "1.1.1", "@dropins/tools": "^0.42.0", "license": "SEE LICENSE IN LICENSE.md"}