@handijitcom/ui 3.3.1 → 3.4.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/README.md +247 -0
- package/build/chat.css +1 -1
- package/build/components/AppShell/Nav.cjs +1 -1
- package/build/components/AppShell/Nav.cjs.map +1 -1
- package/build/components/AppShell/Nav.d.cts +8 -1
- package/build/components/AppShell/Nav.d.ts +8 -1
- package/build/components/AppShell/Nav.js +127 -112
- package/build/components/AppShell/Nav.js.map +1 -1
- package/build/components/AppShell/style.css +1 -1
- package/build/components/AppliedFilters/index.cjs +2 -0
- package/build/components/AppliedFilters/index.cjs.map +1 -0
- package/build/components/AppliedFilters/index.d.cts +33 -0
- package/build/components/AppliedFilters/index.d.ts +33 -0
- package/build/components/AppliedFilters/index.js +85 -0
- package/build/components/AppliedFilters/index.js.map +1 -0
- package/build/components/AppliedFilters/style.css +1 -0
- package/build/components/BrandLockup/index.cjs +2 -0
- package/build/components/BrandLockup/index.cjs.map +1 -0
- package/build/components/BrandLockup/index.d.cts +29 -0
- package/build/components/BrandLockup/index.d.ts +29 -0
- package/build/components/BrandLockup/index.js +41 -0
- package/build/components/BrandLockup/index.js.map +1 -0
- package/build/components/BrandLockup/style.css +1 -0
- package/build/components/Carousel/index.cjs +1 -1
- package/build/components/Carousel/index.cjs.map +1 -1
- package/build/components/Carousel/index.d.cts +9 -0
- package/build/components/Carousel/index.d.ts +9 -0
- package/build/components/Carousel/index.js +65 -60
- package/build/components/Carousel/index.js.map +1 -1
- package/build/components/Carousel/style.css +1 -1
- package/build/components/CodeText/CodeTextCopy.cjs +2 -0
- package/build/components/CodeText/CodeTextCopy.cjs.map +1 -0
- package/build/components/CodeText/CodeTextCopy.d.cts +11 -0
- package/build/components/CodeText/CodeTextCopy.d.ts +11 -0
- package/build/components/CodeText/CodeTextCopy.js +41 -0
- package/build/components/CodeText/CodeTextCopy.js.map +1 -0
- package/build/components/CodeText/index.cjs +2 -0
- package/build/components/CodeText/index.cjs.map +1 -0
- package/build/components/CodeText/index.d.cts +26 -0
- package/build/components/CodeText/index.d.ts +26 -0
- package/build/components/CodeText/index.js +39 -0
- package/build/components/CodeText/index.js.map +1 -0
- package/build/components/CodeText/style.css +1 -0
- package/build/components/Combobox/index.cjs +1 -1
- package/build/components/Combobox/index.cjs.map +1 -1
- package/build/components/Combobox/index.js +147 -146
- package/build/components/Combobox/index.js.map +1 -1
- package/build/components/Combobox/style.css +1 -1
- package/build/components/CompareTray/index.cjs +2 -0
- package/build/components/CompareTray/index.cjs.map +1 -0
- package/build/components/CompareTray/index.d.cts +44 -0
- package/build/components/CompareTray/index.d.ts +44 -0
- package/build/components/CompareTray/index.js +94 -0
- package/build/components/CompareTray/index.js.map +1 -0
- package/build/components/CompareTray/style.css +1 -0
- package/build/components/DataTable/index.cjs +1 -1
- package/build/components/DataTable/index.cjs.map +1 -1
- package/build/components/DataTable/index.d.cts +12 -0
- package/build/components/DataTable/index.d.ts +12 -0
- package/build/components/DataTable/index.js +120 -122
- package/build/components/DataTable/index.js.map +1 -1
- package/build/components/DataTable/style.css +1 -1
- package/build/components/Eyebrow/style.css +1 -1
- package/build/components/FacetSection/index.cjs +2 -0
- package/build/components/FacetSection/index.cjs.map +1 -0
- package/build/components/FacetSection/index.d.cts +75 -0
- package/build/components/FacetSection/index.d.ts +75 -0
- package/build/components/FacetSection/index.js +199 -0
- package/build/components/FacetSection/index.js.map +1 -0
- package/build/components/FacetSection/style.css +1 -0
- package/build/components/FacetSidebar/index.cjs +2 -0
- package/build/components/FacetSidebar/index.cjs.map +1 -0
- package/build/components/FacetSidebar/index.d.cts +35 -0
- package/build/components/FacetSidebar/index.d.ts +35 -0
- package/build/components/FacetSidebar/index.js +110 -0
- package/build/components/FacetSidebar/index.js.map +1 -0
- package/build/components/FacetSidebar/style.css +1 -0
- package/build/components/FilterToolbar/index.cjs +2 -0
- package/build/components/FilterToolbar/index.cjs.map +1 -0
- package/build/components/FilterToolbar/index.d.cts +55 -0
- package/build/components/FilterToolbar/index.d.ts +55 -0
- package/build/components/FilterToolbar/index.js +149 -0
- package/build/components/FilterToolbar/index.js.map +1 -0
- package/build/components/FilterToolbar/style.css +1 -0
- package/build/components/Gallery/index.cjs +1 -1
- package/build/components/Gallery/index.cjs.map +1 -1
- package/build/components/Gallery/index.d.cts +8 -1
- package/build/components/Gallery/index.d.ts +8 -1
- package/build/components/Gallery/index.js +146 -138
- package/build/components/Gallery/index.js.map +1 -1
- package/build/components/Gallery/style.css +1 -1
- package/build/components/MegaMenu/index.cjs +2 -0
- package/build/components/MegaMenu/index.cjs.map +1 -0
- package/build/components/MegaMenu/index.d.cts +67 -0
- package/build/components/MegaMenu/index.d.ts +67 -0
- package/build/components/MegaMenu/index.js +220 -0
- package/build/components/MegaMenu/index.js.map +1 -0
- package/build/components/MegaMenu/style.css +1 -0
- package/build/components/MoneyInput/index.cjs +1 -1
- package/build/components/MoneyInput/index.cjs.map +1 -1
- package/build/components/MoneyInput/index.js +10 -10
- package/build/components/MoneyInput/index.js.map +1 -1
- package/build/components/NotificationCenter/style.css +1 -1
- package/build/components/PageHeader/style.css +1 -1
- package/build/components/Popover/style.css +1 -1
- package/build/components/ProductCarousel/index.cjs +2 -0
- package/build/components/ProductCarousel/index.cjs.map +1 -0
- package/build/components/ProductCarousel/index.d.cts +35 -0
- package/build/components/ProductCarousel/index.d.ts +35 -0
- package/build/components/ProductCarousel/index.js +86 -0
- package/build/components/ProductCarousel/index.js.map +1 -0
- package/build/components/ProductCarousel/style.css +1 -0
- package/build/components/Radio/index.cjs +1 -1
- package/build/components/Radio/index.cjs.map +1 -1
- package/build/components/Radio/index.js +10 -10
- package/build/components/Radio/index.js.map +1 -1
- package/build/components/SectionHeader/index.cjs +1 -1
- package/build/components/SectionHeader/index.cjs.map +1 -1
- package/build/components/SectionHeader/index.js +4 -4
- package/build/components/SectionHeader/index.js.map +1 -1
- package/build/components/SectionHeader/style.css +1 -1
- package/build/components/SegmentedControl/index.cjs +1 -1
- package/build/components/SegmentedControl/index.cjs.map +1 -1
- package/build/components/SegmentedControl/index.js +23 -23
- package/build/components/SegmentedControl/index.js.map +1 -1
- package/build/components/Select/index.cjs +1 -1
- package/build/components/Select/index.cjs.map +1 -1
- package/build/components/Select/index.js +37 -37
- package/build/components/Select/index.js.map +1 -1
- package/build/components/Select/style.css +1 -1
- package/build/components/Skeleton/index.cjs +1 -1
- package/build/components/Skeleton/index.cjs.map +1 -1
- package/build/components/Skeleton/index.js +16 -16
- package/build/components/Skeleton/index.js.map +1 -1
- package/build/components/SortableList/index.cjs +2 -0
- package/build/components/SortableList/index.cjs.map +1 -0
- package/build/components/SortableList/index.d.cts +37 -0
- package/build/components/SortableList/index.d.ts +37 -0
- package/build/components/SortableList/index.js +159 -0
- package/build/components/SortableList/index.js.map +1 -0
- package/build/components/SortableList/style.css +1 -0
- package/build/components/Steps/index.cjs +1 -1
- package/build/components/Steps/index.cjs.map +1 -1
- package/build/components/Steps/index.d.cts +6 -0
- package/build/components/Steps/index.d.ts +6 -0
- package/build/components/Steps/index.js +37 -35
- package/build/components/Steps/index.js.map +1 -1
- package/build/components/Steps/style.css +1 -1
- package/build/components/StickyActionBar/index.cjs +2 -0
- package/build/components/StickyActionBar/index.cjs.map +1 -0
- package/build/components/StickyActionBar/index.d.cts +29 -0
- package/build/components/StickyActionBar/index.d.ts +29 -0
- package/build/components/StickyActionBar/index.js +57 -0
- package/build/components/StickyActionBar/index.js.map +1 -0
- package/build/components/StickyActionBar/style.css +1 -0
- package/build/components/Table/index.cjs +1 -1
- package/build/components/Table/index.cjs.map +1 -1
- package/build/components/Table/index.d.cts +6 -0
- package/build/components/Table/index.d.ts +6 -0
- package/build/components/Table/index.js +34 -32
- package/build/components/Table/index.js.map +1 -1
- package/build/components/Table/style.css +1 -1
- package/build/helpers/carousel.helper.cjs +2 -0
- package/build/helpers/carousel.helper.cjs.map +1 -0
- package/build/helpers/carousel.helper.d.cts +11 -0
- package/build/helpers/carousel.helper.d.ts +11 -0
- package/build/helpers/carousel.helper.js +10 -0
- package/build/helpers/carousel.helper.js.map +1 -0
- package/build/helpers/facet.helper.cjs +2 -0
- package/build/helpers/facet.helper.cjs.map +1 -0
- package/build/helpers/facet.helper.d.cts +6 -0
- package/build/helpers/facet.helper.d.ts +6 -0
- package/build/helpers/facet.helper.js +5 -0
- package/build/helpers/facet.helper.js.map +1 -0
- package/build/helpers/focus.helper.cjs +1 -1
- package/build/helpers/focus.helper.cjs.map +1 -1
- package/build/helpers/focus.helper.d.cts +2 -0
- package/build/helpers/focus.helper.d.ts +2 -0
- package/build/helpers/focus.helper.js +1 -0
- package/build/helpers/focus.helper.js.map +1 -1
- package/build/helpers/sortable.helper.cjs +2 -0
- package/build/helpers/sortable.helper.cjs.map +1 -0
- package/build/helpers/sortable.helper.d.cts +19 -0
- package/build/helpers/sortable.helper.d.ts +19 -0
- package/build/helpers/sortable.helper.js +20 -0
- package/build/helpers/sortable.helper.js.map +1 -0
- package/build/helpers/sticky-bar.helper.cjs +2 -0
- package/build/helpers/sticky-bar.helper.cjs.map +1 -0
- package/build/helpers/sticky-bar.helper.d.cts +6 -0
- package/build/helpers/sticky-bar.helper.d.ts +6 -0
- package/build/helpers/sticky-bar.helper.js +8 -0
- package/build/helpers/sticky-bar.helper.js.map +1 -0
- package/build/hooks/useRemovalFocus.cjs +2 -0
- package/build/hooks/useRemovalFocus.cjs.map +1 -0
- package/build/hooks/useRemovalFocus.d.cts +13 -0
- package/build/hooks/useRemovalFocus.d.ts +13 -0
- package/build/hooks/useRemovalFocus.js +21 -0
- package/build/hooks/useRemovalFocus.js.map +1 -0
- package/build/index.cjs +1 -1
- package/build/index.d.cts +13 -2
- package/build/index.d.ts +13 -2
- package/build/index.js +115 -93
- package/build/index.js.map +1 -1
- package/build/scss/_mixins.scss +3 -1
- package/build/styles.css +38 -14
- package/build/types/sortable.type.d.cts +12 -0
- package/build/types/sortable.type.d.ts +12 -0
- package/build/types/theme.type.d.cts +95 -0
- package/build/types/theme.type.d.ts +95 -0
- package/build/types/types/theme.type.d.cts +95 -0
- package/build/types/types/theme.type.d.ts +95 -0
- package/package.json +111 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-toolbar-JRrAn{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hd-space-3);padding:var(--hd-space-2) var(--hd-space-3);border:1px solid var(--hd-border);border-radius:var(--hd-radius-md);background-color:var(--hd-bg-surface)}.ui-toolbar--sticky-APErO{position:sticky;top:calc(var(--ui-header-height, 0px) + var(--hd-space-4));z-index:var(--hd-z-sticky);box-shadow:var(--hd-shadow-1)}@media (max-width: 640px){.ui-toolbar-JRrAn{gap:var(--hd-space-2)}}.ui-toolbar__filter--Srca{display:none;flex-shrink:0}@media (max-width: 1024px){.ui-toolbar__filter--Srca{display:inline-flex}}.ui-toolbar__badge-arGML{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;margin-inline-start:var(--hd-space-1);padding-inline:5px;border-radius:var(--hd-radius-pill);background-color:var(--hd-primary);color:var(--hd-on-primary);font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-bold);font-variant-numeric:tabular-nums}.ui-toolbar__count-I5u40{margin:0;font-size:var(--hd-type-small-size);color:var(--hd-text-2);font-variant-numeric:tabular-nums;white-space:nowrap}.ui-toolbar__count-I5u40 strong{font-weight:var(--hd-font-weight-semibold);color:var(--hd-text)}@media (max-width: 640px){.ui-toolbar__count-I5u40{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}.ui-toolbar__skeleton-epM-9{flex-shrink:0}@media (max-width: 640px){.ui-toolbar__skeleton-epM-9{display:none}}.ui-toolbar__controls-DHeGd{--ui-picker-width: auto;--ui-picker-min-width: 140px;--ui-picker-max-width: 240px;display:flex;flex-wrap:wrap;align-items:center;gap:var(--hd-space-2);justify-content:flex-end;min-width:0;max-width:100%;margin-inline-start:auto}.ui-toolbar__view-HvpsI,.ui-toolbar__density-S7aan{flex-shrink:0}@media (max-width: 640px){.ui-toolbar__view-HvpsI,.ui-toolbar__density-S7aan{display:none}}.ui-srOnly-kcVaY{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),o=require("react"),g=require("react-bootstrap-icons"),w=require("../../helpers/class-name.helper.cjs"),re=require("../../helpers/component.helper.cjs"),F=require("../../helpers/focus.helper.cjs"),x=require("../../helpers/label.helper.cjs"),le=require("../../hooks/useScrollLock.cjs"),ce=require("../../theme/context.cjs"),z=require("../IconButton/index.cjs"),a={default:{"gallery":"ui-gallery-kHzW5","srOnly":"ui-srOnly-yZqYR","stage":"ui-stage-rg2mL","stage__open":"ui-stage__open-O-WpB","stage__hint":"ui-stage__hint-yvk-Q","stage--empty":"ui-stage--empty-ZC-pm","stage__counter":"ui-stage__counter-YXRje","image":"ui-image-eMyVt","stage--zoom":"ui-stage--zoom-gCoIw","arrow":"ui-arrow-HMm6V","viewer":"ui-viewer-mAIN4","arrow--previous":"ui-arrow--previous-iynhU","arrow--next":"ui-arrow--next-xShor","arrowIcon":"ui-arrowIcon--GW5Q","thumbs":"ui-thumbs-fquXS","thumb":"ui-thumb-Upsix","thumb__image":"ui-thumb__image-9VWiM","viewer__bar":"ui-viewer__bar-8DJT1","viewer__count":"ui-viewer__count--vw9Q","viewer__stage":"ui-viewer__stage-YmCnh","viewer__stage--zoomed":"ui-viewer__stage--zoomed-ktQdi","viewer__image":"ui-viewer__image-hHATa"}},ue=40,ie=({src:d,alt:y,className:v,width:l,height:h,variant:f})=>t.jsx("img",{src:d,alt:y,className:v,width:l,height:h,loading:f==="thumbnail"?"lazy":void 0,decoding:"async",draggable:!1}),A=(d,y,v)=>{const l=d.getBoundingClientRect(),h=l.width>0?(y-l.left)/l.width*100:50,f=l.height>0?(v-l.top)/l.height*100:50;d.style.setProperty("--ui-gallery-zoom-x",`${h}%`),d.style.setProperty("--ui-gallery-zoom-y",`${f}%`)},oe=({images:d,label:y,renderImage:v=ie,index:l,onIndexChange:h,hasZoom:f=!0,placeholder:I,hasCounter:Q,labels:n,className:O,testId:T})=>{var B,Z,V,H,W,J;const{labels:s}=ce.useUi(),[P,ee]=o.useState(0),[M,E]=o.useState(!1),[j,k]=o.useState(!1),X=o.useRef(null),Y=o.useRef(null),G=o.useRef(null),L=o.useRef(!1),c=d.length,u=Math.max(0,Math.min(l??P,c-1)),R={thumbnails:x.resolveLabel("Gallery.labels.thumbnails",n==null?void 0:n.thumbnails,(B=s==null?void 0:s.gallery)==null?void 0:B.thumbnails),previous:x.resolveLabel("Gallery.labels.previous",n==null?void 0:n.previous,(Z=s==null?void 0:s.gallery)==null?void 0:Z.previous),next:x.resolveLabel("Gallery.labels.next",n==null?void 0:n.next,(V=s==null?void 0:s.gallery)==null?void 0:V.next),fullscreen:x.resolveLabel("Gallery.labels.fullscreen",n==null?void 0:n.fullscreen,(H=s==null?void 0:s.gallery)==null?void 0:H.fullscreen)},_=o.useCallback(e=>{const r=(e+c)%c;l===void 0&&ee(r),k(!1),h==null||h(r)},[l,h,c]),C=o.useCallback(()=>{E(!1),k(!1)},[]);if(o.useEffect(()=>{const e=X.current;if(!M||!e)return;const r=F.captureFocus();e.open||e.showModal();const{token:i,pop:m}=F.pushModal(),b=S=>{S.preventDefault(),F.isTopModal(i)&&C()};return e.addEventListener("cancel",b),()=>{e.removeEventListener("cancel",b),e.open&&e.close(),m(),r()}},[M,C]),le.default(M),c===0)return I?t.jsx("section",{className:w.cx(a.default.gallery,O),"aria-label":y,"data-testid":T,children:t.jsx("div",{className:w.cx(a.default.stage,a.default["stage--empty"]),children:I})}):null;const q=d[u],N=c>1,D=(e,r=!1)=>{var b,S;const i={ArrowRight:u+1,ArrowLeft:u-1,Home:0,End:c-1};if(!N||!(e.key in i))return;e.preventDefault();const m=(i[e.key]+c)%c;_(m),r&&((S=(b=Y.current)==null?void 0:b.querySelectorAll("button")[m])==null||S.focus())},K=e=>{L.current=!1,G.current=j?null:{x:e.clientX,y:e.clientY}},U=e=>{const r=G.current;if(G.current=null,!r||!N)return;const i=e.clientX-r.x,m=e.clientY-r.y;Math.abs(i)<ue||Math.abs(i)<Math.abs(m)||(L.current=!0,_(u+(i<0?1:-1)))},te=e=>{f&&e.pointerType==="mouse"&&A(e.currentTarget,e.clientX,e.clientY)},ae=()=>{L.current||E(!0)},ne=e=>{!f||L.current||(A(e.currentTarget,e.clientX,e.clientY),k(r=>!r))},se=e=>{j&&A(e.currentTarget,e.clientX,e.clientY)},$=(e,r)=>({src:q.src,alt:q.alt,className:r,variant:e,index:u,width:q.width,height:q.height}),p=N&&t.jsxs(t.Fragment,{children:[t.jsx(z.default,{icon:t.jsx(g.ChevronLeft,{"aria-hidden":!0,className:a.default.arrowIcon}),label:R.previous,variant:"secondary",shape:"round",className:w.cx(a.default.arrow,a.default["arrow--previous"]),onClick:()=>_(u-1)}),t.jsx(z.default,{icon:t.jsx(g.ChevronRight,{"aria-hidden":!0,className:a.default.arrowIcon}),label:R.next,variant:"secondary",shape:"round",className:w.cx(a.default.arrow,a.default["arrow--next"]),onClick:()=>_(u+1)})]});return t.jsxs("section",{className:w.cx(a.default.gallery,O),"aria-label":y,"data-testid":T,children:[t.jsxs("div",{className:w.cx(a.default.stage,f&&a.default["stage--zoom"]),onPointerMove:te,onPointerDown:K,onPointerUp:U,onKeyDown:e=>D(e),children:[t.jsxs("button",{type:"button",className:a.default.stage__open,onClick:ae,children:[v($("main",a.default.image)),t.jsx("span",{className:a.default.srOnly,children:R.fullscreen}),t.jsx(g.ArrowsFullscreen,{"aria-hidden":!0,className:a.default.stage__hint})]}),Q&&N&&t.jsxs("span",{className:a.default.stage__counter,children:[u+1," / ",c]}),p]}),N&&t.jsx("ul",{ref:Y,className:a.default.thumbs,"aria-label":R.thumbnails,children:d.map((e,r)=>{var i;return t.jsx("li",{children:t.jsx("button",{type:"button",className:a.default.thumb,"aria-current":r===u||void 0,"aria-label":x.resolveFormatter("Gallery.labels.thumbnail",(n==null?void 0:n.thumbnail)??((i=s==null?void 0:s.gallery)==null?void 0:i.thumbnail),r+1,c),tabIndex:r===u?0:-1,onClick:()=>_(r),onKeyDown:m=>D(m,!0),children:v({src:e.thumbnailSrc??e.src,alt:"",className:a.default.thumb__image,variant:"thumbnail",index:r,width:e.width,height:e.height})})},`${e.src}-${r}`)})}),t.jsx("dialog",{ref:X,className:a.default.viewer,"aria-label":y,onKeyDown:e=>D(e),children:M&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:a.default.viewer__bar,children:[t.jsxs("span",{className:a.default.viewer__count,"aria-live":"polite",children:[u+1," / ",c]}),f&&t.jsx(z.default,{icon:j?t.jsx(g.ZoomOut,{"aria-hidden":!0}):t.jsx(g.ZoomIn,{"aria-hidden":!0}),label:j?x.resolveLabel("Gallery.labels.zoomOut",n==null?void 0:n.zoomOut,(W=s==null?void 0:s.gallery)==null?void 0:W.zoomOut):x.resolveLabel("Gallery.labels.zoomIn",n==null?void 0:n.zoomIn,(J=s==null?void 0:s.gallery)==null?void 0:J.zoomIn),variant:"secondary",onClick:()=>k(e=>!e)}),t.jsx(z.default,{icon:t.jsx(g.XLg,{"aria-hidden":!0}),label:x.resolveLabel("Gallery.labels.close",n==null?void 0:n.close,s==null?void 0:s.close),variant:"secondary",onClick:C})]}),t.jsx("div",{className:w.cx(a.default.viewer__stage,j&&a.default["viewer__stage--zoomed"]),onClick:ne,onPointerDown:K,onPointerUp:U,onPointerMove:se,children:v($("fullscreen",a.default.viewer__image))}),p]})})]})},de=o.memo(re.named(oe,"Gallery"));exports.default=de;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Gallery/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyboardEvent,\n memo,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n ArrowsFullscreen,\n ChevronLeft,\n ChevronRight,\n XLg,\n ZoomIn,\n ZoomOut,\n} from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { captureFocus, isTopModal, pushModal } from '../../helpers/focus.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\nexport type GalleryImage = {\n src: string;\n /** What the image shows (\"Fren balatası, ön yüz\"). */\n alt: string;\n /** A smaller file for the thumbnail; `src` when omitted. */\n thumbnailSrc?: string;\n width?: number;\n height?: number;\n};\n\n/** Where an image is drawn: the adapter picks sizes and priority from it. */\nexport type GalleryImageVariant = 'main' | 'thumbnail' | 'fullscreen';\n\n/** What `renderImage` receives. `className` MUST reach the element: zoom is drawn through it. */\nexport type GalleryRenderImageProps = {\n src: string;\n alt: string;\n className: string;\n variant: GalleryImageVariant;\n /** The image's position in `images`. */\n index: number;\n width?: number;\n height?: number;\n};\n\nexport type GalleryLabels = {\n thumbnails: string;\n thumbnail: Formatter<[index: number, total: number]>;\n previous: string;\n next: string;\n fullscreen: string;\n zoomIn: string;\n zoomOut: string;\n close: string;\n};\n\ntype Props = {\n images: GalleryImage[];\n /** The gallery's accessible name (\"Ürün görselleri\"); also the full-screen view's name. */\n label: string;\n /**\n * Draws one image — the platform's own component (`next/image`, a cached Electron loader). A\n * plain `<img>` when omitted.\n */\n renderImage?: (props: GalleryRenderImageProps) => ReactNode;\n /** Controlled index of the shown image; uncontrolled when omitted. */\n index?: number;\n onIndexChange?: (index: number) => void;\n /** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */\n hasZoom?: boolean;\n labels?: Partial<GalleryLabels>;\n className?: string;\n testId?: string;\n};\n\n/* A horizontal drag this long (px) is a swipe, not a tap. */\nconst SWIPE_DISTANCE = 40;\n\nconst defaultRenderImage = ({\n src,\n alt,\n className,\n width,\n height,\n variant,\n}: GalleryRenderImageProps) => (\n <img\n src={src}\n alt={alt}\n className={className}\n width={width}\n height={height}\n loading={variant === 'thumbnail' ? 'lazy' : undefined}\n decoding=\"async\"\n draggable={false}\n />\n);\n\n/** Writes the zoom origin as custom properties: no re-render on every pointer move. */\nconst setZoomOrigin = (element: HTMLElement, clientX: number, clientY: number) => {\n const rect = element.getBoundingClientRect();\n const x = rect.width > 0 ? ((clientX - rect.left) / rect.width) * 100 : 50;\n const y = rect.height > 0 ? ((clientY - rect.top) / rect.height) * 100 : 50;\n element.style.setProperty('--ui-gallery-zoom-x', `${x}%`);\n element.style.setProperty('--ui-gallery-zoom-y', `${y}%`);\n};\n\n/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */\nconst Gallery = ({\n images,\n label,\n renderImage = defaultRenderImage,\n index: controlledIndex,\n onIndexChange,\n hasZoom = true,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const [innerIndex, setInnerIndex] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isZoomed, setIsZoomed] = useState(false);\n const dialogRef = useRef<HTMLDialogElement>(null);\n const thumbsRef = useRef<HTMLUListElement>(null);\n const swipeRef = useRef<{ x: number; y: number } | null>(null);\n /* A swipe ends with a click on the same element: that click must not open the viewer. */\n const didSwipeRef = useRef(false);\n\n const total = images.length;\n const current = Math.max(0, Math.min(controlledIndex ?? innerIndex, total - 1));\n\n const text = {\n thumbnails: resolveLabel(\n 'Gallery.labels.thumbnails',\n labelProps?.thumbnails,\n config?.gallery?.thumbnails,\n ),\n previous: resolveLabel(\n 'Gallery.labels.previous',\n labelProps?.previous,\n config?.gallery?.previous,\n ),\n next: resolveLabel('Gallery.labels.next', labelProps?.next, config?.gallery?.next),\n fullscreen: resolveLabel(\n 'Gallery.labels.fullscreen',\n labelProps?.fullscreen,\n config?.gallery?.fullscreen,\n ),\n };\n\n const select = useCallback(\n (next: number) => {\n const wrapped = (next + total) % total;\n if (controlledIndex === undefined) setInnerIndex(wrapped);\n setIsZoomed(false);\n onIndexChange?.(wrapped);\n },\n [controlledIndex, onIndexChange, total],\n );\n\n const close = useCallback(() => {\n setIsFullscreen(false);\n setIsZoomed(false);\n }, []);\n\n /* The viewer is a modal `<dialog>`, opened and closed like `Modal`. */\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!isFullscreen || !dialog) return;\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n const { token, pop } = pushModal();\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (isTopModal(token)) close();\n };\n dialog.addEventListener('cancel', handleCancel);\n\n return () => {\n dialog.removeEventListener('cancel', handleCancel);\n if (dialog.open) dialog.close();\n pop();\n restoreFocus();\n };\n }, [isFullscreen, close]);\n\n useScrollLock(isFullscreen);\n\n if (total === 0) return null;\n\n const image = images[current];\n const hasMany = total > 1;\n\n const handleArrowKeys = (event: KeyboardEvent<HTMLElement>, moveFocus = false) => {\n const target: Record<string, number> = {\n ArrowRight: current + 1,\n ArrowLeft: current - 1,\n Home: 0,\n End: total - 1,\n };\n if (!hasMany || !(event.key in target)) return;\n\n event.preventDefault();\n const next = (target[event.key] + total) % total;\n select(next);\n if (moveFocus) thumbsRef.current?.querySelectorAll('button')[next]?.focus();\n };\n\n const handlePointerDown = (event: PointerEvent<HTMLElement>) => {\n didSwipeRef.current = false;\n swipeRef.current = isZoomed ? null : { x: event.clientX, y: event.clientY };\n };\n\n const handlePointerUp = (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || !hasMany) return;\n\n const dx = event.clientX - start.x;\n const dy = event.clientY - start.y;\n if (Math.abs(dx) < SWIPE_DISTANCE || Math.abs(dx) < Math.abs(dy)) return;\n\n didSwipeRef.current = true;\n select(current + (dx < 0 ? 1 : -1));\n };\n\n const handleStageMove = (event: PointerEvent<HTMLElement>) => {\n if (hasZoom && event.pointerType === 'mouse')\n setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n };\n\n const openViewer = () => {\n if (didSwipeRef.current) return;\n setIsFullscreen(true);\n };\n\n const toggleZoomAt = (event: MouseEvent<HTMLElement>) => {\n if (!hasZoom || didSwipeRef.current) return;\n setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n setIsZoomed(zoomed => !zoomed);\n };\n\n const handleViewerMove = (event: PointerEvent<HTMLElement>) => {\n if (isZoomed) setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n };\n\n const imageProps = (variant: GalleryImageVariant, className: string) => ({\n src: image.src,\n alt: image.alt,\n className,\n variant,\n index: current,\n width: image.width,\n height: image.height,\n });\n\n const arrows = hasMany && (\n <>\n <IconButton\n icon={<ChevronLeft aria-hidden className={styles.arrowIcon} />}\n label={text.previous}\n variant=\"secondary\"\n shape=\"round\"\n className={cx(styles.arrow, styles['arrow--previous'])}\n onClick={() => select(current - 1)}\n />\n <IconButton\n icon={<ChevronRight aria-hidden className={styles.arrowIcon} />}\n label={text.next}\n variant=\"secondary\"\n shape=\"round\"\n className={cx(styles.arrow, styles['arrow--next'])}\n onClick={() => select(current + 1)}\n />\n </>\n );\n\n return (\n <section className={cx(styles.gallery, className)} aria-label={label} data-testid={testId}>\n <div\n className={cx(styles.stage, hasZoom && styles['stage--zoom'])}\n onPointerMove={handleStageMove}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onKeyDown={event => handleArrowKeys(event)}\n >\n <button type=\"button\" className={styles.stage__open} onClick={openViewer}>\n {renderImage(imageProps('main', styles.image))}\n <span className={styles.srOnly}>{text.fullscreen}</span>\n <ArrowsFullscreen aria-hidden className={styles.stage__hint} />\n </button>\n {arrows}\n </div>\n\n {hasMany && (\n <ul ref={thumbsRef} className={styles.thumbs} aria-label={text.thumbnails}>\n {images.map((item, position) => (\n <li key={`${item.src}-${position}`}>\n <button\n type=\"button\"\n className={styles.thumb}\n aria-current={position === current || undefined}\n aria-label={resolveFormatter(\n 'Gallery.labels.thumbnail',\n labelProps?.thumbnail ?? config?.gallery?.thumbnail,\n position + 1,\n total,\n )}\n tabIndex={position === current ? 0 : -1}\n onClick={() => select(position)}\n onKeyDown={event => handleArrowKeys(event, true)}\n >\n {renderImage({\n src: item.thumbnailSrc ?? item.src,\n alt: '',\n className: styles.thumb__image,\n variant: 'thumbnail',\n index: position,\n width: item.width,\n height: item.height,\n })}\n </button>\n </li>\n ))}\n </ul>\n )}\n\n <dialog\n ref={dialogRef}\n className={styles.viewer}\n aria-label={label}\n onKeyDown={event => handleArrowKeys(event)}\n >\n {isFullscreen && (\n <>\n <div className={styles.viewer__bar}>\n <span className={styles.viewer__count} aria-live=\"polite\">\n {current + 1} / {total}\n </span>\n {hasZoom && (\n <IconButton\n icon={isZoomed ? <ZoomOut aria-hidden /> : <ZoomIn aria-hidden />}\n label={\n isZoomed\n ? resolveLabel(\n 'Gallery.labels.zoomOut',\n labelProps?.zoomOut,\n config?.gallery?.zoomOut,\n )\n : resolveLabel(\n 'Gallery.labels.zoomIn',\n labelProps?.zoomIn,\n config?.gallery?.zoomIn,\n )\n }\n variant=\"secondary\"\n onClick={() => setIsZoomed(zoomed => !zoomed)}\n />\n )}\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Gallery.labels.close', labelProps?.close, config?.close)}\n variant=\"secondary\"\n onClick={close}\n />\n </div>\n <div\n className={cx(styles.viewer__stage, isZoomed && styles['viewer__stage--zoomed'])}\n onClick={toggleZoomAt}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onPointerMove={handleViewerMove}\n >\n {renderImage(imageProps('fullscreen', styles.viewer__image))}\n </div>\n {arrows}\n </>\n )}\n </dialog>\n </section>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Gallery, 'Gallery')) as typeof Gallery;\n"],"names":["SWIPE_DISTANCE","defaultRenderImage","src","alt","className","width","height","variant","jsx","setZoomOrigin","element","clientX","clientY","rect","x","y","Gallery","images","label","renderImage","controlledIndex","onIndexChange","hasZoom","labelProps","testId","config","useUi","innerIndex","setInnerIndex","useState","isFullscreen","setIsFullscreen","isZoomed","setIsZoomed","dialogRef","useRef","thumbsRef","swipeRef","didSwipeRef","total","current","text","resolveLabel","_a","_b","_c","_d","select","useCallback","next","wrapped","close","useEffect","dialog","restoreFocus","captureFocus","token","pop","pushModal","handleCancel","event","isTopModal","useScrollLock","image","hasMany","handleArrowKeys","moveFocus","target","handlePointerDown","handlePointerUp","start","dx","dy","handleStageMove","openViewer","toggleZoomAt","zoomed","handleViewerMove","imageProps","arrows","jsxs","Fragment","IconButton","ChevronLeft","styles","cx","ChevronRight","ArrowsFullscreen","item","position","resolveFormatter","ZoomOut","ZoomIn","_e","_f","XLg","index","memo","named"],"mappings":"0iBAyFMA,GAAiB,GAEjBC,GAAqB,CAAC,CAC1B,IAAAC,EACA,IAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAAAC,CACF,IACEC,EAAAA,IAAC,MAAA,CACC,IAAAN,EACA,IAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAASC,IAAY,YAAc,OAAS,OAC5C,SAAS,QACT,UAAW,EAAA,CACb,EAIIE,EAAgB,CAACC,EAAsBC,EAAiBC,IAAoB,CAChF,MAAMC,EAAOH,EAAQ,sBAAA,EACfI,EAAID,EAAK,MAAQ,GAAMF,EAAUE,EAAK,MAAQA,EAAK,MAAS,IAAM,GAClEE,EAAIF,EAAK,OAAS,GAAMD,EAAUC,EAAK,KAAOA,EAAK,OAAU,IAAM,GACzEH,EAAQ,MAAM,YAAY,sBAAuB,GAAG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,wBACAnB,GAAA,YAAAA,EAAY,QACZuE,EAAArE,GAAA,YAAAA,EAAQ,UAAR,YAAAqE,EAAiB,MAAA,EAGzB,QAAQ,YACR,QAAS,IAAM7D,EAAY2C,GAAU,CAACA,CAAM,CAAA,CAAA,EAGhDpE,EAAAA,IAAC0E,EAAAA,QAAA,CACC,KAAM1E,EAAAA,IAACuF,EAAAA,IAAA,CAAI,cAAW,EAAA,CAAC,EACvB,MAAOrD,EAAAA,aAAa,uBAAwBnB,GAAA,YAAAA,EAAY,MAAOE,GAAA,YAAAA,EAAQ,KAAK,EAC5E,QAAQ,YACR,QAAS0B,CAAA,CAAA,CACX,EACF,EACA3C,EAAAA,IAAC,MAAA,CACC,UAAW6E,EAAAA,GAAGD,UAAO,cAAepD,GAAYoD,EAAAA,QAAO,uBAAuB,CAAC,EAC/E,QAAST,GACT,cAAeP,EACf,YAAaC,EACb,cAAeQ,GAEd,SAAA1D,EAAY2D,EAAW,aAAcM,EAAAA,QAAO,aAAa,CAAC,CAAA,CAAA,EAE5DL,CAAA,CAAA,CACH,CAAA,CAAA,CAEJ,EACF,CAEJ,EAEAiB,GAA6BC,OAAmBC,GAAAA,MAAMlF,GAAS,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Gallery/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyboardEvent,\n memo,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n ArrowsFullscreen,\n ChevronLeft,\n ChevronRight,\n XLg,\n ZoomIn,\n ZoomOut,\n} from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { captureFocus, isTopModal, pushModal } from '../../helpers/focus.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\nexport type GalleryImage = {\n src: string;\n /** What the image shows (\"Fren balatası, ön yüz\"). */\n alt: string;\n /** A smaller file for the thumbnail; `src` when omitted. */\n thumbnailSrc?: string;\n width?: number;\n height?: number;\n};\n\n/** Where an image is drawn: the adapter picks sizes and priority from it. */\nexport type GalleryImageVariant = 'main' | 'thumbnail' | 'fullscreen';\n\n/** What `renderImage` receives. `className` MUST reach the element: zoom is drawn through it. */\nexport type GalleryRenderImageProps = {\n src: string;\n alt: string;\n className: string;\n variant: GalleryImageVariant;\n /** The image's position in `images`. */\n index: number;\n width?: number;\n height?: number;\n};\n\nexport type GalleryLabels = {\n thumbnails: string;\n thumbnail: Formatter<[index: number, total: number]>;\n previous: string;\n next: string;\n fullscreen: string;\n zoomIn: string;\n zoomOut: string;\n close: string;\n};\n\ntype Props = {\n images: GalleryImage[];\n /** The gallery's accessible name (\"Ürün görselleri\"); also the full-screen view's name. */\n label: string;\n /**\n * Draws one image — the platform's own component (`next/image`, a cached Electron loader). A\n * plain `<img>` when omitted.\n */\n renderImage?: (props: GalleryRenderImageProps) => ReactNode;\n /** Controlled index of the shown image; uncontrolled when omitted. */\n index?: number;\n onIndexChange?: (index: number) => void;\n /** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */\n hasZoom?: boolean;\n /**\n * Drawn in the image's place when `images` is empty (3.4): the product's \"no image\" artwork.\n * Without it an empty gallery draws nothing.\n */\n placeholder?: ReactNode;\n /** Writes \"2 / 5\" on the main image (3.4): on a phone the thumbnails may be scrolled away. */\n hasCounter?: boolean;\n labels?: Partial<GalleryLabels>;\n className?: string;\n testId?: string;\n};\n\n/* A horizontal drag this long (px) is a swipe, not a tap. */\nconst SWIPE_DISTANCE = 40;\n\nconst defaultRenderImage = ({\n src,\n alt,\n className,\n width,\n height,\n variant,\n}: GalleryRenderImageProps) => (\n <img\n src={src}\n alt={alt}\n className={className}\n width={width}\n height={height}\n loading={variant === 'thumbnail' ? 'lazy' : undefined}\n decoding=\"async\"\n draggable={false}\n />\n);\n\n/** Writes the zoom origin as custom properties: no re-render on every pointer move. */\nconst setZoomOrigin = (element: HTMLElement, clientX: number, clientY: number) => {\n const rect = element.getBoundingClientRect();\n const x = rect.width > 0 ? ((clientX - rect.left) / rect.width) * 100 : 50;\n const y = rect.height > 0 ? ((clientY - rect.top) / rect.height) * 100 : 50;\n element.style.setProperty('--ui-gallery-zoom-x', `${x}%`);\n element.style.setProperty('--ui-gallery-zoom-y', `${y}%`);\n};\n\n/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */\nconst Gallery = ({\n images,\n label,\n renderImage = defaultRenderImage,\n index: controlledIndex,\n onIndexChange,\n hasZoom = true,\n placeholder,\n hasCounter,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const [innerIndex, setInnerIndex] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isZoomed, setIsZoomed] = useState(false);\n const dialogRef = useRef<HTMLDialogElement>(null);\n const thumbsRef = useRef<HTMLUListElement>(null);\n const swipeRef = useRef<{ x: number; y: number } | null>(null);\n /* A swipe ends with a click on the same element: that click must not open the viewer. */\n const didSwipeRef = useRef(false);\n\n const total = images.length;\n const current = Math.max(0, Math.min(controlledIndex ?? innerIndex, total - 1));\n\n const text = {\n thumbnails: resolveLabel(\n 'Gallery.labels.thumbnails',\n labelProps?.thumbnails,\n config?.gallery?.thumbnails,\n ),\n previous: resolveLabel(\n 'Gallery.labels.previous',\n labelProps?.previous,\n config?.gallery?.previous,\n ),\n next: resolveLabel('Gallery.labels.next', labelProps?.next, config?.gallery?.next),\n fullscreen: resolveLabel(\n 'Gallery.labels.fullscreen',\n labelProps?.fullscreen,\n config?.gallery?.fullscreen,\n ),\n };\n\n const select = useCallback(\n (next: number) => {\n const wrapped = (next + total) % total;\n if (controlledIndex === undefined) setInnerIndex(wrapped);\n setIsZoomed(false);\n onIndexChange?.(wrapped);\n },\n [controlledIndex, onIndexChange, total],\n );\n\n const close = useCallback(() => {\n setIsFullscreen(false);\n setIsZoomed(false);\n }, []);\n\n /* The viewer is a modal `<dialog>`, opened and closed like `Modal`. */\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!isFullscreen || !dialog) return;\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n const { token, pop } = pushModal();\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (isTopModal(token)) close();\n };\n dialog.addEventListener('cancel', handleCancel);\n\n return () => {\n dialog.removeEventListener('cancel', handleCancel);\n if (dialog.open) dialog.close();\n pop();\n restoreFocus();\n };\n }, [isFullscreen, close]);\n\n useScrollLock(isFullscreen);\n\n if (total === 0)\n return placeholder ? (\n <section className={cx(styles.gallery, className)} aria-label={label} data-testid={testId}>\n <div className={cx(styles.stage, styles['stage--empty'])}>{placeholder}</div>\n </section>\n ) : null;\n\n const image = images[current];\n const hasMany = total > 1;\n\n const handleArrowKeys = (event: KeyboardEvent<HTMLElement>, moveFocus = false) => {\n const target: Record<string, number> = {\n ArrowRight: current + 1,\n ArrowLeft: current - 1,\n Home: 0,\n End: total - 1,\n };\n if (!hasMany || !(event.key in target)) return;\n\n event.preventDefault();\n const next = (target[event.key] + total) % total;\n select(next);\n if (moveFocus) thumbsRef.current?.querySelectorAll('button')[next]?.focus();\n };\n\n const handlePointerDown = (event: PointerEvent<HTMLElement>) => {\n didSwipeRef.current = false;\n swipeRef.current = isZoomed ? null : { x: event.clientX, y: event.clientY };\n };\n\n const handlePointerUp = (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || !hasMany) return;\n\n const dx = event.clientX - start.x;\n const dy = event.clientY - start.y;\n if (Math.abs(dx) < SWIPE_DISTANCE || Math.abs(dx) < Math.abs(dy)) return;\n\n didSwipeRef.current = true;\n select(current + (dx < 0 ? 1 : -1));\n };\n\n const handleStageMove = (event: PointerEvent<HTMLElement>) => {\n if (hasZoom && event.pointerType === 'mouse')\n setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n };\n\n const openViewer = () => {\n if (didSwipeRef.current) return;\n setIsFullscreen(true);\n };\n\n const toggleZoomAt = (event: MouseEvent<HTMLElement>) => {\n if (!hasZoom || didSwipeRef.current) return;\n setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n setIsZoomed(zoomed => !zoomed);\n };\n\n const handleViewerMove = (event: PointerEvent<HTMLElement>) => {\n if (isZoomed) setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n };\n\n const imageProps = (variant: GalleryImageVariant, className: string) => ({\n src: image.src,\n alt: image.alt,\n className,\n variant,\n index: current,\n width: image.width,\n height: image.height,\n });\n\n const arrows = hasMany && (\n <>\n <IconButton\n icon={<ChevronLeft aria-hidden className={styles.arrowIcon} />}\n label={text.previous}\n variant=\"secondary\"\n shape=\"round\"\n className={cx(styles.arrow, styles['arrow--previous'])}\n onClick={() => select(current - 1)}\n />\n <IconButton\n icon={<ChevronRight aria-hidden className={styles.arrowIcon} />}\n label={text.next}\n variant=\"secondary\"\n shape=\"round\"\n className={cx(styles.arrow, styles['arrow--next'])}\n onClick={() => select(current + 1)}\n />\n </>\n );\n\n return (\n <section className={cx(styles.gallery, className)} aria-label={label} data-testid={testId}>\n <div\n className={cx(styles.stage, hasZoom && styles['stage--zoom'])}\n onPointerMove={handleStageMove}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onKeyDown={event => handleArrowKeys(event)}\n >\n <button type=\"button\" className={styles.stage__open} onClick={openViewer}>\n {renderImage(imageProps('main', styles.image))}\n <span className={styles.srOnly}>{text.fullscreen}</span>\n <ArrowsFullscreen aria-hidden className={styles.stage__hint} />\n </button>\n {hasCounter && hasMany && (\n <span className={styles.stage__counter}>\n {current + 1} / {total}\n </span>\n )}\n {arrows}\n </div>\n\n {hasMany && (\n <ul ref={thumbsRef} className={styles.thumbs} aria-label={text.thumbnails}>\n {images.map((item, position) => (\n <li key={`${item.src}-${position}`}>\n <button\n type=\"button\"\n className={styles.thumb}\n aria-current={position === current || undefined}\n aria-label={resolveFormatter(\n 'Gallery.labels.thumbnail',\n labelProps?.thumbnail ?? config?.gallery?.thumbnail,\n position + 1,\n total,\n )}\n tabIndex={position === current ? 0 : -1}\n onClick={() => select(position)}\n onKeyDown={event => handleArrowKeys(event, true)}\n >\n {renderImage({\n src: item.thumbnailSrc ?? item.src,\n alt: '',\n className: styles.thumb__image,\n variant: 'thumbnail',\n index: position,\n width: item.width,\n height: item.height,\n })}\n </button>\n </li>\n ))}\n </ul>\n )}\n\n <dialog\n ref={dialogRef}\n className={styles.viewer}\n aria-label={label}\n onKeyDown={event => handleArrowKeys(event)}\n >\n {isFullscreen && (\n <>\n <div className={styles.viewer__bar}>\n <span className={styles.viewer__count} aria-live=\"polite\">\n {current + 1} / {total}\n </span>\n {hasZoom && (\n <IconButton\n icon={isZoomed ? <ZoomOut aria-hidden /> : <ZoomIn aria-hidden />}\n label={\n isZoomed\n ? resolveLabel(\n 'Gallery.labels.zoomOut',\n labelProps?.zoomOut,\n config?.gallery?.zoomOut,\n )\n : resolveLabel(\n 'Gallery.labels.zoomIn',\n labelProps?.zoomIn,\n config?.gallery?.zoomIn,\n )\n }\n variant=\"secondary\"\n onClick={() => setIsZoomed(zoomed => !zoomed)}\n />\n )}\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Gallery.labels.close', labelProps?.close, config?.close)}\n variant=\"secondary\"\n onClick={close}\n />\n </div>\n <div\n className={cx(styles.viewer__stage, isZoomed && styles['viewer__stage--zoomed'])}\n onClick={toggleZoomAt}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onPointerMove={handleViewerMove}\n >\n {renderImage(imageProps('fullscreen', styles.viewer__image))}\n </div>\n {arrows}\n </>\n )}\n </dialog>\n </section>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Gallery, 'Gallery')) as typeof Gallery;\n"],"names":["SWIPE_DISTANCE","defaultRenderImage","src","alt","className","width","height","variant","jsx","setZoomOrigin","element","clientX","clientY","rect","x","y","Gallery","images","label","renderImage","controlledIndex","onIndexChange","hasZoom","placeholder","hasCounter","labelProps","testId","config","useUi","innerIndex","setInnerIndex","useState","isFullscreen","setIsFullscreen","isZoomed","setIsZoomed","dialogRef","useRef","thumbsRef","swipeRef","didSwipeRef","total","current","text","resolveLabel","_a","_b","_c","_d","select","useCallback","next","wrapped","close","useEffect","dialog","restoreFocus","captureFocus","token","pop","pushModal","handleCancel","event","isTopModal","useScrollLock","cx","styles","image","hasMany","handleArrowKeys","moveFocus","target","handlePointerDown","handlePointerUp","start","dx","dy","handleStageMove","openViewer","toggleZoomAt","zoomed","handleViewerMove","imageProps","arrows","jsxs","Fragment","IconButton","ChevronLeft","ChevronRight","ArrowsFullscreen","item","position","resolveFormatter","ZoomOut","ZoomIn","_e","_f","XLg","index","memo","named"],"mappings":"0iBAgGMA,GAAiB,GAEjBC,GAAqB,CAAC,CAC1B,IAAAC,EACA,IAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAAAC,CACF,IACEC,EAAAA,IAAC,MAAA,CACC,IAAAN,EACA,IAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAASC,IAAY,YAAc,OAAS,OAC5C,SAAS,QACT,UAAW,EAAA,CACb,EAIIE,EAAgB,CAACC,EAAsBC,EAAiBC,IAAoB,CAChF,MAAMC,EAAOH,EAAQ,sBAAA,EACfI,EAAID,EAAK,MAAQ,GAAMF,EAAUE,EAAK,MAAQA,EAAK,MAAS,IAAM,GAClEE,EAAIF,EAAK,OAAS,GAAMD,EAAUC,EAAK,KAAOA,EAAK,OAAU,IAAM,GACzEH,EAAQ,MAAM,YAAY,sBAAuB,GAAGI,CAAC,GAAG,EACxDJ,EAAQ,MAAM,YAAY,sBAAuB,GAAGK,CAAC,GAAG,CAC1D,EAGMC,GAAU,CAAC,CACf,OAAAC,EACA,MAAAC,EACA,Y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AA,IAAC8E,EAAAA,QAAA,CACC,KAAMpD,EAAW1B,EAAAA,IAACqF,EAAAA,QAAA,CAAQ,cAAW,GAAC,EAAKrF,EAAAA,IAACsF,EAAAA,OAAA,CAAO,cAAW,EAAA,CAAC,EAC/D,MACE5D,EACIU,EAAAA,aACE,yBACAnB,GAAA,YAAAA,EAAY,SACZsE,EAAApE,GAAA,YAAAA,EAAQ,UAAR,YAAAoE,EAAiB,OAAA,EAEnBnD,EAAAA,aACE,wBACAnB,GAAA,YAAAA,EAAY,QACZuE,EAAArE,GAAA,YAAAA,EAAQ,UAAR,YAAAqE,EAAiB,MAAA,EAGzB,QAAQ,YACR,QAAS,IAAM7D,EAAY6C,GAAU,CAACA,CAAM,CAAA,CAAA,EAGhDxE,EAAAA,IAAC8E,EAAAA,QAAA,CACC,KAAM9E,EAAAA,IAACyF,EAAAA,IAAA,CAAI,cAAW,EAAA,CAAC,EACvB,MAAOrD,EAAAA,aAAa,uBAAwBnB,GAAA,YAAAA,EAAY,MAAOE,GAAA,YAAAA,EAAQ,KAAK,EAC5E,QAAQ,YACR,QAAS0B,CAAA,CAAA,CACX,EACF,EACA7C,EAAAA,IAAC,MAAA,CACC,UAAWyD,EAAAA,GAAGC,UAAO,cAAehC,GAAYgC,EAAAA,QAAO,uBAAuB,CAAC,EAC/E,QAASa,GACT,cAAeP,EACf,YAAaC,EACb,cAAeQ,GAEd,SAAA9D,EAAY+D,EAAW,aAAchB,EAAAA,QAAO,aAAa,CAAC,CAAA,CAAA,EAE5DiB,CAAA,CAAA,CACH,CAAA,CAAA,CAEJ,EACF,CAEJ,EAEAe,GAA6BC,OAAmBC,GAAAA,MAAMpF,GAAS,SAAS,CAAC"}
|
|
@@ -46,11 +46,18 @@ type Props = {
|
|
|
46
46
|
onIndexChange?: (index: number) => void;
|
|
47
47
|
/** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */
|
|
48
48
|
hasZoom?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Drawn in the image's place when `images` is empty (3.4): the product's "no image" artwork.
|
|
51
|
+
* Without it an empty gallery draws nothing.
|
|
52
|
+
*/
|
|
53
|
+
placeholder?: ReactNode;
|
|
54
|
+
/** Writes "2 / 5" on the main image (3.4): on a phone the thumbnails may be scrolled away. */
|
|
55
|
+
hasCounter?: boolean;
|
|
49
56
|
labels?: Partial<GalleryLabels>;
|
|
50
57
|
className?: string;
|
|
51
58
|
testId?: string;
|
|
52
59
|
};
|
|
53
60
|
/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */
|
|
54
|
-
declare const Gallery: ({ images, label, renderImage, index: controlledIndex, onIndexChange, hasZoom, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element | null;
|
|
61
|
+
declare const Gallery: ({ images, label, renderImage, index: controlledIndex, onIndexChange, hasZoom, placeholder, hasCounter, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element | null;
|
|
55
62
|
declare const _default: typeof Gallery;
|
|
56
63
|
export default _default;
|
|
@@ -46,11 +46,18 @@ type Props = {
|
|
|
46
46
|
onIndexChange?: (index: number) => void;
|
|
47
47
|
/** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */
|
|
48
48
|
hasZoom?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Drawn in the image's place when `images` is empty (3.4): the product's "no image" artwork.
|
|
51
|
+
* Without it an empty gallery draws nothing.
|
|
52
|
+
*/
|
|
53
|
+
placeholder?: ReactNode;
|
|
54
|
+
/** Writes "2 / 5" on the main image (3.4): on a phone the thumbnails may be scrolled away. */
|
|
55
|
+
hasCounter?: boolean;
|
|
49
56
|
labels?: Partial<GalleryLabels>;
|
|
50
57
|
className?: string;
|
|
51
58
|
testId?: string;
|
|
52
59
|
};
|
|
53
60
|
/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */
|
|
54
|
-
declare const Gallery: ({ images, label, renderImage, index: controlledIndex, onIndexChange, hasZoom, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element | null;
|
|
61
|
+
declare const Gallery: ({ images, label, renderImage, index: controlledIndex, onIndexChange, hasZoom, placeholder, hasCounter, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element | null;
|
|
55
62
|
declare const _default: typeof Gallery;
|
|
56
63
|
export default _default;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { memo as
|
|
4
|
-
import { ChevronLeft as
|
|
5
|
-
import { cx as
|
|
6
|
-
import { named as
|
|
7
|
-
import { pushModal as
|
|
8
|
-
import { resolveLabel as
|
|
9
|
-
import
|
|
2
|
+
import { jsx as i, jsxs as y, Fragment as Q } from "react/jsx-runtime";
|
|
3
|
+
import { memo as le, useState as b, useRef as S, useCallback as P, useEffect as ce } from "react";
|
|
4
|
+
import { ChevronLeft as oe, ChevronRight as ue, ArrowsFullscreen as me, ZoomOut as de, ZoomIn as he, XLg as ye } from "react-bootstrap-icons";
|
|
5
|
+
import { cx as g } from "../../helpers/class-name.helper.js";
|
|
6
|
+
import { named as fe } from "../../helpers/component.helper.js";
|
|
7
|
+
import { pushModal as we, isTopModal as ge, captureFocus as ve } from "../../helpers/focus.helper.js";
|
|
8
|
+
import { resolveLabel as v, resolveFormatter as Ne } from "../../helpers/label.helper.js";
|
|
9
|
+
import _e from "../../hooks/useScrollLock.js";
|
|
10
10
|
import { useUi as xe } from "../../theme/context.js";
|
|
11
|
-
import
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
import p from "../IconButton/index.js";
|
|
12
|
+
const t = {"gallery":"ui-gallery-kHzW5","srOnly":"ui-srOnly-yZqYR","stage":"ui-stage-rg2mL","stage__open":"ui-stage__open-O-WpB","stage__hint":"ui-stage__hint-yvk-Q","stage--empty":"ui-stage--empty-ZC-pm","stage__counter":"ui-stage__counter-YXRje","image":"ui-image-eMyVt","stage--zoom":"ui-stage--zoom-gCoIw","arrow":"ui-arrow-HMm6V","viewer":"ui-viewer-mAIN4","arrow--previous":"ui-arrow--previous-iynhU","arrow--next":"ui-arrow--next-xShor","arrowIcon":"ui-arrowIcon--GW5Q","thumbs":"ui-thumbs-fquXS","thumb":"ui-thumb-Upsix","thumb__image":"ui-thumb__image-9VWiM","viewer__bar":"ui-viewer__bar-8DJT1","viewer__count":"ui-viewer__count--vw9Q","viewer__stage":"ui-viewer__stage-YmCnh","viewer__stage--zoomed":"ui-viewer__stage--zoomed-ktQdi","viewer__image":"ui-viewer__image-hHATa"};
|
|
13
|
+
const Me = 40, ke = ({
|
|
14
14
|
src: u,
|
|
15
|
-
alt:
|
|
16
|
-
className:
|
|
15
|
+
alt: f,
|
|
16
|
+
className: w,
|
|
17
17
|
width: s,
|
|
18
18
|
height: m,
|
|
19
19
|
variant: d
|
|
@@ -21,166 +21,174 @@ const Ne = 40, _e = ({
|
|
|
21
21
|
"img",
|
|
22
22
|
{
|
|
23
23
|
src: u,
|
|
24
|
-
alt:
|
|
25
|
-
className:
|
|
24
|
+
alt: f,
|
|
25
|
+
className: w,
|
|
26
26
|
width: s,
|
|
27
27
|
height: m,
|
|
28
28
|
loading: d === "thumbnail" ? "lazy" : void 0,
|
|
29
29
|
decoding: "async",
|
|
30
30
|
draggable: !1
|
|
31
31
|
}
|
|
32
|
-
),
|
|
33
|
-
const s = u.getBoundingClientRect(), m = s.width > 0 ? (
|
|
32
|
+
), E = (u, f, w) => {
|
|
33
|
+
const s = u.getBoundingClientRect(), m = s.width > 0 ? (f - s.left) / s.width * 100 : 50, d = s.height > 0 ? (w - s.top) / s.height * 100 : 50;
|
|
34
34
|
u.style.setProperty("--ui-gallery-zoom-x", `${m}%`), u.style.setProperty("--ui-gallery-zoom-y", `${d}%`);
|
|
35
|
-
},
|
|
35
|
+
}, ze = ({
|
|
36
36
|
images: u,
|
|
37
|
-
label:
|
|
38
|
-
renderImage:
|
|
37
|
+
label: f,
|
|
38
|
+
renderImage: w = ke,
|
|
39
39
|
index: s,
|
|
40
40
|
onIndexChange: m,
|
|
41
41
|
hasZoom: d = !0,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
placeholder: I,
|
|
43
|
+
hasCounter: ee,
|
|
44
|
+
labels: n,
|
|
45
|
+
className: O,
|
|
46
|
+
testId: T
|
|
45
47
|
}) => {
|
|
46
|
-
var
|
|
47
|
-
const { labels: r } = xe(), [
|
|
48
|
-
thumbnails:
|
|
48
|
+
var B, V, q, H, W, J;
|
|
49
|
+
const { labels: r } = xe(), [te, ne] = b(0), [k, X] = b(!1), [N, z] = b(!1), Y = S(null), K = S(null), A = S(null), G = S(!1), l = u.length, c = Math.max(0, Math.min(s ?? te, l - 1)), D = {
|
|
50
|
+
thumbnails: v(
|
|
49
51
|
"Gallery.labels.thumbnails",
|
|
50
|
-
|
|
51
|
-
(
|
|
52
|
+
n == null ? void 0 : n.thumbnails,
|
|
53
|
+
(B = r == null ? void 0 : r.gallery) == null ? void 0 : B.thumbnails
|
|
52
54
|
),
|
|
53
|
-
previous:
|
|
55
|
+
previous: v(
|
|
54
56
|
"Gallery.labels.previous",
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
+
n == null ? void 0 : n.previous,
|
|
58
|
+
(V = r == null ? void 0 : r.gallery) == null ? void 0 : V.previous
|
|
57
59
|
),
|
|
58
|
-
next:
|
|
59
|
-
fullscreen:
|
|
60
|
+
next: v("Gallery.labels.next", n == null ? void 0 : n.next, (q = r == null ? void 0 : r.gallery) == null ? void 0 : q.next),
|
|
61
|
+
fullscreen: v(
|
|
60
62
|
"Gallery.labels.fullscreen",
|
|
61
|
-
|
|
62
|
-
(
|
|
63
|
+
n == null ? void 0 : n.fullscreen,
|
|
64
|
+
(H = r == null ? void 0 : r.gallery) == null ? void 0 : H.fullscreen
|
|
63
65
|
)
|
|
64
|
-
},
|
|
66
|
+
}, _ = P(
|
|
65
67
|
(e) => {
|
|
66
68
|
const a = (e + l) % l;
|
|
67
|
-
s === void 0 &&
|
|
69
|
+
s === void 0 && ne(a), z(!1), m == null || m(a);
|
|
68
70
|
},
|
|
69
71
|
[s, m, l]
|
|
70
|
-
),
|
|
71
|
-
|
|
72
|
+
), F = P(() => {
|
|
73
|
+
X(!1), z(!1);
|
|
72
74
|
}, []);
|
|
73
|
-
if (
|
|
74
|
-
const e =
|
|
75
|
-
if (!
|
|
76
|
-
const a =
|
|
75
|
+
if (ce(() => {
|
|
76
|
+
const e = Y.current;
|
|
77
|
+
if (!k || !e) return;
|
|
78
|
+
const a = ve();
|
|
77
79
|
e.open || e.showModal();
|
|
78
|
-
const { token:
|
|
79
|
-
C.preventDefault(),
|
|
80
|
+
const { token: o, pop: h } = we(), M = (C) => {
|
|
81
|
+
C.preventDefault(), ge(o) && F();
|
|
80
82
|
};
|
|
81
|
-
return e.addEventListener("cancel",
|
|
82
|
-
e.removeEventListener("cancel",
|
|
83
|
+
return e.addEventListener("cancel", M), () => {
|
|
84
|
+
e.removeEventListener("cancel", M), e.open && e.close(), h(), a();
|
|
83
85
|
};
|
|
84
|
-
}, [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
}, [k, F]), _e(k), l === 0)
|
|
87
|
+
return I ? /* @__PURE__ */ i("section", { className: g(t.gallery, O), "aria-label": f, "data-testid": T, children: /* @__PURE__ */ i("div", { className: g(t.stage, t["stage--empty"]), children: I }) }) : null;
|
|
88
|
+
const R = u[c], x = l > 1, L = (e, a = !1) => {
|
|
89
|
+
var M, C;
|
|
90
|
+
const o = {
|
|
91
|
+
ArrowRight: c + 1,
|
|
92
|
+
ArrowLeft: c - 1,
|
|
90
93
|
Home: 0,
|
|
91
94
|
End: l - 1
|
|
92
95
|
};
|
|
93
|
-
if (!
|
|
96
|
+
if (!x || !(e.key in o)) return;
|
|
94
97
|
e.preventDefault();
|
|
95
|
-
const h = (
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
const a =
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
Math.abs(
|
|
104
|
-
},
|
|
105
|
-
d && e.pointerType === "mouse" &&
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
!d ||
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
src:
|
|
114
|
-
alt:
|
|
98
|
+
const h = (o[e.key] + l) % l;
|
|
99
|
+
_(h), a && ((C = (M = K.current) == null ? void 0 : M.querySelectorAll("button")[h]) == null || C.focus());
|
|
100
|
+
}, U = (e) => {
|
|
101
|
+
G.current = !1, A.current = N ? null : { x: e.clientX, y: e.clientY };
|
|
102
|
+
}, $ = (e) => {
|
|
103
|
+
const a = A.current;
|
|
104
|
+
if (A.current = null, !a || !x) return;
|
|
105
|
+
const o = e.clientX - a.x, h = e.clientY - a.y;
|
|
106
|
+
Math.abs(o) < Me || Math.abs(o) < Math.abs(h) || (G.current = !0, _(c + (o < 0 ? 1 : -1)));
|
|
107
|
+
}, re = (e) => {
|
|
108
|
+
d && e.pointerType === "mouse" && E(e.currentTarget, e.clientX, e.clientY);
|
|
109
|
+
}, ae = () => {
|
|
110
|
+
G.current || X(!0);
|
|
111
|
+
}, ie = (e) => {
|
|
112
|
+
!d || G.current || (E(e.currentTarget, e.clientX, e.clientY), z((a) => !a));
|
|
113
|
+
}, se = (e) => {
|
|
114
|
+
N && E(e.currentTarget, e.clientX, e.clientY);
|
|
115
|
+
}, Z = (e, a) => ({
|
|
116
|
+
src: R.src,
|
|
117
|
+
alt: R.alt,
|
|
115
118
|
className: a,
|
|
116
119
|
variant: e,
|
|
117
|
-
index:
|
|
118
|
-
width:
|
|
119
|
-
height:
|
|
120
|
-
}),
|
|
120
|
+
index: c,
|
|
121
|
+
width: R.width,
|
|
122
|
+
height: R.height
|
|
123
|
+
}), j = x && /* @__PURE__ */ y(Q, { children: [
|
|
121
124
|
/* @__PURE__ */ i(
|
|
122
|
-
|
|
125
|
+
p,
|
|
123
126
|
{
|
|
124
|
-
icon: /* @__PURE__ */ i(
|
|
125
|
-
label:
|
|
127
|
+
icon: /* @__PURE__ */ i(oe, { "aria-hidden": !0, className: t.arrowIcon }),
|
|
128
|
+
label: D.previous,
|
|
126
129
|
variant: "secondary",
|
|
127
130
|
shape: "round",
|
|
128
|
-
className:
|
|
129
|
-
onClick: () =>
|
|
131
|
+
className: g(t.arrow, t["arrow--previous"]),
|
|
132
|
+
onClick: () => _(c - 1)
|
|
130
133
|
}
|
|
131
134
|
),
|
|
132
135
|
/* @__PURE__ */ i(
|
|
133
|
-
|
|
136
|
+
p,
|
|
134
137
|
{
|
|
135
|
-
icon: /* @__PURE__ */ i(
|
|
136
|
-
label:
|
|
138
|
+
icon: /* @__PURE__ */ i(ue, { "aria-hidden": !0, className: t.arrowIcon }),
|
|
139
|
+
label: D.next,
|
|
137
140
|
variant: "secondary",
|
|
138
141
|
shape: "round",
|
|
139
|
-
className:
|
|
140
|
-
onClick: () =>
|
|
142
|
+
className: g(t.arrow, t["arrow--next"]),
|
|
143
|
+
onClick: () => _(c + 1)
|
|
141
144
|
}
|
|
142
145
|
)
|
|
143
146
|
] });
|
|
144
|
-
return /* @__PURE__ */
|
|
145
|
-
/* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ y("section", { className: g(t.gallery, O), "aria-label": f, "data-testid": T, children: [
|
|
148
|
+
/* @__PURE__ */ y(
|
|
146
149
|
"div",
|
|
147
150
|
{
|
|
148
|
-
className:
|
|
149
|
-
onPointerMove:
|
|
150
|
-
onPointerDown:
|
|
151
|
-
onPointerUp:
|
|
151
|
+
className: g(t.stage, d && t["stage--zoom"]),
|
|
152
|
+
onPointerMove: re,
|
|
153
|
+
onPointerDown: U,
|
|
154
|
+
onPointerUp: $,
|
|
152
155
|
onKeyDown: (e) => L(e),
|
|
153
156
|
children: [
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
|
|
156
|
-
/* @__PURE__ */ i("span", { className:
|
|
157
|
-
/* @__PURE__ */ i(
|
|
157
|
+
/* @__PURE__ */ y("button", { type: "button", className: t.stage__open, onClick: ae, children: [
|
|
158
|
+
w(Z("main", t.image)),
|
|
159
|
+
/* @__PURE__ */ i("span", { className: t.srOnly, children: D.fullscreen }),
|
|
160
|
+
/* @__PURE__ */ i(me, { "aria-hidden": !0, className: t.stage__hint })
|
|
158
161
|
] }),
|
|
159
|
-
|
|
162
|
+
ee && x && /* @__PURE__ */ y("span", { className: t.stage__counter, children: [
|
|
163
|
+
c + 1,
|
|
164
|
+
" / ",
|
|
165
|
+
l
|
|
166
|
+
] }),
|
|
167
|
+
j
|
|
160
168
|
]
|
|
161
169
|
}
|
|
162
170
|
),
|
|
163
|
-
|
|
164
|
-
var
|
|
171
|
+
x && /* @__PURE__ */ i("ul", { ref: K, className: t.thumbs, "aria-label": D.thumbnails, children: u.map((e, a) => {
|
|
172
|
+
var o;
|
|
165
173
|
return /* @__PURE__ */ i("li", { children: /* @__PURE__ */ i(
|
|
166
174
|
"button",
|
|
167
175
|
{
|
|
168
176
|
type: "button",
|
|
169
|
-
className:
|
|
170
|
-
"aria-current": a ===
|
|
171
|
-
"aria-label":
|
|
177
|
+
className: t.thumb,
|
|
178
|
+
"aria-current": a === c || void 0,
|
|
179
|
+
"aria-label": Ne(
|
|
172
180
|
"Gallery.labels.thumbnail",
|
|
173
|
-
(
|
|
181
|
+
(n == null ? void 0 : n.thumbnail) ?? ((o = r == null ? void 0 : r.gallery) == null ? void 0 : o.thumbnail),
|
|
174
182
|
a + 1,
|
|
175
183
|
l
|
|
176
184
|
),
|
|
177
|
-
tabIndex: a ===
|
|
178
|
-
onClick: () =>
|
|
185
|
+
tabIndex: a === c ? 0 : -1,
|
|
186
|
+
onClick: () => _(a),
|
|
179
187
|
onKeyDown: (h) => L(h, !0),
|
|
180
|
-
children:
|
|
188
|
+
children: w({
|
|
181
189
|
src: e.thumbnailSrc ?? e.src,
|
|
182
190
|
alt: "",
|
|
183
|
-
className:
|
|
191
|
+
className: t.thumb__image,
|
|
184
192
|
variant: "thumbnail",
|
|
185
193
|
index: a,
|
|
186
194
|
width: e.width,
|
|
@@ -192,62 +200,62 @@ const Ne = 40, _e = ({
|
|
|
192
200
|
/* @__PURE__ */ i(
|
|
193
201
|
"dialog",
|
|
194
202
|
{
|
|
195
|
-
ref:
|
|
196
|
-
className:
|
|
197
|
-
"aria-label":
|
|
203
|
+
ref: Y,
|
|
204
|
+
className: t.viewer,
|
|
205
|
+
"aria-label": f,
|
|
198
206
|
onKeyDown: (e) => L(e),
|
|
199
|
-
children:
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
|
|
207
|
+
children: k && /* @__PURE__ */ y(Q, { children: [
|
|
208
|
+
/* @__PURE__ */ y("div", { className: t.viewer__bar, children: [
|
|
209
|
+
/* @__PURE__ */ y("span", { className: t.viewer__count, "aria-live": "polite", children: [
|
|
210
|
+
c + 1,
|
|
203
211
|
" / ",
|
|
204
212
|
l
|
|
205
213
|
] }),
|
|
206
214
|
d && /* @__PURE__ */ i(
|
|
207
|
-
|
|
215
|
+
p,
|
|
208
216
|
{
|
|
209
|
-
icon:
|
|
210
|
-
label:
|
|
217
|
+
icon: N ? /* @__PURE__ */ i(de, { "aria-hidden": !0 }) : /* @__PURE__ */ i(he, { "aria-hidden": !0 }),
|
|
218
|
+
label: N ? v(
|
|
211
219
|
"Gallery.labels.zoomOut",
|
|
212
|
-
|
|
213
|
-
(
|
|
214
|
-
) :
|
|
220
|
+
n == null ? void 0 : n.zoomOut,
|
|
221
|
+
(W = r == null ? void 0 : r.gallery) == null ? void 0 : W.zoomOut
|
|
222
|
+
) : v(
|
|
215
223
|
"Gallery.labels.zoomIn",
|
|
216
|
-
|
|
217
|
-
(
|
|
224
|
+
n == null ? void 0 : n.zoomIn,
|
|
225
|
+
(J = r == null ? void 0 : r.gallery) == null ? void 0 : J.zoomIn
|
|
218
226
|
),
|
|
219
227
|
variant: "secondary",
|
|
220
|
-
onClick: () =>
|
|
228
|
+
onClick: () => z((e) => !e)
|
|
221
229
|
}
|
|
222
230
|
),
|
|
223
231
|
/* @__PURE__ */ i(
|
|
224
|
-
|
|
232
|
+
p,
|
|
225
233
|
{
|
|
226
|
-
icon: /* @__PURE__ */ i(
|
|
227
|
-
label:
|
|
234
|
+
icon: /* @__PURE__ */ i(ye, { "aria-hidden": !0 }),
|
|
235
|
+
label: v("Gallery.labels.close", n == null ? void 0 : n.close, r == null ? void 0 : r.close),
|
|
228
236
|
variant: "secondary",
|
|
229
|
-
onClick:
|
|
237
|
+
onClick: F
|
|
230
238
|
}
|
|
231
239
|
)
|
|
232
240
|
] }),
|
|
233
241
|
/* @__PURE__ */ i(
|
|
234
242
|
"div",
|
|
235
243
|
{
|
|
236
|
-
className:
|
|
237
|
-
onClick:
|
|
238
|
-
onPointerDown:
|
|
239
|
-
onPointerUp:
|
|
240
|
-
onPointerMove:
|
|
241
|
-
children:
|
|
244
|
+
className: g(t.viewer__stage, N && t["viewer__stage--zoomed"]),
|
|
245
|
+
onClick: ie,
|
|
246
|
+
onPointerDown: U,
|
|
247
|
+
onPointerUp: $,
|
|
248
|
+
onPointerMove: se,
|
|
249
|
+
children: w(Z("fullscreen", t.viewer__image))
|
|
242
250
|
}
|
|
243
251
|
),
|
|
244
|
-
|
|
252
|
+
j
|
|
245
253
|
] })
|
|
246
254
|
}
|
|
247
255
|
)
|
|
248
256
|
] });
|
|
249
|
-
},
|
|
257
|
+
}, Ie = /* @__PURE__ */ le(/* @__PURE__ */ fe(ze, "Gallery"));
|
|
250
258
|
export {
|
|
251
|
-
|
|
259
|
+
Ie as default
|
|
252
260
|
};
|
|
253
261
|
//# sourceMappingURL=index.js.map
|