wulf.js 1.9.3 → 2.0.0

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 (79) hide show
  1. package/README.md +118 -78
  2. package/changelog.md +60 -0
  3. package/dist/focus-trap.esm.js +202 -136
  4. package/dist/focus-trap.esm.js.map +3 -3
  5. package/dist/focus-trap.global.js +203 -137
  6. package/dist/focus-trap.global.js.map +3 -3
  7. package/dist/focus-trap.global.min.js +4 -4
  8. package/dist/focus-trap.global.min.js.map +4 -4
  9. package/dist/index.esm.js +2130 -858
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +2124 -852
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +4 -4
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.css +1 -1
  16. package/dist/mask.css.map +2 -2
  17. package/dist/mask.esm.js +686 -330
  18. package/dist/mask.esm.js.map +3 -3
  19. package/dist/mask.global.js +687 -331
  20. package/dist/mask.global.js.map +3 -3
  21. package/dist/mask.global.min.js +4 -4
  22. package/dist/mask.global.min.js.map +4 -4
  23. package/dist/mask.layered.css +1 -0
  24. package/dist/mask.layered.css.map +7 -0
  25. package/dist/masonry.css +1 -1
  26. package/dist/masonry.css.map +2 -2
  27. package/dist/masonry.esm.js +248 -77
  28. package/dist/masonry.esm.js.map +3 -3
  29. package/dist/masonry.global.js +249 -78
  30. package/dist/masonry.global.js.map +3 -3
  31. package/dist/masonry.global.min.js +4 -4
  32. package/dist/masonry.global.min.js.map +4 -4
  33. package/dist/masonry.layered.css +1 -0
  34. package/dist/masonry.layered.css.map +7 -0
  35. package/dist/scroll.css +1 -1
  36. package/dist/scroll.css.map +2 -2
  37. package/dist/scroll.esm.js +462 -129
  38. package/dist/scroll.esm.js.map +3 -3
  39. package/dist/scroll.global.js +463 -130
  40. package/dist/scroll.global.js.map +3 -3
  41. package/dist/scroll.global.min.js +4 -4
  42. package/dist/scroll.global.min.js.map +4 -4
  43. package/dist/scroll.layered.css +1 -0
  44. package/dist/scroll.layered.css.map +7 -0
  45. package/dist/shortcut.esm.js +164 -48
  46. package/dist/shortcut.esm.js.map +3 -3
  47. package/dist/shortcut.global.js +165 -49
  48. package/dist/shortcut.global.js.map +3 -3
  49. package/dist/shortcut.global.min.js +2 -2
  50. package/dist/shortcut.global.min.js.map +4 -4
  51. package/dist/toast.css +1 -1
  52. package/dist/toast.css.map +2 -2
  53. package/dist/toast.esm.js +489 -124
  54. package/dist/toast.esm.js.map +3 -3
  55. package/dist/toast.global.js +490 -125
  56. package/dist/toast.global.js.map +3 -3
  57. package/dist/toast.global.min.js +3 -3
  58. package/dist/toast.global.min.js.map +4 -4
  59. package/dist/toast.layered.css +1 -0
  60. package/dist/toast.layered.css.map +7 -0
  61. package/dist/types/common/dom.d.ts +38 -0
  62. package/dist/types/focus-trap/FocusTrap.d.ts +14 -6
  63. package/dist/types/focus-trap/types.d.ts +2 -2
  64. package/dist/types/index.d.ts +10 -0
  65. package/dist/types/mask/BaseInputMask.d.ts +20 -0
  66. package/dist/types/mask/InputAmountMask.d.ts +2 -0
  67. package/dist/types/mask/InputEmailMask.d.ts +16 -1
  68. package/dist/types/mask/MaskEngine.d.ts +4 -0
  69. package/dist/types/masonry/Masonry.d.ts +10 -3
  70. package/dist/types/scroll/ScrollBlock.d.ts +31 -3
  71. package/dist/types/scroll/types.d.ts +13 -1
  72. package/dist/types/shortcut/ShortcutFormatter.d.ts +6 -0
  73. package/dist/types/shortcut/ShortcutManager.d.ts +1 -0
  74. package/dist/types/toast/Toast.d.ts +4 -0
  75. package/dist/types/toast/ToastInstance.d.ts +22 -10
  76. package/dist/types/toast/ToastManager.d.ts +37 -4
  77. package/dist/types/toast/i18n/types.d.ts +2 -0
  78. package/dist/types/toast/types.d.ts +9 -2
  79. package/package.json +16 -3
@@ -31,6 +31,33 @@ var __WulfIIFE = (() => {
31
31
  scrollI18n: () => scrollI18n
32
32
  });
33
33
 
34
+ // src/common/dom.ts
35
+ function getSafeWulfNamespace() {
36
+ if (typeof window === "undefined") return null;
37
+ const win = window;
38
+ const existing = win.Wulf;
39
+ if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
40
+ const fresh = {};
41
+ win.Wulf = fresh;
42
+ return fresh;
43
+ }
44
+ return existing;
45
+ }
46
+ function safeMove(parent, node, referenceNode = null) {
47
+ const moveBefore = parent.moveBefore;
48
+ if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
49
+ try {
50
+ moveBefore.call(parent, node, referenceNode);
51
+ return;
52
+ } catch {
53
+ }
54
+ }
55
+ parent.insertBefore(node, referenceNode);
56
+ }
57
+ function prefersReducedMotion() {
58
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
59
+ }
60
+
34
61
  // src/common/AuditableComponent.ts
