@donotdev/components 0.2.3 → 0.3.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.
Files changed (120) hide show
  1. package/dist/CarouselContent-5W2E2F2I.js +1 -0
  2. package/dist/CarouselContent-EELYAALW.js +1 -0
  3. package/dist/CodeContent-7FWYPAB3.js +2 -0
  4. package/dist/CodeContent-E3HLW6BW.js +2 -0
  5. package/dist/advanced/Carousel/Carousel.d.ts +6 -4
  6. package/dist/advanced/Carousel/Carousel.d.ts.map +1 -1
  7. package/dist/advanced/Carousel/Carousel.js +10 -8
  8. package/dist/advanced/Carousel/CarouselContent.d.ts +35 -3
  9. package/dist/advanced/Carousel/CarouselContent.d.ts.map +1 -1
  10. package/dist/advanced/Carousel/CarouselContent.js +103 -67
  11. package/dist/advanced/Carousel/CarouselSkeleton.d.ts +3 -1
  12. package/dist/advanced/Carousel/CarouselSkeleton.d.ts.map +1 -1
  13. package/dist/advanced/Carousel/CarouselSkeleton.js +2 -2
  14. package/dist/advanced/ImageGallery/ImageGallery.d.ts +12 -2
  15. package/dist/advanced/ImageGallery/ImageGallery.d.ts.map +1 -1
  16. package/dist/advanced/ImageGallery/ImageGallery.js +3 -3
  17. package/dist/atomic/ActionButton/index.d.ts +1 -1
  18. package/dist/atomic/ActionButton/index.js +1 -1
  19. package/dist/atomic/Alert/index.d.ts +1 -1
  20. package/dist/atomic/Badge/index.d.ts +1 -1
  21. package/dist/atomic/Button/index.d.ts +30 -1
  22. package/dist/atomic/Button/index.d.ts.map +1 -1
  23. package/dist/atomic/Button/index.js +38 -1
  24. package/dist/atomic/Card/cover.d.ts +8 -1
  25. package/dist/atomic/Card/cover.d.ts.map +1 -1
  26. package/dist/atomic/Card/cover.js +2 -2
  27. package/dist/atomic/Card/index.d.ts +18 -3
  28. package/dist/atomic/Card/index.d.ts.map +1 -1
  29. package/dist/atomic/Card/index.js +20 -3
  30. package/dist/atomic/Collapsible/index.d.ts +7 -1
  31. package/dist/atomic/Collapsible/index.d.ts.map +1 -1
  32. package/dist/atomic/Collapsible/index.js +8 -3
  33. package/dist/atomic/Combobox/index.d.ts +11 -1
  34. package/dist/atomic/Combobox/index.d.ts.map +1 -1
  35. package/dist/atomic/Combobox/index.js +25 -9
  36. package/dist/atomic/DatePicker/index.d.ts +3 -1
  37. package/dist/atomic/DatePicker/index.d.ts.map +1 -1
  38. package/dist/atomic/DatePicker/index.js +2 -2
  39. package/dist/atomic/DateTimePicker/index.d.ts +3 -1
  40. package/dist/atomic/DateTimePicker/index.d.ts.map +1 -1
  41. package/dist/atomic/DateTimePicker/index.js +2 -2
  42. package/dist/atomic/HeroSection/index.d.ts +1 -1
  43. package/dist/atomic/Input/index.d.ts +3 -1
  44. package/dist/atomic/Input/index.d.ts.map +1 -1
  45. package/dist/atomic/Input/index.js +3 -3
  46. package/dist/atomic/Label/FieldInfo.d.ts +18 -0
  47. package/dist/atomic/Label/FieldInfo.d.ts.map +1 -0
  48. package/dist/atomic/Label/FieldInfo.js +34 -0
  49. package/dist/atomic/Label/FloatingLabel.d.ts +6 -1
  50. package/dist/atomic/Label/FloatingLabel.d.ts.map +1 -1
  51. package/dist/atomic/Label/FloatingLabel.js +6 -2
  52. package/dist/atomic/Label/index.d.ts +1 -0
  53. package/dist/atomic/Label/index.d.ts.map +1 -1
  54. package/dist/atomic/Label/index.js +1 -0
  55. package/dist/atomic/PasswordInput/index.d.ts +3 -1
  56. package/dist/atomic/PasswordInput/index.d.ts.map +1 -1
  57. package/dist/atomic/PasswordInput/index.js +2 -2
  58. package/dist/atomic/PinInput/index.d.ts +3 -1
  59. package/dist/atomic/PinInput/index.d.ts.map +1 -1
  60. package/dist/atomic/PinInput/index.js +2 -2
  61. package/dist/atomic/QuantityStepper/index.d.ts +19 -4
  62. package/dist/atomic/QuantityStepper/index.d.ts.map +1 -1
  63. package/dist/atomic/QuantityStepper/index.js +208 -5
  64. package/dist/atomic/QuantityStepper/quantity.d.ts +14 -0
  65. package/dist/atomic/QuantityStepper/quantity.d.ts.map +1 -0
  66. package/dist/atomic/QuantityStepper/quantity.js +35 -0
  67. package/dist/atomic/RangeInput/index.d.ts +3 -1
  68. package/dist/atomic/RangeInput/index.d.ts.map +1 -1
  69. package/dist/atomic/RangeInput/index.js +2 -2
  70. package/dist/atomic/Rating/index.d.ts +1 -1
  71. package/dist/atomic/Select/index.d.ts +3 -1
  72. package/dist/atomic/Select/index.d.ts.map +1 -1
  73. package/dist/atomic/Select/index.js +2 -2
  74. package/dist/atomic/Stepper/index.d.ts +1 -1
  75. package/dist/atomic/SwipeAction/gesture.d.ts +5 -0
  76. package/dist/atomic/SwipeAction/gesture.d.ts.map +1 -0
  77. package/dist/atomic/SwipeAction/gesture.js +10 -0
  78. package/dist/atomic/SwipeAction/index.d.ts +12 -0
  79. package/dist/atomic/SwipeAction/index.d.ts.map +1 -0
  80. package/dist/atomic/SwipeAction/index.js +62 -0
  81. package/dist/atomic/Table/editing.d.ts +3 -1
  82. package/dist/atomic/Table/editing.d.ts.map +1 -1
  83. package/dist/atomic/Table/editing.js +9 -6
  84. package/dist/atomic/Table/index.d.ts +9 -1
  85. package/dist/atomic/Table/index.d.ts.map +1 -1
  86. package/dist/atomic/Table/index.js +64 -48
  87. package/dist/atomic/Tabs/index.d.ts +1 -1
  88. package/dist/atomic/Tag/index.d.ts +3 -1
  89. package/dist/atomic/Tag/index.d.ts.map +1 -1
  90. package/dist/atomic/Tag/index.js +2 -2
  91. package/dist/atomic/Toaster/ToastPrimitive.d.ts +2 -2
  92. package/dist/atomic/Toaster/ToastPrimitive.d.ts.map +1 -1
  93. package/dist/atomic/Toggle/index.d.ts +1 -1
  94. package/dist/atomic/index.d.ts +6 -3
  95. package/dist/atomic/index.d.ts.map +1 -1
  96. package/dist/atomic/index.js +3 -1
  97. package/dist/chunk-SZNEXFUZ.js +3 -0
  98. package/dist/chunk-XK52GUFA.js +3 -0
  99. package/dist/hooks/useIntersectionObserver.d.ts +2 -1
  100. package/dist/hooks/useIntersectionObserver.d.ts.map +1 -1
  101. package/dist/hooks/useIntersectionObserver.js +6 -7
  102. package/dist/index.js +10 -10
  103. package/dist/styles/index.css +316 -51
  104. package/dist/symbol-index.json +1 -1
  105. package/dist/types.d.ts +7 -0
  106. package/dist/types.d.ts.map +1 -1
  107. package/dist/utils/sanitizeDom.browser.d.ts +8 -0
  108. package/dist/utils/sanitizeDom.browser.d.ts.map +1 -0
  109. package/dist/utils/sanitizeDom.browser.js +1 -0
  110. package/dist/utils/sanitizeDom.server.d.ts +9 -0
  111. package/dist/utils/sanitizeDom.server.d.ts.map +1 -0
  112. package/dist/utils/sanitizeDom.server.js +1 -0
  113. package/dist/utils/sanitizeHtml.d.ts.map +1 -1
  114. package/dist/utils/sanitizeHtml.js +7 -6
  115. package/dist/utils/variants.d.ts +1 -1
  116. package/guidelines/API_REFERENCE.md +3 -2
  117. package/guidelines/COMPONENTS.md +10 -5
  118. package/guidelines/QUANTITY_STEPPER.md +78 -0
  119. package/guidelines/SWIPE_ACTION.md +101 -0
  120. package/package.json +8 -2
