efficient-storefront-blocks 0.126.0 → 0.126.2

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.
@@ -4350,7 +4350,8 @@ em.text-accent {
4350
4350
  The ground is on the PICTURE's box (the box that holds the Picture part,
4351
4351
  found by what it holds, as "Words: Over the picture" finds it), and the
4352
4352
  wheel is placed in that box: the well between them steps aside
4353
- (`position: static`), so a Show next image layer covers the whole picture.
4353
+ (`position: static`), so a Show next image layer covers the whole picture
4354
+ and is drawn as the picture is (same ellipse, place and floor shadows).
4354
4355
  The numbers are the design file's own (mockups/inovit-home-top-2026-11-18,
4355
4356
  `.pph`, `.st`, `.s1`, `.s2`), written in the box's width (`cqw`): the
4356
4357
  wheel is 77% of the box wide, 11.5% in from the left and 22% of the box's
@@ -4368,16 +4369,33 @@ em.text-accent {
4368
4369
  background-color: transparent;
4369
4370
  }
4370
4371
  .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) {
4371
- position: relative;
4372
- aspect-ratio: 10 / 13;
4373
- container-type: inline-size;
4374
- isolation: isolate;
4375
- background-image: radial-gradient(
4372
+ --sf-card-studio-ground: radial-gradient(
4376
4373
  ellipse at 50% 42%,
4377
4374
  color-mix(in oklab, var(--bg) 96.4%, var(--fg)) 0%,
4378
4375
  color-mix(in oklab, var(--bg) 91.5%, var(--fg)) 75%,
4379
4376
  color-mix(in oklab, var(--bg) 88.5%, var(--fg)) 100%
4380
4377
  );
4378
+ position: relative;
4379
+ aspect-ratio: 10 / 13;
4380
+ container-type: inline-size;
4381
+ isolation: isolate;
4382
+ background-image: var(--sf-card-studio-ground);
4383
+ }
4384
+ /* Show next image: the layer covers the whole picture box, so it paints the
4385
+ same ellipse (opaque, over the card's flat ground colour the layer is
4386
+ handed), holds the next rendering where the wheel sits, at its size (no
4387
+ zoom, no crop), and draws the same floor shadows on itself (below). */
4388
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-hover-media] {
4389
+ isolation: isolate;
4390
+ background-image: var(--sf-card-studio-ground);
4391
+ }
4392
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-hover-media] > img {
4393
+ position: absolute;
4394
+ left: 11.5cqw;
4395
+ top: 28.6cqw;
4396
+ width: 77cqw;
4397
+ height: 77cqw;
4398
+ object-fit: contain;
4381
4399
  }
4382
4400
  .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-part="image-frame"] {
4383
4401
  position: static;
@@ -4391,14 +4409,17 @@ em.text-accent {
4391
4409
  height: 77cqw;
4392
4410
  }
4393
4411
  .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::before,
4394
- .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::after {
4412
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::after,
4413
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-hover-media]::before,
4414
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-hover-media]::after {
4395
4415
  content: "";
4396
4416
  position: absolute;
4397
4417
  z-index: -1;
4398
4418
  pointer-events: none;
4399
4419
  }
4400
4420
  /* The wide, faint shadow (`.s2`): 142% of the wheel wide, 1:5. */
