wulf.js 0.0.0-stage → 1.8.3

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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +870 -2
  3. package/changelog.md +289 -0
  4. package/dist/index.cjs.js +4247 -0
  5. package/dist/index.cjs.js.map +7 -0
  6. package/dist/index.esm.js +4230 -0
  7. package/dist/index.esm.js.map +7 -0
  8. package/dist/index.global.js +4250 -0
  9. package/dist/index.global.js.map +7 -0
  10. package/dist/index.global.min.js +3 -0
  11. package/dist/index.global.min.js.map +7 -0
  12. package/dist/mask.cjs.js +2782 -0
  13. package/dist/mask.cjs.js.map +7 -0
  14. package/dist/mask.css +1 -0
  15. package/dist/mask.css.map +7 -0
  16. package/dist/mask.esm.js +2759 -0
  17. package/dist/mask.esm.js.map +7 -0
  18. package/dist/mask.global.js +2785 -0
  19. package/dist/mask.global.js.map +7 -0
  20. package/dist/mask.global.min.js +3 -0
  21. package/dist/mask.global.min.js.map +7 -0
  22. package/dist/masonry.cjs.js +572 -0
  23. package/dist/masonry.cjs.js.map +7 -0
  24. package/dist/masonry.css +1 -0
  25. package/dist/masonry.css.map +7 -0
  26. package/dist/masonry.esm.js +549 -0
  27. package/dist/masonry.esm.js.map +7 -0
  28. package/dist/masonry.global.js +575 -0
  29. package/dist/masonry.global.js.map +7 -0
  30. package/dist/masonry.global.min.js +3 -0
  31. package/dist/masonry.global.min.js.map +7 -0
  32. package/dist/scroll.cjs.js +500 -0
  33. package/dist/scroll.cjs.js.map +7 -0
  34. package/dist/scroll.css +1 -0
  35. package/dist/scroll.css.map +7 -0
  36. package/dist/scroll.esm.js +477 -0
  37. package/dist/scroll.esm.js.map +7 -0
  38. package/dist/scroll.global.js +503 -0
  39. package/dist/scroll.global.js.map +7 -0
  40. package/dist/scroll.global.min.js +3 -0
  41. package/dist/scroll.global.min.js.map +7 -0
  42. package/dist/toast.cjs.js +433 -0
  43. package/dist/toast.cjs.js.map +7 -0
  44. package/dist/toast.css +1 -0
  45. package/dist/toast.css.map +7 -0
  46. package/dist/toast.esm.js +410 -0
  47. package/dist/toast.esm.js.map +7 -0
  48. package/dist/toast.global.js +436 -0
  49. package/dist/toast.global.js.map +7 -0
  50. package/dist/toast.global.min.js +3 -0
  51. package/dist/toast.global.min.js.map +7 -0
  52. package/dist/types/index.d.ts +6 -0
  53. package/dist/types/mask/AmountEngine.d.ts +72 -0
  54. package/dist/types/mask/BaseInputMask.d.ts +173 -0
  55. package/dist/types/mask/EmailEngine.d.ts +42 -0
  56. package/dist/types/mask/InputAmountMask.d.ts +70 -0
  57. package/dist/types/mask/InputEmailMask.d.ts +65 -0
  58. package/dist/types/mask/InputMask.d.ts +116 -0
  59. package/dist/types/mask/MaskEngine.d.ts +102 -0
  60. package/dist/types/mask/MaskHistory.d.ts +48 -0
  61. package/dist/types/mask/MaskKeyboard.d.ts +28 -0
  62. package/dist/types/mask/index.d.ts +28 -0
  63. package/dist/types/mask/types.d.ts +137 -0
  64. package/dist/types/masonry/LayoutEngine.d.ts +29 -0
  65. package/dist/types/masonry/Masonry.d.ts +63 -0
  66. package/dist/types/masonry/index.d.ts +7 -0
  67. package/dist/types/masonry/types.d.ts +125 -0
  68. package/dist/types/scroll/ScrollBlock.d.ts +94 -0
  69. package/dist/types/scroll/index.d.ts +8 -0
  70. package/dist/types/scroll/types.d.ts +76 -0
  71. package/dist/types/toast/Toast.d.ts +15 -0
  72. package/dist/types/toast/ToastInstance.d.ts +52 -0
  73. package/dist/types/toast/ToastManager.d.ts +34 -0
  74. package/dist/types/toast/index.d.ts +6 -0
  75. package/dist/types/toast/types.d.ts +68 -0
  76. package/package.json +99 -4
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/scroll/index.ts", "../src/scroll/ScrollBlock.ts"],
4
+ "sourcesContent": ["import { ScrollBlock } from './ScrollBlock';\n\nexport * from './types';\nexport * from './ScrollBlock';\n\nexport const Scroll = {\n ScrollBlock\n};\n\nexport { ScrollBlock };\nexport default ScrollBlock;\n\n// Attachement namespace global dans les environnements de navigation (IIFE / Vanilla)\nif (typeof window !== 'undefined') {\n const win = window as unknown as Record<string, unknown>;\n const wulfNamespace = ((win.Wulf as Record<string, unknown>) || {}) as Record<string, unknown>;\n win.Wulf = wulfNamespace;\n \n // Namespace sp\u00E9cifique et exclusif \u00E0 la librairie Scroll : Wulf.Scroll\n wulfNamespace.Scroll = Scroll;\n}\n", "import { \n ScrollBlockOptions, \n ScrollInfo, \n ScrollToTarget, \n ScrollToTargetOptions,\n IScrollBlock \n} from './types';\n\nlet idCounter = 0;\n\n/**\n * ScrollBlock - Alternative accessible, moderne et ultra-l\u00E9g\u00E8re \u00E0 malihu-custom-scrollbar-plugin.\n * Repose sur le d\u00E9filement natif du navigateur avec synchronisation GPU sans reflow.\n */\nexport class ScrollBlock implements IScrollBlock {\n public readonly root: HTMLElement;\n public readonly viewport: HTMLElement;\n\n private options: Required<ScrollBlockOptions>;\n private createdViewport: boolean = false;\n\n private trackY?: HTMLElement;\n private thumbY?: HTMLElement;\n private trackX?: HTMLElement;\n private thumbX?: HTMLElement;\n\n private resizeObserver?: ResizeObserver;\n private hideTimer?: number;\n\n private isDragging: boolean = false;\n private dragAxis?: 'y' | 'x';\n private dragPointerId?: number;\n private dragStartPos: number = 0;\n private dragStartScroll: number = 0;\n\n private atBottom: boolean = false;\n private atTop: boolean = true;\n private atRight: boolean = false;\n private atLeft: boolean = true;\n\n // R\u00E9f\u00E9rences d'\u00E9couteurs d'\u00E9v\u00E9nements pour le nettoyage\n private boundOnScroll: () => void;\n private boundOnMouseEnter: () => void;\n private boundOnMouseLeave: () => void;\n private boundOnFocusIn: () => void;\n private boundOnFocusOut: () => void;\n private boundPointerMove: (e: PointerEvent) => void;\n private boundPointerUp: (e: PointerEvent) => void;\n\n constructor(element: HTMLElement | string, options?: ScrollBlockOptions) {\n const resolvedElement = typeof element === 'string' \n ? document.querySelector<HTMLElement>(element) \n : element;\n\n if (!resolvedElement) {\n throw new Error(`[ScrollBlock] \u00C9l\u00E9ment introuvable : \"${element}\".`);\n }\n\n this.root = resolvedElement;\n\n // Options par d\u00E9faut\n this.options = {\n axis: options?.axis || 'y',\n autoHide: options?.autoHide ?? true,\n autoHideDelay: options?.autoHideDelay ?? 1000,\n alwaysVisible: options?.alwaysVisible ?? false,\n ariaLabel: options?.ariaLabel || 'Zone de contenu d\u00E9filable',\n minThumbSize: options?.minThumbSize ?? 24,\n edgeThreshold: options?.edgeThreshold ?? 10,\n onScroll: options?.onScroll || (() => {}),\n onTotalScroll: options?.onTotalScroll || (() => {}),\n onTotalScrollBack: options?.onTotalScrollBack || (() => {})\n };\n\n // Liaison des m\u00E9thodes\n this.boundOnScroll = this.handleScroll.bind(this);\n this.boundOnMouseEnter = this.handleMouseEnter.bind(this);\n this.boundOnMouseLeave = this.handleMouseLeave.bind(this);\n this.boundOnFocusIn = this.handleFocusIn.bind(this);\n this.boundOnFocusOut = this.handleFocusOut.bind(this);\n this.boundPointerMove = this.handlePointerMove.bind(this);\n this.boundPointerUp = this.handlePointerUp.bind(this);\n\n // Initialisation du DOM et du viewport\n this.viewport = this.setupViewport();\n this.setupAccessibility();\n this.setupScrollbars();\n this.setupEventListeners();\n this.setupObserver();\n\n // Premier calcul\n this.update();\n }\n\n /**\n * Pr\u00E9pare le viewport d\u00E9filant sans alt\u00E9rer les \u00E9l\u00E9ments enfants.\n */\n private setupViewport(): HTMLElement {\n this.root.classList.add('wulf-scrollblock');\n\n if (this.options.alwaysVisible) {\n this.root.classList.add('is-always-visible');\n }\n\n if (this.options.axis === 'both') {\n this.root.classList.add('has-both-axes');\n }\n\n // R\u00E9utilisation d'un viewport existant ou cr\u00E9ation transparente\n const existingViewport = this.root.querySelector<HTMLElement>(':scope > .wulf-scrollblock-viewport');\n if (existingViewport) {\n return existingViewport;\n }\n\n const viewport = document.createElement('div');\n viewport.className = 'wulf-scrollblock-viewport';\n\n // D\u00E9placement des enfants existants dans le viewport\n while (this.root.firstChild) {\n viewport.appendChild(this.root.firstChild);\n }\n\n this.root.appendChild(viewport);\n this.createdViewport = true;\n return viewport;\n }\n\n /**\n * Configure les attributs WAI-ARIA pour une accessibilit\u00E9 maximale.\n */\n private setupAccessibility(): void {\n if (!this.viewport.id) {\n idCounter += 1;\n this.viewport.id = `wulf-scrollblock-vp-${idCounter}`;\n }\n\n this.viewport.setAttribute('role', 'region');\n this.viewport.setAttribute('aria-label', this.options.ariaLabel);\n }\n\n /**\n * Cr\u00E9e les rails et curseurs selon l'axe s\u00E9lectionn\u00E9.\n */\n private setupScrollbars(): void {\n if (this.options.axis === 'y' || this.options.axis === 'both') {\n this.trackY = document.createElement('div');\n this.trackY.className = 'wulf-scrollblock-track wulf-scrollblock-vertical';\n this.trackY.setAttribute('aria-hidden', 'true');\n\n this.thumbY = document.createElement('div');\n this.thumbY.className = 'wulf-scrollblock-thumb';\n this.thumbY.setAttribute('role', 'scrollbar');\n this.thumbY.setAttribute('aria-orientation', 'vertical');\n this.thumbY.setAttribute('aria-controls', this.viewport.id);\n this.thumbY.setAttribute('aria-valuenow', '0');\n this.thumbY.setAttribute('aria-valuemin', '0');\n this.thumbY.setAttribute('aria-valuemax', '100');\n this.thumbY.setAttribute('aria-label', 'D\u00E9filement vertical');\n\n this.trackY.appendChild(this.thumbY);\n this.root.appendChild(this.trackY);\n\n this.attachTrackListeners(this.trackY, this.thumbY, 'y');\n }\n\n if (this.options.axis === 'x' || this.options.axis === 'both') {\n this.trackX = document.createElement('div');\n this.trackX.className = 'wulf-scrollblock-track wulf-scrollblock-horizontal';\n this.trackX.setAttribute('aria-hidden', 'true');\n\n this.thumbX = document.createElement('div');\n this.thumbX.className = 'wulf-scrollblock-thumb';\n this.thumbX.setAttribute('role', 'scrollbar');\n this.thumbX.setAttribute('aria-orientation', 'horizontal');\n this.thumbX.setAttribute('aria-controls', this.viewport.id);\n this.thumbX.setAttribute('aria-valuenow', '0');\n this.thumbX.setAttribute('aria-valuemin', '0');\n this.thumbX.setAttribute('aria-valuemax', '100');\n this.thumbX.setAttribute('aria-label', 'D\u00E9filement horizontal');\n\n this.trackX.appendChild(this.thumbX);\n this.root.appendChild(this.trackX);\n\n this.attachTrackListeners(this.trackX, this.thumbX, 'x');\n }\n }\n\n /**\n * Attache les \u00E9couteurs sur un rail et son curseur.\n */\n private attachTrackListeners(track: HTMLElement, thumb: HTMLElement, axis: 'y' | 'x'): void {\n thumb.addEventListener('pointerdown', (e: PointerEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n this.isDragging = true;\n this.dragAxis = axis;\n this.dragPointerId = e.pointerId;\n this.dragStartPos = axis === 'y' ? e.clientY : e.clientX;\n this.dragStartScroll = axis === 'y' ? this.viewport.scrollTop : this.viewport.scrollLeft;\n\n thumb.setPointerCapture(e.pointerId);\n thumb.classList.add('is-active');\n this.root.classList.add('is-dragging');\n\n // Liaison dynamique sur window uniquement pendant la dur\u00E9e active du drag\n window.addEventListener('pointermove', this.boundPointerMove);\n window.addEventListener('pointerup', this.boundPointerUp);\n window.addEventListener('pointercancel', this.boundPointerUp);\n });\n\n // Clic direct sur le rail (hors dragger)\n track.addEventListener('pointerdown', (e: PointerEvent) => {\n if (e.target === thumb) return;\n e.preventDefault();\n\n const rect = track.getBoundingClientRect();\n const clickPos = axis === 'y' ? (e.clientY - rect.top) : (e.clientX - rect.left);\n const trackSize = axis === 'y' ? rect.height : rect.width;\n const clientSize = axis === 'y' ? this.viewport.clientHeight : this.viewport.clientWidth;\n const scrollSize = axis === 'y' ? this.viewport.scrollHeight : this.viewport.scrollWidth;\n\n const ratio = clickPos / trackSize;\n const targetScroll = ratio * (scrollSize - clientSize);\n\n this.scrollTo(axis === 'y' ? { top: targetScroll } : { left: targetScroll }, { smooth: true });\n });\n }\n\n /**\n * \u00C9couteurs globaux sur le viewport et les interactions.\n */\n private setupEventListeners(): void {\n this.viewport.addEventListener('scroll', this.boundOnScroll, { passive: true });\n\n if (this.options.autoHide && !this.options.alwaysVisible) {\n this.root.addEventListener('mouseenter', this.boundOnMouseEnter);\n this.root.addEventListener('mouseleave', this.boundOnMouseLeave);\n this.root.addEventListener('focusin', this.boundOnFocusIn);\n this.root.addEventListener('focusout', this.boundOnFocusOut);\n }\n }\n\n /**\n * Initialise le ResizeObserver r\u00E9actif.\n */\n private setupObserver(): void {\n if (typeof ResizeObserver !== 'undefined') {\n this.resizeObserver = new ResizeObserver(() => {\n window.requestAnimationFrame(() => this.update());\n });\n this.resizeObserver.observe(this.root);\n this.resizeObserver.observe(this.viewport);\n if (this.viewport.firstElementChild) {\n this.resizeObserver.observe(this.viewport.firstElementChild);\n }\n }\n }\n\n /**\n * D\u00E9placement lors du glissement du curseur.\n */\n private handlePointerMove(e: PointerEvent): void {\n if (!this.isDragging || !this.dragAxis) return;\n\n const isY = this.dragAxis === 'y';\n const delta = (isY ? e.clientY : e.clientX) - this.dragStartPos;\n const track = isY ? this.trackY : this.trackX;\n const thumb = isY ? this.thumbY : this.thumbX;\n\n if (!track || !thumb) return;\n\n const trackSize = isY ? track.clientHeight : track.clientWidth;\n const thumbSize = isY ? thumb.clientHeight : thumb.clientWidth;\n const clientSize = isY ? this.viewport.clientHeight : this.viewport.clientWidth;\n const scrollSize = isY ? this.viewport.scrollHeight : this.viewport.scrollWidth;\n\n const maxScroll = scrollSize - clientSize;\n const maxThumbTravel = trackSize - thumbSize;\n\n if (maxThumbTravel <= 0 || maxScroll <= 0) return;\n\n const ratio = maxScroll / maxThumbTravel;\n const nextScroll = this.dragStartScroll + delta * ratio;\n\n if (isY) {\n this.viewport.scrollTop = Math.max(0, Math.min(maxScroll, nextScroll));\n } else {\n this.viewport.scrollLeft = Math.max(0, Math.min(maxScroll, nextScroll));\n }\n }\n\n /**\n * Rel\u00E2chement de la capture du pointeur.\n */\n private handlePointerUp(e: PointerEvent): void {\n if (!this.isDragging) return;\n\n if (this.dragPointerId !== undefined) {\n const activeThumb = this.dragAxis === 'y' ? this.thumbY : this.thumbX;\n if (activeThumb && activeThumb.hasPointerCapture(this.dragPointerId)) {\n activeThumb.releasePointerCapture(this.dragPointerId);\n }\n }\n\n // D\u00E9tachement imm\u00E9diat des \u00E9couteurs globaux\n window.removeEventListener('pointermove', this.boundPointerMove);\n window.removeEventListener('pointerup', this.boundPointerUp);\n window.removeEventListener('pointercancel', this.boundPointerUp);\n\n this.isDragging = false;\n this.dragAxis = undefined;\n this.dragPointerId = undefined;\n\n this.thumbY?.classList.remove('is-active');\n this.thumbX?.classList.remove('is-active');\n this.root.classList.remove('is-dragging');\n\n this.scheduleAutoHide();\n }\n\n /**\n * Gestionnaire d'\u00E9v\u00E9nement de d\u00E9filement natif.\n */\n private handleScroll(): void {\n this.syncThumbs();\n\n const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this.viewport;\n const maxTop = Math.max(0, scrollHeight - clientHeight);\n const maxLeft = Math.max(0, scrollWidth - clientWidth);\n\n const progressY = maxTop > 0 ? (scrollTop / maxTop) : 0;\n const progressX = maxLeft > 0 ? (scrollLeft / maxLeft) : 0;\n\n // D\u00E9clenchement du callback onScroll\n this.options.onScroll({\n top: scrollTop,\n left: scrollLeft,\n maxTop,\n maxLeft,\n progressY: Math.round(progressY * 100),\n progressX: Math.round(progressX * 100)\n });\n\n // D\u00E9tection des extr\u00E9mit\u00E9s (infinite scroll / edge callbacks)\n const threshold = this.options.edgeThreshold;\n\n if (maxTop > 0) {\n const nowBottom = scrollTop >= maxTop - threshold;\n const nowTop = scrollTop <= threshold;\n\n if (nowBottom && !this.atBottom) {\n this.options.onTotalScroll('bottom');\n }\n if (nowTop && !this.atTop) {\n this.options.onTotalScrollBack('top');\n }\n\n this.atBottom = nowBottom;\n this.atTop = nowTop;\n }\n\n if (maxLeft > 0) {\n const nowRight = scrollLeft >= maxLeft - threshold;\n const nowLeft = scrollLeft <= threshold;\n\n if (nowRight && !this.atRight) {\n this.options.onTotalScroll('right');\n }\n if (nowLeft && !this.atLeft) {\n this.options.onTotalScrollBack('left');\n }\n\n this.atRight = nowRight;\n this.atLeft = nowLeft;\n }\n\n // Gestion de l'affichage pendant le scroll\n if (this.options.autoHide && !this.options.alwaysVisible) {\n this.root.classList.add('is-scrolling');\n this.scheduleAutoHide();\n }\n }\n\n /**\n * Synchronise la position physique et ARIA des curseurs.\n */\n private syncThumbs(): void {\n const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this.viewport;\n\n // Axe Y\n if (this.thumbY && this.trackY) {\n const maxScrollY = scrollHeight - clientHeight;\n const trackHeight = this.trackY.clientHeight;\n const thumbHeight = this.thumbY.clientHeight;\n const maxTravelY = trackHeight - thumbHeight;\n\n if (maxScrollY > 0 && maxTravelY > 0) {\n const ratioY = scrollTop / maxScrollY;\n const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));\n this.thumbY.style.transform = `translate3d(0, ${posY}px, 0)`;\n this.thumbY.setAttribute('aria-valuenow', String(Math.round(ratioY * 100)));\n }\n }\n\n // Axe X\n if (this.thumbX && this.trackX) {\n const maxScrollX = scrollWidth - clientWidth;\n const trackWidth = this.trackX.clientWidth;\n const thumbWidth = this.thumbX.clientWidth;\n const maxTravelX = trackWidth - thumbWidth;\n\n if (maxScrollX > 0 && maxTravelX > 0) {\n const ratioX = scrollLeft / maxScrollX;\n const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));\n this.thumbX.style.transform = `translate3d(${posX}px, 0, 0)`;\n this.thumbX.setAttribute('aria-valuenow', String(Math.round(ratioX * 100)));\n }\n }\n }\n\n private handleMouseEnter(): void {\n this.root.classList.add('is-visible');\n this.clearAutoHideTimer();\n }\n\n private handleMouseLeave(): void {\n this.scheduleAutoHide();\n }\n\n private handleFocusIn(): void {\n this.root.classList.add('is-visible');\n this.clearAutoHideTimer();\n }\n\n private handleFocusOut(): void {\n this.scheduleAutoHide();\n }\n\n private clearAutoHideTimer(): void {\n if (this.hideTimer) {\n window.clearTimeout(this.hideTimer);\n this.hideTimer = undefined;\n }\n }\n\n private scheduleAutoHide(): void {\n if (this.options.alwaysVisible || !this.options.autoHide || this.isDragging) return;\n this.clearAutoHideTimer();\n\n this.hideTimer = window.setTimeout(() => {\n this.root.classList.remove('is-scrolling');\n this.root.classList.remove('is-visible');\n }, this.options.autoHideDelay);\n }\n\n /**\n * Recalcule les dimensions et la visibilit\u00E9 des barres.\n */\n public update(): void {\n const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;\n\n const canScrollY = scrollHeight > clientHeight;\n const canScrollX = scrollWidth > clientWidth;\n\n // Gestion de la classe CSS de scrollabilit\u00E9\n this.root.classList.toggle('has-scroll-y', canScrollY);\n this.root.classList.toggle('has-scroll-x', canScrollX);\n\n // WCAG 2.1.1 : tabindex=\"0\" uniquement si le contenu d\u00E9borde\n if (canScrollY || canScrollX) {\n this.viewport.setAttribute('tabindex', '0');\n } else {\n this.viewport.removeAttribute('tabindex');\n }\n\n // Mise \u00E0 jour taille du thumb Y\n if (this.trackY && this.thumbY) {\n if (canScrollY) {\n const trackHeight = this.trackY.clientHeight;\n const calculatedHeight = Math.max(\n this.options.minThumbSize,\n trackHeight * (clientHeight / scrollHeight)\n );\n this.thumbY.style.height = `${calculatedHeight}px`;\n }\n }\n\n // Mise \u00E0 jour taille du thumb X\n if (this.trackX && this.thumbX) {\n if (canScrollX) {\n const trackWidth = this.trackX.clientWidth;\n const calculatedWidth = Math.max(\n this.options.minThumbSize,\n trackWidth * (clientWidth / scrollWidth)\n );\n this.thumbX.style.width = `${calculatedWidth}px`;\n }\n }\n\n this.syncThumbs();\n }\n\n /**\n * D\u00E9filement programmatique direct ou liss\u00E9.\n */\n public scrollTo(target: ScrollToTarget, options?: { smooth?: boolean }): void {\n const prefersReducedMotion = typeof window !== 'undefined' \n && window.matchMedia \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n const targetSmooth = typeof target === 'object' && target !== null && !(target instanceof HTMLElement)\n ? (target as ScrollToTargetOptions).smooth\n : undefined;\n const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion;\n const behavior: ScrollBehavior = shouldSmooth ? 'smooth' : 'auto';\n\n const maxTop = Math.max(0, this.viewport.scrollHeight - this.viewport.clientHeight);\n const maxLeft = Math.max(0, this.viewport.scrollWidth - this.viewport.clientWidth);\n\n let targetTop: number | undefined;\n let targetLeft: number | undefined;\n\n if (typeof target === 'number') {\n targetTop = target;\n } else if (typeof target === 'string') {\n switch (target) {\n case 'top':\n targetTop = 0;\n break;\n case 'bottom':\n targetTop = maxTop;\n break;\n case 'left':\n targetLeft = 0;\n break;\n case 'right':\n targetLeft = maxLeft;\n break;\n default: {\n let el: HTMLElement | null = null;\n try {\n el = this.viewport.querySelector<HTMLElement>(target);\n } catch {\n el = null;\n }\n if (el) {\n targetTop = el.offsetTop;\n targetLeft = el.offsetLeft;\n }\n break;\n }\n }\n } else if (target instanceof HTMLElement) {\n targetTop = target.offsetTop;\n targetLeft = target.offsetLeft;\n } else if (typeof target === 'object') {\n targetTop = target.top;\n targetLeft = target.left;\n }\n\n this.viewport.scrollTo({\n top: targetTop !== undefined ? Math.max(0, Math.min(maxTop, targetTop)) : undefined,\n left: targetLeft !== undefined ? Math.max(0, Math.min(maxLeft, targetLeft)) : undefined,\n behavior\n });\n }\n\n /**\n * D\u00E9truit le composant et lib\u00E8re toutes les ressources.\n */\n public destroy(): void {\n this.clearAutoHideTimer();\n\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n }\n\n this.viewport.removeEventListener('scroll', this.boundOnScroll);\n this.root.removeEventListener('mouseenter', this.boundOnMouseEnter);\n this.root.removeEventListener('mouseleave', this.boundOnMouseLeave);\n this.root.removeEventListener('focusin', this.boundOnFocusIn);\n this.root.removeEventListener('focusout', this.boundOnFocusOut);\n\n window.removeEventListener('pointermove', this.boundPointerMove);\n window.removeEventListener('pointerup', this.boundPointerUp);\n window.removeEventListener('pointercancel', this.boundPointerUp);\n\n this.trackY?.remove();\n this.trackX?.remove();\n\n this.root.classList.remove(\n 'wulf-scrollblock',\n 'has-scroll-y',\n 'has-scroll-x',\n 'has-both-axes',\n 'is-visible',\n 'is-scrolling',\n 'is-dragging',\n 'is-always-visible'\n );\n\n // Restauration du DOM d'origine si le viewport a \u00E9t\u00E9 cr\u00E9\u00E9 dynamiquement\n if (this.createdViewport && this.viewport.parentElement === this.root) {\n while (this.viewport.firstChild) {\n this.root.insertBefore(this.viewport.firstChild, this.viewport);\n }\n this.viewport.remove();\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,IAAI,YAAY;AAMT,IAAM,cAAN,MAA0C;AAAA,EAmC/C,YAAY,SAA+B,SAA8B;AA9BzE,SAAQ,kBAA2B;AAUnC,SAAQ,aAAsB;AAG9B,SAAQ,eAAuB;AAC/B,SAAQ,kBAA0B;AAElC,SAAQ,WAAoB;AAC5B,SAAQ,QAAiB;AACzB,SAAQ,UAAmB;AAC3B,SAAQ,SAAkB;AAYxB,UAAM,kBAAkB,OAAO,YAAY,WACvC,SAAS,cAA2B,OAAO,IAC3C;AAEJ,QAAI,CAAC,iBAAiB;AACpB,YAAM,IAAI,MAAM,8CAAwC,OAAO,IAAI;AAAA,IACrE;AAEA,SAAK,OAAO;AAGZ,SAAK,UAAU;AAAA,MACb,MAAM,SAAS,QAAQ;AAAA,MACvB,UAAU,SAAS,YAAY;AAAA,MAC/B,eAAe,SAAS,iBAAiB;AAAA,MACzC,eAAe,SAAS,iBAAiB;AAAA,MACzC,WAAW,SAAS,aAAa;AAAA,MACjC,cAAc,SAAS,gBAAgB;AAAA,MACvC,eAAe,SAAS,iBAAiB;AAAA,MACzC,UAAU,SAAS,aAAa,MAAM;AAAA,MAAC;AAAA,MACvC,eAAe,SAAS,kBAAkB,MAAM;AAAA,MAAC;AAAA,MACjD,mBAAmB,SAAS,sBAAsB,MAAM;AAAA,MAAC;AAAA,IAC3D;AAGA,SAAK,gBAAgB,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,IACjC;AAEA,SAAK,SAAS,oBAAoB,UAAU,KAAK,aAAa;AAC9D,SAAK,KAAK,oBAAoB,cAAc,KAAK,iBAAiB;AAClE,SAAK,KAAK,oBAAoB,cAAc,KAAK,iBAAiB;AAClE,SAAK,KAAK,oBAAoB,WAAW,KAAK,cAAc;AAC5D,SAAK,KAAK,oBAAoB,YAAY,KAAK,eAAe;AAE9D,WAAO,oBAAoB,eAAe,KAAK,gBAAgB;AAC/D,WAAO,oBAAoB,aAAa,KAAK,cAAc;AAC3D,WAAO,oBAAoB,iBAAiB,KAAK,cAAc;AAE/D,SAAK,QAAQ,OAAO;AACpB,SAAK,QAAQ,OAAO;AAEpB,SAAK,KAAK,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAGA,QAAI,KAAK,mBAAmB,KAAK,SAAS,kBAAkB,KAAK,MAAM;AACrE,aAAO,KAAK,SAAS,YAAY;AAC/B,aAAK,KAAK,aAAa,KAAK,SAAS,YAAY,KAAK,QAAQ;AAAA,MAChE;AACA,WAAK,SAAS,OAAO;AAAA,IACvB;AAAA,EACF;AACF;;;AD7lBO,IAAM,SAAS;AAAA,EACpB;AACF;AAGA,IAAO,gBAAQ;AAGf,IAAI,OAAO,WAAW,aAAa;AACjC,QAAM,MAAM;AACZ,QAAM,gBAAkB,IAAI,QAAoC,CAAC;AACjE,MAAI,OAAO;AAGX,gBAAc,SAAS;AACzB;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ :root,.wulf-scrollblock{--scrollblock-size: 8px;--scrollblock-size-hover: 10px;--scrollblock-min-thumb: 24px;--scrollblock-radius: 4px;--scrollblock-offset: 2px;--scrollblock-track-bg: transparent;--scrollblock-track-hover-bg: rgba(0, 0, 0, .05);--scrollblock-thumb-bg: rgba(0, 0, 0, .38);--scrollblock-thumb-hover-bg: rgba(0, 0, 0, .65);--scrollblock-thumb-active-bg: rgba(0, 0, 0, .85);--scrollblock-transition-duration: .2s}.wulf-scrollblock{position:relative;overflow:hidden;display:block;box-sizing:border-box}.wulf-scrollblock-viewport{position:relative;width:100%;height:100%;overflow:auto;box-sizing:border-box;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.wulf-scrollblock-viewport::-webkit-scrollbar{display:none;width:0;height:0}.wulf-scrollblock-viewport:focus-visible{outline:2px solid currentColor;outline-offset:-2px}.wulf-scrollblock-track{position:absolute;z-index:10;background:var(--scrollblock-track-bg);border-radius:var(--scrollblock-radius);transition:background-color var(--scrollblock-transition-duration) ease,opacity var(--scrollblock-transition-duration) ease,width var(--scrollblock-transition-duration) ease,height var(--scrollblock-transition-duration) ease;user-select:none;pointer-events:none;opacity:0;visibility:hidden}.wulf-scrollblock-track:hover{background:var(--scrollblock-track-hover-bg)}.wulf-scrollblock-thumb{position:absolute;background:var(--scrollblock-thumb-bg);border-radius:var(--scrollblock-radius);transition:background-color var(--scrollblock-transition-duration) ease;cursor:grab;pointer-events:auto;touch-action:none}.wulf-scrollblock-thumb:hover{background:var(--scrollblock-thumb-hover-bg)}.wulf-scrollblock-thumb:active,.wulf-scrollblock-thumb.is-active{cursor:grabbing;background:var(--scrollblock-thumb-active-bg)}.wulf-scrollblock-vertical{top:var(--scrollblock-offset);bottom:var(--scrollblock-offset);right:var(--scrollblock-offset);width:var(--scrollblock-size)}.wulf-scrollblock-vertical:hover{width:var(--scrollblock-size-hover)}.wulf-scrollblock-vertical .wulf-scrollblock-thumb{width:100%;min-height:var(--scrollblock-min-thumb);top:0;left:0}.wulf-scrollblock-horizontal{left:var(--scrollblock-offset);right:var(--scrollblock-offset);bottom:var(--scrollblock-offset);height:var(--scrollblock-size)}.wulf-scrollblock-horizontal:hover{height:var(--scrollblock-size-hover)}.wulf-scrollblock-horizontal .wulf-scrollblock-thumb{height:100%;min-width:var(--scrollblock-min-thumb);bottom:0;left:0}.wulf-scrollblock.has-both-axes .wulf-scrollblock-vertical{bottom:calc(var(--scrollblock-size) + var(--scrollblock-offset) * 2)}.wulf-scrollblock.has-both-axes .wulf-scrollblock-horizontal{right:calc(var(--scrollblock-size) + var(--scrollblock-offset) * 2)}.wulf-scrollblock.has-scroll-y .wulf-scrollblock-vertical,.wulf-scrollblock.has-scroll-x .wulf-scrollblock-horizontal{pointer-events:auto;visibility:visible}.wulf-scrollblock.is-visible .wulf-scrollblock-track,.wulf-scrollblock.is-scrolling .wulf-scrollblock-track,.wulf-scrollblock.is-dragging .wulf-scrollblock-track,.wulf-scrollblock:hover .wulf-scrollblock-track,.wulf-scrollblock:focus-within .wulf-scrollblock-track{opacity:1}.wulf-scrollblock.is-dragging{user-select:none;-webkit-user-select:none}.wulf-scrollblock.is-always-visible .wulf-scrollblock-track{opacity:1}@media(prefers-reduced-motion:reduce){.wulf-scrollblock-track,.wulf-scrollblock-thumb{transition:none!important}}@media(forced-colors:active){.wulf-scrollblock-track{background:Canvas!important;border:1px solid CanvasText}.wulf-scrollblock-thumb{background:Highlight!important;border:1px solid ButtonText}}
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["<stdin>"],
4
+ "sourcesContent": ["/**\n * Styles pour ScrollBlock (Wulf.Scroll)\n * Namespace : .wulf-scrollblock\n * Architecture par tokens CSS pour surcharge ais\u00E9e par le framework h\u00F4te.\n */\n:root,\n.wulf-scrollblock {\n /* Dimensions */\n --scrollblock-size: 8px;\n --scrollblock-size-hover: 10px;\n --scrollblock-min-thumb: 24px;\n --scrollblock-radius: 4px;\n --scrollblock-offset: 2px;\n /* Couleurs et contrastes (Conforme WCAG 1.4.11 >= 3:1) */\n --scrollblock-track-bg: transparent;\n --scrollblock-track-hover-bg: rgba(0, 0, 0, 0.05);\n --scrollblock-thumb-bg: rgba(0, 0, 0, 0.38);\n --scrollblock-thumb-hover-bg: rgba(0, 0, 0, 0.65);\n --scrollblock-thumb-active-bg: rgba(0, 0, 0, 0.85);\n /* Animations */\n --scrollblock-transition-duration: 200ms;\n}\n.wulf-scrollblock {\n position: relative;\n overflow: hidden;\n display: block;\n box-sizing: border-box;\n /* Viewport avec d\u00E9filement natif fluide */\n /* Rail de d\u00E9filement (Track) */\n /* Curseur de d\u00E9filement (Thumb / Dragger) */\n /* Rail vertical */\n /* Rail horizontal */\n /* Gestion du coin d'intersection quand les deux barres sont actives */\n /* Visibilit\u00E9 des barres */\n /* Auto-masquage / Visibilit\u00E9 active */\n /* En cours de glissement : neutraliser la s\u00E9lection globale */\n /* Mode always-visible */\n}\n.wulf-scrollblock-viewport {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: auto;\n box-sizing: border-box;\n -webkit-overflow-scrolling: touch;\n /* Masquage des barres natives du navigateur */\n scrollbar-width: none;\n -ms-overflow-style: none;\n}\n.wulf-scrollblock-viewport::-webkit-scrollbar {\n display: none;\n width: 0;\n height: 0;\n}\n.wulf-scrollblock-viewport:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: -2px;\n}\n.wulf-scrollblock-track {\n position: absolute;\n z-index: 10;\n background: var(--scrollblock-track-bg);\n border-radius: var(--scrollblock-radius);\n transition: background-color var(--scrollblock-transition-duration) ease, opacity var(--scrollblock-transition-duration) ease, width var(--scrollblock-transition-duration) ease, height var(--scrollblock-transition-duration) ease;\n user-select: none;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n}\n.wulf-scrollblock-track:hover {\n background: var(--scrollblock-track-hover-bg);\n}\n.wulf-scrollblock-thumb {\n position: absolute;\n background: var(--scrollblock-thumb-bg);\n border-radius: var(--scrollblock-radius);\n transition: background-color var(--scrollblock-transition-duration) ease;\n cursor: grab;\n pointer-events: auto;\n touch-action: none;\n}\n.wulf-scrollblock-thumb:hover {\n background: var(--scrollblock-thumb-hover-bg);\n}\n.wulf-scrollblock-thumb:active,\n.wulf-scrollblock-thumb.is-active {\n cursor: grabbing;\n background: var(--scrollblock-thumb-active-bg);\n}\n.wulf-scrollblock-vertical {\n top: var(--scrollblock-offset);\n bottom: var(--scrollblock-offset);\n right: var(--scrollblock-offset);\n width: var(--scrollblock-size);\n}\n.wulf-scrollblock-vertical:hover {\n width: var(--scrollblock-size-hover);\n}\n.wulf-scrollblock-vertical .wulf-scrollblock-thumb {\n width: 100%;\n min-height: var(--scrollblock-min-thumb);\n top: 0;\n left: 0;\n}\n.wulf-scrollblock-horizontal {\n left: var(--scrollblock-offset);\n right: var(--scrollblock-offset);\n bottom: var(--scrollblock-offset);\n height: var(--scrollblock-size);\n}\n.wulf-scrollblock-horizontal:hover {\n height: var(--scrollblock-size-hover);\n}\n.wulf-scrollblock-horizontal .wulf-scrollblock-thumb {\n height: 100%;\n min-width: var(--scrollblock-min-thumb);\n bottom: 0;\n left: 0;\n}\n.wulf-scrollblock.has-both-axes .wulf-scrollblock-vertical {\n bottom: calc(var(--scrollblock-size) + var(--scrollblock-offset) * 2);\n}\n.wulf-scrollblock.has-both-axes .wulf-scrollblock-horizontal {\n right: calc(var(--scrollblock-size) + var(--scrollblock-offset) * 2);\n}\n.wulf-scrollblock.has-scroll-y .wulf-scrollblock-vertical,\n.wulf-scrollblock.has-scroll-x .wulf-scrollblock-horizontal {\n pointer-events: auto;\n visibility: visible;\n}\n.wulf-scrollblock.is-visible .wulf-scrollblock-track,\n.wulf-scrollblock.is-scrolling .wulf-scrollblock-track,\n.wulf-scrollblock.is-dragging .wulf-scrollblock-track,\n.wulf-scrollblock:hover .wulf-scrollblock-track,\n.wulf-scrollblock:focus-within .wulf-scrollblock-track {\n opacity: 1;\n}\n.wulf-scrollblock.is-dragging {\n user-select: none;\n -webkit-user-select: none;\n}\n.wulf-scrollblock.is-always-visible .wulf-scrollblock-track {\n opacity: 1;\n}\n/* Accessibilit\u00E9 : Mode r\u00E9duction des animations */\n@media (prefers-reduced-motion: reduce) {\n .wulf-scrollblock-track,\n .wulf-scrollblock-thumb {\n transition: none !important;\n }\n}\n/* Accessibilit\u00E9 : Mode contraste \u00E9lev\u00E9 syst\u00E8me */\n@media (forced-colors: active) {\n .wulf-scrollblock-track {\n background: Canvas !important;\n border: 1px solid CanvasText;\n }\n .wulf-scrollblock-thumb {\n background: Highlight !important;\n border: 1px solid ButtonText;\n }\n}\n"],
5
+ "mappings": "AAKA,MACA,CAAC,iBAEC,oBAAoB,IACpB,0BAA0B,KAC1B,yBAAyB,KACzB,sBAAsB,IACtB,sBAAsB,IAEtB,wBAAwB,YACxB,8BAA8B,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAC5C,wBAAwB,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KACtC,8BAA8B,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAC5C,+BAA+B,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAE7C,mCAAmC,GACrC,CACA,CAhBC,iBAiBC,SAAU,SACV,SAAU,OACV,QAAS,MACT,WAAY,UAWd,CACA,CAAC,0BACC,SAAU,SACV,MAAO,KACP,OAAQ,KACR,SAAU,KACV,WAAY,WACZ,2BAA4B,MAE5B,gBAAiB,KACjB,mBAAoB,IACtB,CACA,CAXC,yBAWyB,oBACxB,QAAS,KACT,MAAO,EACP,OAAQ,CACV,CACA,CAhBC,yBAgByB,eACxB,QAAS,IAAI,MAAM,aACnB,eAAgB,IAClB,CACA,CAAC,uBACC,SAAU,SACV,QAAS,GACT,WAAY,IAAI,wBAChB,cAAe,IAAI,sBACnB,WAAY,iBAAiB,IAAI,mCAAmC,IAAI,CAAE,QAAQ,IAAI,mCAAmC,IAAI,CAAE,MAAM,IAAI,mCAAmC,IAAI,CAAE,OAAO,IAAI,mCAAmC,KAChO,YAAa,KACb,eAAgB,KAChB,QAAS,EACT,WAAY,MACd,CACA,CAXC,sBAWsB,OACrB,WAAY,IAAI,6BAClB,CACA,CAAC,uBACC,SAAU,SACV,WAAY,IAAI,wBAChB,cAAe,IAAI,sBACnB,WAAY,iBAAiB,IAAI,mCAAmC,KACpE,OAAQ,KACR,eAAgB,KAChB,aAAc,IAChB,CACA,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FnC,uBAoFC,QAAS,CACX,CAEA,OAAO,uBAAyB,QAC9B,CAxFD,uBAyFC,CA3ED,uBA4EG,WAAY,cACd,CACF,CAEA,OAAO,cAAgB,QACrB,CA/FD,uBAgGG,WAAY,iBACZ,OAAQ,IAAI,MAAM,UACpB,CACA,CArFD,uBAsFG,WAAY,oBACZ,OAAQ,IAAI,MAAM,UACpB,CACF",
6
+ "names": []
7
+ }
@@ -0,0 +1,477 @@
1
+ // src/scroll/ScrollBlock.ts
2
+ var idCounter = 0;
3
+ var ScrollBlock = class {
4
+ constructor(element, options) {
5
+ this.createdViewport = false;
6
+ this.isDragging = false;
7
+ this.dragStartPos = 0;
8
+ this.dragStartScroll = 0;
9
+ this.atBottom = false;
10
+ this.atTop = true;
11
+ this.atRight = false;
12
+ this.atLeft = true;
13
+ const resolvedElement = typeof element === "string" ? document.querySelector(element) : element;
14
+ if (!resolvedElement) {
15
+ throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${element}".`);
16
+ }
17
+ this.root = resolvedElement;
18
+ this.options = {
19
+ axis: options?.axis || "y",
20
+ autoHide: options?.autoHide ?? true,
21
+ autoHideDelay: options?.autoHideDelay ?? 1e3,
22
+ alwaysVisible: options?.alwaysVisible ?? false,
23
+ ariaLabel: options?.ariaLabel || "Zone de contenu d\xE9filable",
24
+ minThumbSize: options?.minThumbSize ?? 24,
25
+ edgeThreshold: options?.edgeThreshold ?? 10,
26
+ onScroll: options?.onScroll || (() => {
27
+ }),
28
+ onTotalScroll: options?.onTotalScroll || (() => {
29
+ }),
30
+ onTotalScrollBack: options?.onTotalScrollBack || (() => {
31
+ })
32
+ };
33
+ this.boundOnScroll = this.handleScroll.bind(this);
34
+ this.boundOnMouseEnter = this.handleMouseEnter.bind(this);
35
+ this.boundOnMouseLeave = this.handleMouseLeave.bind(this);
36
+ this.boundOnFocusIn = this.handleFocusIn.bind(this);
37
+ this.boundOnFocusOut = this.handleFocusOut.bind(this);
38
+ this.boundPointerMove = this.handlePointerMove.bind(this);
39
+ this.boundPointerUp = this.handlePointerUp.bind(this);
40
+ this.viewport = this.setupViewport();
41
+ this.setupAccessibility();
42
+ this.setupScrollbars();
43
+ this.setupEventListeners();
44
+ this.setupObserver();
45
+ this.update();
46
+ }
47
+ /**
48
+ * Prépare le viewport défilant sans altérer les éléments enfants.
49
+ */
50
+ setupViewport() {
51
+ this.root.classList.add("wulf-scrollblock");
52
+ if (this.options.alwaysVisible) {
53
+ this.root.classList.add("is-always-visible");
54
+ }
55
+ if (this.options.axis === "both") {
56
+ this.root.classList.add("has-both-axes");
57
+ }
58
+ const existingViewport = this.root.querySelector(":scope > .wulf-scrollblock-viewport");
59
+ if (existingViewport) {
60
+ return existingViewport;
61
+ }
62
+ const viewport = document.createElement("div");
63
+ viewport.className = "wulf-scrollblock-viewport";
64
+ while (this.root.firstChild) {
65
+ viewport.appendChild(this.root.firstChild);
66
+ }
67
+ this.root.appendChild(viewport);
68
+ this.createdViewport = true;
69
+ return viewport;
70
+ }
71
+ /**
72
+ * Configure les attributs WAI-ARIA pour une accessibilité maximale.
73
+ */
74
+ setupAccessibility() {
75
+ if (!this.viewport.id) {
76
+ idCounter += 1;
77
+ this.viewport.id = `wulf-scrollblock-vp-${idCounter}`;
78
+ }
79
+ this.viewport.setAttribute("role", "region");
80
+ this.viewport.setAttribute("aria-label", this.options.ariaLabel);
81
+ }
82
+ /**
83
+ * Crée les rails et curseurs selon l'axe sélectionné.
84
+ */
85
+ setupScrollbars() {
86
+ if (this.options.axis === "y" || this.options.axis === "both") {
87
+ this.trackY = document.createElement("div");
88
+ this.trackY.className = "wulf-scrollblock-track wulf-scrollblock-vertical";
89
+ this.trackY.setAttribute("aria-hidden", "true");
90
+ this.thumbY = document.createElement("div");
91
+ this.thumbY.className = "wulf-scrollblock-thumb";
92
+ this.thumbY.setAttribute("role", "scrollbar");
93
+ this.thumbY.setAttribute("aria-orientation", "vertical");
94
+ this.thumbY.setAttribute("aria-controls", this.viewport.id);
95
+ this.thumbY.setAttribute("aria-valuenow", "0");
96
+ this.thumbY.setAttribute("aria-valuemin", "0");
97
+ this.thumbY.setAttribute("aria-valuemax", "100");
98
+ this.thumbY.setAttribute("aria-label", "D\xE9filement vertical");
99
+ this.trackY.appendChild(this.thumbY);
100
+ this.root.appendChild(this.trackY);
101
+ this.attachTrackListeners(this.trackY, this.thumbY, "y");
102
+ }
103
+ if (this.options.axis === "x" || this.options.axis === "both") {
104
+ this.trackX = document.createElement("div");
105
+ this.trackX.className = "wulf-scrollblock-track wulf-scrollblock-horizontal";
106
+ this.trackX.setAttribute("aria-hidden", "true");
107
+ this.thumbX = document.createElement("div");
108
+ this.thumbX.className = "wulf-scrollblock-thumb";
109
+ this.thumbX.setAttribute("role", "scrollbar");
110
+ this.thumbX.setAttribute("aria-orientation", "horizontal");
111
+ this.thumbX.setAttribute("aria-controls", this.viewport.id);
112
+ this.thumbX.setAttribute("aria-valuenow", "0");
113
+ this.thumbX.setAttribute("aria-valuemin", "0");
114
+ this.thumbX.setAttribute("aria-valuemax", "100");
115
+ this.thumbX.setAttribute("aria-label", "D\xE9filement horizontal");
116
+ this.trackX.appendChild(this.thumbX);
117
+ this.root.appendChild(this.trackX);
118
+ this.attachTrackListeners(this.trackX, this.thumbX, "x");
119
+ }
120
+ }
121
+ /**
122
+ * Attache les écouteurs sur un rail et son curseur.
123
+ */
124
+ attachTrackListeners(track, thumb, axis) {
125
+ thumb.addEventListener("pointerdown", (e) => {
126
+ e.preventDefault();
127
+ e.stopPropagation();
128
+ this.isDragging = true;
129
+ this.dragAxis = axis;
130
+ this.dragPointerId = e.pointerId;
131
+ this.dragStartPos = axis === "y" ? e.clientY : e.clientX;
132
+ this.dragStartScroll = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
133
+ thumb.setPointerCapture(e.pointerId);
134
+ thumb.classList.add("is-active");
135
+ this.root.classList.add("is-dragging");
136
+ window.addEventListener("pointermove", this.boundPointerMove);
137
+ window.addEventListener("pointerup", this.boundPointerUp);
138
+ window.addEventListener("pointercancel", this.boundPointerUp);
139
+ });
140
+ track.addEventListener("pointerdown", (e) => {
141
+ if (e.target === thumb) return;
142
+ e.preventDefault();
143
+ const rect = track.getBoundingClientRect();
144
+ const clickPos = axis === "y" ? e.clientY - rect.top : e.clientX - rect.left;
145
+ const trackSize = axis === "y" ? rect.height : rect.width;
146
+ const clientSize = axis === "y" ? this.viewport.clientHeight : this.viewport.clientWidth;
147
+ const scrollSize = axis === "y" ? this.viewport.scrollHeight : this.viewport.scrollWidth;
148
+ const ratio = clickPos / trackSize;
149
+ const targetScroll = ratio * (scrollSize - clientSize);
150
+ this.scrollTo(axis === "y" ? { top: targetScroll } : { left: targetScroll }, { smooth: true });
151
+ });
152
+ }
153
+ /**
154
+ * Écouteurs globaux sur le viewport et les interactions.
155
+ */
156
+ setupEventListeners() {
157
+ this.viewport.addEventListener("scroll", this.boundOnScroll, { passive: true });
158
+ if (this.options.autoHide && !this.options.alwaysVisible) {
159
+ this.root.addEventListener("mouseenter", this.boundOnMouseEnter);
160
+ this.root.addEventListener("mouseleave", this.boundOnMouseLeave);
161
+ this.root.addEventListener("focusin", this.boundOnFocusIn);
162
+ this.root.addEventListener("focusout", this.boundOnFocusOut);
163
+ }
164
+ }
165
+ /**
166
+ * Initialise le ResizeObserver réactif.
167
+ */
168
+ setupObserver() {
169
+ if (typeof ResizeObserver !== "undefined") {
170
+ this.resizeObserver = new ResizeObserver(() => {
171
+ window.requestAnimationFrame(() => this.update());
172
+ });
173
+ this.resizeObserver.observe(this.root);
174
+ this.resizeObserver.observe(this.viewport);
175
+ if (this.viewport.firstElementChild) {
176
+ this.resizeObserver.observe(this.viewport.firstElementChild);
177
+ }
178
+ }
179
+ }
180
+ /**
181
+ * Déplacement lors du glissement du curseur.
182
+ */
183
+ handlePointerMove(e) {
184
+ if (!this.isDragging || !this.dragAxis) return;
185
+ const isY = this.dragAxis === "y";
186
+ const delta = (isY ? e.clientY : e.clientX) - this.dragStartPos;
187
+ const track = isY ? this.trackY : this.trackX;
188
+ const thumb = isY ? this.thumbY : this.thumbX;
189
+ if (!track || !thumb) return;
190
+ const trackSize = isY ? track.clientHeight : track.clientWidth;
191
+ const thumbSize = isY ? thumb.clientHeight : thumb.clientWidth;
192
+ const clientSize = isY ? this.viewport.clientHeight : this.viewport.clientWidth;
193
+ const scrollSize = isY ? this.viewport.scrollHeight : this.viewport.scrollWidth;
194
+ const maxScroll = scrollSize - clientSize;
195
+ const maxThumbTravel = trackSize - thumbSize;
196
+ if (maxThumbTravel <= 0 || maxScroll <= 0) return;
197
+ const ratio = maxScroll / maxThumbTravel;
198
+ const nextScroll = this.dragStartScroll + delta * ratio;
199
+ if (isY) {
200
+ this.viewport.scrollTop = Math.max(0, Math.min(maxScroll, nextScroll));
201
+ } else {
202
+ this.viewport.scrollLeft = Math.max(0, Math.min(maxScroll, nextScroll));
203
+ }
204
+ }
205
+ /**
206
+ * Relâchement de la capture du pointeur.
207
+ */
208
+ handlePointerUp(e) {
209
+ if (!this.isDragging) return;
210
+ if (this.dragPointerId !== void 0) {
211
+ const activeThumb = this.dragAxis === "y" ? this.thumbY : this.thumbX;
212
+ if (activeThumb && activeThumb.hasPointerCapture(this.dragPointerId)) {
213
+ activeThumb.releasePointerCapture(this.dragPointerId);
214
+ }
215
+ }
216
+ window.removeEventListener("pointermove", this.boundPointerMove);
217
+ window.removeEventListener("pointerup", this.boundPointerUp);
218
+ window.removeEventListener("pointercancel", this.boundPointerUp);
219
+ this.isDragging = false;
220
+ this.dragAxis = void 0;
221
+ this.dragPointerId = void 0;
222
+ this.thumbY?.classList.remove("is-active");
223
+ this.thumbX?.classList.remove("is-active");
224
+ this.root.classList.remove("is-dragging");
225
+ this.scheduleAutoHide();
226
+ }
227
+ /**
228
+ * Gestionnaire d'événement de défilement natif.
229
+ */
230
+ handleScroll() {
231
+ this.syncThumbs();
232
+ const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this.viewport;
233
+ const maxTop = Math.max(0, scrollHeight - clientHeight);
234
+ const maxLeft = Math.max(0, scrollWidth - clientWidth);
235
+ const progressY = maxTop > 0 ? scrollTop / maxTop : 0;
236
+ const progressX = maxLeft > 0 ? scrollLeft / maxLeft : 0;
237
+ this.options.onScroll({
238
+ top: scrollTop,
239
+ left: scrollLeft,
240
+ maxTop,
241
+ maxLeft,
242
+ progressY: Math.round(progressY * 100),
243
+ progressX: Math.round(progressX * 100)
244
+ });
245
+ const threshold = this.options.edgeThreshold;
246
+ if (maxTop > 0) {
247
+ const nowBottom = scrollTop >= maxTop - threshold;
248
+ const nowTop = scrollTop <= threshold;
249
+ if (nowBottom && !this.atBottom) {
250
+ this.options.onTotalScroll("bottom");
251
+ }
252
+ if (nowTop && !this.atTop) {
253
+ this.options.onTotalScrollBack("top");
254
+ }
255
+ this.atBottom = nowBottom;
256
+ this.atTop = nowTop;
257
+ }
258
+ if (maxLeft > 0) {
259
+ const nowRight = scrollLeft >= maxLeft - threshold;
260
+ const nowLeft = scrollLeft <= threshold;
261
+ if (nowRight && !this.atRight) {
262
+ this.options.onTotalScroll("right");
263
+ }
264
+ if (nowLeft && !this.atLeft) {
265
+ this.options.onTotalScrollBack("left");
266
+ }
267
+ this.atRight = nowRight;
268
+ this.atLeft = nowLeft;
269
+ }
270
+ if (this.options.autoHide && !this.options.alwaysVisible) {
271
+ this.root.classList.add("is-scrolling");
272
+ this.scheduleAutoHide();
273
+ }
274
+ }
275
+ /**
276
+ * Synchronise la position physique et ARIA des curseurs.
277
+ */
278
+ syncThumbs() {
279
+ const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this.viewport;
280
+ if (this.thumbY && this.trackY) {
281
+ const maxScrollY = scrollHeight - clientHeight;
282
+ const trackHeight = this.trackY.clientHeight;
283
+ const thumbHeight = this.thumbY.clientHeight;
284
+ const maxTravelY = trackHeight - thumbHeight;
285
+ if (maxScrollY > 0 && maxTravelY > 0) {
286
+ const ratioY = scrollTop / maxScrollY;
287
+ const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
288
+ this.thumbY.style.transform = `translate3d(0, ${posY}px, 0)`;
289
+ this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
290
+ }
291
+ }
292
+ if (this.thumbX && this.trackX) {
293
+ const maxScrollX = scrollWidth - clientWidth;
294
+ const trackWidth = this.trackX.clientWidth;
295
+ const thumbWidth = this.thumbX.clientWidth;
296
+ const maxTravelX = trackWidth - thumbWidth;
297
+ if (maxScrollX > 0 && maxTravelX > 0) {
298
+ const ratioX = scrollLeft / maxScrollX;
299
+ const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
300
+ this.thumbX.style.transform = `translate3d(${posX}px, 0, 0)`;
301
+ this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
302
+ }
303
+ }
304
+ }
305
+ handleMouseEnter() {
306
+ this.root.classList.add("is-visible");
307
+ this.clearAutoHideTimer();
308
+ }
309
+ handleMouseLeave() {
310
+ this.scheduleAutoHide();
311
+ }
312
+ handleFocusIn() {
313
+ this.root.classList.add("is-visible");
314
+ this.clearAutoHideTimer();
315
+ }
316
+ handleFocusOut() {
317
+ this.scheduleAutoHide();
318
+ }
319
+ clearAutoHideTimer() {
320
+ if (this.hideTimer) {
321
+ window.clearTimeout(this.hideTimer);
322
+ this.hideTimer = void 0;
323
+ }
324
+ }
325
+ scheduleAutoHide() {
326
+ if (this.options.alwaysVisible || !this.options.autoHide || this.isDragging) return;
327
+ this.clearAutoHideTimer();
328
+ this.hideTimer = window.setTimeout(() => {
329
+ this.root.classList.remove("is-scrolling");
330
+ this.root.classList.remove("is-visible");
331
+ }, this.options.autoHideDelay);
332
+ }
333
+ /**
334
+ * Recalcule les dimensions et la visibilité des barres.
335
+ */
336
+ update() {
337
+ const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
338
+ const canScrollY = scrollHeight > clientHeight;
339
+ const canScrollX = scrollWidth > clientWidth;
340
+ this.root.classList.toggle("has-scroll-y", canScrollY);
341
+ this.root.classList.toggle("has-scroll-x", canScrollX);
342
+ if (canScrollY || canScrollX) {
343
+ this.viewport.setAttribute("tabindex", "0");
344
+ } else {
345
+ this.viewport.removeAttribute("tabindex");
346
+ }
347
+ if (this.trackY && this.thumbY) {
348
+ if (canScrollY) {
349
+ const trackHeight = this.trackY.clientHeight;
350
+ const calculatedHeight = Math.max(
351
+ this.options.minThumbSize,
352
+ trackHeight * (clientHeight / scrollHeight)
353
+ );
354
+ this.thumbY.style.height = `${calculatedHeight}px`;
355
+ }
356
+ }
357
+ if (this.trackX && this.thumbX) {
358
+ if (canScrollX) {
359
+ const trackWidth = this.trackX.clientWidth;
360
+ const calculatedWidth = Math.max(
361
+ this.options.minThumbSize,
362
+ trackWidth * (clientWidth / scrollWidth)
363
+ );
364
+ this.thumbX.style.width = `${calculatedWidth}px`;
365
+ }
366
+ }
367
+ this.syncThumbs();
368
+ }
369
+ /**
370
+ * Défilement programmatique direct ou lissé.
371
+ */
372
+ scrollTo(target, options) {
373
+ const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
374
+ const targetSmooth = typeof target === "object" && target !== null && !(target instanceof HTMLElement) ? target.smooth : void 0;
375
+ const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion;
376
+ const behavior = shouldSmooth ? "smooth" : "auto";
377
+ const maxTop = Math.max(0, this.viewport.scrollHeight - this.viewport.clientHeight);
378
+ const maxLeft = Math.max(0, this.viewport.scrollWidth - this.viewport.clientWidth);
379
+ let targetTop;
380
+ let targetLeft;
381
+ if (typeof target === "number") {
382
+ targetTop = target;
383
+ } else if (typeof target === "string") {
384
+ switch (target) {
385
+ case "top":
386
+ targetTop = 0;
387
+ break;
388
+ case "bottom":
389
+ targetTop = maxTop;
390
+ break;
391
+ case "left":
392
+ targetLeft = 0;
393
+ break;
394
+ case "right":
395
+ targetLeft = maxLeft;
396
+ break;
397
+ default: {
398
+ let el = null;
399
+ try {
400
+ el = this.viewport.querySelector(target);
401
+ } catch {
402
+ el = null;
403
+ }
404
+ if (el) {
405
+ targetTop = el.offsetTop;
406
+ targetLeft = el.offsetLeft;
407
+ }
408
+ break;
409
+ }
410
+ }
411
+ } else if (target instanceof HTMLElement) {
412
+ targetTop = target.offsetTop;
413
+ targetLeft = target.offsetLeft;
414
+ } else if (typeof target === "object") {
415
+ targetTop = target.top;
416
+ targetLeft = target.left;
417
+ }
418
+ this.viewport.scrollTo({
419
+ top: targetTop !== void 0 ? Math.max(0, Math.min(maxTop, targetTop)) : void 0,
420
+ left: targetLeft !== void 0 ? Math.max(0, Math.min(maxLeft, targetLeft)) : void 0,
421
+ behavior
422
+ });
423
+ }
424
+ /**
425
+ * Détruit le composant et libère toutes les ressources.
426
+ */
427
+ destroy() {
428
+ this.clearAutoHideTimer();
429
+ if (this.resizeObserver) {
430
+ this.resizeObserver.disconnect();
431
+ }
432
+ this.viewport.removeEventListener("scroll", this.boundOnScroll);
433
+ this.root.removeEventListener("mouseenter", this.boundOnMouseEnter);
434
+ this.root.removeEventListener("mouseleave", this.boundOnMouseLeave);
435
+ this.root.removeEventListener("focusin", this.boundOnFocusIn);
436
+ this.root.removeEventListener("focusout", this.boundOnFocusOut);
437
+ window.removeEventListener("pointermove", this.boundPointerMove);
438
+ window.removeEventListener("pointerup", this.boundPointerUp);
439
+ window.removeEventListener("pointercancel", this.boundPointerUp);
440
+ this.trackY?.remove();
441
+ this.trackX?.remove();
442
+ this.root.classList.remove(
443
+ "wulf-scrollblock",
444
+ "has-scroll-y",
445
+ "has-scroll-x",
446
+ "has-both-axes",
447
+ "is-visible",
448
+ "is-scrolling",
449
+ "is-dragging",
450
+ "is-always-visible"
451
+ );
452
+ if (this.createdViewport && this.viewport.parentElement === this.root) {
453
+ while (this.viewport.firstChild) {
454
+ this.root.insertBefore(this.viewport.firstChild, this.viewport);
455
+ }
456
+ this.viewport.remove();
457
+ }
458
+ }
459
+ };
460
+
461
+ // src/scroll/index.ts
462
+ var Scroll = {
463
+ ScrollBlock
464
+ };
465
+ var index_default = ScrollBlock;
466
+ if (typeof window !== "undefined") {
467
+ const win = window;
468
+ const wulfNamespace = win.Wulf || {};
469
+ win.Wulf = wulfNamespace;
470
+ wulfNamespace.Scroll = Scroll;
471
+ }
472
+ export {
473
+ Scroll,
474
+ ScrollBlock,
475
+ index_default as default
476
+ };
477
+ //# sourceMappingURL=scroll.esm.js.map