@@ -0,0 +1 @@
1
+ import{a as Ie}from"./chunk-IFHHPSKN.js";import{c as Me,f as Ee}from"./chunk-CIBFOOWV.js";import{a as P,k as ke}from"./chunk-UTPWB5VD.js";import"./chunk-O2XFH626.js";import{ChevronLeft as lt,ChevronRight as it,Play as ct,Pause as ut}from"lucide-react";import{useRef as M,useState as p,useEffect as N,useLayoutEffect as Le,useCallback as i,useMemo as Z,memo as dt}from"react";import{Fragment as vt,jsx as l,jsxs as Re}from"react/jsx-runtime";var gt=(n,V)=>`Slide ${n} of ${V}`,bt=n=>`Go to slide ${n}`,ee=n=>{n.currentTarget.style.opacity="1"};function ft({items:n,renderItem:V,className:te,slideClassName:Xe,showArrows:Se=!0,showDots:$e=!1,showProgress:Pe=!0,autoplay:X=!1,autoplayInterval:re=5e3,transition:ne="slide",infinite:Ne=!1,slidesToShow:E=1,gap:oe="none",swipeable:ae=!0,momentum:S=!0,onActiveChange:se,onSlideClick:Fe,keyExtractor:le,"aria-label":Ae="Carousel",previousLabel:ze="Previous slide",nextLabel:He="Next slide",playLabel:qe="Play carousel",pauseLabel:Oe="Pause carousel",slideLabel:ie=gt,goToSlideLabel:Ve=bt,emptyLabel:je="No items to display",pauseOnHover:ce=!0,pauseOnInvisible:pt=!0,showPlayPause:Be=!0,lazy:ue=!1,preloadDistance:de=1}){let ge=Array.isArray(E)?E:[E,E,E,E],[F,j,B,G]=ge,be=Math.max(...ge),d=Ne&&n.length>be,h=d?Math.max(be,2):0,A=M(null),C=M(null),[a,fe]=p(0),[T,me]=p(X),[K,ve]=p(!1),[Q,pe]=p(!1),[Ge,Ke]=p(!1);N(()=>Ke(!0),[]);let[I,Qe]=p(!0),[g,W]=p({isDragging:!1,startX:0,currentX:0,startTime:0,velocity:0}),Y=M(null),y=M(null),b=M(null),[$,he]=p("idle"),[z,ye]=p(!1);N(()=>{if(typeof window>"u")return;let e=window.matchMedia("(prefers-reduced-motion: reduce)");return ye(e.matches),Ee(e,"change",r=>{ye(r.matches)})},[]);let[L,Te]=p(F);Le(()=>{let e=[{mq:window.matchMedia("(min-width: 1440px)"),value:G},{mq:window.matchMedia("(min-width: 1024px)"),value:B},{mq:window.matchMedia("(min-width: 768px)"),value:j}],t=()=>{for(let{mq:o,value:s}of e)if(o.matches){Te(s);return}Te(F)};t();let r=e.map(({mq:o})=>{let s=()=>t();return o.addEventListener("change",s),()=>o.removeEventListener("change",s)});return()=>r.forEach(o=>o())},[F,j,B,G]);let H=Z(()=>({tension:.3,friction:.8,mass:1}),[]),We=Z(()=>{if(!d)return n;let e=n.slice(-h),t=n.slice(0,h);return[...e,...n,...t]},[n,d,h]),c=Z(()=>100/L,[L]),Ye=Math.ceil(L/2)-1,q=Math.max(0,n.length-L),v=i(e=>d?e+h:Math.max(0,Math.min(e,q)),[d,h,q]),O=M(a);O.current=a,Le(()=>{let e=C.current;if(!e)return;let t=d?O.current:Math.min(O.current,q);t!==O.current&&fe(t),e.style.transition="none",e.style.transform=`translateX(-${v(t)*c}%)`},[d,q,v,c]);let _e=i(e=>d?((e-h)%n.length+n.length)%n.length:e,[d,n.length,h]),xe=M(I);xe.current=I;let _=i((e,t,r=0)=>{if(!S)return;let o=parseFloat(e.style.transform.replace("translateX(","").replace("%)",""))||0,s=r,u=Date.now(),m=()=>{let D=(Date.now()-u)/1e3,w=o-t,ot=-H.tension*w,at=-H.friction*s,st=(ot+at)/H.mass;s+=st*D,o+=s*D,e.style.transform=`translateX(${o}%)`,xe.current?Math.abs(w)>.1||Math.abs(s)>.1?y.current=requestAnimationFrame(m):(e.style.transform=`translateX(${t}%)`,e.style.transition="none",y.current=null):(e.style.transform=`translateX(${t}%)`,e.style.transition="none",y.current=null)};y.current!==null&&cancelAnimationFrame(y.current),y.current=requestAnimationFrame(m)},[S,H]),we=i((e,t,r)=>{switch(ne){case"fade":{e.style.transition=`opacity ${r} ease-in-out`,e.style.opacity="0";let s=parseInt(r,10)||300;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,e.style.transform=`translateX(${t}%)`,e.style.opacity="1"},s/2);break}case"scale":{e.style.transition=`transform ${r} cubic-bezier(0.25, 0.46, 0.45, 0.94)`,e.style.transform=`translateX(${t}%) scale(0.95)`;let s=parseInt(r,10)||300;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,e.style.transform=`translateX(${t}%) scale(1)`},s/2);break}case"parallax":e.style.transition=`transform ${r} cubic-bezier(0.25, 0.46, 0.45, 0.94)`,e.style.transform=`translateX(${t}%)`,e.querySelectorAll('[role="group"]').forEach((s,u)=>{let m=s,k=(u-Math.abs(t)/c)*.1;m.style.transform=`translateX(${k}%)`});break;default:e.style.transition=`transform ${r} cubic-bezier(0.25, 0.46, 0.45, 0.94)`,e.style.transform=`translateX(${t}%)`;break}},[ne,c]),f=i((e,t=!1)=>{if($!=="idle"&&!t||!I&&!t)return;let r=C.current;if(!r)return;let o=v(e);if(!d&&o===a&&!t)return;let s=-(o*c),u=t||z?"0ms":"300ms";t||he("transitioning"),we(r,s,u);let m=d?(e%n.length+n.length)%n.length:o;if(fe(m),se?.(m),d){let k=o<h,D=o>=n.length+h;if(k||D){let w=k?o+n.length:o-n.length;r.dataset.needsReset="true",r.dataset.resetIndex=w.toString()}if(t&&r.dataset.needsReset==="true"){let w=parseInt(r.dataset.resetIndex||"0");r.style.transition="none",r.style.transform=`translateX(-${w*c}%)`,delete r.dataset.needsReset,delete r.dataset.resetIndex}}},[d,v,a,n.length,c,se,z,$,I,we]),x=i(()=>{f(a+1)},[a,f]),R=i(()=>{f(a-1)},[a,f]),J=i(()=>{me(!0)},[]),U=i(()=>{me(!1)},[]);N(()=>{if(!(!T||K||Q||z||!I||n.length<=1))return Y.current=setTimeout(()=>{x()},re),()=>{Y.current&&clearTimeout(Y.current)}},[T,K,Q,z,I,a,x,re,n.length]),N(()=>A.current?Me(A.current,t=>Qe(t.isIntersecting),{threshold:.1}):void 0,[]),N(()=>()=>{y.current!==null&&(cancelAnimationFrame(y.current),y.current=null),b.current!==null&&(clearTimeout(b.current),b.current=null)},[]);let Je=i(e=>ue?Math.abs(e-a)<=de:!0,[ue,a,de]),Ue=i(e=>{if(!ae||$!=="idle")return;let t=e.touches[0];t&&W({isDragging:!0,startX:t.clientX,currentX:t.clientX,startTime:Date.now(),velocity:0})},[ae,$]),Ze=i(e=>{if(!g.isDragging)return;let t=e.touches[0];if(!t)return;let r=t.clientX-g.startX,o=Date.now()-g.startTime,s=o>0?r/o:0,u=C.current;if(u&&Math.abs(r)>10){e.preventDefault();let m=-(v(a)*c),k=r/(A.current?.clientWidth||1)*100,D=Math.min(Math.abs(r)/200,.8),w=k*(1-D);u.style.transition="none",u.style.transform=`translateX(${m+w}%)`}W(m=>({...m,currentX:t.clientX,velocity:s}))},[g.isDragging,g.startX,g.startTime,a,c,v]),et=i(()=>{if(!g.isDragging)return;let e=g.currentX-g.startX,t=g.velocity,r=50;if(S&&Math.abs(t)>.5){let o=C.current;if(o){let s=t>0?a-1:a+1,u=-(v(s)*c);_(o,u,t*100),f(s,!0)}}else if(Math.abs(e)>r)e>0?R():x();else{let o=C.current;if(o&&S){let s=-(v(a)*c);_(o,s,t*100)}else f(a,!0)}W({isDragging:!1,startX:0,currentX:0,startTime:0,velocity:0})},[g,S,x,R,f,a,_,c,v]),tt=i(()=>{he("idle");let e=C.current;if(e?.dataset.needsReset==="true"){let t=parseInt(e.dataset.resetIndex||"0");e.style.transition="none",e.style.transform=`translateX(-${t*c}%)`,delete e.dataset.needsReset,delete e.dataset.resetIndex}},[c]),rt=i(e=>{if(e.target!==e.currentTarget)return;let t=Ie();switch(e.key){case"ArrowLeft":e.preventDefault(),t?x():R();break;case"ArrowRight":e.preventDefault(),t?R():x();break;case"Home":e.preventDefault(),f(0);break;case"End":e.preventDefault(),f(n.length-1);break;case" ":if(!X)return;e.preventDefault(),T?U():J();break}},[x,R,f,n.length,T,J,U,X]),Ce=v(a),nt=T&&!K&&!Q;return!n||n.length===0?l(ke,{align:"center",justify:"center",className:P("dndev-relative",te),children:l("div",{style:{color:"var(--muted-foreground)"},children:je})}):Re("div",{ref:A,className:P("dndev-relative dndev-overflow-hidden",te),style:{outline:"none","--carousel-slides-mobile":F,"--carousel-slides-tablet":j,"--carousel-slides-laptop":B,"--carousel-slides-desktop":G},onMouseEnter:()=>ce&&ve(!0),onMouseLeave:()=>ce&&ve(!1),onFocus:()=>pe(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||pe(!1)},onKeyDown:rt,tabIndex:0,role:"region","aria-roledescription":"carousel","aria-label":Ae,children:[l("div",{className:"dndev-overflow-hidden",children:l("div",{ref:C,className:P("dndev-flex",g.isDragging&&"dndev-pointer-events-none",$==="transitioning"&&"dndev-pointer-events-none"),style:{cursor:g.isDragging?"grabbing":void 0},onTransitionEnd:tt,onTouchStart:Ue,onTouchMove:Ze,onTouchEnd:et,children:We.map((e,t)=>{let r=_e(t),o=Ge&&n.length>L&&(t<Ce||t>=Ce+L),s=r===(a+Ye)%n.length,u=Je(r);return l("div",{className:P("dndev-carousel-slide",Xe),"data-gap":oe!=="none"?oe:void 0,style:{opacity:u?1:0},role:"group","aria-roledescription":"slide","aria-label":ie(r+1,n.length),inert:o||void 0,onClick:()=>Fe?.(e,r),children:u&&V(e,r,s)},le?le(e,r):`${r}-${t}`)})})}),Se&&n.length>1&&Re(vt,{children:[l("button",{className:"dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center",style:{insetInlineStart:"1rem",top:"50%",transform:"translateY(-50%)",width:"2.5rem",height:"2.5rem",opacity:0,transition:"opacity var(--dur-normal)",borderRadius:"9999px",backgroundColor:"rgb(from var(--background) r g b / 0.8)",border:"1px solid var(--border)",outline:"none"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.9)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.8)"},onFocus:ee,onClick:R,type:"button","aria-label":ze,children:l(lt,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}})}),l("button",{className:"dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center",style:{insetInlineEnd:"1rem",top:"50%",transform:"translateY(-50%)",width:"2.5rem",height:"2.5rem",opacity:0,transition:"opacity var(--dur-normal)",borderRadius:"9999px",backgroundColor:"rgb(from var(--background) r g b / 0.8)",border:"1px solid var(--border)",outline:"none"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.9)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.8)"},onFocus:ee,onClick:x,type:"button","aria-label":He,children:l(it,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}})})]}),X&&Be&&l("button",{className:"dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center",style:{insetBlockStart:"var(--gap-md)",insetInlineEnd:"var(--gap-md)",width:"2rem",height:"2rem",opacity:0,transition:"opacity var(--dur-normal)",borderRadius:"9999px",backgroundColor:"rgb(from var(--background) r g b / 0.8)",border:"1px solid var(--border)",outline:"none"},type:"button",onFocus:ee,onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.9)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.8)"},onClick:()=>T?U():J(),"aria-label":T?Oe:qe,children:T?l(ut,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}}):l(ct,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}})}),$e&&n.length>1&&l("div",{className:"dndev-absolute dndev-flex dndev-gap-sm dndev-z-breadcrumbs",style:{bottom:"1rem",insetInlineStart:"50%",transform:"translateX(-50%)"},children:n.map((e,t)=>l("button",{type:"button","aria-current":t===a||void 0,style:{width:t===a?"1.5rem":"0.5rem",height:"0.5rem",borderRadius:"9999px",transition:"all 0.3s",outline:"none",backgroundColor:t===a?"var(--foreground)":"rgb(from var(--foreground) r g b / 0.3)"},onMouseEnter:r=>{t!==a&&(r.currentTarget.style.backgroundColor="rgb(from var(--foreground) r g b / 0.5)")},onMouseLeave:r=>{t!==a&&(r.currentTarget.style.backgroundColor="rgb(from var(--foreground) r g b / 0.3)")},onClick:()=>f(t),"aria-label":Ve(t+1)},t))}),Pe&&X&&l("div",{className:"dndev-absolute",style:{bottom:0,insetInlineStart:0,insetInlineEnd:0,height:"0.25rem",backgroundColor:"rgb(from var(--foreground) r g b / 0.2)"},children:l("div",{style:{height:"100%",width:`${(a+1)/n.length*100}%`,backgroundColor:"var(--foreground)",transition:"width 0.1s linear"}})}),l("div",{className:"dndev-sr-only","aria-live":nt?"off":"polite","aria-atomic":"true",children:ie(a+1,n.length)})]})}var De=dt(ft);De.displayName="Carousel";var mt=De,Rt=mt;export{Rt as default};
@@ -0,0 +1 @@
1
+ import{a as Me}from"./chunk-IFHHPSKN.js";import{c as xe,f as Ce}from"./chunk-CIBFOOWV.js";import{a as F,k as we}from"./chunk-UTPWB5VD.js";import"./chunk-O2XFH626.js";import{ChevronLeft as rt,ChevronRight as nt,Play as ot,Pause as at}from"lucide-react";import{useRef as k,useState as h,useEffect as D,useLayoutEffect as st,useCallback as d,useMemo as J,memo as lt}from"react";import{Fragment as gt,jsx as l,jsxs as ke}from"react/jsx-runtime";var it=(n,j)=>`Slide ${n} of ${j}`,ct=n=>`Go to slide ${n}`,U=n=>{n.currentTarget.style.opacity="1"};function ut({items:n,renderItem:j,className:Z,slideClassName:Le,showArrows:Re=!0,showDots:Ie=!1,showProgress:De=!0,autoplay:X=!1,autoplayInterval:ee=5e3,transition:te="slide",infinite:g=!0,slidesToShow:E=1,gap:re="none",swipeable:ne=!0,momentum:S=!0,onActiveChange:oe,onSlideClick:Xe,keyExtractor:ae,"aria-label":Se="Carousel",previousLabel:$e="Previous slide",nextLabel:Pe="Next slide",playLabel:Ne="Play carousel",pauseLabel:Fe="Pause carousel",slideLabel:se=it,goToSlideLabel:Ae=ct,emptyLabel:ze="No items to display",pauseOnHover:le=!0,pauseOnInvisible:mt=!0,showPlayPause:He=!0,lazy:ie=!1,preloadDistance:ce=1}){let ue=Array.isArray(E)?E:[E,E,E,E],[$,A,z,H]=ue,i=Math.max(...ue),q=k(null),T=k(null),[s,qe]=h(0),[w,de]=h(X),[B,ge]=h(!1),[G,me]=h(!1),[Oe,Ve]=h(!1);D(()=>Ve(!0),[]);let[L,je]=h(!0),[m,K]=h({isDragging:!1,startX:0,currentX:0,startTime:0,velocity:0}),Q=k(null),p=k(null),b=k(null),[P,be]=h("idle"),[O,fe]=h(!1);D(()=>{if(typeof window>"u")return;let e=window.matchMedia("(prefers-reduced-motion: reduce)");return fe(e.matches),Ce(e,"change",r=>{fe(r.matches)})},[]);let[N,ve]=h(()=>typeof window>"u"?$:window.matchMedia("(min-width: 1440px)").matches?H:window.matchMedia("(min-width: 1024px)").matches?z:window.matchMedia("(min-width: 768px)").matches?A:$);D(()=>{if(typeof window>"u")return;let e=[{mq:window.matchMedia("(min-width: 1440px)"),value:H},{mq:window.matchMedia("(min-width: 1024px)"),value:z},{mq:window.matchMedia("(min-width: 768px)"),value:A}],t=()=>{for(let{mq:o,value:a}of e)if(o.matches){ve(a);return}ve($)},r=e.map(({mq:o})=>{let a=()=>t();return o.addEventListener("change",a),()=>o.removeEventListener("change",a)});return()=>r.forEach(o=>o())},[$,A,z,H]);let V=J(()=>({tension:.3,friction:.8,mass:1}),[]),Be=J(()=>{if(!g||n.length<=i)return n;let e=Math.max(i,2),t=n.slice(-e),r=n.slice(0,e);return[...t,...n,...r]},[n,g,i]),c=J(()=>100/N,[N]),Ge=Math.ceil(N/2)-1,he=k(!1);st(()=>{if(he.current||!g||!T.current||n.length<=i)return;he.current=!0;let e=Math.max(i,2);T.current.style.transform=`translateX(-${e*c}%)`},[g,i,c,n.length]);let Ke=d(e=>{if(!g)return e;let t=Math.max(i,2);return((e-t)%n.length+n.length)%n.length},[g,n.length,i]),pe=k(L);pe.current=L;let W=d((e,t,r=0)=>{if(!S)return;let o=parseFloat(e.style.transform.replace("translateX(","").replace("%)",""))||0,a=r,u=Date.now(),v=()=>{let C=(Date.now()-u)/1e3,I=o-t,M=-V.tension*I,et=-V.friction*a,tt=(M+et)/V.mass;a+=tt*C,o+=a*C,e.style.transform=`translateX(${o}%)`,pe.current?Math.abs(I)>.1||Math.abs(a)>.1?p.current=requestAnimationFrame(v):(e.style.transform=`translateX(${t}%)`,e.style.transition="none",p.current=null):(e.style.transform=`translateX(${t}%)`,e.style.transition="none",p.current=null)};p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(v)},[S,V]),ye=d((e,t,r)=>{switch(te){case"fade":{e.style.transition=`opacity ${r} ease-in-out`,e.style.opacity="0";let a=parseInt(r,10)||300;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,e.style.transform=`translateX(${t}%)`,e.style.opacity="1"},a/2);break}case"scale":{e.style.transition=`transform ${r} cubic-bezier(0.25, 0.46, 0.45, 0.94)`,e.style.transform=`translateX(${t}%) scale(0.95)`;let a=parseInt(r,10)||300;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,e.style.transform=`translateX(${t}%) scale(1)`},a/2);break}case"parallax":e.style.transition=`transform ${r} cubic-bezier(0.25, 0.46, 0.45, 0.94)`,e.style.transform=`translateX(${t}%)`,e.querySelectorAll('[role="group"]').forEach((a,u)=>{let v=a,y=(u-Math.abs(t)/c)*.1;v.style.transform=`translateX(${y}%)`});break;default:e.style.transition=`transform ${r} cubic-bezier(0.25, 0.46, 0.45, 0.94)`,e.style.transform=`translateX(${t}%)`;break}},[te,c]),f=d((e,t=!1)=>{if(P!=="idle"&&!t||!L&&!t)return;let r=T.current;if(!r)return;let o=e;if(g){let y=Math.max(i,2);o=e+y}else o=Math.max(0,Math.min(e,n.length-1));let a=-(o*c),u=t||O?"0ms":"300ms";t||be("transitioning"),ye(r,a,u);let v=g?(e%n.length+n.length)%n.length:o;if(qe(v),oe?.(v),g){let y=Math.max(i,2),C=o<y,I=o>=n.length+y;if(C||I){let M=C?o+n.length:o-n.length;r.dataset.needsReset="true",r.dataset.resetIndex=M.toString()}if(t&&r.dataset.needsReset==="true"){let M=parseInt(r.dataset.resetIndex||"0");r.style.transition="none",r.style.transform=`translateX(-${M*c}%)`,delete r.dataset.needsReset,delete r.dataset.resetIndex}}},[g,n.length,c,i,oe,O,P,L,ye]),x=d(()=>{f(s+1)},[s,f]),R=d(()=>{f(s-1)},[s,f]),Y=d(()=>{de(!0)},[]),_=d(()=>{de(!1)},[]);D(()=>{if(!(!w||B||G||O||!L||n.length<=1))return Q.current=setTimeout(()=>{x()},ee),()=>{Q.current&&clearTimeout(Q.current)}},[w,B,G,O,L,s,x,ee,n.length]),D(()=>q.current?xe(q.current,t=>je(t.isIntersecting),{threshold:.1}):void 0,[]),D(()=>()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),b.current!==null&&(clearTimeout(b.current),b.current=null)},[]);let Qe=d(e=>ie?Math.abs(e-s)<=ce:!0,[ie,s,ce]),We=d(e=>{if(!ne||P!=="idle")return;let t=e.touches[0];t&&K({isDragging:!0,startX:t.clientX,currentX:t.clientX,startTime:Date.now(),velocity:0})},[ne,P]),Ye=d(e=>{if(!m.isDragging)return;let t=e.touches[0];if(!t)return;let r=t.clientX-m.startX,o=Date.now()-m.startTime,a=o>0?r/o:0,u=T.current;if(u&&Math.abs(r)>10){e.preventDefault();let v=g?Math.max(i,2):0,y=-((s+v)*c),C=r/(q.current?.clientWidth||1)*100,I=Math.min(Math.abs(r)/200,.8),M=C*(1-I);u.style.transition="none",u.style.transform=`translateX(${y+M}%)`}K(v=>({...v,currentX:t.clientX,velocity:a}))},[m.isDragging,m.startX,m.startTime,s,c,g,i]),_e=d(()=>{if(!m.isDragging)return;let e=m.currentX-m.startX,t=m.velocity,r=50;if(S&&Math.abs(t)>.5){let o=T.current;if(o){let a=t>0?s-1:s+1,u=-(a*c);W(o,u,t*100),f(a,!0)}}else if(Math.abs(e)>r)e>0?R():x();else{let o=T.current;if(o&&S){let a=-(s*c);W(o,a,t*100)}else f(s,!0)}K({isDragging:!1,startX:0,currentX:0,startTime:0,velocity:0})},[m,S,x,R,f,s,W,c]),Je=d(()=>{be("idle");let e=T.current;if(e?.dataset.needsReset==="true"){let t=parseInt(e.dataset.resetIndex||"0");e.style.transition="none",e.style.transform=`translateX(-${t*c}%)`,delete e.dataset.needsReset,delete e.dataset.resetIndex}},[c]),Ue=d(e=>{if(e.target!==e.currentTarget)return;let t=Me();switch(e.key){case"ArrowLeft":e.preventDefault(),t?x():R();break;case"ArrowRight":e.preventDefault(),t?R():x();break;case"Home":e.preventDefault(),f(0);break;case"End":e.preventDefault(),f(n.length-1);break;case" ":if(!X)return;e.preventDefault(),w?_():Y();break}},[x,R,f,n.length,w,Y,_,X]),Te=g&&n.length>i?s+Math.max(i,2):s,Ze=w&&!B&&!G;return!n||n.length===0?l(we,{align:"center",justify:"center",className:F("dndev-relative",Z),children:l("div",{style:{color:"var(--muted-foreground)"},children:ze})}):ke("div",{ref:q,className:F("dndev-relative dndev-overflow-hidden",Z),style:{outline:"none","--carousel-slides-mobile":$,"--carousel-slides-tablet":A,"--carousel-slides-laptop":z,"--carousel-slides-desktop":H},onMouseEnter:()=>le&&ge(!0),onMouseLeave:()=>le&&ge(!1),onFocus:()=>me(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||me(!1)},onKeyDown:Ue,tabIndex:0,role:"region","aria-roledescription":"carousel","aria-label":Se,children:[l("div",{className:"dndev-overflow-hidden",children:l("div",{ref:T,className:F("dndev-flex",m.isDragging&&"dndev-pointer-events-none",P==="transitioning"&&"dndev-pointer-events-none"),style:{cursor:m.isDragging?"grabbing":void 0},onTransitionEnd:Je,onTouchStart:We,onTouchMove:Ye,onTouchEnd:_e,children:Be.map((e,t)=>{let r=Ke(t),o=Oe&&n.length>N&&(t<Te||t>=Te+N),a=r===(s+Ge)%n.length,u=Qe(r);return l("div",{className:F("dndev-carousel-slide",Le),"data-gap":re!=="none"?re:void 0,style:{opacity:u?1:0},role:"group","aria-roledescription":"slide","aria-label":se(r+1,n.length),inert:o||void 0,onClick:()=>Xe?.(e,r),children:u&&j(e,r,a)},ae?ae(e,r):`${r}-${t}`)})})}),Re&&n.length>1&&ke(gt,{children:[l("button",{className:"dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center",style:{insetInlineStart:"1rem",top:"50%",transform:"translateY(-50%)",width:"2.5rem",height:"2.5rem",opacity:0,transition:"opacity var(--dur-normal)",borderRadius:"9999px",backgroundColor:"rgb(from var(--background) r g b / 0.8)",border:"1px solid var(--border)",outline:"none"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.9)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.8)"},onFocus:U,onClick:R,type:"button","aria-label":$e,children:l(rt,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}})}),l("button",{className:"dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center",style:{insetInlineEnd:"1rem",top:"50%",transform:"translateY(-50%)",width:"2.5rem",height:"2.5rem",opacity:0,transition:"opacity var(--dur-normal)",borderRadius:"9999px",backgroundColor:"rgb(from var(--background) r g b / 0.8)",border:"1px solid var(--border)",outline:"none"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.9)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.8)"},onFocus:U,onClick:x,type:"button","aria-label":Pe,children:l(nt,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}})})]}),X&&He&&l("button",{className:"dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center",style:{insetBlockStart:"var(--gap-md)",insetInlineEnd:"var(--gap-md)",width:"2rem",height:"2rem",opacity:0,transition:"opacity var(--dur-normal)",borderRadius:"9999px",backgroundColor:"rgb(from var(--background) r g b / 0.8)",border:"1px solid var(--border)",outline:"none"},type:"button",onFocus:U,onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.9)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="rgb(from var(--background) r g b / 0.8)"},onClick:()=>w?_():Y(),"aria-label":w?Fe:Ne,children:w?l(at,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}}):l(ot,{style:{width:"var(--icon-md)",height:"var(--icon-md)",color:"var(--foreground)"}})}),Ie&&n.length>1&&l("div",{className:"dndev-absolute dndev-flex dndev-gap-sm dndev-z-breadcrumbs",style:{bottom:"1rem",insetInlineStart:"50%",transform:"translateX(-50%)"},children:n.map((e,t)=>l("button",{type:"button","aria-current":t===s||void 0,style:{width:t===s?"1.5rem":"0.5rem",height:"0.5rem",borderRadius:"9999px",transition:"all 0.3s",outline:"none",backgroundColor:t===s?"var(--foreground)":"rgb(from var(--foreground) r g b / 0.3)"},onMouseEnter:r=>{t!==s&&(r.currentTarget.style.backgroundColor="rgb(from var(--foreground) r g b / 0.5)")},onMouseLeave:r=>{t!==s&&(r.currentTarget.style.backgroundColor="rgb(from var(--foreground) r g b / 0.3)")},onClick:()=>f(t),"aria-label":Ae(t+1)},t))}),De&&X&&l("div",{className:"dndev-absolute",style:{bottom:0,insetInlineStart:0,insetInlineEnd:0,height:"0.25rem",backgroundColor:"rgb(from var(--foreground) r g b / 0.2)"},children:l("div",{style:{height:"100%",width:`${(s+1)/n.length*100}%`,backgroundColor:"var(--foreground)",transition:"width 0.1s linear"}})}),l("div",{className:"dndev-sr-only","aria-live":Ze?"off":"polite","aria-atomic":"true",children:se(s+1,n.length)})]})}var Ee=lt(ut);Ee.displayName="Carousel";var dt=Ee,kt=dt;export{kt as default};
@@ -0,0 +1,2 @@
1
+ import{A as S,s as l,x as b,y as C}from"./chunk-SZNEXFUZ.js";import{k as s}from"./chunk-UTPWB5VD.js";import"./chunk-O2XFH626.js";import{useEffect as w,useMemo as P,useState as m}from"react";import{jsx as e,jsxs as n}from"react/jsx-runtime";function $({children:i,language:p="tsx",className:z,showLineNumbers:T=!0,wrapLines:u=!1,showCopyButton:H=!0,onCopy:x,compact:h=!1}){let[r,E]=m(!1),[c,L]=m(null),[f,v]=m(!0),[N,_]=m(!1),k=S(),d=i.trim().split(`
2
+ `);w(()=>{if(!r)return;let t=!0;return(async()=>{try{let[{createHighlighterCore:a},{createJavaScriptRegexEngine:y},M,D,...F]=await Promise.all([import("shiki/core"),import("shiki/engine/javascript"),import("shiki/themes/github-dark.mjs"),import("shiki/themes/github-light.mjs"),import("shiki/langs/typescript.mjs"),import("shiki/langs/tsx.mjs"),import("shiki/langs/javascript.mjs"),import("shiki/langs/jsx.mjs"),import("shiki/langs/json.mjs"),import("shiki/langs/css.mjs"),import("shiki/langs/html.mjs"),import("shiki/langs/bash.mjs"),import("shiki/langs/sql.mjs"),import("shiki/langs/yaml.mjs"),import("shiki/langs/markdown.mjs")]),I=[M.default,D.default],V=F.map(O=>O.default),A=await a({themes:I,langs:V,engine:y()});t&&(L(A),v(!1))}catch(a){a instanceof Error&&(a.message.includes("Cannot find module 'shiki'")||a.message.includes("Failed to fetch dynamically imported module")),t&&(_(!0),v(!1))}})(),()=>{t=!1}},[r]);let g=P(()=>{if(!r||!i||N||!c||f)return null;try{let t=k?"github-dark":"github-light",o=p||"text";return c.getLoadedLanguages().includes(o)?c.codeToHtml(i,{lang:o,theme:t}).replace(/^<pre[^>]*><code[^>]*>/,"").replace(/<\/code><\/pre>$/,"").replace(/\n/g,""):null}catch{return null}},[i,p,r,c,f,k,N]);return w(()=>{E(!0)},[]),n(s,{gap:"none",className:"dndev-code dndev-surface","data-glow":"blank","data-compact":h,children:[!h&&e("div",{className:"dndev-code-header",children:n(s,{direction:"row",align:"center",justify:"between",children:[n(s,{direction:"row",align:"center",gap:"tight",children:[n("div",{className:"dndev-code-traffic-lights",children:[e("div",{className:"dndev-code-traffic-light","data-color":"red"}),e("div",{className:"dndev-code-traffic-light","data-color":"yellow"}),e("div",{className:"dndev-code-traffic-light","data-color":"green"})]}),e(l,{as:"span",className:"dndev-code-language",children:p}),n(l,{as:"span",className:"dndev-code-line-count",children:[d.length," line",d.length!==1?"s":""]})]}),H&&r&&e(C,{text:i,onCopy:x})]})}),e(b,{className:"dndev-code-content",showHorizontal:!u,showVertical:!0,children:e("pre",{className:"dndev-code-pre","data-wrap":u,"data-compact":h,children:T?n(s,{direction:"row",gap:"none",children:[e("div",{className:"dndev-code-line-numbers",children:d.map((t,o)=>e("div",{className:"dndev-code-line-number",children:String(o+1).padStart(2," ")},o))}),g?e("code",{className:"dndev-code-code",dangerouslySetInnerHTML:{__html:g}}):e("code",{className:"dndev-code-code",children:d.map((t,o)=>e(l,{as:"code",variant:"code",style:{display:"block",background:"transparent",padding:0,lineHeight:1.5},children:t||"\xA0"},o))})]}):g?e("code",{className:"dndev-code-code",dangerouslySetInnerHTML:{__html:g}}):e("code",{className:"dndev-code-code",children:d.map((t,o)=>e(l,{as:"code",variant:"code",style:{display:"block",background:"transparent",padding:0},children:t||"\xA0"},o))})})})]})}var G=$;export{G as default};
@@ -0,0 +1,2 @@
1
+ import{A as S,s as l,x as b,y as C}from"./chunk-XK52GUFA.js";import{k as s}from"./chunk-UTPWB5VD.js";import"./chunk-O2XFH626.js";import{useEffect as w,useMemo as P,useState as m}from"react";import{jsx as e,jsxs as n}from"react/jsx-runtime";function $({children:i,language:p="tsx",className:z,showLineNumbers:T=!0,wrapLines:u=!1,showCopyButton:H=!0,onCopy:x,compact:h=!1}){let[r,E]=m(!1),[c,L]=m(null),[f,v]=m(!0),[N,_]=m(!1),k=S(),d=i.trim().split(`
2
+ `);w(()=>{if(!r)return;let t=!0;return(async()=>{try{let[{createHighlighterCore:a},{createJavaScriptRegexEngine:y},M,D,...F]=await Promise.all([import("shiki/core"),import("shiki/engine/javascript"),import("shiki/themes/github-dark.mjs"),import("shiki/themes/github-light.mjs"),import("shiki/langs/typescript.mjs"),import("shiki/langs/tsx.mjs"),import("shiki/langs/javascript.mjs"),import("shiki/langs/jsx.mjs"),import("shiki/langs/json.mjs"),import("shiki/langs/css.mjs"),import("shiki/langs/html.mjs"),import("shiki/langs/bash.mjs"),import("shiki/langs/sql.mjs"),import("shiki/langs/yaml.mjs"),import("shiki/langs/markdown.mjs")]),I=[M.default,D.default],V=F.map(O=>O.default),A=await a({themes:I,langs:V,engine:y()});t&&(L(A),v(!1))}catch(a){a instanceof Error&&(a.message.includes("Cannot find module 'shiki'")||a.message.includes("Failed to fetch dynamically imported module")),t&&(_(!0),v(!1))}})(),()=>{t=!1}},[r]);let g=P(()=>{if(!r||!i||N||!c||f)return null;try{let t=k?"github-dark":"github-light",o=p||"text";return c.getLoadedLanguages().includes(o)?c.codeToHtml(i,{lang:o,theme:t}).replace(/^<pre[^>]*><code[^>]*>/,"").replace(/<\/code><\/pre>$/,"").replace(/\n/g,""):null}catch{return null}},[i,p,r,c,f,k,N]);return w(()=>{E(!0)},[]),n(s,{gap:"none",className:"dndev-code dndev-surface","data-glow":"blank","data-compact":h,children:[!h&&e("div",{className:"dndev-code-header",children:n(s,{direction:"row",align:"center",justify:"between",children:[n(s,{direction:"row",align:"center",gap:"tight",children:[n("div",{className:"dndev-code-traffic-lights",children:[e("div",{className:"dndev-code-traffic-light","data-color":"red"}),e("div",{className:"dndev-code-traffic-light","data-color":"yellow"}),e("div",{className:"dndev-code-traffic-light","data-color":"green"})]}),e(l,{as:"span",className:"dndev-code-language",children:p}),n(l,{as:"span",className:"dndev-code-line-count",children:[d.length," line",d.length!==1?"s":""]})]}),H&&r&&e(C,{text:i,onCopy:x})]})}),e(b,{className:"dndev-code-content",showHorizontal:!u,showVertical:!0,children:e("pre",{className:"dndev-code-pre","data-wrap":u,"data-compact":h,children:T?n(s,{direction:"row",gap:"none",children:[e("div",{className:"dndev-code-line-numbers",children:d.map((t,o)=>e("div",{className:"dndev-code-line-number",children:String(o+1).padStart(2," ")},o))}),g?e("code",{className:"dndev-code-code",dangerouslySetInnerHTML:{__html:g}}):e("code",{className:"dndev-code-code",children:d.map((t,o)=>e(l,{as:"code",variant:"code",style:{display:"block",background:"transparent",padding:0,lineHeight:1.5},children:t||"\xA0"},o))})]}):g?e("code",{className:"dndev-code-code",dangerouslySetInnerHTML:{__html:g}}):e("code",{className:"dndev-code-code",children:d.map((t,o)=>e(l,{as:"code",variant:"code",style:{display:"block",background:"transparent",padding:0},children:t||"\xA0"},o))})})})]})}var G=$;export{G as default};
@@ -5,17 +5,19 @@ export type { CarouselProps };
5
5
  * Premium Carousel Component with lazy loading built-in