35
62
  var AuditableComponent = class {
36
63
  /**
@@ -63,8 +90,11 @@ var __WulfIIFE = (() => {
63
90
  const rawValue = element.getAttribute(attrName)?.trim();
64
91
  if (!rawValue) return false;
65
92
  const doc = element.ownerDocument || document;
93
+ const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
66
94
  const ids = rawValue.split(/\s+/).filter(Boolean);
67
- const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
95
+ const isValid = ids.length > 0 && ids.every(
96
+ (id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
97
+ );
68
98
  if (!isValid) {
69
99
  warnings.push(
70
100
  `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
@@ -76,6 +106,7 @@ var __WulfIIFE = (() => {
76
106
 
77
107
  // src/common/LocalizedComponent.ts
78
108
  var LocalizedComponent = class extends AuditableComponent {
109
+ static _i18n;
79
110
  /**
80
111
  * Définit la langue globale du composant (ex: 'fr', 'en', 'es').
81
112
  */
@@ -126,6 +157,10 @@ var __WulfIIFE = (() => {
126
157
  static t(key, instanceOverride) {
127
158
  return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
128
159
  }
160
+ /**
161
+ * Surcharges de localisation spécifiques à cette instance.
162
+ */
163
+ i18nOverrides;
129
164
  constructor(i18nOverrides) {
130
165
  super();
131
166
  this.i18nOverrides = i18nOverrides;
@@ -156,7 +191,7 @@ var __WulfIIFE = (() => {
156
191
  function assignDefined(target, source) {
157
192
  if (!source || typeof source !== "object") return target;
158
193
  for (const key of Object.keys(source)) {
159
- if (isSafeKey(String(key)) && Object.prototype.hasOwnProperty.call(source, key) && source[key] !== void 0) {
194
+ if (isSafeKey(String(key)) && Object.hasOwn(source, key) && source[key] !== void 0) {
160
195
  target[key] = source[key];
161
196
  }
162
197
  }
@@ -217,7 +252,7 @@ var __WulfIIFE = (() => {
217
252
  if (!isSafeKey(String(key))) {
218
253
  return "";
219
254
  }
220
- if (instanceOverride && typeof instanceOverride === "object" && Object.prototype.hasOwnProperty.call(instanceOverride, key) && instanceOverride[key] !== void 0) {
255
+ if (instanceOverride && typeof instanceOverride === "object" && Object.hasOwn(instanceOverride, key) && instanceOverride[key] !== void 0) {
221
256
  return String(instanceOverride[key]);
222
257
  }
223
258
  if (globalOverrides[key] !== void 0) {
@@ -280,21 +315,60 @@ var __WulfIIFE = (() => {
280
315
  // src/scroll/ScrollBlock.ts
281
316
  var idCounter = 0;
282
317
  var ScrollBlock = class extends LocalizedComponent {
318
+ static _i18n = scrollI18n;
319
+ static i18n = scrollI18n;
320
+ root;
321
+ viewport;
322
+ options;
323
+ createdViewport = false;
324
+ isDestroyed = false;
325
+ wasIdGenerated = false;
326
+ wasRoleInferred = false;
327
+ wasAriaLabelInferred = false;
328
+ hasExplicitAriaLabel = false;
329
+ hasRootAriaLabel = false;
330
+ propagatedRootLabel = null;
331
+ lastInferredAriaLabel = "";
332
+ trackY;
333
+ thumbY;
334
+ trackX;
335
+ thumbX;
336
+ resizeObserver;
337
+ hideTimer;
338
+ scrollEndFallbackTimer;
339
+ rafId = null;
340
+ resizeRafId = null;
341
+ abortController = new AbortController();
342
+ dragAbortController;
343
+ activeScrollToController;
344
+ supportsScrollEnd = typeof window !== "undefined" && "onscrollend" in window;
345
+ // Cache de métriques géométriques mis à jour dans update() pour éviter tout forced reflow en cours de scroll
346
+ cachedMaxTop = 0;
347
+ cachedMaxLeft = 0;
348
+ cachedTrackHeight = 0;
349
+ cachedThumbHeight = 0;
350
+ cachedTrackWidth = 0;
351
+ cachedThumbWidth = 0;
352
+ isDragging = false;
353
+ dragAxis;
354
+ dragPointerId;
355
+ dragStartPos = 0;
356
+ dragStartScroll = 0;
357
+ atBottom = false;
358
+ atTop = true;
359
+ atRight = false;
360
+ atLeft = true;
361
+ // Références d'écouteurs d'événements pour les callbacks et le drag
362
+ boundOnScroll;
363
+ boundOnScrollEnd;
364
+ boundOnMouseEnter;
365
+ boundOnMouseLeave;
366
+ boundOnFocusIn;
367
+ boundOnFocusOut;
368
+ boundPointerMove;
369
+ boundPointerUp;
283
370
  constructor(element, options) {
284
371
  super(options?.i18n);
285
- this.createdViewport = false;
286
- this.wasIdGenerated = false;
287
- this.wasRoleInferred = false;
288
- this.wasAriaLabelInferred = false;
289
- this.hasExplicitAriaLabel = false;
290
- this.lastInferredAriaLabel = "";
291
- this.isDragging = false;
292
- this.dragStartPos = 0;
293
- this.dragStartScroll = 0;
294
- this.atBottom = false;
295
- this.atTop = true;
296
- this.atRight = false;
297
- this.atLeft = true;
298
372
  let resolvedElement = null;
299
373
  if (typeof element === "string") {
300
374
  try {
@@ -318,6 +392,7 @@ var __WulfIIFE = (() => {
318
392
  const safeEdgeThreshold = typeof rawEdge === "number" && Number.isFinite(rawEdge) && rawEdge >= 0 ? rawEdge : 10;
319
393
  this.options = {
320
394
  axis: options?.axis || "y",
395
+ mode: options?.mode || "custom",
321
396
  autoHide: options?.autoHide ?? true,
322
397
  autoHideDelay: safeAutoHideDelay,
323
398
  alwaysVisible: options?.alwaysVisible ?? false,
@@ -327,6 +402,8 @@ var __WulfIIFE = (() => {
327
402
  edgeThreshold: safeEdgeThreshold,
328
403
  onScroll: options?.onScroll || (() => {
329
404
  }),
405
+ onScrollEnd: options?.onScrollEnd || (() => {
406
+ }),
330
407
  onTotalScroll: options?.onTotalScroll || (() => {
331
408
  }),
332
409
  onTotalScrollBack: options?.onTotalScrollBack || (() => {
@@ -334,6 +411,7 @@ var __WulfIIFE = (() => {
334
411
  audit: options?.audit ?? true
335
412
  };
336
413
  this.boundOnScroll = this.handleScroll.bind(this);
414
+ this.boundOnScrollEnd = this.handleScrollEnd.bind(this);
337
415
  this.boundOnMouseEnter = this.handleMouseEnter.bind(this);
338
416
  this.boundOnMouseLeave = this.handleMouseLeave.bind(this);
339
417
  this.boundOnFocusIn = this.handleFocusIn.bind(this);
@@ -353,6 +431,9 @@ var __WulfIIFE = (() => {
353
431
  */
354
432
  setupViewport() {
355
433
  this.root.classList.add("wulf-scrollblock");
434
+ if (this.options.mode === "native") {
435
+ this.root.classList.add("wulf-scrollblock--native");
436
+ }
356
437
  if (this.options.alwaysVisible) {
357
438
  this.root.classList.add("is-always-visible");
358
439
  }
@@ -363,12 +444,13 @@ var __WulfIIFE = (() => {
363
444
  if (existingViewport) {
364
445
  return existingViewport;
365
446
  }
447
+ const existingChildren = Array.from(this.root.childNodes);
366
448
  const viewport = document.createElement("div");
367
449
  viewport.className = "wulf-scrollblock-viewport";
368
- while (this.root.firstChild) {
369
- viewport.appendChild(this.root.firstChild);
370
- }
371
450
  this.root.appendChild(viewport);
451
+ for (const child of existingChildren) {
452
+ safeMove(viewport, child, null);
453
+ }
372
454
  this.createdViewport = true;
373
455
  return viewport;
374
456
  }
@@ -385,8 +467,27 @@ var __WulfIIFE = (() => {
385
467
  this.viewport.setAttribute("role", "region");
386
468
  this.wasRoleInferred = true;
387
469
  }
388
- if (!this.viewport.hasAttribute("aria-label")) {
389
- const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("viewport");
470
+ const rootLabelledBy = this.root.getAttribute("aria-labelledby")?.trim();
471
+ const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
472
+ if (rootLabelledBy) {
473
+ this.hasRootAriaLabel = true;
474
+ if (!this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-labelledby") && !this.viewport.hasAttribute("aria-label")) {
475
+ this.viewport.setAttribute("aria-labelledby", rootLabelledBy);
476
+ this.propagatedRootLabel = "aria-labelledby";
477
+ }
478
+ } else if (rootAriaLabel) {
479
+ this.hasRootAriaLabel = true;
480
+ if (!this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-label") && !this.viewport.hasAttribute("aria-labelledby")) {
481
+ this.viewport.setAttribute("aria-label", rootAriaLabel);
482
+ this.propagatedRootLabel = "aria-label";
483
+ }
484
+ }
485
+ if (this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-label")) {
486
+ this.viewport.setAttribute("aria-label", this.options.ariaLabel);
487
+ this.lastInferredAriaLabel = this.options.ariaLabel;
488
+ this.wasAriaLabelInferred = true;
489
+ } else if (!this.viewport.hasAttribute("aria-label") && !this.viewport.hasAttribute("aria-labelledby")) {
490
+ const label = this.t("viewport");
390
491
  this.viewport.setAttribute("aria-label", label);
391
492
  this.lastInferredAriaLabel = label;
392
493
  this.wasAriaLabelInferred = true;
@@ -416,10 +517,12 @@ var __WulfIIFE = (() => {
416
517
  * Crée les rails et curseurs selon l'axe sélectionné.
417
518
  */
418
519
  setupScrollbars() {
520
+ if (this.options.mode === "native") {
521
+ return;
522
+ }
419
523
  if (this.options.axis === "y" || this.options.axis === "both") {
420
524
  this.trackY = document.createElement("div");
421
525
  this.trackY.className = "wulf-scrollblock-track wulf-scrollblock-vertical";
422
- this.trackY.setAttribute("aria-hidden", "true");
423
526
  this.thumbY = document.createElement("div");
424
527
  this.thumbY.className = "wulf-scrollblock-thumb";
425
528
  this.thumbY.setAttribute("role", "scrollbar");
@@ -436,7 +539,6 @@ var __WulfIIFE = (() => {
436
539
  if (this.options.axis === "x" || this.options.axis === "both") {
437
540
  this.trackX = document.createElement("div");
438
541
  this.trackX.className = "wulf-scrollblock-track wulf-scrollblock-horizontal";
439
- this.trackX.setAttribute("aria-hidden", "true");
440
542
  this.thumbX = document.createElement("div");
441
543
  this.thumbX.className = "wulf-scrollblock-thumb";
442
544
  this.thumbX.setAttribute("role", "scrollbar");
@@ -451,48 +553,129 @@ var __WulfIIFE = (() => {
451
553
  this.attachTrackListeners(this.trackX, this.thumbX, "x");
452
554
  }
453
555
  }
556
+ isRtl() {
557
+ return typeof window !== "undefined" && window.getComputedStyle(this.viewport).direction === "rtl";
558
+ }
454
559
  /**
455
- * Attache les écouteurs sur un rail et son curseur.
560
+ * Attache les écouteurs souris/pointeur et clavier WAI-ARIA sur un rail et son curseur.
456
561
  */
457
562
  attachTrackListeners(track, thumb, axis) {
563
+ const { signal } = this.abortController;
458
564
  thumb.addEventListener("pointerdown", (e) => {
565
+ if (e.button !== 0) return;
459
566
  e.preventDefault();
460
567
  e.stopPropagation();
568
+ this.dragAbortController?.abort();
569
+ this.dragAbortController = new AbortController();
570
+ const dragSignal = this.dragAbortController.signal;
461
571
  this.isDragging = true;
462
572
  this.dragAxis = axis;
463
573
  this.dragPointerId = e.pointerId;
464
574
  this.dragStartPos = axis === "y" ? e.clientY : e.clientX;
465
575
  this.dragStartScroll = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
466
- thumb.setPointerCapture(e.pointerId);
576
+ try {
577
+ thumb.setPointerCapture(e.pointerId);
578
+ } catch {
579
+ }
467
580
  thumb.classList.add("is-active");
468
581
  this.root.classList.add("is-dragging");
469
- window.addEventListener("pointermove", this.boundPointerMove);
470
- window.addEventListener("pointerup", this.boundPointerUp);
471
- window.addEventListener("pointercancel", this.boundPointerUp);
472
- });
582
+ window.addEventListener("pointermove", this.boundPointerMove, { signal: dragSignal });
583
+ window.addEventListener("pointerup", this.boundPointerUp, { signal: dragSignal });
584
+ window.addEventListener("pointercancel", this.boundPointerUp, { signal: dragSignal });
585
+ thumb.addEventListener("lostpointercapture", this.boundPointerUp, { signal: dragSignal });
586
+ }, { signal });
587
+ thumb.addEventListener("keydown", (e) => {
588
+ if (e.ctrlKey || e.altKey || e.metaKey) return;
589
+ const step = 40;
590
+ const page = axis === "y" ? Math.max(step, Math.round(this.viewport.clientHeight * 0.9)) : Math.max(step, Math.round(this.viewport.clientWidth * 0.9));
591
+ const maxScroll = axis === "y" ? this.cachedMaxTop : this.cachedMaxLeft;
592
+ if (maxScroll <= 0) return;
593
+ const rtl = axis === "x" && this.isRtl();
594
+ const current = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
595
+ let target = null;
596
+ if (axis === "y") {
597
+ switch (e.key) {
598
+ case "ArrowDown":
599
+ target = current + step;
600
+ break;
601
+ case "ArrowUp":
602
+ target = current - step;
603
+ break;
604
+ case "PageDown":
605
+ target = current + page;
606
+ break;
607
+ case "PageUp":
608
+ target = current - page;
609
+ break;
610
+ case " ":
611
+ target = current + (e.shiftKey ? -page : page);
612
+ break;
613
+ case "Home":
614
+ target = 0;
615
+ break;
616
+ case "End":
617
+ target = maxScroll;
618
+ break;
619
+ }
620
+ } else {
621
+ switch (e.key) {
622
+ case "ArrowRight":
623
+ target = current + step;
624
+ break;
625
+ case "ArrowLeft":
626
+ target = current - step;
627
+ break;
628
+ case "PageDown":
629
+ target = current + (rtl ? -page : page);
630
+ break;
631
+ case "PageUp":
632
+ target = current + (rtl ? page : -page);
633
+ break;
634
+ case " ":
635
+ target = current + (e.shiftKey ? rtl ? page : -page : rtl ? -page : page);
636
+ break;
637
+ case "Home":
638
+ target = 0;
639
+ break;
640
+ case "End":
641
+ target = rtl ? -maxScroll : maxScroll;
642
+ break;
643
+ }
644
+ }
645
+ if (target === null) return;
646
+ e.preventDefault();
647
+ e.stopPropagation();
648
+ void this.scrollTo(axis === "y" ? { top: target } : { left: target }, { smooth: false });
649
+ this.syncThumbs();
650
+ }, { signal });
473
651
  track.addEventListener("pointerdown", (e) => {
474
- if (e.target === thumb) return;
652
+ if (e.button !== 0 || e.target === thumb) return;
475
653
  e.preventDefault();
654
+ const rtl = axis === "x" && this.isRtl();
476
655
  const rect = track.getBoundingClientRect();
477
- const clickPos = axis === "y" ? e.clientY - rect.top : e.clientX - rect.left;
656
+ const clickPos = axis === "y" ? e.clientY - rect.top : rtl ? rect.right - e.clientX : e.clientX - rect.left;
478
657
  const trackSize = axis === "y" ? rect.height : rect.width;
479
- const clientSize = axis === "y" ? this.viewport.clientHeight : this.viewport.clientWidth;
480
- const scrollSize = axis === "y" ? this.viewport.scrollHeight : this.viewport.scrollWidth;
481
- const ratio = clickPos / trackSize;
482
- const targetScroll = ratio * (scrollSize - clientSize);
483
- this.scrollTo(axis === "y" ? { top: targetScroll } : { left: targetScroll }, { smooth: true });
484
- });
658
+ if (trackSize <= 0) return;
659
+ const maxScroll = axis === "y" ? this.cachedMaxTop : this.cachedMaxLeft;
660
+ const ratio = Math.max(0, Math.min(1, clickPos / trackSize));
661
+ const targetScroll = rtl ? -(ratio * maxScroll) : ratio * maxScroll;
662
+ void this.scrollTo(axis === "y" ? { top: targetScroll } : { left: targetScroll }, { smooth: true });
663
+ }, { signal });
485
664
  }
486
665
  /**
487
666
  * Écouteurs globaux sur le viewport et les interactions.
488
667
  */
489
668
  setupEventListeners() {
490
- this.viewport.addEventListener("scroll", this.boundOnScroll, { passive: true });
491
- if (this.options.autoHide && !this.options.alwaysVisible) {
492
- this.root.addEventListener("mouseenter", this.boundOnMouseEnter);
493
- this.root.addEventListener("mouseleave", this.boundOnMouseLeave);
494
- this.root.addEventListener("focusin", this.boundOnFocusIn);
495
- this.root.addEventListener("focusout", this.boundOnFocusOut);
669
+ const { signal } = this.abortController;
670
+ this.viewport.addEventListener("scroll", this.boundOnScroll, { passive: true, signal });
671
+ if (this.supportsScrollEnd) {
672
+ this.viewport.addEventListener("scrollend", this.boundOnScrollEnd, { passive: true, signal });
673
+ }
674
+ if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
675
+ this.root.addEventListener("mouseenter", this.boundOnMouseEnter, { signal });
676
+ this.root.addEventListener("mouseleave", this.boundOnMouseLeave, { signal });
677
+ this.root.addEventListener("focusin", this.boundOnFocusIn, { signal });
678
+ this.root.addEventListener("focusout", this.boundOnFocusOut, { signal });
496
679
  }
497
680
  }
498
681
  /**
@@ -501,7 +684,13 @@ var __WulfIIFE = (() => {
501
684
  setupObserver() {
502
685
  if (typeof ResizeObserver !== "undefined") {
503
686
  this.resizeObserver = new ResizeObserver(() => {
504
- window.requestAnimationFrame(() => this.update());
687
+ if (this.isDestroyed || this.resizeRafId !== null) return;
688
+ this.resizeRafId = window.requestAnimationFrame(() => {
689
+ this.resizeRafId = null;
690
+ if (!this.isDestroyed) {
691
+ this.update();
692
+ }
693
+ });
505
694
  });
506
695
  this.resizeObserver.observe(this.root);
507
696
  this.resizeObserver.observe(this.viewport);
@@ -515,22 +704,20 @@ var __WulfIIFE = (() => {
515
704
  */
516
705
  handlePointerMove(e) {
517
706
  if (!this.isDragging || !this.dragAxis) return;
707
+ if (this.dragPointerId !== void 0 && e.pointerId !== this.dragPointerId) return;
518
708
  const isY = this.dragAxis === "y";
519
709
  const delta = (isY ? e.clientY : e.clientX) - this.dragStartPos;
520
- const track = isY ? this.trackY : this.trackX;
521
- const thumb = isY ? this.thumbY : this.thumbX;
522
- if (!track || !thumb) return;
523
- const trackSize = isY ? track.clientHeight : track.clientWidth;
524
- const thumbSize = isY ? thumb.clientHeight : thumb.clientWidth;
525
- const clientSize = isY ? this.viewport.clientHeight : this.viewport.clientWidth;
526
- const scrollSize = isY ? this.viewport.scrollHeight : this.viewport.scrollWidth;
527
- const maxScroll = scrollSize - clientSize;
710
+ const trackSize = isY ? this.cachedTrackHeight : this.cachedTrackWidth;
711
+ const thumbSize = isY ? this.cachedThumbHeight : this.cachedThumbWidth;
712
+ const maxScroll = isY ? this.cachedMaxTop : this.cachedMaxLeft;
528
713
  const maxThumbTravel = trackSize - thumbSize;
529
714
  if (maxThumbTravel <= 0 || maxScroll <= 0) return;
530
715
  const ratio = maxScroll / maxThumbTravel;
531
716
  const nextScroll = this.dragStartScroll + delta * ratio;
532
717
  if (isY) {
533
718
  this.viewport.scrollTop = Math.max(0, Math.min(maxScroll, nextScroll));
719
+ } else if (this.isRtl()) {
720
+ this.viewport.scrollLeft = Math.max(-maxScroll, Math.min(0, nextScroll));
534
721
  } else {
535
722
  this.viewport.scrollLeft = Math.max(0, Math.min(maxScroll, nextScroll));
536
723
  }
@@ -540,15 +727,20 @@ var __WulfIIFE = (() => {
540
727
  */
541
728
  handlePointerUp(e) {
542
729
  if (!this.isDragging) return;
730
+ if (e && e.type !== "lostpointercapture" && this.dragPointerId !== void 0 && e.pointerId !== this.dragPointerId) {
731
+ return;
732
+ }
543
733
  if (this.dragPointerId !== void 0) {
544
734
  const activeThumb = this.dragAxis === "y" ? this.thumbY : this.thumbX;
545
- if (activeThumb && activeThumb.hasPointerCapture(this.dragPointerId)) {
546
- activeThumb.releasePointerCapture(this.dragPointerId);
735
+ try {
736
+ if (activeThumb && activeThumb.hasPointerCapture(this.dragPointerId)) {
737
+ activeThumb.releasePointerCapture(this.dragPointerId);
738
+ }
739
+ } catch {
547
740
  }
548
741
  }
549
- window.removeEventListener("pointermove", this.boundPointerMove);
550
- window.removeEventListener("pointerup", this.boundPointerUp);
551
- window.removeEventListener("pointercancel", this.boundPointerUp);
742
+ this.dragAbortController?.abort();
743
+ this.dragAbortController = void 0;
552
744
  this.isDragging = false;
553
745
  this.dragAxis = void 0;
554
746
  this.dragPointerId = void 0;
@@ -557,24 +749,31 @@ var __WulfIIFE = (() => {
557
749
  this.root.classList.remove("is-dragging");
558
750
  this.scheduleAutoHide();
559
751
  }
560
- /**
561
- * Gestionnaire d'événement de défilement natif.
562
- */
563
- handleScroll() {
564
- this.syncThumbs();
565
- const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this.viewport;
566
- const maxTop = Math.max(0, scrollHeight - clientHeight);
567
- const maxLeft = Math.max(0, scrollWidth - clientWidth);
568
- const progressY = maxTop > 0 ? scrollTop / maxTop : 0;
569
- const progressX = maxLeft > 0 ? scrollLeft / maxLeft : 0;
570
- this.options.onScroll({
752
+ getScrollInfo() {
753
+ const { scrollTop, scrollLeft } = this.viewport;
754
+ const maxTop = this.cachedMaxTop;
755
+ const maxLeft = this.cachedMaxLeft;
756
+ const rtl = this.isRtl();
757
+ const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
758
+ const progressY = maxTop > 0 ? Math.max(0, Math.min(1, scrollTop / maxTop)) : 0;
759
+ const progressX = maxLeft > 0 ? Math.max(0, Math.min(1, logicalLeft / maxLeft)) : 0;
760
+ return {
571
761
  top: scrollTop,
572
762
  left: scrollLeft,
573
763
  maxTop,
574
764
  maxLeft,
575
765
  progressY: Math.round(progressY * 100),
576
766
  progressX: Math.round(progressX * 100)
577
- });
767
+ };
768
+ }
769
+ /**
770
+ * Gestionnaire d'événement de défilement natif.
771
+ */
772
+ handleScroll() {
773
+ this.scheduleSyncThumbs();
774
+ const info = this.getScrollInfo();
775
+ const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
776
+ this.options.onScroll(info);
578
777
  const threshold = this.options.edgeThreshold;
579
778
  if (maxTop > 0) {
580
779
  const nowBottom = scrollTop >= maxTop - threshold;
@@ -589,8 +788,9 @@ var __WulfIIFE = (() => {
589
788
  this.atTop = nowTop;
590
789
  }
591
790
  if (maxLeft > 0) {
592
- const nowRight = scrollLeft >= maxLeft - threshold;
593
- const nowLeft = scrollLeft <= threshold;
791
+ const rtl = this.isRtl();
792
+ const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
793
+ const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
594
794
  if (nowRight && !this.atRight) {
595
795
  this.options.onTotalScroll("right");
596
796
  }
@@ -600,37 +800,71 @@ var __WulfIIFE = (() => {
600
800
  this.atRight = nowRight;
601
801
  this.atLeft = nowLeft;
602
802
  }
603
- if (this.options.autoHide && !this.options.alwaysVisible) {
803
+ if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
804
+ this.clearAutoHideTimer();
604
805
  this.root.classList.add("is-scrolling");
806
+ if (!this.supportsScrollEnd) {
807
+ this.scheduleAutoHide();
808
+ }
809
+ }
810
+ if (!this.supportsScrollEnd) {
811
+ if (this.scrollEndFallbackTimer !== void 0) {
812
+ window.clearTimeout(this.scrollEndFallbackTimer);
813
+ }
814
+ this.scrollEndFallbackTimer = window.setTimeout(() => {
815
+ this.scrollEndFallbackTimer = void 0;
816
+ this.handleScrollEnd();
817
+ }, 150);
818
+ }
819
+ }
820
+ /**
821
+ * Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
822
+ */
823
+ handleScrollEnd() {
824
+ this.options.onScrollEnd(this.getScrollInfo());
825
+ if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
605
826
  this.scheduleAutoHide();
606
827
  }
607
828
  }
608
829
  /**
609
- * Synchronise la position physique et ARIA des curseurs.
830
+ * Planifie une synchronisation des curseurs calée sur la prochaine trame d'affichage.
831
+ */
832
+ scheduleSyncThumbs() {
833
+ if (this.options.mode === "native" || this.isDestroyed) return;
834
+ if (this.rafId !== null) return;
835
+ this.rafId = window.requestAnimationFrame(() => {
836
+ this.rafId = null;
837
+ if (!this.isDestroyed) {
838
+ this.syncThumbs();
839
+ }
840
+ });
841
+ }
842
+ /**
843
+ * Synchronise la position physique (via variables CSS) et ARIA des curseurs à partir des métriques en cache.
610
844
  */
611
845
  syncThumbs() {
612
- const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this.viewport;
846
+ if (this.options.mode === "native" || this.isDestroyed) return;
847
+ const { scrollTop, scrollLeft } = this.viewport;
613
848
  if (this.thumbY && this.trackY) {
614
- const maxScrollY = scrollHeight - clientHeight;
615
- const trackHeight = this.trackY.clientHeight;
616
- const thumbHeight = this.thumbY.clientHeight;
617
- const maxTravelY = trackHeight - thumbHeight;
849
+ const maxScrollY = this.cachedMaxTop;
850
+ const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
618
851
  if (maxScrollY > 0 && maxTravelY > 0) {
619
- const ratioY = scrollTop / maxScrollY;
852
+ const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
620
853
  const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
621
- this.thumbY.style.transform = `translate3d(0, ${posY}px, 0)`;
854
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
622
855
  this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
623
856
  }
624
857
  }
625
858
  if (this.thumbX && this.trackX) {
626
- const maxScrollX = scrollWidth - clientWidth;
627
- const trackWidth = this.trackX.clientWidth;
628
- const thumbWidth = this.thumbX.clientWidth;
629
- const maxTravelX = trackWidth - thumbWidth;
859
+ const maxScrollX = this.cachedMaxLeft;
860
+ const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
630
861
  if (maxScrollX > 0 && maxTravelX > 0) {
631
- const ratioX = scrollLeft / maxScrollX;
862
+ const rtl = this.isRtl();
863
+ const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
864
+ const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
632
865
  const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
633
- this.thumbX.style.transform = `translate3d(${posX}px, 0, 0)`;
866
+ const signedPosX = rtl ? -posX : posX;
867
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
634
868
  this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
635
869
  }
636
870
  }
@@ -667,10 +901,37 @@ var __WulfIIFE = (() => {
667
901
  * Recalcule les dimensions et la visibilité des barres.
668
902
  */
669
903
  update() {
904
+ if (this.isDestroyed) return;
670
905
  this.syncAccessibilityLabels();
671
906
  const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
907
+ const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
908
+ const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
909
+ const cssMinY = this.thumbY && typeof window !== "undefined" ? parseFloat(window.getComputedStyle(this.thumbY).minBlockSize) || 0 : 0;
910
+ const cssMinX = this.thumbX && typeof window !== "undefined" ? parseFloat(window.getComputedStyle(this.thumbX).minInlineSize) || 0 : 0;
911
+ this.cachedMaxTop = Math.max(0, scrollHeight - clientHeight);
912
+ this.cachedMaxLeft = Math.max(0, scrollWidth - clientWidth);
913
+ this.cachedTrackHeight = trackHeight;
914
+ this.cachedTrackWidth = trackWidth;
672
915
  const canScrollY = scrollHeight > clientHeight;
673
916
  const canScrollX = scrollWidth > clientWidth;
917
+ let calculatedHeight = this.cachedThumbHeight;
918
+ if (this.trackY && this.thumbY && canScrollY && scrollHeight > 0) {
919
+ const effectiveMinY = Math.max(this.options.minThumbSize, cssMinY);
920
+ calculatedHeight = Math.max(
921
+ effectiveMinY,
922
+ trackHeight * (clientHeight / scrollHeight)
923
+ );
924
+ this.cachedThumbHeight = calculatedHeight;
925
+ }
926
+ let calculatedWidth = this.cachedThumbWidth;
927
+ if (this.trackX && this.thumbX && canScrollX && scrollWidth > 0) {
928
+ const effectiveMinX = Math.max(this.options.minThumbSize, cssMinX);
929
+ calculatedWidth = Math.max(
930
+ effectiveMinX,
931
+ trackWidth * (clientWidth / scrollWidth)
932
+ );
933
+ this.cachedThumbWidth = calculatedWidth;
934
+ }
674
935
  this.root.classList.toggle("has-scroll-y", canScrollY);
675
936
  this.root.classList.toggle("has-scroll-x", canScrollX);
676
937
  if (canScrollY || canScrollX) {
@@ -679,37 +940,40 @@ var __WulfIIFE = (() => {
679
940
  this.viewport.removeAttribute("tabindex");
680
941
  }
681
942
  if (this.trackY && this.thumbY) {
943
+ this.trackY.hidden = !canScrollY;
682
944
  if (canScrollY) {
683
- const trackHeight = this.trackY.clientHeight;
684
- const calculatedHeight = Math.max(
685
- this.options.minThumbSize,
686
- trackHeight * (clientHeight / scrollHeight)
687
- );
945
+ this.thumbY.setAttribute("tabindex", "0");
688
946
  this.thumbY.style.height = `${calculatedHeight}px`;
947
+ } else {
948
+ this.thumbY.removeAttribute("tabindex");
689
949
  }
690
950
  }
691
951
  if (this.trackX && this.thumbX) {
952
+ this.trackX.hidden = !canScrollX;
692
953
  if (canScrollX) {
693
- const trackWidth = this.trackX.clientWidth;
694
- const calculatedWidth = Math.max(
695
- this.options.minThumbSize,
696
- trackWidth * (clientWidth / scrollWidth)
697
- );
954
+ this.thumbX.setAttribute("tabindex", "0");
698
955
  this.thumbX.style.width = `${calculatedWidth}px`;
956
+ } else {
957
+ this.thumbX.removeAttribute("tabindex");
699
958
  }
700
959
  }
701
960
  this.syncThumbs();
702
961
  }
703
962
  /**
704
963
  * Défilement programmatique direct ou lissé.
964
+ * Retourne une Promesse résolue lorsque le défilement atteint sa cible.
705
965
  */
706
966
  scrollTo(target, options) {
707
- const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
967
+ if (this.isDestroyed) return Promise.resolve();
708
968
  const targetSmooth = typeof target === "object" && target !== null && !(target instanceof HTMLElement) ? target.smooth : void 0;
709
- const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion;
969
+ const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion();
710
970
  const behavior = shouldSmooth ? "smooth" : "auto";
711
- const maxTop = Math.max(0, this.viewport.scrollHeight - this.viewport.clientHeight);
712
- const maxLeft = Math.max(0, this.viewport.scrollWidth - this.viewport.clientWidth);
971
+ const rtl = this.isRtl();
972
+ const { scrollHeight, clientHeight, scrollWidth, clientWidth, scrollTop, scrollLeft } = this.viewport;
973
+ const maxTop = Math.max(0, scrollHeight - clientHeight);
974
+ const maxLeft = Math.max(0, scrollWidth - clientWidth);
975
+ this.cachedMaxTop = maxTop;
976
+ this.cachedMaxLeft = maxLeft;
713
977
  let targetTop;
714
978
  let targetLeft;
715
979
  if (typeof target === "number") {
@@ -723,19 +987,19 @@ var __WulfIIFE = (() => {
723
987
  targetTop = maxTop;
724
988
  break;
725
989
  case "left":
726
- targetLeft = 0;
990
+ targetLeft = rtl ? -maxLeft : 0;
727
991
  break;
728
992
  case "right":
729
- targetLeft = maxLeft;
993
+ targetLeft = rtl ? 0 : maxLeft;
730
994
  break;
731
995
  default: {
732
996
  if (/^-?\d+(\.\d+)?%$/.test(target.trim())) {
733
997
  const pct = Math.max(0, Math.min(100, parseFloat(target.trim()))) / 100;
734
998
  if (this.options.axis === "x") {
735
- targetLeft = maxLeft * pct;
999
+ targetLeft = rtl ? -maxLeft * pct : maxLeft * pct;
736
1000
  } else if (this.options.axis === "both") {
737
1001
  targetTop = maxTop * pct;
738
- targetLeft = maxLeft * pct;
1002
+ targetLeft = rtl ? -maxLeft * pct : maxLeft * pct;
739
1003
  } else {
740
1004
  targetTop = maxTop * pct;
741
1005
  }
@@ -748,24 +1012,82 @@ var __WulfIIFE = (() => {
748
1012
  el = null;
749
1013
  }
750
1014
  if (el) {
751
- targetTop = el.offsetTop;
752
- targetLeft = el.offsetLeft;
1015
+ const vpRect = this.viewport.getBoundingClientRect();
1016
+ const elRect = el.getBoundingClientRect();
1017
+ targetTop = elRect.top - vpRect.top + scrollTop;
1018
+ targetLeft = elRect.left - vpRect.left + scrollLeft;
753
1019
  }
754
1020
  break;
755
1021
  }
756
1022
  }
757
1023
  } else if (target instanceof HTMLElement) {
758
- targetTop = target.offsetTop;
759
- targetLeft = target.offsetLeft;
760
- } else if (typeof target === "object") {
1024
+ const vpRect = this.viewport.getBoundingClientRect();
1025
+ const elRect = target.getBoundingClientRect();
1026
+ targetTop = elRect.top - vpRect.top + scrollTop;
1027
+ targetLeft = elRect.left - vpRect.left + scrollLeft;
1028
+ } else if (typeof target === "object" && target !== null) {
761
1029
  targetTop = target.top;
762
1030
  targetLeft = target.left;
763
1031
  }
764
- this.viewport.scrollTo({
765
- top: targetTop !== void 0 && Number.isFinite(targetTop) ? Math.max(0, Math.min(maxTop, targetTop)) : void 0,
766
- left: targetLeft !== void 0 && Number.isFinite(targetLeft) ? Math.max(0, Math.min(maxLeft, targetLeft)) : void 0,
1032
+ const clampedTop = targetTop !== void 0 && Number.isFinite(targetTop) ? Math.max(0, Math.min(maxTop, targetTop)) : void 0;
1033
+ const minLeftBound = rtl ? -maxLeft : 0;
1034
+ const maxLeftBound = rtl ? 0 : maxLeft;
1035
+ const clampedLeft = targetLeft !== void 0 && Number.isFinite(targetLeft) ? Math.max(minLeftBound, Math.min(maxLeftBound, targetLeft)) : void 0;
1036
+ const destTop = clampedTop ?? scrollTop;
1037
+ const destLeft = clampedLeft ?? scrollLeft;
1038
+ if (Math.abs(destTop - scrollTop) <= 1 && Math.abs(destLeft - scrollLeft) <= 1) {
1039
+ return Promise.resolve();
1040
+ }
1041
+ this.activeScrollToController?.abort();
1042
+ const waitController = new AbortController();
1043
+ this.activeScrollToController = waitController;
1044
+ const nativeResult = this.viewport.scrollTo({
1045
+ top: clampedTop,
1046
+ left: clampedLeft,
767
1047
  behavior
768
1048
  });
1049
+ if (nativeResult instanceof Promise) {
1050
+ return nativeResult.then(() => {
1051
+ if (this.activeScrollToController === waitController) {
1052
+ this.activeScrollToController = void 0;
1053
+ }
1054
+ });
1055
+ }
1056
+ if (behavior !== "smooth") {
1057
+ if (this.activeScrollToController === waitController) {
1058
+ this.activeScrollToController = void 0;
1059
+ }
1060
+ return Promise.resolve();
1061
+ }
1062
+ return new Promise((resolve) => {
1063
+ let settled = false;
1064
+ let idleTimerId;
1065
+ let maxTimerId;
1066
+ const finish = () => {
1067
+ if (settled) return;
1068
+ settled = true;
1069
+ if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
1070
+ if (maxTimerId !== void 0) window.clearTimeout(maxTimerId);
1071
+ if (this.activeScrollToController === waitController) {
1072
+ this.activeScrollToController = void 0;
1073
+ }
1074
+ waitController.abort();
1075
+ resolve();
1076
+ };
1077
+ waitController.signal.addEventListener("abort", finish, { once: true });
1078
+ this.abortController.signal.addEventListener("abort", finish, { once: true, signal: waitController.signal });
1079
+ if (this.supportsScrollEnd) {
1080
+ this.viewport.addEventListener("scrollend", finish, { once: true, signal: waitController.signal });
1081
+ } else {
1082
+ const bumpIdle = () => {
1083
+ if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
1084
+ idleTimerId = window.setTimeout(finish, 150);
1085
+ };
1086
+ this.viewport.addEventListener("scroll", bumpIdle, { passive: true, signal: waitController.signal });
1087
+ bumpIdle();
1088
+ }
1089
+ maxTimerId = window.setTimeout(finish, 2500);
1090
+ });
769
1091
  }
770
1092
  /**
771
1093
  * Vérifie la conformité d'accessibilité WAI-ARIA de la zone défilable
@@ -778,12 +1100,12 @@ var __WulfIIFE = (() => {
778
1100
  const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
779
1101
  const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
780
1102
  const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
781
- if (!this.hasExplicitAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
1103
+ if (!this.hasExplicitAriaLabel && !this.hasRootAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
782
1104
  warnings.push(
783
1105
  "Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."
784
1106
  );
785
1107
  }
786
- if (this.options.minThumbSize < 24) {
1108
+ if (this.options.mode !== "native" && this.options.minThumbSize < 24) {
787
1109
  warnings.push(
788
1110
  `Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
789
1111
  );
@@ -800,22 +1122,34 @@ var __WulfIIFE = (() => {
800
1122
  * Détruit le composant et libère toutes les ressources.
801
1123
  */
802
1124
  destroy() {
1125
+ if (this.isDestroyed) return;
1126
+ this.isDestroyed = true;
803
1127
  this.clearAutoHideTimer();
1128
+ if (this.scrollEndFallbackTimer !== void 0) {
1129
+ window.clearTimeout(this.scrollEndFallbackTimer);
1130
+ this.scrollEndFallbackTimer = void 0;
1131
+ }
1132
+ if (this.rafId !== null) {
1133
+ window.cancelAnimationFrame(this.rafId);
1134
+ this.rafId = null;
1135
+ }
1136
+ if (this.resizeRafId !== null) {
1137
+ window.cancelAnimationFrame(this.resizeRafId);
1138
+ this.resizeRafId = null;
1139
+ }
1140
+ this.activeScrollToController?.abort();
1141
+ this.activeScrollToController = void 0;
1142
+ this.dragAbortController?.abort();
1143
+ this.dragAbortController = void 0;
1144
+ this.abortController.abort();
804
1145
  if (this.resizeObserver) {
805
1146
  this.resizeObserver.disconnect();
806
1147
  }
807
- this.viewport.removeEventListener("scroll", this.boundOnScroll);
808
- this.root.removeEventListener("mouseenter", this.boundOnMouseEnter);
809
- this.root.removeEventListener("mouseleave", this.boundOnMouseLeave);
810
- this.root.removeEventListener("focusin", this.boundOnFocusIn);
811
- this.root.removeEventListener("focusout", this.boundOnFocusOut);
812
- window.removeEventListener("pointermove", this.boundPointerMove);
813
- window.removeEventListener("pointerup", this.boundPointerUp);
814
- window.removeEventListener("pointercancel", this.boundPointerUp);
815
1148
  this.trackY?.remove();
816
1149
  this.trackX?.remove();
817
1150
  this.root.classList.remove(
818
1151
  "wulf-scrollblock",
1152
+ "wulf-scrollblock--native",
819
1153
  "has-scroll-y",
820
1154
  "has-scroll-x",
821
1155
  "has-both-axes",
@@ -826,7 +1160,7 @@ var __WulfIIFE = (() => {
826
1160
  );
827
1161
  if (this.createdViewport && this.viewport.parentElement === this.root) {
828
1162
  while (this.viewport.firstChild) {
829
- this.root.insertBefore(this.viewport.firstChild, this.viewport);
1163
+ safeMove(this.root, this.viewport.firstChild, this.viewport);
830
1164
  }
831
1165
  this.viewport.remove();
832
1166
  } else {
@@ -837,14 +1171,15 @@ var __WulfIIFE = (() => {
837
1171
  if (this.wasRoleInferred && this.viewport.getAttribute("role") === "region") {
838
1172
  this.viewport.removeAttribute("role");
839
1173
  }
1174
+ if (this.propagatedRootLabel) {
1175
+ this.viewport.removeAttribute(this.propagatedRootLabel);
1176
+ }
840
1177
  if (this.wasAriaLabelInferred && this.viewport.getAttribute("aria-label") === this.lastInferredAriaLabel) {
841
1178
  this.viewport.removeAttribute("aria-label");
842
1179
  }
843
1180
  }
844
1181
  }
845
1182
  };
846
- ScrollBlock._i18n = scrollI18n;
847
- ScrollBlock.i18n = scrollI18n;
848
1183
 
849
1184
  // src/scroll/index.ts
850
1185
  var Scroll = {
@@ -852,13 +1187,11 @@ var __WulfIIFE = (() => {
852
1187
  i18n: scrollI18n
853
1188
  };
854
1189
  var index_default = ScrollBlock;
855
- if (typeof window !== "undefined") {
856
- const win = window;
857
- const wulfNamespace = win.Wulf || {};
858
- win.Wulf = wulfNamespace;
1190
+ var wulfNamespace = getSafeWulfNamespace();
1191
+ if (wulfNamespace) {
859
1192
  wulfNamespace.Scroll = Scroll;
860
1193
  }
861
1194
  return __toCommonJS(index_exports);
862
1195
  })();
863
- if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.prototype.hasOwnProperty.call(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
1196
+ if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.hasOwn(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && __w[k] === undefined) { try { Object.defineProperty(__w, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { __w[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
864
1197
  //# sourceMappingURL=scroll.global.js.map