4401
- .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::before {
4421
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::before,
4422
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-hover-media]::before {
4402
4423
  left: -2.36cqw;
4403
4424
  top: 96.41cqw;
4404
4425
  width: 109.34cqw;
@@ -4407,7 +4428,8 @@ em.text-accent {
4407
4428
  filter: blur(16px);
4408
4429
  }
4409
4430
  /* The near, darker shadow (`.s1`): the wheel's width, 1:6. */
4410
- .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::after {
4431
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"])::after,
4432
+ .sf-card-ground-studio [data-part="box"]:has(> * > [data-part="image-block"]) [data-hover-media]::after {
4411
4433
  left: 14.58cqw;
4412
4434
  top: 95.85cqw;
4413
4435
  width: 77cqw;
@@ -2,7 +2,8 @@ import { type CSSProperties } from "react";
2
2
  import { type HeroView } from "./product-hero/hero-view.js";
3
3
  import type { StoreProduct } from "../lib/catalog/store-product.js";
4
4
  import { type HeroGalleryMode, type HeroImageFit } from "../lib/sections/hero-gallery.js";
5
- export default function ProductGallery({ product, view, angleIdx, onSelect, isLight, onLightbox, galleryMode, imageFit, style, takesViewHide, }: {
5
+ import { type SpinSets } from "../lib/sections/spin-sets.js";
6
+ export default function ProductGallery({ product, view, angleIdx, onSelect, isLight, onLightbox, galleryMode, imageFit, style, takesViewHide, spin, }: {
6
7
  product: StoreProduct;
7
8
  view: HeroView;
8
9
  angleIdx: number;
@@ -13,4 +14,5 @@ export default function ProductGallery({ product, view, angleIdx, onSelect, isLi
13
14
  imageFit?: HeroImageFit;
14
15
  style?: CSSProperties;
15
16
  takesViewHide?: boolean;
17
+ spin?: SpinSets;
16
18
  }): import("react").JSX.Element;
@@ -1 +1 @@
1
- "use client";import{jsx as n,Fragment as x,jsxs as h}from"react/jsx-runtime";import{useRef as v}from"react";import{photoLabel as g}from"./product-hero/hero-view.js";import{stageControls as H,useHeldStagePhoto as E}from"./product-hero/stage-photo.js";import{DEFAULT_HERO_GALLERY_MODE as M,DEFAULT_HERO_IMAGE_FIT as $,parseHeroGalleryMode as z,parseHeroImageFit as A,resolveHeroImageFit as F}from"../lib/sections/hero-gallery.js";import{productHasComposedRender as R}from"../lib/wheels/set-mode.js";import{HideTaker as _}from"efficient-web-builder/render/components/ViewHideRoot";import{swipeEnabled as O,swipeStep as P}from"efficient-web-builder/format/lib/hero-swipe";function B({product:a,view:e,angleIdx:l,onSelect:m,isLight:o,onLightbox:r,galleryMode:i=M,imageFit:p=$,style:t,takesViewHide:c=!1}){const s=z(i),u=F(A(p),R(a)),f=n(V,{name:a.name,view:e,angleIdx:l,onSelect:m,isLight:o,onLightbox:r,fit:u});return s==="stacked"?n(_,{as:"div",takes:c,"data-hero-gallery":s,"data-hero-fit":u,style:t,children:e.photos.length<2?f:h(x,{children:[n(w,{name:a.name,view:e,isLight:o,onLightbox:r,fit:u}),n(G,{angleIdx:l,total:y(e),onSelect:m,children:f})]})}):h(_,{as:"div",takes:c,"data-hero-gallery":s,"data-hero-fit":u,className:s==="tiled"?"flex items-start gap-3 max-view-tablet:gap-2":void 0,style:t,children:[n("div",{className:s==="tiled"?"min-w-0 flex-1":void 0,children:f}),s!=="main"&&n(D,{name:a.name,view:e,angleIdx:l,onSelect:m,isLight:o,tiled:s==="tiled"})]})}function y(a){return a.photos.length>0?a.photos.length:a.thumbFallbackCells}const j="relative flex aspect-square items-center justify-center overflow-hidden",C=(a,e,l)=>[a,e.metaValue,l].filter(Boolean).join(" — "),k=(a,e)=>`Open ${[a,e.metaValue].filter(Boolean).join(" ")} at full resolution`;function w({name:a,view:e,isLight:l,onLightbox:m,fit:o}){return n("div",{"data-hero-stack":!0,className:"flex flex-col gap-2 max-view-tablet:hidden",children:e.photos.map((r,i)=>{const p=C(a,e,g(e,i));return n("div",{"data-hero-stack-photo":!0,className:[j,l?"bg-bg":""].join(" "),style:{color:e.tint},children:e.stageImage({photo:r,alt:p,label:k(a,e),onZoom:()=>m(r,p),fit:o,eager:i===0})},r)})})}function G({angleIdx:a,total:e,onSelect:l,children:m}){const o=v(null),r=v(null),i=O({count:e}),p=t=>({x:t.touches[0].clientX,y:t.touches[0].clientY});return n("div",{"data-hero-phone-stage":!0,className:"view-tablet:hidden",onTouchStart:t=>{o.current=i&&t.touches.length===1?p(t):null,r.current=o.current},onTouchMove:t=>{o.current&&(t.touches.length!==1?o.current=null:r.current=p(t))},onTouchEnd:()=>{const t=o.current,c=r.current;if(o.current=null,r.current=null,!t||!c)return;const s=P(c.x-t.x,c.y-t.y,a,e);s!==a&&l(s)},children:m})}const I=6;function V({name:a,view:e,angleIdx:l,onSelect:m,isLight:o,onLightbox:r,fit:i}){const p=e.photos[Math.min(l,e.photos.length-1)],t=E(e.photos,p),c=y(e),s=c>=2,u=String(c).padStart(2,"0"),f=Math.min(l,Math.max(e.photos.length-1,0)),L=s||e.captions[f]?g(e,f):"",N=C(a,e,L),b="max-view-tablet:static",S=[`${j} max-view-tablet:col-span-2`,o?"bg-bg":""].join(" ");return h("div",{className:"relative max-view-tablet:grid max-view-tablet:grid-cols-[minmax(0,1fr)_auto] max-view-tablet:items-start max-view-tablet:gap-x-3 max-view-tablet:gap-y-2",style:{color:e.tint},children:[h("div",{className:`absolute left-0 top-0 z-10 flex items-center gap-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.2em] text-fg ${b} max-view-tablet:min-w-0 max-view-tablet:flex-wrap max-view-tablet:gap-x-2 max-view-tablet:gap-y-1`,children:[s&&h(x,{children:[h("span",{className:"text-accent",children:[String(l+1).padStart(2,"0")," / ",u]}),n("span",{className:"text-fg-dim",children:"·"})]}),n("span",{children:a}),e.metaValue&&h(x,{children:[n("span",{className:"text-fg-dim",children:"·"}),n("span",{className:"text-accent",children:e.metaValue})]})]}),s&&n("div",{className:`absolute right-5 top-5 z-10 flex gap-1 ${b}`,children:H(l,c,m).map(d=>n("button",{type:"button","aria-label":d.label,title:d.label,onClick:d.onClick,className:"flex h-7 w-7 items-center justify-center border border-fg-dim/60 text-fg transition-colors hover:border-accent hover:text-accent",children:d.glyph},d.label))}),h("div",{className:S,children:[["top-3 left-3","top-3 right-3","bottom-3 left-3","bottom-3 right-3"].map((d,T)=>n("span",{className:`absolute ${d} h-3 w-3 border border-fg-dim/40`,style:{borderTop:d.includes("top")?"1px solid var(--site-line)":"none",borderBottom:d.includes("bottom")?"1px solid var(--site-line)":"none",borderLeft:d.includes("left")?"1px solid var(--site-line)":"none",borderRight:d.includes("right")?"1px solid var(--site-line)":"none"}},T)),e.stageImage({photo:t,alt:N,label:k(a,e),onZoom:()=>r(t,N),fit:i})]}),h("div",{className:`absolute bottom-0 left-0 right-0 z-10 flex items-end justify-between gap-3 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim ${b} max-view-tablet:col-span-2 max-view-tablet:flex-wrap`,children:[h("span",{className:"flex min-w-0 flex-col gap-1",children:[e.specCaption&&n("span",{children:e.specCaption}),e.referenceNote&&n("span",{"data-hero-reference-note":!0,children:e.referenceNote}),e.galleryHint&&n("span",{"data-hero-gallery-hint":!0,children:e.galleryHint})]}),n("span",{children:e.originCaption})]})]})}function D({name:a,view:e,angleIdx:l,onSelect:m,isLight:o,tiled:r=!1}){const i=y(e);return i<2?null:n("div",{className:r?"order-[-1] flex w-16 flex-col gap-2 max-view-tablet:w-12 max-view-tablet:gap-1":"mt-2 grid grid-cols-4 gap-2 max-view-tablet:gap-1",style:!r&&i>4?{gridTemplateColumns:`repeat(${Math.min(i,I)}, minmax(0, 1fr))`}:void 0,children:Array.from({length:i}).map((p,t)=>{const c=e.photos[t];return h("button",{type:"button",onClick:()=>m(t),"aria-label":`View ${g(e,t)}`,"aria-pressed":t===l,className:["relative flex aspect-square items-center justify-center overflow-hidden transition-colors",o?"bg-bg":"",t===l?"border border-accent":"border border-transparent hover:border-fg-dim"].join(" "),style:{color:e.tint},children:[n("span",{className:"absolute top-1.5 left-2 z-10 font-mono text-[length:var(--size-label,8px)] uppercase tracking-[0.18em] text-fg-dim",children:String(t+1).padStart(2,"0")}),e.thumbImage({photo:c,alt:`${a} — ${g(e,t)}`})]},t)})})}export{B as default};
1
+ "use client";import{jsx as n,Fragment as N,jsxs as m}from"react/jsx-runtime";import{useRef as j}from"react";import{photoLabel as x}from"./product-hero/hero-view.js";import v from"./product-hero/SpinLayer.js";import{stageControls as $,useHeldStagePhoto as F}from"./product-hero/stage-photo.js";import{DEFAULT_HERO_GALLERY_MODE as z,DEFAULT_HERO_IMAGE_FIT as A,parseHeroGalleryMode as O,parseHeroImageFit as P,resolveHeroImageFit as R}from"../lib/sections/hero-gallery.js";import{spinSetFor as B}from"../lib/sections/spin-sets.js";import{productHasComposedRender as I}from"../lib/wheels/set-mode.js";import{HideTaker as C}from"efficient-web-builder/render/components/ViewHideRoot";import{swipeEnabled as V,swipeStep as G}from"efficient-web-builder/format/lib/hero-swipe";function D({product:a,view:e,angleIdx:o,onSelect:d,isLight:l,onLightbox:r,galleryMode:i=z,imageFit:c=A,style:t,takesViewHide:s=!1,spin:u=U}){const g=B(u,a.slug,e.metaValue),h=O(i),f=R(P(c),I(a)),b=n(X,{name:a.name,view:e,angleIdx:o,onSelect:d,isLight:l,onLightbox:r,fit:f,spinSet:g});return h==="stacked"?n(C,{as:"div",takes:s,"data-hero-gallery":h,"data-hero-fit":f,style:t,children:e.photos.length<2?b:m(N,{children:[n(q,{name:a.name,view:e,isLight:l,onLightbox:r,fit:f,spinSet:g}),n(w,{angleIdx:o,total:S(e),onSelect:d,children:b})]})}):m(C,{as:"div",takes:s,"data-hero-gallery":h,"data-hero-fit":f,className:h==="tiled"?"flex items-start gap-3 max-view-tablet:gap-2":void 0,style:t,children:[n("div",{className:h==="tiled"?"min-w-0 flex-1":void 0,children:b}),h!=="main"&&n(Y,{name:a.name,view:e,angleIdx:o,onSelect:d,isLight:l,tiled:h==="tiled"})]})}function S(a){return a.photos.length>0?a.photos.length:a.thumbFallbackCells}const L="relative flex aspect-square items-center justify-center overflow-hidden",U={},k=(a,e,o)=>[a,e.metaValue,o].filter(Boolean).join(" — "),T=(a,e)=>[a,e.metaValue].filter(Boolean).join(" "),H=(a,e)=>`Open ${[a,e.metaValue].filter(Boolean).join(" ")} at full resolution`;function q({name:a,view:e,isLight:o,onLightbox:d,fit:l,spinSet:r}){const i=r?n(v,{set:r,name:T(a,e)}):null;return n("div",{"data-hero-stack":!0,className:"flex flex-col gap-2 max-view-tablet:hidden",children:e.photos.map((c,t)=>{const s=k(a,e,x(e,t));return m("div",{"data-hero-stack-photo":!0,className:[L,o?"bg-bg":""].join(" "),style:{color:e.tint},children:[e.stageImage({photo:c,alt:s,label:H(a,e),onZoom:()=>d(c,s),fit:l,eager:t===0}),t===0&&i]},c)})})}function w({angleIdx:a,total:e,onSelect:o,children:d}){const l=j(null),r=j(null),i=V({count:e}),c=t=>({x:t.touches[0].clientX,y:t.touches[0].clientY});return n("div",{"data-hero-phone-stage":!0,className:"view-tablet:hidden",onTouchStart:t=>{l.current=i&&t.touches.length===1?c(t):null,r.current=l.current},onTouchMove:t=>{l.current&&(t.touches.length!==1?l.current=null:r.current=c(t))},onTouchEnd:()=>{const t=l.current,s=r.current;if(l.current=null,r.current=null,!t||!s)return;const u=G(s.x-t.x,s.y-t.y,a,e);u!==a&&o(u)},children:d})}const W=6;function X({name:a,view:e,angleIdx:o,onSelect:d,isLight:l,onLightbox:r,fit:i,spinSet:c}){const t=e.photos[Math.min(o,e.photos.length-1)],s=F(e.photos,t),u=S(e),g=u>=2,h=String(u).padStart(2,"0"),f=Math.min(o,Math.max(e.photos.length-1,0)),b=g||e.captions[f]?x(e,f):"",_=k(a,e,b),y="max-view-tablet:static",E=[`${L} max-view-tablet:col-span-2`,l?"bg-bg":""].join(" ");return m("div",{className:"relative max-view-tablet:grid max-view-tablet:grid-cols-[minmax(0,1fr)_auto] max-view-tablet:items-start max-view-tablet:gap-x-3 max-view-tablet:gap-y-2",style:{color:e.tint},children:[m("div",{className:`absolute left-0 top-0 z-10 flex items-center gap-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.2em] text-fg ${y} max-view-tablet:min-w-0 max-view-tablet:flex-wrap max-view-tablet:gap-x-2 max-view-tablet:gap-y-1`,children:[g&&m(N,{children:[m("span",{className:"text-accent",children:[String(o+1).padStart(2,"0")," / ",h]}),n("span",{className:"text-fg-dim",children:"·"})]}),n("span",{children:a}),e.metaValue&&m(N,{children:[n("span",{className:"text-fg-dim",children:"·"}),n("span",{className:"text-accent",children:e.metaValue})]})]}),g&&n("div",{className:`absolute right-5 top-5 z-10 flex gap-1 ${y}`,children:$(o,u,d).map(p=>n("button",{type:"button","aria-label":p.label,title:p.label,onClick:p.onClick,className:"flex h-7 w-7 items-center justify-center border border-fg-dim/60 text-fg transition-colors hover:border-accent hover:text-accent",children:p.glyph},p.label))}),m("div",{className:E,children:[["top-3 left-3","top-3 right-3","bottom-3 left-3","bottom-3 right-3"].map((p,M)=>n("span",{className:`absolute ${p} h-3 w-3 border border-fg-dim/40`,style:{borderTop:p.includes("top")?"1px solid var(--site-line)":"none",borderBottom:p.includes("bottom")?"1px solid var(--site-line)":"none",borderLeft:p.includes("left")?"1px solid var(--site-line)":"none",borderRight:p.includes("right")?"1px solid var(--site-line)":"none"}},M)),e.stageImage({photo:s,alt:_,label:H(a,e),onZoom:()=>r(s,_),fit:i}),c&&n(v,{set:c,name:T(a,e)})]}),m("div",{className:`absolute bottom-0 left-0 right-0 z-10 flex items-end justify-between gap-3 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim ${y} max-view-tablet:col-span-2 max-view-tablet:flex-wrap`,children:[m("span",{className:"flex min-w-0 flex-col gap-1",children:[e.specCaption&&n("span",{children:e.specCaption}),e.referenceNote&&n("span",{"data-hero-reference-note":!0,children:e.referenceNote}),e.galleryHint&&n("span",{"data-hero-gallery-hint":!0,children:e.galleryHint})]}),n("span",{children:e.originCaption})]})]})}function Y({name:a,view:e,angleIdx:o,onSelect:d,isLight:l,tiled:r=!1}){const i=S(e);return i<2?null:n("div",{className:r?"order-[-1] flex w-16 flex-col gap-2 max-view-tablet:w-12 max-view-tablet:gap-1":"mt-2 grid grid-cols-4 gap-2 max-view-tablet:gap-1",style:!r&&i>4?{gridTemplateColumns:`repeat(${Math.min(i,W)}, minmax(0, 1fr))`}:void 0,children:Array.from({length:i}).map((c,t)=>{const s=e.photos[t];return m("button",{type:"button",onClick:()=>d(t),"aria-label":`View ${x(e,t)}`,"aria-pressed":t===o,className:["relative flex aspect-square items-center justify-center overflow-hidden transition-colors",l?"bg-bg":"",t===o?"border border-accent":"border border-transparent hover:border-fg-dim"].join(" "),style:{color:e.tint},children:[n("span",{className:"absolute top-1.5 left-2 z-10 font-mono text-[length:var(--size-label,8px)] uppercase tracking-[0.18em] text-fg-dim",children:String(t+1).padStart(2,"0")}),e.thumbImage({photo:s,alt:`${a} — ${x(e,t)}`})]},t)})})}export{D as default};
@@ -1,7 +1,9 @@
1
1
  import type { HeroGalleryMode, HeroImageFit } from "../../lib/sections/hero-gallery.js";
2
+ import type { SpinSets } from "../../lib/sections/spin-sets.js";
2
3
  interface GalleryLook {
3
4
  galleryMode?: HeroGalleryMode;
4
5
  imageFit?: HeroImageFit;
6
+ spin?: SpinSets;
5
7
  }
6
8
  export default function DynamicProductGallery({ editing, ...look }: {
7
9
  editing?: boolean;
@@ -0,0 +1,5 @@
1
+ import { type SpinSet } from "../../lib/sections/spin-sets.js";
2
+ export default function SpinLayer({ set, name }: {
3
+ set: SpinSet;
4
+ name: string;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use client";import{jsx as p,jsxs as T,Fragment as ut}from"react/jsx-runtime";import{useCallback as x,useEffect as k,useRef as a,useState as A}from"react";import{HALF_SIZES as j,sizedImage as U}from"efficient-web-builder/format/lib/sized-image";import{prefersReducedMotion as q}from"efficient-web-builder/render/components/useReducedMotion";import{SPIN_MAX_ZOOM as B,clampSpinZoom as mt,isFullTurn as pt,spinClampPosition as dt,spinFrameIndex as ft,spinPositionAfterDrag as G,spinStartPosition as ht}from"../../lib/sections/spin-sets.js";const xt=.25,gt=.3,bt=.85,K=24,zt=300,yt=.0015,V=4,J=1e3,wt=1920,Q=c=>U(c,{fallbackWidth:J,maxWidth:J}),Mt=c=>U(c,{fallbackWidth:wt});function vt({set:c,name:v}){const[l,nt]=A(!1),[W,et]=A(()=>ht(c)),[g,rt]=A({z:1,x:0,y:0}),[L,O]=A(0),b=a(null),z=a(0),P=a(W),F=a(1),d=a(g),y=a(null),u=a(new Map),h=a(null),S=a(0),I=a(null),m=c.frames.length,D=pt(c),Y=ft(W,m,D),_=x(t=>{const n=dt(t,m,D);return P.current=n,et(n),n},[m,D]),f=x(()=>cancelAnimationFrame(z.current),[]),w=x(t=>{d.current=t,rt(t)},[]),M=x((t,n,e)=>{const r=b.current;if(!r)return;const o=r.getBoundingClientRect(),s=d.current,i=mt(t),E=n-o.left-o.width/2,Z=e-o.top-o.height/2;if(i<=1.01){w({z:1,x:0,y:0});return}const $=r.clientWidth*(i-1)/2,H=r.clientHeight*(i-1)/2,at=E-(E-s.x)*i/s.z,lt=Z-(Z-s.y)*i/s.z;w({z:i,x:Math.max(-$,Math.min($,at)),y:Math.max(-H,Math.min(H,lt))})},[w]),N=x(()=>{const t=c.frames[0];if(I.current===t)return;I.current=t,O(0);const n=[];for(let e=0;e<V;e+=1)for(let r=e;r<m;r+=V)n.push(r);for(const e of n){const r=Q(c.frames[e]),o=new Image;o.onload=()=>{I.current===t&&O(s=>s+1)},o.sizes=j,r.srcSet&&(o.srcset=r.srcSet),o.src=r.src}},[m,c.frames]),ot=x(()=>{const t=()=>{const n=P.current+xt*F.current;_(n)!==n&&(F.current=-F.current),z.current=requestAnimationFrame(t)};z.current=requestAnimationFrame(t)},[_]),st=()=>{const t=!l;if(nt(t),f(),!t){w({z:1,x:0,y:0});return}q()||ot()};k(()=>{l&&N()},[l,N]),k(()=>{const t=b.current;if(!l||!t)return;const n=e=>{e.preventDefault(),f(),M(d.current.z*Math.exp(-e.deltaY*yt),e.clientX,e.clientY)};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[l,f,M]),k(()=>f,[f]);const ct=t=>{if(f(),u.current.set(t.pointerId,{x:t.clientX,y:t.clientY}),t.currentTarget.setPointerCapture?.(t.pointerId),u.current.size===2){const[n,e]=[...u.current.values()];h.current={d0:Math.hypot(n.x-e.x,n.y-e.y),z0:d.current.z},y.current=null;return}if(t.pointerType==="touch"){const n=Date.now();if(n-S.current<zt){S.current=0,M(d.current.z>1.01?1:B,t.clientX,t.clientY);return}S.current=n}y.current={x0:t.clientX,f0:P.current,last:{x:t.clientX,y:t.clientY},speed:0}},it=t=>{if(!u.current.has(t.pointerId))return;if(u.current.set(t.pointerId,{x:t.clientX,y:t.clientY}),u.current.size===2&&h.current){const[o,s]=[...u.current.values()],i=Math.hypot(o.x-s.x,o.y-s.y);h.current.d0>0&&M(h.current.z0*i/h.current.d0,(o.x+s.x)/2,(o.y+s.y)/2);return}const n=y.current,e=b.current;if(!n||!e)return;const r=d.current;if(r.z>1.01){const o=e.clientWidth*(r.z-1)/2,s=e.clientHeight*(r.z-1)/2,i=Math.max(-o,Math.min(o,r.x+t.clientX-n.last.x)),E=Math.max(-s,Math.min(s,r.y+t.clientY-n.last.y));n.last={x:t.clientX,y:t.clientY},w({z:r.z,x:i,y:E});return}n.speed=t.clientX-n.last.x,n.last={x:t.clientX,y:t.clientY},_(G(n.f0,t.clientX-n.x0,e.clientWidth,m))},C=t=>{if(u.current.delete(t.pointerId),u.current.size>0)return;h.current=null;const n=y.current;y.current=null;const e=b.current;if(!n||!e||d.current.z>1.01||q())return;let r=Math.max(-K,Math.min(K,n.speed));const o=()=>{if(Math.abs(r)<gt)return;const s=G(P.current,r,e.clientWidth,m);_(s)===s&&(r*=bt,z.current=requestAnimationFrame(o))};z.current=requestAnimationFrame(o)},X=g.z>1.01,R=`translate(${g.x}px, ${g.y}px) scale(${g.z})`;return T(ut,{children:[l&&T("div",{ref:b,"data-spin-well":!0,"aria-hidden":"true",className:`absolute inset-0 z-20 select-none overflow-hidden bg-bg ${X?"cursor-move":"cursor-grab active:cursor-grabbing"}`,style:{touchAction:X?"none":"pan-y"},onPointerDown:ct,onPointerMove:it,onPointerUp:C,onPointerCancel:C,onDoubleClick:t=>{f(),M(d.current.z>1.01?1:B,t.clientX,t.clientY)},onTouchStart:t=>t.stopPropagation(),onTouchMove:t=>t.stopPropagation(),onTouchEnd:t=>t.stopPropagation(),onClick:t=>t.stopPropagation(),children:[p(tt,{sized:Q(c.frames[Y]),transform:R}),X&&p(tt,{sized:Mt(c.zoomFrames[Y]),transform:R}),p("span",{className:"pointer-events-none absolute bottom-8 left-1/2 -translate-x-1/2 whitespace-nowrap text-xs tracking-[0.04em] text-fg-dim max-view-tablet:bottom-auto max-view-tablet:top-4",children:"Drag to turn · scroll or pinch to zoom"}),L<m&&p("span",{className:"absolute inset-x-0 bottom-0 h-0.5 bg-fg/10",children:p("span",{className:"block h-full bg-fg transition-[width]",style:{width:`${L/m*100}%`}})})]}),T("button",{type:"button","data-spin-toggle":!0,"aria-pressed":l,"aria-label":l?`Show the photo of ${v}`:`Turn ${v} through 360°`,onClick:t=>{t.stopPropagation(),st()},className:"absolute bottom-6 left-6 z-30 inline-flex h-10 items-center gap-2 whitespace-nowrap border border-fg bg-bg px-4 text-xs font-medium uppercase tracking-[0.06em] text-fg transition-colors hover:bg-fg hover:text-bg max-view-tablet:bottom-4 max-view-tablet:left-4",children:[T("svg",{viewBox:"0 0 24 24","aria-hidden":"true",className:"h-4 w-4 fill-none stroke-current",strokeWidth:1.4,children:[p("path",{d:"M20 12a8 8 0 1 1-2.3-5.6"}),p("path",{d:"M20 4v4h-4"})]}),p("span",{children:l?"Show photo":"View 360°"})]})]})}function tt({sized:c,transform:v}){return p("img",{...c,sizes:j,alt:"",draggable:!1,className:"pointer-events-none absolute inset-[6%] h-[88%] w-[88%] object-contain",style:{transform:v}})}export{vt as default};
@@ -1 +1 @@
1
- import{DEFAULT_HERO_GALLERY_MODE as e,DEFAULT_HERO_IMAGE_FIT as l}from"../../../../sections/hero-gallery.js";const o={label:"Product Gallery",defaultProps:{galleryMode:e,imageFit:l}};export{o as ProductGalleryMeta};
1
+ import{DEFAULT_HERO_GALLERY_MODE as e,DEFAULT_HERO_IMAGE_FIT as l}from"../../../../sections/hero-gallery.js";const o={label:"Product Gallery",defaultProps:{galleryMode:e,imageFit:l,spin:{}}};export{o as ProductGalleryMeta};
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import o from"../../../../../components/pdp-dynamic/DynamicProductGallery.js";import{parseHeroGalleryMode as i,parseHeroImageFit as t}from"../../../../sections/hero-gallery.js";import{ProductGalleryMeta as a}from"./meta.js";const y={...a,render:e=>r(o,{editing:e.editor?.isEditing,galleryMode:i(e.galleryMode),imageFit:t(e.imageFit)})};export{y as ProductGalleryRender};
1
+ import{jsx as r}from"react/jsx-runtime";import i from"../../../../../components/pdp-dynamic/DynamicProductGallery.js";import{parseHeroGalleryMode as o,parseHeroImageFit as t}from"../../../../sections/hero-gallery.js";import{parseSpinSets as a}from"../../../../sections/spin-sets.js";import{ProductGalleryMeta as m}from"./meta.js";const y={...m,render:e=>r(i,{editing:e.editor?.isEditing,galleryMode:o(e.galleryMode),imageFit:t(e.imageFit),spin:a(e.spin)})};export{y as ProductGalleryRender};
@@ -0,0 +1,15 @@
1
+ export interface SpinSet {
2
+ frames: string[];
3
+ zoomFrames: string[];
4
+ arc?: number;
5
+ }
6
+ export type SpinSets = Record<string, Record<string, SpinSet>>;
7
+ export declare const SPIN_MAX_ZOOM = 2;
8
+ export declare function parseSpinSets(v: unknown): SpinSets;
9
+ export declare function spinSetFor(sets: SpinSets, productSlug: string, finishName: string | undefined): SpinSet | null;
10
+ export declare function isFullTurn(set: SpinSet): boolean;
11
+ export declare function spinStartPosition(set: SpinSet): number;
12
+ export declare function spinFrameIndex(position: number, count: number, loop?: boolean): number;
13
+ export declare function spinClampPosition(position: number, count: number, loop: boolean): number;
14
+ export declare function spinPositionAfterDrag(start: number, dx: number, width: number, count: number): number;
15
+ export declare function clampSpinZoom(z: number): number;
@@ -0,0 +1 @@
1
+ const p=2,l=360,m=.9,f=r=>Array.isArray(r)&&r.length>0&&r.every(t=>typeof t=="string"&&t.length>0);function a(r){if(!r||typeof r!="object")return null;const{frames:t,zoomFrames:n}=r;if(!f(t)||!f(n)||t.length!==n.length)return null;const{arc:e}=r;return e===void 0?{frames:[...t],zoomFrames:[...n]}:typeof e!="number"||!(e>0&&e<=360)?null:{frames:[...t],zoomFrames:[...n],arc:e}}function h(r){if(!r||typeof r!="object"||Array.isArray(r))return{};const t={};for(const[n,e]of Object.entries(r)){if(!e||typeof e!="object"||Array.isArray(e))continue;const o={};for(const[s,u]of Object.entries(e)){const i=a(u);i&&(o[s]=i)}Object.keys(o).length>0&&(t[n]=o)}return t}function x(r,t,n){return n?r[t]?.[n]??null:null}function c(r){return r.arc===void 0||r.arc>=360}function y(r){return c(r)?0:Math.floor(r.frames.length/2)}function M(r,t,n=!0){return n?(Math.floor(r)%t+t)%t:Math.max(0,Math.min(t-1,Math.floor(r)))}function L(r,t,n){return n?r:Math.max(0,Math.min(t-1,r))}function _(r,t,n,e){return n<=0?r:r-t/n*e*.9}function g(r){return Math.max(1,Math.min(2,r))}export{p as SPIN_MAX_ZOOM,g as clampSpinZoom,c as isFullTurn,h as parseSpinSets,L as spinClampPosition,M as spinFrameIndex,_ as spinPositionAfterDrag,x as spinSetFor,y as spinStartPosition};