6
6
  *
7
7
  * Features:
8
- * - True infinite circular loop
8
+ * - Opt-in infinite circular loop (`infinite`)
9
9
  * - Hardware-accelerated animations
10
10
  * - Swipe/touch gestures
11
- * - Autoplay with pause-on-hover
11
+ * - Opt-in autoplay (pauses on hover/focus, off under reduced motion)
12
12
  * - Lazy loading by default
13
- * - Full accessibility support
13
+ * - WAI-ARIA carousel pattern: labelled region, focusable controls, off-screen
14
+ * slides inert, polite announcements (silent while autoplay rotates)
15
+ * - Translatable labels (`previousLabel`, `nextLabel`, `slideLabel`, ...; English defaults)
14
16
  * - SSR/CSR compatible
15
17
  * - Responsive and RTL-aware
16
18
  *
17
19
  * Simply pass items and renderItem - everything else is handled automatically!
18
20
  */
19
- declare const Carousel: (props: CarouselProps) => import("react").JSX.Element;
21
+ declare function Carousel<T = unknown>(props: CarouselProps<T>): import("react").JSX.Element;
20
22
  export default Carousel;
21
23
  //# sourceMappingURL=Carousel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/advanced/Carousel/Carousel.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,YAAY,EAAE,aAAa,EAAE,CAAC;AAK9B;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,QAAQ,GAAI,OAAO,aAAa,gCAgBrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/advanced/Carousel/Carousel.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,YAAY,EAAE,aAAa,EAAE,CAAC;AAK9B;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,+BAuBrD;AAED,eAAe,QAAQ,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // packages/components/src/advanced/Carousel/Carousel.tsx
3
3
  /**
4
4
  * @fileoverview Carousel Component
5
- * @description Premium carousel component with lazy loading built-in. Features true infinite circular loop, hardware-accelerated animations, swipe/touch gestures, autoplay with pause-on-hover, and lazy loading by default.
5
+ * @description Premium carousel component with lazy loading built-in. Features opt-in infinite circular loop, hardware-accelerated animations, swipe/touch gestures, opt-in autoplay (pauses on hover/focus), translatable labels and the WAI-ARIA carousel pattern.
6
6
  *
7
7
  * @version 0.1.0
8
8
  * @since 0.0.1
@@ -16,19 +16,21 @@ const CarouselContent = lazy(() => import('./CarouselContent'));
16
16
  * Premium Carousel Component with lazy loading built-in
17
17
  *
18
18
  * Features:
19
- * - True infinite circular loop
19
+ * - Opt-in infinite circular loop (`infinite`)
20
20
  * - Hardware-accelerated animations
21
21
  * - Swipe/touch gestures
22
- * - Autoplay with pause-on-hover
22
+ * - Opt-in autoplay (pauses on hover/focus, off under reduced motion)
23
23
  * - Lazy loading by default
24
- * - Full accessibility support
24
+ * - WAI-ARIA carousel pattern: labelled region, focusable controls, off-screen
25
+ * slides inert, polite announcements (silent while autoplay rotates)
26
+ * - Translatable labels (`previousLabel`, `nextLabel`, `slideLabel`, ...; English defaults)
25
27
  * - SSR/CSR compatible
26
28
  * - Responsive and RTL-aware
27
29
  *
28
30
  * Simply pass items and renderItem - everything else is handled automatically!
29
31
  */
30
- const Carousel = (props) => {
31
- const { showArrows = true, showDots = false, showProgress = true } = props;
32
- return (_jsx(Suspense, { fallback: _jsx(CarouselSkeleton, { showArrows: showArrows, showDots: showDots, showProgress: showProgress }), children: _jsx(CarouselContent, { ...props }) }));
33
- };
32
+ function Carousel(props) {
33
+ const { showArrows = true, showDots = false, showProgress = true, loadingLabel, } = props;
34
+ return (_jsx(Suspense, { fallback: _jsx(CarouselSkeleton, { showArrows: showArrows, showDots: showDots, showProgress: showProgress, loadingLabel: loadingLabel }), children: _jsx(CarouselContent, { ...props }) }));
35
+ }
34
36
  export default Carousel;
@@ -22,13 +22,20 @@ export interface CarouselProps<T = unknown> {
22
22
  showDots?: boolean;
23
23
  /** Whether to show progress bar */
24
24
  showProgress?: boolean;
25
- /** Whether to enable autoplay */
25
+ /**
26
+ * Whether to enable autoplay. Stops while the pointer or keyboard focus is inside,
27
+ * and never runs under `prefers-reduced-motion: reduce`.
28
+ * @default false
29
+ */
26
30
  autoplay?: boolean;
27
31
  /** Autoplay interval in milliseconds */
28
32
  autoplayInterval?: number;
29
33
  /** Transition type */
30
34
  transition?: 'slide' | 'fade' | 'scale' | 'parallax';
31
- /** Whether to enable infinite loop */
35
+ /**
36
+ * Whether to loop infinitely (clones the edge slides; they come first in the server HTML).
37
+ * @default false
38
+ */
32
39
  infinite?: boolean;
33
40
  /**
34
41
  * Slides visible at once — static or responsive per breakpoint:
@@ -53,8 +60,33 @@ export interface CarouselProps<T = unknown> {
53
60
  onSlideClick?: (item: T, index: number) => void;
54
61
  /** Optional unique key extractor */
55
62
  keyExtractor?: (item: T, index: number) => string | number;
56
- /** Accessibility label */
63
+ /**
64
+ * Accessible name of the carousel region (WAI-ARIA carousel pattern).
65
+ * @default 'Carousel'
66
+ */
57
67
  'aria-label'?: string;
68
+ /** Accessible name of the previous button @default 'Previous slide' */
69
+ previousLabel?: string;
70
+ /** Accessible name of the next button @default 'Next slide' */
71
+ nextLabel?: string;
72
+ /** Accessible name of the play button @default 'Play carousel' */
73
+ playLabel?: string;
74
+ /** Accessible name of the pause button @default 'Pause carousel' */
75
+ pauseLabel?: string;
76
+ /**
77
+ * Slide name, also announced on slide change (1-based).
78
+ * @default (current, total) => `Slide ${current} of ${total}`
79
+ */
80
+ slideLabel?: (current: number, total: number) => string;
81
+ /**
82
+ * Accessible name of a dot (1-based).
83
+ * @default (index) => `Go to slide ${index}`
84
+ */
85
+ goToSlideLabel?: (index: number) => string;
86
+ /** Text shown when `items` is empty @default 'No items to display' */
87
+ emptyLabel?: string;
88
+ /** Accessible name of the loading placeholder @default 'Loading carousel' */
89
+ loadingLabel?: string;
58
90
  /** Whether to pause autoplay on hover */
59
91
  pauseOnHover?: boolean;
60
92
  /** Whether to pause autoplay when not visible */
@@ -1 +1 @@
1
- {"version":3,"file":"CarouselContent.d.ts","sourceRoot":"","sources":["../../../src/advanced/Carousel/CarouselContent.tsx"],"names":[],"mappings":"AAYA,OAAO,EAOL,KAAK,SAAS,EAGd,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,gBAAgB,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,oCAAoC;IACpC,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,mCAAmC;IACnC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC;IAErE,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,mCAAmC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,sBAAsB;IACtB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;IAErD,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzD;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAE5C,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC,qCAAqC;IACrC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhD,oCAAoC;IACpC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC;IAE3D,0BAA0B;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yCAAyC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,eAAe,EAAE,MAAM,MAAM,CAAC;CAC/B;AA22BD,QAAA,MAAM,QAAQ,EAAmB,CAAC,CAAC,GAAG,OAAO,EAC3C,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACpB,YAAY,CAAC;AAElB,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"CarouselContent.d.ts","sourceRoot":"","sources":["../../../src/advanced/Carousel/CarouselContent.tsx"],"names":[],"mappings":"AAYA,OAAO,EAOL,KAAK,SAAS,EAGd,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AASf,OAAO,gBAAgB,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,oCAAoC;IACpC,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,mCAAmC;IACnC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC;IAErE,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,mCAAmC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,sBAAsB;IACtB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;IAErD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzD;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAE5C,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC,qCAAqC;IACrC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhD,oCAAoC;IACpC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC;IAE3D;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAExD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAE3C,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yCAAyC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,eAAe,EAAE,MAAM,MAAM,CAAC;CAC/B;AA66BD,QAAA,MAAM,QAAQ,EAAmB,CAAC,CAAC,GAAG,OAAO,EAC3C,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACpB,YAAY,CAAC;AAElB,eAAe,QAAQ,CAAC"}
@@ -17,18 +17,32 @@ import { observeElement } from '../../utils/intersectionObserver';
17
17
  import { isRTLLanguage } from '../../utils/rtl';
18
18
  import { withCssVars } from '../../utils/cssVars';
19
19
  import './Carousel.css';
20
- function CarouselComponent({ items, renderItem, className, slideClassName, showArrows = true, showDots = false, showProgress = true, autoplay = true, autoplayInterval = 5000, transition = 'slide', infinite = true, slidesToShow = 1, gap = 'none', swipeable = true, momentum = true, onActiveChange, onSlideClick, keyExtractor, 'aria-label': ariaLabel = 'Premium carousel', pauseOnHover = true, pauseOnInvisible = true, showPlayPause = true, lazy = false, preloadDistance = 1, }) {
20
+ const defaultSlideLabel = (current, total) => `Slide ${current} of ${total}`;
21
+ const defaultGoToSlideLabel = (index) => `Go to slide ${index}`;
22
+ /** Controls are hidden until hovered; keyboard focus reveals them too (WCAG 2.4.7). */
23
+ const revealControl = (e) => {
24
+ e.currentTarget.style.opacity = '1';
25
+ };
26
+ function CarouselComponent({ items, renderItem, className, slideClassName, showArrows = true, showDots = false, showProgress = true, autoplay = false, autoplayInterval = 5000, transition = 'slide', infinite = false, slidesToShow = 1, gap = 'none', swipeable = true, momentum = true, onActiveChange, onSlideClick, keyExtractor, 'aria-label': ariaLabel = 'Carousel', previousLabel = 'Previous slide', nextLabel = 'Next slide', playLabel = 'Play carousel', pauseLabel = 'Pause carousel', slideLabel = defaultSlideLabel, goToSlideLabel = defaultGoToSlideLabel, emptyLabel = 'No items to display', pauseOnHover = true, pauseOnInvisible = true, showPlayPause = true, lazy = false, preloadDistance = 1, }) {
21
27
  // Normalize responsive slides — same pattern as Grid cols
22
28
  const slidesPerBreakpoint = Array.isArray(slidesToShow)
23
29
  ? slidesToShow
24
30
  : [slidesToShow, slidesToShow, slidesToShow, slidesToShow];
25
31
  const [mobileSlides, tabletSlides, laptopSlides, desktopSlides] = slidesPerBreakpoint;
26
32
  const maxSlides = Math.max(...slidesPerBreakpoint);
33
+ // Infinite looping needs clones; with every item visible at once there is nothing to loop
34
+ const loop = infinite && items.length > maxSlides;
35
+ const cloneCount = loop ? Math.max(maxSlides, 2) : 0;
27
36
  const containerRef = useRef(null);
28
37
  const trackRef = useRef(null);
29
38
  const [currentIndex, setCurrentIndex] = useState(0);
30
39
  const [isPlaying, setIsPlaying] = useState(autoplay);
31
40
  const [isPaused, setIsPaused] = useState(false);
41
+ // Keyboard focus inside stops autoplay (WAI-ARIA carousel pattern)
42
+ const [hasFocus, setHasFocus] = useState(false);
43
+ // Off-screen slides become inert after hydration only: the server cannot know the breakpoint
44
+ const [mounted, setMounted] = useState(false);
45
+ useEffect(() => setMounted(true), []);
32
46
  const [isVisible, setIsVisible] = useState(true);
33
47
  const [dragState, setDragState] = useState({
34
48
  isDragging: false,
@@ -54,22 +68,12 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
54
68
  };
55
69
  return addEventListener(mediaQuery, 'change', handleChange);
56
70
  }, []);
57
- // Track current breakpoint for JS calculations (translateX, parallax)
58
- // Synchronous initial value — matchMedia is sync, avoids first-paint mismatch with CSS
59
- const [currentSlides, setCurrentSlides] = useState(() => {
60
- if (typeof window === 'undefined')
61
- return mobileSlides;
62
- if (window.matchMedia('(min-width: 1440px)').matches)
63
- return desktopSlides;
64
- if (window.matchMedia('(min-width: 1024px)').matches)
65
- return laptopSlides;
66
- if (window.matchMedia('(min-width: 768px)').matches)
67
- return tabletSlides;
68
- return mobileSlides;
69
- });
70
- useEffect(() => {
71
- if (typeof window === 'undefined')
72
- return;
71
+ // Track current breakpoint for JS calculations (translateX, parallax, inert slides).
72
+ // Starts at the mobile value on server AND client so hydration matches; the layout
73
+ // effect below resolves the real breakpoint before the browser paints. Slide widths
74
+ // come from CSS (Carousel.css), so the server HTML is already laid out correctly.
75
+ const [currentSlides, setCurrentSlides] = useState(mobileSlides);
76
+ useLayoutEffect(() => {
73
77
  const queries = [
74
78
  { mq: window.matchMedia('(min-width: 1440px)'), value: desktopSlides },
75
79
  { mq: window.matchMedia('(min-width: 1024px)'), value: laptopSlides },
@@ -84,7 +88,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
84
88
  }
85
89
  setCurrentSlides(mobileSlides);
86
90
  };
87
- // Only listen for changes — initial value is already correct
91
+ resolve();
88
92
  const cleanups = queries.map(({ mq }) => {
89
93
  const handler = () => resolve();
90
94
  mq.addEventListener('change', handler);
@@ -101,13 +105,12 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
101
105
  // Enhanced infinite loop with true circular DOM structure
102
106
  // Clone count uses maxSlides to ensure enough clones at every breakpoint
103
107
  const circularItems = useMemo(() => {
104
- if (!infinite || items.length <= maxSlides)
108
+ if (!loop)
105
109
  return items;
106
- const cloneCount = Math.max(maxSlides, 2);
107
110
  const beforeClones = items.slice(-cloneCount);
108
111
  const afterClones = items.slice(0, cloneCount);
109
112
  return [...beforeClones, ...items, ...afterClones];
110
- }, [items, infinite, maxSlides]);
113
+ }, [items, loop, cloneCount]);
111
114
  // JS slide width for translateX calculations — synced with CSS via matchMedia
112
115
  const slideWidth = useMemo(() => {
113
116
  return 100 / currentSlides;
@@ -115,25 +118,32 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
115
118
  // Active slide = center of visible slides, not leftmost
116
119
  // ceil(N/2)-1: 1→0, 2→0, 3→1, 4→1
117
120
  const activeOffset = Math.ceil(currentSlides / 2) - 1;
118
- // Mount: position track at clone offset so first real item is visible (no flash)
119
- const mountedRef = useRef(false);
121
+ // Last logical index that still fills the view (no blank space after the last slide)
122
+ const maxIndex = Math.max(0, items.length - currentSlides);
123
+ /** Track position of a logical index: after the clones when looping, else clamped to a full view. */
124
+ const trackPosition = useCallback((index) => loop ? index + cloneCount : Math.max(0, Math.min(index, maxIndex)), [loop, cloneCount, maxIndex]);
125
+ // Mount and breakpoint change: place the track on the current slide (first real
126
+ // item when looping), re-clamped to a full view for the new slide count.
127
+ const currentIndexRef = useRef(currentIndex);
128
+ currentIndexRef.current = currentIndex;
120
129
  useLayoutEffect(() => {
121
- if (mountedRef.current ||
122
- !infinite ||
123
- !trackRef.current ||
124
- items.length <= maxSlides)
130
+ const track = trackRef.current;
131
+ if (!track)
125
132
  return;
126
- mountedRef.current = true;
127
- const cloneCount = Math.max(maxSlides, 2);
128
- trackRef.current.style.transform = `translateX(-${cloneCount * slideWidth}%)`;
129
- }, [infinite, maxSlides, slideWidth, items.length]);
133
+ const index = loop
134
+ ? currentIndexRef.current
135
+ : Math.min(currentIndexRef.current, maxIndex);
136
+ if (index !== currentIndexRef.current)
137
+ setCurrentIndex(index);
138
+ track.style.transition = 'none';
139
+ track.style.transform = `translateX(-${trackPosition(index) * slideWidth}%)`;
140
+ }, [loop, maxIndex, trackPosition, slideWidth]);
130
141
  // Get the real index (accounting for clones)
131
142
  const getRealIndex = useCallback((index) => {
132
- if (!infinite)
143
+ if (!loop)
133
144
  return index;
134
- const cloneCount = Math.max(maxSlides, 2);
135
145
  return ((((index - cloneCount) % items.length) + items.length) % items.length);
136
- }, [infinite, items.length, maxSlides]);
146
+ }, [loop, items.length, cloneCount]);
137
147
  // Spring-based momentum animation
138
148
  const isVisibleRef = useRef(isVisible);
139
149
  isVisibleRef.current = isVisible;
@@ -229,30 +239,25 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
229
239
  const track = trackRef.current;
230
240
  if (!track)
231
241
  return;
232
- let actualIndex = targetIndex;
233
- if (infinite) {
234
- const cloneCount = Math.max(maxSlides, 2);
235
- // Offset into the real section — don't wrap, let it slide to clones
236
- actualIndex = targetIndex + cloneCount;
237
- }
238
- else {
239
- // Non-infinite: clamp to valid range
240
- actualIndex = Math.max(0, Math.min(targetIndex, items.length - 1));
241
- }
242
+ // Looping: offset into the real section — don't wrap, let it slide to clones.
243
+ // Otherwise: clamped so the last view is full.
244
+ const actualIndex = trackPosition(targetIndex);
245
+ // Already there: nothing moves, so no transitionend would ever reset the state
246
+ if (!loop && actualIndex === currentIndex && !immediate)
247
+ return;
242
248
  const translateX = -(actualIndex * slideWidth);
243
249
  const duration = immediate || prefersReducedMotion ? '0ms' : '300ms';
244
250
  if (!immediate)
245
251
  setState('transitioning');
246
252
  applyTransitionEffect(track, translateX, duration);
247
253
  // Update logical index (wrap to valid range)
248
- const newIndex = infinite
254
+ const newIndex = loop
249
255
  ? ((targetIndex % items.length) + items.length) % items.length
250
256
  : actualIndex;
251
257
  setCurrentIndex(newIndex);
252
258
  onActiveChange?.(newIndex);
253
259
  // Schedule reset if we landed on a clone
254
- if (infinite) {
255
- const cloneCount = Math.max(maxSlides, 2);
260
+ if (loop) {
256
261
  const isOnBeforeClone = actualIndex < cloneCount;
257
262
  const isOnAfterClone = actualIndex >= items.length + cloneCount;
258
263
  if (isOnBeforeClone || isOnAfterClone) {
@@ -273,10 +278,11 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
273
278
  }
274
279
  }
275
280
  }, [
276
- infinite,
281
+ loop,
282
+ trackPosition,
283
+ currentIndex,
277
284
  items.length,
278
285
  slideWidth,
279
- maxSlides,
280
286
  onActiveChange,
281
287
  prefersReducedMotion,
282
288
  state,
@@ -297,7 +303,12 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
297
303
  }, []);
298
304
  // Autoplay functionality
299
305
  useEffect(() => {
300
- if (!isPlaying || isPaused || !isVisible || items.length <= 1)
306
+ if (!isPlaying ||
307
+ isPaused ||
308
+ hasFocus ||
309
+ prefersReducedMotion ||
310
+ !isVisible ||
311
+ items.length <= 1)
301
312
  return;
302
313
  autoplayRef.current = setTimeout(() => {
303
314
  goToNext();
@@ -310,6 +321,8 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
310
321
  }, [
311
322
  isPlaying,
312
323
  isPaused,
324
+ hasFocus,
325
+ prefersReducedMotion,
313
326
  isVisible,
314
327
  currentIndex,
315
328
  goToNext,
@@ -370,8 +383,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
370
383
  const track = trackRef.current;
371
384
  if (track && Math.abs(deltaX) > 10) {
372
385
  e.preventDefault();
373
- const cloneOffset = infinite ? Math.max(maxSlides, 2) : 0;
374
- const currentTranslate = -((currentIndex + cloneOffset) * slideWidth);
386
+ const currentTranslate = -(trackPosition(currentIndex) * slideWidth);
375
387
  const dragPercent = (deltaX / (containerRef.current?.clientWidth || 1)) * 100;
376
388
  const resistance = Math.min(Math.abs(deltaX) / 200, 0.8);
377
389
  const adjustedDragPercent = dragPercent * (1 - resistance);
@@ -389,8 +401,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
389
401
  dragState.startTime,
390
402
  currentIndex,
391
403
  slideWidth,
392
- infinite,
393
- maxSlides,
404
+ trackPosition,
394
405
  ]);
395
406
  const handleTouchEnd = useCallback(() => {
396
407
  if (!dragState.isDragging)
@@ -402,7 +413,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
402
413
  const track = trackRef.current;
403
414
  if (track) {
404
415
  const targetIndex = velocity > 0 ? currentIndex - 1 : currentIndex + 1;
405
- const targetTranslateX = -(targetIndex * slideWidth);
416
+ const targetTranslateX = -(trackPosition(targetIndex) * slideWidth);
406
417
  animateWithSpring(track, targetTranslateX, velocity * 100);
407
418
  goToSlide(targetIndex, true);
408
419
  }
@@ -418,7 +429,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
418
429
  else {
419
430
  const track = trackRef.current;
420
431
  if (track && momentum) {
421
- const targetTranslateX = -(currentIndex * slideWidth);
432
+ const targetTranslateX = -(trackPosition(currentIndex) * slideWidth);
422
433
  animateWithSpring(track, targetTranslateX, velocity * 100);
423
434
  }
424
435
  else {
@@ -441,6 +452,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
441
452
  currentIndex,
442
453
  animateWithSpring,
443
454
  slideWidth,
455
+ trackPosition,
444
456
  ]);
445
457
  // Transition Events (SSR safe, performant)
446
458
  const handleTransitionEnd = useCallback(() => {
@@ -456,6 +468,9 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
456
468
  }, [slideWidth]);
457
469
  // Keyboard navigation
458
470
  const handleKeyDown = useCallback((e) => {
471
+ // Keys typed in slide content (links, buttons, inputs) keep their own behaviour
472
+ if (e.target !== e.currentTarget)
473
+ return;
459
474
  const isRTL = isRTLLanguage();
460
475
  switch (e.key) {
461
476
  case 'ArrowLeft':
@@ -475,14 +490,28 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
475
490
  goToSlide(items.length - 1);
476
491
  break;
477
492
  case ' ':
493
+ if (!autoplay)
494
+ return;
478
495
  e.preventDefault();
479
496
  isPlaying ? pause() : play();
480
497
  break;
481
498
  }
482
- }, [goToNext, goToPrevious, goToSlide, items.length, isPlaying, play, pause]);
499
+ }, [
500
+ goToNext,
501
+ goToPrevious,
502
+ goToSlide,
503
+ items.length,
504
+ isPlaying,
505
+ play,
506
+ pause,
507
+ autoplay,
508
+ ]);
509
+ // Track position of the first visible slide (clones come first in infinite mode)
510
+ const firstVisible = trackPosition(currentIndex);
511
+ const autoplayRunning = isPlaying && !isPaused && !hasFocus;
483
512
  // Early return for empty items — placed after all hooks to satisfy Rules of Hooks
484
513
  if (!items || items.length === 0) {
485
- return (_jsx(Stack, { align: "center", justify: "center", className: cn('dndev-relative', className), children: _jsx("div", { style: { color: 'var(--muted-foreground)' }, children: "No items to display" }) }));
514
+ return (_jsx(Stack, { align: "center", justify: "center", className: cn('dndev-relative', className), children: _jsx("div", { style: { color: 'var(--muted-foreground)' }, children: emptyLabel }) }));
486
515
  }
487
516
  return (_jsxs("div", { ref: containerRef, className: cn('dndev-relative dndev-overflow-hidden', className), style: withCssVars({
488
517
  outline: 'none',
@@ -490,15 +519,22 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
490
519
  '--carousel-slides-tablet': tabletSlides,
491
520
  '--carousel-slides-laptop': laptopSlides,
492
521
  '--carousel-slides-desktop': desktopSlides,
493
- }), onMouseEnter: () => pauseOnHover && setIsPaused(true), onMouseLeave: () => pauseOnHover && setIsPaused(false), onKeyDown: handleKeyDown, tabIndex: 0, role: "region", "aria-label": ariaLabel, "aria-live": "polite", children: [_jsx("div", { className: "dndev-overflow-hidden", children: _jsx("div", { ref: trackRef, className: cn('dndev-flex', dragState.isDragging && 'dndev-pointer-events-none', state === 'transitioning' && 'dndev-pointer-events-none'), style: {
522
+ }), onMouseEnter: () => pauseOnHover && setIsPaused(true), onMouseLeave: () => pauseOnHover && setIsPaused(false), onFocus: () => setHasFocus(true), onBlur: (e) => {
523
+ if (!e.currentTarget.contains(e.relatedTarget))
524
+ setHasFocus(false);
525
+ }, onKeyDown: handleKeyDown, tabIndex: 0, role: "region", "aria-roledescription": "carousel", "aria-label": ariaLabel, children: [_jsx("div", { className: "dndev-overflow-hidden", children: _jsx("div", { ref: trackRef, className: cn('dndev-flex', dragState.isDragging && 'dndev-pointer-events-none', state === 'transitioning' && 'dndev-pointer-events-none'), style: {
494
526
  cursor: dragState.isDragging ? 'grabbing' : undefined,
495
527
  }, onTransitionEnd: handleTransitionEnd, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd, children: circularItems.map((item, index) => {
496
528
  const realIndex = getRealIndex(index);
529
+ // Off-screen slides (and clones) are not focusable nor announced (WCAG 2.4.11)
530
+ const offscreen = mounted &&
531
+ items.length > currentSlides &&
532
+ (index < firstVisible || index >= firstVisible + currentSlides);
497
533
  const isActive = realIndex === (currentIndex + activeOffset) % items.length;
498
534
  const shouldLoad = shouldLoadSlide(realIndex);
499
535
  return (_jsx("div", { className: cn('dndev-carousel-slide', slideClassName), "data-gap": gap !== 'none' ? gap : undefined, style: {
500
536
  opacity: shouldLoad ? 1 : 0,
501
- }, role: "group", "aria-roledescription": "slide", "aria-label": `Slide ${realIndex + 1} of ${items.length}`, onClick: () => onSlideClick?.(item, realIndex), children: shouldLoad && renderItem(item, realIndex, isActive) }, keyExtractor
537
+ }, role: "group", "aria-roledescription": "slide", "aria-label": slideLabel(realIndex + 1, items.length), inert: offscreen || undefined, onClick: () => onSlideClick?.(item, realIndex), children: shouldLoad && renderItem(item, realIndex, isActive) }, keyExtractor
502
538
  ? keyExtractor(item, realIndex)
503
539
  : `${realIndex}-${index}`));
504
540
  }) }) }), showArrows && items.length > 1 && (_jsxs(_Fragment, { children: [_jsx("button", { className: "dndev-absolute dndev-z-breadcrumbs dndev-flex dndev-items-center dndev-justify-center", style: {
@@ -520,7 +556,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
520
556
  }, onMouseLeave: (e) => {
521
557
  e.currentTarget.style.backgroundColor =
522
558
  'rgb(from var(--background) r g b / 0.8)';
523
- }, onClick: goToPrevious, "aria-label": "Previous slide", tabIndex: -1, children: _jsx(ChevronLeft, { style: {
559
+ }, onFocus: revealControl, onClick: goToPrevious, type: "button", "aria-label": previousLabel, children: _jsx(ChevronLeft, { style: {
524
560
  width: 'var(--icon-md)',
525
561
  height: 'var(--icon-md)',
526
562
  color: 'var(--foreground)',
@@ -543,7 +579,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
543
579
  }, onMouseLeave: (e) => {
544
580
  e.currentTarget.style.backgroundColor =
545
581
  'rgb(from var(--background) r g b / 0.8)';
546
- }, onClick: goToNext, "aria-label": "Next slide", tabIndex: -1, children: _jsx(ChevronRight, { style: {
582
+ }, onFocus: revealControl, onClick: goToNext, type: "button", "aria-label": nextLabel, children: _jsx(ChevronRight, { style: {
547
583
  width: 'var(--icon-md)',
548
584
  height: 'var(--icon-md)',
549
585
  color: 'var(--foreground)',
@@ -558,14 +594,14 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
558
594
  backgroundColor: 'rgb(from var(--background) r g b / 0.8)',
559
595
  border: '1px solid var(--border)',
560
596
  outline: 'none',
561
- }, tabIndex: -1, onMouseEnter: (e) => {
597
+ }, type: "button", onFocus: revealControl, onMouseEnter: (e) => {
562
598
  e.currentTarget.style.backgroundColor =
563
599
  'rgb(from var(--background) r g b / 0.9)';
564
600
  e.currentTarget.style.opacity = '1';
565
601
  }, onMouseLeave: (e) => {
566
602
  e.currentTarget.style.backgroundColor =
567
603
  'rgb(from var(--background) r g b / 0.8)';
568
- }, onClick: () => (isPlaying ? pause() : play()), "aria-label": isPlaying ? 'Pause carousel' : 'Play carousel', children: isPlaying ? (_jsx(Pause, { style: {
604
+ }, onClick: () => (isPlaying ? pause() : play()), "aria-label": isPlaying ? pauseLabel : playLabel, children: isPlaying ? (_jsx(Pause, { style: {
569
605
  width: 'var(--icon-md)',
570
606
  height: 'var(--icon-md)',
571
607
  color: 'var(--foreground)',
@@ -577,7 +613,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
577
613
  bottom: '1rem',
578
614
  insetInlineStart: '50%',
579
615
  transform: 'translateX(-50%)',
580
- }, children: items.map((_, index) => (_jsx("button", { tabIndex: -1, style: {
616
+ }, children: items.map((_, index) => (_jsx("button", { type: "button", "aria-current": index === currentIndex || undefined, style: {
581
617
  width: index === currentIndex ? '1.5rem' : '0.5rem',
582
618
  height: '0.5rem',
583
619
  borderRadius: '9999px',
@@ -596,7 +632,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
596
632
  e.currentTarget.style.backgroundColor =
597
633
  'rgb(from var(--foreground) r g b / 0.3)';
598
634
  }
599
- }, onClick: () => goToSlide(index), "aria-label": `Go to slide ${index + 1}` }, index))) })), showProgress && autoplay && (_jsx("div", { className: "dndev-absolute", style: {
635
+ }, onClick: () => goToSlide(index), "aria-label": goToSlideLabel(index + 1) }, index))) })), showProgress && autoplay && (_jsx("div", { className: "dndev-absolute", style: {
600
636
  bottom: 0,
601
637
  insetInlineStart: 0,
602
638
  insetInlineEnd: 0,
@@ -607,7 +643,7 @@ function CarouselComponent({ items, renderItem, className, slideClassName, showA
607
643
  width: `${((currentIndex + 1) / items.length) * 100}%`,
608
644
  backgroundColor: 'var(--foreground)',
609
645
  transition: 'width 0.1s linear',
610
- } }) })), _jsxs("div", { className: "dndev-sr-only", "aria-live": "polite", "aria-atomic": "true", children: ["Slide ", currentIndex + 1, " of ", items.length] })] }));
646
+ } }) })), _jsx("div", { className: "dndev-sr-only", "aria-live": autoplayRunning ? 'off' : 'polite', "aria-atomic": "true", children: slideLabel(currentIndex + 1, items.length) })] }));
611
647
  }
612
648
  // Create typed generic component with display name
613
649
  const MemoCarousel = memo(CarouselComponent);